3

Click here to load reader

Live and Progressive Streaming With Android

Embed Size (px)

Citation preview

Page 1: Live and Progressive Streaming With Android

7/31/2019 Live and Progressive Streaming With Android

http://slidepdf.com/reader/full/live-and-progressive-streaming-with-android 1/3

Live and Progressive Streaming with Android

Published March 4, 2012 Uncategorized 3 Comments 

Background 

You may have seen my prior post on this topic: Streaming Media with Android. The title is

slightly innacurate as it‟s less about generic „media‟ streaming and instead focused on .mp3audio. The basic streaming function described in the post is still valid for Android however that

post was written when Android was still v1.0. Android‟s media handling has improvedsubstantially since then but is still unstable with respect to many media formats. In my

experience, it‟s best to stick to .mp3 for audio and .3gp for video. The best tool I‟ve found for generating .3gp video is Quicktime Pro. Yes…oddly Apple makes the easiest tool for generating

video for Android.

Scroll to the bottom to see a few tutorials I‟ve found on Live Streaming with Andr oid.

Streaming Media…As In Live Radio 

My prior streaming media post has recieved many questions about streaming live audio/video.

That type of streaming is completely different from what I previously discussed, but since there‟sso much interest, I though I would write a brief post that I can refer people to. To start, here‟s

the list of Android‟s supported media formats. As you can see, Android now supports streamingof these live media formats:

  RTSP (RTP, SDP)

  HTTP/HTTPS progressive streaming

 HTTP/HTTPS live streaming draft protocol: 

o  MPEG-2 TS media files only

o  Protocol version 3 (Android 4.0 and above)o  Protocol version 2 (Android 3.x)

o  Not supported before Android 3.0o  Note: HTTPS is not supported before Android 3.1.

Progressive versus Live Streaming 

This distinction is important and may or may not be under your control. If you are streamingyour own media, then research the strengths and weaknesses of these two options to determine

what‟s right for you.  If your app will play somebody elses content, then you‟ll need to determinewhich format they are using. In general though, if the media to stream is self-contained in a file,

then progressive streaming is the easiest solution. If the media is of indeterminate length because it‟s  being generated or created live (e.g. radio or live video blog), then you‟ll need „live‟

streaming.

Progressive Streaming 

Page 2: Live and Progressive Streaming With Android

7/31/2019 Live and Progressive Streaming With Android

http://slidepdf.com/reader/full/live-and-progressive-streaming-with-android 2/3

File delivery via HTTP is referred to as „progressive or http streaming‟.  This isn‟t really filestreaming as much as complete download of a media file to the user‟s computer but with

playback initiated as soon as sufficient content has been downloaded. The media file is buffered

onto the user‟s computer so it can be viewed/listened to. In technical terms, the initially

downloaded file bytes must contain a header describing the media file format, encoding quality

(e.g. 128 kbps) and such. The server doesn‟t care about the file‟s content though, it simply sendsdata to the app as fast as it can. Because the file is downloaded from in its entirety, the ability to

skipping to parts of the file that have not yet been downloaded is not possible…the user must

wait for the server to stream all the prior content before playing the selected section.

Code: Progressing Streaming 

Go here for the code from my progressive streaming post. 

Live Streaming 

Live streaming requires the overhead of a streaming server  – special software that handles themedia requests. This is different from progressive streaming in which a standard web server cansimply deliver a media file via HTTP. Live streaming requires a more intelligent conversation

between the streaming server and the local app performing media playback. The user‟s app must provide „control handling‟ between itself and the server. These control messages include „play‟,

„pause‟, and „seek‟ but also details about the quality of the media to be delivered. E.g. if the appis on a slower network, then it should request lower quality (i.e. kbps) media and if the device

has a smaller screen, it would request video for that size to reduce unnecessary bandwidth usage.

The advantages of Live Streaming are the ability to begin playback at any point, skip through themedia, more efficiently use bandwidth, and to avoid storing media file on the device (the data is

played and discarded immediatley –  e.g. the difference between Apple‟s 1st and 2nd generationApple TV).

When selecting your streaming servers, you‟ll need to determine the appropriate streamingprotocols: RTSP(Real time streaming protocol), RTMP(Real time messaging protocol) and

MMS (Microsoft media services). These streaming protocols deliver video well by being morefocussed on continuous delivery than 100% accuracy. The assumption is that it‟s better to have a

momentary glitch rather than stopping media playback altogether.

Code & Tutorials: Live Streaming 

CatDaaaady repurposed my progressive streaming code and wrote code to listen to NPR‟sstreaming broadcast.  In his words, “I used Biosopher‟s code and modified it to support a

continuous stream of audio instead of a file. It downloads X number of seconds and save thataudio segment. Then it starts playing that audio clip while it downloads the next sections of 

audio in the background. Then queuing up the audio segments for playing next. It is not perfectthough. I get a slight playback pause between audio segments though. Hopefully I will prefect

it or find another way around.”