504 advances in http live streaming 04 d...hevc and h.264 variants can appear in the same master...

221
#WWDC17 © 2017 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple. Roger Pantos, AVFoundation Engineer Anil Katti, AVFoundation Engineer Advances in HTTP Live Streaming Session 504 Media

Upload: others

Post on 27-Jul-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

#WWDC17

© 2017 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.

Roger Pantos, AVFoundation Engineer Anil Katti, AVFoundation Engineer

Advances in HTTP Live Streaming Session 504

Media

Page 2: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

But First

Page 3: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

HLS Has Been Approved for Publication as an RFC!

draft-pantos-http-live-streaming-23 will be published by the IETF as an RFC

Page 4: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

HLS Has Been Approved for Publication as an RFC!

draft-pantos-http-live-streaming-23 will be published by the IETF as an RFC

Once it moves through the publication queue it will be assigned an RFC number

Page 5: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

HLS Has Been Approved for Publication as an RFC!

draft-pantos-http-live-streaming-23 will be published by the IETF as an RFC

Once it moves through the publication queue it will be assigned an RFC number

At that point, it will serve as a stable reference for HLS

Page 6: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

HLS Has Been Approved for Publication as an RFC!

draft-pantos-http-live-streaming-23 will be published by the IETF as an RFC

Once it moves through the publication queue it will be assigned an RFC number

At that point, it will serve as a stable reference for HLS

Watch for a new Internet-Draft containing future updates

Page 7: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

NEW

•New Video Format: HEVC

Page 8: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Benefits of HEVC

Better encoding efficiency than AVC / H.264 • Reduce segment sizes by up to 40% with same visual quality

On a given network link, this translates to: • Faster video start at reasonable quality • Better quality overall

NEW

Page 9: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

HEVC Will Be Widely Supported

iOS macOS

8-bit Hardware Decode (includes FairPlay Streaming)

A9 chip

6th Generation Intel Core processor

10-bit Hardware Decode (includes FairPlay Streaming)

7th Generation Intel Core processor

8-bit Software Decode

All iOS Devices All Macs

10-bit Software Decode

Page 10: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

HEVC Support in HLS

For Apple clients, HEVC must be packaged as fMP4 • No support for HEVC in MPEG-2 TS

Page 11: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

HEVC Support in HLS

For Apple clients, HEVC must be packaged as fMP4 • No support for HEVC in MPEG-2 TS

Same encryption format — 'cbcs' ISO/IEC 23001:7 Common Encryption

Page 12: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

HEVC Support in HLS

For Apple clients, HEVC must be packaged as fMP4 • No support for HEVC in MPEG-2 TS

Same encryption format — 'cbcs' ISO/IEC 23001:7 Common Encryption

Mark your Media Playlists as HEVC with the CODECS attribute

•CODECS= "hvc1.2.4.L123.B0,…"

• See ISO/IEC 14496-15 for the string format

Page 13: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Mixing HEVC and H.264

HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too

Page 14: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Mixing HEVC and H.264

HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Page 15: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4 • Label your Media Playlists with correct CODECS attributes!

Mixing HEVC and H.264

Page 16: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4 • Label your Media Playlists with correct CODECS attributes!

HLS Authoring guidelines have been updated for HEVC • See the on-demand talk "HLS Authoring Update"

HTTP Live Streaming Authoring and Validation WWDC 2016

Mixing HEVC and H.264

Page 17: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

•New Subtitle Format: IMSC1

NEW

Page 18: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

New Subtitle Format: IMSC1

IMSC1 is a profile of TTML that has been optimized for streaming delivery

NEW

Page 19: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

New Subtitle Format: IMSC1

IMSC1 is a profile of TTML that has been optimized for streaming delivery

Better control over styling, compared to VTT

NEW

Page 20: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

New Subtitle Format: IMSC1

IMSC1 is a profile of TTML that has been optimized for streaming delivery

Better control over styling, compared to VTT

Baseline subtitle format for the Common Media Application Format (CMAF) • Part of a wider effort to support CMAF features

NEW

Page 21: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

IMSC1 in HLS

Carried as XML text inside fMP4 Segments

Page 22: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

IMSC1 in HLS

Carried as XML text inside fMP4 Segments

HLS defines support for the IMSC1 Text profile

Page 23: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

IMSC1 in HLS

Carried as XML text inside fMP4 Segments

HLS defines support for the IMSC1 Text profile

Mark your Media Playlists as IMSC1 with the CODECS attribute

• CODECS="stpp.TTML.im1t, …"

Page 24: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

IMSC1 in HLS

Carried as XML text inside fMP4 Segments

HLS defines support for the IMSC1 Text profile

Mark your Media Playlists as IMSC1 with the CODECS attribute

• CODECS="stpp.TTML.im1t, …"

Note that IMSC1 does not depend on HEVC, or vice-versa

Page 25: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//IMSC1 alongside WebVTT in a Master Playlist

#EXTM3U

#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="vtt",LANGUAGE="eng",NAME="English",URI="vtt.m3u8" #EXT-X-STREAM-INF:BANDWIDTH=90000,CODECS="avc1.4d001e,ac-3",SUBTITLES="vtt" bipbop_gear1/prog_index.m3u8

#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="imsc",LANGUAGE="eng",NAME="English",URI="imsc.m3u8" #EXT-X-STREAM-INF:BANDWIDTH=90000,CODECS="avc1.4d001e,ac-3,stpp.TTML.im1t",SUBTITLES="imsc" bipbop_gear1/prog_index.m3u8

Page 26: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

IMSC1 in a Media Playlist

# WebVTT #EXTM3U #EXT-X-TARGETDURATION:6 #EXTINF 6, segment1.vtt #EXTINF 6, segment2.vtt …

# IMSC1 #EXTM3U #EXT-X-TARGETDURATION:6 #EXT-X-MAP:URI="header.mp4" #EXTINF 6, segment1.mp4 #EXTINF 6, segment2.mp4 …

Page 27: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

You Might Switch Your HLS Streams to IMSC1 if …

You want more control over text styling than VTT alone provides

Page 28: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

You Might Switch Your HLS Streams to IMSC1 if …

You want more control over text styling than VTT alone provides

You produce VTT by translating TTML • TTML-to-IMSC1 translation is simpler, and may have higher fidelity

Page 29: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

You Might Switch Your HLS Streams to IMSC1 if …

You want more control over text styling than VTT alone provides

You produce VTT by translating TTML • TTML-to-IMSC1 translation is simpler, and may have higher fidelity

You produce IMSC1 anyway • Reduce the number of overall streams you produce

Page 30: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

You Might Switch Your HLS Streams to IMSC1 if …

You want more control over text styling than VTT alone provides

You produce VTT by translating TTML • TTML-to-IMSC1 translation is simpler, and may have higher fidelity

You produce IMSC1 anyway • Reduce the number of overall streams you produce

Sticking with VTT is fine, too

Page 31: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Is There an IMSC2?

Not yet. It is currently being defined.

Page 32: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Is There an IMSC2?

Not yet. It is currently being defined.

We expect it to add advanced styling features for Japanese text

Page 33: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Is There an IMSC2?

Not yet. It is currently being defined.

We expect it to add advanced styling features for Japanese text

Stay tuned

Page 34: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

•New Streaming Features

Page 35: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

#EXTINF:9.34267, fileSequence9.ts #EXTINF:9.75975, fileSequence10.ts #EXTINF:9.63462, fileSequence11.ts #EXTINF:9.34267, fileSequence12.ts #EXTINF:9.75975, fileSequence13.ts #EXTINF:9.84317, fileSequence14.ts #EXTINF:8.75875,

NEW

#EXTM3U #EXT-X-TARGETDURATION:10 #EXT-X-VERSION:7 #EXT-X-MEDIA-SEQUENCE:

EXT-X-GAP: A New m3u8 Tag

9

Page 36: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

#EXTINF:9.34267, fileSequence9.ts #EXTINF:9.75975, fileSequence10.ts #EXTINF:9.63462, fileSequence11.ts #EXTINF:9.34267, fileSequence12.ts #EXTINF:9.75975, fileSequence13.ts #EXTINF:9.84317, fileSequence14.ts #EXTINF:8.75875, #EXT-X-GAP missing-Sequence15.ts

NEW

#EXTM3U #EXT-X-TARGETDURATION:10 #EXT-X-VERSION:7 #EXT-X-MEDIA-SEQUENCE:

EXT-X-GAP: A New m3u8 Tag

10

Page 37: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

#EXTINF:9.34267, fileSequence9.ts #EXTINF:9.75975, fileSequence10.ts #EXTINF:9.63462, fileSequence11.ts #EXTINF:9.34267, fileSequence12.ts #EXTINF:9.75975, fileSequence13.ts #EXTINF:9.84317, fileSequence14.ts #EXTINF:8.75875, #EXT-X-GAP missing-Sequence15.ts #EXTINF:9.88487, #EXT-X-GAP

NEW

#EXTM3U #EXT-X-TARGETDURATION:10 #EXT-X-VERSION:7 #EXT-X-MEDIA-SEQUENCE:

EXT-X-GAP: A New m3u8 Tag

11

Page 38: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

#EXTINF:9.34267, fileSequence9.ts #EXTINF:9.75975, fileSequence10.ts #EXTINF:9.63462, fileSequence11.ts #EXTINF:9.34267, fileSequence12.ts #EXTINF:9.75975, fileSequence13.ts #EXTINF:9.84317, fileSequence14.ts #EXTINF:8.75875, #EXT-X-GAP missing-Sequence15.ts #EXTINF:9.88487, #EXT-X-GAP missing-Sequence16.ts #EXTINF:9.09242,

NEW

#EXTM3U #EXT-X-TARGETDURATION:10 #EXT-X-VERSION:7 #EXT-X-MEDIA-SEQUENCE:

EXT-X-GAP: A New m3u8 Tag

12

Page 39: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

#EXTINF:9.34267, fileSequence9.ts #EXTINF:9.75975, fileSequence10.ts #EXTINF:9.63462, fileSequence11.ts #EXTINF:9.34267, fileSequence12.ts #EXTINF:9.75975, fileSequence13.ts #EXTINF:9.84317, fileSequence14.ts #EXTINF:8.75875, #EXT-X-GAP missing-Sequence15.ts #EXTINF:9.88487, #EXT-X-GAP missing-Sequence16.ts #EXTINF:9.09242, fileSequence17.ts #EXTINF:9.63462,

NEW

#EXTM3U #EXT-X-TARGETDURATION:10 #EXT-X-VERSION:7 #EXT-X-MEDIA-SEQUENCE:

EXT-X-GAP: A New m3u8 Tag

13

Page 40: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

#EXTINF:9.34267, fileSequence9.ts #EXTINF:9.75975, fileSequence10.ts #EXTINF:9.63462, fileSequence11.ts #EXTINF:9.34267, fileSequence12.ts #EXTINF:9.75975, fileSequence13.ts #EXTINF:9.84317, fileSequence14.ts #EXTINF:8.75875, #EXT-X-GAP missing-Sequence15.ts #EXTINF:9.88487, #EXT-X-GAP missing-Sequence16.ts #EXTINF:9.09242, fileSequence17.ts #EXTINF:9.63462, fileSequence18.ts #EXTINF:9.75975,

NEW

#EXTM3U #EXT-X-TARGETDURATION:10 #EXT-X-VERSION:7 #EXT-X-MEDIA-SEQUENCE:

EXT-X-GAP: A New m3u8 Tag

14

Page 41: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

#EXTINF:9.75975, fileSequence10.ts #EXTINF:9.63462, fileSequence11.ts #EXTINF:9.34267, fileSequence12.ts #EXTINF:9.75975, fileSequence13.ts #EXTINF:9.84317, fileSequence14.ts #EXTINF:8.75875, #EXT-X-GAP missing-Sequence15.ts #EXTINF:9.88487, #EXT-X-GAP missing-Sequence16.ts #EXTINF:9.09242, fileSequence17.ts #EXTINF:9.63462, fileSequence18.ts #EXTINF:9.75975, fileSequence19.ts

NEW

#EXTM3U #EXT-X-TARGETDURATION:10 #EXT-X-VERSION:7 #EXT-X-MEDIA-SEQUENCE:

EXT-X-GAP: A New m3u8 Tag

15

Page 42: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

EXT-X-GAP Tag Semantics

Gap tag indicates that a Media Segment is missing

Page 43: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

EXT-X-GAP Tag Semantics

Gap tag indicates that a Media Segment is missing • Player will not attempt to download the segment URL

Page 44: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

EXT-X-GAP Tag Semantics

Gap tag indicates that a Media Segment is missing • Player will not attempt to download the segment URL • Player will attempt to find another variant without a gap to play

Page 45: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

EXT-X-GAP Tag Semantics

Gap tag indicates that a Media Segment is missing • Player will not attempt to download the segment URL • Player will attempt to find another variant without a gap to play • If all variants have the same gap, silence will be played until gap ends

Page 46: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

EXT-X-GAP Tag Semantics

Gap tag indicates that a Media Segment is missing • Player will not attempt to download the segment URL • Player will attempt to find another variant without a gap to play • If all variants have the same gap, silence will be played until gap ends

