Stream represents a single playable video URL. More...

Inherits com.ooyala.android.item.JSONUpdatableItem.

Inherited by com.ooyala.android.ads.vast.VASTStream, com.ooyala.android.imasdk.IMAStream, and com.ooyala.android.pulseintegration.PulseStream.

Public Member Functions

 Stream ()
 Create an empty Stream object. More...
 
 Stream (JSONObject data)
 
 Stream (JSONObject data, boolean fromAsset)
 Create a Stream Object based on a provided JSON Object. More...
 
 Stream (String url, String deliveryType)
 Create an Stream that simply contains URL and Delivery Type This is the bare minimum for the instantiation of an UnbundledVideo object. More...
 
String getDeliveryType ()
 Get the Delivery type of this Stream instance. More...
 
void setDeliveryType (String deliveryType)
 Set the Delivery type of this Stream instance. More...
 
String getUrlFormat ()
 Get the URL format for this Stream Instance. More...
 
void setUrlFormat (String urlFormat)
 Set the URL format for this Stream instance. More...
 
String getUrl ()
 Get the video URL from this Stream instance The returned string could be encoded or unencoded, based on the URL Format field. More...
 
void setUrl (String url)
 Set the video URL of this Stream instance If the video url is encoded, make sure you set the urlFormat. More...
 
URL decodedURL ()
 Get the unencoded video URL for the stream, whether it is encoded or not. More...
 
void setWidevineServerPath (String widevineServerPath)
 Set the Widevine Server Path of this content for downloaded assets. More...
 
String getWidevineServerPath ()
 Get the Widevine Server Path of this content. More...
 
UUID getWidevineUUID ()
 Get the Widevine UUID of this content. More...
 
void initWidevineUUID ()
 Init the Widevine UUID of this content. More...
 
boolean isLiveStream ()
 Return true if the Stream has been marked as a live stream. More...
 
void setLiveStream (boolean isLiveStream)
 Set if the Stream is marked as a live stream. More...
 
int getVideoBitrate ()
 Get the video bitrate of this Stream instance NOTE: Only has information for MP4 assets. More...
 
void setVideoBitrate (int videoBitrate)
 Set the video bitrate of this Stream instance NOTE: Only has information for MP4 assets. More...
 
int getAudioBitrate ()
 Get the audio bitrate of this Stream instance NOTE: Only has information for MP4 assets. More...
 
void setAudioBitrate (int audioBitrate)
 Set the audio bitrate of this Stream instance NOTE: Only has information for MP4 assets. More...
 
int getCombinedBitrate ()
 Get the combined audio and video bitrate for this stream If AudioBitrate = # & VideoBitrate = # Then the combined bitrate = AudioBitrate + VideoBitrate If AudioBitrate = -1 & VideoBitrate = # Then the combined bitrate = VideoBitrate only If AudioBitrate = # & VideoBitrate = -1 Then the combined bitrate = AudioBitrate only If AudioBitrate = -1 & VideoBitrate = -1 Then the combined bitrate = -1. More...
 
int getHeight ()
 Get the height of this Stream instance NOTE: Only has information for MP4 assets. More...
 
void setHeight (int height)
 Set the height of this Stream instance NOTE: Only has information for MP4 assets. More...
 
int getWidth ()
 Get the width of this Stream instance NOTE: Only has information for MP4 assets. More...
 
void setWidth (int width)
 Set the width of this Stream instance NOTE: Only has information for MP4 assets. More...
 
String getVideoCodec ()
 Get the video codec of this Stream instance NOTE: Only has information for MP4 assets. More...
 
void setVideoCodec (String videoCodec)
 Set the video codec of this Stream instance. More...
 
String getFramerate ()
 Get the framerate of this Stream instance NOTE: Only has information for MP4 assets. More...
 
void setFramerate (String framerate)
 Set the framerate of this Stream instance. More...
 
String getAspectRatio ()
 Get the aspect ratio of this Stream instance NOTE: May not be populated for any assets. More...
 
