35
ExoPlayer for Application Developers Google Developers Summit - April 28 Hassan Abid - GDE

ExoPlayer for Application developers

Embed Size (px)

Citation preview

Page 1: ExoPlayer for Application developers

ExoPlayer for Application Developers

Google Developers Summit - April 28

Hassan Abid - GDE

Page 2: ExoPlayer for Application developers

Contents

● Media Playback in Android

● ExoPlayer Overview

● Adaptive Media Playback Protocols and Demo

● Content Protection

2

Page 3: ExoPlayer for Application developers

Terms

DASH : Dynamic Adaptive Streaming over HTTP

HLS : Http Live Streaming

DRM : Digital Rights Management

MPD : Media Presentation Description

ABR : Adaptive Bitrate Streaming

3

Page 5: ExoPlayer for Application developers

It supports features not currently provided by MediaPlayer, including DASH, SmoothStreaming and Common Encryption.

5

ExoPlayer is an open source, application level media player built on top of Android’s low level media APIs (Mediacodec and MediaExtractor). Google is already using it for Youtube and Movies app

Page 6: ExoPlayer for Application developers

Pros

● Supports DASH,HLS, Smooth-Streaming …

● DRM protected content

● Customizable

● Easily Updatable

● Few device specific issues

6

Page 7: ExoPlayer for Application developers

Cons

● ExoPlayer’s standard audio and video components rely on Android’s MediaCodec API, which was released in Android 4.1 Jelly Bean (API level 16). Hence they do not work on earlier versions of Android.

7

Page 8: ExoPlayer for Application developers

Component Diagram

FrameworkSampleSource

ExoPlayer (Application Level)

Video/Audio/Text TrackRenderers

Media CodecMedia Extractor

Android Framework

BufferingNetworking Extraction Decoding

Audio Track

8

Rendering

Page 9: ExoPlayer for Application developers

Interfaces● TrackRenderer

○ MediaCodecVideoTrackRenderer

○ MediaCodecAudioTrackRenderer

○ TextTrackRenderer

● SampleSource○ ExtractorSampleSource (Mp4)

○ ChunkSampleSource (Dash, Smooth Streaming)

○ HlsSampleSource (HLS)

● DataSource○ DefaultUriDataSource

○ AssetDataSource9

Page 10: ExoPlayer for Application developers

Usage -MP4

DefaultUriDataSource ExtractorSampleSource

Mp4Extractor

MediaCodecVideoTrackRenderer

MediaCodecAudioTrackRenderer

ExoPlayer - MP4

Mediacodec AudioTrack

Decoding RenderingAndroid Framework

10

Page 11: ExoPlayer for Application developers

Execution Flow

ExoPlayerImplInternal

MediaCodecAudioTrackRenderer

MediaCodecVideoTrackRenderer

SampleSource for Audio Track

SampleSource for Video Track

MediaCodec

AudioTrack

Time Source

1:doSomeWork()

11

2: readData() 3: queueInputBuffer()

4: dequeOutputBuffer()5: handleBuffer()

6: doSomeWork()

7: getCurrentPositionUS()

8: readData()

9: decode & render()

Page 14: ExoPlayer for Application developers

Adaptive Media Playbacks or ABR

● Adaptive bitrate streaming over HTTP

● Accommodate changing network conditions

● No special firewalls, proxies, or cache is required

● Efficient and cost-effective

14

Page 15: ExoPlayer for Application developers

Adaptive Media Playbacks (Example)

15

Page 16: ExoPlayer for Application developers

Adaptive Media Playbacks (Protocols)

● Dynamic Adaptive Streaming over HTTP (DASH) ○ Mpeg

● Smooth Streaming○ Microsoft

● HTTP Live Streaming (HLS)○ Apple

16

Page 17: ExoPlayer for Application developers

DASH● First major trial started in 2012 London Olympics ● How it works? [ref]

HTTP Server

segment

segment

segment

segment

segment

segment

segment

segment

segment

segment

segment

segment

segment

segment

segment

segment

MPD

Dash Client

HTTP ClientHTTP/1.1

Media Player

Control Heuristics

MPD Delivery MPD Parser

Segment Parser

17

1

2

Page 19: ExoPlayer for Application developers

DASH Object Model

DefaultUriDataSource DashChunkSource

FixedEvaluator

MediaCodecVideoTrackRenderer

ExoPlayer - Dash

Mediacodec AudioTrack

Decoding Rendering

DefaultUriDataSource DashChunkSource

AdaptiveEvaluator

ChunkSampleSource MediaCodecAudioTrackRenderer

DefaultLoadControl

ChunkSampleSource

Android Framework

19

Page 21: ExoPlayer for Application developers

HLS● Developed by Apple● How it works? [ref]

Distribution Client

HTTP/1.1

Index file (.m3u8)

.ts

.ts .ts

.ts

21

Page 22: ExoPlayer for Application developers

HLS Index File .M3U8#EXT-X-VERSION:3

#EXTM3U

#EXT-X-TARGETDURATION:10

#EXT-X-MEDIA-SEQUENCE:1

# Old-style integer duration; avoid for newer clients.

#EXTINF:10,

http://media.example.com/segment0.ts

# New-style floating-point duration; use for modern clients.

#EXTINF:10.0,

http://media.example.com/segment1.ts

#EXTINF:9.5,

http://media.example.com/segment2.ts

#EXT-X-ENDLIST22

Page 23: ExoPlayer for Application developers

HLS Stream Alternates

Index file

Alternate -A

Index file

Alternate - B

Index file

Alternate - C

Index file

.ts

.ts .ts

.ts

.ts

.ts .ts

.ts

.ts

.ts .ts

.ts

23

Page 24: ExoPlayer for Application developers

24

HLS advance index file

Page 25: ExoPlayer for Application developers

HLS Object Model

DefaultUriDataSource HLSChunkSource MediaCodecVideoTrackRenderer

MediaCodecAudioTrackRenderer

ExoPlayer - HLS

Mediacodec AudioTrack

Decoding Rendering

HLSSampleSource

Android Framework

25

FormatEvaluator LoadControl

Page 27: ExoPlayer for Application developers

Customization

● TrackRenderer○ Example : TextTrackRenderer

● Extractor

● SampleSource

● FormatEvaluator

● DataSource27

Page 28: ExoPlayer for Application developers

Customization Example

CacheDataSource DashChunkSource

FixedEvaluator

MediaCodecVideoTrackRenderer

ExoPlayer - Dash

Mediacodec AudioTrack

Decoding Rendering

CacheDataSource DashChunkSource

AdaptiveEvaluator

ChunkSampleSource MediaCodecAudioTrackRenderer

DefaultLoadControl

ChunkSampleSource

Android Framework

DefaultUriDataSource

DefaultUriDataSource

28

Page 29: ExoPlayer for Application developers

Digital Rights Management

Microsoft PlayReady Google Widevine

Fairplay (Apple) Adobe PrimeTime

29

Page 31: ExoPlayer for Application developers

Digital Rights Management (ExoPlayer)

● DrmSessionManager○ StreamingDrmSessionManager

○ On Android 4.3 (18) and higher

● WideVine DRM○ DASH

31

Page 32: ExoPlayer for Application developers

Conclusions

● ExoPlayer is an application level media player which can

be easily updated and extended by developers

● It is Open Source

● Start with demo code here

32

Page 33: ExoPlayer for Application developers

Applications using ExoPlayer

33

Page 35: ExoPlayer for Application developers

Thank You!Sample Code : https://github.com/hassanabidpk/ExoPlayerSample

Contact : [email protected]

Web : http://hassanabid.com35