See the WWDC HLS beta spec for details

Page 47: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Variable Support in m3u8 Playlists

Simple variable substitution in m3u8 playlists

NEW

Page 48: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Variable Support in m3u8 Playlists

Simple variable substitution in m3u8 playlists

PHP-style syntax for variables: {$filename}.ts

NEW

Page 49: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Variable Support in m3u8 Playlists

Simple variable substitution in m3u8 playlists

PHP-style syntax for variables: {$filename}.ts

EXT-X-DEFINE tag defines a variable • Or imports it from master playlist

All variables must be defined, or playlist will not parse

NEW

Page 50: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Variable Support in m3u8 Playlists

Simple variable substitution in m3u8 playlists

PHP-style syntax for variables: {$filename}.ts

EXT-X-DEFINE tag defines a variable • Or imports it from master playlist

All variables must be defined, or playlist will not parse

Allows media playlists to depend on values defined in master playlist • Media Playlist must explicitly import each variable

NEW

Page 51: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Variables in Master Playlists

#EXTM3U

#EXT-X-DEFINE:NAME="auth",VALUE="?auth_token=/aazv/54334:pp2"

#EXT-X-STREAM-INF:BANDWIDTH=1156000,RESOLUTION=640x480,CODECS="avc1.4d001e,mp4a.40.2" bipbop_gear1/prog_index.m3u8{$auth}

Page 52: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Variables in Media Playlists

#EXTM3U #EXT-X-TARGETDURATION:6

#EXT-X-DEFINE:NAME="path",VALUE="/media/encoded/asset127-a/1MB/" #EXT-X-DEFINE:IMPORT="auth"

#EXT-X-MEDIA-SEQUENCE:44 #EXTINF 6, {$path}segment44.mp4{$auth}

See the WWDC HLS beta spec for details

Page 53: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Synchronized Playback of Live Streams

Playback is synchronized using shared EXT-X-PROGRAM-DATE-TIME tags

NEW

Page 54: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Synchronized Playback of Live Streams

Playback is synchronized using shared EXT-X-PROGRAM-DATE-TIME tags

Use -[AVPlayer setRate:time:atHostTime:] to start second player in sync

NEW

Page 55: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Synchronized Playback of Live Streams

Playback is synchronized using shared EXT-X-PROGRAM-DATE-TIME tags

Use -[AVPlayer setRate:time:atHostTime:] to start second player in sync • Sample code available, "SyncStartTV"

NEW

Page 56: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

•Demo •Synchronized live stream playback

Page 57: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Resolution Cap: preferredMaximumResolution

Companion to existing bandwidth cap (preferredPeakBitRate)

NEW

Page 58: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Resolution Cap: preferredMaximumResolution

Companion to existing bandwidth cap (preferredPeakBitRate)

Programmatically specify the maximum desired content resolution

NEW

Page 59: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Resolution Cap: preferredMaximumResolution

Companion to existing bandwidth cap (preferredPeakBitRate)

Programmatically specify the maximum desired content resolution

Useful for video thumbnails and multi-stream presentations

NEW

Page 60: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Resolution Cap: preferredMaximumResolution

Companion to existing bandwidth cap (preferredPeakBitRate)

Programmatically specify the maximum desired content resolution

Useful for video thumbnails and multi-stream presentations

If there is no playable variant below the resolution cap, the lowest-resolution variant is chosen

NEW

Page 61: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Resolution Cap Example

func configureMyPlayerItem(item: AVPlayerItem) { item.preferredMaximumResolution = CGSize(height: 640, width: 480) . . . }

Page 62: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

HLS Offline Storage Management

Page 63: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4
Page 64: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4
Page 65: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

HLS Offline Storage Management

The OS can delete offline assets while the app is not running • Via Settings, or when space is required for a software update

NEW

Page 66: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

HLS Offline Storage Management

The OS can delete offline assets while the app is not running • Via Settings, or when space is required for a software update

AVAssetDownloadStorageManager

NEW

Page 67: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

HLS Offline Storage Management

The OS can delete offline assets while the app is not running • Via Settings, or when space is required for a software update

AVAssetDownloadStorageManager

Sets the policy for automatic purging of downloaded AVAssets

NEW

Page 68: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

HLS Offline Storage Management

The OS can delete offline assets while the app is not running • Via Settings, or when space is required for a software update

AVAssetDownloadStorageManager

Sets the policy for automatic purging of downloaded AVAssets • AVAssetDownloadStorageManagementPolicy has two properties:

NEW

Page 69: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

HLS Offline Storage Management

The OS can delete offline assets while the app is not running • Via Settings, or when space is required for a software update

AVAssetDownloadStorageManager

Sets the policy for automatic purging of downloaded AVAssets • AVAssetDownloadStorageManagementPolicy has two properties:

- Expiration date

NEW

Page 70: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

HLS Offline Storage Management

The OS can delete offline assets while the app is not running • Via Settings, or when space is required for a software update

AVAssetDownloadStorageManager

Sets the policy for automatic purging of downloaded AVAssets • AVAssetDownloadStorageManagementPolicy has two properties:

- Expiration date - Priority (important, default)

NEW

Page 71: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

// AVAssetDownloadStorageManager

// Get the singleton let storageManager = AVAssetDownloadStorageManager.shared()

Page 72: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

// AVAssetDownloadStorageManager

// Get the singleton let storageManager = AVAssetDownloadStorageManager.shared()

// Set the policy let newPolicy = AVMutableAssetDownloadStorageManagementPolicy() newPolicy.expirationDate = myExpiryDate newPolicy.priority = .important storageManager.setStorageManagementPolicy(newPolicy, forURL: myDownloadStorageURL)

Page 73: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

// AVAssetDownloadStorageManager

// Get the singleton let storageManager = AVAssetDownloadStorageManager.shared()

// Set the policy let newPolicy = AVMutableAssetDownloadStorageManagementPolicy() newPolicy.expirationDate = myExpiryDate newPolicy.priority = .important storageManager.setStorageManagementPolicy(newPolicy, forURL: myDownloadStorageURL)

// Get the policy let currentPolicy = storageManager.storageManagementPolicy(forURL: myDownloadStorageURL)

Page 74: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Batching up Your Offline Downloads

AVAggregateAssetDownloadTask

• Specify multiple media selections prior to initiating download

NEW

Page 75: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Batching up Your Offline Downloads

AVAggregateAssetDownloadTask

• Specify multiple media selections prior to initiating download

let task = myDownloadSession.aggregateAssetDownloadTask(with: AVURLAsset, mediaSelections: AVMediaSelection[], assetTitle: String, assetArtworkData: Data?, options: [String:Any]?)

NEW

