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

Commit 4a4a8f01 authored by Andreas Huber's avatar Andreas Huber
Browse files

Remove RTSP support from libvideoeditor's PreviewPlayer...

Change-Id: I2032772037c1130736081cb62bd6ce8d1270e1b9
parent 2534acb8
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@

#include <dlfcn.h>

#include "include/ARTSPController.h"
#include "PreviewPlayer.h"
#include "DummyAudioSource.h"
#include "DummyVideoSource.h"
+4 −66
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@

#include <dlfcn.h>

#include "include/ARTSPController.h"
#include "PreviewPlayerBase.h"
#include "AudioPlayerBase.h"
#include "include/SoftwareRenderer.h"
@@ -49,9 +48,6 @@
#include <gui/SurfaceTextureClient.h>
#include <surfaceflinger/ISurfaceComposer.h>

#include <media/stagefright/foundation/ALooper.h>
#include <media/stagefright/foundation/AMessage.h>

#include <cutils/properties.h>

#define USE_SURFACE_ALLOC 1
@@ -60,7 +56,6 @@ namespace android {

static int64_t kLowWaterMarkUs = 2000000ll;  // 2secs
static int64_t kHighWaterMarkUs = 10000000ll;  // 10secs
static int64_t kHighWaterMarkRTSPUs = 4000000ll;  // 4secs
static const size_t kLowWaterMarkBytes = 40000;
static const size_t kHighWaterMarkBytes = 200000;

@@ -429,9 +424,6 @@ void PreviewPlayerBase::reset_l() {
        if (mConnectingDataSource != NULL) {
            LOGI("interrupting the connection process");
            mConnectingDataSource->disconnect();
        } else if (mConnectingRTSPController != NULL) {
            LOGI("interrupting the connection process");
            mConnectingRTSPController->disconnect();
        }

        if (mFlags & PREPARING_CONNECTED) {
@@ -471,11 +463,6 @@ void PreviewPlayerBase::reset_l() {

    mVideoRenderer.clear();

    if (mRTSPController != NULL) {
        mRTSPController->disconnect();
        mRTSPController.clear();
    }

    if (mVideoSource != NULL) {
        shutdownVideoDecoder_l();
    }
@@ -531,10 +518,7 @@ bool PreviewPlayerBase::getBitrate(int64_t *bitrate) {
bool PreviewPlayerBase::getCachedDuration_l(int64_t *durationUs, bool *eos) {
    int64_t bitrate;

    if (mRTSPController != NULL) {
        *durationUs = mRTSPController->getQueueDurationUs(eos);
        return true;
    } else if (mCachedSource != NULL && getBitrate(&bitrate)) {
    if (mCachedSource != NULL && getBitrate(&bitrate)) {
        status_t finalStatus;
        size_t cachedDataRemaining = mCachedSource->approxDataRemaining(&finalStatus);
        *durationUs = cachedDataRemaining * 8000000ll / bitrate;
@@ -640,9 +624,6 @@ void PreviewPlayerBase::onBufferingUpdate() {
        LOGV("cachedDurationUs = %.2f secs, eos=%d",
             cachedDurationUs / 1E6, eos);

        int64_t highWaterMarkUs =
            (mRTSPController != NULL) ? kHighWaterMarkRTSPUs : kHighWaterMarkUs;

        if ((mFlags & PLAYING) && !eos
                && (cachedDurationUs < kLowWaterMarkUs)) {
            LOGI("cache is running low (%.2f secs) , pausing.",
@@ -651,7 +632,7 @@ void PreviewPlayerBase::onBufferingUpdate() {
            pause_l();
            ensureCacheIsFetching_l();
            notifyListener_l(MEDIA_INFO, MEDIA_INFO_BUFFERING_START);
        } else if (eos || cachedDurationUs > highWaterMarkUs) {
        } else if (eos || cachedDurationUs > kHighWaterMarkUs) {
            if (mFlags & CACHE_UNDERRUN) {
                LOGI("cache has filled up (%.2f secs), resuming.",
                     cachedDurationUs / 1E6);
@@ -1099,10 +1080,7 @@ status_t PreviewPlayerBase::getDuration(int64_t *durationUs) {
}

status_t PreviewPlayerBase::getPosition(int64_t *positionUs) {
    if (mRTSPController != NULL) {
        *positionUs = mRTSPController->getNormalPlayTimeUs();
    }
    else if (mSeeking != NO_SEEK) {
    if (mSeeking != NO_SEEK) {
        *positionUs = mSeekTimeUs;
    } else if (mVideoSource != NULL
            && (mAudioPlayer == NULL || !(mFlags & VIDEO_AT_EOS))) {
@@ -1126,22 +1104,7 @@ status_t PreviewPlayerBase::seekTo(int64_t timeUs) {
    return OK;
}

// static
void PreviewPlayerBase::OnRTSPSeekDoneWrapper(void *cookie) {
    static_cast<PreviewPlayerBase *>(cookie)->onRTSPSeekDone();
}

void PreviewPlayerBase::onRTSPSeekDone() {
    notifyListener_l(MEDIA_SEEK_COMPLETE);
    mSeekNotificationSent = true;
}

status_t PreviewPlayerBase::seekTo_l(int64_t timeUs) {
    if (mRTSPController != NULL) {
        mRTSPController->seekAsync(timeUs, OnRTSPSeekDoneWrapper, this);
        return OK;
    }

    if (mFlags & CACHE_UNDERRUN) {
        mFlags &= ~CACHE_UNDERRUN;
        play_l();
@@ -1510,7 +1473,6 @@ void PreviewPlayerBase::onVideoEvent() {
        int64_t latenessUs = nowUs - timeUs;

        if (latenessUs > 500000ll
                && mRTSPController == NULL
                && mAudioPlayer != NULL
                && mAudioPlayer->getMediaTimeMapping(
                    &realTimeUs, &mediaTimeUs)) {
@@ -1765,30 +1727,6 @@ status_t PreviewPlayerBase::finishSetDataSource_l() {
            LOGI("Prepare cancelled while waiting for initial cache fill.");
            return UNKNOWN_ERROR;
        }
    } else if (!strncasecmp("rtsp://", mUri.string(), 7)) {
        if (mLooper == NULL) {
            mLooper = new ALooper;
            mLooper->setName("rtsp");
            mLooper->start();
        }
        mRTSPController = new ARTSPController(mLooper);
        mConnectingRTSPController = mRTSPController;

        mLock.unlock();
        status_t err = mRTSPController->connect(mUri.string());
        mLock.lock();

        mConnectingRTSPController.clear();

        LOGI("ARTSPController::connect returned %d", err);

        if (err != OK) {
            mRTSPController.clear();
            return err;
        }

        sp<MediaExtractor> extractor = mRTSPController.get();
        return setDataSource_l(extractor);
    } else {
        dataSource = DataSource::CreateFromURI(mUri.string(), &mUriHeaders);
    }
@@ -1873,7 +1811,7 @@ void PreviewPlayerBase::onPrepareAsyncEvent() {

    mFlags |= PREPARING_CONNECTED;

    if (mCachedSource != NULL || mRTSPController != NULL) {
    if (mCachedSource != NULL) {
        postBufferingEvent_l();
    } else {
        finishAsyncPrepare_l();
+0 −10
Original line number Diff line number Diff line
@@ -39,9 +39,6 @@ struct MediaSource;
struct NuCachedSource2;
struct ISurfaceTexture;

struct ALooper;
struct ARTSPController;

class DrmManagerClinet;
class DecryptHandle;

@@ -215,10 +212,6 @@ private:
    sp<HTTPBase> mConnectingDataSource;
    sp<NuCachedSource2> mCachedSource;

    sp<ALooper> mLooper;
    sp<ARTSPController> mRTSPController;
    sp<ARTSPController> mConnectingRTSPController;

    DrmManagerClient *mDrmManagerClient;
    sp<DecryptHandle> mDecryptHandle;

@@ -266,9 +259,6 @@ private:

    static bool ContinuePreparation(void *cookie);

    static void OnRTSPSeekDoneWrapper(void *cookie);
    void onRTSPSeekDone();

    bool getBitrate(int64_t *bitrate);

    void finishSeekIfNecessary(int64_t videoTimeUs);