-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[GStreamer][MSE] Append pipeline is counting streams incorrectly with new init segments #12114
Conversation
EWS run on previous version of this PR (hash c6ddc06) |
Some tests fail. I need to investigate. |
EWS run on previous version of this PR (hash 47e70b6) |
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.
Thanks for this patch.
gst_pad_get_stream_id()
is a great find. I have been able to confirm through looking at the source code that both qtdemux and matroskademux emit the track IDs found in the containers metadata (namely the tkhd
box for MP4 and the TrackNumber:TrackUID pair for Matroska/WebM), and this is not a new feature, already being present in GStreamer 1.10 and earlier.
So far, for lack of a way to get these bits of information, AppendPipeline has been using pad indices as track IDs (see AppendPipeline::generateTrackId()
), so the first video pad gets V1, the second V2 and so on...
Now, taking this into consideration, it makes sense to update the code and replace the autogenerated track IDs with actual track IDs from GStreamer. I also noticed that the MediaSource spec requires track IDs exposed to the user to be distinct but doesn't specify they need to match the exact values in tkhd (although the engine internally must match those).
Something I've been wondering about this patch is, how are we handling recycling pads? This is the current code for matching tracks and pads:
// Try to find a matching pre-existing track. Ideally, tracks should be matched by track ID, but matching by type
// is provided as a fallback -- which will be used, since we don't have a way to fetch those from GStreamer at the moment.
Track* matchingTrack = nullptr;
for (std::unique_ptr<Track>& track : m_tracks) {
if (track->streamType != streamType)
continue;
matchingTrack = &*track;
if (track->trackId == trackId)
break;
}
Assuming pad indices are consistent, our code should still work. For that reason, this patch LGTM as it is. Feel free to rework the track IDs to use the data from GStreamer stream IDs if you want, but that can be a future patch as well, leaving this fix contained.
Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp
Outdated
Show resolved
Hide resolved
EWS run on current version of this PR (hash b483c02) |
β¦ new init segments https://bugs.webkit.org/show_bug.cgi?id=254664 Reviewed by Alicia Boya Garcia. When you append another init segment we match GStreamer pads against tracks but we are not counting properly as we are skipping the pads that are already linked we can end up with less pads than tracks. Besides it is against the spec. We need to match the number of tracks and track IDs if there are more than one for a kind. * LayoutTests/media/media-source/media-source-seek-detach-crash.html: Fail the test earlier instead of waiting for a timeout. * LayoutTests/platform/glib/TestExpectations: Unmark media/encrypted-media/encrypted-media-append-encrypted-unencrypted.html as failure. It works now. * Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp: (WebCore::AppendPipeline::didReceiveInitializationSegment): (WebCore::AppendPipeline::recycleTrackForPad): Canonical link: https://commits.webkit.org/264676@main
b483c02
to
847e28d
Compare
Committed 264676@main (847e28d): https://commits.webkit.org/264676@main Reviewed commits have been landed. Closing PR #12114 and removing active labels. |
847e28d
b483c02
π§ͺ ios-wk2π§ͺ api-macπ§ͺ gtk-wk2π§ͺ mac-wk2