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

Commit 3a0ef0dc authored by Andreas Huber's avatar Andreas Huber Committed by Android (Google) Code Review
Browse files

Tell the encoder to emit SPS/PPS before IDR frames in wifi display code.

Change-Id: Ic40e09b66784dd2e370d30b688d50561a47ab85a
related-to-bug: 7245308
parent e646b2d2
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@
#include <media/stagefright/OMXClient.h>
#include <media/stagefright/OMXCodec.h>

#include <media/hardware/HardwareAPI.h>

#include <OMX_Component.h>

#include "include/avc_utils.h"
@@ -881,6 +883,33 @@ status_t ACodec::configureCodec(
        }
    }

    int32_t prependSPSPPS;
    if (encoder
            && msg->findInt32("prepend-sps-pps-to-idr-frames", &prependSPSPPS)
            && prependSPSPPS != 0) {
        OMX_INDEXTYPE index;
        err = mOMX->getExtensionIndex(
                mNode,
                "OMX.google.android.index.prependSPSPPSToIDRFrames",
                &index);

        if (err == OK) {
            PrependSPSPPSToIDRFramesParams params;
            InitOMXParams(&params);
            params.bEnable = OMX_TRUE;

            err = mOMX->setParameter(
                    mNode, index, &params, sizeof(params));
        }

        if (err != OK) {
            ALOGE("Encoder could not be configured to emit SPS/PPS before "
                  "IDR frames. (err %d)", err);

            return err;
        }
    }

    if (!strncasecmp(mime, "video/", 6)) {
        if (encoder) {
            err = setupVideoEncoder(mime, msg);
+8 −0
Original line number Diff line number Diff line
@@ -53,6 +53,13 @@ Converter::Converter(
    }

    mInitCheck = initEncoder();

    if (mInitCheck != OK) {
        if (mEncoder != NULL) {
            mEncoder->release();
            mEncoder.clear();
        }
    }
}

Converter::~Converter() {
@@ -127,6 +134,7 @@ status_t Converter::initEncoder() {
        mOutputFormat->setInt32("bitrate", videoBitrate);
        mOutputFormat->setInt32("frame-rate", 24);
        mOutputFormat->setInt32("i-frame-interval", 1);  // Iframes every 1 secs
        // mOutputFormat->setInt32("prepend-sps-pps-to-idr-frames", 1);
    }

    ALOGV("output format is '%s'", mOutputFormat->debugString(0).c_str());
+4 −1
Original line number Diff line number Diff line
@@ -846,7 +846,10 @@ status_t WifiDisplaySource::PlaybackSession::addSource(

    sp<Converter> converter =
        new Converter(notify, codecLooper, format);
    CHECK_EQ(converter->initCheck(), (status_t)OK);

    if (converter->initCheck() != OK) {
        return converter->initCheck();
    }

    looper()->registerHandler(converter);