Skip to content

Commit

Permalink
Fix playback of FLV live streams with no audio track
Browse files Browse the repository at this point in the history
Issue: #3188

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177811487
  • Loading branch information
ojw28 committed Dec 12, 2017
1 parent bc7bfb4 commit 13a7037
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
([#2980](https://github.com/google/ExoPlayer/issues/2980)).
* Fix handling of playback parameters changes while paused when followed by a
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
implementations.
* CEA-608: Fix handling of row count changes in roll-up mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public Extractor[] createExtractors() {

private ExtractorOutput extractorOutput;
private @States int state;
private long mediaTagTimestampOffsetUs;
private int bytesToNextTagHeader;
private int tagType;
private int tagDataSize;
Expand All @@ -93,6 +94,7 @@ public FlvExtractor() {
tagData = new ParsableByteArray();
metadataReader = new ScriptTagPayloadReader();
state = STATE_READING_FLV_HEADER;
mediaTagTimestampOffsetUs = C.TIME_UNSET;
}

@Override
Expand Down Expand Up @@ -134,6 +136,7 @@ public void init(ExtractorOutput output) {
@Override
public void seek(long position, long timeUs) {
state = STATE_READING_FLV_HEADER;
mediaTagTimestampOffsetUs = C.TIME_UNSET;
bytesToNextTagHeader = 0;
}

Expand Down Expand Up @@ -255,11 +258,11 @@ private boolean readTagHeader(ExtractorInput input) throws IOException, Interrup
private boolean readTagData(ExtractorInput input) throws IOException, InterruptedException {
boolean wasConsumed = true;
if (tagType == TAG_TYPE_AUDIO && audioReader != null) {
ensureOutputSeekMap();
audioReader.consume(prepareTagData(input), tagTimestampUs);
ensureReadyForMediaOutput();
audioReader.consume(prepareTagData(input), mediaTagTimestampOffsetUs + tagTimestampUs);
} else if (tagType == TAG_TYPE_VIDEO && videoReader != null) {
ensureOutputSeekMap();
videoReader.consume(prepareTagData(input), tagTimestampUs);
ensureReadyForMediaOutput();
videoReader.consume(prepareTagData(input), mediaTagTimestampOffsetUs + tagTimestampUs);
} else if (tagType == TAG_TYPE_SCRIPT_DATA && !outputSeekMap) {
metadataReader.consume(prepareTagData(input), tagTimestampUs);
long durationUs = metadataReader.getDurationUs();
Expand Down Expand Up @@ -288,11 +291,15 @@ private ParsableByteArray prepareTagData(ExtractorInput input) throws IOExceptio
return tagData;
}

private void ensureOutputSeekMap() {
private void ensureReadyForMediaOutput() {
if (!outputSeekMap) {
extractorOutput.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
outputSeekMap = true;
}
if (mediaTagTimestampOffsetUs == C.TIME_UNSET) {
mediaTagTimestampOffsetUs =
metadataReader.getDurationUs() == C.TIME_UNSET ? -tagTimestampUs : 0;
}
}

}

0 comments on commit 13a7037

Please sign in to comment.