Bug 190035 - [GStreamer] Fix EncodedImage timestamps to match what libWebRTC expects
Summary: [GStreamer] Fix EncodedImage timestamps to match what libWebRTC expects
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Thibault Saunier
URL:
Keywords: InRadar
Depends on: 190678
Blocks: 187064 190682
  Show dependency treegraph
 
Reported: 2018-09-27 06:13 PDT by Thibault Saunier
Modified: 2018-11-05 23:15 PST (History)
5 users (show)

See Also:


Attachments
Patch (4.40 KB, patch)
2018-09-27 06:18 PDT, Thibault Saunier
no flags Details | Formatted Diff | Diff
Patch (14.25 KB, patch)
2018-10-17 12:39 PDT, Thibault Saunier
no flags Details | Formatted Diff | Diff
Patch (14.25 KB, patch)
2018-11-05 09:19 PST, Thibault Saunier
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thibault Saunier 2018-09-27 06:13:15 PDT
[GStreamer] Fix EncodedImage timestamps to match what libWebRTC expects
Comment 1 Thibault Saunier 2018-09-27 06:18:37 PDT
Created attachment 350957 [details]
Patch
Comment 2 Alejandro G. Castro 2018-09-27 07:55:51 PDT
Comment on attachment 350957 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=350957&action=review

Great catch, tricky problem, LGTM with some small changes.

> Source/WebCore/ChangeLog:12
> +        all the GStreamer processing pipelines as the WebRTC object basically wrap the "same"

Nit, wrap -> wraps

> Source/WebCore/ChangeLog:26
> +        because of that issue.

Nit, is this a leftover?

> Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp:424
> +    std::map<GstClockTime, RtpTimestamps> m_ptsRtpTimestampMap;

We usually use HashMap type defined in WTF, is there any feature in the std::maps that we want to use?
Comment 3 Thibault Saunier 2018-10-17 12:39:14 PDT
Created attachment 352612 [details]
Patch
Comment 4 Thibault Saunier 2018-11-05 09:19:32 PST
Created attachment 353868 [details]
Patch
Comment 5 Philippe Normand 2018-11-05 10:40:45 PST
Comment on attachment 353868 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=353868&action=review

> Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp:70
> +        , m_adapter(adoptGRef(gst_adapter_new()))

Hum. I think this needs a GRefPtrGStreamer template specialization to avoid leaks.
Comment 6 Philippe Normand 2018-11-05 10:43:30 PST
Comment on attachment 353868 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=353868&action=review

>> Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp:70
>> +        , m_adapter(adoptGRef(gst_adapter_new()))
> 
> Hum. I think this needs a GRefPtrGStreamer template specialization to avoid leaks.

Ah no, it's a normal GObject. Nevermind :)
Comment 7 WebKit Commit Bot 2018-11-05 11:15:22 PST
Comment on attachment 353868 [details]
Patch

Clearing flags on attachment: 353868

Committed r237819: <https://trac.webkit.org/changeset/237819>
Comment 8 WebKit Commit Bot 2018-11-05 11:15:23 PST
All reviewed patches have been landed.  Closing bug.
Comment 9 Radar WebKit Bug Importer 2018-11-05 11:16:24 PST
<rdar://problem/45813371>
Comment 10 Xabier Rodríguez Calvar 2018-11-05 23:15:41 PST
Comment on attachment 353868 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=353868&action=review

I'm late, but if there's any follow up, we can fix this couple of things.

> Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.cpp:242
> +        m_bufferMapLock.lock();
> +        // Make sure that the frame.timestamp == previsouly input_frame._timeStamp
> +        // as it is required by the VideoDecoder baseclass.
> +        auto timestamps = m_dtsPtsMap[GST_BUFFER_PTS(buffer)];
> +        m_dtsPtsMap.erase(GST_BUFFER_PTS(buffer));
> +        m_bufferMapLock.unlock();

Nit: I would have used a Locker here by either using unlockEarly or just using { } to create scope.

Besides, previsouly -> previously.

> Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp:266
> +                uint flags = GST_BUFFER_FLAGS(buffer);

unsigned