mirror of
https://github.com/androidx/media.git
synced 2025-04-29 22:36:54 +08:00
Use ReorderingBufferQueue
in H.262 UserDataReader
Issue: androidx/media#2372 PiperOrigin-RevId: 752721649
This commit is contained in:
parent
49064c4b82
commit
e5d3236649
@ -45,6 +45,8 @@
|
||||
* Fix playback getting stuck when switching from a stream with a subtitle
|
||||
error to a live stream with an empty subtitle track
|
||||
([#2328](https://github.com/androidx/media/issues/2328)).
|
||||
* Fix garbled CEA-608 subtitles when playing H.262 streams containing
|
||||
B-frames ([#2372](https://github.com/androidx/media/issues/2372)).
|
||||
* Metadata:
|
||||
* Image:
|
||||
* DataSource:
|
||||
|
@ -21,6 +21,7 @@ import androidx.media3.common.Format;
|
||||
import androidx.media3.common.MimeTypes;
|
||||
import androidx.media3.common.util.Assertions;
|
||||
import androidx.media3.common.util.ParsableByteArray;
|
||||
import androidx.media3.container.ReorderingBufferQueue;
|
||||
import androidx.media3.extractor.CeaUtil;
|
||||
import androidx.media3.extractor.ExtractorOutput;
|
||||
import androidx.media3.extractor.TrackOutput;
|
||||
@ -34,11 +35,19 @@ import java.util.List;
|
||||
private final List<Format> closedCaptionFormats;
|
||||
private final String containerMimeType;
|
||||
private final TrackOutput[] outputs;
|
||||
private final ReorderingBufferQueue reorderingBufferQueue;
|
||||
|
||||
public UserDataReader(List<Format> closedCaptionFormats, String containerMimeType) {
|
||||
this.closedCaptionFormats = closedCaptionFormats;
|
||||
this.containerMimeType = containerMimeType;
|
||||
outputs = new TrackOutput[closedCaptionFormats.size()];
|
||||
reorderingBufferQueue =
|
||||
new ReorderingBufferQueue(
|
||||
(presentationTimeUs, seiBuffer) ->
|
||||
CeaUtil.consumeCcData(presentationTimeUs, seiBuffer, outputs));
|
||||
// H.262 doesn't provide a convenient 'max reordering queue size' value, so we hard-code 3
|
||||
// as it seems unlikely to see more consecutive B-frames than this.
|
||||
reorderingBufferQueue.setMaxSize(3);
|
||||
}
|
||||
|
||||
public void createTracks(
|
||||
@ -76,7 +85,7 @@ import java.util.List;
|
||||
if (userDataStartCode == USER_DATA_START_CODE
|
||||
&& userDataIdentifier == CeaUtil.USER_DATA_IDENTIFIER_GA94
|
||||
&& userDataTypeCode == CeaUtil.USER_DATA_TYPE_CODE_MPEG_CC) {
|
||||
CeaUtil.consumeCcData(pesTimeUs, userDataPayload, outputs);
|
||||
reorderingBufferQueue.add(pesTimeUs, userDataPayload);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user