mirror of
https://github.com/samsonjs/media.git
synced 2026-04-20 13:45:47 +00:00
Remove setLocation() method from Muxer interface
PiperOrigin-RevId: 516314175
This commit is contained in:
parent
82c9479dd2
commit
7b8c562d7b
16 changed files with 60 additions and 46 deletions
|
|
@ -10,12 +10,14 @@ format 0:
|
|||
initializationData:
|
||||
data = length 29, hash 4746B5D9
|
||||
data = length 10, hash 7A0D0F2B
|
||||
metadata = entries=[xyz: latitude=40.68 longitude=-74.5]
|
||||
format 1:
|
||||
sampleMimeType = audio/mp4a-latm
|
||||
channelCount = 1
|
||||
sampleRate = 48000
|
||||
pcmEncoding = 2
|
||||
metadata = entries=[TSSE: description=null: values=[Lavf56.1.0], xyz: latitude=40.68 longitude=-74.5]
|
||||
metadata = entries=[TSSE: description=null: values=[Lavf56.1.0], xyz: latitude=40.68 longitude=-74.5]
|
||||
sample:
|
||||
trackIndex = 1
|
||||
dataHashCode = 1868041800
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ format 0:
|
|||
initializationData:
|
||||
data = length 29, hash 4746B5D9
|
||||
data = length 10, hash 7A0D0F2B
|
||||
metadata = entries=[xyz: latitude=40.68 longitude=-74.5]
|
||||
format 1:
|
||||
peakBitrate = 200000
|
||||
id = 2
|
||||
|
|
@ -22,6 +23,7 @@ format 1:
|
|||
metadata = entries=[TSSE: description=null: values=[Lavf56.1.0], xyz: latitude=40.68 longitude=-74.5]
|
||||
initializationData:
|
||||
data = length 2, hash 5F7
|
||||
metadata = entries=[TSSE: description=null: values=[Lavf56.1.0], xyz: latitude=40.68 longitude=-74.5]
|
||||
sample:
|
||||
trackIndex = 1
|
||||
dataHashCode = 1205768497
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ format 0:
|
|||
sampleRate = 44100
|
||||
pcmEncoding = 2
|
||||
metadata = entries=[TSSE: description=null: values=[Lavf56.1.0], xyz: latitude=40.68 longitude=-74.5]
|
||||
metadata = entries=[TSSE: description=null: values=[Lavf56.1.0], xyz: latitude=40.68 longitude=-74.5]
|
||||
sample:
|
||||
trackIndex = 0
|
||||
dataHashCode = 915609509
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ format 0:
|
|||
initializationData:
|
||||
data = length 29, hash 4746B5D9
|
||||
data = length 10, hash 7A0D0F2B
|
||||
metadata = entries=[xyz: latitude=40.68 longitude=-74.5]
|
||||
format 1:
|
||||
peakBitrate = 200000
|
||||
id = 2
|
||||
|
|
@ -22,6 +23,7 @@ format 1:
|
|||
metadata = entries=[TSSE: description=null: values=[Lavf56.1.0], xyz: latitude=40.68 longitude=-74.5]
|
||||
initializationData:
|
||||
data = length 2, hash 5F7
|
||||
metadata = entries=[TSSE: description=null: values=[Lavf56.1.0], xyz: latitude=40.68 longitude=-74.5]
|
||||
sample:
|
||||
trackIndex = 1
|
||||
dataHashCode = 1205768497
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ format 0:
|
|||
initializationData:
|
||||
data = length 29, hash 4746B5D9
|
||||
data = length 10, hash 7A0D0F2B
|
||||
metadata = entries=[xyz: latitude=40.68 longitude=-74.5]
|
||||
sample:
|
||||
trackIndex = 0
|
||||
dataHashCode = -770308242
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ format 0:
|
|||
metadata = entries=[TSSE: description=null: values=[Lavf56.1.0], xyz: latitude=40.68 longitude=-74.5]
|
||||
initializationData:
|
||||
data = length 2, hash 5F7
|
||||
metadata = entries=[TSSE: description=null: values=[Lavf56.1.0], xyz: latitude=40.68 longitude=-74.5]
|
||||
sample:
|
||||
trackIndex = 0
|
||||
dataHashCode = 1205768497
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ format 0:
|
|||
initializationData:
|
||||
data = length 29, hash 4746B5D9
|
||||
data = length 10, hash 7A0D0F2B
|
||||
metadata = entries=[xyz: latitude=40.68 longitude=-74.5]
|
||||
format 1:
|
||||
sampleMimeType = audio/mp4a-latm
|
||||
channelCount = 2
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ format 0:
|
|||
initializationData:
|
||||
data = length 29, hash 4746B5D9
|
||||
data = length 10, hash 7A0D0F2B
|
||||
metadata = entries=[xyz: latitude=40.68 longitude=-74.5]
|
||||
format 1:
|
||||
sampleMimeType = audio/mp4a-latm
|
||||
channelCount = 2
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ format 0:
|
|||
initializationData:
|
||||
data = length 29, hash 4746B5D9
|
||||
data = length 10, hash 7A0D0F2B
|
||||
metadata = entries=[xyz: latitude=40.68 longitude=-74.5]
|
||||
format 1:
|
||||
sampleMimeType = audio/mp4a-latm
|
||||
channelCount = 2
|
||||
|
|
|
|||
|
|
@ -10,12 +10,14 @@ format 0:
|
|||
initializationData:
|
||||
data = length 33, hash D3FB879D
|
||||
data = length 10, hash 7A0D0F2B
|
||||
metadata = entries=[mdta: key=com.android.capture.fps, smta: captureFrameRate=240.0, svcTemporalLayerCount=4, SlowMotion: segments=[Segment: startTimeMs=88, endTimeMs=879, speedDivisor=2, Segment: startTimeMs=1255, endTimeMs=1970, speedDivisor=8]]
|
||||
format 1:
|
||||
sampleMimeType = audio/mp4a-latm
|
||||
channelCount = 2
|
||||
sampleRate = 12000
|
||||
pcmEncoding = 2
|
||||
metadata = entries=[smta: captureFrameRate=240.0, svcTemporalLayerCount=4, SlowMotion: segments=[Segment: startTimeMs=88, endTimeMs=879, speedDivisor=2, Segment: startTimeMs=1255, endTimeMs=1970, speedDivisor=8]]
|
||||
metadata = entries=[smta: captureFrameRate=240.0, svcTemporalLayerCount=4, SlowMotion: segments=[Segment: startTimeMs=88, endTimeMs=879, speedDivisor=2, Segment: startTimeMs=1255, endTimeMs=1970, speedDivisor=8]]
|
||||
sample:
|
||||
trackIndex = 1
|
||||
dataHashCode = -212376212
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ format 1:
|
|||
metadata = entries=[TSSE: description=null: values=[Lavf58.76.100]]
|
||||
initializationData:
|
||||
data = length 2, hash 560
|
||||
metadata = entries=[TSSE: description=null: values=[Lavf58.76.100]]
|
||||
sample:
|
||||
trackIndex = 1
|
||||
dataHashCode = 620415738
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ package androidx.media3.transformer;
|
|||
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.Format;
|
||||
import androidx.media3.common.Metadata;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.nio.ByteBuffer;
|
||||
|
|
@ -78,11 +79,6 @@ public final class DefaultMuxer implements Muxer {
|
|||
this.muxer = muxer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(float latitude, float longitude) {
|
||||
this.muxer.setLocation(latitude, longitude);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addTrack(Format format) throws MuxerException {
|
||||
return muxer.addTrack(format);
|
||||
|
|
@ -95,6 +91,11 @@ public final class DefaultMuxer implements Muxer {
|
|||
muxer.writeSampleData(trackIndex, data, presentationTimeUs, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMetadata(Metadata metadata) {
|
||||
muxer.addMetadata(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release(boolean forCancellation) throws MuxerException {
|
||||
muxer.release(forCancellation);
|
||||
|
|
|
|||
|
|
@ -25,11 +25,14 @@ import android.media.MediaCodec;
|
|||
import android.media.MediaFormat;
|
||||
import android.media.MediaMuxer;
|
||||
import android.util.SparseLongArray;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.Format;
|
||||
import androidx.media3.common.Metadata;
|
||||
import androidx.media3.common.MimeTypes;
|
||||
import androidx.media3.common.util.MediaFormatUtil;
|
||||
import androidx.media3.common.util.Util;
|
||||
import androidx.media3.extractor.metadata.mp4.Mp4LocationData;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
|
|
@ -104,11 +107,6 @@ import java.nio.ByteBuffer;
|
|||
videoTrackIndex = C.INDEX_UNSET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(float latitude, float longitude) {
|
||||
mediaMuxer.setLocation(latitude, longitude);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addTrack(Format format) throws MuxerException {
|
||||
String sampleMimeType = checkNotNull(format.sampleMimeType);
|
||||
|
|
@ -190,6 +188,14 @@ import java.nio.ByteBuffer;
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMetadata(Metadata metadata) {
|
||||
@Nullable Mp4LocationData mp4LocationData = getMp4LocationData(metadata);
|
||||
if (mp4LocationData != null) {
|
||||
mediaMuxer.setLocation(mp4LocationData.latitude, mp4LocationData.longitude);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release(boolean forCancellation) throws MuxerException {
|
||||
if (!isStarted) {
|
||||
|
|
@ -261,4 +267,15 @@ import java.nio.ByteBuffer;
|
|||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Mp4LocationData getMp4LocationData(Metadata metadata) {
|
||||
for (int i = 0; i < metadata.length(); i++) {
|
||||
Metadata.Entry entry = metadata.get(i);
|
||||
if (entry instanceof Mp4LocationData) {
|
||||
return (Mp4LocationData) entry;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ package androidx.media3.transformer;
|
|||
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.Format;
|
||||
import androidx.media3.common.Metadata;
|
||||
import androidx.media3.common.MimeTypes;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
|
@ -65,14 +66,6 @@ public interface Muxer {
|
|||
ImmutableList<String> getSupportedSampleMimeTypes(@C.TrackType int trackType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
|
@ -96,6 +89,9 @@ public interface Muxer {
|
|||
int trackIndex, ByteBuffer data, long presentationTimeUs, @C.BufferFlags int flags)
|
||||
throws MuxerException;
|
||||
|
||||
/** Adds {@link Metadata} about the output file. */
|
||||
void addMetadata(Metadata metadata);
|
||||
|
||||
/**
|
||||
* Finishes writing the output and releases any resources associated with muxing.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import androidx.media3.common.Format;
|
|||
import androidx.media3.common.Metadata;
|
||||
import androidx.media3.common.MimeTypes;
|
||||
import androidx.media3.common.util.Util;
|
||||
import androidx.media3.extractor.metadata.mp4.Mp4LocationData;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.io.File;
|
||||
import java.nio.ByteBuffer;
|
||||
|
|
@ -131,8 +130,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
* and all the formats must be added before any samples can be {@linkplain #writeSample(int,
|
||||
* ByteBuffer, boolean, long) written}.
|
||||
*
|
||||
* <p>If the {@link Format#metadata} contains {@link Mp4LocationData}, then it will be added to
|
||||
* the muxer.
|
||||
* <p>{@link Muxer#addMetadata(Metadata)} is called if the {@link Format#metadata} is present.
|
||||
*
|
||||
* @param format The {@link Format} to be added.
|
||||
* @throws IllegalArgumentException If the format is unsupported.
|
||||
|
|
@ -160,15 +158,15 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
|
||||
TrackInfo trackInfo = new TrackInfo(format, muxer.addTrack(format));
|
||||
trackTypeToInfo.put(trackType, trackInfo);
|
||||
|
||||
if (format.metadata != null) {
|
||||
muxer.addMetadata(format.metadata);
|
||||
}
|
||||
|
||||
if (trackTypeToInfo.size() == trackCount) {
|
||||
isReady = true;
|
||||
resetAbortTimer();
|
||||
}
|
||||
|
||||
@Nullable Mp4LocationData mp4LocationData = extractMp4LocationData(format);
|
||||
if (mp4LocationData != null) {
|
||||
muxer.setLocation(mp4LocationData.latitude, mp4LocationData.longitude);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -338,21 +336,6 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
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 {
|
||||
public final Format format;
|
||||
public final int index;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ package androidx.media3.transformer;
|
|||
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.Format;
|
||||
import androidx.media3.common.Metadata;
|
||||
import androidx.media3.test.utils.DumpableFormat;
|
||||
import androidx.media3.test.utils.Dumper;
|
||||
import java.nio.ByteBuffer;
|
||||
|
|
@ -42,11 +43,6 @@ public final class TestMuxer implements Muxer, Dumper.Dumpable {
|
|||
|
||||
// Muxer implementation.
|
||||
|
||||
@Override
|
||||
public void setLocation(float latitude, float longitude) {
|
||||
muxer.setLocation(latitude, longitude);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addTrack(Format format) throws MuxerException {
|
||||
int trackIndex = muxer.addTrack(format);
|
||||
|
|
@ -67,6 +63,12 @@ public final class TestMuxer implements Muxer, Dumper.Dumpable {
|
|||
muxer.writeSampleData(trackIndex, data, presentationTimeUs, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMetadata(Metadata metadata) {
|
||||
dumpables.add(dumper -> dumper.add("metadata", metadata));
|
||||
muxer.addMetadata(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release(boolean forCancellation) throws MuxerException {
|
||||
dumpables.add(dumper -> dumper.add("released", true));
|
||||
|
|
|
|||
Loading…
Reference in a new issue