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

Commit 6eb6ffa4 authored by Mahesh Lanka's avatar Mahesh Lanka Committed by Surajit Podder
Browse files

frameworks/av: Integrate STAProxy for httpstreaming

Added support to integrate STAProxy support in httpstreaming

Change-Id: I72a531b254fa06f2dd22cdbfd9d102f741d4f092
parent d9b04af0
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -68,6 +68,8 @@
#include "QCMetaData.h"
#endif

#include "include/ExtendedUtils.h"

#define USE_SURFACE_ALLOC 1
#define FRAME_DROP_FREQ 0

@@ -2513,6 +2515,17 @@ status_t AwesomePlayer::finishSetDataSource_l() {
                &mUriHeaders, &cacheConfig, &disconnectAtHighwatermark);

        mLock.unlock();

        int32_t port = 0;
        if (ExtendedUtils::ShellProp::getSTAProxyConfig(port)) {
            String8 portString = String8("127.0.0.1");
            portString.appendFormat(":%d", port);
            ALOGI("getSTAProxyConfig Proxy IPportString %s", portString.string());
            mUriHeaders.add(String8("use-proxy"), portString);
        } else {
            ALOGV("getSTAProxyConfig failed or disabled");
        }

        status_t err = mConnectingDataSource->connect(mUri, &mUriHeaders);
        // force connection at this point, to avoid a race condition between getMIMEType and the
        // caching datasource constructed below, which could result in multiple requests to the
+47 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#include <sys/types.h>
#include <ctype.h>
#include <unistd.h>
#include <dlfcn.h>

#include <media/stagefright/MetaData.h>
#include <media/stagefright/foundation/ABitReader.h>
@@ -827,6 +828,48 @@ void ExtendedUtils::ShellProp::getRtpPortRange(unsigned *start, unsigned *end) {
    ALOGV("rtp port_start = %u, port_end = %u", *start, *end);
}

bool ExtendedUtils::ShellProp::getSTAProxyConfig(int32_t &port) {
    void* staLibHandle = NULL;

    char value[PROPERTY_VALUE_MAX];
    property_get("persist.mm.sta.disable", value, "0");
    // Return false if persist.disable.staproxy is set to 1
    if (atoi(value)) {
        ALOGW("Proxy is disabled using persist.disable.staproxy");
        return false;
    }

    staLibHandle = dlopen("libstaapi.so", RTLD_NOW);
    if (staLibHandle == NULL) {
        ALOGW("libstaapi.so open dll error :%s", dlerror());
        return false;
    }
    typedef bool (*fnIsProxySupported)();
    typedef int (*fnGetPort)();

    fnIsProxySupported isProxySupported = (fnIsProxySupported) dlsym(staLibHandle, "isSTAProxySupported");
    if (isProxySupported == NULL) {
        ALOGW("Not able to load the symbol");
        return false;
    }
    if (isProxySupported()) {
        fnGetPort getPort = (fnGetPort)dlsym(staLibHandle, "getSTAProxyAlwaysAccelerateServicePort");
        if (getPort == NULL) {
            ALOGW("Not able to load the symbol to get the STA proxy port");
            return false;
        }
        port = getPort();
        ALOGI("The STA proxy is running at port:%d", port );
    } else {
        ALOGW("STA Proxy is not supported");
        return false;
    }
    if (staLibHandle != NULL) {
        dlclose(staLibHandle);
    }
    return true;
}

void ExtendedUtils::setBFrames(
        OMX_VIDEO_PARAM_MPEG4TYPE &mpeg4type, const char* componentName) {
    //ignore non QC components
@@ -1702,6 +1745,10 @@ void ExtendedUtils::ShellProp::getRtpPortRange(unsigned *start, unsigned *end) {
    *end = kDefaultRtpPortRangeEnd;
}

bool ExtendedUtils::ShellProp::getSTAProxyConfig(int32_t &port) {
    return false;
}

void ExtendedUtils::setBFrames(
        OMX_VIDEO_PARAM_MPEG4TYPE &mpeg4type, const char* componentName) {
    ARG_TOUCH(mpeg4type);
+2 −1
Original line number Diff line number Diff line
@@ -167,6 +167,8 @@ struct ExtendedUtils {

        //helper function to parse rtp port range form system property
        static void getRtpPortRange(unsigned *start, unsigned *end);

        static bool getSTAProxyConfig(int32_t &port);
    };

    struct RTSPStream {
@@ -201,7 +203,6 @@ struct ExtendedUtils {

    static const int32_t kNumBFramesPerPFrame = 1;
    static bool mIsQCHWAACEncoder;

    //set B frames for MPEG4
    static void setBFrames(OMX_VIDEO_PARAM_MPEG4TYPE &mpeg4type,
            const char* componentName);