09.02.2013 Views

Sviluppo di una piattaforma per lo streaming multimediale - MobiLab ...

Sviluppo di una piattaforma per lo streaming multimediale - MobiLab ...

Sviluppo di una piattaforma per lo streaming multimediale - MobiLab ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Sviluppo</strong> <strong>di</strong> <strong>una</strong> <strong>piattaforma</strong> <strong>per</strong> <strong>lo</strong> <strong>streaming</strong> multime<strong>di</strong>ale in ambiente Android<br />

bounds.bottom == bitmap.height()) {<br />

canvas.drawBitmap(bitmap, 0, 0, null);<br />

} else {<br />

Rect dest;<br />

if (preserveAspectRatio) {<br />

dest = new Rect(bounds);<br />

dest.bottom = bitmap.height() * bounds.right / bitmap.width();<br />

dest.offset(0, (bounds.bottom - dest.bottom)/2);<br />

} else {<br />

dest = bounds;<br />

}<br />

canvas.drawBitmap(bitmap, null, dest, paint);<br />

}<br />

Anche in questo caso ad <strong>una</strong> ideale facilità <strong>di</strong> realizzazione si contrappone un<br />

pesante limite strutturale; infatti anche se questa ipotesi rispecchia l'idea <strong>di</strong> <strong>una</strong><br />

realizzazione “senza saldature” è evidente che l'algoritmo <strong>di</strong> decompressione in<br />

tempo reale e la pesante richiesta in termini <strong>di</strong> prestazioni alla scheda grafica del<br />

<strong>di</strong>spositivo avrebbero penalizzato non poco l'usufruibilità del<strong>lo</strong> <strong>streaming</strong>.<br />

Per la troppa complessità e <strong>per</strong> le troppe componenti aleatorie si è invece<br />

scartata la possibilità <strong>di</strong> ricompattare <strong>lo</strong> <strong>streaming</strong> <strong>di</strong>namico in un URI con cui settare<br />

il me<strong>di</strong>aplayer fornito da android; la necessità <strong>di</strong> doverne poi identificare <strong>lo</strong> schema e<br />

un protocol<strong>lo</strong> <strong>di</strong> comunicazione, nonostante la possibilità <strong>di</strong> creare un Uri.builder in<br />

maniera <strong>di</strong>namica, l'hanno resa <strong>una</strong> scelta ben integrata con android ma <strong>di</strong>fficilmente<br />

<strong>per</strong>seguibile.<br />

L'alternativa che meglio si sposa con le nostre richieste nasce dalla ricerca <strong>di</strong><br />

un modo <strong>per</strong> tradurre il tipico me<strong>di</strong>aplayer.<br />

Il co<strong>di</strong>ce riportato <strong>di</strong> seguito è stato strutturato <strong>per</strong> essere meglio integrato nella<br />

nostra applicazione me<strong>di</strong>ante l'inserimento <strong>di</strong> un thread <strong>di</strong> control<strong>lo</strong> del flusso dati –<br />

Runnable r – e <strong>di</strong> un override <strong>per</strong> ogni funzione principale del Me<strong>di</strong>aplayer. In<br />

particolar modo se si riuscisse ad implementare la lettura da buffer nel metodo<br />

setDataSource(String path) si riuscirebbe ad utilizzare proprio il me<strong>di</strong>aplayer <strong>di</strong><br />

android in maniera ottimale, ve<strong>lo</strong>ce e adatta al progetto.<br />

78

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!