void setAspectRatio (String aspectRatio)
 Set the aspect ratio of this Stream instance NOTE: May not be populated for any assets. More...
 
String getProfile ()
 Get the encoding profile of this Stream Instance NOTE: Only has information for MP4 assets. More...
 
void setProfile (String profile)
 Set the encoding profile of this Stream Instance NOTE: Only has information for MP4 assets. More...
 
boolean hasTokenExpired (long currentTimeMillisecond)
 check if the stream url token has expired More...
 

Static Public Member Functions

static void setStreamSelector (StreamSelector selector)
 Set the StreamSelector used to select the Stream to play. More...
 
static void resetStreamSelector ()
 Reset the StreamSelector to the default. More...
 
static boolean isDeliveryTypePlayable (Stream stream)
 Determine if the video type is playable on this this Android OS Version Primarily checks if the delivery type is one of the expected delivery types, or if the type is HLS, if the Android OS is above 3.0,. More...
 
static boolean isProfilePlayable (Stream stream)
 Determine if the encoding profile is playable This check is primarily for MP4 Playback - If the mp4 is not Baseline, we do not play it on Android. More...
 
static Stream bestStream (Set< Stream > streams, boolean isWifiEnabled)
 Determine the best stream from a set of streams. More...
 
static boolean streamSetContainsDeliveryType (Set< Stream > streams, String deliveryType)
 Check the set of Streams to see if any of the Streams are of a specific delivery type. More...
 
static Stream getStreamWithDeliveryType (Set< Stream > streams, String desiredType)
 Get a Stream that has the desired type. More...
 

Static Public Attributes

static final String KEY_VIDEO_BITRATE = "video_bitrate"
 
static final String KEY_AUDIO_BITRATE = "audio_bitrate"
 
static final String KEY_VIDEO_CODEC = "video_codec"
 
static final String KEY_FRAMERATE = "framerate"
 
static final String KEY_DELIVERY_TYPE = "delivery_type"
 
static final String KEY_DATA = "data"
 
static final String KEY_FORMAT = "format"
 
static final String KEY_IS_LIVE_STREAM = "is_live_stream"
 
static final String KEY_ASPECT_RATIO = "aspect_ratio"
 
static final String KEY_PROFILE = "profile"
 
static final String KEY_WIDEVINE_SERVER_PATH = "widevine_server_path"
 
static final String KEY_HEIGHT = "height"
 
static final String KEY_WIDTH = "width"
 
static final String KEY_URL = "url"
 
static final String KEY_TOKEN_EXPIRE = "token_expire"
 
static final String KEY_DRM = "drm"
 
static final String KEY_WIDEVINE = "widevine"
 
static final String KEY_LICENSE_URL = "la_url"
 
static final String KEY_CONTENT = "content"
 
static final String KEY_STREAMS = "streams"
 
static final String PROFILE_BASELINE = "baseline"
 
static final String DELIVERY_TYPE_HLS = "hls"
 
static final String DELIVERY_TYPE_PLAYREADY_HLS = "playready_hls"
 
static final String DELIVERY_TYPE_MP4 = "mp4"
 
static final String DELIVERY_TYPE_M3U8 = "m3u8"
 
static final String DELIVERY_TYPE_DASH = "dash"
 
static final String DELIVERY_TYPE_REMOTE_ASSET = "remote_asset"
 
static final String DELIVERY_TYPE_AKAMAI_HD2_VOD_HLS = "akamai_hd2_vod_hls"
 
static final String DELIVERY_TYPE_AKAMAI_HD2_HLS = "akamai_hd2_hls"
 
static final String DELIVERY_TYPE_SMOOTH = "smooth"
 
static final String DELIVERY_TYPE_AUDIO = "audio"
 
static final String DELIVERY_TYPE_OGG = "audio_ogg"
 
static final String DELIVERY_TYPE_M4A = "audio_m4a"
 
static final String DELIVERY_TYPE_AUDIO_HLS = "audio_hls"
 
static final String STREAM_URL_FORMAT_TEXT = "text"
 
static final String STREAM_URL_FORMAT_B64 = "encoded"
 

Protected Attributes

String _deliveryType = null
 
String _videoCodec = null
 
String _urlFormat = null
 
String _framerate = null
 
int _videoBitrate = UNDEFINED_VALUE
 
int _audioBitrate = UNDEFINED_VALUE
 
int _height = UNDEFINED_VALUE
 
int _width = UNDEFINED_VALUE
 
String _url = null
 
String _aspectRatio = null
 
boolean _isLiveStream = false
 
String _profile = null
 
String _widevineServerPath = null
 
UUID _widevineUUID = null
 
Long _tokenExpireDateInMilliSeconds
 

Detailed Description

Stream represents a single playable video URL.

This refers to the Video URL, and any metadata around that particular video.

NOTE: When reading Streams that are generated from Ooyala Backlot APIs, A lot of the fields within this class apply solely to Streams with MP4 Delivery Type

Constructor & Destructor Documentation

com.ooyala.android.item.Stream.Stream ( )

Create an empty Stream object.

com.ooyala.android.item.Stream.Stream ( JSONObject  data)
com.ooyala.android.item.Stream.Stream ( JSONObject  data,
boolean  fromAsset 
)

Create a Stream Object based on a provided JSON Object.

Take a look at Stream's static class variables that are prefixed with "KEY_" to understand the acceptable JSONObject entries

Parameters
dataa JSONObject with proper entries for a Stream
com.ooyala.android.item.Stream.Stream ( String  url,
String  deliveryType 
)

Create an Stream that simply contains URL and Delivery Type This is the bare minimum for the instantiation of an UnbundledVideo object.

Parameters
urlsource for the video stream e.g. "http://techslides.com/demos/sample-videos/small.mp4".
deliveryTypethe stream delivery type e.g. DELIVERY_TYPE_MP4. See Stream's class variables that are prefixed with "DELIVERY_TYPE"

Member Function Documentation

static Stream com.ooyala.android.item.Stream.bestStream ( Set< Stream streams,
boolean  isWifiEnabled 
)
static

Determine the best stream from a set of streams.

If there are multiple streams, we prioritize remote assets, HLS, and DASH streams. Outside of that, we then priortize Smooth, and finally MP4 streams

Parameters
streamsa set of Streams to test against
isWifiEnabledIf wifi is enabled, we choose the highest quality of all MP4 bitrates
Returns
the best stream to play back.
URL com.ooyala.android.item.Stream.decodedURL ( )

Get the unencoded video URL for the stream, whether it is encoded or not.

Returns
the unencoded video URL
String com.ooyala.android.item.Stream.getAspectRatio ( )

Get the aspect ratio of this Stream instance NOTE: May not be populated for any assets.

Returns
the aspect ratio, if available
int com.ooyala.android.item.Stream.getAudioBitrate ( )

Get the audio bitrate of this Stream instance NOTE: Only has information for MP4 assets.

Other formats may not have this field populated

Returns
the audio bitrate (MP4 Only)
int com.ooyala.android.item.Stream.getCombinedBitrate ( )

Get the combined audio and video bitrate for this stream If AudioBitrate = # & VideoBitrate = # Then the combined bitrate = AudioBitrate + VideoBitrate If AudioBitrate = -1 & VideoBitrate = # Then the combined bitrate = VideoBitrate only If AudioBitrate = # & VideoBitrate = -1 Then the combined bitrate = AudioBitrate only If AudioBitrate = -1 & VideoBitrate = -1 Then the combined bitrate = -1.

Returns
the combined audio and video bitrate
String com.ooyala.android.item.Stream.getDeliveryType ( )

Get the Delivery type of this Stream instance.

Returns
the String of the Delivery Type. the available options are the Stream's class variables which are prefixed with "DELIVERY_TYPE"
String com.ooyala.android.item.Stream.getFramerate ( )

Get the framerate of this Stream instance NOTE: Only has information for MP4 assets.

Other formats may not have this field populated

Returns
the framerate (MP4 Only)
int com.ooyala.android.item.Stream.getHeight ( )

