Dash-Industry-Forum / livesim2

DASH Live Source Simulator v2 in Go
Other
34 stars 5 forks source link

Livesim2 dropping xml namespace attributes, such as "xmlns:mspr", "xmlns:ck", "xmlns:dashif", "xmlns:mas" DRM systems #140

Closed Murmur closed 6 months ago

Murmur commented 7 months ago

XML namespaces are dropped from the MPD element, some of them needed for DRM elements. xmlns:cenc="urn:mpeg:cenc:2013" | xmlns:ck="http://dashif.org/guidelines/clearKey" | xmlns:dashif="https://dashif.org/" | xmlns:mas="urn:marlin:mas:1-0:services:schemas:mpd" | xmlns:mspr="urn:microsoft:playready" | xmlns:xlink="http://www.w3.org/1999/xlink"

Original vod manifest

<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:cenc="urn:mpeg:cenc:2013" xmlns:ck="http://dashif.org/guidelines/clearKey" xmlns:dashif="https://dashif.org/" xmlns:mas="urn:marlin:mas:1-0:services:schemas:mpd" xmlns:mspr="urn:microsoft:playready" xmlns:xlink="http://www.w3.org/1999/xlink" maxSegmentDuration="PT0H0M3.840S" mediaPresentationDuration="PT380.160S" minBufferTime="PT1.500S" profiles="urn:dvb:dash:profile:dvb-dash:2014,urn:dvb:dash:profile:dvb-dash:isoff-ext-live:2014" type="static">
 <Period duration="PT380.160S" id="p0">

  <AdaptationSet contentType="video" id="1" lang="en" maxFrameRate="25" maxHeight="1080" maxWidth="1920" par="16:9" segmentAlignment="true" startWithSAP="1">
   <ContentProtection cenc:default_KID="43215678-1234-1234-1234-123412341236" schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc"/>
   <ContentProtection schemeIdUri="urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95" value="MSPR 2.0">
     <mspr:pro>BgIAAAExxxxxx...</mspr:pro>
     <cenc:pssh>AAACJnBzc2gAxxxxxx..</cenc:pssh>
   </ContentProtection>
   <ContentProtection schemeIdUri="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed" value="widevine">
     <cenc:pssh>AAAATHBxxxxxx...</cenc:pssh>
   </ContentProtection>
   <Role schemeIdUri="urn:mpeg:dash:role:2011" value="main"/>
   <SegmentTemplate duration="49152" initialization="$RepresentationID$/i_prwvcenc.mp4" media="$RepresentationID$/$Number$.m4s" startNumber="1" timescale="12800"/>
   <Representation bandwidth="427400" codecs="avc1.4D401E" frameRate="25" height="360" id="v1" mimeType="video/mp4" sar="1:1" scanType="progressive" width="640">
   </Representation>
   <Representation bandwidth="1299392" codecs="avc1.640028" frameRate="25" height="720" id="v2" mimeType="video/mp4" sar="1:1" scanType="progressive" width="1280">
   </Representation>
   <Representation bandwidth="1781624" codecs="avc1.640028" frameRate="25" height="1080" id="v3" mimeType="video/mp4" sar="1:1" scanType="progressive" width="1920">
   </Representation>
  </AdaptationSet>

...clip...

See livesim2 example response here https://refapp.hbbtv.org/livesim2/tsbd_240/mup_4/spd_8/utc_keep/00_llama_h264_v9/cenc/manifest_prwvcenc_1080p.mpd

Livesim2 writes xmlns:cenc in cenc <contentprotection> but it also may be needed inside the Widevine+Playready drm element as well. It would be best to share namespace attributes in MPD parent element and not drop any unknown to a livesim2. Older Livesim1 did not drop an additional namespace attributes.

Livesim2 also touches the ordering of <AdaptationSet> child elements, DRM elements go to the end of list.

