From 19f80d8478bfbbd119bb40fd6e09a2f3ab3b379a Mon Sep 17 00:00:00 2001 From: KongQun Yang Date: Tue, 18 Sep 2018 12:05:11 -0700 Subject: [PATCH] Put namespace URIs in DASH mpd only if needed Change-Id: I31284b665599a8ee8f0b1aa11b58d6797dbe2884 --- packager/app/test/testdata/acc-he/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 +- .../test/testdata/av1-mp4-to-webm/output.mpd | 2 +- packager/app/test/testdata/av1-mp4/output.mpd | 2 +- .../app/test/testdata/av1-webm/output.mpd | 2 +- .../app/test/testdata/avc-aac-ts/output.mpd | 2 +- .../output.mpd | 2 +- .../testdata/bandwidth-override/output.mpd | 2 +- .../output.mpd | 2 +- .../encryption-and-ad-cues/output.mpd | 2 +- .../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 +- .../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-fixed-key/output.mpd | 2 +- .../encryption-with-fairplay/output.mpd | 2 +- .../app/test/testdata/encryption/output.mpd | 2 +- .../app/test/testdata/first-stream/output.mpd | 2 +- .../testdata/flac-with-encryption/output.mpd | 2 +- .../testdata/hevc-with-encryption/output.mpd | 2 +- .../output.mpd | 42 +++++++++---------- .../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 +- .../live-profile-with-webm/output.mpd | 2 +- .../app/test/testdata/live-profile/output.mpd | 2 +- .../output.mpd | 2 +- .../testdata/live-static-profile/output.mpd | 2 +- .../opus-vp9-mp4-with-encryption/output.mpd | 2 +- packager/app/test/testdata/text/output.mpd | 2 +- .../test/testdata/video-audio-text/output.mpd | 2 +- .../test/testdata/video-audio-ttml/output.mpd | 2 +- .../testdata/video-audio-webvtt/output.mpd | 2 +- .../testdata/video-no-edit-list/output.mpd | 2 +- .../app/test/testdata/vorbis-webm/output.mpd | 2 +- .../vp8-mp4-with-encryption/output.mpd | 2 +- .../app/test/testdata/vp8-webm/output.mpd | 2 +- .../vp9-webm-with-blockgroup/output.mpd | 2 +- .../app/test/testdata/vp9-webm/output.mpd | 2 +- .../vtt-text-to-mp4-with-ad-cues/output.mpd | 2 +- .../webm-subsample-encryption/output.mpd | 2 +- .../output.mpd | 2 +- .../testdata/webm-with-encryption/output.mpd | 2 +- .../output.mpd | 2 +- .../app/test/testdata/wvm-input/output.mpd | 2 +- packager/mpd/base/mpd_builder.cc | 23 ++++++++-- packager/mpd/base/mpd_builder_unittest.cc | 4 -- packager/mpd/base/xml/xml_node.cc | 32 ++++++++++++++ packager/mpd/base/xml/xml_node.h | 4 ++ packager/mpd/base/xml/xml_node_unittest.cc | 35 ++++++++++++++++ 65 files changed, 170 insertions(+), 88 deletions(-) diff --git a/packager/app/test/testdata/acc-he/output.mpd b/packager/app/test/testdata/acc-he/output.mpd index 8248a5dce5..2f625aa48a 100644 --- a/packager/app/test/testdata/acc-he/output.mpd +++ b/packager/app/test/testdata/acc-he/output.mpd @@ -1,6 +1,6 @@ - + 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 59c68c6cd1..5b3b059ac7 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 @@ -1,6 +1,6 @@ - + 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 8f310ea022..8e93172d75 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 @@ -1,6 +1,6 @@ - + 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 e7bb25ac23..3d73826001 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 @@ -1,6 +1,6 @@ - + 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 06363446d4..1585bc0a20 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 @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/audio-video/output.mpd b/packager/app/test/testdata/audio-video/output.mpd index 37b639e703..6937a5b732 100644 --- a/packager/app/test/testdata/audio-video/output.mpd +++ b/packager/app/test/testdata/audio-video/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/av1-mp4-to-webm/output.mpd b/packager/app/test/testdata/av1-mp4-to-webm/output.mpd index 938730bcd2..4ca0b2846b 100644 --- a/packager/app/test/testdata/av1-mp4-to-webm/output.mpd +++ b/packager/app/test/testdata/av1-mp4-to-webm/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/av1-mp4/output.mpd b/packager/app/test/testdata/av1-mp4/output.mpd index 6dadc45a81..c30fbb8ea8 100644 --- a/packager/app/test/testdata/av1-mp4/output.mpd +++ b/packager/app/test/testdata/av1-mp4/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/av1-webm/output.mpd b/packager/app/test/testdata/av1-webm/output.mpd index cc84f078f7..dfeb67c4e6 100644 --- a/packager/app/test/testdata/av1-webm/output.mpd +++ b/packager/app/test/testdata/av1-webm/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/avc-aac-ts/output.mpd b/packager/app/test/testdata/avc-aac-ts/output.mpd index 5f974a63ec..e3f9a69f49 100644 --- a/packager/app/test/testdata/avc-aac-ts/output.mpd +++ b/packager/app/test/testdata/avc-aac-ts/output.mpd @@ -1,6 +1,6 @@ - + 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 2d335c1f64..674e7e3232 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 @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/bandwidth-override/output.mpd b/packager/app/test/testdata/bandwidth-override/output.mpd index 17eef65808..76106d2a37 100644 --- a/packager/app/test/testdata/bandwidth-override/output.mpd +++ b/packager/app/test/testdata/bandwidth-override/output.mpd @@ -1,6 +1,6 @@ - + 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 8379ae13a6..002796df53 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 @@ -1,6 +1,6 @@ - + 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 9e79670160..228bcba980 100644 --- a/packager/app/test/testdata/encryption-and-ad-cues/output.mpd +++ b/packager/app/test/testdata/encryption-and-ad-cues/output.mpd @@ -1,6 +1,6 @@ - + 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 1d851b73df..a210d1f375 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 @@ -1,6 +1,6 @@ - + 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 c5effb88ad..8984bb81c5 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 @@ -1,6 +1,6 @@ - + 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 62181cb275..9e57374ebc 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 @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/encryption-and-output-media-info-and-mpd-from-media-info/output.mpd b/packager/app/test/testdata/encryption-and-output-media-info-and-mpd-from-media-info/output.mpd index e3089005c4..080d441abd 100644 --- a/packager/app/test/testdata/encryption-and-output-media-info-and-mpd-from-media-info/output.mpd +++ b/packager/app/test/testdata/encryption-and-output-media-info-and-mpd-from-media-info/output.mpd @@ -1,6 +1,6 @@ - + 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 803f5b9d1b..9bfc9d648e 100644 --- a/packager/app/test/testdata/encryption-and-trick-play/output.mpd +++ b/packager/app/test/testdata/encryption-and-trick-play/output.mpd @@ -1,6 +1,6 @@ - + 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 29c07d0482..537a83b450 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 @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/encryption-cbc-1/output.mpd b/packager/app/test/testdata/encryption-cbc-1/output.mpd index 576d07bcf0..cc11fce83a 100644 --- a/packager/app/test/testdata/encryption-cbc-1/output.mpd +++ b/packager/app/test/testdata/encryption-cbc-1/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/encryption-cbcs/output.mpd b/packager/app/test/testdata/encryption-cbcs/output.mpd index ac84f39e58..55d19f794b 100644 --- a/packager/app/test/testdata/encryption-cbcs/output.mpd +++ b/packager/app/test/testdata/encryption-cbcs/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/encryption-cens/output.mpd b/packager/app/test/testdata/encryption-cens/output.mpd index d525881a43..ff47c4dfd9 100644 --- a/packager/app/test/testdata/encryption-cens/output.mpd +++ b/packager/app/test/testdata/encryption-cens/output.mpd @@ -1,6 +1,6 @@ - + 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 a2d29602e2..47756c1e88 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 @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/encryption-multi-keys/output.mpd b/packager/app/test/testdata/encryption-multi-keys/output.mpd index 501e0a1fcc..f1ef2fa2ae 100644 --- a/packager/app/test/testdata/encryption-multi-keys/output.mpd +++ b/packager/app/test/testdata/encryption-multi-keys/output.mpd @@ -1,6 +1,6 @@ - + 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 687304d53a..0f47816fc5 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 @@ -1,6 +1,6 @@ - + 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 5fbc0ace45..c63c2cb24b 100644 --- a/packager/app/test/testdata/encryption-using-fixed-key/output.mpd +++ b/packager/app/test/testdata/encryption-using-fixed-key/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/encryption-with-fairplay/output.mpd b/packager/app/test/testdata/encryption-with-fairplay/output.mpd index a98ef3ed20..13dbbdda48 100644 --- a/packager/app/test/testdata/encryption-with-fairplay/output.mpd +++ b/packager/app/test/testdata/encryption-with-fairplay/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/encryption/output.mpd b/packager/app/test/testdata/encryption/output.mpd index 5fbc0ace45..c63c2cb24b 100644 --- a/packager/app/test/testdata/encryption/output.mpd +++ b/packager/app/test/testdata/encryption/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/first-stream/output.mpd b/packager/app/test/testdata/first-stream/output.mpd index 5364783c93..180f196cc9 100644 --- a/packager/app/test/testdata/first-stream/output.mpd +++ b/packager/app/test/testdata/first-stream/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/flac-with-encryption/output.mpd b/packager/app/test/testdata/flac-with-encryption/output.mpd index f05517f962..6ef77687de 100644 --- a/packager/app/test/testdata/flac-with-encryption/output.mpd +++ b/packager/app/test/testdata/flac-with-encryption/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/hevc-with-encryption/output.mpd b/packager/app/test/testdata/hevc-with-encryption/output.mpd index e752e46cbf..db5775be46 100644 --- a/packager/app/test/testdata/hevc-with-encryption/output.mpd +++ b/packager/app/test/testdata/hevc-with-encryption/output.mpd @@ -1,6 +1,6 @@ - + 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 0feb548297..a37f0e0204 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 @@ -1,21 +1,13 @@ - + AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - - - - - - - - - + @@ -23,6 +15,14 @@ + + + + + + + + @@ -37,17 +37,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - - - - - - - - - - - + @@ -57,6 +47,16 @@ + + + + + + + + + + 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 6fa1e6a8be..24b5e67416 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 @@ -1,6 +1,6 @@ - + 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 76a8c1b6b0..cd7abd5883 100644 --- a/packager/app/test/testdata/live-profile-and-encryption/output.mpd +++ b/packager/app/test/testdata/live-profile-and-encryption/output.mpd @@ -1,6 +1,6 @@ - + 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 2a5b14c401..834b2af16d 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 @@ -1,6 +1,6 @@ - + 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 5edcd69f0b..a3e7a483f7 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 @@ -1,6 +1,6 @@ - + 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 894a5ae5d1..80c25d20db 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 @@ -1,6 +1,6 @@ - + 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 ae8c6c28e5..0dfd5c1afe 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 @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/live-profile-with-webm/output.mpd b/packager/app/test/testdata/live-profile-with-webm/output.mpd index a970d599c3..acfdd31f70 100644 --- a/packager/app/test/testdata/live-profile-with-webm/output.mpd +++ b/packager/app/test/testdata/live-profile-with-webm/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/live-profile/output.mpd b/packager/app/test/testdata/live-profile/output.mpd index 5ceca2cb9b..c68a2c59d7 100644 --- a/packager/app/test/testdata/live-profile/output.mpd +++ b/packager/app/test/testdata/live-profile/output.mpd @@ -1,6 +1,6 @@ - + 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 42da948f28..67cd9e16af 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 @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/live-static-profile/output.mpd b/packager/app/test/testdata/live-static-profile/output.mpd index 741f02f243..5bb9dacec3 100644 --- a/packager/app/test/testdata/live-static-profile/output.mpd +++ b/packager/app/test/testdata/live-static-profile/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/opus-vp9-mp4-with-encryption/output.mpd b/packager/app/test/testdata/opus-vp9-mp4-with-encryption/output.mpd index b2547407cf..283e00ab9e 100644 --- a/packager/app/test/testdata/opus-vp9-mp4-with-encryption/output.mpd +++ b/packager/app/test/testdata/opus-vp9-mp4-with-encryption/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/text/output.mpd b/packager/app/test/testdata/text/output.mpd index 4ca04f3252..0e1c7cf2a5 100644 --- a/packager/app/test/testdata/text/output.mpd +++ b/packager/app/test/testdata/text/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/video-audio-text/output.mpd b/packager/app/test/testdata/video-audio-text/output.mpd index 530ea83a97..828cc82da2 100644 --- a/packager/app/test/testdata/video-audio-text/output.mpd +++ b/packager/app/test/testdata/video-audio-text/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/video-audio-ttml/output.mpd b/packager/app/test/testdata/video-audio-ttml/output.mpd index 56ed737db4..b7ffc8f999 100644 --- a/packager/app/test/testdata/video-audio-ttml/output.mpd +++ b/packager/app/test/testdata/video-audio-ttml/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/video-audio-webvtt/output.mpd b/packager/app/test/testdata/video-audio-webvtt/output.mpd index 549784651f..69b162968b 100644 --- a/packager/app/test/testdata/video-audio-webvtt/output.mpd +++ b/packager/app/test/testdata/video-audio-webvtt/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/video-no-edit-list/output.mpd b/packager/app/test/testdata/video-no-edit-list/output.mpd index 61df73f51c..d2b6ba4b5f 100644 --- a/packager/app/test/testdata/video-no-edit-list/output.mpd +++ b/packager/app/test/testdata/video-no-edit-list/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/vorbis-webm/output.mpd b/packager/app/test/testdata/vorbis-webm/output.mpd index 73e8ac87cc..d94b4a3d7a 100644 --- a/packager/app/test/testdata/vorbis-webm/output.mpd +++ b/packager/app/test/testdata/vorbis-webm/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/vp8-mp4-with-encryption/output.mpd b/packager/app/test/testdata/vp8-mp4-with-encryption/output.mpd index 188e15c6ba..1fe1015889 100644 --- a/packager/app/test/testdata/vp8-mp4-with-encryption/output.mpd +++ b/packager/app/test/testdata/vp8-mp4-with-encryption/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/vp8-webm/output.mpd b/packager/app/test/testdata/vp8-webm/output.mpd index 2357e3f266..777ddf60cf 100644 --- a/packager/app/test/testdata/vp8-webm/output.mpd +++ b/packager/app/test/testdata/vp8-webm/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/vp9-webm-with-blockgroup/output.mpd b/packager/app/test/testdata/vp9-webm-with-blockgroup/output.mpd index 69803111d3..cbd3526f73 100644 --- a/packager/app/test/testdata/vp9-webm-with-blockgroup/output.mpd +++ b/packager/app/test/testdata/vp9-webm-with-blockgroup/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/vp9-webm/output.mpd b/packager/app/test/testdata/vp9-webm/output.mpd index 6564a760a3..5cc8a6deda 100644 --- a/packager/app/test/testdata/vp9-webm/output.mpd +++ b/packager/app/test/testdata/vp9-webm/output.mpd @@ -1,6 +1,6 @@ - + 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 0b108d8e13..a365052883 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 @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/webm-subsample-encryption/output.mpd b/packager/app/test/testdata/webm-subsample-encryption/output.mpd index 6050e51404..69140f2d58 100644 --- a/packager/app/test/testdata/webm-subsample-encryption/output.mpd +++ b/packager/app/test/testdata/webm-subsample-encryption/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/webm-vp9-full-sample-encryption/output.mpd b/packager/app/test/testdata/webm-vp9-full-sample-encryption/output.mpd index 6050e51404..69140f2d58 100644 --- a/packager/app/test/testdata/webm-vp9-full-sample-encryption/output.mpd +++ b/packager/app/test/testdata/webm-vp9-full-sample-encryption/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/webm-with-encryption/output.mpd b/packager/app/test/testdata/webm-with-encryption/output.mpd index 73e41c7ff0..c06555905b 100644 --- a/packager/app/test/testdata/webm-with-encryption/output.mpd +++ b/packager/app/test/testdata/webm-with-encryption/output.mpd @@ -1,6 +1,6 @@ - + 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 4ac84c125e..d80c0fdbba 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 @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/wvm-input/output.mpd b/packager/app/test/testdata/wvm-input/output.mpd index a0d7fdd818..cd5677f847 100644 --- a/packager/app/test/testdata/wvm-input/output.mpd +++ b/packager/app/test/testdata/wvm-input/output.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/mpd/base/mpd_builder.cc b/packager/mpd/base/mpd_builder.cc index 8cb405505c..c2ec7f69d6 100644 --- a/packager/mpd/base/mpd_builder.cc +++ b/packager/mpd/base/mpd_builder.cc @@ -33,19 +33,34 @@ namespace { void AddMpdNameSpaceInfo(XmlNode* mpd) { DCHECK(mpd); + const std::set namespaces = mpd->ExtractReferencedNamespaces(); + static const char kXmlNamespace[] = "urn:mpeg:dash:schema:mpd:2011"; static const char kXmlNamespaceXsi[] = "http://www.w3.org/2001/XMLSchema-instance"; - static const char kXmlNamespaceXlink[] = "http://www.w3.org/1999/xlink"; static const char kDashSchemaMpd2011[] = "urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd"; - static const char kCencNamespace[] = "urn:mpeg:cenc:2013"; mpd->SetStringAttribute("xmlns", kXmlNamespace); mpd->SetStringAttribute("xmlns:xsi", kXmlNamespaceXsi); - mpd->SetStringAttribute("xmlns:xlink", kXmlNamespaceXlink); mpd->SetStringAttribute("xsi:schemaLocation", kDashSchemaMpd2011); - mpd->SetStringAttribute("xmlns:cenc", kCencNamespace); + + static const char kCencNamespace[] = "urn:mpeg:cenc:2013"; + static const char kXmlNamespaceXlink[] = "http://www.w3.org/1999/xlink"; + + const std::map uris = { + {"cenc", kCencNamespace}, + {"xlink", kXmlNamespaceXlink}, + }; + + for (const std::string& namespace_name : namespaces) { + auto iter = uris.find(namespace_name); + CHECK(iter != uris.end()) << " unexpected namespace " << namespace_name; + + mpd->SetStringAttribute( + base::StringPrintf("xmlns:%s", namespace_name.c_str()).c_str(), + iter->second); + } } bool Positive(double d) { diff --git a/packager/mpd/base/mpd_builder_unittest.cc b/packager/mpd/base/mpd_builder_unittest.cc index 0f129b9a29..acd7ed1c8e 100644 --- a/packager/mpd/base/mpd_builder_unittest.cc +++ b/packager/mpd/base/mpd_builder_unittest.cc @@ -268,9 +268,7 @@ TEST_F(LiveMpdBuilderTest, DynamicCheckMpdAttributes) { " version ---->\n" "---->\n" "& segment_infos, return true; } +void CollectNamespaceFromName(const std::string& name, + std::set* namespaces) { + const size_t pos = name.find(':'); + if (pos != std::string::npos) + namespaces->insert(name.substr(0, pos)); +} + +void TraverseAttrsAndCollectNamespaces(const xmlAttr* attr, + std::set* namespaces) { + for (const xmlAttr* cur_attr = attr; cur_attr; cur_attr = cur_attr->next) { + CollectNamespaceFromName(reinterpret_cast(cur_attr->name), + namespaces); + } +} + +void TraverseNodesAndCollectNamespaces(const xmlNode* node, + std::set* namespaces) { + for (const xmlNode* cur_node = node; cur_node; cur_node = cur_node->next) { + CollectNamespaceFromName(reinterpret_cast(cur_node->name), + namespaces); + + TraverseNodesAndCollectNamespaces(cur_node->children, namespaces); + TraverseAttrsAndCollectNamespaces(cur_node->properties, namespaces); + } +} + } // namespace namespace xml { @@ -166,6 +192,12 @@ void XmlNode::SetContent(const std::string& content) { xmlNodeSetContent(node_.get(), BAD_CAST content.c_str()); } +std::set XmlNode::ExtractReferencedNamespaces() { + std::set namespaces; + TraverseNodesAndCollectNamespaces(node_.get(), &namespaces); + return namespaces; +} + scoped_xml_ptr XmlNode::PassScopedPtr() { DVLOG(2) << "Passing node_."; DCHECK(node_); diff --git a/packager/mpd/base/xml/xml_node.h b/packager/mpd/base/xml/xml_node.h index c841b60768..1dc1f71ae0 100644 --- a/packager/mpd/base/xml/xml_node.h +++ b/packager/mpd/base/xml/xml_node.h @@ -14,6 +14,7 @@ #include #include +#include #include "packager/base/macros.h" #include "packager/mpd/base/content_protection_element.h" @@ -73,6 +74,9 @@ class XmlNode { /// be added to the element. void SetContent(const std::string& content); + /// @return namespaces used in the node and its descendents. + std::set ExtractReferencedNamespaces(); + /// Transfer the ownership of the xmlNodePtr. After calling this method, the /// behavior of any methods, except the destructor, is undefined. /// @return The resource of this object. diff --git a/packager/mpd/base/xml/xml_node_unittest.cc b/packager/mpd/base/xml/xml_node_unittest.cc index 2e164c9af5..558284503c 100644 --- a/packager/mpd/base/xml/xml_node_unittest.cc +++ b/packager/mpd/base/xml/xml_node_unittest.cc @@ -19,6 +19,8 @@ DECLARE_bool(segment_template_constant_duration); +using ::testing::ElementsAre; + namespace shaka { namespace xml { @@ -136,6 +138,39 @@ TEST(XmlNodeTest, MetaTestXmlEqualDifferentContent) { "content1content2")); } +TEST(XmlNodeTest, ExtractReferencedNamespaces) { + XmlNode grand_child_with_namespace("grand_ns:grand_child"); + grand_child_with_namespace.SetContent("grand child content"); + + XmlNode child("child1"); + child.SetContent("child1 content"); + child.AddChild(grand_child_with_namespace.PassScopedPtr()); + + XmlNode child_with_namespace("child_ns:child2"); + child_with_namespace.SetContent("child2 content"); + + XmlNode root("root"); + root.AddChild(child.PassScopedPtr()); + root.AddChild(child_with_namespace.PassScopedPtr()); + + EXPECT_THAT(root.ExtractReferencedNamespaces(), + ElementsAre("child_ns", "grand_ns")); +} + +TEST(XmlNodeTest, ExtractReferencedNamespacesFromAttributes) { + XmlNode child("child"); + child.SetStringAttribute("child_attribute_ns:attribute", + "child attribute value"); + + XmlNode root("root"); + root.AddChild(child.PassScopedPtr()); + root.SetStringAttribute("root_attribute_ns:attribute", + "root attribute value"); + + EXPECT_THAT(root.ExtractReferencedNamespaces(), + ElementsAre("child_attribute_ns", "root_attribute_ns")); +} + // Verify that AddContentProtectionElements work. // xmlReadMemory() (used in XmlEqual()) doesn't like XML fragments that have // namespaces without context, e.g. element.