Presentazione di PowerPoint

Report
Video Streaming
dal player standard Android
verso device non convenzionali
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Chi siamo?
+MatteoBonifazi
m.bonifazi[at]reply.it
@mbonifazi
+AlessandroMartellu
cci
a.martellucci[at]repl
y.it
@martellux
http://www.reply.e http://www.gaiareply.c
GDGuFest Roma – 2014 – Matteoom
Bonifazi & Alessandro Martellucci
Open Reply & Android Lab
• Reply spa è una delle società leader nel settore IT
• Opera in Italia, Germania, UK, Benelux, USA and Brasile.
• Open Reply è una società del Gruppo Reply spa specializzata su
tecnologie open source, soluzioni web multicanale and applicazioni
mobile.
• Based in Rome, Open Reply’s Android Lab is a young team of over 20
engineers 100% focused on Android development.
•
Specializzati in applicazioni broadcasting, bancarie e customizzazioni
del sistema operativo Android .
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Codelab Millestones
• Ex1 – Streaming di un contenuto su smartphone e tablet
• Ex2 – Streaming con app per
• Ex3 – Divertirsi utilizzando il
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Android multimedia framework
• Android supporta diversi tipi di formati per lo streaming di contenuti
• I file possono essere salvati all’interno dell’applicazione (raw
resources, standalone files) oppure utilizzando servizi di OTT
streaming.
• La documentazione dell’Android multimedia framework copre soltanto i
casi base.
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Tipi supportati
HttpLiveStreaming Protocol 3 è supportato da Android 4.0. La migliore
implementazione si trova su dispositivi KitKat.
source:
http://developer.android.com/guide/appendix/mediaGDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro formats.html
Martellucci
MediaPlayer code example
android.widget.VideoView
//1. Recuperare la view
VideoView myVideoView = (VideoView)findViewById(R.id.myvideoview);
//2. Setup video url
myVideoView.setVideoURI(Uri.parse(SrcPath));
//3. Impostare il video controller
myVideoView.setMediaController(new MediaController(this));
//4. Inizio dello streaming.
myVideoView.requestFocus();
myVideoView.start();
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Android TV
L’intrattenimento per la nostra sala
Source:http://www.televisedrevolution.com/
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Nexus Player
Asus device – 235 g
1.8GHz Quad Core, Intel®
Atom™
Imagination PowerVR Series
6 Graphics 2D/3D Engine
1GB RAM
8GB storage
Source:http://www.televisedrevolution.com/
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Android TV app
caratteristiche tecniche
• Android TV device hanno Android Lollipop 5.0.
• Android TV possiede la stessa versione del Multimedia Framework dei
normali dispisitvi Android.
• Android TV app sono compatibili dalle API 17.
• Basate sulla libreria Leanback Android Support.
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
10 feet experience
TV Full HD
30” 320 dpi
Smartphone
5” 320 dp
50 centimetri
3
metri
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Manifest features
Supportare landscape
Portrait activity sono escluse
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Manifest features
No touch screen
<uses-feature android:name="android.hardware.touchscreen"
android:required="false"/>
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Manifest features
Limit sensor
<uses-feature android:name="android.hardware.sensor.accelerometer”
android:required="false" />
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Keep calm and lean back!!
Fornisce componeti built-in customizzati per lo schermo della TV
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Leanback support library
<uses-feature android:name="android.software.leanback"
android:required="true" />
<application
android:allowBackup="false”
android:label="@string/app_name”
android:theme="@style/Theme.Leanback" >
<activity
android:name="MainActivity”
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Leanback support library
Model View Presenter
Model
Presenter
View
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Leanback UI component
BroswerFragment
Permette agli sviluppatore di avere un layout della propria applicazione
già precostruito e pronto all’uso.
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Leanback UI component
DetailFragment
Mostra informazioni riguardo i contenuti selezionati dall’utente.
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Chromecast
un cast-ready device per la multi-screen experience
source: www.google.it
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Chromecast
caratteristiche hardware
source: www.pcworld.com
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Chromecast
componenti
• Google Cast
•
•
Esperienza Multi-Screen
Google Cast SDK
• Applicazione client
•
•
•
Android app
iOS app
Chrome app
• Applicazione receiver
•
•
•
Default Media Receiver
Styled Media Receiver
Custom Media Receiver
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Applicazione client Android
librerie e dipendenze
• Versione minima supportata è la 9 (Gingerbread)
• MediaRouter API nel android-support-v7
• Google Play Services
• AppCompat API nel android-support-v7
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Applicazione client Android
tipico flusso di esecuzione
• Client usa MediaRouter per fare il discovery: MediaRouter.addCallback
• MediaRouter informa il client della route selezionata:
MediaRouter.Callback.onRouteSelected
• Il client recupera l’istanza di CastDevice: CastDevice.getFromBundle
• Il client usa GoogleApiClient per collegarsi allo strato di sistema:
GoogleApiClient.Builder
source: developers.google.com
• Il client avvia l’applicazione receiver: Cast.CastApi.launchApplication
• Il client instaura il canale di comunicazione:
Cast.CastApi.setMessageReceivedCallbacks
• Il client invia messaggi di protocollo sul canale di trasmissione:
Cast.CastApi.sendMessage
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Ricerca Cast-Ready Device
caratteristiche
Remote Playback
Live Audio
Live Video
MediaRouteSelector.Builder mediaRouteSelectorBuilder = new
MediaRouteSelector.Builder();
mediaRouteSelectorBuilder.addControlCategory(MediaControlIntent.CATEGORY_REM
OTE_PLAYBACK);
mediaRouteSelectorBuilder.addControlCategory(MediaControlIntent.CATEGORY_LIVE
_AUDIO);
mediaRouteSelectorBuilder.addControlCategory(MediaControlIntent.CATEGORY_LIVE
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Media Cast Button
facile approccio alla ricerca
source: developers.google.com
source: developers.google.com
public boolean onCreateOptionsMenu(Menu menu) {
MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider)
MenuItemCompat.getActionProvider(mediaRouteMenuItem);
mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
….
}
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Applicazione Receiver
quale mistero?
Che cosa è?
Applicazione HTML5 - Javascript
Che cosa fa?
Visualizza il contenuto a video
Gestisce i messaggi
Quali tipo esistono?
Default Media Receiver
Styled Media Receiver
Custom Media Receiver
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Default Media Receiver
il più semplice
• Off-the-shelf
• Nessuna
personalizzazione
• Nessuna registrazione
Source: developers.google.com
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Styled Media Receiver
semplice e personalizzabile
• Simile al Default Media Player
• CSS per la personalizzazione
• Registrazione
Source: developers.google.com
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Custom Media Receiver (1/3)
qualsiasi cosa
• Web Applicaiton
• Debug(able) at 9222
• Registrazione
Source: developers.google.com
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Custom Media Receiver (2/3)
esempio
<html>
<head>
<title>Example minimum receiver</title>
<script
src="//www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js"></script>
</head>
<body>
<video id='media'/>
<script>
window.mediaElement = document.getElementById('media');
window.mediaManager = new
cast.receiver.MediaManager(window.mediaElement);
window.castReceiverManager =
cast.receiver.CastReceiverManager.getInstance();
window.castReceiverManager.start();
</script>
</body>
</html>
GDG Fest Roma – 2014 – Matteo Bonifazi & Alessandro Martellucci
Custom Media Receiver (3/3)
caratteristiche avanzate
•
Video Codification/Decodification
•
•
•
Adaptive Bitrate Streaming
•
•
•
•
H.264 High Profile Level 4.1, 4.2 and 5
VP8
HTTP Live Streaming (HLS)
Dynamic Adaptive Streaming over HTTP (MPEG-DASH)
Smooth Streaming
Digital Rights Management
•
•
Play Ready DRM
Widevine DRM
• Media Player Library
GDG Fest Roma– 2014 – Matteo Bonifazi & Alessandro Martellucci
Channel, Namespace e Protocol
(1/2)
comunicazione
• Protocol: insieme di messaggi
• Namespace: nome protocollo
• Channel: lo strato di comunicazione
class CustomChannel implements Cast.MessageReceivedCallback {
public String getNamespace() { return “urn:x-cast:com.channel.custom”; }
@Override
public void onMessageReceiver(CastDevice castDevice, String namespace, String
message) { … }
}
…
Cast.CastApi.setMessageReceivedCallbacks(mApiClient,
mCustomChannel.getNamespace(), mCustomChannel);
…
GDG Fest Roma– 2014 – Matteo Bonifazi & Alessandro Martellucci
Channel, Namespace e Protocol
(2/2)
comunicazione
• Media Namespace: urn:x-cast:com.google.media.cast
• RemoteMediaPlayer
• MediaManager
RECEIVER MEDIA CHANNEL
…
window.mediaManager = new
cast.receiver.MediaManager(window.mediaElement);
…
CLIENT MEDIA CHANNEL
…
Cast.CastApi.setMessageReceivedCallbacks(mApiClient,
mRemoteMediaPlayer.getNamespace(),
mCustomChannel);
…
GDG Fest Roma– 2014 – Matteo Bonifazi & Alessandro Martellucci
Google Api Client e Media Route Provider
manufacturer
Source: developers.google.com
CastDevice selectedCastDevice = CastDevice.getFromBundle(selectedRouteInfo.getExtras);
Cast.CastOptions.Builder apiOptionsBuilder = new
Cast.CastOptions.Builder(selectedCastDevice, …);
googleApiClient = new GoogleApiClient.Builder().addApi(Cast.API,
apiOptionsBuilder.build()).build();
googleApiClient.connect();
Cast.CastApi.launchApplication(googleApiClient, applicationId, launchOptions);
Cast.CastApi.joinApplication(googleApiClient);
Cast.CastApi.stopApplication(googleApiClient);
Cast.CastApi.leaveApplication(googleApiClient);
GDG Fest Roma– 2014 – Matteo Bonifazi & Alessandro Martellucci
RemoteMediaPlayer
…finalmente
MediaInfo mediaInfo = new MediaInfo.Builder("http://your.server.com/video.mp4")
.setContentType("video/mp4")
.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
.setMetadata(mediaMetadata)
.build();
…
mRemoteMediaPlayer = new RemoteMediaPlayer();
mRemoteMediaPlayer.load(mApiClient, mediaInfo, true);
…
GDG Fest Roma– 2014 – Matteo Bonifazi & Alessandro Martellucci
Buona visione
Source: www.huffingtonpost.ca
Grazie a tutti
GDG Fest Roma– 2014 – Matteo Bonifazi & Alessandro Martellucci
Risorse
• Android Mediaplayer->
•
http://developer.android.com/guide/topics/media/mediaplayer.html
ExoPlayer -> https://github.com/google/ExoPlayer
•
•
•
•
Google Cast -> https://developers.google.com/cast
Chromecast App -> http://www.google.it/chrome/devices/chromecast/apps.html
Google Cast Downloads -> https://developers.google.com/cast/docs/downloads
Github -> https://github.com/googlecast
• Android TV -> https://developer.android.com/tv
• Nvidia Guideline -> https://developer.nvidia.com/android-tv-developer-guide
• Github -> https://github.com/googlesamples/androidtv-Leanback.git
GDG Fest Roma– 2014 – Matteo Bonifazi & Alessandro Martellucci
Libro
Sviluppare
applicazioni Android in
sette giorni
https://androidinsettegiorni.wordpress.com/
GDG Fest Roma– 2014 – Matteo Bonifazi & Alessandro Martellucci
Contatti
+MatteoBonifazi
m.bonifazi[at]reply.it
@mbonifazi
+AlessandroMartellu
cci
a.martellucci[at]repl
y.it
@martellux
http://www.reply.e http://www.gaiareply.c
GDG
Bonifazi & Alessandro Martellucci
u Fest Roma– 2014 – Matteoom

similar documents