google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.7k stars 6.02k forks source link

DASH Widevine issue when scheme specific ContentProtection is omitted #3630

Closed lucalooz closed 6 years ago

lucalooz commented 6 years ago

I have a DASH content protected with Widevine that doesn't work only on ExoPlayer 2.6.0 (it works on 2.5.4).

The manifest for content protection contains only <ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="fe2cbd2e-78a3-5fdd-b1f7-3b166d8abbed" />

When checking if the video format is supported 2.6.0 returns FORMAT_UNSUPPORTED_DRM.

I have debugged the ExoPlayer source of 2.5.4 and 2.6.0 to find the difference.

On 2.5.4 the previous ContentProtection tag is ignored in DashManifestParser and so drmInitData inside supportsFormat of MediaCodecRenderer is null and it assumes that there is no protection. Only later it will update drmInitData by parsing a Widevine SchemeData from the MP4 atoms and ask for the license.

On 2.6.0 the ContentProtection tag is parsed with a SchemeData having COMMON_PSSH_UUID as uuid. Because there is an existing DrmInitData the MediaVideoCodecRenderer class doesn't assume that there is no protection and checks if it's a supported DRM by calling canAcquireSession of DrmSessionManager. DefaultDrmSessionManager calls getSchemeData that will return null because there is no match with the Widevine UUID or with the CLEARKEY logic, this will finally result in FORMAT_UNSUPPORTED_DRM.

I don't know much about DASH manifest and DRM standards so currently i can't say if it's an ExoPlayer issue or it's a malformed manifest.

Unfortunately i don't have any control on these DASH manifests.

ojw28 commented 6 years ago

I'm not sure either, although regardless of whether it's required to include the scheme specific ContentProtection elements, it seems highly preferable to do so.

Assigning to myself to figure out whether we should be more lenient in this case.

piatt commented 6 years ago

I am experiencing a similar issue, except my app crashes trying to parse the UUID from the the defaultKid string. I too have no control over the manifests, but it seems that the switch statement in the parseContentProtection method changed from 2.5.4 to 2.6.0, and now does not allow me to proceed for DASH Widevine parsing. Here is a sample of a manifest my app might use:

<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:cenc="urn:mpeg:cenc:2013" xmlns:mas="urn:marlin:mas:1-0:services:schemas:mpd" xmlns:mspr="urn:microsoft:playready" mediaPresentationDuration="PT2H9M27.301S" minBufferTime="PT3.00S" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" type="static">
    <!--  Created with Bento4 mp4-dash.py, VERSION=1.6.0-601  -->
    <Period>
        <AdaptationSet lang="English (United States)" mimeType="audio/mp4" segmentAlignment="true" startWithSAP="1">
            <Role schemeIdUri="urn:mpeg:dash:role:2011" value="alternate" />
            <!--  Common Encryption  -->
            <ContentProtection cenc:default_KID="12677be9-4e98-86cd-d05eee34fd5c547f" schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" />
            <!--  Marlin  -->
            <ContentProtection schemeIdUri="urn:uuid:5E629AF5-38DA-4063-8977-97FFBD9902D4">
                <mas:MarlinContentIds>
                    <mas:MarlinContentId>urn:marlin:kid:12677be94e9886cdd05eee34fd5c547f</mas:MarlinContentId>
                </mas:MarlinContentIds>
            </ContentProtection>
            <!--  PlayReady  -->
            <ContentProtection schemeIdUri="urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95">
                <mspr:pro>egIAAAEAAQBwAjwAVwBSAE0ASABFAEEARABFAFIAIAB4AG0AbABuAHMAPQAiAGgAdAB0AHAAOgAvAC8AcwBjAGgAZQBtAGEAcwAuAG0AaQBjAHIAbwBzAG8AZgB0AC4AYwBvAG0ALwBEAFIATQAvADIAMAAwADcALwAwADMALwBQAGwAYQB5AFIAZQBhAGQAeQBIAGUAYQBkAGUAcgAiACAAdgBlAHIAcwBpAG8AbgA9ACIANAAuADAALgAwAC4AMAAiAD4APABEAEEAVABBAD4APABQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsARQBZAEwARQBOAD4AMQA2ADwALwBLAEUAWQBMAEUATgA+ADwAQQBMAEcASQBEAD4AQQBFAFMAQwBUAFIAPAAvAEEATABHAEkARAA+ADwALwBQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsASQBEAD4ANgBYAHQAbgBFAHAAaABPAHoAWQBiAFEAWAB1ADQAMAAvAFYAeABVAGYAdwA9AD0APAAvAEsASQBEAD4APABDAEgARQBDAEsAUwBVAE0APgBFAFAAbABWAG0AOQBWAFkAZABWAGcAPQA8AC8AQwBIAEUAQwBLAFMAVQBNAD4APABMAEEAXwBVAFIATAA+AGgAdAB0AHAAcwA6AC8ALwBwAHIALgBzAHcAYQBuAGsAbQBwAC4AYwBvAG0ALwByAGkAZwBoAHQAcwBtAGEAbgBhAGcAZQByAC4AYQBzAG0AeAA8AC8ATABBAF8AVQBSAEwAPgA8AC8ARABBAFQAQQA+ADwALwBXAFIATQBIAEUAQQBEAEUAUgA+AA==</mspr:pro>
            </ContentProtection>
            <!--  Widevine  -->
            <ContentProtection schemeIdUri="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed">
                <cenc:pssh>AAAAXXBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAAD0IARIQEmd76U6Yhs3QXu40/VxUfxoFc3dhbmsiIDEyNjc3QkU5NEU5ODg2Q0REMDVFRUUzNEZENUM1NDdG</cenc:pssh>
            </ContentProtection>
            <!--  Primetime  -->
            <ContentProtection schemeIdUri="urn:uuid:F239E769-EFA3-4850-9C16-A903C6932EFB" />
            <Representation audioSamplingRate="48000" bandwidth="221502" codecs="mp4a.40.2" id="audio-en-US">
                <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2" />
                <BaseURL>A56627_E2_XX_XX_XX_en-US.mp4</BaseURL>
                <SegmentBase indexRange="1467-32578">
                    <Initialization range="0-1466" />
                </SegmentBase>
            </Representation>
        </AdaptationSet>
        <AdaptationSet mimeType="video/mp4" segmentAlignment="true" startWithSAP="1">
            <!--  Common Encryption  -->
            <ContentProtection cenc:default_KID="12677be9-4e98-86cd-d05eee34fd5c547f" schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" />
            <!--  Marlin  -->
            <ContentProtection schemeIdUri="urn:uuid:5E629AF5-38DA-4063-8977-97FFBD9902D4">
                <mas:MarlinContentIds>
                    <mas:MarlinContentId>urn:marlin:kid:12677be94e9886cdd05eee34fd5c547f</mas:MarlinContentId>
                </mas:MarlinContentIds>
            </ContentProtection>
            <!--  PlayReady  -->
            <ContentProtection schemeIdUri="urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95">
                <mspr:pro>egIAAAEAAQBwAjwAVwBSAE0ASABFAEEARABFAFIAIAB4AG0AbABuAHMAPQAiAGgAdAB0AHAAOgAvAC8AcwBjAGgAZQBtAGEAcwAuAG0AaQBjAHIAbwBzAG8AZgB0AC4AYwBvAG0ALwBEAFIATQAvADIAMAAwADcALwAwADMALwBQAGwAYQB5AFIAZQBhAGQAeQBIAGUAYQBkAGUAcgAiACAAdgBlAHIAcwBpAG8AbgA9ACIANAAuADAALgAwAC4AMAAiAD4APABEAEEAVABBAD4APABQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsARQBZAEwARQBOAD4AMQA2ADwALwBLAEUAWQBMAEUATgA+ADwAQQBMAEcASQBEAD4AQQBFAFMAQwBUAFIAPAAvAEEATABHAEkARAA+ADwALwBQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsASQBEAD4ANgBYAHQAbgBFAHAAaABPAHoAWQBiAFEAWAB1ADQAMAAvAFYAeABVAGYAdwA9AD0APAAvAEsASQBEAD4APABDAEgARQBDAEsAUwBVAE0APgBFAFAAbABWAG0AOQBWAFkAZABWAGcAPQA8AC8AQwBIAEUAQwBLAFMAVQBNAD4APABMAEEAXwBVAFIATAA+AGgAdAB0AHAAcwA6AC8ALwBwAHIALgBzAHcAYQBuAGsAbQBwAC4AYwBvAG0ALwByAGkAZwBoAHQAcwBtAGEAbgBhAGcAZQByAC4AYQBzAG0AeAA8AC8ATABBAF8AVQBSAEwAPgA8AC8ARABBAFQAQQA+ADwALwBXAFIATQBIAEUAQQBEAEUAUgA+AA==</mspr:pro>
            </ContentProtection>
            <!--  Widevine  -->
            <ContentProtection schemeIdUri="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed">
                <cenc:pssh>AAAAXXBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAAD0IARIQEmd76U6Yhs3QXu40/VxUfxoFc3dhbmsiIDEyNjc3QkU5NEU5ODg2Q0REMDVFRUUzNEZENUM1NDdG</cenc:pssh>
            </ContentProtection>
            <!--  Primetime  -->
            <ContentProtection schemeIdUri="urn:uuid:F239E769-EFA3-4850-9C16-A903C6932EFB" />
            <Representation bandwidth="1212093" codecs="avc1.4D401F" frameRate="24000/1001" height="720" id="video-1" scanType="progressive" width="1280">
                <BaseURL>A56627_E2_XX_XX_XX_720p_1200kbps_en-US.mp4</BaseURL>
                <SegmentBase indexRange="1539-9334">
                    <Initialization range="0-1538" />
                </SegmentBase>
            </Representation>
            <Representation bandwidth="1511461" codecs="avc1.4D401F" frameRate="24000/1001" height="480" id="video-2" scanType="progressive" width="854">
                <BaseURL>A56627_E2_XX_XX_XX_480p_1500kbps_en-US.mp4</BaseURL>
                <SegmentBase indexRange="1539-9334">
                    <Initialization range="0-1538" />
                </SegmentBase>
            </Representation>
        </AdaptationSet>
    </Period>
</MPD>

And here is the exception:

java.lang.IllegalArgumentException: Invalid UUID: 12677be9-4e98-86cd-d05eee34fd5c547f
    at java.util.UUID.fromString(UUID.java:198)
    at com.google.android.exoplayer2.source.dash.manifest.DashManifestParser.parseContentProtection(DashManifestParser.java:360)
    at com.google.android.exoplayer2.source.dash.manifest.DashManifestParser.parseAdaptationSet(DashManifestParser.java:258)
    at com.google.android.exoplayer2.source.dash.manifest.DashManifestParser.parsePeriod(DashManifestParser.java:209)
    at com.google.android.exoplayer2.source.dash.manifest.DashManifestParser.parseMediaPresentationDescription(DashManifestParser.java:137)
    at com.google.android.exoplayer2.source.dash.manifest.DashManifestParser.parse(DashManifestParser.java:99)
    at com.google.android.exoplayer2.source.dash.manifest.DashManifestParser.parse(DashManifestParser.java:54)

Clearly that string is not a valid UUID, hence the crash, but the format of the manifest has not changed, which leads me to wonder why the change from 2.5.4 to 2.6.0 was made that would break this step in the parsing process. I would love to be able to take advantage of the improvements made in 2.6.0, but cannot until this is resolved. Thanks!

ojw28 commented 6 years ago

Does your app really crash (i.e. the process actually dies because the exception is uncaught), or is it just that playback fails? If your app really crashes, please provide the complete stack trace (i.e. there must be more call stack calling into DashManifestParser.parse). Thanks.

piatt commented 6 years ago

My application does not crash, since I catch the exception, but the exception is received via the onPlayerError listener method, as a ExoPlaybackException, with the cause of the error being the UUID stacktrace above.

ojw28 commented 6 years ago

@piatt - I took a look at your example. The manifest is not spec compliant, and unfortunately failure is expected in this case. We have no plan to mitigate the issue unless it turns out to be a widespread problem, so I suggest you contact whoever's content you're attempting to play and ask them to fix it. The reason it fails now when it didn't previously is that we're parsing more elements from the manifest, which was required to fix https://github.com/google/ExoPlayer/issues/3138. If you require a workaround for the issue then you can extend DashManifestParser, override parseContentProtection with an implementation that's robust against this particular manifest issue, and inject an instance of your custom parser when you build the DashMediaSource.

piatt commented 6 years ago

@ojw28 thanks for letting me know. I can try your workaround in the interim, but could you provide a couple of technical specifics or point me to spec reqs that I could bring to the manifest vendor as items that would need to change? Any help would be much appreciated!

ojw28 commented 6 years ago

The only thing wrong with the manifest is that the UUID we're failing to parse is missing a dash where there should be one. It's in the manifest as:

12677be9-4e98-86cd-d05eee34fd5c547f

But it should be:

12677be9-4e98-86cd-d05e-ee34fd5c547f

See: https://en.wikipedia.org/wiki/Universally_unique_identifier

ojw28 commented 6 years ago

@llooz - I think our plan is to optimistically attempt playback of media in the case you describe (printing a warning to logcat). Playback will then fail a bit later in the initialization process if scheme specific DRM init data for the correct scheme (Widevine) isn't present in the streams themselves.

letianxu commented 6 years ago

@ojw28 We have experienced the same issue here: in 2.5.4 parsing content protection is omitted, so when using DashUtil.loadDrmInitData, it goes to DashUtil.loadSampleFormat to get drmInitData; while in 2.6.0 it parses content protection, but drmInitData.data is null, which will causes DefaultDrmSessionManager.acquireSession failure.

piatt commented 6 years ago

@ojw28 thank you for you help!

sebastien4 commented 6 years ago

@ojw28 Same problem here, looks like @llooz one. Here is mpd which fails:


