Split metadata and text outputs from their renderer classes
There will be non-ExoPlayer players that can output text and metadata, so the outputs should be standalone. There may also be ExoPlayer instances that use non-standard text and metadata renderers, for which this change also makes sense. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=165628420
This commit is contained in:
parent
4917929a3a
commit
2470b39d95
@ -29,7 +29,7 @@ import com.google.android.exoplayer2.audio.AudioRendererEventListener;
|
|||||||
import com.google.android.exoplayer2.decoder.DecoderCounters;
|
import com.google.android.exoplayer2.decoder.DecoderCounters;
|
||||||
import com.google.android.exoplayer2.drm.DefaultDrmSessionManager;
|
import com.google.android.exoplayer2.drm.DefaultDrmSessionManager;
|
||||||
import com.google.android.exoplayer2.metadata.Metadata;
|
import com.google.android.exoplayer2.metadata.Metadata;
|
||||||
import com.google.android.exoplayer2.metadata.MetadataRenderer;
|
import com.google.android.exoplayer2.metadata.MetadataOutput;
|
||||||
import com.google.android.exoplayer2.metadata.emsg.EventMessage;
|
import com.google.android.exoplayer2.metadata.emsg.EventMessage;
|
||||||
import com.google.android.exoplayer2.metadata.id3.ApicFrame;
|
import com.google.android.exoplayer2.metadata.id3.ApicFrame;
|
||||||
import com.google.android.exoplayer2.metadata.id3.CommentFrame;
|
import com.google.android.exoplayer2.metadata.id3.CommentFrame;
|
||||||
@ -55,10 +55,9 @@ import java.util.Locale;
|
|||||||
/**
|
/**
|
||||||
* Logs player events using {@link Log}.
|
* Logs player events using {@link Log}.
|
||||||
*/
|
*/
|
||||||
/* package */ final class EventLogger implements Player.EventListener, AudioRendererEventListener,
|
/* package */ final class EventLogger implements Player.EventListener, MetadataOutput,
|
||||||
VideoRendererEventListener, AdaptiveMediaSourceEventListener,
|
AudioRendererEventListener, VideoRendererEventListener, AdaptiveMediaSourceEventListener,
|
||||||
ExtractorMediaSource.EventListener, DefaultDrmSessionManager.EventListener,
|
ExtractorMediaSource.EventListener, DefaultDrmSessionManager.EventListener {
|
||||||
MetadataRenderer.Output {
|
|
||||||
|
|
||||||
private static final String TAG = "EventLogger";
|
private static final String TAG = "EventLogger";
|
||||||
private static final int MAX_TIMELINE_ITEM_LINES = 3;
|
private static final int MAX_TIMELINE_ITEM_LINES = 3;
|
||||||
@ -205,7 +204,7 @@ import java.util.Locale;
|
|||||||
Log.d(TAG, "]");
|
Log.d(TAG, "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
// MetadataRenderer.Output
|
// MetadataOutput
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMetadata(Metadata metadata) {
|
public void onMetadata(Metadata metadata) {
|
||||||
|
@ -28,7 +28,9 @@ import com.google.android.exoplayer2.audio.MediaCodecAudioRenderer;
|
|||||||
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
||||||
import com.google.android.exoplayer2.drm.FrameworkMediaCrypto;
|
import com.google.android.exoplayer2.drm.FrameworkMediaCrypto;
|
||||||
import com.google.android.exoplayer2.mediacodec.MediaCodecSelector;
|
import com.google.android.exoplayer2.mediacodec.MediaCodecSelector;
|
||||||
|
import com.google.android.exoplayer2.metadata.MetadataOutput;
|
||||||
import com.google.android.exoplayer2.metadata.MetadataRenderer;
|
import com.google.android.exoplayer2.metadata.MetadataRenderer;
|
||||||
|
import com.google.android.exoplayer2.text.TextOutput;
|
||||||
import com.google.android.exoplayer2.text.TextRenderer;
|
import com.google.android.exoplayer2.text.TextRenderer;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelector;
|
import com.google.android.exoplayer2.trackselection.TrackSelector;
|
||||||
import com.google.android.exoplayer2.video.MediaCodecVideoRenderer;
|
import com.google.android.exoplayer2.video.MediaCodecVideoRenderer;
|
||||||
@ -137,8 +139,8 @@ public class DefaultRenderersFactory implements RenderersFactory {
|
|||||||
@Override
|
@Override
|
||||||
public Renderer[] createRenderers(Handler eventHandler,
|
public Renderer[] createRenderers(Handler eventHandler,
|
||||||
VideoRendererEventListener videoRendererEventListener,
|
VideoRendererEventListener videoRendererEventListener,
|
||||||
AudioRendererEventListener audioRendererEventListener, TextRenderer.Output textRendererOutput,
|
AudioRendererEventListener audioRendererEventListener,
|
||||||
MetadataRenderer.Output metadataRendererOutput) {
|
TextOutput textRendererOutput, MetadataOutput metadataRendererOutput) {
|
||||||
ArrayList<Renderer> renderersList = new ArrayList<>();
|
ArrayList<Renderer> renderersList = new ArrayList<>();
|
||||||
buildVideoRenderers(context, drmSessionManager, allowedVideoJoiningTimeMs,
|
buildVideoRenderers(context, drmSessionManager, allowedVideoJoiningTimeMs,
|
||||||
eventHandler, videoRendererEventListener, extensionRendererMode, renderersList);
|
eventHandler, videoRendererEventListener, extensionRendererMode, renderersList);
|
||||||
@ -283,8 +285,8 @@ public class DefaultRenderersFactory implements RenderersFactory {
|
|||||||
* @param extensionRendererMode The extension renderer mode.
|
* @param extensionRendererMode The extension renderer mode.
|
||||||
* @param out An array to which the built renderers should be appended.
|
* @param out An array to which the built renderers should be appended.
|
||||||
*/
|
*/
|
||||||
protected void buildTextRenderers(Context context, TextRenderer.Output output,
|
protected void buildTextRenderers(Context context, TextOutput output, Looper outputLooper,
|
||||||
Looper outputLooper, @ExtensionRendererMode int extensionRendererMode,
|
@ExtensionRendererMode int extensionRendererMode,
|
||||||
ArrayList<Renderer> out) {
|
ArrayList<Renderer> out) {
|
||||||
out.add(new TextRenderer(output, outputLooper));
|
out.add(new TextRenderer(output, outputLooper));
|
||||||
}
|
}
|
||||||
@ -299,9 +301,8 @@ public class DefaultRenderersFactory implements RenderersFactory {
|
|||||||
* @param extensionRendererMode The extension renderer mode.
|
* @param extensionRendererMode The extension renderer mode.
|
||||||
* @param out An array to which the built renderers should be appended.
|
* @param out An array to which the built renderers should be appended.
|
||||||
*/
|
*/
|
||||||
protected void buildMetadataRenderers(Context context, MetadataRenderer.Output output,
|
protected void buildMetadataRenderers(Context context, MetadataOutput output, Looper outputLooper,
|
||||||
Looper outputLooper, @ExtensionRendererMode int extensionRendererMode,
|
@ExtensionRendererMode int extensionRendererMode, ArrayList<Renderer> out) {
|
||||||
ArrayList<Renderer> out) {
|
|
||||||
out.add(new MetadataRenderer(output, outputLooper));
|
out.add(new MetadataRenderer(output, outputLooper));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@ package com.google.android.exoplayer2;
|
|||||||
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
|
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
|
||||||
import com.google.android.exoplayer2.metadata.MetadataRenderer;
|
import com.google.android.exoplayer2.metadata.MetadataOutput;
|
||||||
import com.google.android.exoplayer2.text.TextRenderer;
|
import com.google.android.exoplayer2.text.TextOutput;
|
||||||
import com.google.android.exoplayer2.video.VideoRendererEventListener;
|
import com.google.android.exoplayer2.video.VideoRendererEventListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,7 +38,7 @@ public interface RenderersFactory {
|
|||||||
*/
|
*/
|
||||||
Renderer[] createRenderers(Handler eventHandler,
|
Renderer[] createRenderers(Handler eventHandler,
|
||||||
VideoRendererEventListener videoRendererEventListener,
|
VideoRendererEventListener videoRendererEventListener,
|
||||||
AudioRendererEventListener audioRendererEventListener,
|
AudioRendererEventListener audioRendererEventListener, TextOutput textRendererOutput,
|
||||||
TextRenderer.Output textRendererOutput, MetadataRenderer.Output metadataRendererOutput);
|
MetadataOutput metadataRendererOutput);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,11 +31,11 @@ import com.google.android.exoplayer2.audio.AudioAttributes;
|
|||||||
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
|
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
|
||||||
import com.google.android.exoplayer2.decoder.DecoderCounters;
|
import com.google.android.exoplayer2.decoder.DecoderCounters;
|
||||||
import com.google.android.exoplayer2.metadata.Metadata;
|
import com.google.android.exoplayer2.metadata.Metadata;
|
||||||
import com.google.android.exoplayer2.metadata.MetadataRenderer;
|
import com.google.android.exoplayer2.metadata.MetadataOutput;
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
import com.google.android.exoplayer2.source.MediaSource;
|
||||||
import com.google.android.exoplayer2.source.TrackGroupArray;
|
import com.google.android.exoplayer2.source.TrackGroupArray;
|
||||||
import com.google.android.exoplayer2.text.Cue;
|
import com.google.android.exoplayer2.text.Cue;
|
||||||
import com.google.android.exoplayer2.text.TextRenderer;
|
import com.google.android.exoplayer2.text.TextOutput;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelector;
|
import com.google.android.exoplayer2.trackselection.TrackSelector;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
@ -89,8 +89,8 @@ public class SimpleExoPlayer implements ExoPlayer {
|
|||||||
private final ExoPlayer player;
|
private final ExoPlayer player;
|
||||||
private final ComponentListener componentListener;
|
private final ComponentListener componentListener;
|
||||||
private final CopyOnWriteArraySet<VideoListener> videoListeners;
|
private final CopyOnWriteArraySet<VideoListener> videoListeners;
|
||||||
private final CopyOnWriteArraySet<TextRenderer.Output> textOutputs;
|
private final CopyOnWriteArraySet<TextOutput> textOutputs;
|
||||||
private final CopyOnWriteArraySet<MetadataRenderer.Output> metadataOutputs;
|
private final CopyOnWriteArraySet<MetadataOutput> metadataOutputs;
|
||||||
private final int videoRendererCount;
|
private final int videoRendererCount;
|
||||||
private final int audioRendererCount;
|
private final int audioRendererCount;
|
||||||
|
|
||||||
@ -491,7 +491,7 @@ public class SimpleExoPlayer implements ExoPlayer {
|
|||||||
*
|
*
|
||||||
* @param listener The output to register.
|
* @param listener The output to register.
|
||||||
*/
|
*/
|
||||||
public void addTextOutput(TextRenderer.Output listener) {
|
public void addTextOutput(TextOutput listener) {
|
||||||
textOutputs.add(listener);
|
textOutputs.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,7 +500,7 @@ public class SimpleExoPlayer implements ExoPlayer {
|
|||||||
*
|
*
|
||||||
* @param listener The output to remove.
|
* @param listener The output to remove.
|
||||||
*/
|
*/
|
||||||
public void removeTextOutput(TextRenderer.Output listener) {
|
public void removeTextOutput(TextOutput listener) {
|
||||||
textOutputs.remove(listener);
|
textOutputs.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -508,10 +508,10 @@ public class SimpleExoPlayer implements ExoPlayer {
|
|||||||
* Sets an output to receive text events, removing all existing outputs.
|
* Sets an output to receive text events, removing all existing outputs.
|
||||||
*
|
*
|
||||||
* @param output The output.
|
* @param output The output.
|
||||||
* @deprecated Use {@link #addTextOutput(TextRenderer.Output)}.
|
* @deprecated Use {@link #addTextOutput(TextOutput)}.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setTextOutput(TextRenderer.Output output) {
|
public void setTextOutput(TextOutput output) {
|
||||||
textOutputs.clear();
|
textOutputs.clear();
|
||||||
if (output != null) {
|
if (output != null) {
|
||||||
addTextOutput(output);
|
addTextOutput(output);
|
||||||
@ -519,13 +519,13 @@ public class SimpleExoPlayer implements ExoPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Equivalent to {@link #removeTextOutput(TextRenderer.Output)}.
|
* Equivalent to {@link #removeTextOutput(TextOutput)}.
|
||||||
*
|
*
|
||||||
* @param output The output to clear.
|
* @param output The output to clear.
|
||||||
* @deprecated Use {@link #removeTextOutput(TextRenderer.Output)}.
|
* @deprecated Use {@link #removeTextOutput(TextOutput)}.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void clearTextOutput(TextRenderer.Output output) {
|
public void clearTextOutput(TextOutput output) {
|
||||||
removeTextOutput(output);
|
removeTextOutput(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -534,7 +534,7 @@ public class SimpleExoPlayer implements ExoPlayer {
|
|||||||
*
|
*
|
||||||
* @param listener The output to register.
|
* @param listener The output to register.
|
||||||
*/
|
*/
|
||||||
public void addMetadataOutput(MetadataRenderer.Output listener) {
|
public void addMetadataOutput(MetadataOutput listener) {
|
||||||
metadataOutputs.add(listener);
|
metadataOutputs.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -543,7 +543,7 @@ public class SimpleExoPlayer implements ExoPlayer {
|
|||||||
*
|
*
|
||||||
* @param listener The output to remove.
|
* @param listener The output to remove.
|
||||||
*/
|
*/
|
||||||
public void removeMetadataOutput(MetadataRenderer.Output listener) {
|
public void removeMetadataOutput(MetadataOutput listener) {
|
||||||
metadataOutputs.remove(listener);
|
metadataOutputs.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -551,10 +551,10 @@ public class SimpleExoPlayer implements ExoPlayer {
|
|||||||
* Sets an output to receive metadata events, removing all existing outputs.
|
* Sets an output to receive metadata events, removing all existing outputs.
|
||||||
*
|
*
|
||||||
* @param output The output.
|
* @param output The output.
|
||||||
* @deprecated Use {@link #addMetadataOutput(MetadataRenderer.Output)}.
|
* @deprecated Use {@link #addMetadataOutput(MetadataOutput)}.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setMetadataOutput(MetadataRenderer.Output output) {
|
public void setMetadataOutput(MetadataOutput output) {
|
||||||
metadataOutputs.clear();
|
metadataOutputs.clear();
|
||||||
if (output != null) {
|
if (output != null) {
|
||||||
addMetadataOutput(output);
|
addMetadataOutput(output);
|
||||||
@ -562,13 +562,13 @@ public class SimpleExoPlayer implements ExoPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Equivalent to {@link #removeMetadataOutput(MetadataRenderer.Output)}.
|
* Equivalent to {@link #removeMetadataOutput(MetadataOutput)}.
|
||||||
*
|
*
|
||||||
* @param output The output to clear.
|
* @param output The output to clear.
|
||||||
* @deprecated Use {@link #removeMetadataOutput(MetadataRenderer.Output)}.
|
* @deprecated Use {@link #removeMetadataOutput(MetadataOutput)}.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void clearMetadataOutput(MetadataRenderer.Output output) {
|
public void clearMetadataOutput(MetadataOutput output) {
|
||||||
removeMetadataOutput(output);
|
removeMetadataOutput(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -849,8 +849,8 @@ public class SimpleExoPlayer implements ExoPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final class ComponentListener implements VideoRendererEventListener,
|
private final class ComponentListener implements VideoRendererEventListener,
|
||||||
AudioRendererEventListener, TextRenderer.Output, MetadataRenderer.Output,
|
AudioRendererEventListener, TextOutput, MetadataOutput, SurfaceHolder.Callback,
|
||||||
SurfaceHolder.Callback, TextureView.SurfaceTextureListener {
|
TextureView.SurfaceTextureListener {
|
||||||
|
|
||||||
// VideoRendererEventListener implementation
|
// VideoRendererEventListener implementation
|
||||||
|
|
||||||
@ -973,20 +973,20 @@ public class SimpleExoPlayer implements ExoPlayer {
|
|||||||
audioSessionId = C.AUDIO_SESSION_ID_UNSET;
|
audioSessionId = C.AUDIO_SESSION_ID_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextRenderer.Output implementation
|
// TextOutput implementation
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCues(List<Cue> cues) {
|
public void onCues(List<Cue> cues) {
|
||||||
for (TextRenderer.Output textOutput : textOutputs) {
|
for (TextOutput textOutput : textOutputs) {
|
||||||
textOutput.onCues(cues);
|
textOutput.onCues(cues);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MetadataRenderer.Output implementation
|
// MetadataOutput implementation
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMetadata(Metadata metadata) {
|
public void onMetadata(Metadata metadata) {
|
||||||
for (MetadataRenderer.Output metadataOutput : metadataOutputs) {
|
for (MetadataOutput metadataOutput : metadataOutputs) {
|
||||||
metadataOutput.onMetadata(metadata);
|
metadataOutput.onMetadata(metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 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.exoplayer2.metadata;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives metadata output.
|
||||||
|
*/
|
||||||
|
public interface MetadataOutput {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when there is metadata associated with current playback time.
|
||||||
|
*
|
||||||
|
* @param metadata The metadata.
|
||||||
|
*/
|
||||||
|
void onMetadata(Metadata metadata);
|
||||||
|
|
||||||
|
}
|
@ -33,18 +33,10 @@ import java.util.Arrays;
|
|||||||
public final class MetadataRenderer extends BaseRenderer implements Callback {
|
public final class MetadataRenderer extends BaseRenderer implements Callback {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receives output from a {@link MetadataRenderer}.
|
* @deprecated Use {@link MetadataOutput}.
|
||||||
*/
|
*/
|
||||||
public interface Output {
|
@Deprecated
|
||||||
|
public interface Output extends MetadataOutput {}
|
||||||
/**
|
|
||||||
* Called each time there is a metadata associated with current playback time.
|
|
||||||
*
|
|
||||||
* @param metadata The metadata.
|
|
||||||
*/
|
|
||||||
void onMetadata(Metadata metadata);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final int MSG_INVOKE_RENDERER = 0;
|
private static final int MSG_INVOKE_RENDERER = 0;
|
||||||
// TODO: Holding multiple pending metadata objects is temporary mitigation against
|
// TODO: Holding multiple pending metadata objects is temporary mitigation against
|
||||||
@ -53,7 +45,7 @@ public final class MetadataRenderer extends BaseRenderer implements Callback {
|
|||||||
private static final int MAX_PENDING_METADATA_COUNT = 5;
|
private static final int MAX_PENDING_METADATA_COUNT = 5;
|
||||||
|
|
||||||
private final MetadataDecoderFactory decoderFactory;
|
private final MetadataDecoderFactory decoderFactory;
|
||||||
private final Output output;
|
private final MetadataOutput output;
|
||||||
private final Handler outputHandler;
|
private final Handler outputHandler;
|
||||||
private final FormatHolder formatHolder;
|
private final FormatHolder formatHolder;
|
||||||
private final MetadataInputBuffer buffer;
|
private final MetadataInputBuffer buffer;
|
||||||
@ -73,7 +65,7 @@ public final class MetadataRenderer extends BaseRenderer implements Callback {
|
|||||||
* {@link android.app.Activity#getMainLooper()}. Null may be passed if the output should be
|
* {@link android.app.Activity#getMainLooper()}. Null may be passed if the output should be
|
||||||
* called directly on the player's internal rendering thread.
|
* called directly on the player's internal rendering thread.
|
||||||
*/
|
*/
|
||||||
public MetadataRenderer(Output output, Looper outputLooper) {
|
public MetadataRenderer(MetadataOutput output, Looper outputLooper) {
|
||||||
this(output, outputLooper, MetadataDecoderFactory.DEFAULT);
|
this(output, outputLooper, MetadataDecoderFactory.DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +78,7 @@ public final class MetadataRenderer extends BaseRenderer implements Callback {
|
|||||||
* called directly on the player's internal rendering thread.
|
* called directly on the player's internal rendering thread.
|
||||||
* @param decoderFactory A factory from which to obtain {@link MetadataDecoder} instances.
|
* @param decoderFactory A factory from which to obtain {@link MetadataDecoder} instances.
|
||||||
*/
|
*/
|
||||||
public MetadataRenderer(Output output, Looper outputLooper,
|
public MetadataRenderer(MetadataOutput output, Looper outputLooper,
|
||||||
MetadataDecoderFactory decoderFactory) {
|
MetadataDecoderFactory decoderFactory) {
|
||||||
super(C.TRACK_TYPE_METADATA);
|
super(C.TRACK_TYPE_METADATA);
|
||||||
this.output = Assertions.checkNotNull(output);
|
this.output = Assertions.checkNotNull(output);
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 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.exoplayer2.text;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives text output.
|
||||||
|
*/
|
||||||
|
public interface TextOutput {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when there is a change in the {@link Cue}s.
|
||||||
|
*
|
||||||
|
* @param cues The {@link Cue}s.
|
||||||
|
*/
|
||||||
|
void onCues(List<Cue> cues);
|
||||||
|
|
||||||
|
}
|
@ -37,23 +37,15 @@ import java.util.List;
|
|||||||
* <p>
|
* <p>
|
||||||
* {@link Subtitle}s are decoded from sample data using {@link SubtitleDecoder} instances obtained
|
* {@link Subtitle}s are decoded from sample data using {@link SubtitleDecoder} instances obtained
|
||||||
* from a {@link SubtitleDecoderFactory}. The actual rendering of the subtitle {@link Cue}s is
|
* from a {@link SubtitleDecoderFactory}. The actual rendering of the subtitle {@link Cue}s is
|
||||||
* delegated to an {@link Output}.
|
* delegated to an {@link TextOutput}.
|
||||||
*/
|
*/
|
||||||
public final class TextRenderer extends BaseRenderer implements Callback {
|
public final class TextRenderer extends BaseRenderer implements Callback {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receives output from a {@link TextRenderer}.
|
* @deprecated Use {@link TextOutput}.
|
||||||
*/
|
*/
|
||||||
public interface Output {
|
@Deprecated
|
||||||
|
public interface Output extends TextOutput {}
|
||||||
/**
|
|
||||||
* Called each time there is a change in the {@link Cue}s.
|
|
||||||
*
|
|
||||||
* @param cues The {@link Cue}s.
|
|
||||||
*/
|
|
||||||
void onCues(List<Cue> cues);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
@IntDef({REPLACEMENT_STATE_NONE, REPLACEMENT_STATE_SIGNAL_END_OF_STREAM,
|
@IntDef({REPLACEMENT_STATE_NONE, REPLACEMENT_STATE_SIGNAL_END_OF_STREAM,
|
||||||
@ -79,7 +71,7 @@ public final class TextRenderer extends BaseRenderer implements Callback {
|
|||||||
private static final int MSG_UPDATE_OUTPUT = 0;
|
private static final int MSG_UPDATE_OUTPUT = 0;
|
||||||
|
|
||||||
private final Handler outputHandler;
|
private final Handler outputHandler;
|
||||||
private final Output output;
|
private final TextOutput output;
|
||||||
private final SubtitleDecoderFactory decoderFactory;
|
private final SubtitleDecoderFactory decoderFactory;
|
||||||
private final FormatHolder formatHolder;
|
private final FormatHolder formatHolder;
|
||||||
|
|
||||||
@ -101,7 +93,7 @@ public final class TextRenderer extends BaseRenderer implements Callback {
|
|||||||
* using {@link android.app.Activity#getMainLooper()}. Null may be passed if the output
|
* using {@link android.app.Activity#getMainLooper()}. Null may be passed if the output
|
||||||
* should be called directly on the player's internal rendering thread.
|
* should be called directly on the player's internal rendering thread.
|
||||||
*/
|
*/
|
||||||
public TextRenderer(Output output, Looper outputLooper) {
|
public TextRenderer(TextOutput output, Looper outputLooper) {
|
||||||
this(output, outputLooper, SubtitleDecoderFactory.DEFAULT);
|
this(output, outputLooper, SubtitleDecoderFactory.DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +106,8 @@ public final class TextRenderer extends BaseRenderer implements Callback {
|
|||||||
* should be called directly on the player's internal rendering thread.
|
* should be called directly on the player's internal rendering thread.
|
||||||
* @param decoderFactory A factory from which to obtain {@link SubtitleDecoder} instances.
|
* @param decoderFactory A factory from which to obtain {@link SubtitleDecoder} instances.
|
||||||
*/
|
*/
|
||||||
public TextRenderer(Output output, Looper outputLooper, SubtitleDecoderFactory decoderFactory) {
|
public TextRenderer(TextOutput output, Looper outputLooper,
|
||||||
|
SubtitleDecoderFactory decoderFactory) {
|
||||||
super(C.TRACK_TYPE_TEXT);
|
super(C.TRACK_TYPE_TEXT);
|
||||||
this.output = Assertions.checkNotNull(output);
|
this.output = Assertions.checkNotNull(output);
|
||||||
this.outputHandler = outputLooper == null ? null : new Handler(outputLooper, this);
|
this.outputHandler = outputLooper == null ? null : new Handler(outputLooper, this);
|
||||||
|
@ -43,7 +43,7 @@ import com.google.android.exoplayer2.metadata.Metadata;
|
|||||||
import com.google.android.exoplayer2.metadata.id3.ApicFrame;
|
import com.google.android.exoplayer2.metadata.id3.ApicFrame;
|
||||||
import com.google.android.exoplayer2.source.TrackGroupArray;
|
import com.google.android.exoplayer2.source.TrackGroupArray;
|
||||||
import com.google.android.exoplayer2.text.Cue;
|
import com.google.android.exoplayer2.text.Cue;
|
||||||
import com.google.android.exoplayer2.text.TextRenderer;
|
import com.google.android.exoplayer2.text.TextOutput;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelection;
|
import com.google.android.exoplayer2.trackselection.TrackSelection;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
||||||
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout.ResizeMode;
|
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout.ResizeMode;
|
||||||
@ -844,10 +844,10 @@ public final class SimpleExoPlayerView extends FrameLayout {
|
|||||||
aspectRatioFrame.setResizeMode(resizeMode);
|
aspectRatioFrame.setResizeMode(resizeMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ComponentListener implements SimpleExoPlayer.VideoListener,
|
private final class ComponentListener implements TextOutput, SimpleExoPlayer.VideoListener,
|
||||||
TextRenderer.Output, Player.EventListener {
|
Player.EventListener {
|
||||||
|
|
||||||
// TextRenderer.Output implementation
|
// TextOutput implementation
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCues(List<Cue> cues) {
|
public void onCues(List<Cue> cues) {
|
||||||
@ -856,7 +856,7 @@ public final class SimpleExoPlayerView extends FrameLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SimpleExoPlayer.VideoListener implementation
|
// SimpleExoPlayer.VideoInfoListener implementation
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees,
|
public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees,
|
||||||
|
@ -25,7 +25,7 @@ import android.view.View;
|
|||||||
import android.view.accessibility.CaptioningManager;
|
import android.view.accessibility.CaptioningManager;
|
||||||
import com.google.android.exoplayer2.text.CaptionStyleCompat;
|
import com.google.android.exoplayer2.text.CaptionStyleCompat;
|
||||||
import com.google.android.exoplayer2.text.Cue;
|
import com.google.android.exoplayer2.text.Cue;
|
||||||
import com.google.android.exoplayer2.text.TextRenderer;
|
import com.google.android.exoplayer2.text.TextOutput;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -33,7 +33,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* A view for displaying subtitle {@link Cue}s.
|
* A view for displaying subtitle {@link Cue}s.
|
||||||
*/
|
*/
|
||||||
public final class SubtitleView extends View implements TextRenderer.Output {
|
public final class SubtitleView extends View implements TextOutput {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default fractional text size.
|
* The default fractional text size.
|
||||||
|
@ -29,12 +29,12 @@ import com.google.android.exoplayer2.RenderersFactory;
|
|||||||
import com.google.android.exoplayer2.SimpleExoPlayer;
|
import com.google.android.exoplayer2.SimpleExoPlayer;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
import com.google.android.exoplayer2.Timeline;
|
||||||
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
|
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
|
||||||
import com.google.android.exoplayer2.metadata.MetadataRenderer;
|
import com.google.android.exoplayer2.metadata.MetadataOutput;
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
import com.google.android.exoplayer2.source.MediaSource;
|
||||||
import com.google.android.exoplayer2.source.TrackGroupArray;
|
import com.google.android.exoplayer2.source.TrackGroupArray;
|
||||||
import com.google.android.exoplayer2.testutil.ExoPlayerTestRunner.Builder.PlayerFactory;
|
import com.google.android.exoplayer2.testutil.ExoPlayerTestRunner.Builder.PlayerFactory;
|
||||||
import com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition;
|
import com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition;
|
||||||
import com.google.android.exoplayer2.text.TextRenderer.Output;
|
import com.google.android.exoplayer2.text.TextOutput;
|
||||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
||||||
import com.google.android.exoplayer2.trackselection.MappingTrackSelector;
|
import com.google.android.exoplayer2.trackselection.MappingTrackSelector;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
||||||
@ -164,8 +164,8 @@ public final class ExoPlayerTestRunner implements Player.EventListener {
|
|||||||
@Override
|
@Override
|
||||||
public Renderer[] createRenderers(Handler eventHandler,
|
public Renderer[] createRenderers(Handler eventHandler,
|
||||||
VideoRendererEventListener videoRendererEventListener,
|
VideoRendererEventListener videoRendererEventListener,
|
||||||
AudioRendererEventListener audioRendererEventListener, Output textRendererOutput,
|
AudioRendererEventListener audioRendererEventListener, TextOutput textRendererOutput,
|
||||||
MetadataRenderer.Output metadataRendererOutput) {
|
MetadataOutput metadataRendererOutput) {
|
||||||
return renderers;
|
return renderers;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user