mirror of
https://github.com/samsonjs/media.git
synced 2026-03-26 09:35:47 +00:00
Deprecate FrameworkSampleSource as a deterrent.
This commit is contained in:
parent
37827be8cb
commit
9921dfd1ce
4 changed files with 22 additions and 73 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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}.
|
||||
* <p>
|
||||
* 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:
|
||||
* <ul>
|
||||
* <li>Playing a container format for which an ExoPlayer extractor does not yet exist (e.g. ogg).
|
||||
* </li>
|
||||
* <li>Playing media whose container format is unknown and so needs to be inferred automatically.
|
||||
* </li>
|
||||
* </ul>
|
||||
* 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 {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue