shaka-project / shaka-player-embedded

Shaka Player in a C++ Framework
Apache License 2.0
239 stars 62 forks source link

How to send only once license request? #157

Open yukihiro-m-play opened 3 years ago

yukihiro-m-play commented 3 years ago

When playing the encrypted mpd file, Shaka Player send the license request twice.

the mpd that problem occurs is below. The following is an example of playing a video only encrypted mpd. Other than that, a mpd with both video and audio send the license request twice too.

MPD File:

<?xml version="1.0"?>
<!-- MPD file Generated with GPAC version 0.6.1-rev0-g72d766c-HEAD  at 2016-12-20T06:57:38.265Z-->
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:cenc="urn:mpeg:cenc:2013" minBufferTime="PT1.500S" type="static" mediaPresentationDuration="PT0H1M40.067S" maxSegmentDuration="PT0H0M1.000S" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" xmlns:mspr="urn:microsoft:playready">
  <ProgramInformation moreInformationURL="http://gpac.sourceforge.net">
    <Title>/home/encoder/work/tmp/bbb_2M_100sec_20161220155550/job_4/bbb_2M_100sec.mpd generated by GPAC</Title>
  </ProgramInformation>
  <Period duration="PT0H1M40.067S">
    <AdaptationSet segmentAlignment="true" maxWidth="1280" maxHeight="720" maxFrameRate="30" par="16:9" lang="eng" subsegmentAlignment="true" subsegmentStartsWithSAP="1">
      <ContentProtection schemeIdUri="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed" value="Widevine">
        <cenc:pssh>AAAAWHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAADgIARIQxXcyfkNpsb3dz3hYVXtRrxoMc2tpbGx1cHZpZGVvIg1iYmJfMk1fMTAwc2VjKgVTRF9IRA==</cenc:pssh>
      </ContentProtection>
      <Representation id="0" mimeType="video/mp4" codecs="avc1.4d401e" width="1280" height="720" frameRate="30" sar="1:1" startWithSAP="1" bandwidth="1011314">
        <BaseURL>bbb_2M_100sec/bbb_2M_100sec_0.mp4</BaseURL>
        <SegmentBase indexRangeExact="true" indexRange="1715-2958">
          <Initialization range="0-1714"/>
        </SegmentBase>
      </Representation>
    </AdaptationSet>
  </Period>
</MPD>

The log that confirms the request type with ShakaPlayerNetworkFilter is below. ShakaPlayerRequestTypeLicense(type=2) is output twice.

Logs:

 D -[ShakaPlayer onPlayer:networkRequest:ofType:withBlock:] 588# ENTER ShakaPlayerNetworkFilterReq type:0
 D -[ShakaPlayer onPlayer:networkRequest:ofType:withBlock:] 588# ENTER ShakaPlayerNetworkFilterReq type:1
 D -[ShakaPlayer onPlayer:networkRequest:ofType:withBlock:] 588# ENTER ShakaPlayerNetworkFilterReq type:2
 D -[ShakaPlayer onPlayer:networkRequest:ofType:withBlock:] 588# ENTER ShakaPlayerNetworkFilterReq type:1
 D -[ShakaPlayer onPlayer:networkRequest:ofType:withBlock:] 588# ENTER ShakaPlayerNetworkFilterReq type:1
 D -[ShakaPlayer onPlayer:networkRequest:ofType:withBlock:] 588# ENTER ShakaPlayerNetworkFilterReq type:2
 D -[ShakaPlayer onPlayer:networkRequest:ofType:withBlock:] 588# ENTER ShakaPlayerNetworkFilterReq type:1
 D -[ShakaPlayer onPlayer:networkRequest:ofType:withBlock:] 588# ENTER ShakaPlayerNetworkFilterReq type:1
 D -[ShakaPlayer onPlayer:networkRequest:ofType:withBlock:] 588# ENTER ShakaPlayerNetworkFilterReq type:1
 D -[ShakaPlayer onPlayer:networkRequest:ofType:withBlock:] 588# ENTER ShakaPlayerNetworkFilterReq type:1
 D -[ShakaPlayer onPlayer:networkRequest:ofType:withBlock:] 588# ENTER ShakaPlayerNetworkFilterReq type:1
 D -[ShakaPlayer onPlayer:networkRequest:ofType:withBlock:] 588# ENTER ShakaPlayerNetworkFilterReq type:1

And, we setting DRM config in Shaka Player.

Code: [_shakaPlayer configure:@"drm.servers.com\\.widevine\\.alpha" withString:licenseUrl];

How to send only once license request?

joeyparrish commented 3 years ago

Sounds like this issue: https://github.com/google/shaka-player/issues/2754

That will be resolved in v3.0.3 and v2.5.15 of Shaka Player, which hopefully will be out this week. When Shaka Player Embedded adopts that version, you should see the fix in your native app.

@TheModMaker, does that seem accurate?

TheModMaker commented 3 years ago

It could also be a server certificate request. If this is the case, you could avoid the request by setting the server certificate the same was as in JavaScript. Something like this:

[player configure:@"drm.advanced.com\\.widevine\\.alpha.serverCertificate" withData:cert];
[player configure:ShakaPlayerAdvancedDrmConfig(@"com.widevine.alpha", @"serverCertificate") withData:cert];
TheModMaker commented 3 years ago