Get the height of this Stream instance NOTE: Only has information for MP4 assets.

Other formats may not have this field populated

Returns
the height (MP4 Only)
String com.ooyala.android.item.Stream.getProfile ( )

Get the encoding profile of this Stream Instance NOTE: Only has information for MP4 assets.

Other formats may not have this field populated

Returns
the encoding profile of this Stream
static Stream com.ooyala.android.item.Stream.getStreamWithDeliveryType ( Set< Stream streams,
String  desiredType 
)
static

Get a Stream that has the desired type.

Parameters
streamsa set of Streams
desiredTypethe desired type
Returns
a Stream that satisfy the desired type, null otherwise
String com.ooyala.android.item.Stream.getUrl ( )

Get the video URL from this Stream instance The returned string could be encoded or unencoded, based on the URL Format field.

Returns
the video url, or encoded string
String com.ooyala.android.item.Stream.getUrlFormat ( )

Get the URL format for this Stream Instance.

Returns
the URL format. the available options are the Stream's class variables which are prefixed with "STREAM_URL_FORMAT"
int com.ooyala.android.item.Stream.getVideoBitrate ( )

Get the video bitrate of this Stream instance NOTE: Only has information for MP4 assets.

Other formats may not have this field populated

Returns
the video bitrate (MP4 Only)
String com.ooyala.android.item.Stream.getVideoCodec ( )

Get the video codec of this Stream instance NOTE: Only has information for MP4 assets.

Other formats may not have this field populated

Returns
the video codec (MP4 Only)
String com.ooyala.android.item.Stream.getWidevineServerPath ( )

Get the Widevine Server Path of this content.

This field is only populated for Widevine encoded assets

Returns
the Widevine server path, if available
UUID com.ooyala.android.item.Stream.getWidevineUUID ( )

Get the Widevine UUID of this content.

This field is only populated for Widevine encoded assets

Returns
the Widevine UUID, if available
int com.ooyala.android.item.Stream.getWidth ( )

Get the width of this Stream instance NOTE: Only has information for MP4 assets.

Other formats may not have this field populated

Returns
the width (MP4 Only)
boolean com.ooyala.android.item.Stream.hasTokenExpired ( long  currentTimeMillisecond)

check if the stream url token has expired

Parameters
currentTimeMillisecondcurrent time in milliseconds
Returns
true if url token expires, false otherwise
void com.ooyala.android.item.Stream.initWidevineUUID ( )

Init the Widevine UUID of this content.

This field is only populated for Widevine encoded assets

static boolean com.ooyala.android.item.Stream.isDeliveryTypePlayable ( Stream  stream)
static

Determine if the video type is playable on this this Android OS Version Primarily checks if the delivery type is one of the expected delivery types, or if the type is HLS, if the Android OS is above 3.0,.

Parameters
streamthe Stream instance to test against
Returns
true if the Stream instance's delivery type should be playable, false otherwise

NOTE(jigish) Android 3.0+ supports HLS, but we support it only on 4.0+ to simplify secure HLS implementation

boolean com.ooyala.android.item.Stream.isLiveStream ( )

Return true if the Stream has been marked as a live stream.

Returns
true if the stream is marked as a live stream, false otherwise
static boolean com.ooyala.android.item.Stream.isProfilePlayable ( Stream  stream)
static

Determine if the encoding profile is playable This check is primarily for MP4 Playback - If the mp4 is not Baseline, we do not play it on Android.

Parameters
streamthe Stream instance to test against
Returns
true if the Stream instance's profile should be playable, false otherwise
static void com.ooyala.android.item.Stream.resetStreamSelector ( )
static

Reset the StreamSelector to the default.

void com.ooyala.android.item.Stream.setAspectRatio ( String  aspectRatio)

Set the aspect ratio of this Stream instance NOTE: May not be populated for any assets.

Parameters
aspectRatiothe aspect ratio
void com.ooyala.android.item.Stream.setAudioBitrate ( int  audioBitrate)

Set the audio bitrate of this Stream instance NOTE: Only has information for MP4 assets.

