mirror of
https://github.com/samsonjs/media.git
synced 2026-04-05 11:15:46 +00:00
Use @linkplain for link text that doesn't match symbol name.
PiperOrigin-RevId: 437992927
This commit is contained in:
parent
479e8ea36e
commit
990d5ccf4d
17 changed files with 132 additions and 126 deletions
|
|
@ -27,10 +27,11 @@ import java.io.IOException;
|
|||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
|
||||
/**
|
||||
* Applies a transformation matrix in the vertex shader. Operations are done on normalized device
|
||||
* coordinates (-1 to 1 on x and y axes). No automatic adjustments (like done in {@link
|
||||
* ScaleToFitFrameProcessor}) are applied on the transformation. Width and height are not modified.
|
||||
* The background color will default to black.
|
||||
* Applies a transformation matrix in the vertex shader.
|
||||
*
|
||||
* <p>Operations are done on normalized device coordinates (-1 to 1 on x and y axes). No automatic
|
||||
* adjustments (like done in {@link ScaleToFitFrameProcessor}) are applied on the transformation.
|
||||
* Width and height are not modified. The background color will default to black.
|
||||
*/
|
||||
public final class AdvancedFrameProcessor implements GlFrameProcessor {
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import java.util.List;
|
|||
*/
|
||||
public interface Codec {
|
||||
|
||||
/** A factory for {@link Codec decoder} instances. */
|
||||
/** A factory for {@linkplain Codec decoder} instances. */
|
||||
interface DecoderFactory {
|
||||
|
||||
/** A default {@code DecoderFactory} implementation. */
|
||||
|
|
@ -65,7 +65,7 @@ public interface Codec {
|
|||
throws TransformationException;
|
||||
}
|
||||
|
||||
/** A factory for {@link Codec encoder} instances. */
|
||||
/** A factory for {@linkplain Codec encoder} instances. */
|
||||
interface EncoderFactory {
|
||||
|
||||
/** A default {@code EncoderFactory} implementation. */
|
||||
|
|
@ -75,13 +75,13 @@ public interface Codec {
|
|||
* Returns a {@link Codec} for audio encoding.
|
||||
*
|
||||
* <p>This method must validate that the {@link Codec} is configured to produce one of the
|
||||
* {@code allowedMimeTypes}. The {@link Format#sampleMimeType sample MIME type} given in {@code
|
||||
* format} is not necessarily allowed.
|
||||
* {@code allowedMimeTypes}. The {@linkplain Format#sampleMimeType sample MIME type} given in
|
||||
* {@code format} is not necessarily allowed.
|
||||
*
|
||||
* @param format The {@link Format} (of the output data) used to determine the underlying
|
||||
* encoder and its configuration values.
|
||||
* @param allowedMimeTypes The non-empty list of allowed output sample {@link MimeTypes MIME
|
||||
* types}.
|
||||
* @param allowedMimeTypes The non-empty list of allowed output sample {@linkplain MimeTypes
|
||||
* MIME types}.
|
||||
* @return A {@link Codec} for audio encoding.
|
||||
* @throws TransformationException If no suitable {@link Codec} can be created.
|
||||
*/
|
||||
|
|
@ -92,8 +92,8 @@ public interface Codec {
|
|||
* Returns a {@link Codec} for video encoding.
|
||||
*
|
||||
* <p>This method must validate that the {@link Codec} is configured to produce one of the
|
||||
* {@code allowedMimeTypes}. The {@link Format#sampleMimeType sample MIME type} given in {@code
|
||||
* format} is not necessarily allowed.
|
||||
* {@code allowedMimeTypes}. The {@linkplain Format#sampleMimeType sample MIME type} given in
|
||||
* {@code format} is not necessarily allowed.
|
||||
*
|
||||
* @param format The {@link Format} (of the output data) used to determine the underlying
|
||||
* encoder and its configuration values. {@link Format#sampleMimeType}, {@link Format#width}
|
||||
|
|
@ -101,8 +101,8 @@ public interface Codec {
|
|||
* Format#rotationDegrees} is 0 and {@link Format#width} {@code >=} {@link Format#height},
|
||||
* therefore the video is always in landscape orientation. {@link Format#frameRate} is set
|
||||
* to the output video's frame rate, if available.
|
||||
* @param allowedMimeTypes The non-empty list of allowed output sample {@link MimeTypes MIME
|
||||
* types}.
|
||||
* @param allowedMimeTypes The non-empty list of allowed output sample {@linkplain MimeTypes
|
||||
* MIME types}.
|
||||
* @return A {@link Codec} for video encoding.
|
||||
* @throws TransformationException If no suitable {@link Codec} can be created.
|
||||
*/
|
||||
|
|
@ -140,8 +140,8 @@ public interface Codec {
|
|||
/**
|
||||
* Dequeues a writable input buffer, if available.
|
||||
*
|
||||
* <p>This method must not be called from video encoders because they must use {@link Surface
|
||||
* surfaces} as inputs.
|
||||
* <p>This method must not be called from video encoders because they must use a {@link Surface}
|
||||
* to receive input.
|
||||
*
|
||||
* @param inputBuffer The buffer where the dequeued buffer data is stored, at {@link
|
||||
* DecoderInputBuffer#data inputBuffer.data}.
|
||||
|
|
@ -151,13 +151,13 @@ public interface Codec {
|
|||
boolean maybeDequeueInputBuffer(DecoderInputBuffer inputBuffer) throws TransformationException;
|
||||
|
||||
/**
|
||||
* Queues an input buffer to the {@code Codec}. No buffers may be queued after {@link
|
||||
* Queues an input buffer to the {@code Codec}. No buffers may be queued after {@linkplain
|
||||
* DecoderInputBuffer#isEndOfStream() end of stream} buffer has been queued.
|
||||
*
|
||||
* <p>This method must not be called from video encoders because they must use {@link Surface
|
||||
* surfaces} as inputs.
|
||||
* <p>This method must not be called from video encoders because they must use a {@link Surface}
|
||||
* to receive input.
|
||||
*
|
||||
* @param inputBuffer The {@link DecoderInputBuffer input buffer}.
|
||||
* @param inputBuffer The {@linkplain DecoderInputBuffer input buffer}.
|
||||
* @throws TransformationException If the underlying decoder or encoder encounters a problem.
|
||||
*/
|
||||
void queueInputBuffer(DecoderInputBuffer inputBuffer) throws TransformationException;
|
||||
|
|
@ -167,7 +167,8 @@ public interface Codec {
|
|||
*
|
||||
* <p>This method must only be called on video encoders because they must use a {@link Surface} as
|
||||
* input. For audio/video decoders or audio encoders, the {@link C#BUFFER_FLAG_END_OF_STREAM} flag
|
||||
* should be set on the last input buffer {@link #queueInputBuffer(DecoderInputBuffer) queued}.
|
||||
* should be set on the last input buffer {@linkplain #queueInputBuffer(DecoderInputBuffer)
|
||||
* queued}.
|
||||
*
|
||||
* @throws TransformationException If the underlying video encoder encounters a problem.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -197,9 +197,9 @@ public final class DefaultEncoderFactory implements Codec.EncoderFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* Finds an {@link MediaCodecInfo encoder} that supports the requested format most closely.
|
||||
* Finds an {@linkplain MediaCodecInfo encoder} that supports the requested format most closely.
|
||||
*
|
||||
* <p>Returns the {@link MediaCodecInfo encoder} and the supported {@link Format} in a {@link
|
||||
* <p>Returns the {@linkplain MediaCodecInfo encoder} and the supported {@link Format} in a {@link
|
||||
* Pair}, or {@code null} if none is found.
|
||||
*/
|
||||
@RequiresNonNull("#1.sampleMimeType")
|
||||
|
|
@ -400,22 +400,22 @@ public final class DefaultEncoderFactory implements Codec.EncoderFactory {
|
|||
private interface EncoderFallbackCost {
|
||||
/**
|
||||
* Returns a cost that represents the gap between the requested encoding parameter(s) and the
|
||||
* {@link MediaCodecInfo encoder}'s support for them.
|
||||
* {@linkplain MediaCodecInfo encoder}'s support for them.
|
||||
*
|
||||
* <p>The method must return {@link Integer#MAX_VALUE} when the {@link MediaCodecInfo encoder}
|
||||
* does not support the encoding parameters.
|
||||
* <p>The method must return {@link Integer#MAX_VALUE} when the {@linkplain MediaCodecInfo
|
||||
* encoder} does not support the encoding parameters.
|
||||
*/
|
||||
int getParameterSupportGap(MediaCodecInfo encoderInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters a list of {@link MediaCodecInfo encoders} by a {@link EncoderFallbackCost cost
|
||||
* function}.
|
||||
* Filters a list of {@linkplain MediaCodecInfo encoders} by a {@linkplain EncoderFallbackCost
|
||||
* cost function}.
|
||||
*
|
||||
* @param encoders A list of {@link MediaCodecInfo encoders}.
|
||||
* @param cost A {@link EncoderFallbackCost cost function}.
|
||||
* @return A list of {@link MediaCodecInfo encoders} with the lowest costs, empty if the costs of
|
||||
* all encoders are {@link Integer#MAX_VALUE}.
|
||||
* @param encoders A list of {@linkplain MediaCodecInfo encoders}.
|
||||
* @param cost A {@linkplain EncoderFallbackCost cost function}.
|
||||
* @return A list of {@linkplain MediaCodecInfo encoders} with the lowest costs, empty if the
|
||||
* costs of all encoders are {@link Integer#MAX_VALUE}.
|
||||
*/
|
||||
private static ImmutableList<MediaCodecInfo> filterEncoders(
|
||||
List<MediaCodecInfo> encoders, EncoderFallbackCost cost, String filterName) {
|
||||
|
|
@ -452,7 +452,7 @@ public final class DefaultEncoderFactory implements Codec.EncoderFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* Finds a {@link MimeTypes MIME type} that is supported by the encoder and in the {@code
|
||||
* Finds a {@linkplain MimeTypes MIME type} that is supported by the encoder and in the {@code
|
||||
* allowedMimeTypes}.
|
||||
*/
|
||||
@Nullable
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ public interface EncoderSelector {
|
|||
* Returns a list of encoders that can encode media in the specified {@code mimeType}, in priority
|
||||
* order.
|
||||
*
|
||||
* @param mimeType The {@link MimeTypes MIME type} for which an encoder is required.
|
||||
* @return An unmodifiable list of {@link MediaCodecInfo encoders} that supports the {@code
|
||||
* @param mimeType The {@linkplain MimeTypes MIME type} for which an encoder is required.
|
||||
* @return An unmodifiable list of {@linkplain MediaCodecInfo encoders} that support the {@code
|
||||
* mimeType}. The list may be empty.
|
||||
*/
|
||||
List<MediaCodecInfo> selectEncoderInfos(String mimeType);
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ public final class EncoderUtil {
|
|||
private static final List<MediaCodecInfo> encoders = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Returns a list of {@link MediaCodecInfo encoders} that support the given {@code mimeType}, or
|
||||
* an empty list if there is none.
|
||||
* Returns a list of {@linkplain MediaCodecInfo encoders} that support the given {@code mimeType},
|
||||
* or an empty list if there is none.
|
||||
*/
|
||||
public static ImmutableList<MediaCodecInfo> getSupportedEncoders(String mimeType) {
|
||||
maybePopulateEncoderInfos();
|
||||
|
|
@ -65,22 +65,22 @@ public final class EncoderUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Finds a {@link MediaCodecInfo encoder}'s supported resolution from a given resolution.
|
||||
* Finds an {@linkplain MediaCodecInfo encoder}'s supported resolution from a given resolution.
|
||||
*
|
||||
* <p>The input resolution is returned, if it (after aligning to the encoders requirement) is
|
||||
* supported by the {@link MediaCodecInfo encoder}.
|
||||
* <p>The input resolution is returned, if it (after aligning to the encoder's requirement) is
|
||||
* supported by the {@linkplain MediaCodecInfo encoder}.
|
||||
*
|
||||
* <p>The resolution will be adjusted to be within the {@link MediaCodecInfo encoder}'s range of
|
||||
* supported resolutions, and will be aligned to the {@link MediaCodecInfo encoder}'s alignment
|
||||
* requirement. The adjustment process takes into account the original aspect ratio. But the fixed
|
||||
* resolution may not preserve the original aspect ratio, depending on the encoder's required size
|
||||
* alignment.
|
||||
* <p>The resolution will be adjusted to be within the {@linkplain MediaCodecInfo encoder}'s range
|
||||
* of supported resolutions, and will be aligned to the {@linkplain MediaCodecInfo encoder}'s
|
||||
* alignment requirement. The adjustment process takes into account the original aspect ratio. But
|
||||
* the fixed resolution may not preserve the original aspect ratio, depending on the encoder's
|
||||
* required size alignment.
|
||||
*
|
||||
* @param encoderInfo The {@link MediaCodecInfo} of the encoder.
|
||||
* @param mimeType The output MIME type.
|
||||
* @param width The original width.
|
||||
* @param height The original height.
|
||||
* @return A {@link Size supported resolution}, or {@code null} if unable to find a fallback.
|
||||
* @return A {@linkplain Size supported resolution}, or {@code null} if unable to find a fallback.
|
||||
*/
|
||||
@Nullable
|
||||
public static Size getSupportedResolution(
|
||||
|
|
@ -134,7 +134,7 @@ public final class EncoderUtil {
|
|||
* Finds the highest supported encoding level given a profile.
|
||||
*
|
||||
* @param encoderInfo The {@link MediaCodecInfo encoderInfo}.
|
||||
* @param mimeType The {@link MimeTypes MIME type}.
|
||||
* @param mimeType The {@linkplain MimeTypes MIME type}.
|
||||
* @param profile The encoding profile.
|
||||
* @return The highest supported encoding level, as documented in {@link
|
||||
* MediaCodecInfo.CodecProfileLevel}, or {@link #LEVEL_UNSET} if the profile is not supported.
|
||||
|
|
@ -155,8 +155,8 @@ public final class EncoderUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Finds a {@link MediaCodec codec} that supports the {@link MediaFormat}, or {@code null} if none
|
||||
* is found.
|
||||
* Finds a {@link MediaCodec} that supports the {@link MediaFormat}, or {@code null} if none is
|
||||
* found.
|
||||
*/
|
||||
@Nullable
|
||||
public static String findCodecForFormat(MediaFormat format, boolean isDecoder) {
|
||||
|
|
@ -181,7 +181,8 @@ public final class EncoderUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Finds the {@link MediaCodecInfo encoder}'s closest supported bitrate from the given bitrate.
|
||||
* Finds the {@linkplain MediaCodecInfo encoder}'s closest supported bitrate from the given
|
||||
* bitrate.
|
||||
*/
|
||||
public static int getClosestSupportedBitrate(
|
||||
MediaCodecInfo encoderInfo, String mimeType, int bitrate) {
|
||||
|
|
@ -201,7 +202,7 @@ public final class EncoderUtil {
|
|||
.isBitrateModeSupported(bitrateMode);
|
||||
}
|
||||
|
||||
/** Checks if a {@link MediaCodecInfo codec} is hardware-accelerated. */
|
||||
/** Checks if a {@linkplain MediaCodecInfo codec} is hardware-accelerated. */
|
||||
public static boolean isHardwareAccelerated(MediaCodecInfo encoderInfo, String mimeType) {
|
||||
// TODO(b/214964116): Merge into MediaCodecUtil.
|
||||
if (Util.SDK_INT >= 29) {
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||
* Sets the texture transform matrix for converting an external surface texture's coordinates to
|
||||
* sampling locations.
|
||||
*
|
||||
* @param textureTransformMatrix The external surface texture's {@link
|
||||
* @param textureTransformMatrix The external surface texture's {@linkplain
|
||||
* android.graphics.SurfaceTexture#getTransformMatrix(float[]) transform matrix}.
|
||||
*/
|
||||
public void setTextureTransformMatrix(float[] textureTransformMatrix) {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ import com.google.android.exoplayer2.util.Util;
|
|||
* Creates a new instance.
|
||||
*
|
||||
* @param mediaItem The {@link MediaItem} to transform.
|
||||
* @param transformerListeners The {@link Transformer.Listener listeners} to forward events to.
|
||||
* @param transformerListeners The {@linkplain Transformer.Listener listeners} to forward events
|
||||
* to.
|
||||
* @param originalTransformationRequest The original {@link TransformationRequest}.
|
||||
*/
|
||||
public FallbackListener(
|
||||
|
|
@ -56,7 +57,7 @@ import com.google.android.exoplayer2.util.Util;
|
|||
/**
|
||||
* Registers an output track.
|
||||
*
|
||||
* <p>All tracks must be registered before a transformation request is {@link
|
||||
* <p>All tracks must be registered before a transformation request is {@linkplain
|
||||
* #onTransformationRequestFinalized(TransformationRequest) finalized}.
|
||||
*/
|
||||
public void registerTrack() {
|
||||
|
|
|
|||
|
|
@ -52,12 +52,12 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
/**
|
||||
* {@code FrameProcessorChain} applies changes to individual video frames.
|
||||
*
|
||||
* <p>Input becomes available on its {@link #getInputSurface() input surface} asynchronously and is
|
||||
* processed on a background thread as it becomes available. All input frames should be {@link
|
||||
* #registerInputFrame() registered} before they are rendered to the input surface. {@link
|
||||
* #getPendingFrameCount()} can be used to check whether there are frames that have not been fully
|
||||
* processed yet. Output is written to its {@link #configure(Surface, int, int, SurfaceView) output
|
||||
* surface}.
|
||||
* <p>Input becomes available on its {@linkplain #getInputSurface() input surface} asynchronously
|
||||
* and is processed on a background thread as it becomes available. All input frames should be
|
||||
* {@linkplain #registerInputFrame() registered} before they are rendered to the input surface.
|
||||
* {@link #getPendingFrameCount()} can be used to check whether there are frames that have not been
|
||||
* fully processed yet. Output is written to its {@linkplain #configure(Surface, int, int,
|
||||
* SurfaceView) output surface}.
|
||||
*/
|
||||
/* package */ final class FrameProcessorChain {
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
private final ExecutorService singleThreadExecutorService;
|
||||
/** Futures corresponding to the executor service's pending tasks. */
|
||||
private final ConcurrentLinkedQueue<Future<?>> futures;
|
||||
/** Number of frames {@link #registerInputFrame() registered} but not fully processed. */
|
||||
/** Number of frames {@linkplain #registerInputFrame() registered} but not fully processed. */
|
||||
private final AtomicInteger pendingFrameCount;
|
||||
/** Prevents further frame processing tasks from being scheduled after {@link #release()}. */
|
||||
private volatile boolean releaseRequested;
|
||||
|
|
@ -186,7 +186,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
/**
|
||||
* Configures the {@code FrameProcessorChain} to process frames to the specified output targets.
|
||||
*
|
||||
* <p>This method may only be called once and may override the {@link
|
||||
* <p>This method may only be called once and may override the {@linkplain
|
||||
* GlFrameProcessor#configureOutputSize(int, int) output size} of the final {@link
|
||||
* GlFrameProcessor}.
|
||||
*
|
||||
|
|
@ -253,8 +253,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
/**
|
||||
* Returns the input {@link Surface}.
|
||||
*
|
||||
* <p>The {@code FrameProcessorChain} must be {@link #configure(Surface, int, int, SurfaceView)
|
||||
* configured}.
|
||||
* <p>The {@code FrameProcessorChain} must be {@linkplain #configure(Surface, int, int,
|
||||
* SurfaceView) configured}.
|
||||
*/
|
||||
public Surface getInputSurface() {
|
||||
checkStateNotNull(inputSurface, "The FrameProcessorChain must be configured.");
|
||||
|
|
@ -296,8 +296,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the number of input frames that have been {@link #registerInputFrame() registered} but
|
||||
* not completely processed yet.
|
||||
* Returns the number of input frames that have been {@linkplain #registerInputFrame() registered}
|
||||
* but not completely processed yet.
|
||||
*/
|
||||
public int getPendingFrameCount() {
|
||||
return pendingFrameCount.get();
|
||||
|
|
@ -316,9 +316,9 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
/**
|
||||
* Releases all resources.
|
||||
*
|
||||
* <p>If the frame processor chain is released before it has {@link #isEnded() ended}, it will
|
||||
* attempt to cancel processing any input frames that have already become available. Input frames
|
||||
* that become available after release are ignored.
|
||||
* <p>If the frame processor chain is released before it has {@linkplain #isEnded() ended}, it
|
||||
* will attempt to cancel processing any input frames that have already become available. Input
|
||||
* frames that become available after release are ignored.
|
||||
*/
|
||||
public void release() {
|
||||
releaseRequested = true;
|
||||
|
|
@ -447,7 +447,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
}
|
||||
|
||||
/**
|
||||
* Configures the input and output {@link Size sizes} of a list of {@link GlFrameProcessor
|
||||
* Configures the input and output {@linkplain Size sizes} of a list of {@link GlFrameProcessor
|
||||
* GlFrameProcessors}.
|
||||
*
|
||||
* @param inputWidth The width of frames passed to the first {@link GlFrameProcessor}, in pixels.
|
||||
|
|
|
|||
|
|
@ -221,13 +221,13 @@ import java.nio.ByteBuffer;
|
|||
}
|
||||
|
||||
/**
|
||||
* Converts a {@link MimeTypes MIME type} into a {@link MediaMuxer.OutputFormat MediaMuxer output
|
||||
* format}.
|
||||
* Converts a {@linkplain MimeTypes MIME type} into a {@linkplain MediaMuxer.OutputFormat
|
||||
* MediaMuxer output format}.
|
||||
*
|
||||
* @param mimeType The {@link MimeTypes MIME type} to convert.
|
||||
* @return The corresponding {@link MediaMuxer.OutputFormat MediaMuxer output format}.
|
||||
* @throws IllegalArgumentException If the {@link MimeTypes MIME type} is not supported as output
|
||||
* format.
|
||||
* @param mimeType The {@linkplain MimeTypes MIME type} to convert.
|
||||
* @return The corresponding {@linkplain MediaMuxer.OutputFormat MediaMuxer output format}.
|
||||
* @throws IllegalArgumentException If the {@linkplain MimeTypes MIME type} is not supported as
|
||||
* output format.
|
||||
*/
|
||||
private static int mimeTypeToMuxerOutputFormat(String mimeType) {
|
||||
if (mimeType.equals(MimeTypes.VIDEO_MP4)) {
|
||||
|
|
|
|||
|
|
@ -55,8 +55,8 @@ public interface GlFrameProcessor {
|
|||
/**
|
||||
* Updates the shader program's vertex attributes and uniforms, binds them, and draws.
|
||||
*
|
||||
* <p>The frame processor must be {@link #initialize(int) initialized}. The caller is responsible
|
||||
* for focussing the correct render target before calling this method.
|
||||
* <p>The frame processor must be {@linkplain #initialize(int) initialized}. The caller is
|
||||
* responsible for focussing the correct render target before calling this method.
|
||||
*
|
||||
* @param presentationTimeNs The presentation timestamp of the current frame, in nanoseconds.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@ import java.nio.ByteBuffer;
|
|||
/**
|
||||
* Abstracts media muxing operations.
|
||||
*
|
||||
* <p>Query whether {@link Factory#supportsOutputMimeType(String) container MIME type} and {@link
|
||||
* Factory#supportsSampleMimeType(String, String) sample MIME types} are supported and {@link
|
||||
* #addTrack(Format) add all tracks}, then {@link #writeSampleData(int, ByteBuffer, boolean, long)
|
||||
* write sample data} to mux samples. Once any sample data has been written, it is not possible to
|
||||
* add tracks. After writing all sample data, {@link #release(boolean) release} the instance to
|
||||
* finish writing to the output and return any resources to the system.
|
||||
* <p>Query whether {@linkplain Factory#supportsOutputMimeType(String) container MIME type} and
|
||||
* {@linkplain Factory#supportsSampleMimeType(String, String) sample MIME types} are supported and
|
||||
* {@linkplain #addTrack(Format) add all tracks}, then {@linkplain #writeSampleData(int, ByteBuffer,
|
||||
* boolean, long) write sample data} to mux samples. Once any sample data has been written, it is
|
||||
* not possible to add tracks. After writing all sample data, {@linkplain #release(boolean) release}
|
||||
* the instance to finish writing to the output and return any resources to the system.
|
||||
*/
|
||||
/* package */ interface Muxer {
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ import java.nio.ByteBuffer;
|
|||
* Returns a new muxer writing to a file.
|
||||
*
|
||||
* @param path The path to the output file.
|
||||
* @param outputMimeType The container {@link MimeTypes MIME type} of the output file.
|
||||
* @param outputMimeType The container {@linkplain MimeTypes MIME type} of the output file.
|
||||
* @throws IllegalArgumentException If the path is invalid or the MIME type is not supported.
|
||||
* @throws IOException If an error occurs opening the output file for writing.
|
||||
*/
|
||||
|
|
@ -68,7 +68,7 @@ import java.nio.ByteBuffer;
|
|||
* output. The file referenced by this ParcelFileDescriptor should not be used before the
|
||||
* muxer is released. It is the responsibility of the caller to close the
|
||||
* ParcelFileDescriptor. This can be done after this method returns.
|
||||
* @param outputMimeType The {@link MimeTypes MIME type} of the output.
|
||||
* @param outputMimeType The {@linkplain MimeTypes MIME type} of the output.
|
||||
* @throws IllegalArgumentException If the file descriptor is invalid or the MIME type is not
|
||||
* supported.
|
||||
* @throws IOException If an error occurs opening the output file descriptor for writing.
|
||||
|
|
@ -76,18 +76,20 @@ import java.nio.ByteBuffer;
|
|||
Muxer create(ParcelFileDescriptor parcelFileDescriptor, String outputMimeType)
|
||||
throws IOException;
|
||||
|
||||
/** Returns whether the {@link MimeTypes MIME type} provided is a supported output format. */
|
||||
/**
|
||||
* Returns whether the {@linkplain MimeTypes MIME type} provided is a supported output format.
|
||||
*/
|
||||
boolean supportsOutputMimeType(String mimeType);
|
||||
|
||||
/**
|
||||
* Returns whether the sample {@link MimeTypes MIME type} is supported with the given container
|
||||
* {@link MimeTypes MIME type}.
|
||||
* Returns whether the sample {@linkplain MimeTypes MIME type} is supported with the given
|
||||
* container {@linkplain MimeTypes MIME type}.
|
||||
*/
|
||||
boolean supportsSampleMimeType(@Nullable String sampleMimeType, String containerMimeType);
|
||||
|
||||
/**
|
||||
* Returns the supported sample {@link MimeTypes MIME types} for the given {@link C.TrackType}
|
||||
* and container {@link MimeTypes MIME type}.
|
||||
* Returns the supported sample {@linkplain MimeTypes MIME types} for the given {@link
|
||||
* C.TrackType} and container {@linkplain MimeTypes MIME type}.
|
||||
*/
|
||||
ImmutableList<String> getSupportedSampleMimeTypes(
|
||||
@C.TrackType int trackType, String containerMimeType);
|
||||
|
|
|
|||
|
|
@ -70,10 +70,10 @@ import java.nio.ByteBuffer;
|
|||
/**
|
||||
* Registers an output track.
|
||||
*
|
||||
* <p>All tracks must be registered before any track format is {@link #addTrackFormat(Format)
|
||||
* <p>All tracks must be registered before any track format is {@linkplain #addTrackFormat(Format)
|
||||
* added}.
|
||||
*
|
||||
* @throws IllegalStateException If a track format was {@link #addTrackFormat(Format) added}
|
||||
* @throws IllegalStateException If a track format was {@linkplain #addTrackFormat(Format) added}
|
||||
* before calling this method.
|
||||
*/
|
||||
public void registerTrack() {
|
||||
|
|
@ -82,14 +82,14 @@ import java.nio.ByteBuffer;
|
|||
trackCount++;
|
||||
}
|
||||
|
||||
/** Returns whether the sample {@link MimeTypes MIME type} is supported. */
|
||||
/** Returns whether the sample {@linkplain MimeTypes MIME type} is supported. */
|
||||
public boolean supportsSampleMimeType(@Nullable String mimeType) {
|
||||
return muxerFactory.supportsSampleMimeType(mimeType, containerMimeType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the supported {@link MimeTypes MIME types} for the given {@link C.TrackType track
|
||||
* type}.
|
||||
* Returns the supported {@linkplain MimeTypes MIME types} for the given {@linkplain C.TrackType
|
||||
* track type}.
|
||||
*/
|
||||
public ImmutableList<String> getSupportedSampleMimeTypes(@C.TrackType int trackType) {
|
||||
return muxerFactory.getSupportedSampleMimeTypes(trackType, containerMimeType);
|
||||
|
|
@ -98,9 +98,9 @@ import java.nio.ByteBuffer;
|
|||
/**
|
||||
* Adds a track format to the muxer.
|
||||
*
|
||||
* <p>The tracks must all be {@link #registerTrack() registered} before any format is added and
|
||||
* all the formats must be added before samples are {@link #writeSample(int, ByteBuffer, boolean,
|
||||
* long) written}.
|
||||
* <p>The tracks must all be {@linkplain #registerTrack() registered} before any format is added
|
||||
* and all the formats must be added before samples are {@linkplain #writeSample(int, ByteBuffer,
|
||||
* boolean, long) written}.
|
||||
*
|
||||
* @param format The {@link Format} to be added.
|
||||
* @throws IllegalStateException If the format is unsupported or if there is already a track
|
||||
|
|
@ -133,16 +133,16 @@ import java.nio.ByteBuffer;
|
|||
/**
|
||||
* Attempts to write a sample to the muxer.
|
||||
*
|
||||
* @param trackType The {@link C.TrackType track type} of the sample.
|
||||
* @param trackType The {@linkplain C.TrackType track type} of the sample.
|
||||
* @param data The sample to write.
|
||||
* @param isKeyFrame Whether the sample is a key frame.
|
||||
* @param presentationTimeUs The presentation time of the sample in microseconds.
|
||||
* @return Whether the sample was successfully written. This is {@code false} if the muxer hasn't
|
||||
* {@link #addTrackFormat(Format) received a format} for every {@link #registerTrack()
|
||||
* registered track}, or if it should write samples of other track types first to ensure a
|
||||
* good interleaving.
|
||||
* @throws IllegalStateException If the muxer doesn't have any {@link #endTrack(int) non-ended}
|
||||
* track of the given track type.
|
||||
* {@linkplain #addTrackFormat(Format) received a format} for every {@linkplain
|
||||
* #registerTrack() registered track}, or if it should write samples of other track types
|
||||
* first to ensure a good interleaving.
|
||||
* @throws IllegalStateException If the muxer doesn't have any {@linkplain #endTrack(int)
|
||||
* non-ended} track of the given track type.
|
||||
* @throws Muxer.MuxerException If the underlying muxer fails to write the sample.
|
||||
*/
|
||||
public boolean writeSample(
|
||||
|
|
|
|||
|
|
@ -247,8 +247,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
* output frame rate might be variable.
|
||||
*
|
||||
* <p>This method can only be called if all the frames until the current one (included) have been
|
||||
* {@link #processCurrentFrame(int, long) processed} in order, and if the next frames have not
|
||||
* been processed yet.
|
||||
* {@linkplain #processCurrentFrame(int, long) processed} in order, and if the next frames have
|
||||
* not been processed yet.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
/* package */ long getCurrentFrameOutputTimeUs(long inputTimeUs) {
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ public final class TransformationException extends Exception {
|
|||
/**
|
||||
* Caused by the output format for a track not being supported.
|
||||
*
|
||||
* <p>Supported output formats are limited by the muxer's capabilities and the {@link
|
||||
* <p>Supported output formats are limited by the muxer's capabilities and the {@linkplain
|
||||
* Codec.DecoderFactory encoders} available.
|
||||
*/
|
||||
public static final int ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED = 4003;
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ public final class TransformationRequest {
|
|||
* @param videoMimeType The MIME type of the video samples in the output.
|
||||
* @return This builder.
|
||||
* @throws IllegalArgumentException If the {@code videoMimeType} is non-null but not a video
|
||||
* {@link MimeTypes MIME type}.
|
||||
* {@linkplain MimeTypes MIME type}.
|
||||
*/
|
||||
public Builder setVideoMimeType(@Nullable String videoMimeType) {
|
||||
checkArgument(
|
||||
|
|
@ -184,7 +184,7 @@ public final class TransformationRequest {
|
|||
* @param audioMimeType The MIME type of the audio samples in the output.
|
||||
* @return This builder.
|
||||
* @throws IllegalArgumentException If the {@code audioMimeType} is non-null but not an audio
|
||||
* {@link MimeTypes MIME type}.
|
||||
* {@linkplain MimeTypes MIME type}.
|
||||
*/
|
||||
public Builder setAudioMimeType(@Nullable String audioMimeType) {
|
||||
checkArgument(
|
||||
|
|
@ -216,7 +216,7 @@ public final class TransformationRequest {
|
|||
*
|
||||
* <p>This method is experimental, and will be renamed or removed in a future release. The HDR
|
||||
* editing feature is under development and is intended for developing/testing HDR processing
|
||||
* and encoding support. HDR editing can't be enabled at the same time as {@link
|
||||
* and encoding support. HDR editing can't be enabled at the same time as {@linkplain
|
||||
* #setEnableRequestSdrToneMapping(boolean) SDR tone-mapping}.
|
||||
*
|
||||
* @param enableHdrEditing Whether to attempt to process any input video stream as a high
|
||||
|
|
@ -276,15 +276,15 @@ public final class TransformationRequest {
|
|||
*/
|
||||
public final int outputHeight;
|
||||
/**
|
||||
* The requested output audio sample {@link MimeTypes MIME type}, or {@code null} if inferred from
|
||||
* the input.
|
||||
* The requested output audio sample {@linkplain MimeTypes MIME type}, or {@code null} if inferred
|
||||
* from the input.
|
||||
*
|
||||
* @see Builder#setAudioMimeType(String)
|
||||
*/
|
||||
@Nullable public final String audioMimeType;
|
||||
/**
|
||||
* The requested output video sample {@link MimeTypes MIME type}, or {@code null} if inferred from
|
||||
* the input.
|
||||
* The requested output video sample {@linkplain MimeTypes MIME type}, or {@code null} if inferred
|
||||
* from the input.
|
||||
*
|
||||
* @see Builder#setVideoMimeType(String)
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ public final class Transformer {
|
|||
* Sets the {@link MediaSource.Factory} to be used to retrieve the inputs to transform.
|
||||
*
|
||||
* <p>The default value is a {@link DefaultMediaSourceFactory} built with the context provided
|
||||
* in {@link #Builder(Context) the constructor}.
|
||||
* in {@linkplain #Builder(Context) the constructor}.
|
||||
*
|
||||
* @param mediaSourceFactory A {@link MediaSource.Factory}.
|
||||
* @return This builder.
|
||||
|
|
@ -307,7 +307,7 @@ public final class Transformer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Removes all {@link Transformer.Listener listeners}.
|
||||
* Removes all {@linkplain Transformer.Listener listeners}.
|
||||
*
|
||||
* <p>This is equivalent to {@link Transformer#removeAllListeners()}.
|
||||
*
|
||||
|
|
@ -637,7 +637,7 @@ public final class Transformer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Removes all {@link Transformer.Listener listeners}.
|
||||
* Removes all {@linkplain Transformer.Listener listeners}.
|
||||
*
|
||||
* @throws IllegalStateException If this method is called from the wrong thread.
|
||||
*/
|
||||
|
|
@ -649,14 +649,14 @@ public final class Transformer {
|
|||
/**
|
||||
* Starts an asynchronous operation to transform the given {@link MediaItem}.
|
||||
*
|
||||
* <p>The transformation state is notified through the {@link Builder#addListener(Listener)
|
||||
* <p>The transformation state is notified through the {@linkplain Builder#addListener(Listener)
|
||||
* listener}.
|
||||
*
|
||||
* <p>Concurrent transformations on the same Transformer object are not allowed.
|
||||
*
|
||||
* <p>The output is an MP4 file. It can contain at most one video track and one audio track. Other
|
||||
* track types are ignored. For adaptive bitrate {@link MediaSource media sources}, the highest
|
||||
* bitrate video and audio streams are selected.
|
||||
* track types are ignored. For adaptive bitrate {@linkplain MediaSource media sources}, the
|
||||
* highest bitrate video and audio streams are selected.
|
||||
*
|
||||
* @param mediaItem The {@link MediaItem} to transform.
|
||||
* @param path The path to the output file.
|
||||
|
|
@ -672,14 +672,14 @@ public final class Transformer {
|
|||
/**
|
||||
* Starts an asynchronous operation to transform the given {@link MediaItem}.
|
||||
*
|
||||
* <p>The transformation state is notified through the {@link Builder#addListener(Listener)
|
||||
* <p>The transformation state is notified through the {@linkplain Builder#addListener(Listener)
|
||||
* listener}.
|
||||
*
|
||||
* <p>Concurrent transformations on the same Transformer object are not allowed.
|
||||
*
|
||||
* <p>The output is an MP4 file. It can contain at most one video track and one audio track. Other
|
||||
* track types are ignored. For adaptive bitrate {@link MediaSource media sources}, the highest
|
||||
* bitrate video and audio streams are selected.
|
||||
* track types are ignored. For adaptive bitrate {@linkplain MediaSource media sources}, the
|
||||
* highest bitrate video and audio streams are selected.
|
||||
*
|
||||
* @param mediaItem The {@link MediaItem} to transform.
|
||||
* @param parcelFileDescriptor A readable and writable {@link ParcelFileDescriptor} of the output.
|
||||
|
|
@ -765,7 +765,7 @@ public final class Transformer {
|
|||
* Returns the current {@link ProgressState} and updates {@code progressHolder} with the current
|
||||
* progress if it is {@link #PROGRESS_STATE_AVAILABLE available}.
|
||||
*
|
||||
* <p>After a transformation {@link Listener#onTransformationCompleted(MediaItem,
|
||||
* <p>After a transformation {@linkplain Listener#onTransformationCompleted(MediaItem,
|
||||
* TransformationResult) completes}, this method returns {@link
|
||||
* #PROGRESS_STATE_NO_TRANSFORMATION}.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ public final class VideoEncoderSettings {
|
|||
|
||||
/** The encoding bitrate. */
|
||||
public final int bitrate;
|
||||
/** One of {@link BitrateMode the allowed modes}. */
|
||||
/** One of {@linkplain BitrateMode the allowed modes}. */
|
||||
public final @BitrateMode int bitrateMode;
|
||||
/** The encoding profile. */
|
||||
public final int profile;
|
||||
|
|
|
|||
Loading…
Reference in a new issue