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
e846e9f0
authored
Nov 25, 2021
by
kimvde
Committed by
kim-vde
Nov 26, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Miscellaneous small fixes in Transformer
PiperOrigin-RevId: 412286692
parent
276f103c
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
42 deletions
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformation.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformer.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformerAudioRenderer.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformerBaseRenderer.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformerVideoRenderer.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/VideoSamplePipeline.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformation.java
View file @
e846e9f0
...
@@ -21,9 +21,6 @@ import androidx.annotation.Nullable;
...
@@ -21,9 +21,6 @@ import androidx.annotation.Nullable;
/** A media transformation configuration. */
/** A media transformation configuration. */
/* package */
final
class
Transformation
{
/* 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
removeAudio
;
public
final
boolean
removeVideo
;
public
final
boolean
removeVideo
;
public
final
boolean
flattenForSlowMotion
;
public
final
boolean
flattenForSlowMotion
;
...
...
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformer.java
View file @
e846e9f0
...
@@ -38,6 +38,7 @@ import com.google.android.exoplayer2.C;
...
@@ -38,6 +38,7 @@ import com.google.android.exoplayer2.C;
import
com.google.android.exoplayer2.DefaultLoadControl
;
import
com.google.android.exoplayer2.DefaultLoadControl
;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.ExoPlayerLibraryInfo
;
import
com.google.android.exoplayer2.ExoPlayerLibraryInfo
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.MediaItem
;
import
com.google.android.exoplayer2.MediaItem
;
import
com.google.android.exoplayer2.PlaybackException
;
import
com.google.android.exoplayer2.PlaybackException
;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.Player
;
...
@@ -107,15 +108,11 @@ public final class Transformer {
...
@@ -107,15 +108,11 @@ public final class Transformer {
private
Looper
looper
;
private
Looper
looper
;
private
Clock
clock
;
private
Clock
clock
;
/**
/** @deprecated Use {@link #Builder(Context)} instead. */
* Creates a builder with default values.
*
* @deprecated Use {@link #Builder(Context)} instead.
*/
@Deprecated
@Deprecated
public
Builder
()
{
public
Builder
()
{
muxerFactory
=
new
FrameworkMuxer
.
Factory
();
muxerFactory
=
new
FrameworkMuxer
.
Factory
();
outputHeight
=
Transformation
.
NO_VALUE
;
outputHeight
=
Format
.
NO_VALUE
;
containerMimeType
=
MimeTypes
.
VIDEO_MP4
;
containerMimeType
=
MimeTypes
.
VIDEO_MP4
;
listener
=
new
Listener
()
{};
listener
=
new
Listener
()
{};
looper
=
Util
.
getCurrentOrMainLooper
();
looper
=
Util
.
getCurrentOrMainLooper
();
...
@@ -126,12 +123,11 @@ public final class Transformer {
...
@@ -126,12 +123,11 @@ public final class Transformer {
* Creates a builder with default values.
* Creates a builder with default values.
*
*
* @param context The {@link Context}.
* @param context The {@link Context}.
* @throws NullPointerException If the {@link Context} has not been provided.
*/
*/
public
Builder
(
Context
context
)
{
public
Builder
(
Context
context
)
{
this
.
context
=
context
.
getApplicationContext
();
this
.
context
=
context
.
getApplicationContext
();
muxerFactory
=
new
FrameworkMuxer
.
Factory
();
muxerFactory
=
new
FrameworkMuxer
.
Factory
();
outputHeight
=
Transformation
.
NO_VALUE
;
outputHeight
=
Format
.
NO_VALUE
;
containerMimeType
=
MimeTypes
.
VIDEO_MP4
;
containerMimeType
=
MimeTypes
.
VIDEO_MP4
;
listener
=
new
Listener
()
{};
listener
=
new
Listener
()
{};
looper
=
Util
.
getCurrentOrMainLooper
();
looper
=
Util
.
getCurrentOrMainLooper
();
...
@@ -155,15 +151,7 @@ public final class Transformer {
...
@@ -155,15 +151,7 @@ public final class Transformer {
this
.
clock
=
transformer
.
clock
;
this
.
clock
=
transformer
.
clock
;
}
}
/**
/** @deprecated Use {@link #Builder(Context)} instead. */
* Sets the {@link Context}.
*
* <p>This parameter is mandatory.
*
* @param context The {@link Context}.
* @return This builder.
* @deprecated Use {@link #Builder(Context)} instead.
*/
@Deprecated
@Deprecated
public
Builder
setContext
(
Context
context
)
{
public
Builder
setContext
(
Context
context
)
{
this
.
context
=
context
.
getApplicationContext
();
this
.
context
=
context
.
getApplicationContext
();
...
@@ -172,8 +160,8 @@ public final class Transformer {
...
@@ -172,8 +160,8 @@ public final class Transformer {
/**
/**
* Sets the {@link MediaSourceFactory} to be used to retrieve the inputs to transform. The
* 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
* default value is a {@link DefaultMediaSourceFactory} built with the context provided in
*
constructor
.
*
{@link #Builder(Context) the constructor}
.
*
*
* @param mediaSourceFactory A {@link MediaSourceFactory}.
* @param mediaSourceFactory A {@link MediaSourceFactory}.
* @return This builder.
* @return This builder.
...
@@ -242,9 +230,8 @@ public final class Transformer {
...
@@ -242,9 +230,8 @@ public final class Transformer {
}
}
/**
/**
* Sets the output resolution using the output height. The default value is {@link
* Sets the output resolution using the output height. The default value is the same height as
* Transformation#NO_VALUE}, which will use the same height as the input. Output width will
* the input. Output width will scale to preserve the input video's aspect ratio.
* 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
* <p>For now, only "popular" heights like 240, 360, 480, 720, 1080, 1440, or 2160 are
* supported, to ensure compatibility on different devices.
* supported, to ensure compatibility on different devices.
...
...
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformerAudioRenderer.java
View file @
e846e9f0
...
@@ -46,7 +46,7 @@ import com.google.android.exoplayer2.source.SampleStream.ReadDataResult;
...
@@ -46,7 +46,7 @@ import com.google.android.exoplayer2.source.SampleStream.ReadDataResult;
return
TAG
;
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
@Override
protected
boolean
ensureConfigured
()
throws
ExoPlaybackException
{
protected
boolean
ensureConfigured
()
throws
ExoPlaybackException
{
if
(
samplePipeline
!=
null
)
{
if
(
samplePipeline
!=
null
)
{
...
...
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformerBaseRenderer.java
View file @
e846e9f0
...
@@ -80,13 +80,13 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
...
@@ -80,13 +80,13 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
}
}
@Override
@Override
public
final
boolean
isReady
()
{
public
final
MediaClock
getMediaClock
()
{
return
isSourceReady
()
;
return
mediaClock
;
}
}
@Override
@Override
public
final
MediaClock
getMediaClock
()
{
public
final
boolean
isReady
()
{
return
mediaClock
;
return
isSourceReady
()
;
}
}
@Override
@Override
...
@@ -109,15 +109,6 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
...
@@ -109,15 +109,6 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
}
}
@Override
@Override
protected
final
void
onReset
()
{
if
(
samplePipeline
!=
null
)
{
samplePipeline
.
release
();
}
muxerWrapperTrackAdded
=
false
;
muxerWrapperTrackEnded
=
false
;
}
@Override
protected
final
void
onEnabled
(
boolean
joining
,
boolean
mayRenderStartOfStream
)
{
protected
final
void
onEnabled
(
boolean
joining
,
boolean
mayRenderStartOfStream
)
{
muxerWrapper
.
registerTrack
();
muxerWrapper
.
registerTrack
();
mediaClock
.
updateTimeForTrackType
(
getTrackType
(),
0L
);
mediaClock
.
updateTimeForTrackType
(
getTrackType
(),
0L
);
...
@@ -133,6 +124,15 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
...
@@ -133,6 +124,15 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
isRendererStarted
=
false
;
isRendererStarted
=
false
;
}
}
@Override
protected
final
void
onReset
()
{
if
(
samplePipeline
!=
null
)
{
samplePipeline
.
release
();
}
muxerWrapperTrackAdded
=
false
;
muxerWrapperTrackEnded
=
false
;
}
@EnsuresNonNullIf
(
expression
=
"samplePipeline"
,
result
=
true
)
@EnsuresNonNullIf
(
expression
=
"samplePipeline"
,
result
=
true
)
protected
abstract
boolean
ensureConfigured
()
throws
ExoPlaybackException
;
protected
abstract
boolean
ensureConfigured
()
throws
ExoPlaybackException
;
...
...
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformerVideoRenderer.java
View file @
e846e9f0
...
@@ -57,7 +57,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
...
@@ -57,7 +57,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
return
TAG
;
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
@Override
protected
boolean
ensureConfigured
()
throws
ExoPlaybackException
{
protected
boolean
ensureConfigured
()
throws
ExoPlaybackException
{
if
(
samplePipeline
!=
null
)
{
if
(
samplePipeline
!=
null
)
{
...
@@ -72,7 +72,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
...
@@ -72,7 +72,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
Format
inputFormat
=
checkNotNull
(
formatHolder
.
format
);
Format
inputFormat
=
checkNotNull
(
formatHolder
.
format
);
if
((
transformation
.
videoMimeType
!=
null
if
((
transformation
.
videoMimeType
!=
null
&&
!
transformation
.
videoMimeType
.
equals
(
inputFormat
.
sampleMimeType
))
&&
!
transformation
.
videoMimeType
.
equals
(
inputFormat
.
sampleMimeType
))
||
(
transformation
.
outputHeight
!=
Transformation
.
NO_VALUE
||
(
transformation
.
outputHeight
!=
Format
.
NO_VALUE
&&
transformation
.
outputHeight
!=
inputFormat
.
height
))
{
&&
transformation
.
outputHeight
!=
inputFormat
.
height
))
{
samplePipeline
=
new
VideoSamplePipeline
(
context
,
inputFormat
,
transformation
,
getIndex
());
samplePipeline
=
new
VideoSamplePipeline
(
context
,
inputFormat
,
transformation
,
getIndex
());
}
else
{
}
else
{
...
...
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/VideoSamplePipeline.java
View file @
e846e9f0
...
@@ -58,7 +58,7 @@ import java.io.IOException;
...
@@ -58,7 +58,7 @@ import java.io.IOException;
int
outputWidth
=
inputFormat
.
width
;
int
outputWidth
=
inputFormat
.
width
;
int
outputHeight
=
inputFormat
.
height
;
int
outputHeight
=
inputFormat
.
height
;
if
(
transformation
.
outputHeight
!=
Transformation
.
NO_VALUE
if
(
transformation
.
outputHeight
!=
Format
.
NO_VALUE
&&
transformation
.
outputHeight
!=
inputFormat
.
height
)
{
&&
transformation
.
outputHeight
!=
inputFormat
.
height
)
{
outputWidth
=
inputFormat
.
width
*
transformation
.
outputHeight
/
inputFormat
.
height
;
outputWidth
=
inputFormat
.
width
*
transformation
.
outputHeight
/
inputFormat
.
height
;
outputHeight
=
transformation
.
outputHeight
;
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