Page 76: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Key Management Enhancements

Page 77: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

FairPlay Streaming

Page 78: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

FairPlay Streaming

FairPlay Streaming introduced in 2015

Page 79: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

FairPlay Streaming

FairPlay Streaming introduced in 2015

Protects HLS content

Page 80: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

FairPlay Streaming

FairPlay Streaming introduced in 2015

Protects HLS content

Enhancements to • Simplify workflow

Page 81: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

FairPlay Streaming

FairPlay Streaming introduced in 2015

Protects HLS content

Enhancements to • Simplify workflow• Scale adoption

Page 82: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

FairPlay Streaming

FairPlay Streaming introduced in 2015

Protects HLS content

Enhancements to • Simplify workflow• Scale adoption• Support new features

Page 83: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

FairPlay Streaming Overview

Page 84: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

FairPlay Streaming OverviewSecurely deliver Content Decryption Keys

Page 85: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Media-Centric Application

Media-Centric Application

FairPlay Streaming Overview

Page 86: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Media-Centric Application

Media-Centric Application

FairPlay Streaming Overview

FPS Key Server

Module

Page 87: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Media-Centric Application

Media-Centric Application

FairPlay Streaming Overview

FPS Key Server

Module

AVFoundation

Page 88: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Media-Centric Application

Media-Centric Application

1. Request Playback

FairPlay Streaming Overview

FPS Key Server

Module

AVFoundation

1

Page 89: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Media-Centric Application

1. Request Playback

2. Request keyAVFoundation Delegate

FairPlay Streaming Overview

FPS Key Server

Module

AVFoundation

1 2

Page 90: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Media-Centric Application

1. Request Playback

2. Request key

3. Create SPCAVFoundation Delegate

FairPlay Streaming Overview

FPS Key Server

Module

AVFoundation

1 2 3

Page 91: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Media-Centric Application

1. Request Playback

2. Request key

3. Create SPC

4. Send SPC; Get CKC

AVFoundation Delegate

FairPlay Streaming Overview

FPS Key Server

Module

AVFoundation

1 2 3

4

Page 92: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Media-Centric Application

1. Request Playback

2. Request key

3. Create SPC

4. Send SPC; Get CKC

5. Respond with CKC

AVFoundation Delegate

FairPlay Streaming Overview

FPS Key Server

Module

AVFoundation

1 2 3 5

4

Page 93: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

FairPlay Streaming Keys

Media-Centric Application

AVFoundation

AVFoundation Delegate

Page 94: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Media Data

FairPlay Streaming Keys

Media-Centric Application

AVFoundation

Playlists

AVFoundation Delegate

Page 95: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Media Data

FairPlay Streaming Keys

Media-Centric Application

AVFoundation

FPS Keys

Playlists

AVFoundation Delegate

Page 96: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Media Data

FairPlay Streaming Keys

Media-Centric Application

AVFoundation

FPS Keys

PlaylistsStart Playback

AVFoundation Delegate

Page 97: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Media Data

FairPlay Streaming Keys

Media-Centric Application

AVFoundation

FPS Keys

PlaylistsStart Playback

AVFoundation Delegate

Page 98: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Media Data

FairPlay Streaming Keys

Media-Centric Application

AVFoundation

FPS Keys

PlaylistsStart Playback

AVAssetResourceLoader

AVFoundation Delegate

Page 99: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

FairPlay Streaming KeysNEW

Page 100: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

FPS keys are more specialized resources

FairPlay Streaming KeysNEW

Page 101: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

FPS keys are more specialized resources• Freeze dry for future use (offline playback)

FairPlay Streaming KeysNEW

Page 102: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

FPS keys are more specialized resources• Freeze dry for future use (offline playback)• Set up to expire - need renewal

FairPlay Streaming KeysNEW

Page 103: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

FPS keys are more specialized resources• Freeze dry for future use (offline playback)• Set up to expire - need renewal• More such operations as content protection evolves

FairPlay Streaming KeysNEW

Page 104: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

FPS keys are more specialized resources• Freeze dry for future use (offline playback)• Set up to expire - need renewal• More such operations as content protection evolves

FPS keys can be loaded independently of assets

FairPlay Streaming KeysNEW

Page 105: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

FPS keys are more specialized resources• Freeze dry for future use (offline playback)• Set up to expire - need renewal• More such operations as content protection evolves

FPS keys can be loaded independently of assets

New API to manage and deliver decryption keys

FairPlay Streaming KeysNEW

Page 106: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

FPS keys are more specialized resources• Freeze dry for future use (offline playback)• Set up to expire - need renewal• More such operations as content protection evolves

FPS keys can be loaded independently of assets

New API to manage and deliver decryption keys

FairPlay Streaming KeysNEW

AVContentKeySession

Page 107: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

AVContentKeySession

Page 108: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

AVFoundation class for decryption keys

AVContentKeySession

Page 109: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

AVFoundation class for decryption keys• Decouples key loading from media loading or playback

AVContentKeySession

Page 110: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

AVFoundation class for decryption keys• Decouples key loading from media loading or playback• Better control over lifecycle of keys

AVContentKeySession

Page 111: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

AVFoundation class for decryption keys• Decouples key loading from media loading or playback• Better control over lifecycle of keys

Allows you to load keys at any time

AVContentKeySession

Page 112: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

AVFoundation class for decryption keys• Decouples key loading from media loading or playback• Better control over lifecycle of keys

Allows you to load keys at any time

Two ways key loading process is triggered:

AVContentKeySession

Page 113: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

AVFoundation class for decryption keys• Decouples key loading from media loading or playback• Better control over lifecycle of keys

Allows you to load keys at any time

Two ways key loading process is triggered:

AVContentKeySession

Application

Using AVContentKeySession

Page 114: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

AVFoundation class for decryption keys• Decouples key loading from media loading or playback• Better control over lifecycle of keys

Allows you to load keys at any time

Two ways key loading process is triggered:

AVContentKeySession

Application AVFoundation

Using AVContentKeySession

After playback starts (content is encrypted)

Page 115: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Improve Playback Startup

Page 116: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Improve Playback Startup

Key load time can significantly impact startup

Page 117: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Improve Playback Startup

Key load time can significantly impact startup

Keys are normally loaded on-demand

Page 118: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Improve Playback Startup

Key load time can significantly impact startup

Keys are normally loaded on-demand

Use AVContentKeySession to• Predictively load keys before requesting playback (key preloading)

Page 119: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Scale Live Playback

Page 120: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Scale Live Playback

Huge growth in live content

Page 121: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Scale Live Playback

Huge growth in live content

Extra protection with key rotation and lease renewal

Page 122: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Scale Live Playback

Huge growth in live content

Extra protection with key rotation and lease renewal

Impulse load on key server

Page 123: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Scale Live Playback

Huge growth in live content

Extra protection with key rotation and lease renewal

Impulse load on key server

Use AVContentKeySession to• Load balance key requests at the point of origin

Page 124: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Key Server

Scale Live Playback

Page 125: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Initial Key Request

Key Server

Scale Live Playback

Multiple Users Watching a Live Stream

Page 126: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Scale Live Playback

Key Server

Page 127: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Scale Live Playback

Key Server

New Key Request (Rotation / Renewal)

Page 128: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Scale Live Playback

Key ServerKey Server

Page 129: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Scale Live Playback

Key Server

Page 130: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Scale Live Playback

New Key Request (Rotation / Renewal)

Key Server

Page 131: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Scale Live Playback

Key ServerKey Server

Page 132: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Scale Live Playback

Key Server

Page 133: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Scale Live Playback

New Key Request (Rotation / Renewal)

Key Server

Page 134: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Key Server

Scale Live Playback

Page 135: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Key Server

Scale Live Playback

Page 136: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Key ServerKey Server

Scale Live Playback

Page 137: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Key ServerKey Server

Scale Live Playback

Page 138: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Using AVContentKeySession to initiate Key Loading Process

//Create AVContentKeySession instance for FairPlay Streaming Key Delivery

let contentKeySession = AVContentKeySession(keySystem: .fairPlayStreaming)

//Register self as Delegate

contentKeySession.setDelegate(self, queue: DispatchQueue(label: "DelegateQueue"))

//Initiate Key Loading Process

contentKeySession.processContentKeyRequest(withIdentifier: "skd://myKey", initializationData: nil, options: nil)

Page 139: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Using AVContentKeySession to initiate Key Loading Process

//Create AVContentKeySession instance for FairPlay Streaming Key Delivery

let contentKeySession = AVContentKeySession(keySystem: .fairPlayStreaming)

//Register self as Delegate

contentKeySession.setDelegate(self, queue: DispatchQueue(label: "DelegateQueue"))

//Initiate Key Loading Process

contentKeySession.processContentKeyRequest(withIdentifier: "skd://myKey", initializationData: nil, options: nil)

Page 140: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Using AVContentKeySession to initiate Key Loading Process

//Create AVContentKeySession instance for FairPlay Streaming Key Delivery

let contentKeySession = AVContentKeySession(keySystem: .fairPlayStreaming)

//Register self as Delegate

contentKeySession.setDelegate(self, queue: DispatchQueue(label: "DelegateQueue"))

//Initiate Key Loading Process

contentKeySession.processContentKeyRequest(withIdentifier: "skd://myKey", initializationData: nil, options: nil)

Page 141: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Using AVContentKeySession to initiate Key Loading Process

//Create AVContentKeySession instance for FairPlay Streaming Key Delivery

let contentKeySession = AVContentKeySession(keySystem: .fairPlayStreaming)

//Register self as Delegate

contentKeySession.setDelegate(self, queue: DispatchQueue(label: "DelegateQueue"))

//Initiate Key Loading Process

contentKeySession.processContentKeyRequest(withIdentifier: "skd://myKey", initializationData: nil, options: nil)

//Tag in your Media Playlist

#EXT-X-KEY:METHOD=SAMPLE-AES,URI="skd://myKey",KEYFORMAT=“com.apple.streamingkeydelivery", KEYFORMATVERSIONS="1"

//Using AVContentKeySession to initiate Key Loading Process

//Create AVContentKeySession instance for FairPlay Streaming Key Delivery

let contentKeySession = AVContentKeySession(keySystem: .fairPlayStreaming)

//Register self as Delegate

contentKeySession.setDelegate(self, queue: DispatchQueue(label: "DelegateQueue"))

//Initiate Key Loading Process

contentKeySession.processContentKeyRequest(withIdentifier: "skd://myKey", initializationData: nil, options: nil)

Page 142: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Delegate callback that delivers AVContentKeyRequest

func contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVContentKeyRequest) {

}

Page 143: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Delegate callback that delivers AVContentKeyRequest

func contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVContentKeyRequest) {

}

Page 144: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Delegate callback that delivers AVContentKeyRequest

func contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVContentKeyRequest) {

//Request SPC

keyRequest.makeStreamingContentKeyRequestData(forApp: appCertificate, contentIdentifier: assetID, options: keyRequestOptions) {

(spcBytes: Data?, spcCreationError: Error?) in

//Send SPC to Key Server and obtain CKC

if let ckcBytes = getCKCFromKeyServer(forSPC: spcBytes) { //Create Response using the CKC you obtained from Key Server

let response = AVContentKeyResponse(fairPlayStreamingKeyResponseData: ckcBytes)

//Set Response on the Key Request object when you are about to start playback

keyRequest.processContentKeyResponse(response)

}

}

}

Page 145: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Delegate callback that delivers AVContentKeyRequest

func contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVContentKeyRequest) {

//Request SPC

keyRequest.makeStreamingContentKeyRequestData(forApp: appCertificate, contentIdentifier: assetID, options: keyRequestOptions) {

(spcBytes: Data?, spcCreationError: Error?) in

//Send SPC to Key Server and obtain CKC

if let ckcBytes = getCKCFromKeyServer(forSPC: spcBytes) { //Create Response using the CKC you obtained from Key Server

let response = AVContentKeyResponse(fairPlayStreamingKeyResponseData: ckcBytes)

//Set Response on the Key Request object when you are about to start playback

keyRequest.processContentKeyResponse(response)

}

}

}

Page 146: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Delegate callback that delivers AVContentKeyRequest

func contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVContentKeyRequest) {

//Request SPC

keyRequest.makeStreamingContentKeyRequestData(forApp: appCertificate, contentIdentifier: assetID, options: keyRequestOptions) {

(spcBytes: Data?, spcCreationError: Error?) in

//Send SPC to Key Server and obtain CKC

if let ckcBytes = getCKCFromKeyServer(forSPC: spcBytes) { //Create Response using the CKC you obtained from Key Server

let response = AVContentKeyResponse(fairPlayStreamingKeyResponseData: ckcBytes)

//Set Response on the Key Request object when you are about to start playback

keyRequest.processContentKeyResponse(response)

}

}

}

Page 147: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Delegate callback that delivers AVContentKeyRequest

func contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVContentKeyRequest) {

//Request SPC

keyRequest.makeStreamingContentKeyRequestData(forApp: appCertificate, contentIdentifier: assetID, options: keyRequestOptions) {

(spcBytes: Data?, spcCreationError: Error?) in

//Send SPC to Key Server and obtain CKC

if let ckcBytes = getCKCFromKeyServer(forSPC: spcBytes) { //Create Response using the CKC you obtained from Key Server

let response = AVContentKeyResponse(fairPlayStreamingKeyResponseData: ckcBytes)

//Set Response on the Key Request object when you are about to start playback

keyRequest.processContentKeyResponse(response)

}

}

}

Page 148: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Delegate callback that delivers AVContentKeyRequest

func contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVContentKeyRequest) {

//Request SPC

keyRequest.makeStreamingContentKeyRequestData(forApp: appCertificate, contentIdentifier: assetID, options: keyRequestOptions) {

(spcBytes: Data?, spcCreationError: Error?) in

//Send SPC to Key Server and obtain CKC

if let ckcBytes = getCKCFromKeyServer(forSPC: spcBytes) { //Create Response using the CKC you obtained from Key Server

let response = AVContentKeyResponse(fairPlayStreamingKeyResponseData: ckcBytes)

//Set Response on the Key Request object when you are about to start playback

keyRequest.processContentKeyResponse(response)

}

}

}

Page 149: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Responding to Key Requests

96

Page 150: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Responding to Key Requests

Be mindful while responding to key requests

96

Page 151: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Responding to Key Requests

Be mindful while responding to key requests• Secure decrypt slots - limited resource

96

Page 152: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Responding to Key Requests

Be mindful while responding to key requests• Secure decrypt slots - limited resource• Set CKC as response only for required key requests

96

Page 153: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Responding to Key Requests

Be mindful while responding to key requests• Secure decrypt slots - limited resource• Set CKC as response only for required key requests• Respond to key requests just before requesting playback

96

Page 154: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Persistent FPS Keys

Page 155: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Persistent FPS Keys

Persistent FPS keys protect offline HLS assets

Page 156: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Persistent FPS Keys

Persistent FPS keys protect offline HLS assets

Use AVContentKeySession to• Create persistent keys before requesting HLS asset download

Page 157: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Persistent FPS Keys

Persistent FPS keys protect offline HLS assets

Use AVContentKeySession to• Create persistent keys before requesting HLS asset download

Simpler and cleaner workflow

Page 158: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Persistent FPS Keys

Persistent FPS keys protect offline HLS assets

Use AVContentKeySession to• Create persistent keys before requesting HLS asset download

Simpler and cleaner workflow

Work with AVPersistableContentKeyRequest

Page 159: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Delegate callback that delivers AVContentKeyRequest func contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVContentKeyRequest) { //Check if you are creating a Persistent Decryption Key if (creatingPersistentDecryptionKey(keyRequest.identifier)) { //Request a Persistable Key Request

keyRequest.respondByRequestingPersistableContentKeyRequest() return } //Continue with AVContentKeyRequest while loading non-Persistent Decryption Key }

Page 160: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Delegate callback that delivers AVContentKeyRequest func contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVContentKeyRequest) { //Check if you are creating a Persistent Decryption Key if (creatingPersistentDecryptionKey(keyRequest.identifier)) { //Request a Persistable Key Request

keyRequest.respondByRequestingPersistableContentKeyRequest() return } //Continue with AVContentKeyRequest while loading non-Persistent Decryption Key }

Page 161: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Delegate callback that delivers AVContentKeyRequest func contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVContentKeyRequest) { //Check if you are creating a Persistent Decryption Key if (creatingPersistentDecryptionKey(keyRequest.identifier)) { //Request a Persistable Key Request

keyRequest.respondByRequestingPersistableContentKeyRequest() return } //Continue with AVContentKeyRequest while loading non-Persistent Decryption Key }

Page 162: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Delegate callback that delivers AVContentKeyRequest func contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVContentKeyRequest) { //Check if you are creating a Persistent Decryption Key if (creatingPersistentDecryptionKey(keyRequest.identifier)) { //Request a Persistable Key Request

keyRequest.respondByRequestingPersistableContentKeyRequest() return } //Continue with AVContentKeyRequest while loading non-Persistent Decryption Key }

Page 163: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Delegate callback that delivers AVContentKeyRequest func contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVContentKeyRequest) { //Check if you are creating a Persistent Decryption Key if (creatingPersistentDecryptionKey(keyRequest.identifier)) { //Request a Persistable Key Request

keyRequest.respondByRequestingPersistableContentKeyRequest() return } //Continue with AVContentKeyRequest while loading non-Persistent Decryption Key }

//Delegate callback that delivers AVPersistableContentKeyRequest func contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVPersistableContentKeyRequest) { }

Page 164: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Delegate callback that delivers AVPersistableContentKeyRequest func contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVPersistableContentKeyRequest) { }

Page 165: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Delegate callback that delivers AVPersistableContentKeyRequest func contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVPersistableContentKeyRequest) { //Request SPC keyRequest.makeStreamingContentKeyRequestData(forApp: appCertificate, contentIdentifier: assetID, options: keyRequestOptions) { (spcBytes: Data?, spcCreationError: Error?) in //Send SPC to Key Server and obtain CKC if let ckcBytes = getCKCFromKeyServer(forSPC: spcBytes) { //Request Persistent Decryption Key by providing the CKC let persistentKey = try? keyRequest.persistableContentKey(fromKeyVendorResponse: ckcBytes!, options: nil)

//Stow persistentKey data blob for future use } } }

Page 166: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Delegate callback that delivers AVPersistableContentKeyRequest func contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVPersistableContentKeyRequest) { //Request SPC keyRequest.makeStreamingContentKeyRequestData(forApp: appCertificate, contentIdentifier: assetID, options: keyRequestOptions) { (spcBytes: Data?, spcCreationError: Error?) in //Send SPC to Key Server and obtain CKC if let ckcBytes = getCKCFromKeyServer(forSPC: spcBytes) { //Request Persistent Decryption Key by providing the CKC let persistentKey = try? keyRequest.persistableContentKey(fromKeyVendorResponse: ckcBytes!, options: nil)

//Stow persistentKey data blob for future use } } }

Page 167: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Delegate callback that delivers AVPersistableContentKeyRequest func contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVPersistableContentKeyRequest) { //Request SPC keyRequest.makeStreamingContentKeyRequestData(forApp: appCertificate, contentIdentifier: assetID, options: keyRequestOptions) { (spcBytes: Data?, spcCreationError: Error?) in //Send SPC to Key Server and obtain CKC if let ckcBytes = getCKCFromKeyServer(forSPC: spcBytes) { //Request Persistent Decryption Key by providing the CKC let persistentKey = try? keyRequest.persistableContentKey(fromKeyVendorResponse: ckcBytes!, options: nil)

//Stow persistentKey data blob for future use } } }

Page 168: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Delegate callback that delivers AVPersistableContentKeyRequest func contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVPersistableContentKeyRequest) { //Request SPC keyRequest.makeStreamingContentKeyRequestData(forApp: appCertificate, contentIdentifier: assetID, options: keyRequestOptions) { (spcBytes: Data?, spcCreationError: Error?) in //Send SPC to Key Server and obtain CKC if let ckcBytes = getCKCFromKeyServer(forSPC: spcBytes) { //Request Persistent Decryption Key by providing the CKC let persistentKey = try? keyRequest.persistableContentKey(fromKeyVendorResponse: ckcBytes!, options: nil)

//Stow persistentKey data blob for future use } } }

Page 169: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Delegate callback that delivers AVPersistableContentKeyRequest func contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVPersistableContentKeyRequest) { //Create Response using the Persistent Key that was created earlier let response = AVContentKeyResponse(fairPlayStreamingKeyResponseData: persistentKey) //Set Response on the Persistable Key Request Object keyRequest.processContentKeyResponse(response) }

Page 170: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Delegate callback that delivers AVPersistableContentKeyRequest func contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVPersistableContentKeyRequest) { //Create Response using the Persistent Key that was created earlier let response = AVContentKeyResponse(fairPlayStreamingKeyResponseData: persistentKey) //Set Response on the Persistable Key Request Object keyRequest.processContentKeyResponse(response) }

Page 171: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

//Delegate callback that delivers AVPersistableContentKeyRequest func contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVPersistableContentKeyRequest) { //Create Response using the Persistent Key that was created earlier let response = AVContentKeyResponse(fairPlayStreamingKeyResponseData: persistentKey) //Set Response on the Persistable Key Request Object keyRequest.processContentKeyResponse(response) }

Page 172: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

AVContentKeySession

Page 173: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Works similarly to AVAssetResourceLoader

AVContentKeySession

Page 174: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Works similarly to AVAssetResourceLoader

AVAssetResourceLoadingRequest

AVContentKeySession

AVContentKeyRequest

Page 175: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Works similarly to AVAssetResourceLoader

AVAssetResourceLoadingRequest

AVAssetResourceLoaderDelegate

AVContentKeySession

AVContentKeyRequest

AVContentKeySessionDelegate

Page 176: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Works similarly to AVAssetResourceLoader

AVAssetResourceLoadingRequest

AVAssetResourceLoaderDelegate

Except not tied to AVURLAsset at the time of creation

AVContentKeySession

AVContentKeyRequest

AVContentKeySessionDelegate

Page 177: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Works similarly to AVAssetResourceLoader

AVAssetResourceLoadingRequest

AVAssetResourceLoaderDelegate

Except not tied to AVURLAsset at the time of creation

Create AVContentKeySession at any time

AVContentKeySession

AVContentKeyRequest

AVContentKeySessionDelegate

Page 178: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Works similarly to AVAssetResourceLoader

AVAssetResourceLoadingRequest

AVAssetResourceLoaderDelegate

Except not tied to AVURLAsset at the time of creation

Create AVContentKeySession at any time

Add asset as a content key recipient before requesting playback• Using addContentKeyRecipient()

AVContentKeySession

AVContentKeyRequest

AVContentKeySessionDelegate

Page 179: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Recommended Usage

Page 180: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Recommended Usage

AVContentKeySession for• Content decryption keys

Page 181: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Recommended Usage

AVContentKeySession for• Content decryption keys

AVAssetResourceLoader for• Playlists, media data, and metadata

Page 182: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Recommended Usage

AVContentKeySession for• Content decryption keys

AVAssetResourceLoader for• Playlists, media data, and metadata• Key loading is still supported

Page 183: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Recommended Usage

AVContentKeySession for• Content decryption keys

AVAssetResourceLoader for• Playlists, media data, and metadata• Key loading is still supported

What if AVURLAsset has both delegates installed?

Page 184: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Recommended Usage

AVContentKeySession for• Content decryption keys

AVAssetResourceLoader for• Playlists, media data, and metadata• Key loading is still supported

What if AVURLAsset has both delegates installed?• AVAssetResourceLoader delegate should defer key requests to AVContentKeySession

Page 185: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

func resourceLoader(_ resourceLoader: AVAssetResourceLoader, shouldWaitForLoadingOfRequestedResource loadingRequest: AVAssetResourceLoadingRequest) -> Bool { //Check if the resource loading request is for Content Decryption Key if (requestIsForContentDecryptionKey(request: loadingRequest)) { //Defer loading of Content Decryption Key to AVContentKeySession loadingRequest.contentInformationRequest?.contentType = AVStreamingKeyDeliveryContentKeyType loadingRequest.finishLoading() return true }

//Continue loading all other resources (playlists, media data & metadata)

return true }

Page 186: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

func resourceLoader(_ resourceLoader: AVAssetResourceLoader, shouldWaitForLoadingOfRequestedResource loadingRequest: AVAssetResourceLoadingRequest) -> Bool { //Check if the resource loading request is for Content Decryption Key if (requestIsForContentDecryptionKey(request: loadingRequest)) { //Defer loading of Content Decryption Key to AVContentKeySession loadingRequest.contentInformationRequest?.contentType = AVStreamingKeyDeliveryContentKeyType loadingRequest.finishLoading() return true }

//Continue loading all other resources (playlists, media data & metadata)

return true }

Page 187: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

func resourceLoader(_ resourceLoader: AVAssetResourceLoader, shouldWaitForLoadingOfRequestedResource loadingRequest: AVAssetResourceLoadingRequest) -> Bool { //Check if the resource loading request is for Content Decryption Key if (requestIsForContentDecryptionKey(request: loadingRequest)) { //Defer loading of Content Decryption Key to AVContentKeySession loadingRequest.contentInformationRequest?.contentType = AVStreamingKeyDeliveryContentKeyType loadingRequest.finishLoading() return true }

//Continue loading all other resources (playlists, media data & metadata)

return true }

Page 188: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

func resourceLoader(_ resourceLoader: AVAssetResourceLoader, shouldWaitForLoadingOfRequestedResource loadingRequest: AVAssetResourceLoadingRequest) -> Bool { //Check if the resource loading request is for Content Decryption Key if (requestIsForContentDecryptionKey(request: loadingRequest)) { //Defer loading of Content Decryption Key to AVContentKeySession loadingRequest.contentInformationRequest?.contentType = AVStreamingKeyDeliveryContentKeyType loadingRequest.finishLoading() return true }

//Continue loading all other resources (playlists, media data & metadata)

return true }

Page 189: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

func resourceLoader(_ resourceLoader: AVAssetResourceLoader, shouldWaitForLoadingOfRequestedResource loadingRequest: AVAssetResourceLoadingRequest) -> Bool { //Check if the resource loading request is for Content Decryption Key if (requestIsForContentDecryptionKey(request: loadingRequest)) { //Defer loading of Content Decryption Key to AVContentKeySession loadingRequest.contentInformationRequest?.contentType = AVStreamingKeyDeliveryContentKeyType loadingRequest.finishLoading() return true }

//Continue loading all other resources (playlists, media data & metadata)

return true }

Page 190: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Dual Expiry Windows for Persistent KeysNEW

Page 191: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Dual Expiry Windows for Persistent Keys

Support dual expiry windows for persistent FPS keys

NEW

Page 192: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Dual Expiry Windows for Persistent Keys

Support dual expiry windows for persistent FPS keys

Dual expiry window model for rentals

NEW

Page 193: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Dual Expiry Windows for Persistent Keys

Support dual expiry windows for persistent FPS keys

Dual expiry window model for rentals

Works for both online and offline playback

NEW

Page 194: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Dual Expiry Windows for Persistent Keys

Support dual expiry windows for persistent FPS keys

Dual expiry window model for rentals

Works for both online and offline playback

Server opts in by sending suitable descriptor in CKC

NEW

Page 195: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Dual Expiry Windows for Persistent Keys

Support dual expiry windows for persistent FPS keys

Dual expiry window model for rentals

Works for both online and offline playback

Server opts in by sending suitable descriptor in CKC• Storage expiry

NEW

Page 196: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Dual Expiry Windows for Persistent Keys

Support dual expiry windows for persistent FPS keys

Dual expiry window model for rentals

Works for both online and offline playback

Server opts in by sending suitable descriptor in CKC• Storage expiry• Playback expiry

NEW

Page 197: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Dual Expiry Windows for Persistent Keys

Page 198: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Dual Expiry Windows for Persistent Keys

Page 199: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Dual Expiry Windows for Persistent Keys

User rents content

Page 200: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

K1

Create Persistent Key with CKC

Dual Expiry Windows for Persistent Keys

User rents content

Page 201: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

K1 Expires in 30 Days

K1

Create Persistent Key with CKC

Dual Expiry Windows for Persistent Keys

Page 202: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

K1 Expires in 30 DaysK1

Dual Expiry Windows for Persistent Keys

Page 203: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

K1 Expires in 30 DaysK1

Dual Expiry Windows for Persistent Keys

User starts playback

Page 204: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

K1 Expires in 30 Days

K1

Dual Expiry Windows for Persistent Keys

User starts playback

Use K1 to answer Key Request

Page 205: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

K1 Expires in 30 Days

K1

Dual Expiry Windows for Persistent Keys

Receive updated Persistent Key

Use K1 to answer Key Request

K2

Page 206: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

K1 Expires in 30 Days

K1

Dual Expiry Windows for Persistent Keys

K2 Expires in 24 Hours

Receive updated Persistent Key

K2

Page 207: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

K1 Expires in 30 DaysK1 is Expired

K1

Dual Expiry Windows for Persistent Keys

K2 Expires in 24 Hours

Receive updated Persistent Key

K1 K2

Page 208: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

K1 Expires in 30 DaysK1 is Expired

K1

Dual Expiry Windows for Persistent Keys

K2 Expires in 24 Hours

K1

K2

Page 209: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

K1 Expires in 30 DaysK1 is Expired

K1

Dual Expiry Windows for Persistent Keys

K2 Expires in 24 Hours

K1

Updated Persistent Key sent through delegate callback:

didUpdatePersistableContentKey

K2

Page 210: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Summary

Page 211: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Summary

HEVC video and IMSC1 subtitles now available in HLS

Page 212: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Summary

HEVC video and IMSC1 subtitles now available in HLS

New EXT-X-GAP tag and metavariable support in m3u8

Page 213: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Summary

HEVC video and IMSC1 subtitles now available in HLS

New EXT-X-GAP tag and metavariable support in m3u8

Synchronized playback of live HLS streams

Page 214: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Summary

HEVC video and IMSC1 subtitles now available in HLS

New EXT-X-GAP tag and metavariable support in m3u8

Synchronized playback of live HLS streams

Better control over offline storage and aggregate asset downloads

Page 215: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Summary

HEVC video and IMSC1 subtitles now available in HLS

New EXT-X-GAP tag and metavariable support in m3u8

Synchronized playback of live HLS streams

Better control over offline storage and aggregate asset downloads

AVContentKeySession API to manage and deliver content keys

Page 216: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Summary

HEVC video and IMSC1 subtitles now available in HLS

New EXT-X-GAP tag and metavariable support in m3u8

Synchronized playback of live HLS streams

Better control over offline storage and aggregate asset downloads

AVContentKeySession API to manage and deliver content keys

Rental support for persistent FPS keys

Page 217: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

More Informationhttps://developer.apple.com/wwdc17/504

Page 218: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

Error Handling Best Practices for HTTP Live Streaming WWDC 2017 Video

HLS Authoring Update WWDC 2017 Video

Introducing HEIF and HEVC Executive Ballroom Tuesday 4:10PM

Media and Gaming Accessibility Grand Ballroom A Wednesday 3:10PM

Introducing AirPlay 2 Executive Ballroom Thursday 4:10PM

Working with HEIF and HEVC Hall 2 Friday 11:00PM

Related Sessions

Page 219: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

AVFoundation Lab 1 Technology Lab F Tue 1:00 - 4:10 PM

HTTP Live Streaming Lab 1 Technology Lab F Wed 9:00 - 11:00 AM

AVFoundation Lab 2 Technology Lab G Wed 11:00 AM - 1:00 PM

AVFoundation Lab 3 Technology Lab F Thur 12:00 - 3:00 PM

HTTP Live Streaming Lab 2 Technology Lab G Thur 3:10 - 6:00 PM

Labs

Page 220: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4

AVKit Lab 1 Technology Lab F Tue 1:00 - 4:10 PM

HEIF/HEVC Lab 1 Technology Lab A Wed 9:00 - 11:00 AM

AirPlay Lab 1 Technology Lab A Wed 11:00 AM - 1:00 PM

AVKit Lab 2 Technology Lab G Wed 11:00 AM - 1:00 PM

AirPlay Lab 2 Technology Lab A Fri 9:00 - 11:00 AM

HEIF/HEVC Lab 2 Technology Lab F Fri 12:00 - 1:50 PM

Labs (continued)

Page 221: 504 Advances in HTTP Live Streaming 04 D...HEVC and H.264 variants can appear in the same Master playlist • I-frame playlists too • HEVC must be fMP4 • H.264 can be TS or fMP4