<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" minBufferTime="PT1.500000S" type="static" mediaPresentationDuration="PT0H27M15.20S" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" xmlns:cenc="urn:mpeg:cenc:2013">
 <ProgramInformation>
  <Title>ROOM1040105W0123688</Title>
 </ProgramInformation>

 <Period duration="PT0H27M15.20S">
  <AdaptationSet segmentAlignment="true" maxWidth="1920" maxHeight="1080" maxFrameRate="25" subsegmentStartsWithSAP="1">
   <Representation id="1" mimeType="video/mp4" codecs="avc1.640015" width="426" height="240" frameRate="25" sar="640:639" startWithSAP="1" bandwidth="175397">
    <ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="ade6210d-7e1d-4c55-a70e-4e8b6d28caab"/>
    <BaseURL>ROOM1040105W0123688.t0.230k.240p.230k.4B3BC829-A3E1-40B1-B3F1-6C3C2B65CF9E.packaged_dashinit.mp4</BaseURL>
    <SegmentBase indexRangeExact="true" indexRange="1733-7008">
      <Initialization range="0-1732"/>
    </SegmentBase>
   </Representation>
   <Representation id="2" mimeType="video/mp4" codecs="avc1.640015" width="482" height="272" frameRate="25" sar="2176:2169" startWithSAP="1" bandwidth="500335">
    <ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="ade6210d-7e1d-4c55-a70e-4e8b6d28caab"/>
    <BaseURL>ROOM1040105W0123688.t0.550k.272p.550k.4B3BC829-A3E1-40B1-B3F1-6C3C2B65CF9E.packaged_dashinit.mp4</BaseURL>
    <SegmentBase indexRangeExact="true" indexRange="1733-7008">
      <Initialization range="0-1732"/>
    </SegmentBase>
   </Representation>
   <Representation id="3" mimeType="video/mp4" codecs="avc1.64001e" width="654" height="368" frameRate="25" sar="2944:2943" startWithSAP="1" bandwidth="1001223">
    <ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="ade6210d-7e1d-4c55-a70e-4e8b6d28caab"/>
    <BaseURL>ROOM1040105W0123688.t0.1000k.368p.1000k.4B3BC829-A3E1-40B1-B3F1-6C3C2B65CF9E.packaged_dashinit.mp4</BaseURL>
    <SegmentBase indexRangeExact="true" indexRange="1733-7008">
      <Initialization range="0-1732"/>
    </SegmentBase>
   </Representation>
   <Representation id="4" mimeType="video/mp4" codecs="avc1.64001e" width="852" height="480" frameRate="25" sar="640:639" startWithSAP="1" bandwidth="1600470">
    <ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="ade6210d-7e1d-4c55-a70e-4e8b6d28caab"/>
    <BaseURL>ROOM1040105W0123688.t0.1600k.480p.1600k.4B3BC829-A3E1-40B1-B3F1-6C3C2B65CF9E.packaged_dashinit.mp4</BaseURL>
    <SegmentBase indexRangeExact="true" indexRange="1733-7008">
      <Initialization range="0-1732"/>
    </SegmentBase>
   </Representation>
   <Representation id="5" mimeType="video/mp4" codecs="avc1.64001f" width="1024" height="576" frameRate="25" sar="1:1" startWithSAP="1" bandwidth="2100393">
    <ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="ade6210d-7e1d-4c55-a70e-4e8b6d28caab"/>
    <BaseURL>ROOM1040105W0123688.t0.2100k.576p.2100k.4B3BC829-A3E1-40B1-B3F1-6C3C2B65CF9E.packaged_dashinit.mp4</BaseURL>
    <SegmentBase indexRangeExact="true" indexRange="1713-6988">
      <Initialization range="0-1712"/>
    </SegmentBase>
   </Representation>
   <Representation id="6" mimeType="video/mp4" codecs="avc1.64001f" width="1280" height="720" frameRate="25" sar="1:1" startWithSAP="1" bandwidth="2599224">
    <ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="ade6210d-7e1d-4c55-a70e-4e8b6d28caab"/>
    <BaseURL>ROOM1040105W0123688.t0.2600k.720p.2600k.4B3BC829-A3E1-40B1-B3F1-6C3C2B65CF9E.packaged_dashinit.mp4</BaseURL>
    <SegmentBase indexRangeExact="true" indexRange="1713-6988">
      <Initialization range="0-1712"/>
    </SegmentBase>
   </Representation>
   <Representation id="7" mimeType="video/mp4" codecs="avc1.64001f" width="1280" height="720" frameRate="25" sar="1:1" startWithSAP="1" bandwidth="2998760">
    <ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="ade6210d-7e1d-4c55-a70e-4e8b6d28caab"/>
    <BaseURL>ROOM1040105W0123688.t0.3000k.720p.3000k.4B3BC829-A3E1-40B1-B3F1-6C3C2B65CF9E.packaged_dashinit.mp4</BaseURL>
    <SegmentBase indexRangeExact="true" indexRange="1713-6988">
      <Initialization range="0-1712"/>
    </SegmentBase>
   </Representation>
   <Representation id="8" mimeType="video/mp4" codecs="avc1.640028" width="1920" height="1080" frameRate="25" sar="1:1" startWithSAP="1" bandwidth="4995416">
    <ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="ade6210d-7e1d-4c55-a70e-4e8b6d28caab"/>
    <BaseURL>ROOM1040105W0123688.t0.5000k.1080p.5000k.4B3BC829-A3E1-40B1-B3F1-6C3C2B65CF9E.packaged_dashinit.mp4</BaseURL>
    <SegmentBase indexRangeExact="true" indexRange="1714-6989">
      <Initialization range="0-1713"/>
    </SegmentBase>
   </Representation>
  </AdaptationSet>
  <AdaptationSet segmentAlignment="true" group="1" lang="fra" subsegmentStartsWithSAP="1">
   <Representation id="9" mimeType="audio/mp4" codecs="mp4a.40.2" audioSamplingRate="44100" startWithSAP="1" bandwidth="100945">
    <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
    <ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="ade6210d-7e1d-4c55-a70e-4e8b6d28caab"/>
    <BaseURL>ROOM1040105W0123688.t1.p0.96k.4B3BC829-A3E1-40B1-B3F1-6C3C2B65CF9E.packaged_dashinit.mp4</BaseURL>
    <SegmentBase indexRangeExact="true" indexRange="1640-11499">
      <Initialization range="0-1639"/>
    </SegmentBase>
   </Representation>
  </AdaptationSet>
  <AdaptationSet segmentAlignment="true" group="1" lang="eng" subsegmentStartsWithSAP="1">
   <Representation id="10" mimeType="audio/mp4" codecs="mp4a.40.2" audioSamplingRate="44100" startWithSAP="1" bandwidth="100945">
    <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
    <ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="ade6210d-7e1d-4c55-a70e-4e8b6d28caab"/>
    <BaseURL>ROOM1040105W0123688.t2.p0.96k.4B3BC829-A3E1-40B1-B3F1-6C3C2B65CF9E.packaged_dashinit.mp4</BaseURL>
    <SegmentBase indexRangeExact="true" indexRange="1639-11498">
      <Initialization range="0-1638"/>
    </SegmentBase>
   </Representation>
  </AdaptationSet>
  <AdaptationSet segmentAlignment="true" lang="fra" subsegmentStartsWithSAP="1">
   <Representation id="11" mimeType="application/mp4" codecs="stpp" startWithSAP="1" bandwidth="1492">
    <BaseURL>ROOM1040105W0123688.t4.dash_dashinit.mp4</BaseURL>
    <SegmentBase indexRangeExact="true" indexRange="632-6267">
      <Initialization range="0-631"/>
    </SegmentBase>
   </Representation>
  </AdaptationSet>
 </Period>
