Commit 8c879487 by eguven Committed by Oliver Woodman

Fixed demo-misc-vp9-opus-sw DASH check

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=111839055
parent b7d5ce36
......@@ -87,16 +87,9 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback,
public static final String CONTENT_ID_EXTRA = "content_id";
public static final String CONTENT_TYPE_EXTRA = "content_type";
public static final String PROVIDER_EXTRA = "provider";
public static final int TYPE_DASH = 0;
public static final int TYPE_SS = 1;
public static final int TYPE_HLS = 2;
public static final int TYPE_OTHER = 3;
// For use when launching the demo app using adb.
private static final String CONTENT_EXT_EXTRA = "type";
private static final String EXT_DASH = ".mpd";
private static final String EXT_SS = ".ism";
private static final String EXT_HLS = ".m3u8";
private static final String TAG = "PlayerActivity";
private static final int MENU_GROUP_TRACKS = 1;
......@@ -306,15 +299,15 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback,
private RendererBuilder getRendererBuilder() {
String userAgent = Util.getUserAgent(this, "ExoPlayerDemo");
switch (contentType) {
case TYPE_SS:
case Util.TYPE_SS:
return new SmoothStreamingRendererBuilder(this, userAgent, contentUri.toString(),
new SmoothStreamingTestMediaDrmCallback());
case TYPE_DASH:
case Util.TYPE_DASH:
return new DashRendererBuilder(this, userAgent, contentUri.toString(),
new WidevineTestMediaDrmCallback(contentId, provider));
case TYPE_HLS:
case Util.TYPE_HLS:
return new HlsRendererBuilder(this, userAgent, contentUri.toString());
case TYPE_OTHER:
case Util.TYPE_OTHER:
return new ExtractorRendererBuilder(this, userAgent, contentUri);
default:
throw new IllegalStateException("Unsupported type: " + contentType);
......@@ -693,17 +686,7 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback,
private static int inferContentType(Uri uri, String fileExtension) {
String lastPathSegment = !TextUtils.isEmpty(fileExtension) ? "." + fileExtension
: uri.getLastPathSegment();
if (lastPathSegment == null) {
return TYPE_OTHER;
} else if (lastPathSegment.endsWith(EXT_DASH)) {
return TYPE_DASH;
} else if (lastPathSegment.endsWith(EXT_SS)) {
return TYPE_SS;
} else if (lastPathSegment.endsWith(EXT_HLS)) {
return TYPE_HLS;
} else {
return TYPE_OTHER;
}
return Util.inferContentType(lastPathSegment);
}
private static final class KeyCompatibleMediaController extends MediaController {
......
......@@ -53,11 +53,14 @@ import android.widget.Toast;
public class PlayerActivity extends Activity implements
LibvpxVideoTrackRenderer.EventListener, ExoPlayer.Listener {
public static final String USE_OPENGL_ID_EXTRA = "use_opengl";
/*package*/ static final String CONTENT_TYPE_EXTRA = "content_type";
/*package*/ static final String USE_OPENGL_ID_EXTRA = "use_opengl";
private static final int BUFFER_SEGMENT_SIZE = 64 * 1024;
private static final int BUFFER_SEGMENT_COUNT = 160;
private Uri contentUri;
private int contentType;
private boolean useOpenGL;
private ExoPlayer player;
......@@ -69,7 +72,6 @@ public class PlayerActivity extends Activity implements
private TextView debugInfoView;
private String debugInfo;
private String playerState;
private Uri contentUri;
@Override
public void onCreate(Bundle savedInstanceState) {
......@@ -77,6 +79,8 @@ public class PlayerActivity extends Activity implements
Intent intent = getIntent();
contentUri = intent.getData();
contentType = intent.getIntExtra(CONTENT_TYPE_EXTRA,
Util.inferContentType(contentUri.toString()));
useOpenGL = intent.getBooleanExtra(USE_OPENGL_ID_EXTRA, true);
handler = new Handler();
......@@ -111,7 +115,7 @@ public class PlayerActivity extends Activity implements
}
private void startPlayback() {
if (Util.isLocalFileUri(contentUri)) {
if (contentType != Util.TYPE_DASH) {
startBasicPlayback();
} else {
startDashPlayback();
......
......@@ -15,6 +15,8 @@
*/
package com.google.android.exoplayer.demo.vp9opus;
import com.google.android.exoplayer.util.Util;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
......@@ -44,13 +46,16 @@ public class SampleChooserActivity extends Activity {
sampleAdapter.add(new Header("DASH - VP9 Only"));
sampleAdapter.add(new Sample("Google Glass",
"http://demos.webmproject.org/dash/201410/vp9_glass/manifest_vp9.mpd"));
"http://demos.webmproject.org/dash/201410/vp9_glass/manifest_vp9.mpd",
Util.TYPE_DASH));
sampleAdapter.add(new Header("DASH - VP9 and Opus"));
sampleAdapter.add(new Sample("Google Glass",
"http://demos.webmproject.org/dash/201410/vp9_glass/manifest_vp9_opus.mpd"));
"http://demos.webmproject.org/dash/201410/vp9_glass/manifest_vp9_opus.mpd",
Util.TYPE_DASH));
sampleAdapter.add(new Header("DASH - VP9 and Vorbis"));
sampleAdapter.add(new Sample("Google Glass",
"http://demos.webmproject.org/dash/201410/vp9_glass/manifest_vp9_vorbis.mpd"));
"http://demos.webmproject.org/dash/201410/vp9_glass/manifest_vp9_vorbis.mpd",
Util.TYPE_DASH));
sampleList.setAdapter(sampleAdapter);
sampleList.setOnItemClickListener(new OnItemClickListener() {
......@@ -67,7 +72,7 @@ public class SampleChooserActivity extends Activity {
private void onSampleSelected(Sample sample) {
Intent playerIntent = new Intent(this, PlayerActivity.class)
.setData(Uri.parse(sample.uri))
.putExtra(PlayerActivity.USE_OPENGL_ID_EXTRA, sample.useOpenGL);
.putExtra(PlayerActivity.CONTENT_TYPE_EXTRA, sample.type);
startActivity(playerIntent);
}
......@@ -112,20 +117,12 @@ public class SampleChooserActivity extends Activity {
public final String description;
public final String uri;
public final boolean useOpenGL;
public Sample(String description, boolean useOpenGL) {
this(description, null, useOpenGL);
}
public Sample(String description, String uri) {
this(description, uri, true); // always use OpenGL for DASH playbacks.
}
public final int type;
public Sample(String description, String uri, boolean useOpenGL) {
public Sample(String description, String uri, int type) {
this.description = description;
this.uri = uri;
this.useOpenGL = useOpenGL;
this.type = type;
}
}
......
......@@ -82,6 +82,27 @@ public final class Util {
*/
public static final String MODEL = android.os.Build.MODEL;
/**
* Value returned by {@link #inferContentType(String)} for DASH manifests.
*/
public static final int TYPE_DASH = 0;
/**
* Value returned by {@link #inferContentType(String)} for Smooth Streaming manifests.
*/
public static final int TYPE_SS = 1;
/**
* Value returned by {@link #inferContentType(String)} for HLS manifests.
*/
public static final int TYPE_HLS = 2;
/**
* Value returned by {@link #inferContentType(String)} for files other than DASH, HLS or Smooth
* Streaming manifests.
*/
public static final int TYPE_OTHER = 3;
private static final Pattern XS_DATE_TIME_PATTERN = Pattern.compile(
"(\\d\\d\\d\\d)\\-(\\d\\d)\\-(\\d\\d)[Tt]"
+ "(\\d\\d):(\\d\\d):(\\d\\d)(\\.(\\d+))?"
......@@ -728,4 +749,23 @@ public final class Util {
}
}
/**
* Makes a best guess to infer the type from a file name.
*
* @param fileName Name of the file. It can include the path of the file.
* @return One of {@link #TYPE_DASH}, {@link #TYPE_SS}, {@link #TYPE_HLS} or {@link #TYPE_OTHER}.
*/
public static int inferContentType(String fileName) {
if (fileName == null) {
return TYPE_OTHER;
} else if (fileName.endsWith(".mpd")) {
return TYPE_DASH;
} else if (fileName.endsWith(".ism")) {
return TYPE_SS;
} else if (fileName.endsWith(".m3u8")) {
return TYPE_HLS;
} else {
return TYPE_OTHER;
}
}
}
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