mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Report exporter and muxer names metrics to EditingEndedEvent
Added reporting 2 values from Transformer: - `exporterName`: name of the package calling for export. Example: "androidx.media3.transformer". - `muxerName`: name of the muxer used for the export operation. Example: "androidx.media3.muxer". PiperOrigin-RevId: 714000672
This commit is contained in:
parent
f6eb2e6dd5
commit
72a71e8b9c
@ -100,6 +100,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final int SUCCESS_PROGRESS_PERCENTAGE = 100;
|
private static final int SUCCESS_PROGRESS_PERCENTAGE = 100;
|
||||||
|
private final String exporterName;
|
||||||
|
@Nullable private final String muxerName;
|
||||||
private @MonotonicNonNull EditingSession editingSession;
|
private @MonotonicNonNull EditingSession editingSession;
|
||||||
private long startTimeMs;
|
private long startTimeMs;
|
||||||
|
|
||||||
@ -108,9 +110,16 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
*
|
*
|
||||||
* <p>A new instance must be created before starting a new export.
|
* <p>A new instance must be created before starting a new export.
|
||||||
*
|
*
|
||||||
|
* <p>Both {@code exporterName} and {@code muxerName} should follow the format
|
||||||
|
* "<packageName>:<version>".
|
||||||
|
*
|
||||||
* @param context The {@link Context}.
|
* @param context The {@link Context}.
|
||||||
|
* @param exporterName Java package name and version of the library or application implementing
|
||||||
|
* the editing operation.
|
||||||
|
* @param muxerName Java package name and version of the library or application that writes to the
|
||||||
|
* output file.
|
||||||
*/
|
*/
|
||||||
public EditingMetricsCollector(Context context) {
|
public EditingMetricsCollector(Context context, String exporterName, @Nullable String muxerName) {
|
||||||
@Nullable
|
@Nullable
|
||||||
MediaMetricsManager mediaMetricsManager =
|
MediaMetricsManager mediaMetricsManager =
|
||||||
(MediaMetricsManager) context.getSystemService(Context.MEDIA_METRICS_SERVICE);
|
(MediaMetricsManager) context.getSystemService(Context.MEDIA_METRICS_SERVICE);
|
||||||
@ -118,6 +127,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
editingSession = checkNotNull(mediaMetricsManager.createEditingSession());
|
editingSession = checkNotNull(mediaMetricsManager.createEditingSession());
|
||||||
startTimeMs = SystemClock.DEFAULT.elapsedRealtime();
|
startTimeMs = SystemClock.DEFAULT.elapsedRealtime();
|
||||||
}
|
}
|
||||||
|
this.exporterName = exporterName;
|
||||||
|
this.muxerName = muxerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called when export completes with success. */
|
/** Called when export completes with success. */
|
||||||
@ -174,8 +185,14 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
|
|
||||||
private EditingEndedEvent.Builder createEditingEndedEventBuilder(int finalState) {
|
private EditingEndedEvent.Builder createEditingEndedEventBuilder(int finalState) {
|
||||||
long endTimeMs = SystemClock.DEFAULT.elapsedRealtime();
|
long endTimeMs = SystemClock.DEFAULT.elapsedRealtime();
|
||||||
return new EditingEndedEvent.Builder(finalState)
|
EditingEndedEvent.Builder editingEndedEventBuilder =
|
||||||
.setTimeSinceCreatedMillis(endTimeMs - startTimeMs);
|
new EditingEndedEvent.Builder(finalState)
|
||||||
|
.setTimeSinceCreatedMillis(endTimeMs - startTimeMs)
|
||||||
|
.setExporterName(exporterName);
|
||||||
|
if (muxerName != null) {
|
||||||
|
editingEndedEventBuilder.setMuxerName(muxerName);
|
||||||
|
}
|
||||||
|
return editingEndedEventBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getEditingEndedEventErrorCode(@ExportException.ErrorCode int errorCode) {
|
private static int getEditingEndedEventErrorCode(@ExportException.ErrorCode int errorCode) {
|
||||||
|
@ -96,6 +96,8 @@ import java.util.Locale;
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final String MUXER_STOPPING_FAILED_ERROR_MESSAGE = "Failed to stop the MediaMuxer";
|
public static final String MUXER_STOPPING_FAILED_ERROR_MESSAGE = "Failed to stop the MediaMuxer";
|
||||||
|
public static final String MUXER_NAME =
|
||||||
|
checkNotNull(MediaMuxer.class.getPackage()).getName() + ":" + SDK_INT;
|
||||||
|
|
||||||
// MediaMuxer supported sample formats are documented in MediaMuxer.addTrack(MediaFormat).
|
// MediaMuxer supported sample formats are documented in MediaMuxer.addTrack(MediaFormat).
|
||||||
private static final ImmutableList<String> SUPPORTED_VIDEO_SAMPLE_MIME_TYPES =
|
private static final ImmutableList<String> SUPPORTED_VIDEO_SAMPLE_MIME_TYPES =
|
||||||
|
@ -22,6 +22,7 @@ import android.media.MediaCodec.BufferInfo;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.media3.common.C;
|
import androidx.media3.common.C;
|
||||||
import androidx.media3.common.Format;
|
import androidx.media3.common.Format;
|
||||||
|
import androidx.media3.common.MediaLibraryInfo;
|
||||||
import androidx.media3.common.Metadata;
|
import androidx.media3.common.Metadata;
|
||||||
import androidx.media3.common.MimeTypes;
|
import androidx.media3.common.MimeTypes;
|
||||||
import androidx.media3.common.util.Log;
|
import androidx.media3.common.util.Log;
|
||||||
@ -205,6 +206,9 @@ public final class InAppMuxer implements Muxer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final String MUXER_NAME =
|
||||||
|
"androidx.media3.media3-muxer:" + MediaLibraryInfo.VERSION;
|
||||||
|
|
||||||
private static final String TAG = "InAppMuxer";
|
private static final String TAG = "InAppMuxer";
|
||||||
private static final int TRACK_ID_UNSET = -1;
|
private static final int TRACK_ID_UNSET = -1;
|
||||||
|
|
||||||
|
@ -1580,7 +1580,15 @@ public final class Transformer {
|
|||||||
}
|
}
|
||||||
DebugTraceUtil.reset();
|
DebugTraceUtil.reset();
|
||||||
if (canCollectEditingMetrics()) {
|
if (canCollectEditingMetrics()) {
|
||||||
editingMetricsCollector = new EditingMetricsCollector(context);
|
String exporterName =
|
||||||
|
checkNotNull(this.getClass().getPackage()).getName() + ":" + MediaLibraryInfo.VERSION;
|
||||||
|
String muxerName = null;
|
||||||
|
if (muxerFactory instanceof InAppMuxer.Factory) {
|
||||||
|
muxerName = InAppMuxer.MUXER_NAME;
|
||||||
|
} else if (muxerFactory instanceof FrameworkMuxer.Factory) {
|
||||||
|
muxerName = FrameworkMuxer.MUXER_NAME;
|
||||||
|
}
|
||||||
|
editingMetricsCollector = new EditingMetricsCollector(context, exporterName, muxerName);
|
||||||
}
|
}
|
||||||
transformerInternal =
|
transformerInternal =
|
||||||
new TransformerInternal(
|
new TransformerInternal(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user