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

Commit 94621e87 authored by Jason Simmons's avatar Jason Simmons
Browse files

Add a way to play file descriptor data sources using the A@H transmitter media player.

* Added a MediaPlayer.setMediaPlayerType API that be called to specify the
  desired media player implementation before calling setDataSource
* Implemented setDataSource(fd) in the AAH_TxPlayer

Change-Id: I359075d9c7d6fd699dda14eb85ec50da19307639
parent 02421f52
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ public:
    virtual status_t        attachAuxEffect(int effectId) = 0;
    virtual status_t        setParameter(int key, const Parcel& request) = 0;
    virtual status_t        getParameter(int key, Parcel* reply) = 0;
    virtual status_t        setMediaPlayerType(int playerType) = 0;

    // Invoke a generic method on the player by using opaque parcels
    // for the request and reply.
+3 −0
Original line number Diff line number Diff line
@@ -201,6 +201,7 @@ public:
            status_t        attachAuxEffect(int effectId);
            status_t        setParameter(int key, const Parcel& request);
            status_t        getParameter(int key, Parcel* reply);
            status_t        setMediaPlayerType(int playerType);

private:
            void            clear_l();
@@ -231,6 +232,8 @@ private:
    int                         mVideoHeight;
    int                         mAudioSessionId;
    float                       mSendLevel;
    bool                        mOverridePlayerType;
    int                         mOverridePlayerTypeValue;
};

}; // namespace android
+30 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include <aah_timesrv/cc_helper.h>
#include <media/IMediaPlayer.h>
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/FileSource.h>
#include <media/stagefright/MediaBuffer.h>
#include <media/stagefright/MediaDebug.h>
#include <media/stagefright/MetaData.h>
@@ -184,7 +185,27 @@ status_t AAH_TXPlayer::setDataSource_l(
}

status_t AAH_TXPlayer::setDataSource(int fd, int64_t offset, int64_t length) {
    return INVALID_OPERATION;
    Mutex::Autolock autoLock(mLock);

    reset_l();

    sp<DataSource> dataSource = new FileSource(dup(fd), offset, length);

    status_t err = dataSource->initCheck();

    if (err != OK) {
        return err;
    }

    mFileSource = dataSource;

    sp<MediaExtractor> extractor = MediaExtractor::Create(dataSource);

    if (extractor == NULL) {
        return UNKNOWN_ERROR;
    }

    return setDataSource_l(extractor);
}

status_t AAH_TXPlayer::setVideoSurface(const sp<Surface>& surface) {
@@ -379,7 +400,12 @@ void AAH_TXPlayer::onPrepareAsyncEvent() {

    mAudioSource->getFormat()->findInt64(kKeyDuration, &mDurationUs);

    mAudioSource->start();
    status_t err = mAudioSource->start();
    if (err != OK) {
        LOGI("failed to start audio source, err=%d", err);
        abortPrepare(err);
        return;
    }

    mFlags |= PREPARING_CONNECTED;

@@ -651,6 +677,8 @@ void AAH_TXPlayer::reset_l() {
    mUri.setTo("");
    mUriHeaders.clear();

    mFileSource.clear();

    mBitrate = -1;

    {
+2 −0
Original line number Diff line number Diff line
@@ -136,6 +136,8 @@ class AAH_TXPlayer : public MediaPlayerHWInterface {
    String8 mUri;
    KeyedVector<String8, String8> mUriHeaders;

    sp<DataSource> mFileSource;

    sp<TimedEventQueue::Event> mAsyncPrepareEvent;
    Condition mPreparedCondition;
    status_t mPrepareResult;
+13 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ enum {
    SET_VIDEO_SURFACETEXTURE,
    SET_PARAMETER,
    GET_PARAMETER,
    SET_MEDIA_PLAYER_TYPE,
};

class BpMediaPlayer: public BpInterface<IMediaPlayer>
@@ -291,6 +292,13 @@ public:
        return remote()->transact(GET_PARAMETER, data, reply);
    }

    status_t setMediaPlayerType(int playerType) {
        Parcel data, reply;
        data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor());
        data.writeInt32(playerType);
        remote()->transact(SET_MEDIA_PLAYER_TYPE, data, &reply);
        return reply.readInt32();
    }
};

IMPLEMENT_META_INTERFACE(MediaPlayer, "android.media.IMediaPlayer");
@@ -459,6 +467,11 @@ status_t BnMediaPlayer::onTransact(
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            return getParameter(data.readInt32(), reply);
        } break;
        case SET_MEDIA_PLAYER_TYPE: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            reply->writeInt32(setMediaPlayerType(data.readInt32()));
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
Loading