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)).
|
query parameters ([#553](https://github.com/androidx/media/issues/553)).
|
||||||
* Fix `ConcurrentModificationException` in `ExperimentalBandwidthMeter`
|
* Fix `ConcurrentModificationException` in `ExperimentalBandwidthMeter`
|
||||||
([#612](https://github.com/androidx/media/issues/612)).
|
([#612](https://github.com/androidx/media/issues/612)).
|
||||||
|
* Add `MediaPeriodId` parameter to
|
||||||
|
`CompositeMediaSource.getMediaTimeForChildMediaTime`.
|
||||||
* Transformer:
|
* Transformer:
|
||||||
* Changed `frameRate` and `durationUs` parameters of
|
* Changed `frameRate` and `durationUs` parameters of
|
||||||
`SampleConsumer.queueInputBitmap` to `TimestampIterator`.
|
`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 childSourceId The unique id used to prepare the child source.
|
||||||
* @param mediaTimeMs A media time in the {@link MediaPeriod} of the child source, in
|
* @param mediaTimeMs A media time in the {@link MediaPeriod} of the child source, in
|
||||||
* milliseconds.
|
* 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
|
* @return The corresponding media time in the {@link MediaPeriod} of the composite source, in
|
||||||
* milliseconds.
|
* milliseconds.
|
||||||
*/
|
*/
|
||||||
protected long getMediaTimeForChildMediaTime(@UnknownNull T childSourceId, long mediaTimeMs) {
|
protected long getMediaTimeForChildMediaTime(
|
||||||
|
@UnknownNull T childSourceId, long mediaTimeMs, @Nullable MediaPeriodId mediaPeriodId) {
|
||||||
return mediaTimeMs;
|
return mediaTimeMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +242,7 @@ public abstract class CompositeMediaSource<T> extends BaseMediaSource {
|
|||||||
MediaLoadData mediaLoadData) {
|
MediaLoadData mediaLoadData) {
|
||||||
if (maybeUpdateEventDispatcher(windowIndex, mediaPeriodId)) {
|
if (maybeUpdateEventDispatcher(windowIndex, mediaPeriodId)) {
|
||||||
mediaSourceEventDispatcher.loadStarted(
|
mediaSourceEventDispatcher.loadStarted(
|
||||||
loadEventData, maybeUpdateMediaLoadData(mediaLoadData));
|
loadEventData, maybeUpdateMediaLoadData(mediaLoadData, mediaPeriodId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +254,7 @@ public abstract class CompositeMediaSource<T> extends BaseMediaSource {
|
|||||||
MediaLoadData mediaLoadData) {
|
MediaLoadData mediaLoadData) {
|
||||||
if (maybeUpdateEventDispatcher(windowIndex, mediaPeriodId)) {
|
if (maybeUpdateEventDispatcher(windowIndex, mediaPeriodId)) {
|
||||||
mediaSourceEventDispatcher.loadCompleted(
|
mediaSourceEventDispatcher.loadCompleted(
|
||||||
loadEventData, maybeUpdateMediaLoadData(mediaLoadData));
|
loadEventData, maybeUpdateMediaLoadData(mediaLoadData, mediaPeriodId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,7 +266,7 @@ public abstract class CompositeMediaSource<T> extends BaseMediaSource {
|
|||||||
MediaLoadData mediaLoadData) {
|
MediaLoadData mediaLoadData) {
|
||||||
if (maybeUpdateEventDispatcher(windowIndex, mediaPeriodId)) {
|
if (maybeUpdateEventDispatcher(windowIndex, mediaPeriodId)) {
|
||||||
mediaSourceEventDispatcher.loadCanceled(
|
mediaSourceEventDispatcher.loadCanceled(
|
||||||
loadEventData, maybeUpdateMediaLoadData(mediaLoadData));
|
loadEventData, maybeUpdateMediaLoadData(mediaLoadData, mediaPeriodId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,7 +280,10 @@ public abstract class CompositeMediaSource<T> extends BaseMediaSource {
|
|||||||
boolean wasCanceled) {
|
boolean wasCanceled) {
|
||||||
if (maybeUpdateEventDispatcher(windowIndex, mediaPeriodId)) {
|
if (maybeUpdateEventDispatcher(windowIndex, mediaPeriodId)) {
|
||||||
mediaSourceEventDispatcher.loadError(
|
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(
|
public void onUpstreamDiscarded(
|
||||||
int windowIndex, @Nullable MediaPeriodId mediaPeriodId, MediaLoadData mediaLoadData) {
|
int windowIndex, @Nullable MediaPeriodId mediaPeriodId, MediaLoadData mediaLoadData) {
|
||||||
if (maybeUpdateEventDispatcher(windowIndex, mediaPeriodId)) {
|
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(
|
public void onDownstreamFormatChanged(
|
||||||
int windowIndex, @Nullable MediaPeriodId mediaPeriodId, MediaLoadData mediaLoadData) {
|
int windowIndex, @Nullable MediaPeriodId mediaPeriodId, MediaLoadData mediaLoadData) {
|
||||||
if (maybeUpdateEventDispatcher(windowIndex, mediaPeriodId)) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MediaLoadData maybeUpdateMediaLoadData(MediaLoadData mediaLoadData) {
|
private MediaLoadData maybeUpdateMediaLoadData(
|
||||||
long mediaStartTimeMs = getMediaTimeForChildMediaTime(id, mediaLoadData.mediaStartTimeMs);
|
MediaLoadData mediaLoadData, @Nullable MediaPeriodId childMediaPeriodId) {
|
||||||
long mediaEndTimeMs = getMediaTimeForChildMediaTime(id, mediaLoadData.mediaEndTimeMs);
|
long mediaStartTimeMs =
|
||||||
|
getMediaTimeForChildMediaTime(id, mediaLoadData.mediaStartTimeMs, childMediaPeriodId);
|
||||||
|
long mediaEndTimeMs =
|
||||||
|
getMediaTimeForChildMediaTime(id, mediaLoadData.mediaEndTimeMs, childMediaPeriodId);
|
||||||
if (mediaStartTimeMs == mediaLoadData.mediaStartTimeMs
|
if (mediaStartTimeMs == mediaLoadData.mediaStartTimeMs
|
||||||
&& mediaEndTimeMs == mediaLoadData.mediaEndTimeMs) {
|
&& mediaEndTimeMs == mediaLoadData.mediaEndTimeMs) {
|
||||||
return mediaLoadData;
|
return mediaLoadData;
|
||||||
|
@ -205,8 +205,9 @@ public abstract class WrappingMediaSource extends CompositeMediaSource<Void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected final long getMediaTimeForChildMediaTime(Void childSourceId, long mediaTimeMs) {
|
protected final long getMediaTimeForChildMediaTime(
|
||||||
return getMediaTimeForChildMediaTime(mediaTimeMs);
|
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
|
* @param mediaTimeMs A media time in the {@link MediaPeriod} of the child source, in
|
||||||
* milliseconds.
|
* 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
|
* @return The corresponding media time in the {@link MediaPeriod} of the wrapping source, in
|
||||||
* milliseconds.
|
* milliseconds.
|
||||||
*/
|
*/
|
||||||
protected long getMediaTimeForChildMediaTime(long mediaTimeMs) {
|
protected long getMediaTimeForChildMediaTime(
|
||||||
|
long mediaTimeMs, @Nullable MediaPeriodId mediaPeriodId) {
|
||||||
return mediaTimeMs;
|
return mediaTimeMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user