Other formats may not have this field populated

Parameters
audioBitratethe audio bitrate (MP4 Only)
void com.ooyala.android.item.Stream.setDeliveryType ( String  deliveryType)

Set the Delivery type of this Stream instance.

Parameters
deliveryTypethe String of the Delivery Type. the available options are the Stream's class variables which are prefixed with "DELIVERY_TYPE"
void com.ooyala.android.item.Stream.setFramerate ( String  framerate)

Set the framerate of this Stream instance.

Parameters
framerate(MP4 Only)
void com.ooyala.android.item.Stream.setHeight ( int  height)

Set the height of this Stream instance NOTE: Only has information for MP4 assets.

Other formats may not have this field populated

Parameters
heightthe height (MP4 Only)
void com.ooyala.android.item.Stream.setLiveStream ( boolean  isLiveStream)

Set if the Stream is marked as a live stream.

Parameters
isLiveStreamtrue if the stream is live, false otherwise
void com.ooyala.android.item.Stream.setProfile ( String  profile)

Set the encoding profile of this Stream Instance NOTE: Only has information for MP4 assets.

Other formats may not have this field populated

Parameters
profilethe encoding profile of the Stream
static void com.ooyala.android.item.Stream.setStreamSelector ( StreamSelector  selector)
static

Set the StreamSelector used to select the Stream to play.

Parameters
selectoran implemented StreamSelector
void com.ooyala.android.item.Stream.setUrl ( String  url)

Set the video URL of this Stream instance If the video url is encoded, make sure you set the urlFormat.

Parameters
urlthe video url, or encoded string
void com.ooyala.android.item.Stream.setUrlFormat ( String  urlFormat)

Set the URL format for this Stream instance.

Parameters
urlFormatthe URL format. the available options are the Stream's class variables which are prefixed with "STREAM_URL_FORMAT"
void com.ooyala.android.item.Stream.setVideoBitrate ( int  videoBitrate)

Set the video bitrate of this Stream instance NOTE: Only has information for MP4 assets.

Other formats may not have this field populated

Parameters
videoBitrate(MP4 Only)
void com.ooyala.android.item.Stream.setVideoCodec ( String  videoCodec)

Set the video codec of this Stream instance.

Parameters
videoCodecthe video codec (MP4 Only)
void com.ooyala.android.item.Stream.setWidevineServerPath ( String  widevineServerPath)

Set the Widevine Server Path of this content for downloaded assets.

This field is only populated for Widevine encoded assets

Parameters
widevineServerPaththe Widevine server path
void com.ooyala.android.item.Stream.setWidth ( int  width)

Set the width of this Stream instance NOTE: Only has information for MP4 assets.

Other formats may not have this field populated

Parameters
widththe width (MP4 Only)
static boolean com.ooyala.android.item.Stream.streamSetContainsDeliveryType ( Set< Stream streams,
String  deliveryType 
)
static

Check the set of Streams to see if any of the Streams are of a specific delivery type.

Parameters
streamsa set of Streams to test against
deliveryTypethe desired Delivery Type
Returns
true if the set of streams contain the desired deliveryType

Member Data Documentation