I just pushed the fix for the bug @joeyparrish said; if you still have duplicate requests, you'll need to set the server certificate.

yukihiro-m-play commented 3 years ago

Thanks for your response. We imported the ShakaPlayer Embedded framework with the bug fixed and set the serverCertificate, but app sent a license request twice.

We tried to play Google's Widevine content in ShakaPlayer Embedded Sample Project, and sample app sent multiple license requests.

Google's Widevine content:

[uri]
 https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears_sd.mpd
[configuration]
 key=drm.servers.com\.widevine\.alpha
 value=https://proxy.staging.widevine.com/proxy

Logs:

ShakaPlayerNetworkFilterRes type:0 uri:https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears_sd.mpd
ShakaPlayerNetworkFilterRes type:2 uri:https://proxy.staging.widevine.com/proxy
ShakaPlayerNetworkFilterRes type:1 uri:https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears_audio_eng.mp4
ShakaPlayerNetworkFilterRes type:1 uri:https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears_h264_baseline_240p_800.mp4
ShakaPlayerNetworkFilterRes type:2 uri:https://proxy.staging.widevine.com/proxy
ShakaPlayerNetworkFilterRes type:2 uri:https://proxy.staging.widevine.com/proxy
ShakaPlayerNetworkFilterRes type:1 uri:https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears_h264_baseline_240p_800.mp4
ShakaPlayerNetworkFilterRes type:1 uri:https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears_audio_eng.mp4
ShakaPlayerNetworkFilterRes type:1 uri:https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears_audio_eng.mp4
ShakaPlayerNetworkFilterRes type:1 uri:https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears_h264_baseline_240p_800.mp4
ShakaPlayerNetworkFilterRes type:1 uri:https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears_audio_eng.mp4
ShakaPlayerNetworkFilterRes type:1 uri:https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears_h264_main_480p_2000.mp4
ShakaPlayerNetworkFilterRes type:1 uri:https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears_h264_baseline_240p_800.mp4
ShakaPlayerNetworkFilterRes type:1 uri:https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears_audio_eng.mp4
ShakaPlayerNetworkFilterRes type:1 uri:https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears_h264_main_480p_2000.mp4

Code:

NSDataAsset *certificate = [[NSDataAsset alloc] initWithName:@"certificate"];
[self.player configure:@"drm.advanced.com\\.widevine\\.alpha.serverCertificate" withData:certificate.data];
TheModMaker commented 3 years ago

It may be related to google/shaka-player#2644.

yukihiro-m-play commented 3 years ago

We tried to play content (google/shaka-player#2644) in ShakaPlayer Embedded Sample Project, and sample app sent multiple license requests.

Content (google/shaka-player#2644):

Manifest URL: https://storage.googleapis.com/shaka-demo-assets/angel-one-widevine/dash.mpd
License Server URL: https://cwip-shaka-proxy.appspot.com/no_auth
License Certificate URL: https://cwip-shaka-proxy.appspot.com/service-cert

Logs:

ShakaPlayerNetworkFilterRes type:0 uri:https://storage.googleapis.com/shaka-demo-assets/angel-one-widevine/dash.mpd
ShakaPlayerNetworkFilterRes type:2 uri:https://cwip-shaka-proxy.appspot.com/no_auth
ShakaPlayerNetworkFilterRes type:1 uri:https://storage.googleapis.com/shaka-demo-assets/angel-one-widevine/a-eng-0128k-aac-2c.mp4
ShakaPlayerNetworkFilterRes type:1 uri:https://storage.googleapis.com/shaka-demo-assets/angel-one-widevine/v-0144p-0100k-libx264.mp4
ShakaPlayerNetworkFilterRes type:2 uri:https://cwip-shaka-proxy.appspot.com/no_auth
ShakaPlayerNetworkFilterRes type:1 uri:https://storage.googleapis.com/shaka-demo-assets/angel-one-widevine/a-eng-0128k-aac-2c.mp4
ShakaPlayerNetworkFilterRes type:1 uri:https://storage.googleapis.com/shaka-demo-assets/angel-one-widevine/a-eng-0128k-aac-2c.mp4
ShakaPlayerNetworkFilterRes type:1 uri:https://storage.googleapis.com/shaka-demo-assets/angel-one-widevine/v-0144p-0100k-libx264.mp4
ShakaPlayerNetworkFilterRes type:1 uri:https://storage.googleapis.com/shaka-demo-assets/angel-one-widevine/v-0144p-0100k-libx264.mp4
ShakaPlayerNetworkFilterRes type:1 uri:https://storage.googleapis.com/shaka-demo-assets/angel-one-widevine/a-eng-0128k-aac-2c.mp4
ShakaPlayerNetworkFilterRes type:1 uri:https://storage.googleapis.com/shaka-demo-assets/angel-one-widevine/a-fra-0128k-aac-2c.mp4
ShakaPlayerNetworkFilterRes type:1 uri:https://storage.googleapis.com/shaka-demo-assets/angel-one-widevine/a-ita-0128k-aac-2c.mp4
ShakaPlayerNetworkFilterRes type:1 uri:https://storage.googleapis.com/shaka-demo-assets/angel-one-widevine/v-0576p-1400k-libx264.mp4
...

When do you fix #2644?