mirror of
https://github.com/samsonjs/media.git
synced 2026-04-12 12:25:47 +00:00
Remove references to core player classes from C
Move player messages and scaling modes to Renderer. Remove @links to ExoPlayer AudioAttributes and renderers. PiperOrigin-RevId: 290932785
This commit is contained in:
parent
78fe1afa85
commit
c8f0814bd0
10 changed files with 218 additions and 168 deletions
|
|
@ -11,6 +11,8 @@
|
|||
* Rename `MediaCodecRenderer.onOutputFormatChanged` to
|
||||
`MediaCodecRenderer.onOutputMediaFormatChanged`, further
|
||||
clarifying the distinction between `Format` and `MediaFormat`.
|
||||
* Move player message-related constants from `C` to `Renderer`, to avoid
|
||||
having the constants class depend on player/renderer classes.
|
||||
* Text:
|
||||
* Parse `<ruby>` and `<rt>` tags in WebVTT subtitles (rendering is coming
|
||||
later).
|
||||
|
|
|
|||
|
|
@ -46,9 +46,9 @@ import com.google.android.exoplayer2.video.VideoRendererEventListener;
|
|||
* on the playback thread:
|
||||
*
|
||||
* <ul>
|
||||
* <li>Message with type {@link C#MSG_SET_SURFACE} to set the output surface. The message payload
|
||||
* <li>Message with type {@link #MSG_SET_SURFACE} to set the output surface. The message payload
|
||||
* should be the target {@link Surface}, or null.
|
||||
* <li>Message with type {@link C#MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER} to set the output
|
||||
* <li>Message with type {@link #MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER} to set the output
|
||||
* buffer renderer. The message payload should be the target {@link
|
||||
* VideoDecoderOutputBufferRenderer}, or null.
|
||||
* </ul>
|
||||
|
|
@ -186,9 +186,9 @@ public class Libgav1VideoRenderer extends SimpleDecoderVideoRenderer {
|
|||
|
||||
@Override
|
||||
public void handleMessage(int messageType, @Nullable Object message) throws ExoPlaybackException {
|
||||
if (messageType == C.MSG_SET_SURFACE) {
|
||||
if (messageType == MSG_SET_SURFACE) {
|
||||
setOutputSurface((Surface) message);
|
||||
} else if (messageType == C.MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER) {
|
||||
} else if (messageType == MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER) {
|
||||
setOutputBufferRenderer((VideoDecoderOutputBufferRenderer) message);
|
||||
} else {
|
||||
super.handleMessage(messageType, message);
|
||||
|
|
|
|||
|
|
@ -47,9 +47,9 @@ import com.google.android.exoplayer2.video.VideoRendererEventListener;
|
|||
* on the playback thread:
|
||||
*
|
||||
* <ul>
|
||||
* <li>Message with type {@link C#MSG_SET_SURFACE} to set the output surface. The message payload
|
||||
* <li>Message with type {@link #MSG_SET_SURFACE} to set the output surface. The message payload
|
||||
* should be the target {@link Surface}, or null.
|
||||
* <li>Message with type {@link C#MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER} to set the output
|
||||
* <li>Message with type {@link #MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER} to set the output
|
||||
* buffer renderer. The message payload should be the target {@link
|
||||
* VideoDecoderOutputBufferRenderer}, or null.
|
||||
* </ul>
|
||||
|
|
@ -292,11 +292,11 @@ public class LibvpxVideoRenderer extends SimpleDecoderVideoRenderer {
|
|||
|
||||
@Override
|
||||
public void handleMessage(int messageType, @Nullable Object message) throws ExoPlaybackException {
|
||||
if (messageType == C.MSG_SET_SURFACE) {
|
||||
if (messageType == MSG_SET_SURFACE) {
|
||||
setOutputSurface((Surface) message);
|
||||
} else if (messageType == C.MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER) {
|
||||
} else if (messageType == MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER) {
|
||||
setOutputBufferRenderer((VideoDecoderOutputBufferRenderer) message);
|
||||
} else if (messageType == C.MSG_SET_VIDEO_FRAME_METADATA_LISTENER) {
|
||||
} else if (messageType == MSG_SET_VIDEO_FRAME_METADATA_LISTENER) {
|
||||
frameMetadataListener = (VideoFrameMetadataListener) message;
|
||||
} else {
|
||||
super.handleMessage(messageType, message);
|
||||
|
|
|
|||
|
|
@ -22,15 +22,8 @@ import android.media.AudioFormat;
|
|||
import android.media.AudioManager;
|
||||
import android.media.MediaCodec;
|
||||
import android.media.MediaFormat;
|
||||
import android.view.Surface;
|
||||
import androidx.annotation.IntDef;
|
||||
import com.google.android.exoplayer2.PlayerMessage.Target;
|
||||
import com.google.android.exoplayer2.audio.AuxEffectInfo;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import com.google.android.exoplayer2.video.SimpleDecoderVideoRenderer;
|
||||
import com.google.android.exoplayer2.video.VideoDecoderOutputBufferRenderer;
|
||||
import com.google.android.exoplayer2.video.VideoFrameMetadataListener;
|
||||
import com.google.android.exoplayer2.video.spherical.CameraMotionListener;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
|
@ -284,9 +277,9 @@ public final class C {
|
|||
public static final int STREAM_TYPE_DEFAULT = STREAM_TYPE_MUSIC;
|
||||
|
||||
/**
|
||||
* Content types for {@link com.google.android.exoplayer2.audio.AudioAttributes}. One of {@link
|
||||
* #CONTENT_TYPE_MOVIE}, {@link #CONTENT_TYPE_MUSIC}, {@link #CONTENT_TYPE_SONIFICATION}, {@link
|
||||
* #CONTENT_TYPE_SPEECH} or {@link #CONTENT_TYPE_UNKNOWN}.
|
||||
* Content types for audio attributes. One of {@link #CONTENT_TYPE_MOVIE}, {@link
|
||||
* #CONTENT_TYPE_MUSIC}, {@link #CONTENT_TYPE_SONIFICATION}, {@link #CONTENT_TYPE_SPEECH} or
|
||||
* {@link #CONTENT_TYPE_UNKNOWN}.
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
|
|
@ -323,8 +316,7 @@ public final class C {
|
|||
android.media.AudioAttributes.CONTENT_TYPE_UNKNOWN;
|
||||
|
||||
/**
|
||||
* Flags for {@link com.google.android.exoplayer2.audio.AudioAttributes}. Possible flag value is
|
||||
* {@link #FLAG_AUDIBILITY_ENFORCED}.
|
||||
* Flags for audio attributes. Possible flag value is {@link #FLAG_AUDIBILITY_ENFORCED}.
|
||||
*
|
||||
* <p>Note that {@code FLAG_HW_AV_SYNC} is not available because the player takes care of setting
|
||||
* the flag when tunneling is enabled via a track selector.
|
||||
|
|
@ -342,15 +334,14 @@ public final class C {
|
|||
android.media.AudioAttributes.FLAG_AUDIBILITY_ENFORCED;
|
||||
|
||||
/**
|
||||
* Usage types for {@link com.google.android.exoplayer2.audio.AudioAttributes}. One of {@link
|
||||
* #USAGE_ALARM}, {@link #USAGE_ASSISTANCE_ACCESSIBILITY}, {@link
|
||||
* #USAGE_ASSISTANCE_NAVIGATION_GUIDANCE}, {@link #USAGE_ASSISTANCE_SONIFICATION}, {@link
|
||||
* #USAGE_ASSISTANT}, {@link #USAGE_GAME}, {@link #USAGE_MEDIA}, {@link #USAGE_NOTIFICATION},
|
||||
* {@link #USAGE_NOTIFICATION_COMMUNICATION_DELAYED}, {@link
|
||||
* #USAGE_NOTIFICATION_COMMUNICATION_INSTANT}, {@link #USAGE_NOTIFICATION_COMMUNICATION_REQUEST},
|
||||
* {@link #USAGE_NOTIFICATION_EVENT}, {@link #USAGE_NOTIFICATION_RINGTONE}, {@link
|
||||
* #USAGE_UNKNOWN}, {@link #USAGE_VOICE_COMMUNICATION} or {@link
|
||||
* #USAGE_VOICE_COMMUNICATION_SIGNALLING}.
|
||||
* Usage types for audio attributes. One of {@link #USAGE_ALARM}, {@link
|
||||
* #USAGE_ASSISTANCE_ACCESSIBILITY}, {@link #USAGE_ASSISTANCE_NAVIGATION_GUIDANCE}, {@link
|
||||
* #USAGE_ASSISTANCE_SONIFICATION}, {@link #USAGE_ASSISTANT}, {@link #USAGE_GAME}, {@link
|
||||
* #USAGE_MEDIA}, {@link #USAGE_NOTIFICATION}, {@link #USAGE_NOTIFICATION_COMMUNICATION_DELAYED},
|
||||
* {@link #USAGE_NOTIFICATION_COMMUNICATION_INSTANT}, {@link
|
||||
* #USAGE_NOTIFICATION_COMMUNICATION_REQUEST}, {@link #USAGE_NOTIFICATION_EVENT}, {@link
|
||||
* #USAGE_NOTIFICATION_RINGTONE}, {@link #USAGE_UNKNOWN}, {@link #USAGE_VOICE_COMMUNICATION} or
|
||||
* {@link #USAGE_VOICE_COMMUNICATION_SIGNALLING}.
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
|
|
@ -445,8 +436,8 @@ public final class C {
|
|||
android.media.AudioAttributes.USAGE_VOICE_COMMUNICATION_SIGNALLING;
|
||||
|
||||
/**
|
||||
* Capture policies for {@link com.google.android.exoplayer2.audio.AudioAttributes}. One of {@link
|
||||
* #ALLOW_CAPTURE_BY_ALL}, {@link #ALLOW_CAPTURE_BY_NONE} or {@link #ALLOW_CAPTURE_BY_SYSTEM}.
|
||||
* Capture policies for audio attributes. One of {@link #ALLOW_CAPTURE_BY_ALL}, {@link
|
||||
* #ALLOW_CAPTURE_BY_NONE} or {@link #ALLOW_CAPTURE_BY_SYSTEM}.
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
|
|
@ -542,28 +533,22 @@ public final class C {
|
|||
// ../../../../../../../../../extensions/vp9/src/main/jni/vpx_jni.cc
|
||||
// )
|
||||
|
||||
/**
|
||||
* Video scaling modes for {@link MediaCodec}-based {@link Renderer}s. One of {@link
|
||||
* #VIDEO_SCALING_MODE_SCALE_TO_FIT} or {@link #VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING}.
|
||||
*/
|
||||
/** @deprecated Use {@code Renderer.VideoScalingMode}. */
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef(value = {VIDEO_SCALING_MODE_SCALE_TO_FIT, VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING})
|
||||
@Deprecated
|
||||
public @interface VideoScalingMode {}
|
||||
/**
|
||||
* @see MediaCodec#VIDEO_SCALING_MODE_SCALE_TO_FIT
|
||||
*/
|
||||
/** @deprecated Use {@code Renderer.VIDEO_SCALING_MODE_SCALE_TO_FIT}. */
|
||||
@Deprecated
|
||||
public static final int VIDEO_SCALING_MODE_SCALE_TO_FIT =
|
||||
MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT;
|
||||
/**
|
||||
* @see MediaCodec#VIDEO_SCALING_MODE_SCALE_TO_FIT
|
||||
*/
|
||||
/** @deprecated Use {@code Renderer.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING}. */
|
||||
@Deprecated
|
||||
public static final int VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING =
|
||||
MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING;
|
||||
/**
|
||||
* A default video scaling mode for {@link MediaCodec}-based {@link Renderer}s.
|
||||
*/
|
||||
public static final int VIDEO_SCALING_MODE_DEFAULT = VIDEO_SCALING_MODE_SCALE_TO_FIT;
|
||||
/** @deprecated Use {@code Renderer.VIDEO_SCALING_MODE_DEFAULT}. */
|
||||
@Deprecated public static final int VIDEO_SCALING_MODE_DEFAULT = VIDEO_SCALING_MODE_SCALE_TO_FIT;
|
||||
|
||||
/**
|
||||
* Track selection flags. Possible flag values are {@link #SELECTION_FLAG_DEFAULT}, {@link
|
||||
|
|
@ -763,90 +748,32 @@ public final class C {
|
|||
*/
|
||||
public static final UUID PLAYREADY_UUID = new UUID(0x9A04F07998404286L, 0xAB92E65BE0885F95L);
|
||||
|
||||
/**
|
||||
* The type of a message that can be passed to a video {@link Renderer} via {@link
|
||||
* ExoPlayer#createMessage(Target)}. The message payload should be the target {@link Surface}, or
|
||||
* null.
|
||||
*/
|
||||
public static final int MSG_SET_SURFACE = 1;
|
||||
/** @deprecated Use {@code Renderer.MSG_SET_SURFACE}. */
|
||||
@Deprecated public static final int MSG_SET_SURFACE = 1;
|
||||
|
||||
/**
|
||||
* A type of a message that can be passed to an audio {@link Renderer} via {@link
|
||||
* ExoPlayer#createMessage(Target)}. The message payload should be a {@link Float} with 0 being
|
||||
* silence and 1 being unity gain.
|
||||
*/
|
||||
public static final int MSG_SET_VOLUME = 2;
|
||||
/** @deprecated Use {@code Renderer.MSG_SET_VOLUME}. */
|
||||
@Deprecated public static final int MSG_SET_VOLUME = 2;
|
||||
|
||||
/**
|
||||
* A type of a message that can be passed to an audio {@link Renderer} via {@link
|
||||
* ExoPlayer#createMessage(Target)}. The message payload should be an {@link
|
||||
* com.google.android.exoplayer2.audio.AudioAttributes} instance that will configure the
|
||||
* underlying audio track. If not set, the default audio attributes will be used. They are
|
||||
* suitable for general media playback.
|
||||
*
|
||||
* <p>Setting the audio attributes during playback may introduce a short gap in audio output as
|
||||
* the audio track is recreated. A new audio session id will also be generated.
|
||||
*
|
||||
* <p>If tunneling is enabled by the track selector, the specified audio attributes will be
|
||||
* ignored, but they will take effect if audio is later played without tunneling.
|
||||
*
|
||||
* <p>If the device is running a build before platform API version 21, audio attributes cannot be
|
||||
* set directly on the underlying audio track. In this case, the usage will be mapped onto an
|
||||
* equivalent stream type using {@link Util#getStreamTypeForAudioUsage(int)}.
|
||||
*
|
||||
* <p>To get audio attributes that are equivalent to a legacy stream type, pass the stream type to
|
||||
* {@link Util#getAudioUsageForStreamType(int)} and use the returned {@link C.AudioUsage} to build
|
||||
* an audio attributes instance.
|
||||
*/
|
||||
public static final int MSG_SET_AUDIO_ATTRIBUTES = 3;
|
||||
/** @deprecated Use {@code Renderer.MSG_SET_AUDIO_ATTRIBUTES}. */
|
||||
@Deprecated public static final int MSG_SET_AUDIO_ATTRIBUTES = 3;
|
||||
|
||||
/**
|
||||
* The type of a message that can be passed to a {@link MediaCodec}-based video {@link Renderer}
|
||||
* via {@link ExoPlayer#createMessage(Target)}. The message payload should be one of the integer
|
||||
* scaling modes in {@link C.VideoScalingMode}.
|
||||
*
|
||||
* <p>Note that the scaling mode only applies if the {@link Surface} targeted by the renderer is
|
||||
* owned by a {@link android.view.SurfaceView}.
|
||||
*/
|
||||
public static final int MSG_SET_SCALING_MODE = 4;
|
||||
/** @deprecated Use {@code Renderer.MSG_SET_SCALING_MODE}. */
|
||||
@Deprecated public static final int MSG_SET_SCALING_MODE = 4;
|
||||
|
||||
/**
|
||||
* A type of a message that can be passed to an audio {@link Renderer} via {@link
|
||||
* ExoPlayer#createMessage(Target)}. The message payload should be an {@link AuxEffectInfo}
|
||||
* instance representing an auxiliary audio effect for the underlying audio track.
|
||||
*/
|
||||
public static final int MSG_SET_AUX_EFFECT_INFO = 5;
|
||||
/** @deprecated Use {@code Renderer.MSG_SET_AUX_EFFECT_INFO}. */
|
||||
@Deprecated public static final int MSG_SET_AUX_EFFECT_INFO = 5;
|
||||
|
||||
/**
|
||||
* The type of a message that can be passed to a video {@link Renderer} via {@link
|
||||
* ExoPlayer#createMessage(Target)}. The message payload should be a {@link
|
||||
* VideoFrameMetadataListener} instance, or null.
|
||||
*/
|
||||
public static final int MSG_SET_VIDEO_FRAME_METADATA_LISTENER = 6;
|
||||
/** @deprecated Use {@code Renderer.MSG_SET_VIDEO_FRAME_METADATA_LISTENER}. */
|
||||
@Deprecated public static final int MSG_SET_VIDEO_FRAME_METADATA_LISTENER = 6;
|
||||
|
||||
/**
|
||||
* The type of a message that can be passed to a camera motion {@link Renderer} via {@link
|
||||
* ExoPlayer#createMessage(Target)}. The message payload should be a {@link CameraMotionListener}
|
||||
* instance, or null.
|
||||
*/
|
||||
public static final int MSG_SET_CAMERA_MOTION_LISTENER = 7;
|
||||
/** @deprecated Use {@code Renderer.MSG_SET_CAMERA_MOTION_LISTENER}. */
|
||||
@Deprecated public static final int MSG_SET_CAMERA_MOTION_LISTENER = 7;
|
||||
|
||||
/**
|
||||
* The type of a message that can be passed to a {@link SimpleDecoderVideoRenderer} via {@link
|
||||
* ExoPlayer#createMessage(Target)}. The message payload should be the target {@link
|
||||
* VideoDecoderOutputBufferRenderer}, or null.
|
||||
*
|
||||
* <p>This message is intended only for use with extension renderers that expect a {@link
|
||||
* VideoDecoderOutputBufferRenderer}. For other use cases, an output surface should be passed via
|
||||
* {@link #MSG_SET_SURFACE} instead.
|
||||
*/
|
||||
public static final int MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER = 8;
|
||||
/** @deprecated Use {@code Renderer.MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER}. */
|
||||
@Deprecated public static final int MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER = 8;
|
||||
|
||||
/**
|
||||
* Applications or extensions may define custom {@code MSG_*} constants that can be passed to
|
||||
* {@link Renderer}s. These custom constants must be greater than or equal to this value.
|
||||
*/
|
||||
public static final int MSG_CUSTOM_BASE = 10000;
|
||||
/** @deprecated Use {@code Renderer.MSG_CUSTOM_BASE}. */
|
||||
@Deprecated public static final int MSG_CUSTOM_BASE = 10000;
|
||||
|
||||
/**
|
||||
* The stereo mode for 360/3D/VR videos. One of {@link Format#NO_VALUE}, {@link
|
||||
|
|
|
|||
|
|
@ -15,10 +15,19 @@
|
|||
*/
|
||||
package com.google.android.exoplayer2;
|
||||
|
||||
import android.media.MediaCodec;
|
||||
import android.view.Surface;
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.PlayerMessage.Target;
|
||||
import com.google.android.exoplayer2.audio.AuxEffectInfo;
|
||||
import com.google.android.exoplayer2.source.SampleStream;
|
||||
import com.google.android.exoplayer2.util.MediaClock;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import com.google.android.exoplayer2.video.SimpleDecoderVideoRenderer;
|
||||
import com.google.android.exoplayer2.video.VideoDecoderOutputBufferRenderer;
|
||||
import com.google.android.exoplayer2.video.VideoFrameMetadataListener;
|
||||
import com.google.android.exoplayer2.video.spherical.CameraMotionListener;
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
|
|
@ -37,6 +46,111 @@ import java.lang.annotation.RetentionPolicy;
|
|||
*/
|
||||
public interface Renderer extends PlayerMessage.Target {
|
||||
|
||||
/**
|
||||
* The type of a message that can be passed to a video renderer via {@link
|
||||
* ExoPlayer#createMessage(Target)}. The message payload should be the target {@link Surface}, or
|
||||
* null.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
int MSG_SET_SURFACE = C.MSG_SET_SURFACE;
|
||||
/**
|
||||
* A type of a message that can be passed to an audio renderer via {@link
|
||||
* ExoPlayer#createMessage(Target)}. The message payload should be a {@link Float} with 0 being
|
||||
* silence and 1 being unity gain.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
int MSG_SET_VOLUME = C.MSG_SET_VOLUME;
|
||||
/**
|
||||
* A type of a message that can be passed to an audio renderer via {@link
|
||||
* ExoPlayer#createMessage(Target)}. The message payload should be an {@link
|
||||
* com.google.android.exoplayer2.audio.AudioAttributes} instance that will configure the
|
||||
* underlying audio track. If not set, the default audio attributes will be used. They are
|
||||
* suitable for general media playback.
|
||||
*
|
||||
* <p>Setting the audio attributes during playback may introduce a short gap in audio output as
|
||||
* the audio track is recreated. A new audio session id will also be generated.
|
||||
*
|
||||
* <p>If tunneling is enabled by the track selector, the specified audio attributes will be
|
||||
* ignored, but they will take effect if audio is later played without tunneling.
|
||||
*
|
||||
* <p>If the device is running a build before platform API version 21, audio attributes cannot be
|
||||
* set directly on the underlying audio track. In this case, the usage will be mapped onto an
|
||||
* equivalent stream type using {@link Util#getStreamTypeForAudioUsage(int)}.
|
||||
*
|
||||
* <p>To get audio attributes that are equivalent to a legacy stream type, pass the stream type to
|
||||
* {@link Util#getAudioUsageForStreamType(int)} and use the returned {@link C.AudioUsage} to build
|
||||
* an audio attributes instance.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
int MSG_SET_AUDIO_ATTRIBUTES = C.MSG_SET_AUDIO_ATTRIBUTES;
|
||||
/**
|
||||
* The type of a message that can be passed to a {@link MediaCodec}-based video renderer via
|
||||
* {@link ExoPlayer#createMessage(Target)}. The message payload should be one of the integer
|
||||
* scaling modes in {@link VideoScalingMode}.
|
||||
*
|
||||
* <p>Note that the scaling mode only applies if the {@link Surface} targeted by the renderer is
|
||||
* owned by a {@link android.view.SurfaceView}.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
int MSG_SET_SCALING_MODE = C.MSG_SET_SCALING_MODE;
|
||||
/**
|
||||
* A type of a message that can be passed to an audio renderer via {@link
|
||||
* ExoPlayer#createMessage(Target)}. The message payload should be an {@link AuxEffectInfo}
|
||||
* instance representing an auxiliary audio effect for the underlying audio track.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
int MSG_SET_AUX_EFFECT_INFO = C.MSG_SET_AUX_EFFECT_INFO;
|
||||
/**
|
||||
* The type of a message that can be passed to a video renderer via {@link
|
||||
* ExoPlayer#createMessage(Target)}. The message payload should be a {@link
|
||||
* VideoFrameMetadataListener} instance, or null.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
int MSG_SET_VIDEO_FRAME_METADATA_LISTENER = C.MSG_SET_VIDEO_FRAME_METADATA_LISTENER;
|
||||
/**
|
||||
* The type of a message that can be passed to a camera motion renderer via {@link
|
||||
* ExoPlayer#createMessage(Target)}. The message payload should be a {@link CameraMotionListener}
|
||||
* instance, or null.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
int MSG_SET_CAMERA_MOTION_LISTENER = C.MSG_SET_CAMERA_MOTION_LISTENER;
|
||||
/**
|
||||
* The type of a message that can be passed to a {@link SimpleDecoderVideoRenderer} via {@link
|
||||
* ExoPlayer#createMessage(Target)}. The message payload should be the target {@link
|
||||
* VideoDecoderOutputBufferRenderer}, or null.
|
||||
*
|
||||
* <p>This message is intended only for use with extension renderers that expect a {@link
|
||||
* VideoDecoderOutputBufferRenderer}. For other use cases, an output surface should be passed via
|
||||
* {@link #MSG_SET_SURFACE} instead.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
int MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER = C.MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER;
|
||||
/**
|
||||
* Applications or extensions may define custom {@code MSG_*} constants that can be passed to
|
||||
* renderers. These custom constants must be greater than or equal to this value.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
int MSG_CUSTOM_BASE = C.MSG_CUSTOM_BASE;
|
||||
|
||||
/**
|
||||
* Video scaling modes for {@link MediaCodec}-based renderers. One of {@link
|
||||
* #VIDEO_SCALING_MODE_SCALE_TO_FIT} or {@link #VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING}.
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef(value = {VIDEO_SCALING_MODE_SCALE_TO_FIT, VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING})
|
||||
@interface VideoScalingMode {}
|
||||
/** See {@link MediaCodec#VIDEO_SCALING_MODE_SCALE_TO_FIT}. */
|
||||
@SuppressWarnings("deprecation")
|
||||
int VIDEO_SCALING_MODE_SCALE_TO_FIT = C.VIDEO_SCALING_MODE_SCALE_TO_FIT;
|
||||
/** See {@link MediaCodec#VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING}. */
|
||||
@SuppressWarnings("deprecation")
|
||||
int VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING =
|
||||
C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING;
|
||||
/** A default video scaling mode for {@link MediaCodec}-based renderers. */
|
||||
@SuppressWarnings("deprecation")
|
||||
int VIDEO_SCALING_MODE_DEFAULT = C.VIDEO_SCALING_MODE_DEFAULT;
|
||||
|
||||
/**
|
||||
* The renderer states. One of {@link #STATE_DISABLED}, {@link #STATE_ENABLED} or {@link
|
||||
* #STATE_STARTED}.
|
||||
|
|
@ -64,9 +178,9 @@ public interface Renderer extends PlayerMessage.Target {
|
|||
int STATE_STARTED = 2;
|
||||
|
||||
/**
|
||||
* Returns the track type that the {@link Renderer} handles. For example, a video renderer will
|
||||
* return {@link C#TRACK_TYPE_VIDEO}, an audio renderer will return {@link C#TRACK_TYPE_AUDIO}, a
|
||||
* text renderer will return {@link C#TRACK_TYPE_TEXT}, and so on.
|
||||
* Returns the track type that the renderer handles. For example, a video renderer will return
|
||||
* {@link C#TRACK_TYPE_VIDEO}, an audio renderer will return {@link C#TRACK_TYPE_AUDIO}, a text
|
||||
* renderer will return {@link C#TRACK_TYPE_TEXT}, and so on.
|
||||
*
|
||||
* @return One of the {@code TRACK_TYPE_*} constants defined in {@link C}.
|
||||
*/
|
||||
|
|
@ -266,12 +380,12 @@ public interface Renderer extends PlayerMessage.Target {
|
|||
boolean isReady();
|
||||
|
||||
/**
|
||||
* Whether the renderer is ready for the {@link ExoPlayer} instance to transition to
|
||||
* {@link Player#STATE_ENDED}. The player will make this transition as soon as {@code true} is
|
||||
* returned by all of its {@link Renderer}s.
|
||||
* <p>
|
||||
* This method may be called when the renderer is in the following states:
|
||||
* {@link #STATE_ENABLED}, {@link #STATE_STARTED}.
|
||||
* Whether the renderer is ready for the {@link ExoPlayer} instance to transition to {@link
|
||||
* Player#STATE_ENDED}. The player will make this transition as soon as {@code true} is returned
|
||||
* by all of its renderers.
|
||||
*
|
||||
* <p>This method may be called when the renderer is in the following states: {@link
|
||||
* #STATE_ENABLED}, {@link #STATE_STARTED}.
|
||||
*
|
||||
* @return Whether the renderer is ready for the player to transition to the ended state.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -434,7 +434,7 @@ public class SimpleExoPlayer extends BasePlayer
|
|||
audioVolume = 1;
|
||||
audioSessionId = C.AUDIO_SESSION_ID_UNSET;
|
||||
audioAttributes = AudioAttributes.DEFAULT;
|
||||
videoScalingMode = C.VIDEO_SCALING_MODE_DEFAULT;
|
||||
videoScalingMode = Renderer.VIDEO_SCALING_MODE_DEFAULT;
|
||||
currentCues = Collections.emptyList();
|
||||
|
||||
// Build the player and associated objects.
|
||||
|
|
@ -506,7 +506,7 @@ public class SimpleExoPlayer extends BasePlayer
|
|||
if (renderer.getTrackType() == C.TRACK_TYPE_VIDEO) {
|
||||
player
|
||||
.createMessage(renderer)
|
||||
.setType(C.MSG_SET_SCALING_MODE)
|
||||
.setType(Renderer.MSG_SET_SCALING_MODE)
|
||||
.setPayload(videoScalingMode)
|
||||
.send();
|
||||
}
|
||||
|
|
@ -678,7 +678,7 @@ public class SimpleExoPlayer extends BasePlayer
|
|||
if (renderer.getTrackType() == C.TRACK_TYPE_AUDIO) {
|
||||
player
|
||||
.createMessage(renderer)
|
||||
.setType(C.MSG_SET_AUDIO_ATTRIBUTES)
|
||||
.setType(Renderer.MSG_SET_AUDIO_ATTRIBUTES)
|
||||
.setPayload(audioAttributes)
|
||||
.send();
|
||||
}
|
||||
|
|
@ -712,7 +712,7 @@ public class SimpleExoPlayer extends BasePlayer
|
|||
if (renderer.getTrackType() == C.TRACK_TYPE_AUDIO) {
|
||||
player
|
||||
.createMessage(renderer)
|
||||
.setType(C.MSG_SET_AUX_EFFECT_INFO)
|
||||
.setType(Renderer.MSG_SET_AUX_EFFECT_INFO)
|
||||
.setPayload(auxEffectInfo)
|
||||
.send();
|
||||
}
|
||||
|
|
@ -904,7 +904,7 @@ public class SimpleExoPlayer extends BasePlayer
|
|||
if (renderer.getTrackType() == C.TRACK_TYPE_VIDEO) {
|
||||
player
|
||||
.createMessage(renderer)
|
||||
.setType(C.MSG_SET_VIDEO_FRAME_METADATA_LISTENER)
|
||||
.setType(Renderer.MSG_SET_VIDEO_FRAME_METADATA_LISTENER)
|
||||
.setPayload(listener)
|
||||
.send();
|
||||
}
|
||||
|
|
@ -921,7 +921,7 @@ public class SimpleExoPlayer extends BasePlayer
|
|||
if (renderer.getTrackType() == C.TRACK_TYPE_VIDEO) {
|
||||
player
|
||||
.createMessage(renderer)
|
||||
.setType(C.MSG_SET_VIDEO_FRAME_METADATA_LISTENER)
|
||||
.setType(Renderer.MSG_SET_VIDEO_FRAME_METADATA_LISTENER)
|
||||
.setPayload(null)
|
||||
.send();
|
||||
}
|
||||
|
|
@ -936,7 +936,7 @@ public class SimpleExoPlayer extends BasePlayer
|
|||
if (renderer.getTrackType() == C.TRACK_TYPE_CAMERA_MOTION) {
|
||||
player
|
||||
.createMessage(renderer)
|
||||
.setType(C.MSG_SET_CAMERA_MOTION_LISTENER)
|
||||
.setType(Renderer.MSG_SET_CAMERA_MOTION_LISTENER)
|
||||
.setPayload(listener)
|
||||
.send();
|
||||
}
|
||||
|
|
@ -953,7 +953,7 @@ public class SimpleExoPlayer extends BasePlayer
|
|||
if (renderer.getTrackType() == C.TRACK_TYPE_CAMERA_MOTION) {
|
||||
player
|
||||
.createMessage(renderer)
|
||||
.setType(C.MSG_SET_CAMERA_MOTION_LISTENER)
|
||||
.setType(Renderer.MSG_SET_CAMERA_MOTION_LISTENER)
|
||||
.setPayload(null)
|
||||
.send();
|
||||
}
|
||||
|
|
@ -1571,7 +1571,11 @@ public class SimpleExoPlayer extends BasePlayer
|
|||
for (Renderer renderer : renderers) {
|
||||
if (renderer.getTrackType() == C.TRACK_TYPE_VIDEO) {
|
||||
messages.add(
|
||||
player.createMessage(renderer).setType(C.MSG_SET_SURFACE).setPayload(surface).send());
|
||||
player
|
||||
.createMessage(renderer)
|
||||
.setType(Renderer.MSG_SET_SURFACE)
|
||||
.setPayload(surface)
|
||||
.send());
|
||||
}
|
||||
}
|
||||
if (this.surface != null && this.surface != surface) {
|
||||
|
|
@ -1598,7 +1602,7 @@ public class SimpleExoPlayer extends BasePlayer
|
|||
if (renderer.getTrackType() == C.TRACK_TYPE_VIDEO) {
|
||||
player
|
||||
.createMessage(renderer)
|
||||
.setType(C.MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER)
|
||||
.setType(Renderer.MSG_SET_VIDEO_DECODER_OUTPUT_BUFFER_RENDERER)
|
||||
.setPayload(videoDecoderOutputBufferRenderer)
|
||||
.send();
|
||||
}
|
||||
|
|
@ -1620,7 +1624,11 @@ public class SimpleExoPlayer extends BasePlayer
|
|||
float scaledVolume = audioVolume * audioFocusManager.getVolumeMultiplier();
|
||||
for (Renderer renderer : renderers) {
|
||||
if (renderer.getTrackType() == C.TRACK_TYPE_AUDIO) {
|
||||
player.createMessage(renderer).setType(C.MSG_SET_VOLUME).setPayload(scaledVolume).send();
|
||||
player
|
||||
.createMessage(renderer)
|
||||
.setType(Renderer.MSG_SET_VOLUME)
|
||||
.setPayload(scaledVolume)
|
||||
.send();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,14 +59,14 @@ import java.util.List;
|
|||
* on the playback thread:
|
||||
*
|
||||
* <ul>
|
||||
* <li>Message with type {@link C#MSG_SET_VOLUME} to set the volume. The message payload should be
|
||||
* <li>Message with type {@link #MSG_SET_VOLUME} to set the volume. The message payload should be
|
||||
* a {@link Float} with 0 being silence and 1 being unity gain.
|
||||
* <li>Message with type {@link C#MSG_SET_AUDIO_ATTRIBUTES} to set the audio attributes. The
|
||||
* <li>Message with type {@link #MSG_SET_AUDIO_ATTRIBUTES} to set the audio attributes. The
|
||||
* message payload should be an {@link com.google.android.exoplayer2.audio.AudioAttributes}
|
||||
* instance that will configure the underlying audio track.
|
||||
* <li>Message with type {@link C#MSG_SET_AUX_EFFECT_INFO} to set the auxiliary effect. The
|
||||
* message payload should be an {@link AuxEffectInfo} instance that will configure the
|
||||
* underlying audio track.
|
||||
* <li>Message with type {@link #MSG_SET_AUX_EFFECT_INFO} to set the auxiliary effect. The message
|
||||
* payload should be an {@link AuxEffectInfo} instance that will configure the underlying
|
||||
* audio track.
|
||||
* </ul>
|
||||
*/
|
||||
public class MediaCodecAudioRenderer extends MediaCodecRenderer implements MediaClock {
|
||||
|
|
@ -846,14 +846,14 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
|||
@Override
|
||||
public void handleMessage(int messageType, @Nullable Object message) throws ExoPlaybackException {
|
||||
switch (messageType) {
|
||||
case C.MSG_SET_VOLUME:
|
||||
case MSG_SET_VOLUME:
|
||||
audioSink.setVolume((Float) message);
|
||||
break;
|
||||
case C.MSG_SET_AUDIO_ATTRIBUTES:
|
||||
case MSG_SET_AUDIO_ATTRIBUTES:
|
||||
AudioAttributes audioAttributes = (AudioAttributes) message;
|
||||
audioSink.setAudioAttributes(audioAttributes);
|
||||
break;
|
||||
case C.MSG_SET_AUX_EFFECT_INFO:
|
||||
case MSG_SET_AUX_EFFECT_INFO:
|
||||
AuxEffectInfo auxEffectInfo = (AuxEffectInfo) message;
|
||||
audioSink.setAuxEffectInfo(auxEffectInfo);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -54,14 +54,14 @@ import java.lang.annotation.RetentionPolicy;
|
|||
* on the playback thread:
|
||||
*
|
||||
* <ul>
|
||||
* <li>Message with type {@link C#MSG_SET_VOLUME} to set the volume. The message payload should be
|
||||
* <li>Message with type {@link #MSG_SET_VOLUME} to set the volume. The message payload should be
|
||||
* a {@link Float} with 0 being silence and 1 being unity gain.
|
||||
* <li>Message with type {@link C#MSG_SET_AUDIO_ATTRIBUTES} to set the audio attributes. The
|
||||
* <li>Message with type {@link #MSG_SET_AUDIO_ATTRIBUTES} to set the audio attributes. The
|
||||
* message payload should be an {@link com.google.android.exoplayer2.audio.AudioAttributes}
|
||||
* instance that will configure the underlying audio track.
|
||||
* <li>Message with type {@link C#MSG_SET_AUX_EFFECT_INFO} to set the auxiliary effect. The
|
||||
* message payload should be an {@link AuxEffectInfo} instance that will configure the
|
||||
* underlying audio track.
|
||||
* <li>Message with type {@link #MSG_SET_AUX_EFFECT_INFO} to set the auxiliary effect. The message
|
||||
* payload should be an {@link AuxEffectInfo} instance that will configure the underlying
|
||||
* audio track.
|
||||
* </ul>
|
||||
*/
|
||||
public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements MediaClock {
|
||||
|
|
@ -594,14 +594,14 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements
|
|||
@Override
|
||||
public void handleMessage(int messageType, @Nullable Object message) throws ExoPlaybackException {
|
||||
switch (messageType) {
|
||||
case C.MSG_SET_VOLUME:
|
||||
case MSG_SET_VOLUME:
|
||||
audioSink.setVolume((Float) message);
|
||||
break;
|
||||
case C.MSG_SET_AUDIO_ATTRIBUTES:
|
||||
case MSG_SET_AUDIO_ATTRIBUTES:
|
||||
AudioAttributes audioAttributes = (AudioAttributes) message;
|
||||
audioSink.setAudioAttributes(audioAttributes);
|
||||
break;
|
||||
case C.MSG_SET_AUX_EFFECT_INFO:
|
||||
case MSG_SET_AUX_EFFECT_INFO:
|
||||
AuxEffectInfo auxEffectInfo = (AuxEffectInfo) message;
|
||||
audioSink.setAuxEffectInfo(auxEffectInfo);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -67,10 +67,10 @@ import java.util.List;
|
|||
* on the playback thread:
|
||||
*
|
||||
* <ul>
|
||||
* <li>Message with type {@link C#MSG_SET_SURFACE} to set the output surface. The message payload
|
||||
* <li>Message with type {@link #MSG_SET_SURFACE} to set the output surface. The message payload
|
||||
* should be the target {@link Surface}, or null.
|
||||
* <li>Message with type {@link C#MSG_SET_SCALING_MODE} to set the video scaling mode. The message
|
||||
* payload should be one of the integer scaling modes in {@link C.VideoScalingMode}. Note that
|
||||
* <li>Message with type {@link #MSG_SET_SCALING_MODE} to set the video scaling mode. The message
|
||||
* payload should be one of the integer scaling modes in {@link VideoScalingMode}. Note that
|
||||
* the scaling mode only applies if the {@link Surface} targeted by this renderer is owned by
|
||||
* a {@link android.view.SurfaceView}.
|
||||
* </ul>
|
||||
|
|
@ -134,8 +134,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
|||
|
||||
private Surface surface;
|
||||
private Surface dummySurface;
|
||||
@C.VideoScalingMode
|
||||
private int scalingMode;
|
||||
@VideoScalingMode private int scalingMode;
|
||||
private boolean renderedFirstFrame;
|
||||
private long initialPositionUs;
|
||||
private long joiningDeadlineMs;
|
||||
|
|
@ -357,7 +356,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
|||
currentHeight = Format.NO_VALUE;
|
||||
currentPixelWidthHeightRatio = Format.NO_VALUE;
|
||||
pendingPixelWidthHeightRatio = Format.NO_VALUE;
|
||||
scalingMode = C.VIDEO_SCALING_MODE_DEFAULT;
|
||||
scalingMode = VIDEO_SCALING_MODE_DEFAULT;
|
||||
clearReportedVideoSize();
|
||||
}
|
||||
|
||||
|
|
@ -589,15 +588,15 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
|||
|
||||
@Override
|
||||
public void handleMessage(int messageType, @Nullable Object message) throws ExoPlaybackException {
|
||||
if (messageType == C.MSG_SET_SURFACE) {
|
||||
if (messageType == MSG_SET_SURFACE) {
|
||||
setSurface((Surface) message);
|
||||
} else if (messageType == C.MSG_SET_SCALING_MODE) {
|
||||
} else if (messageType == MSG_SET_SCALING_MODE) {
|
||||
scalingMode = (Integer) message;
|
||||
MediaCodec codec = getCodec();
|
||||
if (codec != null) {
|
||||
codec.setVideoScalingMode(scalingMode);
|
||||
}
|
||||
} else if (messageType == C.MSG_SET_VIDEO_FRAME_METADATA_LISTENER) {
|
||||
} else if (messageType == MSG_SET_VIDEO_FRAME_METADATA_LISTENER) {
|
||||
frameMetadataListener = (VideoFrameMetadataListener) message;
|
||||
} else {
|
||||
super.handleMessage(messageType, message);
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class CameraMotionRenderer extends BaseRenderer {
|
|||
|
||||
@Override
|
||||
public void handleMessage(int messageType, @Nullable Object message) throws ExoPlaybackException {
|
||||
if (messageType == C.MSG_SET_CAMERA_MOTION_LISTENER) {
|
||||
if (messageType == MSG_SET_CAMERA_MOTION_LISTENER) {
|
||||
listener = (CameraMotionListener) message;
|
||||
} else {
|
||||
super.handleMessage(messageType, message);
|
||||
|
|
|
|||
Loading…
Reference in a new issue