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

Commit 9e0e629f authored by Praveen Chavan's avatar Praveen Chavan Committed by Steve Kondik
Browse files

libstagefright: enable smoothstreaming in ACodec

Enable smoothstreaming mode from ACodec
 - To handle stride change along with crop notification,
   notify NativeWindow with update-buffer-geometry
 - Enable smoothstreaming by-default based on the flag
   TARGET_ENABLE_DEFAULT_SMOOTHSTREAMING

Change-Id: I2a60035993f521fc164d3176d179882c6748b44e
parent d7c3a752
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -195,6 +195,8 @@ private:
    bool mChannelMaskPresent;
    int32_t mChannelMask;

    bool mInSmoothStreamingMode;

    status_t setCyclicIntraMacroblockRefresh(const sp<AMessage> &msg, int32_t mode);
    status_t allocateBuffersOnPort(OMX_U32 portIndex);
    status_t freeBuffersOnPort(OMX_U32 portIndex);
+4 −0
Original line number Diff line number Diff line
@@ -92,6 +92,10 @@ struct ExtendedCodec {
            const sp<MetaData> &meta, sp<IOMX> OMXhandle,
            const uint32_t flags, IOMX::node_id nodeID, char* componentName );

    static void enableSmoothStreaming(
            const sp<IOMX> &omx, IOMX::node_id nodeID, bool* isEnabled,
            const char* componentName);

private:

    static status_t setWMAFormat(
+17 −1
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include <media/stagefright/NativeWindowWrapper.h>
#include <media/stagefright/OMXClient.h>
#include <media/stagefright/OMXCodec.h>
#include <media/stagefright/ExtendedCodec.h>

#include <media/hardware/HardwareAPI.h>

@@ -45,6 +46,7 @@
#endif

#include "include/avc_utils.h"
#include "include/QCUtils.h"

namespace android {

@@ -370,7 +372,8 @@ ACodec::ACodec()
      mEncoderDelay(0),
      mEncoderPadding(0),
      mChannelMaskPresent(false),
      mChannelMask(0) {
      mChannelMask(0),
      mInSmoothStreamingMode(false) {
    mUninitializedState = new UninitializedState(this);
    mLoadedState = new LoadedState(this);
    mLoadedToIdleState = new LoadedToIdleState(this);
@@ -1588,6 +1591,9 @@ status_t ACodec::setupVideoDecoder(
        return err;
    }

    ExtendedCodec::enableSmoothStreaming(
            mOMX, mNode, &mInSmoothStreamingMode, mComponentName.c_str());

    return OK;
}

@@ -2341,6 +2347,9 @@ void ACodec::sendFormatChange(const sp<AMessage> &reply) {
                            rect.nTop,
                            rect.nLeft + rect.nWidth,
                            rect.nTop + rect.nHeight);
                    reply->setInt32(
                            "color-format",
                            (int)(videoDef->eColorFormat));
                }
            }
            break;
@@ -3169,6 +3178,13 @@ void ACodec::BaseState::onOutputBufferDrained(const sp<AMessage> &msg) {
    android_native_rect_t crop;
    if (msg->findRect("crop",
            &crop.left, &crop.top, &crop.right, &crop.bottom)) {
        if (mCodec->mInSmoothStreamingMode) {
            OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatUnused;
            CHECK(msg->findInt32("color-format", (int32_t*)&eColorFormat));
            QCUtils::updateNativeWindowBufferGeometry(
                    mCodec->mNativeWindow.get(), crop.right,
                    crop.bottom, eColorFormat);
        }
        CHECK_EQ(0, native_window_set_crop(
                mCodec->mNativeWindow.get(), &crop));
    }
+3 −0
Original line number Diff line number Diff line
@@ -186,6 +186,9 @@ ifeq ($(TARGET_ENABLE_QC_AV_ENHANCEMENTS),true)
        LOCAL_C_INCLUDES += \
            $(TOP)/hardware/qcom/media/mm-core/inc
    endif
    ifeq ($(TARGET_ENABLE_DEFAULT_SMOOTHSTREAMING),true)
            LOCAL_CFLAGS += -DENABLE_DEFAULT_SMOOTHSTREAMING
    endif #TARGET_ENABLE_DEAFULT_SMOOTHSTREAMING
endif #TARGET_ENABLE_QC_AV_ENHANCEMENTS

include $(BUILD_SHARED_LIBRARY)
+31 −0
Original line number Diff line number Diff line
@@ -347,6 +347,30 @@ void ExtendedCodec::configureVideoCodec(
    }
}

void ExtendedCodec::enableSmoothStreaming(
        const sp<IOMX> &omx, IOMX::node_id nodeID, bool* isEnabled,
        const char* componentName) {
    *isEnabled = false;
#ifndef ENABLE_DEFAULT_SMOOTHSTREAMING
    return;
#endif
    //ignore non QC components
    if (strncmp(componentName, "OMX.qcom.", 9)) {
        return;
    }
    status_t err = omx->setParameter(
            nodeID,
            (OMX_INDEXTYPE)OMX_QcomIndexParamEnableSmoothStreaming,
            &err, sizeof(status_t));
    if (err != OK) {
        ALOGE("Failed to enable Smoothstreaming!");
        return;
    }
    *isEnabled = true;
    ALOGI("Smoothstreaming Enabled");
    return;
}

//private methods
void ExtendedCodec::setEVRCFormat(
        int32_t numChannels, int32_t sampleRate, sp<IOMX> OMXhandle,
@@ -719,6 +743,13 @@ namespace android {
        const uint32_t flags, IOMX::node_id nodeID, char* componentName ) {
    }

    void ExtendedCodec::enableSmoothStreaming(
            const sp<IOMX> &omx, IOMX::node_id nodeID, bool* isEnabled,
            const char* componentName) {
        *isEnabled = false;
        return;
    }

} //namespace android

#endif //ENABLE_QC_AV_ENHANCEMENTS
Loading