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

Commit 04c13213 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add AudioPresentation selection support for MediaCodec"

parents eb458627 5e05320c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -23989,6 +23989,7 @@ package android.media {
    method public void releaseOutputBuffer(int, boolean);
    method public void releaseOutputBuffer(int, long);
    method public void reset();
    method public void setAudioPresentation(android.media.AudioPresentation);
    method public void setCallback(android.media.MediaCodec.Callback, android.os.Handler);
    method public void setCallback(android.media.MediaCodec.Callback);
    method public void setInputSurface(android.view.Surface);
+31 −1
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import android.media.MediaCodecInfo.CodecCapabilities;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.IHwBinder;
import android.os.Looper;
import android.os.Message;
@@ -1426,6 +1425,24 @@ import java.util.concurrent.locks.ReentrantLock;
    <td>&#9094;</td>
    <td>&#9094;</td>
   </tr>
   <tr>
    <td>(29+)</td>
    <td>29+</td>
    <td>29+</td>
    <td>29+</td>
    <td>(29+)</td>
    <td>(29+)</td>
    <td>-</td>
    <td class=fn>{@link #setAudioPresentation setAudioPresentation}</td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
   </tr>
   <tr>
    <td>-</td>
    <td>-</td>
@@ -3259,6 +3276,19 @@ final public class MediaCodec {
     */
    public native final void setVideoScalingMode(@VideoScalingMode int mode);

    /**
     * Sets the audio presentation.
     * @param presentation see {@link AudioPresentation}. In particular, id should be set.
     */
    public void setAudioPresentation(@NonNull AudioPresentation presentation) {
        if (presentation == null) {
            throw new IllegalArgumentException("audio presentation is null");
        }
        native_setAudioPresentation(presentation.getPresentationId(), presentation.getProgramId());
    }

    private native void native_setAudioPresentation(int presentationId, int programId);

    /**
     * Get the component name. If the codec was created by createDecoderByType
     * or createEncoderByType, what component is chosen is not known beforehand.
+22 −0
Original line number Diff line number Diff line
@@ -752,6 +752,13 @@ void JMediaCodec::setVideoScalingMode(int mode) {
    }
}

void JMediaCodec::selectAudioPresentation(const int32_t presentationId, const int32_t programId) {
    sp<AMessage> msg = new AMessage;
    msg->setInt32("audio-presentation-presentation-id", presentationId);
    msg->setInt32("audio-presentation-program-id", programId);
    (void)mCodec->setParameters(msg);
}

static jthrowable createCodecException(
        JNIEnv *env, status_t err, int32_t actionCode, const char *msg = NULL) {
    ScopedLocalRef<jclass> clazz(
@@ -1874,6 +1881,18 @@ static void android_media_MediaCodec_setVideoScalingMode(
    codec->setVideoScalingMode(mode);
}

static void android_media_MediaCodec_setAudioPresentation(
        JNIEnv *env, jobject thiz, jint presentationId, jint programId) {
    sp<JMediaCodec> codec = getMediaCodec(env, thiz);

    if (codec == NULL) {
        throwExceptionAsNecessary(env, INVALID_OPERATION);
        return;
    }

    codec->selectAudioPresentation((int32_t)presentationId, (int32_t)programId);
}

static void android_media_MediaCodec_native_init(JNIEnv *env) {
    ScopedLocalRef<jclass> clazz(
            env, env->FindClass("android/media/MediaCodec"));
@@ -2183,6 +2202,9 @@ static const JNINativeMethod gMethods[] = {
    { "setVideoScalingMode", "(I)V",
      (void *)android_media_MediaCodec_setVideoScalingMode },

    { "native_setAudioPresentation", "(II)V",
      (void *)android_media_MediaCodec_setAudioPresentation },

    { "native_init", "()V", (void *)android_media_MediaCodec_native_init },

    { "native_setup", "(Ljava/lang/String;ZZ)V",
+2 −0
Original line number Diff line number Diff line
@@ -128,6 +128,8 @@ struct JMediaCodec : public AHandler {

    void setVideoScalingMode(int mode);

    void selectAudioPresentation(const int32_t presentationId, const int32_t programId);

protected:
    virtual ~JMediaCodec();