Skip to content

remove-gostream-dep-on-mediadevices #4983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nicksanford
Copy link
Member

Mediadevices's camera driver's init function, defined in camera_PLATFORM.go, runs C code within it's init() function that tries to discover webcams but doesn't always work on all platforms, sometimes causing the OS process to crash:

https://github.com/pion/mediadevices/blob/v0.6.4/pkg/driver/camera/camera_linux.go
https://github.com/pion/mediadevices/blob/v0.6.4/pkg/driver/camera/camera_darwin.go
https://github.com/pion/mediadevices/blob/v0.6.4/pkg/driver/camera/camera_windows.go

Currently, any module that has a transitive dependency on the RDK camera interface also depends on gostream, and as a consequence, will execute the media devices camera driver's init function on os process startup.

This is completely unnecessary as the only reason why gostream depended on mediadevices is to import a constant.

This code change removes the gostream -> mediadevices dependency, reducing the times when module implementers will unexpectedly.

Long term, we should consider removing the dependency on mediadevices altogether by moving the builtin webcam camera to a module.

@nicksanford nicksanford marked this pull request as ready for review May 12, 2025 18:09
@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label May 12, 2025
Comment on lines -365 to -370
for _, label := range labels {
if label == target {
return true
}
}
return false
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated cleanup

Comment on lines -379 to -385
labels := strings.Split(d.Info().Label, camera.LabelSeparator)
for _, label := range labels {
if labelPattern.MatchString(label) {
return true
}
}
return false
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated cleanup

Comment on lines -30 to -32
constraint.Width = prop.IntRanged{640, 4096, 1920}
constraint.Height = prop.IntRanged{400, 2160, 1080}
constraint.FrameRate = prop.FloatRanged{0, 200, 60}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated cleanup

@seanavery
Copy link
Member

@nicksanford Have we verified that using camera package from RDK no longer includes mediadevices as a dependency?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants