mirror of
https://github.com/androidx/media.git
synced 2025-05-14 11:09:53 +08:00
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:
parent
7792f667d4
commit
bb0fae3ee8
@ -29,6 +29,8 @@
|
||||
* Add optional parameter to `Player.stop` to reset the player when stopping.
|
||||
* 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
|
||||
|
@ -78,6 +78,7 @@ public final class FlvExtractor implements Extractor {
|
||||
|
||||
private ExtractorOutput extractorOutput;
|
||||
private @States int state;
|
||||
private long mediaTagTimestampOffsetUs;
|
||||
private int bytesToNextTagHeader;
|
||||
private int tagType;
|
||||
private int tagDataSize;
|
||||
@ -93,6 +94,7 @@ public final class FlvExtractor implements Extractor {
|
||||
tagData = new ParsableByteArray();
|
||||
metadataReader = new ScriptTagPayloadReader();
|
||||
state = STATE_READING_FLV_HEADER;
|
||||
mediaTagTimestampOffsetUs = C.TIME_UNSET;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -134,6 +136,7 @@ public final class FlvExtractor implements Extractor {
|
||||
@Override
|
||||
public void seek(long position, long timeUs) {
|
||||
state = STATE_READING_FLV_HEADER;
|
||||
mediaTagTimestampOffsetUs = C.TIME_UNSET;
|
||||
bytesToNextTagHeader = 0;
|
||||
}
|
||||
|
||||
@ -255,11 +258,11 @@ public final class FlvExtractor implements Extractor {
|
||||
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();
|
||||
@ -288,11 +291,15 @@ public final class FlvExtractor implements Extractor {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user