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

Commit 9fed0df1 authored by Jason Simmons's avatar Jason Simmons Committed by Android (Google) Code Review
Browse files

Merge "Add a way to play file descriptor data sources using the A@H...

Merge "Add a way to play file descriptor data sources using the A@H transmitter media player." into ics-aah
parents 6c5fe627 64006cb1
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
+12 −0
Original line number Diff line number Diff line
@@ -1486,6 +1486,18 @@ public class MediaPlayer
     */
    public native static int native_pullBatteryData(Parcel reply);

    /**
     * Override the choice of media player implementation the next time
     * setDataSource is called.
     *
     * Only valid when the player is in the Idle state.
     *
     * @param playerType media player type (defined in MediaPlayerInterface.h)
     * {@hide}
     */
    public native void setMediaPlayerType(int playerType)
        throws IOException, IllegalStateException;

    @Override
    protected void finalize() { native_finalize(); }

+15 −0
Original line number Diff line number Diff line
@@ -755,6 +755,20 @@ android_media_MediaPlayer_getParameter(JNIEnv *env, jobject thiz, jint key, jobj
    process_media_player_call(env, thiz, mp->getParameter(key, reply), NULL, NULL );
}

static void
android_media_MediaPlayer_setMediaPlayerType(JNIEnv *env, jobject thiz, jint playerType)
{
    sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
    if (mp == NULL) {
        jniThrowException(env, "java/lang/IllegalStateException", NULL);
        return;
    }

    process_media_player_call(env, thiz, mp->setMediaPlayerType(playerType),
                              "java/io/IOException",
                              "setMediaPlayerType failed");
}

// ----------------------------------------------------------------------------

static JNINativeMethod gMethods[] = {
@@ -799,6 +813,7 @@ static JNINativeMethod gMethods[] = {
    {"native_pullBatteryData", "(Landroid/os/Parcel;)I",        (void *)android_media_MediaPlayer_pullBatteryData},
    {"setParameter",        "(ILandroid/os/Parcel;)Z",          (void *)android_media_MediaPlayer_setParameter},
    {"getParameter",        "(ILandroid/os/Parcel;)V",          (void *)android_media_MediaPlayer_getParameter},
    {"setMediaPlayerType", "(I)V",                              (void *)android_media_MediaPlayer_setMediaPlayerType},
};

static const char* const kClassPathName = "android/media/MediaPlayer";
+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;

    {
Loading