mirror of
https://github.com/samsonjs/media.git
synced 2026-04-04 11:05:47 +00:00
Fix miscellaneous consistency/formatting things.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=126631393
This commit is contained in:
parent
f0f25aef83
commit
7b673fe432
10 changed files with 41 additions and 41 deletions
|
|
@ -35,13 +35,14 @@ import java.util.Arrays;
|
|||
* Facilitates the extraction of data from the FLAC container format.
|
||||
*/
|
||||
public final class FlacExtractor implements Extractor {
|
||||
|
||||
/**
|
||||
* FLAC signature: first 4 is the signature word, second 4 is the sizeof STREAMINFO. 0x22 is the
|
||||
* mandatory STREAMINFO.
|
||||
*/
|
||||
private static final byte[] FLAC_SIGNATURE = {'f', 'L', 'a', 'C', 0, 0, 0, 0x22};
|
||||
|
||||
private ExtractorOutput output;
|
||||
private ExtractorOutput extractorOutput;
|
||||
private TrackOutput trackOutput;
|
||||
|
||||
private FlacJni decoder;
|
||||
|
|
@ -53,9 +54,9 @@ public final class FlacExtractor implements Extractor {
|
|||
|
||||
@Override
|
||||
public void init(ExtractorOutput output) {
|
||||
this.output = output;
|
||||
this.trackOutput = output.track(0);
|
||||
output.endTracks();
|
||||
extractorOutput = output;
|
||||
trackOutput = extractorOutput.track(0);
|
||||
extractorOutput.endTracks();
|
||||
|
||||
try {
|
||||
decoder = new FlacJni();
|
||||
|
|
@ -90,7 +91,7 @@ public final class FlacExtractor implements Extractor {
|
|||
}
|
||||
metadataParsed = true;
|
||||
|
||||
output.seekMap(new SeekMap() {
|
||||
extractorOutput.seekMap(new SeekMap() {
|
||||
final boolean isSeekable = decoder.getSeekPosition(0) != -1;
|
||||
final long durationUs = streamInfo.durationUs();
|
||||
|
||||
|
|
|
|||
|
|
@ -42,13 +42,6 @@ public interface Extractor {
|
|||
*/
|
||||
int RESULT_END_OF_INPUT = C.RESULT_END_OF_INPUT;
|
||||
|
||||
/**
|
||||
* Initializes the extractor with an {@link ExtractorOutput}.
|
||||
*
|
||||
* @param output An {@link ExtractorOutput} to receive extracted data.
|
||||
*/
|
||||
void init(ExtractorOutput output);
|
||||
|
||||
/**
|
||||
* Returns whether this extractor can extract samples from the {@link ExtractorInput}, which must
|
||||
* provide data from the start of the stream.
|
||||
|
|
@ -63,6 +56,13 @@ public interface Extractor {
|
|||
*/
|
||||
boolean sniff(ExtractorInput input) throws IOException, InterruptedException;
|
||||
|
||||
/**
|
||||
* Initializes the extractor with an {@link ExtractorOutput}.
|
||||
*
|
||||
* @param output An {@link ExtractorOutput} to receive extracted data.
|
||||
*/
|
||||
void init(ExtractorOutput output);
|
||||
|
||||
/**
|
||||
* Extracts data read from a provided {@link ExtractorInput}.
|
||||
* <p>
|
||||
|
|
|
|||
|
|
@ -215,77 +215,77 @@ public final class ExtractorSampleSource implements SampleSource, ExtractorOutpu
|
|||
try {
|
||||
extractorClasses.add(
|
||||
Class.forName("com.google.android.exoplayer.extractor.mkv.MatroskaExtractor")
|
||||
.asSubclass(Extractor.class));
|
||||
.asSubclass(Extractor.class));
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Extractor not found.
|
||||
}
|
||||
try {
|
||||
extractorClasses.add(
|
||||
Class.forName("com.google.android.exoplayer.extractor.mp4.FragmentedMp4Extractor")
|
||||
.asSubclass(Extractor.class));
|
||||
.asSubclass(Extractor.class));
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Extractor not found.
|
||||
}
|
||||
try {
|
||||
extractorClasses.add(
|
||||
Class.forName("com.google.android.exoplayer.extractor.mp4.Mp4Extractor")
|
||||
.asSubclass(Extractor.class));
|
||||
.asSubclass(Extractor.class));
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Extractor not found.
|
||||
}
|
||||
try {
|
||||
extractorClasses.add(
|
||||
Class.forName("com.google.android.exoplayer.extractor.mp3.Mp3Extractor")
|
||||
.asSubclass(Extractor.class));
|
||||
.asSubclass(Extractor.class));
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Extractor not found.
|
||||
}
|
||||
try {
|
||||
extractorClasses.add(
|
||||
Class.forName("com.google.android.exoplayer.extractor.ts.AdtsExtractor")
|
||||
.asSubclass(Extractor.class));
|
||||
.asSubclass(Extractor.class));
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Extractor not found.
|
||||
}
|
||||
try {
|
||||
extractorClasses.add(
|
||||
Class.forName("com.google.android.exoplayer.extractor.ts.TsExtractor")
|
||||
.asSubclass(Extractor.class));
|
||||
.asSubclass(Extractor.class));
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Extractor not found.
|
||||
}
|
||||
try {
|
||||
extractorClasses.add(
|
||||
Class.forName("com.google.android.exoplayer.extractor.flv.FlvExtractor")
|
||||
.asSubclass(Extractor.class));
|
||||
.asSubclass(Extractor.class));
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Extractor not found.
|
||||
}
|
||||
try {
|
||||
extractorClasses.add(
|
||||
Class.forName("com.google.android.exoplayer.extractor.ogg.OggExtractor")
|
||||
.asSubclass(Extractor.class));
|
||||
.asSubclass(Extractor.class));
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Extractor not found.
|
||||
}
|
||||
try {
|
||||
extractorClasses.add(
|
||||
Class.forName("com.google.android.exoplayer.extractor.ts.PsExtractor")
|
||||
.asSubclass(Extractor.class));
|
||||
.asSubclass(Extractor.class));
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Extractor not found.
|
||||
}
|
||||
try {
|
||||
extractorClasses.add(
|
||||
Class.forName("com.google.android.exoplayer.extractor.wav.WavExtractor")
|
||||
.asSubclass(Extractor.class));
|
||||
.asSubclass(Extractor.class));
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Extractor not found.
|
||||
}
|
||||
try {
|
||||
extractorClasses.add(
|
||||
Class.forName("com.google.android.exoplayer.ext.flac.FlacExtractor")
|
||||
.asSubclass(Extractor.class));
|
||||
.asSubclass(Extractor.class));
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Extractor not found.
|
||||
}
|
||||
|
|
@ -788,6 +788,7 @@ public final class ExtractorSampleSource implements SampleSource, ExtractorOutpu
|
|||
* later calls.
|
||||
*
|
||||
* @param input The {@link ExtractorInput} from which data should be read.
|
||||
* @return An initialized extractor for reading {@code input}.
|
||||
* @throws UnrecognizedInputFormatException Thrown if the input format could not be detected.
|
||||
* @throws IOException Thrown if the input could not be read.
|
||||
* @throws InterruptedException Thrown if the thread was interrupted.
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Holder for gapless playback information
|
||||
* Holder for gapless playback information.
|
||||
*/
|
||||
public final class GaplessInfoHolder {
|
||||
|
||||
|
|
|
|||
|
|
@ -773,7 +773,7 @@ public final class MatroskaExtractor implements Extractor {
|
|||
}
|
||||
// The first read value is the first size. Later values are signed offsets.
|
||||
if (sampleIndex > 0) {
|
||||
readValue -= (1L << 6 + i * 7) - 1;
|
||||
readValue -= (1L << (6 + i * 7)) - 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,8 +97,8 @@ public final class Mp3Extractor implements Extractor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void init(ExtractorOutput extractorOutput) {
|
||||
this.extractorOutput = extractorOutput;
|
||||
public void init(ExtractorOutput output) {
|
||||
extractorOutput = output;
|
||||
trackOutput = extractorOutput.track(0);
|
||||
extractorOutput.endTracks();
|
||||
}
|
||||
|
|
@ -106,8 +106,8 @@ public final class Mp3Extractor implements Extractor {
|
|||
@Override
|
||||
public void seek(long position) {
|
||||
synchronizedHeaderData = 0;
|
||||
samplesRead = 0;
|
||||
basisTimeUs = -1;
|
||||
samplesRead = 0;
|
||||
sampleBytesRemaining = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1034,7 +1034,7 @@ public final class FragmentedMp4Extractor implements Extractor {
|
|||
|| atom == Atom.TYPE_tfhd || atom == Atom.TYPE_tkhd || atom == Atom.TYPE_trex
|
||||
|| atom == Atom.TYPE_trun || atom == Atom.TYPE_pssh || atom == Atom.TYPE_saiz
|
||||
|| atom == Atom.TYPE_saio || atom == Atom.TYPE_senc || atom == Atom.TYPE_uuid
|
||||
|| atom == Atom.TYPE_sbgp || atom == Atom.TYPE_sgpd || atom == Atom.TYPE_elst
|
||||
|| atom == Atom.TYPE_sbgp || atom == Atom.TYPE_sgpd || atom == Atom.TYPE_elst
|
||||
|| atom == Atom.TYPE_mehd;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import java.io.IOException;
|
|||
public class OggExtractor implements Extractor {
|
||||
|
||||
private static final int MAX_VERIFICATION_BYTES = 8;
|
||||
|
||||
|
||||
private StreamReader streamReader;
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ import java.io.IOException;
|
|||
|
||||
/**
|
||||
* Resets the state of the {@link StreamReader}.
|
||||
*
|
||||
* @param headerData Resets parsed header data too.
|
||||
*/
|
||||
protected void reset(boolean headerData) {
|
||||
|
|
@ -174,9 +175,8 @@ import java.io.IOException;
|
|||
/**
|
||||
* Converts granule value to time.
|
||||
*
|
||||
* @param granule
|
||||
* granule value.
|
||||
* @return Returns time in milliseconds.
|
||||
* @param granule The granule value.
|
||||
* @return Time in milliseconds.
|
||||
*/
|
||||
protected long convertGranuleToTime(long granule) {
|
||||
return (granule * C.MICROS_PER_SECOND) / sampleRate;
|
||||
|
|
@ -185,9 +185,8 @@ import java.io.IOException;
|
|||
/**
|
||||
* Converts time value to granule.
|
||||
*
|
||||
* @param timeUs
|
||||
* Time in milliseconds.
|
||||
* @return Granule value.
|
||||
* @param timeUs Time in milliseconds.
|
||||
* @return The granule value.
|
||||
*/
|
||||
protected long convertTimeToGranule(long timeUs) {
|
||||
return (sampleRate * timeUs) / C.MICROS_PER_SECOND;
|
||||
|
|
@ -197,8 +196,7 @@ import java.io.IOException;
|
|||
* Prepares payload data in the packet for submitting to TrackOutput and returns number of
|
||||
* granules in the packet.
|
||||
*
|
||||
* @param packet
|
||||
* Ogg payload data packet
|
||||
* @param packet Ogg payload data packet.
|
||||
* @return Number of granules in the packet or -1 if the packet doesn't contain payload data.
|
||||
*/
|
||||
protected abstract long preparePayload(ParsableByteArray packet);
|
||||
|
|
@ -209,7 +207,7 @@ import java.io.IOException;
|
|||
* @param packet An ogg packet.
|
||||
* @param position Position of the given header packet.
|
||||
* @param setupData Setup data to be filled.
|
||||
* @return Return true if the packet contains header data.
|
||||
* @return True if the packet contains header data. False otherwise.
|
||||
*/
|
||||
protected abstract boolean readHeaders(ParsableByteArray packet, long position,
|
||||
SetupData setupData) throws IOException, InterruptedException;
|
||||
|
|
@ -223,7 +221,7 @@ import java.io.IOException;
|
|||
this.currentGranule = currentGranule;
|
||||
}
|
||||
|
||||
private class UnseekableOggSeeker implements OggSeeker {
|
||||
private static final class UnseekableOggSeeker implements OggSeeker {
|
||||
@Override
|
||||
public long read(ExtractorInput input) throws IOException, InterruptedException {
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ import java.util.ArrayList;
|
|||
}
|
||||
previousPacketBlockSize = 0;
|
||||
seenFirstAudioPacket = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSeekEnd(long currentGranule) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue