Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8281ed6f authored by shubang's avatar shubang Committed by Shubang Lu
Browse files

Add PlaybackComponent interface

And use it for MediaCodec as an example.

Test: mmm
Bug: 167036690
Change-Id: Idfea3876d413c3d8d3d6e153e716687e79815d95
parent a1435cb6
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.graphics.Rect;
import android.graphics.SurfaceTexture;
import android.hardware.HardwareBuffer;
import android.media.MediaCodecInfo.CodecCapabilities;
import android.media.metrics.PlaybackComponent;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
@@ -1538,7 +1539,8 @@ import java.util.concurrent.locks.ReentrantLock;
  </tbody>
 </table>
 */
final public class MediaCodec {
final public class MediaCodec implements PlaybackComponent {

    /**
     * Per buffer metadata includes an offset and size specifying
     * the range of valid data in the associated codec (output) buffer.
@@ -1680,6 +1682,7 @@ final public class MediaCodec {
    private MediaCodecInfo mCodecInfo;
    private final Object mCodecInfoLock = new Object();
    private MediaCrypto mCrypto;
    private String mPlaybackId;

    private static final int EVENT_CALLBACK = 1;
    private static final int EVENT_SET_CALLBACK = 2;
@@ -1690,6 +1693,23 @@ final public class MediaCodec {
    private static final int CB_ERROR = 3;
    private static final int CB_OUTPUT_FORMAT_CHANGE = 4;


    /**
     * @hide
     */
    @Override
    public void setPlaybackId(@NonNull String playbackId) {
        // TODO: add a native method to pass the ID to the native code for logging.
        mPlaybackId = playbackId;
    }
    /**
     * @hide
     */
    @Override
    public String getPlaybackId() {
        return mPlaybackId;
    }

    private class EventHandler extends Handler {
        private MediaCodec mCodec;

+36 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.media.metrics;

import android.annotation.NonNull;

/**
 * Interface for playback related components used by playback metrics.
 * @hide
 */
public interface PlaybackComponent {

    /**
     * Sets the playback ID of the component.
     */
    void setPlaybackId(@NonNull String playbackId);

    /**
     * Gets playback ID.
     */
    @NonNull String getPlaybackId();
}