Commit dd30632a by ojw28

SmoothStreaming Live support.

Issue: #12
parent 4adf8f77
...@@ -45,7 +45,7 @@ public class DemoUtil { ...@@ -45,7 +45,7 @@ public class DemoUtil {
public static final String CONTENT_ID_EXTRA = "content_id"; public static final String CONTENT_ID_EXTRA = "content_id";
public static final int TYPE_DASH_VOD = 0; public static final int TYPE_DASH_VOD = 0;
public static final int TYPE_SS_VOD = 1; public static final int TYPE_SS = 1;
public static final int TYPE_OTHER = 2; public static final int TYPE_OTHER = 2;
public static final boolean EXPOSE_EXPERIMENTAL_FEATURES = false; public static final boolean EXPOSE_EXPERIMENTAL_FEATURES = false;
......
...@@ -56,7 +56,7 @@ package com.google.android.exoplayer.demo; ...@@ -56,7 +56,7 @@ package com.google.android.exoplayer.demo;
false), false),
new Sample("Super speed (SmoothStreaming)", "uid:ss:superspeed", new Sample("Super speed (SmoothStreaming)", "uid:ss:superspeed",
"http://playready.directtaps.net/smoothstreaming/SSWSS720H264/SuperSpeedway_720.ism", "http://playready.directtaps.net/smoothstreaming/SSWSS720H264/SuperSpeedway_720.ism",
DemoUtil.TYPE_SS_VOD, false, false), DemoUtil.TYPE_SS, false, false),
new Sample("Dizzy (Misc)", "uid:misc:dizzy", new Sample("Dizzy (Misc)", "uid:misc:dizzy",
"http://html5demos.com/assets/dizzy.mp4", DemoUtil.TYPE_OTHER, false, false), "http://html5demos.com/assets/dizzy.mp4", DemoUtil.TYPE_OTHER, false, false),
}; };
...@@ -92,10 +92,10 @@ package com.google.android.exoplayer.demo; ...@@ -92,10 +92,10 @@ package com.google.android.exoplayer.demo;
public static final Sample[] SMOOTHSTREAMING = new Sample[] { public static final Sample[] SMOOTHSTREAMING = new Sample[] {
new Sample("Super speed", "uid:ss:superspeed", new Sample("Super speed", "uid:ss:superspeed",
"http://playready.directtaps.net/smoothstreaming/SSWSS720H264/SuperSpeedway_720.ism", "http://playready.directtaps.net/smoothstreaming/SSWSS720H264/SuperSpeedway_720.ism",
DemoUtil.TYPE_SS_VOD, false, true), DemoUtil.TYPE_SS, false, true),
new Sample("Super speed (PlayReady)", "uid:ss:pr:superspeed", new Sample("Super speed (PlayReady)", "uid:ss:pr:superspeed",
"http://playready.directtaps.net/smoothstreaming/SSWSS720H264PR/SuperSpeedway_720.ism", "http://playready.directtaps.net/smoothstreaming/SSWSS720H264PR/SuperSpeedway_720.ism",
DemoUtil.TYPE_SS_VOD, true, true), DemoUtil.TYPE_SS, true, true),
}; };
public static final Sample[] WIDEVINE_GTS = new Sample[] { public static final Sample[] WIDEVINE_GTS = new Sample[] {
......
...@@ -167,7 +167,7 @@ public class FullPlayerActivity extends Activity implements SurfaceHolder.Callba ...@@ -167,7 +167,7 @@ public class FullPlayerActivity extends Activity implements SurfaceHolder.Callba
private RendererBuilder getRendererBuilder() { private RendererBuilder getRendererBuilder() {
String userAgent = DemoUtil.getUserAgent(this); String userAgent = DemoUtil.getUserAgent(this);
switch (contentType) { switch (contentType) {
case DemoUtil.TYPE_SS_VOD: case DemoUtil.TYPE_SS:
return new SmoothStreamingRendererBuilder(userAgent, contentUri.toString(), contentId, return new SmoothStreamingRendererBuilder(userAgent, contentUri.toString(), contentId,
new SmoothStreamingTestMediaDrmCallback(), debugTextView); new SmoothStreamingTestMediaDrmCallback(), debugTextView);
case DemoUtil.TYPE_DASH_VOD: case DemoUtil.TYPE_DASH_VOD:
......
...@@ -65,6 +65,7 @@ public class SmoothStreamingRendererBuilder implements RendererBuilder, ...@@ -65,6 +65,7 @@ public class SmoothStreamingRendererBuilder implements RendererBuilder,
private static final int VIDEO_BUFFER_SEGMENTS = 200; private static final int VIDEO_BUFFER_SEGMENTS = 200;
private static final int AUDIO_BUFFER_SEGMENTS = 60; private static final int AUDIO_BUFFER_SEGMENTS = 60;
private static final int TTML_BUFFER_SEGMENTS = 2; private static final int TTML_BUFFER_SEGMENTS = 2;
private static final int LIVE_EDGE_LATENCY_MS = 30000;
private final String userAgent; private final String userAgent;
private final String url; private final String url;
...@@ -74,6 +75,7 @@ public class SmoothStreamingRendererBuilder implements RendererBuilder, ...@@ -74,6 +75,7 @@ public class SmoothStreamingRendererBuilder implements RendererBuilder,
private DemoPlayer player; private DemoPlayer player;
private RendererBuilderCallback callback; private RendererBuilderCallback callback;
private ManifestFetcher<SmoothStreamingManifest> manifestFetcher;
public SmoothStreamingRendererBuilder(String userAgent, String url, String contentId, public SmoothStreamingRendererBuilder(String userAgent, String url, String contentId,
MediaDrmCallback drmCallback, TextView debugTextView) { MediaDrmCallback drmCallback, TextView debugTextView) {
...@@ -89,8 +91,8 @@ public class SmoothStreamingRendererBuilder implements RendererBuilder, ...@@ -89,8 +91,8 @@ public class SmoothStreamingRendererBuilder implements RendererBuilder,
this.player = player; this.player = player;
this.callback = callback; this.callback = callback;
SmoothStreamingManifestParser parser = new SmoothStreamingManifestParser(); SmoothStreamingManifestParser parser = new SmoothStreamingManifestParser();
ManifestFetcher<SmoothStreamingManifest> manifestFetcher = manifestFetcher = new ManifestFetcher<SmoothStreamingManifest>(parser, contentId,
new ManifestFetcher<SmoothStreamingManifest>(parser, contentId, url + "/Manifest"); url + "/Manifest");
manifestFetcher.singleLoad(player.getMainHandler().getLooper(), this); manifestFetcher.singleLoad(player.getMainHandler().getLooper(), this);
} }
...@@ -154,9 +156,9 @@ public class SmoothStreamingRendererBuilder implements RendererBuilder, ...@@ -154,9 +156,9 @@ public class SmoothStreamingRendererBuilder implements RendererBuilder,
// Build the video renderer. // Build the video renderer.
DataSource videoDataSource = new HttpDataSource(userAgent, null, bandwidthMeter); DataSource videoDataSource = new HttpDataSource(userAgent, null, bandwidthMeter);
ChunkSource videoChunkSource = new SmoothStreamingChunkSource(manifest, ChunkSource videoChunkSource = new SmoothStreamingChunkSource(manifestFetcher,
videoStreamElementIndex, videoTrackIndices, videoDataSource, videoStreamElementIndex, videoTrackIndices, videoDataSource,
new AdaptiveEvaluator(bandwidthMeter)); new AdaptiveEvaluator(bandwidthMeter), LIVE_EDGE_LATENCY_MS);
ChunkSampleSource videoSampleSource = new ChunkSampleSource(videoChunkSource, loadControl, ChunkSampleSource videoSampleSource = new ChunkSampleSource(videoChunkSource, loadControl,
VIDEO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, true, mainHandler, player, VIDEO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, true, mainHandler, player,
DemoPlayer.TYPE_VIDEO); DemoPlayer.TYPE_VIDEO);
...@@ -181,8 +183,9 @@ public class SmoothStreamingRendererBuilder implements RendererBuilder, ...@@ -181,8 +183,9 @@ public class SmoothStreamingRendererBuilder implements RendererBuilder,
for (int i = 0; i < manifest.streamElements.length; i++) { for (int i = 0; i < manifest.streamElements.length; i++) {
if (manifest.streamElements[i].type == StreamElement.TYPE_AUDIO) { if (manifest.streamElements[i].type == StreamElement.TYPE_AUDIO) {
audioTrackNames[audioStreamElementCount] = manifest.streamElements[i].name; audioTrackNames[audioStreamElementCount] = manifest.streamElements[i].name;
audioChunkSources[audioStreamElementCount] = new SmoothStreamingChunkSource(manifest, audioChunkSources[audioStreamElementCount] = new SmoothStreamingChunkSource(
i, new int[] {0}, audioDataSource, audioFormatEvaluator); manifestFetcher, i, new int[] {0}, audioDataSource, audioFormatEvaluator,
LIVE_EDGE_LATENCY_MS);
audioStreamElementCount++; audioStreamElementCount++;
} }
} }
...@@ -211,8 +214,8 @@ public class SmoothStreamingRendererBuilder implements RendererBuilder, ...@@ -211,8 +214,8 @@ public class SmoothStreamingRendererBuilder implements RendererBuilder,
for (int i = 0; i < manifest.streamElements.length; i++) { for (int i = 0; i < manifest.streamElements.length; i++) {
if (manifest.streamElements[i].type == StreamElement.TYPE_TEXT) { if (manifest.streamElements[i].type == StreamElement.TYPE_TEXT) {
textTrackNames[textStreamElementCount] = manifest.streamElements[i].language; textTrackNames[textStreamElementCount] = manifest.streamElements[i].language;
textChunkSources[textStreamElementCount] = new SmoothStreamingChunkSource(manifest, textChunkSources[textStreamElementCount] = new SmoothStreamingChunkSource(manifestFetcher,
i, new int[] {0}, ttmlDataSource, ttmlFormatEvaluator); i, new int[] {0}, ttmlDataSource, ttmlFormatEvaluator, LIVE_EDGE_LATENCY_MS);
textStreamElementCount++; textStreamElementCount++;
} }
} }
......
...@@ -54,6 +54,7 @@ import java.util.ArrayList; ...@@ -54,6 +54,7 @@ import java.util.ArrayList;
private static final int BUFFER_SEGMENT_SIZE = 64 * 1024; private static final int BUFFER_SEGMENT_SIZE = 64 * 1024;
private static final int VIDEO_BUFFER_SEGMENTS = 200; private static final int VIDEO_BUFFER_SEGMENTS = 200;
private static final int AUDIO_BUFFER_SEGMENTS = 60; private static final int AUDIO_BUFFER_SEGMENTS = 60;
private static final int LIVE_EDGE_LATENCY_MS = 30000;
private final SimplePlayerActivity playerActivity; private final SimplePlayerActivity playerActivity;
private final String userAgent; private final String userAgent;
...@@ -61,6 +62,7 @@ import java.util.ArrayList; ...@@ -61,6 +62,7 @@ import java.util.ArrayList;
private final String contentId; private final String contentId;
private RendererBuilderCallback callback; private RendererBuilderCallback callback;
private ManifestFetcher<SmoothStreamingManifest> manifestFetcher;
public SmoothStreamingRendererBuilder(SimplePlayerActivity playerActivity, String userAgent, public SmoothStreamingRendererBuilder(SimplePlayerActivity playerActivity, String userAgent,
String url, String contentId) { String url, String contentId) {
...@@ -74,8 +76,8 @@ import java.util.ArrayList; ...@@ -74,8 +76,8 @@ import java.util.ArrayList;
public void buildRenderers(RendererBuilderCallback callback) { public void buildRenderers(RendererBuilderCallback callback) {
this.callback = callback; this.callback = callback;
SmoothStreamingManifestParser parser = new SmoothStreamingManifestParser(); SmoothStreamingManifestParser parser = new SmoothStreamingManifestParser();
ManifestFetcher<SmoothStreamingManifest> manifestFetcher = manifestFetcher = new ManifestFetcher<SmoothStreamingManifest>(parser, contentId,
new ManifestFetcher<SmoothStreamingManifest>(parser, contentId, url + "/Manifest"); url + "/Manifest");
manifestFetcher.singleLoad(playerActivity.getMainLooper(), this); manifestFetcher.singleLoad(playerActivity.getMainLooper(), this);
} }
...@@ -120,8 +122,9 @@ import java.util.ArrayList; ...@@ -120,8 +122,9 @@ import java.util.ArrayList;
// Build the video renderer. // Build the video renderer.
DataSource videoDataSource = new HttpDataSource(userAgent, null, bandwidthMeter); DataSource videoDataSource = new HttpDataSource(userAgent, null, bandwidthMeter);
ChunkSource videoChunkSource = new SmoothStreamingChunkSource(manifest, videoStreamElementIndex, ChunkSource videoChunkSource = new SmoothStreamingChunkSource(manifestFetcher,
videoTrackIndices, videoDataSource, new AdaptiveEvaluator(bandwidthMeter)); videoStreamElementIndex, videoTrackIndices, videoDataSource,
new AdaptiveEvaluator(bandwidthMeter), LIVE_EDGE_LATENCY_MS);
ChunkSampleSource videoSampleSource = new ChunkSampleSource(videoChunkSource, loadControl, ChunkSampleSource videoSampleSource = new ChunkSampleSource(videoChunkSource, loadControl,
VIDEO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, true); VIDEO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, true);
MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(videoSampleSource, MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(videoSampleSource,
...@@ -129,8 +132,9 @@ import java.util.ArrayList; ...@@ -129,8 +132,9 @@ import java.util.ArrayList;
// Build the audio renderer. // Build the audio renderer.
DataSource audioDataSource = new HttpDataSource(userAgent, null, bandwidthMeter); DataSource audioDataSource = new HttpDataSource(userAgent, null, bandwidthMeter);
ChunkSource audioChunkSource = new SmoothStreamingChunkSource(manifest, audioStreamElementIndex, ChunkSource audioChunkSource = new SmoothStreamingChunkSource(manifestFetcher,
new int[] {0}, audioDataSource, new FormatEvaluator.FixedEvaluator()); audioStreamElementIndex, new int[] {0}, audioDataSource,
new FormatEvaluator.FixedEvaluator(), LIVE_EDGE_LATENCY_MS);
SampleSource audioSampleSource = new ChunkSampleSource(audioChunkSource, loadControl, SampleSource audioSampleSource = new ChunkSampleSource(audioChunkSource, loadControl,
AUDIO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, true); AUDIO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, true);
MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer( MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(
......
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer;
import java.io.IOException;
/**
* Thrown when a live playback falls behind the available media window.
*/
public class BehindLiveWindowException extends IOException {
public BehindLiveWindowException() {
super();
}
public BehindLiveWindowException(String message) {
super(message);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment