Comments (1)
@at-wat about this issue, I was thinking to create a meta transformer which will return the same data, but it'll listen to changes in the data itself, and will inform the caller through a callback. So, in a sketch, it will like like the following:
// not really sure what to call this..
type VideoPropertyOnChange func(prev, current prop.Media)
func NewVideoPropertyListener(onChange VideoPropertyOnChange) video.TransformFunc {
var prevProp, currentProp prop.Media
return video.TransformFunc(func(r video.Reader) video.Reader {
return func() (img image.Image, err error) {
img, err = r.Read()
if err == nil {
// detect changes here
// store the currentProp to preProp, and get the currentProp
onChange(prevProp, currentProp)
}
return
}
})
}
For getting the first property, the caller just needs to wait for the first callback to get called. Since the data flows after the callback is called, the caller will have a chance to pre-setup things. A useful thing from this property is probably when we want to adjust an encoder. Instead of initializing the encoder manually, we would simply listen to this callback and have a flag to mark the first callback. For the rest of callbacks, it would be just adjusting the existing encoding session.
Overall, I think this approach is somewhat similar to Gstreamer's Autoplugging, https://gstreamer.freedesktop.org/documentation/application-development/advanced/autoplugging.html?gi-language=python.
What do you think about this approach?
from mediadevices.
Related Issues (20)
- Compile error when using `codec/opus` in Ubuntu 22.04
- What is wrong with the C interface for opus opus_encoder_create ? HOT 2
- Closing media track causes panic
- Colour difference in generated video stream HOT 1
- How does screen capture work on Windows vs Linux? HOT 2
- ForceKeyFrame HOT 3
- Failed to start streaming: invalid argument HOT 5
- go build linux error HOT 3
- Add pion/.goassets
- GCC problem on Windows 10 HOT 1
- Display mouse cursor HOT 1
- Video not showing in video element in latest versions of chrome. HOT 5
- why does opening dev console in http example crash the server?
- rtp example problems
- Distorted audio capture on linux. HOT 5
- failed to find the best driver that fits the constraints to open usb camera HOT 1
- Multiple display for webcam device HOT 2
- use mediadevices.GetUserMedia() failed. err: failed to open device: failed to connect filters HOT 2
- jetson agx xavier ubuntu20.04 fail run HOT 2
- webrtc demo mic Sound tearing sensation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mediadevices.