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
8fe90562
authored
Jan 11, 2023
by
samrobinson
Committed by
Rohit Singh
Jan 17, 2023
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Allow Muxer.writeSampleData to take @C.BufferFlag int flags.
PiperOrigin-RevId: 501314812
parent
74cc5880
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
16 deletions
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/DefaultMuxer.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/FrameworkMuxer.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Muxer.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/MuxerWrapper.java
library/transformer/src/test/java/com/google/android/exoplayer2/transformer/TestMuxer.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/DefaultMuxer.java
View file @
8fe90562
...
...
@@ -78,9 +78,9 @@ public final class DefaultMuxer implements Muxer {
@Override
public
void
writeSampleData
(
int
trackIndex
,
ByteBuffer
data
,
boolean
isKeyFrame
,
long
presentationTimeU
s
)
int
trackIndex
,
ByteBuffer
data
,
long
presentationTimeUs
,
@C
.
BufferFlags
int
flag
s
)
throws
MuxerException
{
muxer
.
writeSampleData
(
trackIndex
,
data
,
isKeyFrame
,
presentationTimeU
s
);
muxer
.
writeSampleData
(
trackIndex
,
data
,
presentationTimeUs
,
flag
s
);
}
@Override
...
...
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/FrameworkMuxer.java
View file @
8fe90562
...
...
@@ -142,10 +142,9 @@ import java.nio.ByteBuffer;
return
trackIndex
;
}
@SuppressLint
(
"WrongConstant"
)
// C.BUFFER_FLAG_KEY_FRAME equals MediaCodec.BUFFER_FLAG_KEY_FRAME.
@Override
public
void
writeSampleData
(
int
trackIndex
,
ByteBuffer
data
,
boolean
isKeyFrame
,
long
presentationTimeU
s
)
int
trackIndex
,
ByteBuffer
data
,
long
presentationTimeUs
,
@C
.
BufferFlags
int
flag
s
)
throws
MuxerException
{
if
(!
isStarted
)
{
isStarted
=
true
;
...
...
@@ -157,7 +156,6 @@ import java.nio.ByteBuffer;
}
int
offset
=
data
.
position
();
int
size
=
data
.
limit
()
-
offset
;
int
flags
=
isKeyFrame
?
C
.
BUFFER_FLAG_KEY_FRAME
:
0
;
bufferInfo
.
set
(
offset
,
size
,
presentationTimeUs
,
flags
);
long
lastSamplePresentationTimeUs
=
trackIndexToLastPresentationTimeUs
.
get
(
trackIndex
);
try
{
...
...
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Muxer.java
View file @
8fe90562
...
...
@@ -26,11 +26,10 @@ import java.nio.ByteBuffer;
* Abstracts media muxing operations.
*
* <p>Query whether {@linkplain Factory#getSupportedSampleMimeTypes(int) 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.
* supported and {@linkplain #addTrack(Format) add all tracks}, then {@linkplain #writeSampleData
* 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.
*/
public
interface
Muxer
{
...
...
@@ -91,11 +90,13 @@ public interface Muxer {
*
* @param trackIndex The index of the track, previously returned by {@link #addTrack(Format)}.
* @param data A buffer containing the sample data to write to the container.
* @param isKeyFrame Whether the sample is a key frame.
* @param presentationTimeUs The presentation time of the sample in microseconds.
* @param flags The {@link C.BufferFlags} associated with the data. Only {@link
* C#BUFFER_FLAG_KEY_FRAME} is supported.
* @throws MuxerException If the muxer fails to write the sample.
*/
void
writeSampleData
(
int
trackIndex
,
ByteBuffer
data
,
boolean
isKeyFrame
,
long
presentationTimeUs
)
void
writeSampleData
(
int
trackIndex
,
ByteBuffer
data
,
long
presentationTimeUs
,
@C
.
BufferFlags
int
flags
)
throws
MuxerException
;
/**
...
...
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/MuxerWrapper.java
View file @
8fe90562
...
...
@@ -202,7 +202,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
checkNotNull
(
muxer
);
resetAbortTimer
();
muxer
.
writeSampleData
(
trackInfo
.
index
,
data
,
isKeyFrame
,
presentationTimeUs
);
muxer
.
writeSampleData
(
trackInfo
.
index
,
data
,
presentationTimeUs
,
isKeyFrame
?
C
.
BUFFER_FLAG_KEY_FRAME
:
0
);
previousTrackType
=
trackType
;
return
true
;
}
...
...
library/transformer/src/test/java/com/google/android/exoplayer2/transformer/TestMuxer.java
View file @
8fe90562
...
...
@@ -15,6 +15,7 @@
*/
package
com
.
google
.
android
.
exoplayer2
.
transformer
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.testutil.DumpableFormat
;
import
com.google.android.exoplayer2.testutil.Dumper
;
...
...
@@ -50,10 +51,15 @@ public final class TestMuxer implements Muxer, Dumper.Dumpable {
@Override
public
void
writeSampleData
(
int
trackIndex
,
ByteBuffer
data
,
boolean
isKeyFrame
,
long
presentationTimeU
s
)
int
trackIndex
,
ByteBuffer
data
,
long
presentationTimeUs
,
@C
.
BufferFlags
int
flag
s
)
throws
MuxerException
{
dumpables
.
add
(
new
DumpableSample
(
trackIndex
,
data
,
isKeyFrame
,
presentationTimeUs
));
muxer
.
writeSampleData
(
trackIndex
,
data
,
isKeyFrame
,
presentationTimeUs
);
dumpables
.
add
(
new
DumpableSample
(
trackIndex
,
data
,
(
flags
&
C
.
BUFFER_FLAG_KEY_FRAME
)
==
C
.
BUFFER_FLAG_KEY_FRAME
,
presentationTimeUs
));
muxer
.
writeSampleData
(
trackIndex
,
data
,
presentationTimeUs
,
flags
);
}
@Override
...
...
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