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

Commit 5a68fc34 authored by Li Sun's avatar Li Sun Committed by Linux Build Service Account
Browse files

RTSP: add RTSP extensions for IPV6 support

Change access modifiers and add overridables in rtsp stack.

Make ARTSPConnection/ARTPConnection extensible for IPV6 support.

Provide default implementations in AVMediaServiceExensions and
AVMediaServiceFactory.

Change-Id: Iaa67070d1832d56e0569dabfd8327c1998f04493
parent 502b3cb4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -67,6 +67,8 @@ LOCAL_C_INCLUDES:= \
        $(TOP)/frameworks/av/include/media/ \
        $(TOP)/frameworks/av/media/libmediaplayerservice \
        $(TOP)/frameworks/av/media/libavextensions \
        $(TOP)/frameworks/av/media/libstagefright/include \
        $(TOP)/frameworks/av/media/libstagefright/rtsp \
        $(TOP)/frameworks/native/include/media/hardware \
        $(TOP)/frameworks/native/include/media/openmax \
        $(TOP)/external/flac/include \
+16 −0
Original line number Diff line number Diff line
@@ -31,11 +31,16 @@

#include <common/AVExtensionsCommon.h>

#include <utils/RefBase.h>
#include <utils/String16.h>

namespace android {

struct StagefrightRecorder;
struct ARTSPConnection;
struct ARTPConnection;
struct AString;
struct MyHandler;

/*
 * Factory to create objects of base-classes in libmediaplayerservice
@@ -43,6 +48,10 @@ struct StagefrightRecorder;
struct AVMediaServiceFactory {
    virtual StagefrightRecorder *createStagefrightRecorder(const String16 &);

    // RTSP extensions
    virtual sp<ARTSPConnection> createARTSPConnection(bool uidValid, uid_t uid);
    virtual sp<ARTPConnection> createARTPConnection();

    // ----- NO TRESSPASSING BEYOND THIS LINE ------
    DECLARE_LOADABLE_SINGLETON(AVMediaServiceFactory);
};
@@ -52,6 +61,13 @@ struct AVMediaServiceFactory {
 */
struct AVMediaServiceUtils {

    // RTSP IPV6 utils
    virtual bool pokeAHole(sp<MyHandler> handler, int rtpSocket, int rtcpSocket,
            const AString &transport, const AString &sessionHost);
    virtual void makePortPair(int *rtpSocket, int *rtcpSocket, unsigned *rtpPort,
            bool isIPV6);
    virtual const char* parseURL(AString *host);

    // ----- NO TRESSPASSING BEYOND THIS LINE ------
    DECLARE_LOADABLE_SINGLETON(AVMediaServiceUtils);
};
+11 −0
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@

#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
#include "ARTPConnection.h"
#include "ARTSPConnection.h"

#include "MediaRecorderClient.h"
#include "MediaPlayerService.h"
@@ -46,6 +48,15 @@ StagefrightRecorder *AVMediaServiceFactory::createStagefrightRecorder(
    return new StagefrightRecorder(opPackageName);
}

sp<ARTSPConnection> AVMediaServiceFactory::createARTSPConnection(
        bool uidValid, uid_t uid) {
    return new ARTSPConnection(uidValid, uid);
}

sp<ARTPConnection> AVMediaServiceFactory::createARTPConnection() {
    return new ARTPConnection();
}

// ----- NO TRESSPASSING BEYOND THIS LINE ------
AVMediaServiceFactory::AVMediaServiceFactory() {
}
+20 −0
Original line number Diff line number Diff line
@@ -31,11 +31,31 @@
#include <utils/Log.h>

#include <media/stagefright/foundation/ADebug.h>
#include "ARTPConnection.h"
#include "MyHandler.h"

#include "common/ExtensionsLoader.hpp"
#include "mediaplayerservice/AVMediaServiceExtensions.h"

namespace android {

bool AVMediaServiceUtils::pokeAHole(sp<MyHandler> handler, int rtpSocket, int rtcpSocket,
        const AString &transport, const AString &/*sessionHost*/) {
    if (handler == NULL) {
        ALOGW("MyHandler is NULL");
        return false;
    }
    return handler->pokeAHole(rtpSocket, rtcpSocket, transport);
}

void AVMediaServiceUtils::makePortPair(int *rtpSocket, int *rtcpSocket, unsigned *rtpPort,
        bool /*isIPV6*/) {
    return ARTPConnection::MakePortPair(rtpSocket, rtcpSocket, rtpPort);
}

const char* AVMediaServiceUtils::parseURL(AString *host) {
    return strchr(host->c_str(), ':');
}

// ----- NO TRESSPASSING BEYOND THIS LINE ------
AVMediaServiceUtils::AVMediaServiceUtils() {
+8 −2
Original line number Diff line number Diff line
@@ -81,7 +81,8 @@ void ARTPConnection::addStream(
        const sp<ASessionDescription> &sessionDesc,
        size_t index,
        const sp<AMessage> &notify,
        bool injected) {
        bool injected,
        bool isIPV6) {
    sp<AMessage> msg = new AMessage(kWhatAddStream, this);
    msg->setInt32("rtp-socket", rtpSocket);
    msg->setInt32("rtcp-socket", rtcpSocket);
@@ -89,6 +90,7 @@ void ARTPConnection::addStream(
    msg->setSize("index", index);
    msg->setMessage("notify", notify);
    msg->setInt32("injected", injected);
    msg->setInt32("isIPV6", isIPV6);
    msg->post();
}

@@ -145,6 +147,10 @@ void ARTPConnection::MakePortPair(
    TRESPASS();
}

size_t ARTPConnection::sockAddrSize() {
    return sizeof(struct sockaddr_in);
}

void ARTPConnection::onMessageReceived(const sp<AMessage> &msg) {
    switch (msg->what()) {
        case kWhatAddStream:
@@ -345,7 +351,7 @@ void ARTPConnection::onPollStreams() {
                    n = sendto(
                        s->mRTCPSocket, buffer->data(), buffer->size(), 0,
                        (const struct sockaddr *)&s->mRemoteRTCPAddr,
                        sizeof(s->mRemoteRTCPAddr));
                        sockAddrSize());
                } while (n < 0 && errno == EINTR);

                if (n <= 0) {
Loading