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
[sailfishos][webrtc] Enable support for WebRTC video. JB#53982 #3
Conversation
+namespace webrtc { | ||
+namespace videocapturemodule { | ||
+ | ||
+#define GST_DROID_CAMERA_PRIMARY "primary" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these still valid? I think we have to use the camera number now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is reported as camera ID, see GstDroidCameraManager::GetDeviceName()
below. These names are later translated to native wording, see https://github.com/sailfishos/sailfish-components-webview/blob/7b47472eac71d31792bff2ee6766e03683a890e2/import/popups/WebrtcPermissionDialog.qml#L36
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not able to do much more than a sanity check of the code I'm afraid. It broadly looks sensible and builds fine. I've made a few comments, but nothing major.
However, when I tried it on an XA2 with gmp-droid-0.2-1.2.1 I got some strange output when testing it with the meetecho Janus test server you recommended. I get the same results with both the front and back cameras, but I don't know why this is I'm afraid.
ipc::Shmem* aMem) = 0; | ||
virtual void Dealloc(ipc::Shmem& aMem) = 0; | ||
|
||
+ Mutex mMutex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I accidentally left it public. Thank you.
// 3* is because we're using 3 buffers per frame for i420 data for now. | ||
- if ((NumInUse(GMPSharedMem::kGMPFrameData) > | ||
- 3 * GMPSharedMem::kGMPBufLimit) || | ||
+ if ((NumInUse(GMPSharedMem::kGMPFrameData) > 3 * GMPSharedMem::kGMPBufLimit) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is just an accidental formatting change. If so, it might be better to skip it from the patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I've been fiddling with these lines. This is a candidate for future revision. Will remove this from the patch.
- 3 * GMPSharedMem::kGMPBufLimit) || | ||
+ if ((NumInUse(GMPSharedMem::kGMPFrameData) > 3 * GMPSharedMem::kGMPBufLimit) || | ||
(NumInUse(GMPSharedMem::kGMPEncodedData) > GMPSharedMem::kGMPBufLimit)) { | ||
+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly here; the extra newline looks unintentional.
rpm/0069-sailfishos-webrtc-Enable-GMP-for-encoding.-JB-53982.patch
Outdated
Show resolved
Hide resolved
rpm/0069-sailfishos-webrtc-Enable-GMP-for-encoding.-JB-53982.patch
Outdated
Show resolved
Hide resolved
+ | ||
+ if (deviceNameLength >= strlen(cameraName)) | ||
+ { | ||
+ memcpy(deviceNameUTF8, cameraName, strlen(cameraName)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If deviceNameLength == strlen(cameraName)
then this could leave deviceNameUTF8
without a null terminator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. I copied this code from media/webrtc/trunk/webrtc/modules/video_capture/linux/
and edited just to fit my internal Camera interface. I never tested it and it is not listed in supported camera types. Will review that better.
+ char* deviceUniqueIdUTF8, | ||
+ uint32_t deviceUniqueIdUTF8Length, | ||
+ char* productUniqueIdUTF8, | ||
+ uint32_t productUniqueIdUTF8Length, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it matter that productUniqueIdUTF8
is never populated (in particular, is there any danger the caller will assume the return value will be null terminated)?
+ { | ||
+ memset(deviceUniqueIdUTF8, 0, deviceUniqueIdUTF8Length); | ||
+ memcpy(deviceUniqueIdUTF8, cap.bus_info, | ||
+ strlen((const char*) cap.bus_info)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if deviceUniqueIdUTF8Length == strlen((const char*) cap.bus_info)
this could leave the returned buffer without a null terminator I think.
+ rtc::scoped_refptr<Camera> OpenCamera (const char* deviceUniqueIdUTF8); | ||
+private: | ||
+ int32_t FillCapabilities(int fd, std::vector<VideoCaptureCapability>& caps); | ||
+ unsigned _numberOfDevices; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is _numberOfDevices
needed? It looks unused.
rpm/0070-sailfishos-webrtc-Implement-video-capture-module.-JB.patch
Outdated
Show resolved
Hide resolved
That's bad. Looks like the image format from viewfinder is totally different. I have no access to XA2 to check, and gecko is cut off the logging in production build. I will ask is someone has the device. |
rpm/0070-sailfishos-webrtc-Implement-video-capture-module.-JB.patch
Outdated
Show resolved
Hide resolved
rpm/0070-sailfishos-webrtc-Implement-video-capture-module.-JB.patch
Outdated
Show resolved
Hide resolved
f0cdb8f
to
d31b1f3
Compare
Although I tested it on a sony device and it works, I found out that sony's video encoder doesn't support I420 pixel format input. The problem is in gmp-droid, a fix PR is coming soon. Unfortunately sony uses semi-planar format internally, which is not compatible with gecko's internals. Gecko has surprisingly bad design of video input, however I see some optimization opportunities here. |
This patch uses https://github.com/d-grigorev/amber-camera/tree/initial as a video input library. It contains two specs, a library and a plugin. The plugin uses droidmedia-devel at build time and droidmedia at runtime. |
The encoder issue is fixed in sailfishos/gmp-droid#15. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once I resolved the issue with applying the last patch the echo test worked on an Xperia XA2 which was one of the earlier problem devices.
Not a lot stands out in the code otherwise.
I guess we'll need to sort out a process for promoting and reviewing amber-camera as well. The standout thing to me is there might be some similar push back to the separate spec file for the droidmedia plugin. It might be better received if it's in a separate project, or combined into a single spec with conditions.
rpm/0071-sailfishos-webrtc-Implement-video-capture-module.-JB.patch
Outdated
Show resolved
Hide resolved
rpm/0071-sailfishos-webrtc-Implement-video-capture-module.-JB.patch
Outdated
Show resolved
Hide resolved
rpm/0071-sailfishos-webrtc-Implement-video-capture-module.-JB.patch
Outdated
Show resolved
Hide resolved
The lawers gave permission to contibute it to github.com/sailfishos, so what are next steps?. You can leave comments in https://github.com/d-grigorev/amber-camera/pull/1.
Isn't that convenient to have multiple specs? amber-camera headers should be accessible from pj:oss, amber-camera-droid-plugin should be built in a (common) adaptation project. The spec will be chosen depending on the OBS project name - looks clear for me. What are the disadvantages? |
An admin will need to create the project under the sailfishos group. Could you create a task in bugzilla requesting it?
Refer to the discussion in the droidmedia split bug. I argued for separate files there because droidmedia in a unique project, but based on that I would expect a similar objection again. |
Changes from the previous version:
|
Changes from the previous version:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still want to verify this works on a Jolla C and I checked in on the promotion build of the droidmedia changes this depends on and there's a couple compilation failures related to age of the build environment.
But if I can see this working there, I think I'm ready to approve.
Unfortunately I don't have a Jolla C. The code for YCbCr template may need to be fixed in gecko-camera, if the picture is weird.
Thank you. I have a fix for audio getting out of sync with video in the incoming stream, but I think it is matter of the following commits. |
The droidmedia promotion has succeeded on that hardware now. And it appears to work without any display issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it's ready now.
No description provided.