Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MSE][GStreamer] Support Google Dynamic Ad Insertion (DAI)
https://bugs.webkit.org/show_bug.cgi?id=216039 <rdar://problem/68638316> Patch by Philippe Normand <philn@igalia.com> on 2022-05-25 Reviewed by Alicia Boya Garcia. The "simple DAI" demo was not working as expected because the new source pad of the demuxer in the append pipeline was sinking buffers to a "black hole". That was happening because the second time the no-more-pads signal was emitted, the previous source pad was still linked to a track, and there was no code to unlink/relink demuxer pads. This is now handled... The specific "simple DAI" demo generates 2 AAC streams, with different tkhd track-id fields, we had no layout test reproducing this use-case, so this patch provides one. Test: media-source/media-source-audio-track-id-switch.html * LayoutTests/media/media-source/content/test-48kHz-new-track-id.m4a: Added. * LayoutTests/media/media-source/content/test-48khz-new-track-id-manifest.json: Added. * LayoutTests/media/media-source/media-source-audio-track-id-switch-expected.txt: Added. * LayoutTests/media/media-source/media-source-audio-track-id-switch.html: Added. * Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp: (WebCore::AppendPipeline::handleErrorSyncMessage): (WebCore::AppendPipeline::didReceiveInitializationSegment): (WebCore::createOptionalParserForFormat): (WebCore::AppendPipeline::recycleTrackForPad): (WebCore::AppendPipeline::linkPadWithTrack): (WebCore::AppendPipeline::tryMatchPadToExistingTrack): Deleted. * Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.h: (WebCore::AppendPipeline::Track::isLinked const): Canonical link: https://commits.webkit.org/250950@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294791 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
1 parent
7003d0d
commit 296d132
Showing
6 changed files
with
165 additions
and
22 deletions.
There are no files selected for viewing
Binary file not shown.
19 changes: 19 additions & 0 deletions
19
LayoutTests/media/media-source/content/test-48khz-new-track-id-manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"url": "content/test-48kHz-new-track-id.m4a", | ||
"type": "audio/mp4; codecs=\"mp4a.40.2\"", | ||
"init": { "offset": 0, "size": 624 }, | ||
"duration": 10.0906, | ||
"media": [ | ||
{ "offset": 624, "size": 1308, "timestamp": 0, "duration": 1.0027}, | ||
{ "offset": 1932, "size": 1491, "timestamp": 1.0027, "duration": 1.0027}, | ||
{ "offset": 3423, "size": 1341, "timestamp": 2.0053, "duration": 1.0027}, | ||
{ "offset": 4764, "size": 1563, "timestamp": 3.008, "duration": 0.9813}, | ||
{ "offset": 6327, "size": 1425, "timestamp": 3.9893, "duration": 1.0027}, | ||
{ "offset": 7752, "size": 1770, "timestamp": 4.992, "duration": 1.0027}, | ||
{ "offset": 9522, "size": 1910, "timestamp": 5.9947, "duration": 1.0027}, | ||
{ "offset": 11432, "size": 1887, "timestamp": 6.9973, "duration": 1.0027}, | ||
{ "offset": 13319, "size": 1919, "timestamp": 8, "duration": 1.0027}, | ||
{ "offset": 15238, "size": 1892, "timestamp": 9.0027, "duration": 1.0027}, | ||
{ "offset": 17130, "size": 1231, "timestamp": 10.0053, "duration": 0.0853} | ||
] | ||
} |
12 changes: 12 additions & 0 deletions
12
LayoutTests/media/media-source/media-source-audio-track-id-switch-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
RUN(audio.src = URL.createObjectURL(source)) | ||
EVENT(sourceopen) | ||
RUN(source.duration = loader.duration()) | ||
RUN(sourceBuffer = source.addSourceBuffer(loader.type())) | ||
RUN(sourceBuffer.appendBuffer(loader.initSegment())) | ||
EVENT(updateend) | ||
Switching to a similar audio stream but with different mp4 track ID. | ||
RUN(sourceBuffer.appendBuffer(loader.initSegment())) | ||
EVENT(updateend) | ||
END OF TEST | ||
|
55 changes: 55 additions & 0 deletions
55
LayoutTests/media/media-source/media-source-audio-track-id-switch.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>media-source-audio-track-id-switch</title> | ||
<script src="media-source-loader.js"></script> | ||
<script src="../video-test.js"></script> | ||
<script> | ||
var loader; | ||
var source; | ||
var sourceBuffer; | ||
var audio; | ||
|
||
function runTest() { | ||
audio = document.getElementsByTagName('audio')[0]; | ||
|
||
loader = new MediaSourceLoader('content/test-48khz-manifest.json'); | ||
loader.onload = mediaDataLoaded; | ||
loader.onerror = mediaDataLoadingFailed; | ||
} | ||
|
||
function mediaDataLoadingFailed() { | ||
failTest('Media data loading failed'); | ||
} | ||
|
||
function mediaDataLoaded() { | ||
source = new MediaSource(); | ||
waitForEvent('sourceopen', sourceOpen, false, false, source); | ||
run('audio.src = URL.createObjectURL(source)'); | ||
} | ||
|
||
function sourceOpen() { | ||
run('source.duration = loader.duration()'); | ||
run('sourceBuffer = source.addSourceBuffer(loader.type())'); | ||
sourceBuffer.addEventListener('error', mediaDataLoadingFailed); | ||
waitForEventOn(sourceBuffer, 'updateend', sourceInitialized, false, true); | ||
run('sourceBuffer.appendBuffer(loader.initSegment())'); | ||
} | ||
|
||
function sourceInitialized() { | ||
consoleWrite('Switching to a similar audio stream but with different mp4 track ID.') | ||
loader = new MediaSourceLoader('content/test-48khz-new-track-id-manifest.json'); | ||
loader.onload = newTrackMediaDataLoaded; | ||
loader.onerror = mediaDataLoadingFailed; | ||
} | ||
|
||
function newTrackMediaDataLoaded() { | ||
waitForEventOn(sourceBuffer, 'updateend', endTest, false, true); | ||
run('sourceBuffer.appendBuffer(loader.initSegment())'); | ||
} | ||
</script> | ||
</head> | ||
<body onload="runTest()"> | ||
<audio controls/> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters