From d23cce85b93263a4c7541d9761145be54dd1348d Mon Sep 17 00:00:00 2001 From: Cosmin Stejerean Date: Fri, 23 Feb 2024 15:45:46 -0800 Subject: [PATCH] feat: add startwithSAP/subsegmentstartswithSAP for audio tracks (#1346) Add startwithSAP/subsegmentstartswithSAP for aac, ac3, ec3 and ac4 audio tracks according to LIVE or VOD profile. Replaces #1055 Partial solution for #364 --------- Co-authored-by: Xingzhao Yun Co-authored-by: Joey Parrish --- packager/app/test/testdata/acc-he/output.mpd | 2 +- .../output.mpd | 2 +- .../output.mpd | 2 +- .../output.mpd | 2 +- .../output.mpd | 2 +- .../output.mpd | 2 +- .../output.mpd | 2 +- .../output.mpd | 2 +- .../audio-video-with-trick-play/output.mpd | 2 +- .../output.mpd | 2 +- .../app/test/testdata/audio-video/output.mpd | 2 +- .../app/test/testdata/avc-aac-ts/output.mpd | 2 +- .../output.mpd | 2 +- .../testdata/bandwidth-override/output.mpd | 2 +- .../app/test/testdata/dash-label/output.mpd | 2 +- .../output.mpd | 4 ++-- .../output.mpd | 4 ++-- .../encryption-and-ad-cues/output.mpd | 4 ++-- .../encryption-and-no-clear-lead/output.mpd | 2 +- .../output.mpd | 2 +- .../encryption-and-non-dash-if-iop/output.mpd | 2 +- .../output.mpd | 2 +- .../encryption-and-trick-play/output.mpd | 2 +- .../encryption-and-two-trick-plays/output.mpd | 2 +- .../test/testdata/encryption-cbc-1/output.mpd | 2 +- .../output.mpd | 2 +- .../test/testdata/encryption-cbcs/output.mpd | 2 +- .../test/testdata/encryption-cens/output.mpd | 2 +- .../output.mpd | 2 +- .../testdata/encryption-multi-keys/output.mpd | 2 +- .../output.mpd | 2 +- .../encryption-using-explicit-pssh/output.mpd | 2 +- .../encryption-using-fixed-key/output.mpd | 2 +- .../encryption-with-multi-drms/output.mpd | 2 +- .../app/test/testdata/encryption/output.mpd | 2 +- .../forced-commandline-ordering/output.mpd | 2 +- .../test/testdata/forced-subtitle/output.mpd | 2 +- .../hls-only-dash-only-captions/output.mpd | 2 +- .../testdata/hls-only-dash-only/output.mpd | 2 +- .../output.mpd | 2 +- .../output.mpd | 2 +- .../live-profile-and-encryption/output.mpd | 2 +- .../output.mpd | 2 +- .../output.mpd | 2 +- .../output.mpd | 2 +- .../live-profile-and-key-rotation/output.mpd | 2 +- .../app/test/testdata/live-profile/output.mpd | 2 +- .../output.mpd | 2 +- .../testdata/live-static-profile/output.mpd | 2 +- .../testdata/mp4-trailing-moov/output.mpd | 2 +- .../test/testdata/video-audio-ttml/output.mpd | 2 +- .../testdata/video-audio-webvtt/output.mpd | 2 +- .../vtt-text-to-mp4-with-ad-cues/output.mpd | 4 ++-- .../output.mpd | 2 +- .../app/test/testdata/wvm-input/output.mpd | 2 +- packager/mpd/base/adaptation_set.cc | 22 ++++++++++++++++--- packager/mpd/base/adaptation_set.h | 21 ++++++++++++++++-- packager/mpd/base/period.cc | 13 +++++++++-- packager/mpd/base/period_unittest.cc | 4 ++-- ..._video_media_info1_expected_mpd_output.txt | 2 +- 60 files changed, 111 insertions(+), 69 deletions(-) diff --git a/packager/app/test/testdata/acc-he/output.mpd b/packager/app/test/testdata/acc-he/output.mpd index 229ef2b15f..e0376baa3d 100644 --- a/packager/app/test/testdata/acc-he/output.mpd +++ b/packager/app/test/testdata/acc-he/output.mpd @@ -2,7 +2,7 @@ - + bear-640x360-aac_he-silent_right-audio.mp4 diff --git a/packager/app/test/testdata/audio-video-with-accessibilities-and-roles/output.mpd b/packager/app/test/testdata/audio-video-with-accessibilities-and-roles/output.mpd index 32c93b2fe7..3c01ae5ee4 100644 --- a/packager/app/test/testdata/audio-video-with-accessibilities-and-roles/output.mpd +++ b/packager/app/test/testdata/audio-video-with-accessibilities-and-roles/output.mpd @@ -2,7 +2,7 @@ - + diff --git a/packager/app/test/testdata/audio-video-with-codec-switching-and-forced-commandline_order/output.mpd b/packager/app/test/testdata/audio-video-with-codec-switching-and-forced-commandline_order/output.mpd index 4dbb0e2019..3ff2faa158 100644 --- a/packager/app/test/testdata/audio-video-with-codec-switching-and-forced-commandline_order/output.mpd +++ b/packager/app/test/testdata/audio-video-with-codec-switching-and-forced-commandline_order/output.mpd @@ -2,7 +2,7 @@ - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/audio-video-with-codec-switching-encryption-trick-play/output.mpd b/packager/app/test/testdata/audio-video-with-codec-switching-encryption-trick-play/output.mpd index d33134418d..b5b8344745 100644 --- a/packager/app/test/testdata/audio-video-with-codec-switching-encryption-trick-play/output.mpd +++ b/packager/app/test/testdata/audio-video-with-codec-switching-encryption-trick-play/output.mpd @@ -49,7 +49,7 @@ - + AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== diff --git a/packager/app/test/testdata/audio-video-with-codec-switching/output.mpd b/packager/app/test/testdata/audio-video-with-codec-switching/output.mpd index 63c949e4d6..5504466c18 100644 --- a/packager/app/test/testdata/audio-video-with-codec-switching/output.mpd +++ b/packager/app/test/testdata/audio-video-with-codec-switching/output.mpd @@ -28,7 +28,7 @@ - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/audio-video-with-language-override-with-subtag/output.mpd b/packager/app/test/testdata/audio-video-with-language-override-with-subtag/output.mpd index e3bd7b5a80..00bec7e215 100644 --- a/packager/app/test/testdata/audio-video-with-language-override-with-subtag/output.mpd +++ b/packager/app/test/testdata/audio-video-with-language-override-with-subtag/output.mpd @@ -2,7 +2,7 @@ - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/audio-video-with-language-override/output.mpd b/packager/app/test/testdata/audio-video-with-language-override/output.mpd index 3a04fe7567..c75de98f00 100644 --- a/packager/app/test/testdata/audio-video-with-language-override/output.mpd +++ b/packager/app/test/testdata/audio-video-with-language-override/output.mpd @@ -2,7 +2,7 @@ - + diff --git a/packager/app/test/testdata/audio-video-with-trick-play-and-forced-commandline-order/output.mpd b/packager/app/test/testdata/audio-video-with-trick-play-and-forced-commandline-order/output.mpd index 3e6bb8c966..95cb7de42c 100644 --- a/packager/app/test/testdata/audio-video-with-trick-play-and-forced-commandline-order/output.mpd +++ b/packager/app/test/testdata/audio-video-with-trick-play-and-forced-commandline-order/output.mpd @@ -2,7 +2,7 @@ - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/audio-video-with-trick-play/output.mpd b/packager/app/test/testdata/audio-video-with-trick-play/output.mpd index f2ed8f3c10..05e5387dac 100644 --- a/packager/app/test/testdata/audio-video-with-trick-play/output.mpd +++ b/packager/app/test/testdata/audio-video-with-trick-play/output.mpd @@ -2,7 +2,7 @@ - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/audio-video-with-two-trick-play/output.mpd b/packager/app/test/testdata/audio-video-with-two-trick-play/output.mpd index 560d57adaf..dd692cffdd 100644 --- a/packager/app/test/testdata/audio-video-with-two-trick-play/output.mpd +++ b/packager/app/test/testdata/audio-video-with-two-trick-play/output.mpd @@ -2,7 +2,7 @@ - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/audio-video/output.mpd b/packager/app/test/testdata/audio-video/output.mpd index ba7a0c5612..fe3119bb05 100644 --- a/packager/app/test/testdata/audio-video/output.mpd +++ b/packager/app/test/testdata/audio-video/output.mpd @@ -2,7 +2,7 @@ - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/avc-aac-ts/output.mpd b/packager/app/test/testdata/avc-aac-ts/output.mpd index 65a525535e..a238464544 100644 --- a/packager/app/test/testdata/avc-aac-ts/output.mpd +++ b/packager/app/test/testdata/avc-aac-ts/output.mpd @@ -2,7 +2,7 @@ - + diff --git a/packager/app/test/testdata/avc-ts-live-playlist-dash-dynamic-with-segment-deletion/output.mpd b/packager/app/test/testdata/avc-ts-live-playlist-dash-dynamic-with-segment-deletion/output.mpd index 3cbc98eccc..762fd7c69b 100644 --- a/packager/app/test/testdata/avc-ts-live-playlist-dash-dynamic-with-segment-deletion/output.mpd +++ b/packager/app/test/testdata/avc-ts-live-playlist-dash-dynamic-with-segment-deletion/output.mpd @@ -2,7 +2,7 @@ - + diff --git a/packager/app/test/testdata/bandwidth-override/output.mpd b/packager/app/test/testdata/bandwidth-override/output.mpd index dd59d81a02..21e779f058 100644 --- a/packager/app/test/testdata/bandwidth-override/output.mpd +++ b/packager/app/test/testdata/bandwidth-override/output.mpd @@ -2,7 +2,7 @@ - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/dash-label/output.mpd b/packager/app/test/testdata/dash-label/output.mpd index 537849bb38..7bcd23108f 100644 --- a/packager/app/test/testdata/dash-label/output.mpd +++ b/packager/app/test/testdata/dash-label/output.mpd @@ -11,7 +11,7 @@ - + diff --git a/packager/app/test/testdata/encryption-and-ad-cues-and-dash-trick-play/output.mpd b/packager/app/test/testdata/encryption-and-ad-cues-and-dash-trick-play/output.mpd index 7cbfc7ec85..0ec3c23e7c 100644 --- a/packager/app/test/testdata/encryption-and-ad-cues-and-dash-trick-play/output.mpd +++ b/packager/app/test/testdata/encryption-and-ad-cues-and-dash-trick-play/output.mpd @@ -2,7 +2,7 @@ - + AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== @@ -42,7 +42,7 @@ - + AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== diff --git a/packager/app/test/testdata/encryption-and-ad-cues-split-content/output.mpd b/packager/app/test/testdata/encryption-and-ad-cues-split-content/output.mpd index d3f3269f48..74006ed7b4 100644 --- a/packager/app/test/testdata/encryption-and-ad-cues-split-content/output.mpd +++ b/packager/app/test/testdata/encryption-and-ad-cues-split-content/output.mpd @@ -2,7 +2,7 @@ - + AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== @@ -29,7 +29,7 @@ - + AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== diff --git a/packager/app/test/testdata/encryption-and-ad-cues/output.mpd b/packager/app/test/testdata/encryption-and-ad-cues/output.mpd index 92231ba2f5..50050924c6 100644 --- a/packager/app/test/testdata/encryption-and-ad-cues/output.mpd +++ b/packager/app/test/testdata/encryption-and-ad-cues/output.mpd @@ -2,7 +2,7 @@ - + AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== @@ -29,7 +29,7 @@ - + AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== diff --git a/packager/app/test/testdata/encryption-and-no-clear-lead/output.mpd b/packager/app/test/testdata/encryption-and-no-clear-lead/output.mpd index 494ba28b60..99574347e4 100644 --- a/packager/app/test/testdata/encryption-and-no-clear-lead/output.mpd +++ b/packager/app/test/testdata/encryption-and-no-clear-lead/output.mpd @@ -2,7 +2,7 @@ - + AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== diff --git a/packager/app/test/testdata/encryption-and-no-pssh-in-stream/output.mpd b/packager/app/test/testdata/encryption-and-no-pssh-in-stream/output.mpd index 0dc8b94c8d..377e3198f8 100644 --- a/packager/app/test/testdata/encryption-and-no-pssh-in-stream/output.mpd +++ b/packager/app/test/testdata/encryption-and-no-pssh-in-stream/output.mpd @@ -2,7 +2,7 @@ - + AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== diff --git a/packager/app/test/testdata/encryption-and-non-dash-if-iop/output.mpd b/packager/app/test/testdata/encryption-and-non-dash-if-iop/output.mpd index cf597e8577..9b0a75df76 100644 --- a/packager/app/test/testdata/encryption-and-non-dash-if-iop/output.mpd +++ b/packager/app/test/testdata/encryption-and-non-dash-if-iop/output.mpd @@ -2,7 +2,7 @@ - + diff --git a/packager/app/test/testdata/encryption-and-output-media-info-and-mpd-from-media-info-segmentlist/output.mpd b/packager/app/test/testdata/encryption-and-output-media-info-and-mpd-from-media-info-segmentlist/output.mpd index 4c04f2a6e0..26636f0451 100644 --- a/packager/app/test/testdata/encryption-and-output-media-info-and-mpd-from-media-info-segmentlist/output.mpd +++ b/packager/app/test/testdata/encryption-and-output-media-info-and-mpd-from-media-info-segmentlist/output.mpd @@ -2,7 +2,7 @@ - + AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== diff --git a/packager/app/test/testdata/encryption-and-trick-play/output.mpd b/packager/app/test/testdata/encryption-and-trick-play/output.mpd index 1553fb6375..4d289f0442 100644 --- a/packager/app/test/testdata/encryption-and-trick-play/output.mpd +++ b/packager/app/test/testdata/encryption-and-trick-play/output.mpd @@ -2,7 +2,7 @@ - + AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== diff --git a/packager/app/test/testdata/encryption-and-two-trick-plays/output.mpd b/packager/app/test/testdata/encryption-and-two-trick-plays/output.mpd index d0023219bb..f1e0f05972 100644 --- a/packager/app/test/testdata/encryption-and-two-trick-plays/output.mpd +++ b/packager/app/test/testdata/encryption-and-two-trick-plays/output.mpd @@ -2,7 +2,7 @@ - + AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== diff --git a/packager/app/test/testdata/encryption-cbc-1/output.mpd b/packager/app/test/testdata/encryption-cbc-1/output.mpd index c54248a533..1f73d8372f 100644 --- a/packager/app/test/testdata/encryption-cbc-1/output.mpd +++ b/packager/app/test/testdata/encryption-cbc-1/output.mpd @@ -2,7 +2,7 @@ - + AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== diff --git a/packager/app/test/testdata/encryption-cbcs-with-full-protection/output.mpd b/packager/app/test/testdata/encryption-cbcs-with-full-protection/output.mpd index 2686f8be43..bd2d40a560 100644 --- a/packager/app/test/testdata/encryption-cbcs-with-full-protection/output.mpd +++ b/packager/app/test/testdata/encryption-cbcs-with-full-protection/output.mpd @@ -2,7 +2,7 @@ - + AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== diff --git a/packager/app/test/testdata/encryption-cbcs/output.mpd b/packager/app/test/testdata/encryption-cbcs/output.mpd index 2686f8be43..bd2d40a560 100644 --- a/packager/app/test/testdata/encryption-cbcs/output.mpd +++ b/packager/app/test/testdata/encryption-cbcs/output.mpd @@ -2,7 +2,7 @@ - + AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== diff --git a/packager/app/test/testdata/encryption-cens/output.mpd b/packager/app/test/testdata/encryption-cens/output.mpd index 7637e41a5d..d73a8c7636 100644 --- a/packager/app/test/testdata/encryption-cens/output.mpd +++ b/packager/app/test/testdata/encryption-cens/output.mpd @@ -2,7 +2,7 @@ - + AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== diff --git a/packager/app/test/testdata/encryption-multi-keys-with-stream-label/output.mpd b/packager/app/test/testdata/encryption-multi-keys-with-stream-label/output.mpd index dd35a56c54..eb7f66b390 100644 --- a/packager/app/test/testdata/encryption-multi-keys-with-stream-label/output.mpd +++ b/packager/app/test/testdata/encryption-multi-keys-with-stream-label/output.mpd @@ -2,7 +2,7 @@ - + AAAARHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAIQERITFBUWFxgZICEiIyQlICEiIyQlJicoKTAxMjM0NQAAAAA= diff --git a/packager/app/test/testdata/encryption-multi-keys/output.mpd b/packager/app/test/testdata/encryption-multi-keys/output.mpd index 96cde0c744..a11a0e0d49 100644 --- a/packager/app/test/testdata/encryption-multi-keys/output.mpd +++ b/packager/app/test/testdata/encryption-multi-keys/output.mpd @@ -2,7 +2,7 @@ - + AAAARHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAIQERITFBUWFxgZICEiIyQlICEiIyQlJicoKTAxMjM0NQAAAAA= diff --git a/packager/app/test/testdata/encryption-of-only-video-stream/output.mpd b/packager/app/test/testdata/encryption-of-only-video-stream/output.mpd index cc004536d5..ad04e1a117 100644 --- a/packager/app/test/testdata/encryption-of-only-video-stream/output.mpd +++ b/packager/app/test/testdata/encryption-of-only-video-stream/output.mpd @@ -2,7 +2,7 @@ - + bear-640x360-audio-skip_encryption.mp4 diff --git a/packager/app/test/testdata/encryption-using-explicit-pssh/output.mpd b/packager/app/test/testdata/encryption-using-explicit-pssh/output.mpd index 1b40fefc95..4e0cddb507 100644 --- a/packager/app/test/testdata/encryption-using-explicit-pssh/output.mpd +++ b/packager/app/test/testdata/encryption-using-explicit-pssh/output.mpd @@ -2,7 +2,7 @@ - + AAAAIHBzc2gAAAAAEHfv7MCyTQKs4zweUuL7SwAAAAA= diff --git a/packager/app/test/testdata/encryption-using-fixed-key/output.mpd b/packager/app/test/testdata/encryption-using-fixed-key/output.mpd index 3d496a56ce..53a9ffb759 100644 --- a/packager/app/test/testdata/encryption-using-fixed-key/output.mpd +++ b/packager/app/test/testdata/encryption-using-fixed-key/output.mpd @@ -2,7 +2,7 @@ - + AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== diff --git a/packager/app/test/testdata/encryption-with-multi-drms/output.mpd b/packager/app/test/testdata/encryption-with-multi-drms/output.mpd index aed997af74..9ec1468930 100644 --- a/packager/app/test/testdata/encryption-with-multi-drms/output.mpd +++ b/packager/app/test/testdata/encryption-with-multi-drms/output.mpd @@ -2,7 +2,7 @@ - + AAACJnBzc2gAAAAAmgTweZhAQoarkuZb4IhflQAAAgYGAgAAAQABAPwBPABXAFIATQBIAEUAQQBEAEUAUgAgAHgAbQBsAG4AcwA9ACIAaAB0AHQAcAA6AC8ALwBzAGMAaABlAG0AYQBzAC4AbQBpAGMAcgBvAHMAbwBmAHQALgBjAG8AbQAvAEQAUgBNAC8AMgAwADAANwAvADAAMwAvAFAAbABhAHkAUgBlAGEAZAB5AEgAZQBhAGQAZQByACIAIAB2AGUAcgBzAGkAbwBuAD0AIgA0AC4AMAAuADAALgAwACIAPgA8AEQAQQBUAEEAPgA8AFAAUgBPAFQARQBDAFQASQBOAEYATwA+ADwASwBFAFkATABFAE4APgAxADYAPAAvAEsARQBZAEwARQBOAD4APABBAEwARwBJAEQAPgBBAEUAUwBDAFQAUgA8AC8AQQBMAEcASQBEAD4APAAvAFAAUgBPAFQARQBDAFQASQBOAEYATwA+ADwASwBJAEQAPgBOAEQATQB5AE0AVABZADEATwBEAGMANQBNAEQARQB5AE0AegBRADEATgBnAD0APQA8AC8ASwBJAEQAPgA8AEMASABFAEMASwBTAFUATQA+AGwANQBMAG8AVQBnAEsAOQBLAEMAZwA9ADwALwBDAEgARQBDAEsAUwBVAE0APgA8AC8ARABBAFQAQQA+ADwALwBXAFIATQBIAEUAQQBEAEUAUgA+AA== diff --git a/packager/app/test/testdata/encryption/output.mpd b/packager/app/test/testdata/encryption/output.mpd index 3d496a56ce..53a9ffb759 100644 --- a/packager/app/test/testdata/encryption/output.mpd +++ b/packager/app/test/testdata/encryption/output.mpd @@ -2,7 +2,7 @@ - + AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== diff --git a/packager/app/test/testdata/forced-commandline-ordering/output.mpd b/packager/app/test/testdata/forced-commandline-ordering/output.mpd index c6f9030b45..8e1683a3b7 100644 --- a/packager/app/test/testdata/forced-commandline-ordering/output.mpd +++ b/packager/app/test/testdata/forced-commandline-ordering/output.mpd @@ -8,7 +8,7 @@ bear-english-text.vtt - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/forced-subtitle/output.mpd b/packager/app/test/testdata/forced-subtitle/output.mpd index 28ccba2d4e..e557fb28ea 100644 --- a/packager/app/test/testdata/forced-subtitle/output.mpd +++ b/packager/app/test/testdata/forced-subtitle/output.mpd @@ -2,7 +2,7 @@ - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/output.mpd b/packager/app/test/testdata/hls-only-dash-only-captions/output.mpd index 6b5413197d..b760e778ee 100644 --- a/packager/app/test/testdata/hls-only-dash-only-captions/output.mpd +++ b/packager/app/test/testdata/hls-only-dash-only-captions/output.mpd @@ -2,7 +2,7 @@ - + diff --git a/packager/app/test/testdata/hls-only-dash-only/output.mpd b/packager/app/test/testdata/hls-only-dash-only/output.mpd index 038d88a0cf..55e6c71d2b 100644 --- a/packager/app/test/testdata/hls-only-dash-only/output.mpd +++ b/packager/app/test/testdata/hls-only-dash-only/output.mpd @@ -2,7 +2,7 @@ - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/live-profile-and-encryption-and-mult-files/output.mpd b/packager/app/test/testdata/live-profile-and-encryption-and-mult-files/output.mpd index c5f284b6df..9437851ec1 100644 --- a/packager/app/test/testdata/live-profile-and-encryption-and-mult-files/output.mpd +++ b/packager/app/test/testdata/live-profile-and-encryption-and-mult-files/output.mpd @@ -2,7 +2,7 @@ - + AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== diff --git a/packager/app/test/testdata/live-profile-and-encryption-and-non-dash-if-iop/output.mpd b/packager/app/test/testdata/live-profile-and-encryption-and-non-dash-if-iop/output.mpd index d62981b56a..cf50fffd4e 100644 --- a/packager/app/test/testdata/live-profile-and-encryption-and-non-dash-if-iop/output.mpd +++ b/packager/app/test/testdata/live-profile-and-encryption-and-non-dash-if-iop/output.mpd @@ -2,7 +2,7 @@ - + diff --git a/packager/app/test/testdata/live-profile-and-encryption/output.mpd b/packager/app/test/testdata/live-profile-and-encryption/output.mpd index 81b06c5f32..fba35c610f 100644 --- a/packager/app/test/testdata/live-profile-and-encryption/output.mpd +++ b/packager/app/test/testdata/live-profile-and-encryption/output.mpd @@ -2,7 +2,7 @@ - + AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== diff --git a/packager/app/test/testdata/live-profile-and-key-rotation-and-no-pssh-in-stream/output.mpd b/packager/app/test/testdata/live-profile-and-key-rotation-and-no-pssh-in-stream/output.mpd index 4befe541d3..2ed6d6621e 100644 --- a/packager/app/test/testdata/live-profile-and-key-rotation-and-no-pssh-in-stream/output.mpd +++ b/packager/app/test/testdata/live-profile-and-key-rotation-and-no-pssh-in-stream/output.mpd @@ -2,7 +2,7 @@ - + diff --git a/packager/app/test/testdata/live-profile-and-key-rotation-and-non-dash-if-iop/output.mpd b/packager/app/test/testdata/live-profile-and-key-rotation-and-non-dash-if-iop/output.mpd index 4a27746c50..efcb25c193 100644 --- a/packager/app/test/testdata/live-profile-and-key-rotation-and-non-dash-if-iop/output.mpd +++ b/packager/app/test/testdata/live-profile-and-key-rotation-and-non-dash-if-iop/output.mpd @@ -2,7 +2,7 @@ - + diff --git a/packager/app/test/testdata/live-profile-and-key-rotation-cbcs/output.mpd b/packager/app/test/testdata/live-profile-and-key-rotation-cbcs/output.mpd index 5f7ae9bdfd..eeec8f59c8 100644 --- a/packager/app/test/testdata/live-profile-and-key-rotation-cbcs/output.mpd +++ b/packager/app/test/testdata/live-profile-and-key-rotation-cbcs/output.mpd @@ -2,7 +2,7 @@ - + diff --git a/packager/app/test/testdata/live-profile-and-key-rotation/output.mpd b/packager/app/test/testdata/live-profile-and-key-rotation/output.mpd index 02fb8c83f5..78be429746 100644 --- a/packager/app/test/testdata/live-profile-and-key-rotation/output.mpd +++ b/packager/app/test/testdata/live-profile-and-key-rotation/output.mpd @@ -2,7 +2,7 @@ - + diff --git a/packager/app/test/testdata/live-profile/output.mpd b/packager/app/test/testdata/live-profile/output.mpd index 03bf36387f..5a2ac4c9f4 100644 --- a/packager/app/test/testdata/live-profile/output.mpd +++ b/packager/app/test/testdata/live-profile/output.mpd @@ -2,7 +2,7 @@ - + diff --git a/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/output.mpd b/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/output.mpd index 8d0ce66cf8..d584f61eb7 100644 --- a/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/output.mpd +++ b/packager/app/test/testdata/live-static-profile-with-time-in-segment-name/output.mpd @@ -2,7 +2,7 @@ - + diff --git a/packager/app/test/testdata/live-static-profile/output.mpd b/packager/app/test/testdata/live-static-profile/output.mpd index 2224ac20fe..1673295b61 100644 --- a/packager/app/test/testdata/live-static-profile/output.mpd +++ b/packager/app/test/testdata/live-static-profile/output.mpd @@ -2,7 +2,7 @@ - + diff --git a/packager/app/test/testdata/mp4-trailing-moov/output.mpd b/packager/app/test/testdata/mp4-trailing-moov/output.mpd index 83b418247f..c1139bd564 100644 --- a/packager/app/test/testdata/mp4-trailing-moov/output.mpd +++ b/packager/app/test/testdata/mp4-trailing-moov/output.mpd @@ -2,7 +2,7 @@ - + bear-640x360-trailing-moov-audio.mp4 diff --git a/packager/app/test/testdata/video-audio-ttml/output.mpd b/packager/app/test/testdata/video-audio-ttml/output.mpd index e1ef315e3e..4352b23609 100644 --- a/packager/app/test/testdata/video-audio-ttml/output.mpd +++ b/packager/app/test/testdata/video-audio-ttml/output.mpd @@ -7,7 +7,7 @@ bear-english-text.ttml - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/video-audio-webvtt/output.mpd b/packager/app/test/testdata/video-audio-webvtt/output.mpd index b128b524e1..f681078a7e 100644 --- a/packager/app/test/testdata/video-audio-webvtt/output.mpd +++ b/packager/app/test/testdata/video-audio-webvtt/output.mpd @@ -2,7 +2,7 @@ - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/vtt-text-to-mp4-with-ad-cues/output.mpd b/packager/app/test/testdata/vtt-text-to-mp4-with-ad-cues/output.mpd index 31b4ab7a99..75bf1c3bfe 100644 --- a/packager/app/test/testdata/vtt-text-to-mp4-with-ad-cues/output.mpd +++ b/packager/app/test/testdata/vtt-text-to-mp4-with-ad-cues/output.mpd @@ -2,7 +2,7 @@ - + @@ -35,7 +35,7 @@ - + diff --git a/packager/app/test/testdata/wvm-input-without-stripping-parameters-set-nalus/output.mpd b/packager/app/test/testdata/wvm-input-without-stripping-parameters-set-nalus/output.mpd index 55bcbce912..0107e5f763 100644 --- a/packager/app/test/testdata/wvm-input-without-stripping-parameters-set-nalus/output.mpd +++ b/packager/app/test/testdata/wvm-input-without-stripping-parameters-set-nalus/output.mpd @@ -16,7 +16,7 @@ - + bear-multi-configs-1.mp4 diff --git a/packager/app/test/testdata/wvm-input/output.mpd b/packager/app/test/testdata/wvm-input/output.mpd index b157fe5dd6..240810b322 100644 --- a/packager/app/test/testdata/wvm-input/output.mpd +++ b/packager/app/test/testdata/wvm-input/output.mpd @@ -16,7 +16,7 @@ - + bear-multi-configs-1.mp4 diff --git a/packager/mpd/base/adaptation_set.cc b/packager/mpd/base/adaptation_set.cc index e855ccb01a..bfcce9cfa9 100644 --- a/packager/mpd/base/adaptation_set.cc +++ b/packager/mpd/base/adaptation_set.cc @@ -177,9 +177,7 @@ AdaptationSet::AdaptationSet(const std::string& language, uint32_t* counter) : representation_counter_(counter), language_(language), - mpd_options_(mpd_options), - segments_aligned_(kSegmentAlignmentUnknown), - force_set_segment_alignment_(false) { + mpd_options_(mpd_options) { DCHECK(counter); } @@ -278,6 +276,7 @@ std::optional AdaptationSet::GetXml() { return std::nullopt; } } + if (video_heights_.size() == 1) { suppress_representation_height = true; if (!adaptation_set.SetIntegerAttribute("height", *video_heights_.begin())) @@ -289,6 +288,15 @@ std::optional AdaptationSet::GetXml() { } } + if (subsegment_start_with_sap_) { + if (!adaptation_set.SetIntegerAttribute("subsegmentStartsWithSAP", + subsegment_start_with_sap_)) + return std::nullopt; + } else if (start_with_sap_) { + if (!adaptation_set.SetIntegerAttribute("startWithSAP", start_with_sap_)) + return std::nullopt; + } + if (video_frame_rates_.size() == 1) { suppress_representation_frame_rate = true; if (!adaptation_set.SetStringAttribute( @@ -414,6 +422,14 @@ void AdaptationSet::AddAdaptationSetSwitching( switchable_adaptation_sets_.push_back(adaptation_set); } +void AdaptationSet::ForceSubsegmentStartswithSAP(uint32_t sap_value) { + subsegment_start_with_sap_ = sap_value; +} + +void AdaptationSet::ForceStartwithSAP(uint32_t sap_value) { + start_with_sap_ = sap_value; +} + // For dynamic MPD, storing all start_time and duration will out-of-memory // because there's no way of knowing when it will end. Static MPD // subsegmentAlignment check is *not* done here because it is possible that some diff --git a/packager/mpd/base/adaptation_set.h b/packager/mpd/base/adaptation_set.h index 239669c898..372bd1bc20 100644 --- a/packager/mpd/base/adaptation_set.h +++ b/packager/mpd/base/adaptation_set.h @@ -118,6 +118,17 @@ class AdaptationSet { /// attribute. virtual void ForceSetSegmentAlignment(bool segment_alignment); + /// Forces the subsegmentStartswithSAP field to be set to @a sap_value. + /// Use this if you are certain with stream access point value of the + /// subsegment. + /// @param sap_value is the value used for subsegmentstartsWithSAP attribute. + virtual void ForceSubsegmentStartswithSAP(uint32_t sap_value); + + /// Forces the StartswithSAP field to be set to @a sap_value. + /// Use this if you are certain with stream access point value of the segment. + /// @param sap_value is the value used for startWithSAP attribute. + virtual void ForceStartwithSAP(uint32_t sap_value); + /// Adds the adaptation set this adaptation set can switch to. /// @param adaptation_set points to the switchable adaptation set. virtual void AddAdaptationSetSwitching(const AdaptationSet* adaptation_set); @@ -308,8 +319,14 @@ class AdaptationSet { std::set roles_; // True iff all the segments are aligned. - SegmentAligmentStatus segments_aligned_; - bool force_set_segment_alignment_; + SegmentAligmentStatus segments_aligned_ = kSegmentAlignmentUnknown; + bool force_set_segment_alignment_ = false; + + // The stream access point for subsegment + uint8_t subsegment_start_with_sap_ = 0; + + // The stream access point for segment + uint8_t start_with_sap_ = 0; // Keeps track of segment start times of Representations. // For static MPD, this will not be cleared, all the segment start times are diff --git a/packager/mpd/base/period.cc b/packager/mpd/base/period.cc index e2679a1460..6c9033fa29 100644 --- a/packager/mpd/base/period.cc +++ b/packager/mpd/base/period.cc @@ -239,7 +239,8 @@ bool Period::SetNewAdaptationSetAttributes( accessibility.substr(pos + 1)); } - new_adaptation_set->set_codec(GetBaseCodec(media_info)); + const std::string& codec = GetBaseCodec(media_info); + new_adaptation_set->set_codec(codec); if (media_info.has_video_info()) { // Because 'language' is ignored for videos, |adaptation_sets| must have @@ -291,7 +292,15 @@ bool Period::SetNewAdaptationSetAttributes( new_adaptation_set->set_transfer_characteristics( media_info.video_info().transfer_characteristics()); } - + } else if (media_info.has_audio_info()) { + if (codec == "mp4a" || codec == "ac-3" || codec == "ec-3" || + codec == "ac-4") { + if (mpd_options_.dash_profile == DashProfile::kLive) { + new_adaptation_set->ForceStartwithSAP(1); + } else if (mpd_options_.dash_profile == DashProfile::kOnDemand) { + new_adaptation_set->ForceSubsegmentStartswithSAP(1); + } + } } else if (media_info.has_text_info()) { // IOP requires all AdaptationSets to have (sub)segmentAlignment set to // true, so carelessly set it to true. diff --git a/packager/mpd/base/period_unittest.cc b/packager/mpd/base/period_unittest.cc index e6c433d3a8..c149b4af0a 100644 --- a/packager/mpd/base/period_unittest.cc +++ b/packager/mpd/base/period_unittest.cc @@ -588,8 +588,8 @@ TEST_F(PeriodTest, OrderedByAdaptationSetId) { R"()" // ContentType and Representation elements are populated after // Representation::Init() is called. - R"( )" - R"( )" + R"( )" + R"( )" R"()"; EXPECT_THAT(testable_period_.GetXml(!kOutputPeriodDuration), XmlNodeEqual(kExpectedXml)); diff --git a/packager/mpd/test/data/audio_media_info1_video_media_info1_expected_mpd_output.txt b/packager/mpd/test/data/audio_media_info1_video_media_info1_expected_mpd_output.txt index 87e1dd3fff..b3ac9f35e7 100644 --- a/packager/mpd/test/data/audio_media_info1_video_media_info1_expected_mpd_output.txt +++ b/packager/mpd/test/data/audio_media_info1_video_media_info1_expected_mpd_output.txt @@ -9,7 +9,7 @@ - + test_output_file_name_audio1.mp4