HLS with DRM - AVPlayer not switching to different bitrate file

I am trying to play a DRM encrypted mp4 file through a master playlist. Our servers are hosting multiple mp4s

supporting different bitrates (12kpbs, 48kbps, 96kbps, 160kbps, 256kbps and 320kbps).


Each different bitrate file is encrypted with a different content key, and the format of the contentkeyID


is "skd://contentkeyid_<bitrate>". So eg: "skd://abcdefgh123_12" or "skd://abcdefgh123_96" etc:


With the master playlist having autoselect set to 96kbps, whenever I feed the master playlist to the AVPlayer,


it fetches the content key from the key server and starts playing 96kbps stream.


Now, my question is, If the network bandwidth changes, should the AVPlayer not switch to a different file

with higher or lower bitrate depending upon the bandwidth available?


I tried simulating different network conditions using the Network Link Condition tool, the indicatedBitrate property


on the AVPlayerItemAccessLogEvent object seems to change, but the AVPlayer does not make a request to


fetch the new content key for different bitrate file. This tells me that the player is not switching to a different m3u8 file.


Below method is not getting called by AVPlayer under different network conditions:


- contentKeySession:didProvideContentKeyRequest;



Below are the contents of the master m3u8:

#EXT-X-MEDIA:TYPE=AUDIO,URI="fb701719be7fff0a0514d27c0c4cca41_c_12.m3u8",GROUP-ID="default-audio-group",NAME="fb701719be7fff0a0514d27c0c4cca41_c_12",CHANNELS="1"

#EXT-X-MEDIA:TYPE=AUDIO,URI="fb701719be7fff0a0514d27c0c4cca41_c_48.m3u8.",GROUP-ID="default-audio-group",NAME="fb701719be7fff0a0514d27c0c4cca41_c_48",CHANNELS="2"

#EXT-X-MEDIA:TYPE=AUDIO,URI="fb701719be7fff0a0514d27c0c4cca41_c_96.m3u8",GROUP-ID="default-audio-
group",NAME="fb701719be7fff0a0514d27c0c4cca41_c_96",AUTOSELECT=YES,CHANNELS="2"

#EXT-X-MEDIA:TYPE=AUDIO,URI="fb701719be7fff0a0514d27c0c4cca41_c_160.m3u8",GROUP-ID="default-audio-
group",NAME="fb701719be7fff0a0514d27c0c4cca41_c_160",CHANNELS="2"

#EXT-X-MEDIA:TYPE=AUDIO,URI="fb701719be7fff0a0514d27c0c4cca41_c_256.m3u8",GROUP-ID="default-audio-
group",NAME="fb701719be7fff0a0514d27c0c4cca41_c_256",CHANNELS="2"

#EXT-X-MEDIA:TYPE=AUDIO,URI="fb701719be7fff0a0514d27c0c4cca41_c_320.m3u8",GROUP-ID="default-audio-
group",NAME="fb701719be7fff0a0514d27c0c4cca41_c_320",CHANNELS="2"

#EXT-X-STREAM-INF:BANDWIDTH=14715,AVERAGE-BANDWIDTH=12618,CODECS="mp4a.40.2",AUDIO="default-audio-group" fb701719be7fff0a0514d27c0c4cca41_c_12.m3u8

#EXT-X-STREAM-INF:BANDWIDTH=50811,AVERAGE-BANDWIDTH=49418,CODECS="mp4a.40.2",AUDIO="default-audio-group"fb701719be7fff0a0514d27c0c4cca41_c_48.m3u8

#EXT-X-STREAM-INF:BANDWIDTH=101299,AVERAGE-BANDWIDTH=98918,CODECS="mp4a.40.2",AUDIO="default-audio-group" fb701719be7fff0a0514d27c0c4cca41_c_96.m3u8

#EXT-X-STREAM-INF:BANDWIDTH=174243,AVERAGE-BANDWIDTH=166777,CODECS="mp4a.40.2",AUDIO="default-audio-group"
fb701719be7fff0a0514d27c0c4cca41_c_160.m3u8

#EXT-X-STREAM-INF:BANDWIDTH=276432,AVERAGE-BANDWIDTH=267524,CODECS="mp4a.40.2",AUDIO="default-audio-group" fb701719be7fff0a0514d27c0c4cca41_c_256.m3u8

#EXT-X-STREAM-INF:BANDWIDTH=344994,AVERAGE-BANDWIDTH=333661,CODECS="mp4a.40.2",AUDIO="default-audio-group"fb701719be7fff0a0514d27c0c4cca41_c_320.m3u8

Replies

Hi ,


I am facing the same issue,Did you find any solution for it.


Regards,

Syed

Have you run the mediastreamvalidator tool against your streams?


In the Verifying Content section of the following "Debugging HTTP Live Streaming" document it explains how to run it.

It performs several checks to ensure reliable streaming. If any errors or problems are found, a detailed diagnostic report is displayed. It is important to address the issues that the mediastreamvalidator finds to ensure that the AVFoundation framework handles your content in an expected way.


https://developer.apple.com/library/archive/technotes/tn2436/_index.html#//apple_ref/doc/uid/DTS40017666


The tools are linked to from the HTTP Live Streaming page at https://developer.apple.com/streaming/

Yes I have run mediastreamvalidator and generated the report.html by hlsreport.py as well but everything fine.Some suggestions were there but nothing specific.


Regards,

Syed Ghaus

Can you post the sugestions or the report?

I am posting a report why is this happening as same thing works on iOS 12 but why not on iOS 13.