From 9921dfd1ced208f4dd4d37cd92d3debcb963a501 Mon Sep 17 00:00:00 2001 From: Oliver Woodman Date: Tue, 5 May 2015 20:33:25 +0100 Subject: [PATCH] Deprecate FrameworkSampleSource as a deterrent. --- .../android/exoplayer/demo/DemoUtil.java | 3 +- .../exoplayer/demo/PlayerActivity.java | 5 +- .../demo/player/DefaultRendererBuilder.java | 68 ------------------- .../exoplayer/FrameworkSampleSource.java | 19 ++++++ 4 files changed, 22 insertions(+), 73 deletions(-) delete mode 100644 demo/src/main/java/com/google/android/exoplayer/demo/player/DefaultRendererBuilder.java diff --git a/demo/src/main/java/com/google/android/exoplayer/demo/DemoUtil.java b/demo/src/main/java/com/google/android/exoplayer/demo/DemoUtil.java index ef43fe969b..38a1513a53 100644 --- a/demo/src/main/java/com/google/android/exoplayer/demo/DemoUtil.java +++ b/demo/src/main/java/com/google/android/exoplayer/demo/DemoUtil.java @@ -46,11 +46,10 @@ public class DemoUtil { public static final int TYPE_HLS = 2; public static final int TYPE_MP4 = 3; public static final int TYPE_MP3 = 4; + public static final int TYPE_M4A = 5; public static final int TYPE_WEBM = 5; public static final int TYPE_TS = 6; public static final int TYPE_AAC = 7; - public static final int TYPE_OTHER = 8; - public static final int TYPE_M4A = 9; private static final CookieManager defaultCookieManager; diff --git a/demo/src/main/java/com/google/android/exoplayer/demo/PlayerActivity.java b/demo/src/main/java/com/google/android/exoplayer/demo/PlayerActivity.java index 520470f881..7f17e98a59 100644 --- a/demo/src/main/java/com/google/android/exoplayer/demo/PlayerActivity.java +++ b/demo/src/main/java/com/google/android/exoplayer/demo/PlayerActivity.java @@ -20,7 +20,6 @@ import com.google.android.exoplayer.VideoSurfaceView; import com.google.android.exoplayer.audio.AudioCapabilities; import com.google.android.exoplayer.audio.AudioCapabilitiesReceiver; import com.google.android.exoplayer.demo.player.DashRendererBuilder; -import com.google.android.exoplayer.demo.player.DefaultRendererBuilder; import com.google.android.exoplayer.demo.player.DemoPlayer; import com.google.android.exoplayer.demo.player.DemoPlayer.RendererBuilder; import com.google.android.exoplayer.demo.player.ExtractorRendererBuilder; @@ -120,7 +119,7 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback, Intent intent = getIntent(); contentUri = intent.getData(); - contentType = intent.getIntExtra(CONTENT_TYPE_EXTRA, DemoUtil.TYPE_OTHER); + contentType = intent.getIntExtra(CONTENT_TYPE_EXTRA, -1); contentId = intent.getStringExtra(CONTENT_ID_EXTRA); setContentView(R.layout.player_activity); @@ -248,7 +247,7 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback, return new ExtractorRendererBuilder(userAgent, contentUri, debugTextView, new WebmExtractor()); default: - return new DefaultRendererBuilder(this, contentUri, debugTextView); + throw new IllegalStateException("Unsupported type: " + contentType); } } diff --git a/demo/src/main/java/com/google/android/exoplayer/demo/player/DefaultRendererBuilder.java b/demo/src/main/java/com/google/android/exoplayer/demo/player/DefaultRendererBuilder.java deleted file mode 100644 index 6163d0ad8d..0000000000 --- a/demo/src/main/java/com/google/android/exoplayer/demo/player/DefaultRendererBuilder.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.demo.player; - -import com.google.android.exoplayer.FrameworkSampleSource; -import com.google.android.exoplayer.MediaCodecAudioTrackRenderer; -import com.google.android.exoplayer.MediaCodecVideoTrackRenderer; -import com.google.android.exoplayer.TrackRenderer; -import com.google.android.exoplayer.demo.player.DemoPlayer.RendererBuilder; -import com.google.android.exoplayer.demo.player.DemoPlayer.RendererBuilderCallback; - -import android.content.Context; -import android.media.MediaCodec; -import android.net.Uri; -import android.widget.TextView; - -/** - * A {@link RendererBuilder} for streams that can be read using - * {@link android.media.MediaExtractor}. - */ -public class DefaultRendererBuilder implements RendererBuilder { - - private final Context context; - private final Uri uri; - private final TextView debugTextView; - - public DefaultRendererBuilder(Context context, Uri uri, TextView debugTextView) { - this.context = context; - this.uri = uri; - this.debugTextView = debugTextView; - } - - @Override - public void buildRenderers(DemoPlayer player, RendererBuilderCallback callback) { - // Build the video and audio renderers. - FrameworkSampleSource sampleSource = new FrameworkSampleSource(context, uri, null, 2); - MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(sampleSource, - null, true, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, null, player.getMainHandler(), - player, 50); - MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource, - null, true, player.getMainHandler(), player); - - // Build the debug renderer. - TrackRenderer debugRenderer = debugTextView != null - ? new DebugTrackRenderer(debugTextView, player, videoRenderer) : null; - - // Invoke the callback. - TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT]; - renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer; - renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer; - renderers[DemoPlayer.TYPE_DEBUG] = debugRenderer; - callback.onRenderers(null, null, renderers); - } - -} diff --git a/library/src/main/java/com/google/android/exoplayer/FrameworkSampleSource.java b/library/src/main/java/com/google/android/exoplayer/FrameworkSampleSource.java index bfc4ca64dd..0d3fc61437 100644 --- a/library/src/main/java/com/google/android/exoplayer/FrameworkSampleSource.java +++ b/library/src/main/java/com/google/android/exoplayer/FrameworkSampleSource.java @@ -16,6 +16,8 @@ package com.google.android.exoplayer; import com.google.android.exoplayer.drm.DrmInitData; +import com.google.android.exoplayer.extractor.ExtractorSampleSource; +import com.google.android.exoplayer.extractor.mp4.Mp4Extractor; import com.google.android.exoplayer.util.Assertions; import com.google.android.exoplayer.util.MimeTypes; import com.google.android.exoplayer.util.Util; @@ -32,9 +34,26 @@ import java.util.UUID; /** * Extracts samples from a stream using Android's {@link MediaExtractor}. + *

+ * Warning - This class is marked as deprecated because there are known device specific issues + * associated with its use, including playbacks not starting, playbacks stuttering and other + * miscellaneous failures. For mp4, m4a, mp3, webm, mpeg-ts and aac playbacks it is strongly + * recommended to use {@link ExtractorSampleSource} instead, along with the corresponding extractor + * (e.g. {@link Mp4Extractor} for mp4 playbacks). Where this is not possible this class can still be + * used, but please be aware of the associated risks. Valid use cases of this class that are not + * yet supported by {@link ExtractorSampleSource} include: + *

+ * Over time we hope to enhance {@link ExtractorSampleSource} to support these use cases, and hence + * make use of this class unnecessary. */ // TODO: This implementation needs to be fixed so that its methods are non-blocking (either // through use of a background thread, or through changes to the framework's MediaExtractor API). +@Deprecated @TargetApi(16) public final class FrameworkSampleSource implements SampleSource {