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

Commit efbb781c authored by Andreas Huber's avatar Andreas Huber
Browse files

HDCP module binderized

Change-Id: I866768b1e3f3b232f1934a35b65f66befc12f3f6
parent 74e58c55
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@
namespace android {

struct ICrypto;
struct IHDCP;
class IMediaRecorder;
class IOMX;
class IRemoteDisplay;
@@ -51,6 +52,7 @@ public:
    virtual sp<IMemory>         decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat) = 0;
    virtual sp<IOMX>            getOMX() = 0;
    virtual sp<ICrypto>         makeCrypto() = 0;
    virtual sp<IHDCP>           makeHDCP() = 0;

    // Connects to a remote display.
    // 'iface' specifies the address of the local interface on which to listen for
+15 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <binder/Parcel.h>
#include <binder/IMemory.h>
#include <media/ICrypto.h>
#include <media/IHDCP.h>
#include <media/IMediaPlayerService.h>
#include <media/IMediaRecorder.h>
#include <media/IOMX.h>
@@ -41,6 +42,7 @@ enum {
    CREATE_METADATA_RETRIEVER,
    GET_OMX,
    MAKE_CRYPTO,
    MAKE_HDCP,
    ENABLE_REMOTE_DISPLAY,
    ADD_BATTERY_DATA,
    PULL_BATTERY_DATA,
@@ -125,6 +127,13 @@ public:
        return interface_cast<ICrypto>(reply.readStrongBinder());
    }

    virtual sp<IHDCP> makeHDCP() {
        Parcel data, reply;
        data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor());
        remote()->transact(MAKE_HDCP, data, &reply);
        return interface_cast<IHDCP>(reply.readStrongBinder());
    }

    virtual status_t enableRemoteDisplay(const char *iface) {
        Parcel data, reply;
        data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor());
@@ -237,6 +246,12 @@ status_t BnMediaPlayerService::onTransact(
            reply->writeStrongBinder(crypto->asBinder());
            return NO_ERROR;
        } break;
        case MAKE_HDCP: {
            CHECK_INTERFACE(IMediaPlayerService, data, reply);
            sp<IHDCP> hdcp = makeHDCP();
            reply->writeStrongBinder(hdcp->asBinder());
            return NO_ERROR;
        } break;
        case ENABLE_REMOTE_DISPLAY: {
            CHECK_INTERFACE(IMediaPlayerService, data, reply);
            const char *iface = NULL;
+1 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES:=               \
    ActivityManager.cpp         \
    Crypto.cpp                  \
    HDCP.cpp                    \
    MediaPlayerFactory.cpp      \
    MediaPlayerService.cpp      \
    MediaRecorderClient.cpp     \
+16 −2
Original line number Diff line number Diff line
@@ -36,13 +36,16 @@ HDCP::HDCP()
        return;
    }

    typedef HDCPModule *(*CreateHDCPModuleFunc)();
    typedef HDCPModule *(*CreateHDCPModuleFunc)(
            void *, HDCPModule::ObserverFunc);

    CreateHDCPModuleFunc createHDCPModule =
        (CreateHDCPModuleFunc)dlsym(mLibHandle, "createHDCPModule");

    if (createHDCPModule == NULL) {
        ALOGE("Unable to find symbol 'createHDCPModule'.");
    } else if ((mHDCPModule = createHDCPModule()) == NULL) {
    } else if ((mHDCPModule = createHDCPModule(
                    this, &HDCP::ObserveWrapper)) == NULL) {
        ALOGE("createHDCPModule failed.");
    }
}
@@ -97,5 +100,16 @@ status_t HDCP::encrypt(
    return mHDCPModule->encrypt(inData, size, streamCTR, outInputCTR, outData);
}

// static
void HDCP::ObserveWrapper(void *me, int msg, int ext1, int ext2) {
    static_cast<HDCP *>(me)->observe(msg, ext1, ext2);
}

void HDCP::observe(int msg, int ext1, int ext2) {
    if (mObserver != NULL) {
        mObserver->notify(msg, ext1, ext2, NULL /* obj */);
    }
}

}  // namespace android
+3 −0
Original line number Diff line number Diff line
@@ -39,6 +39,9 @@ private:
    HDCPModule *mHDCPModule;
    sp<IHDCPObserver> mObserver;

    static void ObserveWrapper(void *me, int msg, int ext1, int ext2);
    void observe(int msg, int ext1, int ext2);

    DISALLOW_EVIL_CONSTRUCTORS(HDCP);
};

Loading