</MPD>
ojw28 commented 6 years ago

The issue should be fixed on the latest dev-v2 branch. If someone could verify, that would be great. We may consider doing a 2.6.2 release to pick up the changes referenced above once verified.

letianxu commented 6 years ago

I verified a1bac99f3bae78e510e367b61dd49a37e4301476, it's working for me. Thanks.

ojw28 commented 6 years ago

@llooz - Is it possible for you to verify also? The issue @letianxu verified is related, but different. Thanks!

lucalooz commented 6 years ago

@ojw28 with the latest dev commit a1bac99f3bae78e510e367b61dd49a37e4301476 I'm getting the exception at the bottom. After inspecting the code i see that Format#copyWithManifestFormatInfo gives priority to the manifest DrmInitData


01-05 16:18:29.617 18788-18788/com.google.android.exoplayer2.demo E/EventLogger: playerFailed [1139.73]
                                                                                 com.google.android.exoplayer2.ExoPlaybackException
                                                                                     at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodec(MediaCodecRenderer.java:341)
                                                                                     at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:854)
                                                                                     at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:455)
                                                                                     at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:551)
                                                                                     at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:570)
                                                                                     at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:316)
                                                                                     at android.os.Handler.dispatchMessage(Handler.java:98)
                                                                                     at android.os.Looper.loop(Looper.java:148)
                                                                                     at android.os.HandlerThread.run(HandlerThread.java:61)
                                                                                  Caused by: com.google.android.exoplayer2.drm.DrmSession$DrmSessionException: java.lang.IllegalStateException: Media does not support uuid: edef8ba9-79d6-4ace-a3c8-27dcd51d21ed
                                                                                     at com.google.android.exoplayer2.drm.DefaultDrmSessionManager.acquireSession(DefaultDrmSessionManager.java:403)
                                                                                     at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:830)
                                                                                     at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:455) 
                                                                                     at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:551) 
                                                                                     at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:570) 
                                                                                     at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:316) 
                                                                                     at android.os.Handler.dispatchMessage(Handler.java:98) 
                                                                                     at android.os.Looper.loop(Looper.java:148) 
                                                                                     at android.os.HandlerThread.run(HandlerThread.java:61) 
                                                                                  Caused by: java.lang.IllegalStateException: Media does not support uuid: edef8ba9-79d6-4ace-a3c8-27dcd51d21ed
                                                                                     at com.google.android.exoplayer2.drm.DefaultDrmSessionManager.acquireSession(DefaultDrmSessionManager.java:393)
                                                                                     at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:830) 
                                                                                     at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:455) 
                                                                                     at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:551) 
                                                                                     at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:570) 
                                                                                     at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:316) 
                                                                                     at android.os.Handler.dispatchMessage(Handler.java:98) 
                                                                                     at android.os.Looper.loop(Looper.java:148) 
                                                                                     at android.os.HandlerThread.run(HandlerThread.java:61) ```
ojw28 commented 6 years ago

Right, that's probably still a problem. Are you able to share a sample piece of media? It would help us to fix this more efficiently.

cyrillrx commented 6 years ago

@ojw28 same problem as @llooz with the commit a1bac99 StackTrace and mpd attached (I renamed the mpd with .txt as the .mpd extension is not supported by github) exo-drm-stack-trace.log 24da2a1dd981804c6b758d18d705d07dac02798a.mpd.txt

lucalooz commented 6 years ago

@ojw28 http://edge.tpr-3ehznk.top.comcast.net/demo/content/PDK_(VMS)/781/643/Funny_Pranks_-_Pranks_2014_-_Funny_Videos_-_Funny_Fails_-_Funny_Pepole_-_Funny_Videos_568828483857_mp4_video_480x270_400000_primary_audio_2.mpd

ojw28 commented 6 years ago

@llooz - I'm not sure I understand that manifest, regardless of this issue. It appears to indicate that the audio streams are not DRM protected at all, when in fact they are.

ojw28 commented 6 years ago

Ignore me, the audio streams appear to not be DRM protected after all.

ojw28 commented 6 years ago

@AquilesCanta - Current status of this issue is approximately:

I'm not sure we can avoid having a special case for the manifest containing only a COMMON_PSSH_UUID ContentProtection element. I'd rather we didn't special case in two different places though. I was wondering whether we should:

  1. Move Format.getFilledManifestDrmData into DrmInitData.copyWithSampleDrmInitData (to be called on the manifest instance). Add the special case there that allows merging of extra data from the media stream.
  2. In DefaultDrmSessionManager.canAcquireSession, where we currently return false, instead construct a dummy media stream DrmInitData containing scheme specific data for our own UUID. Try and merge it into drmInitData. If successful, assume media stream init data will arrive that will let us acquire the session rather than saying the scheme isn't supported (probably printing a warning to show we made this assumption).
  3. Not strictly required, but makes everything clearer: We might need DrmInitData to contain a flag indicating whether it's from the manifest only. We could then assert the flag in DrmInitData.copyWithSampleDrmInitData for sanity, and also only try the dummy merge in DefaultDrmSessionManager.canAcquireSession if the flag is set.

There might be a simpler or completely different way. WDYT?

ojw28 commented 6 years ago

Another attempt to fix this is https://github.com/google/ExoPlayer/commit/8716c0ee32a6c5399d8f2e6b3e4f14563bb14c7f, now in dev-v2. Please verify if you have a chance, thanks!

cyrillrx commented 6 years ago

I tested on last commit in dev-v2 (f432b5211). It works for me!