Android builders summit The Android media framework

Similar documents
Serving Media with NGINX Plus

An Android Multimedia Framework based on Gstreamer

SECURE IMPLEMENTATIONS OF CONTENT PROTECTION (DRM) SCHEMES ON CONSUMER ELECTRONIC DEVICES

Android on i.mx Applications Processors

Multimedia Playback & Streaming

Android Virtualization from Sierraware. Simply Secure

Inside Android's UI Embedded Linux Conference Europe 2012 Karim

High Efficiency Video Coding (HEVC) or H.265 is a next generation video coding standard developed by ITU-T (VCEG) and ISO/IEC (MPEG).

The MeeGo Multimedia Stack. Dr. Stefan Kost Nokia - The MeeGo Multimedia Stack - CELF Embedded Linux Conference Europe

Abstractions from Multimedia Hardware. Libraries. Abstraction Levels

Contents. Getting Set Up Contents 2

Developing PlayReady Clients

Fragmented MPEG-4 Technology Overview

SmartTV User Interface Development for SmartTV using Web technology and CEA2014. George Sarosi

DVBLink For IPTV. Installation and configuration manual

Document OwnCloud Collaboration Server (DOCS) User Manual. How to Access Document Storage

Wowza Media Systems provides all the pieces in the streaming puzzle, from capture to delivery, taking the complexity out of streaming live events.

Harmonizing policy management with Murphy in GENIVI, AGL and TIZEN IVI

Spring Design ScreenShare Service SDK Instructions

Adaptive HTTP streaming and HTML5. 1 Introduction. 1.1 Netflix background. 1.2 The need for standards. W3C Web and TV Workshop, 8-9 February 2011

Streaming Networks with VLC. Jean-Paul Saman

Windows Embedded Compact 7 Multimedia Features 1

IxLoad TM Adobe HDS Player Emulation

Specialized Android APP Development Program with Java (SAADPJ) Duration 2 months

Introduction of Fujitsu DRM Solution for Marlin DRM/MPEG-DASH Solutions

Visualizing gem5 via ARM DS-5 Streamline. Dam Sunwoo ARM R&D December 2012

Creating and Using Databases for Android Applications

CSE 237A Final Project Final Report

SA8 T1 Meeting 3 JANUS Basics and Applications

ACTi SDK C Library Edition v1.2 SP1. API Reference Guide

ANDROID PROGRAMMING - INTRODUCTION. Roberto Beraldi

SIP based HD Video Conferencing on OMAP4

Affdex SDK for Windows!

Overview of CS 282 & Android

Creating Content for ipod + itunes

DVBLink TVSource. Installation and configuration manual

ImagineWorldClient Client Management Software. User s Manual. (Revision-2)

GY-HM850 & GY-HM890 camcorders LIVE STREAMING QUICK REFERENCE GUIDE

Android Operating System

OPTIMIZE DMA CONFIGURATION IN ENCRYPTION USE CASE. Guillène Ribière, CEO, System Architect

ITG Software Engineering

HDMI on OMAP4 PANDA. Design, Challenges and Lessons Learned Mythri P K

Office Mix Tutorial: Adding Captions & Subtitles in PowerPoint 2013 & Office 365

Building an On-Demand Video Service with Microsoft Azure Media Services

Internet Captioning - Implications of the Multi-platform, Multi-Display Ecosystem

Blackboard Mobile Learn: Best Practices for Making Online Courses Mobile-Friendly

HbbTV Forum Nederland Specification for use of HbbTV in the Netherlands

JavaFX Session Agenda

Live and VOD OTT Streaming Practical South African Technology Considerations

User's Manual. iphone Codec. for SelenioFlex Ingest

For the Future IT Convergence Vehicle Connected & Downloadable Infotainment Platform. Pusik Park. Korea Electronics Technology Institute

PlayReady App Creation Tutorial

AAC-ELD based Audio Communication on Android

Getting Started with the Skillsoft Learning App

Using Mobile Processors for Cost Effective Live Video Streaming to the Internet

Multimedia Framework Overview. JongHyuk Choi

A Method of Pseudo-Live Streaming for an IP Camera System with

GETTING STARTED WITH ANDROID DEVELOPMENT FOR EMBEDDED SYSTEMS

point to point and point to multi point calls over IP

In: Proceedings of RECPAD th Portuguese Conference on Pattern Recognition June 27th- 28th, 2002 Aveiro, Portugal

Mobile Application Development

Android app development course

OMX, Android, GStreamer How do I decide what to use? 15 July 2011

CORD Monitoring Service

Dolby Digital Plus in HbbTV

EV-8000S. Features & Technical Specifications. EV-8000S Major Features & Specifications 1

Service Providers and WebRTC

... Introduction... 17

Mobile Phones Operating Systems

Intel Media Server Studio - Metrics Monitor (v1.1.0) Reference Manual

MEZORY IP-CCTV QUICK PREVIEW

A Short Introduction to Android

Practical Android Projects Lucas Jordan Pieter Greyling

Alarms of Stream MultiScreen monitoring system

Version 2.8. Released 30 September 2015

ITP 342 Mobile App Development. APIs

This documentation is made available before final release and is subject to change without notice and comes with no warranty express or implied.

Microsoft Smooth Streaming

N-series Evaluation Guide

Android Architecture. Alexandra Harrison & Jake Saxton

Cisco Videoscape Media Suite

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code.

This is DEEPerent: Tracking App behaviors with (Nothing changed) phone for Evasive android malware

Managing video content in DAM How digital asset management software can improve your brands use of video assets

1. Introduction to Android

Trends of Interactive TV & Triple Play

Database FAQs - SQL Server

Source Live 2.0 User Guide

SnapLogic Salesforce Snap Reference

Introduction to Android Programming (CS5248 Fall 2015)

MatrixSSL Developer s Guide

Sophos Mobile Control Technical guide

Accessing Data with ADOBE FLEX 4.6

Lab 7: Sharing and Syncing Digital Media, Using Windows Media Center,Researching an Error Event

Novell Filr. Mobile Client

Università Degli Studi di Parma. Distributed Systems Group. Android Development. Lecture 1 Android SDK & Development Environment. Marco Picone

New Features for Remote Monitoring & Analysis using the StreamScope (RM-40)

Mobile App Framework For any Website

Tool for Automated Provisioning System (TAPS) Version 1.2 (1027)

By Kundan Singh Oct Communication

Transcription:

Android builders summit The Android media framework Author: Bert Van Dam & Poornachandra Kallare Date: 22 April 2014

Usage models Use the framework: MediaPlayer android.media.mediaplayer Framework manages Demuxing Decoding AV synchronization AV rendering DIY: the application manages Demuxing: android.media.mediaextractor Decoding: android.media.mediacodec Video rendering: android.media.mediacodec Audio rendering: android.media.audiotrack 2

MediaPlayer usage model The easy way: instantiate VideoView Creates the MediaPlayer for you Exports similar API to MediaPlayer The slightly more complicated way Application creates SurfaceView Application creates MediaPlayer MediaPlayer.setSurface(surface) 3

Which media players exist Built-in players AwesomePlayer (default player selected) NuPlayer (Apple HLS) SonivoxPlayer (midi files) testplayer Extra player factories can be registered Every player provides same interface frameworks/av/include/media/mediaplayerinterface.h 4

Architecture android.media.mediaplayer Native MediaPlayer MediaPlayerService frameworks/base/media/java/android/media/mediaplayer.java JNI frameworks/base/media/jni/android_media_mediaplayer.cpp frameworks/av/media/libmedia/mediaplayer.cpp Binder frameworks/av/media/libmediaplayerservice/mediaplayerservice.cpp JAVA Native Application Media service MediaPlayer Factory creates NuPlayer Driver frameworks/av/media/libmediaplayerservice/mediaplayerfactory.cpp frameworks/av/media/libmediaplayerservice/nuplayer/nuplayerdriver.cpp StageFright Player frameworks/av/media/libmediaplayerservice/stagefrightplayer.cpp instantiates Awesome Player frameworks/av/media/libstagefright/awesomeplayer.cpp 5

Player creation (simplified) JAVA Native (1) mp = new MediaPlayer(); native_setup(new WeakReference<MediaPlayer>(this)); sp<mediaplayer> mp = new MediaPlayer(); Application MediaPlayer.java android_media_mediaplayer.cpp Object initialization maudiosessionid = AudioSystem::newAudioSessionId(); AudioSystem::acquireAudioSessionId(mAudioSessionId); mediaplayer.cpp Nothing much happened yet 6

Player creation (simplified) JAVA Native binder (2)) mp.setdatasource(url); Application setdatasource(url); mp.setdatasource(url); getmediaplayerservice; Player = Service.create(audiosessionid); MediaPlayer.java android_media_mediaplayer.cpp mediaplayer.cpp new Client(); MediaPlayerService.cpp Player->setDataSource(URL); mediaplayer.cpp Check network permissions MediaPlayerFactory::createPlayer(); MediaPlayerService.cpp Which player handles this URL??? 7