<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" profiles="urn:dvb:dash:profile:dvb-dash:2014,urn:dvb:dash:profile:dvb-dash:isoff-ext-live:2014" type="dynamic" availabilityStartTime="1970-01-01T00:00:00Z" publishTime="1970-01-01T00:00:00Z" minimumUpdatePeriod="PT4S" minBufferTime="PT1.5S" timeShiftBufferDepth="PT4M" suggestedPresentationDelay="PT8S" maxSegmentDuration="PT3.84S">
  <Period id="P0" start="PT0S">
    <AdaptationSet id="1" lang="en" contentType="video" par="16:9" maxWidth="1920" maxHeight="1080" maxFrameRate="25" segmentAlignment="true" startWithSAP="1">
      <Role schemeIdUri="urn:mpeg:dash:role:2011" value="main"></Role>
      <SegmentTemplate media="$RepresentationID$/$Number$.m4s" initialization="$RepresentationID$/i_prwvcenc.mp4" duration="49152" startNumber="0" timescale="12800"></SegmentTemplate>
      <Representation id="v1" bandwidth="427400" width="640" height="360" sar="1:1" frameRate="25" mimeType="video/mp4" codecs="avc1.4D401E" scanType="progressive"></Representation>
      <Representation id="v2" bandwidth="1299392" width="1280" height="720" sar="1:1" frameRate="25" mimeType="video/mp4" codecs="avc1.640028" scanType="progressive"></Representation>
      <Representation id="v3" bandwidth="1781624" width="1920" height="1080" sar="1:1" frameRate="25" mimeType="video/mp4" codecs="avc1.640028" scanType="progressive"></Representation>
      <ContentProtection xmlns:cenc="urn:mpeg:cenc:2013" cenc:default_KID="43215678-1234-1234-1234-123412341236" schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc"></ContentProtection>
      <ContentProtection schemeIdUri="urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95" value="MSPR 2.0">
        <cenc:pssh xmlns:cenc="urn:mpeg:cenc:2013">AAACJnBxxxxxx...</cenc:pssh>
        <mspr:pro xmlns:mspr="urn:microsoft:playready">BgIAAAExxxxxx...</mspr:pro>
      </ContentProtection>
      <ContentProtection schemeIdUri="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed" value="widevine">
        <cenc:pssh xmlns:cenc="urn:mpeg:cenc:2013">AAAATHxxxxxx...</cenc:pssh>
      </ContentProtection>
    </AdaptationSet>
tobbee commented 7 months ago

This is a limitation in the underlying MPD library (https://github.com/Eyevinn/dash-mpd) that goes back to that the Go standard library xml parser does not handle name spaces well. That library has a modified xml library to handle name-spaces better, but they need to be added explicitly.

Livesim1 used a SAX parser (stream parser) and did modifications to the stream without interpreting it. Livesim2 is different in that it uses a mapping to structs derived from the XML schema at https://github.com/MPEGGroup/DASHSchema/blob/5th-Ed-AMD1/DASH-MPD.xsd so all elements that are not in the structs will be dropped.

This is a bit limiting, but also the reason that I started from the XML schema to try to make everything correct and compliant.

Please file a bug towards the MPD library and include an example with the name spaces that you think should be added.

Regarding the output order of the elements, it cannot follow the input, but is defined by the structs, which are in turn base on the order of elements defined by the XML schema alluded to above. There is typically a sequence which implies a strict order. The only uncertain thing is whether the explicit AdaptationSet children should come before or after the sequence of elements from the RepresentationBaseType. They are before right now, but maybe it is more correct to put them at the end. I haven't seen a validator complain yet, in any case.

Murmur commented 7 months ago

Ok I created a ticket in dash-mpd project. "Poor mans post-process solution" would be a brute force string manipulation before Livesim2 returned a manifest payload.

>>The only uncertain thing is whether the explicit AdaptationSet children should come before or after the sequence of elements from the RepresentationBaseType. Yes this part worries me a bit as most other dash content is not using an ordering how Livesim2 writes <AdaptationSet> child elements.