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

Commit d1587177 authored by Byeongjo Park's avatar Byeongjo Park Committed by Lajos Molnar
Browse files

VT: SFP: bind socket to specific network



This will call an API of android_setsocknetwork().

"rtp-param-set-socket-network" is added to update routing table
from media engine of android.

RTP/RTCP sockets will be bound to the networkhandle provided
through the above parameter.

This patch is effected only for Rx(NuPlayer) session.

Merged-in: Id14708049e684f8dd5711c2b9fefb67c6cafbfc6
Change-Id: Id14708049e684f8dd5711c2b9fefb67c6cafbfc6
Signed-off-by: default avatarByeongjo Park <bjo.park@samsung.com>
parent 2b85f7d9
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ cc_library_static {
        "frameworks/av/media/libstagefright/mpeg2ts",
        "frameworks/av/media/libstagefright/rtsp",
        "frameworks/av/media/libstagefright/timedtext",
        "frameworks/native/include/android",
    ],

    cflags: [
@@ -47,6 +48,8 @@ cc_library_static {
    },

    shared_libs: [
        "libandroid",
        "libandroid_net",
        "libbinder",
        "libdatasource",
        "libui",
+18 −1
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ void NuPlayer::RTPSource::prepareAsync() {

        int sockRtp, sockRtcp;
        ARTPConnection::MakeRTPSocketPair(&sockRtp, &sockRtcp, info->mLocalIp, info->mRemoteIp,
                info->mLocalPort, info->mRemotePort);
                info->mLocalPort, info->mRemotePort, info->mSocketNetwork);

        sp<AMessage> notify = new AMessage('accu', this);

@@ -691,6 +691,9 @@ status_t NuPlayer::RTPSource::setParameter(const String8 &key, const String8 &va
        info->mSelfID = atoi(value);
    } else if (key == "rtp-param-ext-cvo-extmap") {
        info->mCVOExtMap = atoi(value);
    } else if (key == "rtp-param-set-socket-network") {
        int64_t networkHandle = atoll(value);
        setSocketNetwork(networkHandle);
    }

    return OK;
@@ -731,6 +734,20 @@ status_t NuPlayer::RTPSource::setParameters(const String8 &params) {
    return OK;
}

void NuPlayer::RTPSource::setSocketNetwork(int64_t networkHandle) {
    ALOGV("setSocketNetwork: %llu", (unsigned long long)networkHandle);

    TrackInfo *info = NULL;
    for (size_t i = 0; i < mTracks.size(); ++i) {
        info = &mTracks.editItemAt(i);

        if (info == NULL)
            break;

        info->mSocketNetwork = networkHandle;
    }
}

// Trim both leading and trailing whitespace from the given string.
//static
void NuPlayer::RTPSource::TrimString(String8 *s) {
+2 −0
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ private:
        String8 mRemoteIp;
        int32_t mLocalPort;
        int32_t mRemotePort;
        int64_t mSocketNetwork;
        int32_t mTimeScale;
        int32_t mAS;

@@ -205,6 +206,7 @@ private:

    status_t setParameters(const String8 &params);
    status_t setParameter(const String8 &key, const String8 &value);
    void setSocketNetwork(int64_t networkHandle);
    static void TrimString(String8 *s);

    DISALLOW_EVIL_CONSTRUCTORS(RTPSource);
+19 −1
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@
#include <media/stagefright/foundation/AString.h>
#include <media/stagefright/foundation/hexdump.h>

#include <android/multinetwork.h>

#include <arpa/inet.h>
#include <sys/socket.h>

@@ -161,7 +163,7 @@ void ARTPConnection::MakePortPair(
// static
void ARTPConnection::MakeRTPSocketPair(
        int *rtpSocket, int *rtcpSocket, const char *localIp, const char *remoteIp,
        unsigned localPort, unsigned remotePort) {
        unsigned localPort, unsigned remotePort, int64_t socketNetwork) {
    bool isIPv6 = false;
    if (strchr(localIp, ':') != NULL)
        isIPv6 = true;
@@ -174,6 +176,22 @@ void ARTPConnection::MakeRTPSocketPair(
    *rtcpSocket = socket(isIPv6 ? AF_INET6 : AF_INET, SOCK_DGRAM, 0);
    CHECK_GE(*rtcpSocket, 0);

    if (socketNetwork != 0) {
        ALOGD("trying to bind rtp socket(%d) to network(%llu).",
                *rtpSocket, (unsigned long long)socketNetwork);

        int result = android_setsocknetwork((net_handle_t)socketNetwork, *rtpSocket);
        if (result != 0) {
            ALOGW("failed(%d) to bind rtp socket(%d) to network(%llu)",
                    result, *rtpSocket, (unsigned long long)socketNetwork);
        }
        result = android_setsocknetwork((net_handle_t)socketNetwork, *rtcpSocket);
        if (result != 0) {
            ALOGW("failed(%d) to bind rtcp socket(%d) to network(%llu)",
                    result, *rtcpSocket, (unsigned long long)socketNetwork);
        }
    }

    bumpSocketBufferSize(*rtcpSocket);

    struct sockaddr *addr;
+1 −1
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ struct ARTPConnection : public AHandler {
    static void MakeRTPSocketPair(
            int *rtpSocket, int *rtcpSocket,
            const char *localIp, const char *remoteIp,
            unsigned localPort, unsigned remotePort);
            unsigned localPort, unsigned remotePort, int64_t socketNetwork = 0);

protected:
    virtual ~ARTPConnection();