Skip to content

Commit

Permalink
Further cleanup to FLV extractor
Browse files Browse the repository at this point in the history
  • Loading branch information
ojw28 committed Oct 27, 2015
1 parent f91ea90 commit 4422e8a
Show file tree
Hide file tree
Showing 6 changed files with 221 additions and 269 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ public Sample(String name, String contentId, String provider, String uri, int ty
"http://demos.webmproject.org/exoplayer/glass_vp9_vorbis.webm", PlayerActivity.TYPE_OTHER),
new Sample("Big Buck Bunny (FLV Video)",
"http://vod.leasewebcdn.com/bbb.flv?ri=1024&rs=150&start=0", PlayerActivity.TYPE_OTHER),

};

private Samples() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.util.Collections;

/**
* Parses audio tags of from an FLV stream and extracts AAC frames.
* Parses audio tags from an FLV stream and extracts AAC frames.
*/
/* package */ final class AudioTagPayloadReader extends TagPayloadReader {

Expand Down Expand Up @@ -59,29 +59,22 @@ public void seek() {

@Override
protected boolean parseHeader(ParsableByteArray data) throws UnsupportedFormatException {
// Parse audio data header, if it was not done, to extract information about the audio codec
// and audio configuration.
if (!hasParsedAudioDataHeader) {
int header = data.readUnsignedByte();
int audioFormat = (header >> 4) & 0x0F;
int sampleRateIndex = (header >> 2) & 0x03;
if (sampleRateIndex < 0 || sampleRateIndex >= AUDIO_SAMPLING_RATE_TABLE.length) {
throw new UnsupportedFormatException("Invalid sample rate for the audio track");
throw new UnsupportedFormatException("Invalid sample rate index: " + sampleRateIndex);
}
// TODO: Add support for MP3 and PCM.
if (audioFormat != AUDIO_FORMAT_AAC) {
// TODO: Adds support for MP3 and PCM
if (audioFormat != AUDIO_FORMAT_AAC) {
throw new UnsupportedFormatException("Audio format not supported: " + audioFormat);
}
throw new UnsupportedFormatException("Audio format not supported: " + audioFormat);
}
hasParsedAudioDataHeader = true;
} else {
// Skip header if it was parsed previously.
data.skipBytes(1);
}

// In all the cases we will be managing AAC format (otherwise an exception would be fired so we
// can just always return true.
return true;
}

Expand Down
Loading

0 comments on commit 4422e8a

Please sign in to comment.