Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a520e7f5
authored
Nov 25, 2021
by
kimvde
Committed by
tonihei
Dec 02, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Miscellaneous small fixes in Transformer
PiperOrigin-RevId: 412286692
parent
a4c12ca9
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
42 deletions
libraries/transformer/src/main/java/androidx/media3/transformer/Transformation.java
libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java
libraries/transformer/src/main/java/androidx/media3/transformer/TransformerAudioRenderer.java
libraries/transformer/src/main/java/androidx/media3/transformer/TransformerBaseRenderer.java
libraries/transformer/src/main/java/androidx/media3/transformer/TransformerVideoRenderer.java
libraries/transformer/src/main/java/androidx/media3/transformer/VideoSamplePipeline.java
libraries/transformer/src/main/java/androidx/media3/transformer/Transformation.java
View file @
a520e7f5
...
...
@@ -21,9 +21,6 @@ import androidx.annotation.Nullable;
/** A media transformation configuration. */
/* package */
final
class
Transformation
{
/** A value for various fields to indicate that the field's value is unknown or not set. */
public
static
final
int
NO_VALUE
=
-
1
;
public
final
boolean
removeAudio
;
public
final
boolean
removeVideo
;
public
final
boolean
flattenForSlowMotion
;
...
...
libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java
View file @
a520e7f5
...
...
@@ -35,6 +35,7 @@ import androidx.annotation.Nullable;
import
androidx.annotation.RequiresApi
;
import
androidx.annotation.VisibleForTesting
;
import
androidx.media3.common.C
;
import
androidx.media3.common.Format
;
import
androidx.media3.common.MediaItem
;
import
androidx.media3.common.MediaLibraryInfo
;
import
androidx.media3.common.MimeTypes
;
...
...
@@ -109,15 +110,11 @@ public final class Transformer {
private
Looper
looper
;
private
Clock
clock
;
/**
* Creates a builder with default values.
*
* @deprecated Use {@link #Builder(Context)} instead.
*/
/** @deprecated Use {@link #Builder(Context)} instead. */
@Deprecated
public
Builder
()
{
muxerFactory
=
new
FrameworkMuxer
.
Factory
();
outputHeight
=
Transformation
.
NO_VALUE
;
outputHeight
=
Format
.
NO_VALUE
;
containerMimeType
=
MimeTypes
.
VIDEO_MP4
;
listener
=
new
Listener
()
{};
looper
=
Util
.
getCurrentOrMainLooper
();
...
...
@@ -128,12 +125,11 @@ public final class Transformer {
* Creates a builder with default values.
*
* @param context The {@link Context}.
* @throws NullPointerException If the {@link Context} has not been provided.
*/
public
Builder
(
Context
context
)
{
this
.
context
=
context
.
getApplicationContext
();
muxerFactory
=
new
FrameworkMuxer
.
Factory
();
outputHeight
=
Transformation
.
NO_VALUE
;
outputHeight
=
Format
.
NO_VALUE
;
containerMimeType
=
MimeTypes
.
VIDEO_MP4
;
listener
=
new
Listener
()
{};
looper
=
Util
.
getCurrentOrMainLooper
();
...
...
@@ -157,15 +153,7 @@ public final class Transformer {
this
.
clock
=
transformer
.
clock
;
}
/**
* Sets the {@link Context}.
*
* <p>This parameter is mandatory.
*
* @param context The {@link Context}.
* @return This builder.
* @deprecated Use {@link #Builder(Context)} instead.
*/
/** @deprecated Use {@link #Builder(Context)} instead. */
@Deprecated
public
Builder
setContext
(
Context
context
)
{
this
.
context
=
context
.
getApplicationContext
();
...
...
@@ -174,8 +162,8 @@ public final class Transformer {
/**
* Sets the {@link MediaSourceFactory} to be used to retrieve the inputs to transform. The
* default value is a {@link DefaultMediaSourceFactory} built with the context provided in
the
*
constructor
.
* default value is a {@link DefaultMediaSourceFactory} built with the context provided in
*
{@link #Builder(Context) the constructor}
.
*
* @param mediaSourceFactory A {@link MediaSourceFactory}.
* @return This builder.
...
...
@@ -244,9 +232,8 @@ public final class Transformer {
}
/**
* Sets the output resolution using the output height. The default value is {@link
* Transformation#NO_VALUE}, which will use the same height as the input. Output width will
* scale to preserve the input video's aspect ratio.
* Sets the output resolution using the output height. The default value is the same height as
* the input. Output width will scale to preserve the input video's aspect ratio.
*
* <p>For now, only "popular" heights like 240, 360, 480, 720, 1080, 1440, or 2160 are
* supported, to ensure compatibility on different devices.
...
...
libraries/transformer/src/main/java/androidx/media3/transformer/TransformerAudioRenderer.java
View file @
a520e7f5
...
...
@@ -46,7 +46,7 @@ import androidx.media3.exoplayer.source.SampleStream.ReadDataResult;
return
TAG
;
}
/** Attempts to read the input format and to initialize the
sample or passthrough pipeline
. */
/** Attempts to read the input format and to initialize the
{@link SamplePipeline}
. */
@Override
protected
boolean
ensureConfigured
()
throws
ExoPlaybackException
{
if
(
samplePipeline
!=
null
)
{
...
...
libraries/transformer/src/main/java/androidx/media3/transformer/TransformerBaseRenderer.java
View file @
a520e7f5
...
...
@@ -80,13 +80,13 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
}
@Override
public
final
boolean
isReady
()
{
return
isSourceReady
()
;
public
final
MediaClock
getMediaClock
()
{
return
mediaClock
;
}
@Override
public
final
MediaClock
getMediaClock
()
{
return
mediaClock
;
public
final
boolean
isReady
()
{
return
isSourceReady
()
;
}
@Override
...
...
@@ -109,15 +109,6 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
}
@Override
protected
final
void
onReset
()
{
if
(
samplePipeline
!=
null
)
{
samplePipeline
.
release
();
}
muxerWrapperTrackAdded
=
false
;
muxerWrapperTrackEnded
=
false
;
}
@Override
protected
final
void
onEnabled
(
boolean
joining
,
boolean
mayRenderStartOfStream
)
{
muxerWrapper
.
registerTrack
();
mediaClock
.
updateTimeForTrackType
(
getTrackType
(),
0L
);
...
...
@@ -133,6 +124,15 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
isRendererStarted
=
false
;
}
@Override
protected
final
void
onReset
()
{
if
(
samplePipeline
!=
null
)
{
samplePipeline
.
release
();
}
muxerWrapperTrackAdded
=
false
;
muxerWrapperTrackEnded
=
false
;
}
@EnsuresNonNullIf
(
expression
=
"samplePipeline"
,
result
=
true
)
protected
abstract
boolean
ensureConfigured
()
throws
ExoPlaybackException
;
...
...
libraries/transformer/src/main/java/androidx/media3/transformer/TransformerVideoRenderer.java
View file @
a520e7f5
...
...
@@ -57,7 +57,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
return
TAG
;
}
/** Attempts to read the input format and to initialize the
sample or passthrough pipeline
. */
/** Attempts to read the input format and to initialize the
{@link SamplePipeline}
. */
@Override
protected
boolean
ensureConfigured
()
throws
ExoPlaybackException
{
if
(
samplePipeline
!=
null
)
{
...
...
@@ -72,7 +72,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
Format
inputFormat
=
checkNotNull
(
formatHolder
.
format
);
if
((
transformation
.
videoMimeType
!=
null
&&
!
transformation
.
videoMimeType
.
equals
(
inputFormat
.
sampleMimeType
))
||
(
transformation
.
outputHeight
!=
Transformation
.
NO_VALUE
||
(
transformation
.
outputHeight
!=
Format
.
NO_VALUE
&&
transformation
.
outputHeight
!=
inputFormat
.
height
))
{
samplePipeline
=
new
VideoSamplePipeline
(
context
,
inputFormat
,
transformation
,
getIndex
());
}
else
{
...
...
libraries/transformer/src/main/java/androidx/media3/transformer/VideoSamplePipeline.java
View file @
a520e7f5
...
...
@@ -58,7 +58,7 @@ import java.io.IOException;
int
outputWidth
=
inputFormat
.
width
;
int
outputHeight
=
inputFormat
.
height
;
if
(
transformation
.
outputHeight
!=
Transformation
.
NO_VALUE
if
(
transformation
.
outputHeight
!=
Format
.
NO_VALUE
&&
transformation
.
outputHeight
!=
inputFormat
.
height
)
{
outputWidth
=
inputFormat
.
width
*
transformation
.
outputHeight
/
inputFormat
.
height
;
outputHeight
=
transformation
.
outputHeight
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment