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
f6916007
authored
Mar 09, 2023
by
sheenachhabra
Committed by
tonihei
Mar 14, 2023
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add support for writing MP4 location data using media muxer
PiperOrigin-RevId: 515297752
parent
9be419e6
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
0 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 @
f6916007
...
@@ -77,6 +77,11 @@ public final class DefaultMuxer implements Muxer {
...
@@ -77,6 +77,11 @@ public final class DefaultMuxer implements Muxer {
}
}
@Override
@Override
public
void
setLocation
(
float
latitude
,
float
longitude
)
{
this
.
muxer
.
setLocation
(
latitude
,
longitude
);
}
@Override
public
int
addTrack
(
Format
format
)
throws
MuxerException
{
public
int
addTrack
(
Format
format
)
throws
MuxerException
{
return
muxer
.
addTrack
(
format
);
return
muxer
.
addTrack
(
format
);
}
}
...
...
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/FrameworkMuxer.java
View file @
f6916007
...
@@ -105,6 +105,11 @@ import java.nio.ByteBuffer;
...
@@ -105,6 +105,11 @@ import java.nio.ByteBuffer;
}
}
@Override
@Override
public
void
setLocation
(
float
latitude
,
float
longitude
)
{
mediaMuxer
.
setLocation
(
latitude
,
longitude
);
}
@Override
public
int
addTrack
(
Format
format
)
throws
MuxerException
{
public
int
addTrack
(
Format
format
)
throws
MuxerException
{
String
sampleMimeType
=
checkNotNull
(
format
.
sampleMimeType
);
String
sampleMimeType
=
checkNotNull
(
format
.
sampleMimeType
);
MediaFormat
mediaFormat
;
MediaFormat
mediaFormat
;
...
...
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Muxer.java
View file @
f6916007
...
@@ -64,6 +64,14 @@ public interface Muxer {
...
@@ -64,6 +64,14 @@ public interface Muxer {
}
}
/**
/**
* Sets the location.
*
* @param latitude The latitude, in degrees. Its value must be in the range [-90, 90].
* @param longitude The longitude, in degrees. Its value must be in the range [-180, 180].
*/
void
setLocation
(
float
latitude
,
float
longitude
);
/**
* Adds a track with the specified format.
* Adds a track with the specified format.
*
*
* @param format The {@link Format} of the track.
* @param format The {@link Format} of the track.
...
...
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/MuxerWrapper.java
View file @
f6916007
...
@@ -27,6 +27,8 @@ import androidx.annotation.IntRange;
...
@@ -27,6 +27,8 @@ import androidx.annotation.IntRange;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.metadata.Metadata
;
import
com.google.android.exoplayer2.metadata.mp4.Mp4LocationData
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableList
;
...
@@ -129,6 +131,9 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
...
@@ -129,6 +131,9 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
* and all the formats must be added before any samples can be {@linkplain #writeSample(int,
* and all the formats must be added before any samples can be {@linkplain #writeSample(int,
* ByteBuffer, boolean, long) written}.
* ByteBuffer, boolean, long) written}.
*
*
* <p>If the {@link Format#metadata} contains {@link Mp4LocationData}, then it will be added to
* the muxer.
*
* @param format The {@link Format} to be added.
* @param format The {@link Format} to be added.
* @throws IllegalArgumentException If the format is unsupported.
* @throws IllegalArgumentException If the format is unsupported.
* @throws IllegalStateException If the number of formats added exceeds the {@linkplain
* @throws IllegalStateException If the number of formats added exceeds the {@linkplain
...
@@ -159,6 +164,11 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
...
@@ -159,6 +164,11 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
isReady
=
true
;
isReady
=
true
;
resetAbortTimer
();
resetAbortTimer
();
}
}
@Nullable
Mp4LocationData
mp4LocationData
=
extractMp4LocationData
(
format
);
if
(
mp4LocationData
!=
null
)
{
muxer
.
setLocation
(
mp4LocationData
.
latitude
,
mp4LocationData
.
longitude
);
}
}
}
/**
/**
...
@@ -328,6 +338,21 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
...
@@ -328,6 +338,21 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
return
trackInfoWithMinTimeUs
;
return
trackInfoWithMinTimeUs
;
}
}
@Nullable
private
static
Mp4LocationData
extractMp4LocationData
(
Format
format
)
{
if
(
format
.
metadata
==
null
)
{
return
null
;
}
for
(
int
i
=
0
;
i
<
format
.
metadata
.
length
();
i
++)
{
Metadata
.
Entry
entry
=
format
.
metadata
.
get
(
i
);
if
(
entry
instanceof
Mp4LocationData
)
{
return
(
Mp4LocationData
)
entry
;
}
}
return
null
;
}
private
static
final
class
TrackInfo
{
private
static
final
class
TrackInfo
{
public
final
Format
format
;
public
final
Format
format
;
public
final
int
index
;
public
final
int
index
;
...
...
library/transformer/src/test/java/com/google/android/exoplayer2/transformer/TestMuxer.java
View file @
f6916007
...
@@ -43,6 +43,11 @@ public final class TestMuxer implements Muxer, Dumper.Dumpable {
...
@@ -43,6 +43,11 @@ public final class TestMuxer implements Muxer, Dumper.Dumpable {
// Muxer implementation.
// Muxer implementation.
@Override
@Override
public
void
setLocation
(
float
latitude
,
float
longitude
)
{
muxer
.
setLocation
(
latitude
,
longitude
);
}
@Override
public
int
addTrack
(
Format
format
)
throws
MuxerException
{
public
int
addTrack
(
Format
format
)
throws
MuxerException
{
int
trackIndex
=
muxer
.
addTrack
(
format
);
int
trackIndex
=
muxer
.
addTrack
(
format
);
dumpables
.
add
(
new
DumpableFormat
(
format
,
trackIndex
));
dumpables
.
add
(
new
DumpableFormat
(
format
,
trackIndex
));
...
...
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