Player creation factory Default is StageFright player_type MediaPlayerFactory::getDefaultPlayerType() { char value[property_value_max]; if (property_get("media.stagefright.use-nuplayer", value, NULL) && (!strcmp("1", value)!strcasecmp("true", value))) { return NU_PLAYER; } } return STAGEFRIGHT_PLAYER; class NuPlayerFactory : public MediaPlayerFactory::IFactory { public: virtual float scorefactory(const sp<imediaplayer>& client, const char* url, float curscore) { static const float kourscore = 0.8; if (kourscore <= curscore) return 0.0; Handle these extensions only class SonivoxPlayerFactory : public MediaPlayerFactory::IFactory { public: virtual float scorefactory(const sp<imediaplayer>& client, const char* url, float curscore) { static const float kourscore = 0.4; static const char* const FILE_EXTS[] = { ".mid", ".midi", ".smf", ".xmf", ".mxmf", ".imy", ".rtttl", ".rtx", ".ota" }; Apple HLS And RTSP } if (!strncasecmp("http://", url, 7)!strncasecmp("https://", url, 8)) { size_t len = strlen(url); if (len >= 5 &&!strcasecmp(".m3u8", &url[len - 5])) { return kourscore; } } if (strstr(url,"m3u8")) { return kourscore; } if (!strncasecmp("rtsp://", url, 7)) { return kourscore; } return 0.0; 8

AwesomePlayer Building blocks OMX-IL http://www.khronos.org/openmax/il/ Standardized interface for accessing streaming components Google provides set of SW decoders SOC suppliers provide HW accelerated decoders MediaExtractors frameworks/av/media/libstagefright/ Classes capable of demuxing specific container formats (MP3Extractor, MPEG4Extractor, MatroskaExtractor, ) Allow extraction of audio, video, subtitle tracks Audioflinger, surfaceflinger for rendering 9

OMX-IL - principles Used by Stagefright players 10

OMX-IL Android integration 11

OMX-IL example config file media_codecs.xml 12

MediaPlayer.prepare Example mconnectingdatasource = HTTPBase::Create; mconnectingdatasource->connect(url); mcachedsource = new NuCachedSource2(); datasource = mcachedsource; creates a ChromiumHttpClient Go through the cache from here onwards AwesomePlayer.cpp Wait for 192 KB of data in the cache Datasource->sniff() ; extractor = MediaExtractor::Create(MIME, datasource); Calculate bitrate of stream through extractor Select first video and audio stream as default initvideodecoder() mvideosource = OMXCodec::Create(); mvideosource->start(); initaudiodecoder(); maudiosource = OMXCodec::Create(); maudiosource->start(); Continue buffering Detect the MIME type of the stream Create the extractor Create and start the video decoder Create and start the audio decoder Notify Prepared state when highwatermark is reached AwesomePlayer.cpp Already registered MediaPlayer is now ready to start playback Decoding is not yet happening at this stage!!! 13

Status after prepare AwesomePlayer MediaSource API instances mvideotrack maudiotrack MediaSource API instances mvideosource maudiosource MediaExtractor OMXCodec (video) datasource OMXCodec (audio) buffer NuCachedSoure2 (network files) FileSource (local files) ChromiumHttpClient (fetches data over IP) 14

MediaPlayer.start mp.setsurface(); mp.start(); Call needed to have a destination for rendering (VideoView srf) Application maudioplayer = new AudioPlayer(); maudioplayer->setsource(maudiosource); mtimesource = maudioplayer; startaudioplayer_l(); mtextdriver->start(); initrenderer_l(); Start video event generation Render buffers after applying AV sync logic Audio track used as timing reference Starts the audio player Start subtitle player Initialize the rendering path (based on SW/HW codec) loop of video events with A/V sync logic AwesomePlayer.cpp 15

Status after start Video data pulled by timed events AV sync happens here AwesomePlayer textdriver AudioPlayer AwesomeRenderer MediaSource API instances mvideotrack maudiotrack audiosink MediaExtractor OMXCodec (video) MediaSource API instances mvideosource maudiosource nativewindow datasource OMXCodec (audio) buffer NuCachedSoure2 (network files) FileSource (local files) AudioFlinger ChromiumHttpClient (fetches data over IP) Audio Video Audio data pulled by sink through callback SurfaceFlinger 16

Track selection MediaPlayer. gettrackinfo Returns list of tracks MediaPlayer. selecttrack(idx) Maps to MediaExtractor Select audio, video or subtitle track 17

Subtitle handling Limited formats supported SRT, 3GPP Both embedded and external files addtimedtextsource to add external file MediaPlayer.getTrackInfo returns both internal and external subtitle tracks Player takes care of syncing to playback time TimedText notifications raised at correct time 18

Subtitle rendering Simple TextView can be used to render 19

The DIY model android.media.mediacodeclist Returns supported formats Based on config.xml file explained before android.media.mediacodec Is basically an abstraction of OMX-IL Application juggles buffers to and from component Application acts as the player in this case Responsible for rendering + AV sync 20

The DIY model typical setup Create SurfaceView (for rendering video) Create AudioTrack (for rendering audio) Create MediaExtractor (alternatively have your own system for ES retrieval) -> query tracks -> selecttrack(audio track idx) -> selecttrack(video track idx) -> gettrackformat(idx) Create MediaCodec for audio and for video Configure MediaCodecs as per formats detected above, and start them while (1) on thread 1 { extr.readsampledata extr.getsampletrackindex // determine if it s the audio or video // presentation time extr.getsampletime audio/videodec.queueinputbuffer } ~~~ while(1) on thread 2 { audio/videodec.dequeueoutputbuffer audiotrack.write for audio videodec.releaseoutputbuffer for video } MyActivity MediaExtractor SurfaceView MediaCodec audiodec MediaCodec videodec AudioTrack 21

Classic DRM Framework http://developer.android.com/reference/android/drm/package-summary.html 22

Classic DRM Framework The Android DRM framework is implemented in two architectural layers A DRM framework API exposed to applications via Dalvik/Java. Application/DRM specific handling for license acquisition, etc. A native code DRM manager Implements the DRM framework Exposes an interface for DRM plugins (agents) to handle rights management and decryption for various DRM schemes. The interface for plugin developers is listed and documented in DrmEngineBase.h. Identical to the Java DRM Framework API (DrmManagerClient). On the device, the DRM plugins are located in /vendor/lib/drm or in /system/lib/drm. DRM Plugins work with media framework for content decryption 23

Prepare Redux Classic DRM Example mconnectingdatasource = HTTPBase::Create; mconnectingdatasource->connect(url); mcachedsource = new NuCachedSource2(); datasource = mcachedsource; creates a ChromiumHttpClient Go through the cache from here onwards AwesomePlayer.cpp Wait for 192 KB of data in the cache Datasource->sniff() ; extractor = MediaExtractor::Create(MIME, datasource); Calculate bitrate of stream through extractor Select first video and audio stream as default initvideodecoder() mvideosource = OMXCodec::Create(); mvideosource->start(); initaudiodecoder(); maudiosource = OMXCodec::Create(); maudiosource->start(); Continue buffering Detect the MIME type of the stream Create the extractor Create and start the video decoder Create and start the audio decoder Notify Prepared state when highwatermark is reached AwesomePlayer.cpp Already registered RegisterSniffer(SniffDRM) There is a media extractor instance for DRM called DrmExtractor. DrmExtractor implements SniffDRM 24

Status after prepare Classic DRM AwesomePlayer MediaSource API instances mvideotrack maudiotrack DrmPlugins DrmPlugins DrmPlugins DrmExtractor OMXCodec (video) MediaSource API instances mvideosource maudiosource OriginalExtractor OMXCodec (audio) DrmSource buffer NuCachedSoure2 (network files) FileSource (local files) ChromiumHttpClient (fetches data over IP) 25

DRM with media codec Applications using mediacodec can also use DRM Example: MPEG DASH CENC Using MediaCrypto and MediaDRM MediaDRM provides application API to Provision DRM clients Generate DRM/content specific challenges Download licenses/keys Generate a session ID that can be used to create media crypto objects MediaCrypto object obtained from MediaDRM can then be used with mediacodec Submit to media codec using public final void queuesecureinputbuffer (int index, int offset, MediaCodec.CryptoInfo info, long presentationtimeus, int flags) Internally uses a plugin framework Not the same plugins as used in classic DRM! Different set of plugins with different API 26

DRM with Mediacodec http://developer.android.com/reference/android/media/mediadrm.html 27

28

Media framework changes Audio track selection improvements Improve runtime audio track changes Trickmodes Android only supports Seek I-Frame based trickmodes, DLNA compliancy (x1/2, x1/4) Adaptive streaming added (DASH, ) Subtitle gaps Add SAMI, SUB, external TTML, DRM extensions PlayReady, WMDRM, Marlin 29

TV inputs Extra player taking care of TV inputs (tuner, extensions) 30