mirror of
https://github.com/androidx/media.git
synced 2025-05-09 16:40:55 +08:00
Add MediaPeriodId to CompositeMediaSource.getMediaTimeForChildMediaTime
This callback asks to correct the media time in a composition, but doesn't provide the MediaPeriodId as the necessary context to do this. PiperOrigin-RevId: 563699344
This commit is contained in:
parent
dd2a373636
commit
0c2aba9ce1
@ -16,6 +16,8 @@
|
||||
query parameters ([#553](https://github.com/androidx/media/issues/553)).
|
||||
* Fix `ConcurrentModificationException` in `ExperimentalBandwidthMeter`
|
||||
([#612](https://github.com/androidx/media/issues/612)).
|
||||
* Add `MediaPeriodId` parameter to
|
||||
`CompositeMediaSource.getMediaTimeForChildMediaTime`.
|
||||
* Transformer:
|
||||
* Changed `frameRate` and `durationUs` parameters of
|
||||
`SampleConsumer.queueInputBitmap` to `TimestampIterator`.
|
||||
|
@ -193,10 +193,13 @@ public abstract class CompositeMediaSource<T> extends BaseMediaSource {
|
||||
* @param childSourceId The unique id used to prepare the child source.
|
||||
* @param mediaTimeMs A media time in the {@link MediaPeriod} of the child source, in
|
||||
* milliseconds.
|
||||
* @param mediaPeriodId The {@link MediaPeriodId} of the {@link MediaPeriod} of the child source,
|
||||
* or null if the time does not relate to a specific {@link MediaPeriod}.
|
||||
* @return The corresponding media time in the {@link MediaPeriod} of the composite source, in
|
||||
* milliseconds.
|
||||
*/
|
||||
protected long getMediaTimeForChildMediaTime(@UnknownNull T childSourceId, long mediaTimeMs) {
|
||||
protected long getMediaTimeForChildMediaTime(
|
||||
@UnknownNull T childSourceId, long mediaTimeMs, @Nullable MediaPeriodId mediaPeriodId) {
|
||||
return mediaTimeMs;
|
||||
}
|
||||
|
||||
@ -239,7 +242,7 @@ public abstract class CompositeMediaSource<T> extends BaseMediaSource {
|
||||
MediaLoadData mediaLoadData) {
|
||||
if (maybeUpdateEventDispatcher(windowIndex, mediaPeriodId)) {
|
||||
mediaSourceEventDispatcher.loadStarted(
|
||||
loadEventData, maybeUpdateMediaLoadData(mediaLoadData));
|
||||
loadEventData, maybeUpdateMediaLoadData(mediaLoadData, mediaPeriodId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -251,7 +254,7 @@ public abstract class CompositeMediaSource<T> extends BaseMediaSource {
|
||||
MediaLoadData mediaLoadData) {
|
||||
if (maybeUpdateEventDispatcher(windowIndex, mediaPeriodId)) {
|
||||
mediaSourceEventDispatcher.loadCompleted(
|
||||
loadEventData, maybeUpdateMediaLoadData(mediaLoadData));
|
||||
loadEventData, maybeUpdateMediaLoadData(mediaLoadData, mediaPeriodId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -263,7 +266,7 @@ public abstract class CompositeMediaSource<T> extends BaseMediaSource {
|
||||
MediaLoadData mediaLoadData) {
|
||||
if (maybeUpdateEventDispatcher(windowIndex, mediaPeriodId)) {
|
||||
mediaSourceEventDispatcher.loadCanceled(
|
||||
loadEventData, maybeUpdateMediaLoadData(mediaLoadData));
|
||||
loadEventData, maybeUpdateMediaLoadData(mediaLoadData, mediaPeriodId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -277,7 +280,10 @@ public abstract class CompositeMediaSource<T> extends BaseMediaSource {
|
||||
boolean wasCanceled) {
|
||||
if (maybeUpdateEventDispatcher(windowIndex, mediaPeriodId)) {
|
||||
mediaSourceEventDispatcher.loadError(
|
||||
loadEventData, maybeUpdateMediaLoadData(mediaLoadData), error, wasCanceled);
|
||||
loadEventData,
|
||||
maybeUpdateMediaLoadData(mediaLoadData, mediaPeriodId),
|
||||
error,
|
||||
wasCanceled);
|
||||
}
|
||||
}
|
||||
|
||||
@ -285,7 +291,8 @@ public abstract class CompositeMediaSource<T> extends BaseMediaSource {
|
||||
public void onUpstreamDiscarded(
|
||||
int windowIndex, @Nullable MediaPeriodId mediaPeriodId, MediaLoadData mediaLoadData) {
|
||||
if (maybeUpdateEventDispatcher(windowIndex, mediaPeriodId)) {
|
||||
mediaSourceEventDispatcher.upstreamDiscarded(maybeUpdateMediaLoadData(mediaLoadData));
|
||||
mediaSourceEventDispatcher.upstreamDiscarded(
|
||||
maybeUpdateMediaLoadData(mediaLoadData, mediaPeriodId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -293,7 +300,8 @@ public abstract class CompositeMediaSource<T> extends BaseMediaSource {
|
||||
public void onDownstreamFormatChanged(
|
||||
int windowIndex, @Nullable MediaPeriodId mediaPeriodId, MediaLoadData mediaLoadData) {
|
||||
if (maybeUpdateEventDispatcher(windowIndex, mediaPeriodId)) {
|
||||
mediaSourceEventDispatcher.downstreamFormatChanged(maybeUpdateMediaLoadData(mediaLoadData));
|
||||
mediaSourceEventDispatcher.downstreamFormatChanged(
|
||||
maybeUpdateMediaLoadData(mediaLoadData, mediaPeriodId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -366,9 +374,12 @@ public abstract class CompositeMediaSource<T> extends BaseMediaSource {
|
||||
return true;
|
||||
}
|
||||
|
||||
private MediaLoadData maybeUpdateMediaLoadData(MediaLoadData mediaLoadData) {
|
||||
long mediaStartTimeMs = getMediaTimeForChildMediaTime(id, mediaLoadData.mediaStartTimeMs);
|
||||
long mediaEndTimeMs = getMediaTimeForChildMediaTime(id, mediaLoadData.mediaEndTimeMs);
|
||||
private MediaLoadData maybeUpdateMediaLoadData(
|
||||
MediaLoadData mediaLoadData, @Nullable MediaPeriodId childMediaPeriodId) {
|
||||
long mediaStartTimeMs =
|
||||
getMediaTimeForChildMediaTime(id, mediaLoadData.mediaStartTimeMs, childMediaPeriodId);
|
||||
long mediaEndTimeMs =
|
||||
getMediaTimeForChildMediaTime(id, mediaLoadData.mediaEndTimeMs, childMediaPeriodId);
|
||||
if (mediaStartTimeMs == mediaLoadData.mediaStartTimeMs
|
||||
&& mediaEndTimeMs == mediaLoadData.mediaEndTimeMs) {
|
||||
return mediaLoadData;
|
||||
|
@ -205,8 +205,9 @@ public abstract class WrappingMediaSource extends CompositeMediaSource<Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final long getMediaTimeForChildMediaTime(Void childSourceId, long mediaTimeMs) {
|
||||
return getMediaTimeForChildMediaTime(mediaTimeMs);
|
||||
protected final long getMediaTimeForChildMediaTime(
|
||||
Void childSourceId, long mediaTimeMs, @Nullable MediaPeriodId mediaPeriodId) {
|
||||
return getMediaTimeForChildMediaTime(mediaTimeMs, mediaPeriodId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -216,10 +217,13 @@ public abstract class WrappingMediaSource extends CompositeMediaSource<Void> {
|
||||
*
|
||||
* @param mediaTimeMs A media time in the {@link MediaPeriod} of the child source, in
|
||||
* milliseconds.
|
||||
* @param mediaPeriodId The {@link MediaPeriodId} of the {@link MediaPeriod} of the child source,
|
||||
* or null if the time does not relate to a specific {@link MediaPeriod}.
|
||||
* @return The corresponding media time in the {@link MediaPeriod} of the wrapping source, in
|
||||
* milliseconds.
|
||||
*/
|
||||
protected long getMediaTimeForChildMediaTime(long mediaTimeMs) {
|
||||
protected long getMediaTimeForChildMediaTime(
|
||||
long mediaTimeMs, @Nullable MediaPeriodId mediaPeriodId) {
|
||||
return mediaTimeMs;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user