mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Report output's MediaItemInfo
to EditingEndedEvent
Most of the values for the output `MediaItemInfo` will be retained from the `ExportResult`, so it's now passed to `onExportSuccess` and `onExportError` directly. For now, the duration of the ouput is recorded for metrics, and more values will be added in the following CLs. PiperOrigin-RevId: 721324689
This commit is contained in:
parent
17100259cd
commit
3f4e0bdb04
@ -161,9 +161,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
/**
|
||||
* Called when export completes with success.
|
||||
*
|
||||
* @param processedInputs The list of {@link ExportResult.ProcessedInput} instances.
|
||||
* @param exportResult The {@link ExportResult} of the export.
|
||||
*/
|
||||
public void onExportSuccess(ImmutableList<ExportResult.ProcessedInput> processedInputs) {
|
||||
public void onExportSuccess(ExportResult exportResult) {
|
||||
if (editingSession == null) {
|
||||
return;
|
||||
}
|
||||
@ -171,11 +171,13 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
createEditingEndedEventBuilder(EditingEndedEvent.FINAL_STATE_SUCCEEDED)
|
||||
.setFinalProgressPercent(SUCCESS_PROGRESS_PERCENTAGE);
|
||||
|
||||
List<MediaItemInfo> inputMediaItemInfoList = getMediaItemInfos(processedInputs);
|
||||
List<MediaItemInfo> inputMediaItemInfoList =
|
||||
getInputMediaItemInfos(exportResult.processedInputs);
|
||||
for (int i = 0; i < inputMediaItemInfoList.size(); i++) {
|
||||
MediaItemInfo inputMediaItemInfo = inputMediaItemInfoList.get(i);
|
||||
editingEndedEventBuilder.addInputMediaItemInfo(inputMediaItemInfo);
|
||||
}
|
||||
editingEndedEventBuilder.setOutputMediaItemInfo(getOutputMediaItemInfo(exportResult));
|
||||
|
||||
editingSession.reportEditingEndedEvent(editingEndedEventBuilder.build());
|
||||
editingSession.close();
|
||||
@ -187,12 +189,10 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
* @param progressPercentage The progress of the export operation in percent. Value is {@link
|
||||
* C#PERCENTAGE_UNSET} if unknown or between 0 and 100 inclusive.
|
||||
* @param exportException The {@link ExportException} describing the exception.
|
||||
* @param processedInputs The list of {@link ExportResult.ProcessedInput} instances.
|
||||
* @param exportResult The {@link ExportResult} of the export.
|
||||
*/
|
||||
public void onExportError(
|
||||
int progressPercentage,
|
||||
ExportException exportException,
|
||||
ImmutableList<ExportResult.ProcessedInput> processedInputs) {
|
||||
int progressPercentage, ExportException exportException, ExportResult exportResult) {
|
||||
if (editingSession == null) {
|
||||
return;
|
||||
}
|
||||
@ -203,11 +203,13 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
editingEndedEventBuilder.setFinalProgressPercent(progressPercentage);
|
||||
}
|
||||
|
||||
List<MediaItemInfo> inputMediaItemInfoList = getMediaItemInfos(processedInputs);
|
||||
List<MediaItemInfo> inputMediaItemInfoList =
|
||||
getInputMediaItemInfos(exportResult.processedInputs);
|
||||
for (int i = 0; i < inputMediaItemInfoList.size(); i++) {
|
||||
MediaItemInfo inputMediaItemInfo = inputMediaItemInfoList.get(i);
|
||||
editingEndedEventBuilder.addInputMediaItemInfo(inputMediaItemInfo);
|
||||
}
|
||||
editingEndedEventBuilder.setOutputMediaItemInfo(getOutputMediaItemInfo(exportResult));
|
||||
|
||||
editingSession.reportEditingEndedEvent(editingEndedEventBuilder.build());
|
||||
editingSession.close();
|
||||
@ -246,7 +248,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
return editingEndedEventBuilder;
|
||||
}
|
||||
|
||||
private static List<MediaItemInfo> getMediaItemInfos(
|
||||
private static List<MediaItemInfo> getInputMediaItemInfos(
|
||||
ImmutableList<ExportResult.ProcessedInput> processedInputs) {
|
||||
List<MediaItemInfo> mediaItemInfoList = new ArrayList<>();
|
||||
for (int i = 0; i < processedInputs.size(); i++) {
|
||||
@ -312,6 +314,14 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
return mediaItemInfoList;
|
||||
}
|
||||
|
||||
private static MediaItemInfo getOutputMediaItemInfo(ExportResult exportResult) {
|
||||
MediaItemInfo.Builder mediaItemInfoBuilder = new MediaItemInfo.Builder();
|
||||
if (exportResult.durationMs != C.TIME_UNSET) {
|
||||
mediaItemInfoBuilder.setDurationMillis(exportResult.durationMs);
|
||||
}
|
||||
return mediaItemInfoBuilder.build();
|
||||
}
|
||||
|
||||
private static int getEditingEndedEventErrorCode(@ExportException.ErrorCode int errorCode) {
|
||||
return ERROR_CODE_CONVERSION_MAP.get(errorCode, EditingEndedEvent.ERROR_CODE_NONE);
|
||||
}
|
||||
|
@ -1619,7 +1619,7 @@ public final class Transformer {
|
||||
listener -> listener.onCompleted(checkNotNull(composition), exportResult));
|
||||
listeners.flushEvents();
|
||||
if (canCollectEditingMetrics()) {
|
||||
checkNotNull(editingMetricsCollector).onExportSuccess(exportResult.processedInputs);
|
||||
checkNotNull(editingMetricsCollector).onExportSuccess(exportResult);
|
||||
}
|
||||
transformerState = TRANSFORMER_STATE_PROCESS_FULL_INPUT;
|
||||
}
|
||||
@ -1639,7 +1639,7 @@ public final class Transformer {
|
||||
? progressHolder.progress
|
||||
: C.PERCENTAGE_UNSET;
|
||||
checkNotNull(editingMetricsCollector)
|
||||
.onExportError(progressPercentage, exception, exportResult.processedInputs);
|
||||
.onExportError(progressPercentage, exception, exportResult);
|
||||
}
|
||||
transformerState = TRANSFORMER_STATE_PROCESS_FULL_INPUT;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user