Fix playback of FLV live streams with no audio track

Issue: #3188

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177811487
This commit is contained in:
olly 2017-12-04 07:35:50 -08:00 committed by Oliver Woodman
parent 7792f667d4
commit bb0fae3ee8
2 changed files with 14 additions and 5 deletions

View File

@ -29,6 +29,8 @@
* Add optional parameter to `Player.stop` to reset the player when stopping. * Add optional parameter to `Player.stop` to reset the player when stopping.
* Fix handling of playback parameters changes while paused when followed by a * Fix handling of playback parameters changes while paused when followed by a
seek. seek.
* Fix playback of live FLV streams that do not contain an audio track
([#3188](https://github.com/google/ExoPlayer/issues/3188)).
* Use the same listener `MediaSourceEventListener` for all MediaSource * Use the same listener `MediaSourceEventListener` for all MediaSource
implementations. implementations.
* CEA-608: Fix handling of row count changes in roll-up mode * CEA-608: Fix handling of row count changes in roll-up mode

View File

@ -78,6 +78,7 @@ public final class FlvExtractor implements Extractor {
private ExtractorOutput extractorOutput; private ExtractorOutput extractorOutput;
private @States int state; private @States int state;
private long mediaTagTimestampOffsetUs;
private int bytesToNextTagHeader; private int bytesToNextTagHeader;
private int tagType; private int tagType;
private int tagDataSize; private int tagDataSize;
@ -93,6 +94,7 @@ public final class FlvExtractor implements Extractor {
tagData = new ParsableByteArray(); tagData = new ParsableByteArray();
metadataReader = new ScriptTagPayloadReader(); metadataReader = new ScriptTagPayloadReader();
state = STATE_READING_FLV_HEADER; state = STATE_READING_FLV_HEADER;
mediaTagTimestampOffsetUs = C.TIME_UNSET;
} }
@Override @Override
@ -134,6 +136,7 @@ public final class FlvExtractor implements Extractor {
@Override @Override
public void seek(long position, long timeUs) { public void seek(long position, long timeUs) {
state = STATE_READING_FLV_HEADER; state = STATE_READING_FLV_HEADER;
mediaTagTimestampOffsetUs = C.TIME_UNSET;
bytesToNextTagHeader = 0; bytesToNextTagHeader = 0;
} }
@ -255,11 +258,11 @@ public final class FlvExtractor implements Extractor {
private boolean readTagData(ExtractorInput input) throws IOException, InterruptedException { private boolean readTagData(ExtractorInput input) throws IOException, InterruptedException {
boolean wasConsumed = true; boolean wasConsumed = true;
if (tagType == TAG_TYPE_AUDIO && audioReader != null) { if (tagType == TAG_TYPE_AUDIO && audioReader != null) {
ensureOutputSeekMap(); ensureReadyForMediaOutput();
audioReader.consume(prepareTagData(input), tagTimestampUs); audioReader.consume(prepareTagData(input), mediaTagTimestampOffsetUs + tagTimestampUs);
} else if (tagType == TAG_TYPE_VIDEO && videoReader != null) { } else if (tagType == TAG_TYPE_VIDEO && videoReader != null) {
ensureOutputSeekMap(); ensureReadyForMediaOutput();
videoReader.consume(prepareTagData(input), tagTimestampUs); videoReader.consume(prepareTagData(input), mediaTagTimestampOffsetUs + tagTimestampUs);
} else if (tagType == TAG_TYPE_SCRIPT_DATA && !outputSeekMap) { } else if (tagType == TAG_TYPE_SCRIPT_DATA && !outputSeekMap) {
metadataReader.consume(prepareTagData(input), tagTimestampUs); metadataReader.consume(prepareTagData(input), tagTimestampUs);
long durationUs = metadataReader.getDurationUs(); long durationUs = metadataReader.getDurationUs();
@ -288,11 +291,15 @@ public final class FlvExtractor implements Extractor {
return tagData; return tagData;
} }
private void ensureOutputSeekMap() { private void ensureReadyForMediaOutput() {
if (!outputSeekMap) { if (!outputSeekMap) {
extractorOutput.seekMap(new SeekMap.Unseekable(C.TIME_UNSET)); extractorOutput.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
outputSeekMap = true; outputSeekMap = true;
} }
if (mediaTagTimestampOffsetUs == C.TIME_UNSET) {
mediaTagTimestampOffsetUs =
metadataReader.getDurationUs() == C.TIME_UNSET ? -tagTimestampUs : 0;
}
} }
} }