String com.ooyala.android.item.Stream._aspectRatio = null
protected
int com.ooyala.android.item.Stream._audioBitrate = UNDEFINED_VALUE
protected
String com.ooyala.android.item.Stream._deliveryType = null
protected
String com.ooyala.android.item.Stream._framerate = null
protected
int com.ooyala.android.item.Stream._height = UNDEFINED_VALUE
protected
boolean com.ooyala.android.item.Stream._isLiveStream = false
protected
String com.ooyala.android.item.Stream._profile = null
protected
Long com.ooyala.android.item.Stream._tokenExpireDateInMilliSeconds
protected
String com.ooyala.android.item.Stream._url = null
protected
String com.ooyala.android.item.Stream._urlFormat = null
protected
int com.ooyala.android.item.Stream._videoBitrate = UNDEFINED_VALUE
protected
String com.ooyala.android.item.Stream._videoCodec = null
protected
String com.ooyala.android.item.Stream._widevineServerPath = null
protected
UUID com.ooyala.android.item.Stream._widevineUUID = null
protected
int com.ooyala.android.item.Stream._width = UNDEFINED_VALUE
protected
final String com.ooyala.android.item.Stream.DELIVERY_TYPE_AKAMAI_HD2_HLS = "akamai_hd2_hls"
static
final String com.ooyala.android.item.Stream.DELIVERY_TYPE_AKAMAI_HD2_VOD_HLS = "akamai_hd2_vod_hls"
static
final String com.ooyala.android.item.Stream.DELIVERY_TYPE_AUDIO = "audio"
static
final String com.ooyala.android.item.Stream.DELIVERY_TYPE_AUDIO_HLS = "audio_hls"
static
final String com.ooyala.android.item.Stream.DELIVERY_TYPE_DASH = "dash"
static
final String com.ooyala.android.item.Stream.DELIVERY_TYPE_HLS = "hls"
static
final String com.ooyala.android.item.Stream.DELIVERY_TYPE_M3U8 = "m3u8"
static
final String com.ooyala.android.item.Stream.DELIVERY_TYPE_M4A = "audio_m4a"
static
final String com.ooyala.android.item.Stream.DELIVERY_TYPE_MP4 = "mp4"
static
final String com.ooyala.android.item.Stream.DELIVERY_TYPE_OGG = "audio_ogg"
static
final String com.ooyala.android.item.Stream.DELIVERY_TYPE_PLAYREADY_HLS = "playready_hls"
static
final String com.ooyala.android.item.Stream.DELIVERY_TYPE_REMOTE_ASSET = "remote_asset"
static
final String com.ooyala.android.item.Stream.DELIVERY_TYPE_SMOOTH = "smooth"
static
final String com.ooyala.android.item.Stream.KEY_ASPECT_RATIO = "aspect_ratio"
static
final String com.ooyala.android.item.Stream.KEY_AUDIO_BITRATE = "audio_bitrate"
static
final String com.ooyala.android.item.Stream.KEY_CONTENT = "content"
static
final String com.ooyala.android.item.Stream.KEY_DATA = "data"
static
final String com.ooyala.android.item.Stream.KEY_DELIVERY_TYPE = "delivery_type"
static
final String com.ooyala.android.item.Stream.KEY_DRM = "drm"
static
final String com.ooyala.android.item.Stream.KEY_FORMAT = "format"
static
final String com.ooyala.android.item.Stream.KEY_FRAMERATE = "framerate"
static
final String com.ooyala.android.item.Stream.KEY_HEIGHT = "height"
static
final String com.ooyala.android.item.Stream.KEY_IS_LIVE_STREAM = "is_live_stream"
static
final String com.ooyala.android.item.Stream.KEY_LICENSE_URL = "la_url"
static
final String com.ooyala.android.item.Stream.KEY_PROFILE = "profile"
static
final String com.ooyala.android.item.Stream.KEY_STREAMS = "streams"
static
final String com.ooyala.android.item.Stream.KEY_TOKEN_EXPIRE = "token_expire"
static
final String com.ooyala.android.item.Stream.KEY_URL = "url"
static
final String com.ooyala.android.item.Stream.KEY_VIDEO_BITRATE = "video_bitrate"
static
final String com.ooyala.android.item.Stream.KEY_VIDEO_CODEC = "video_codec"
static
final String com.ooyala.android.item.Stream.KEY_WIDEVINE = "widevine"
static
final String com.ooyala.android.item.Stream.KEY_WIDEVINE_SERVER_PATH = "widevine_server_path"
static
final String com.ooyala.android.item.Stream.KEY_WIDTH = "width"
static
final String com.ooyala.android.item.Stream.PROFILE_BASELINE = "baseline"
static
final String com.ooyala.android.item.Stream.STREAM_URL_FORMAT_B64 = "encoded"
static
final String com.ooyala.android.item.Stream.STREAM_URL_FORMAT_TEXT = "text"
static