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

Commit ffa98d52 authored by Steve Kondik's avatar Steve Kondik
Browse files

Revert "HLSCustom: Bandwidth switching improvement in HLS"

This reverts commit 06f0b858.

Revert "httplive: Support embedded images in audio-only playlist"

This reverts commit 1ea977c1.

Change-Id: I75caae60740af20039982476679df8a852b35959

Revert "HLSCustom: Fix compilation issues and support for dual HLS stack"

This reverts commit 22f6020c.

Revert "HLSCustom: Copying KK-mr2 files from httplive to httplivecustom"

This reverts commit 0778792e.

Change-Id: I6dd07d315b88143bde84ca89729b33d27d5790ad
parent 6c591944
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ LOCAL_SHARED_LIBRARIES := \
    libstagefright              \
    libstagefright_foundation   \
    libstagefright_httplive     \
    libstagefright_httplivecustom \
    libstagefright_omx          \
    libstagefright_wfd          \
    libutils                    \
+0 −2
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES:=                       \
        GenericSource.cpp               \
        HTTPLiveSource.cpp              \
        HTTPLiveSourceCustom.cpp           \
        NuPlayer.cpp                    \
        NuPlayerDecoder.cpp             \
        NuPlayerDecoderPassThrough.cpp  \
@@ -16,7 +15,6 @@ LOCAL_SRC_FILES:= \

LOCAL_C_INCLUDES := \
	$(TOP)/frameworks/av/media/libstagefright/httplive            \
    $(TOP)/frameworks/av/media/libstagefright/httplivecustom         \
	$(TOP)/frameworks/av/media/libstagefright/include             \
	$(TOP)/frameworks/av/media/libstagefright/mpeg2ts             \
	$(TOP)/frameworks/av/media/libstagefright/rtsp                \
+0 −296
Original line number Diff line number Diff line
/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

//#define LOG_NDEBUG 0
#define LOG_TAG "HTTPLiveSourceCustom"
#include <utils/Log.h>

#include "HTTPLiveSourceCustom.h"

#include "AnotherPacketSource.h"
#include "LiveDataSource.h"
#include "LiveSessionCustom.h"

#include <media/IMediaHTTPService.h>
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/MetaData.h>

#include "ExtendedUtils.h"

namespace android {

NuPlayer::HTTPLiveSourceCustom::HTTPLiveSourceCustom(
        const sp<AMessage> &notify,
        const sp<IMediaHTTPService> &httpService,
        const char *url,
        const KeyedVector<String8, String8> *headers)
    : Source(notify),
      mHTTPService(httpService),
      mURL(url),
      mFlags(0),
      mFinalResult(OK),
      mOffset(0),
      mFetchSubtitleDataGeneration(0) {
    if (headers) {
        mExtraHeaders = *headers;

        ssize_t index =
            mExtraHeaders.indexOfKey(String8("x-hide-urls-from-log"));

        if (index >= 0) {
            mFlags |= kFlagIncognito;

            mExtraHeaders.removeItemsAt(index);
        }
    }
}

NuPlayer::HTTPLiveSourceCustom::~HTTPLiveSourceCustom() {
    if (mLiveSession != NULL) {
        mLiveSession->disconnect();

        mLiveLooper->unregisterHandler(mLiveSession->id());
        mLiveLooper->unregisterHandler(id());
        mLiveLooper->stop();

        mLiveSession.clear();
        mLiveLooper.clear();
    }
}

void NuPlayer::HTTPLiveSourceCustom::prepareAsync() {
    if (mLiveLooper == NULL) {
        mLiveLooper = new ALooper;
        mLiveLooper->setName("http live");
        mLiveLooper->start();

        mLiveLooper->registerHandler(this);
    }

    sp<AMessage> notify = new AMessage(kWhatSessionNotify, id());

    mLiveSession = new LiveSessionCustom(
            notify,
            (mFlags & kFlagIncognito) ? LiveSessionCustom::kFlagIncognito : 0,
            mHTTPService);

    mLiveLooper->registerHandler(mLiveSession);

    mLiveSession->connectAsync(
            mURL.c_str(), mExtraHeaders.isEmpty() ? NULL : &mExtraHeaders);
}

void NuPlayer::HTTPLiveSourceCustom::start() {
}

sp<AMessage> NuPlayer::HTTPLiveSourceCustom::getFormat(bool audio) {
    sp<AMessage> format;
    status_t err = mLiveSession->getStreamFormat(
            audio ? LiveSessionCustom::STREAMTYPE_AUDIO
                  : LiveSessionCustom::STREAMTYPE_VIDEO,
            &format);

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

    return format;
}

status_t NuPlayer::HTTPLiveSourceCustom::feedMoreTSData() {
    return OK;
}

status_t NuPlayer::HTTPLiveSourceCustom::dequeueAccessUnit(
        bool audio, sp<ABuffer> *accessUnit) {
    status_t err = mLiveSession->dequeueAccessUnit(
            audio ? LiveSessionCustom::STREAMTYPE_AUDIO
                  : LiveSessionCustom::STREAMTYPE_VIDEO,
            accessUnit);

    if (err == OK && audio) {
        sp<AMessage> format;
        if (OK != mLiveSession->getStreamFormat(LiveSessionCustom::STREAMTYPE_VIDEO, &format)) {
            //Detect the image in audio only clip
            sp<AMessage> notify = dupNotify();
            notify->setInt32("what", kWhatShowImage);
            ExtendedUtils::detectAndPostImage(*accessUnit, notify);
        }
    }
    return err;
}

status_t NuPlayer::HTTPLiveSourceCustom::getDuration(int64_t *durationUs) {
    return mLiveSession->getDuration(durationUs);
}

size_t NuPlayer::HTTPLiveSourceCustom::getTrackCount() const {
    return mLiveSession->getTrackCount();
}

sp<AMessage> NuPlayer::HTTPLiveSourceCustom::getTrackInfo(size_t trackIndex) const {
    return mLiveSession->getTrackInfo(trackIndex);
}

status_t NuPlayer::HTTPLiveSourceCustom::selectTrack(size_t trackIndex, bool select) {
    status_t err = mLiveSession->selectTrack(trackIndex, select);

    if (err == OK) {
        mFetchSubtitleDataGeneration++;
        if (select) {
            sp<AMessage> msg = new AMessage(kWhatFetchSubtitleData, id());
            msg->setInt32("generation", mFetchSubtitleDataGeneration);
            msg->post();
        }
    }

    // LiveSessionCustom::selectTrack returns BAD_VALUE when selecting the currently
    // selected track, or unselecting a non-selected track. In this case it's an
    // no-op so we return OK.
    return (err == OK || err == BAD_VALUE) ? (status_t)OK : err;
}

status_t NuPlayer::HTTPLiveSourceCustom::seekTo(int64_t seekTimeUs) {
    return mLiveSession->seekTo(seekTimeUs);
}

void NuPlayer::HTTPLiveSourceCustom::onMessageReceived(const sp<AMessage> &msg) {
    switch (msg->what()) {
        case kWhatSessionNotify:
        {
            onSessionNotify(msg);
            break;
        }

        case kWhatFetchSubtitleData:
        {
            int32_t generation;
            CHECK(msg->findInt32("generation", &generation));

            if (generation != mFetchSubtitleDataGeneration) {
                // stale
                break;
            }

            sp<ABuffer> buffer;
            if (mLiveSession->dequeueAccessUnit(
                    LiveSessionCustom::STREAMTYPE_SUBTITLES, &buffer) == OK) {
                sp<AMessage> notify = dupNotify();
                notify->setInt32("what", kWhatSubtitleData);
                notify->setBuffer("buffer", buffer);
                notify->post();

                int64_t timeUs, baseUs, durationUs, delayUs;
                CHECK(buffer->meta()->findInt64("baseUs", &baseUs));
                CHECK(buffer->meta()->findInt64("timeUs", &timeUs));
                CHECK(buffer->meta()->findInt64("durationUs", &durationUs));
                delayUs = baseUs + timeUs - ALooper::GetNowUs();

                msg->post(delayUs > 0ll ? delayUs : 0ll);
            } else {
                // try again in 1 second
                msg->post(1000000ll);
            }

            break;
        }

        default:
            Source::onMessageReceived(msg);
            break;
    }
}

void NuPlayer::HTTPLiveSourceCustom::onSessionNotify(const sp<AMessage> &msg) {
    int32_t what;
    CHECK(msg->findInt32("what", &what));

    switch (what) {
        case LiveSessionCustom::kWhatPrepared:
        {
            // notify the current size here if we have it, otherwise report an initial size of (0,0)
            sp<AMessage> format = getFormat(false /* audio */);
            int32_t width;
            int32_t height;
            if (format != NULL &&
                    format->findInt32("width", &width) && format->findInt32("height", &height)) {
                notifyVideoSizeChanged(format);
            } else {
                notifyVideoSizeChanged();
            }

            uint32_t flags = FLAG_CAN_PAUSE;
            if (mLiveSession->isSeekable()) {
                flags |= FLAG_CAN_SEEK;
                flags |= FLAG_CAN_SEEK_BACKWARD;
                flags |= FLAG_CAN_SEEK_FORWARD;
            }

            if (mLiveSession->hasDynamicDuration()) {
                flags |= FLAG_DYNAMIC_DURATION;
            }

            notifyFlagsChanged(flags);

            notifyPrepared();
            break;
        }

        case LiveSessionCustom::kWhatPreparationFailed:
        {
            status_t err;
            CHECK(msg->findInt32("err", &err));

            notifyPrepared(err);
            break;
        }

        case LiveSessionCustom::kWhatStreamsChanged:
        {
            uint32_t changedMask;
            CHECK(msg->findInt32(
                        "changedMask", (int32_t *)&changedMask));

            bool audio = changedMask & LiveSessionCustom::STREAMTYPE_AUDIO;
            bool video = changedMask & LiveSessionCustom::STREAMTYPE_VIDEO;

            sp<AMessage> reply;
            CHECK(msg->findMessage("reply", &reply));

            sp<AMessage> notify = dupNotify();
            notify->setInt32("what", kWhatQueueDecoderShutdown);
            notify->setInt32("audio", audio);
            notify->setInt32("video", video);
            notify->setMessage("reply", reply);
            notify->post();
            break;
        }

        case LiveSessionCustom::kWhatError:
        {
            break;
        }

        default:
            TRESPASS();
    }
}

}  // namespace android
+0 −81
Original line number Diff line number Diff line
/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef HTTP_LIVE_SOURCE_CUSTOM_H_

#define HTTP_LIVE_SOURCE_CUSTOM_H_

#include "NuPlayer.h"
#include "NuPlayerSource.h"

namespace android {

struct LiveSessionCustom;

struct NuPlayer::HTTPLiveSourceCustom : public NuPlayer::Source {
    HTTPLiveSourceCustom(
            const sp<AMessage> &notify,
            const sp<IMediaHTTPService> &httpService,
            const char *url,
            const KeyedVector<String8, String8> *headers);

    virtual void prepareAsync();
    virtual void start();

    virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit);
    virtual sp<AMessage> getFormat(bool audio);

    virtual status_t feedMoreTSData();
    virtual status_t getDuration(int64_t *durationUs);
    virtual size_t getTrackCount() const;
    virtual sp<AMessage> getTrackInfo(size_t trackIndex) const;
    virtual status_t selectTrack(size_t trackIndex, bool select);
    virtual status_t seekTo(int64_t seekTimeUs);

protected:
    virtual ~HTTPLiveSourceCustom();

    virtual void onMessageReceived(const sp<AMessage> &msg);

private:
    enum Flags {
        // Don't log any URLs.
        kFlagIncognito = 1,
    };

    enum {
        kWhatSessionNotify,
        kWhatFetchSubtitleData,
    };

    sp<IMediaHTTPService> mHTTPService;
    AString mURL;
    KeyedVector<String8, String8> mExtraHeaders;
    uint32_t mFlags;
    status_t mFinalResult;
    off64_t mOffset;
    sp<ALooper> mLiveLooper;
    sp<LiveSessionCustom> mLiveSession;
    int32_t mFetchSubtitleDataGeneration;

    void onSessionNotify(const sp<AMessage> &msg);

    DISALLOW_EVIL_CONSTRUCTORS(HTTPLiveSourceCustom);
};

}  // namespace android

#endif  // HTTP_LIVE_SOURCE_CUSTOM_H_
+1 −41
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@
#include "NuPlayer.h"

#include "HTTPLiveSource.h"
#include "HTTPLiveSourceCustom.h"
#include "NuPlayerDecoder.h"
#include "NuPlayerDecoderPassThrough.h"
#include "NuPlayerDriver.h"
@@ -44,15 +43,11 @@
#include <media/stagefright/MetaData.h>
#include <gui/IGraphicBufferProducer.h>

#include <cutils/properties.h>

#include "avc_utils.h"

#include "ESDS.h"
#include <media/stagefright/Utils.h>

#include "ExtendedUtils.h"

namespace android {

static int64_t kLowWaterMarkUs = 2000000ll;  // 2secs
@@ -182,8 +177,6 @@ NuPlayer::NuPlayer()
      mVideoScalingMode(NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW),
      mStarted(false),
      mBuffering(false),
      mPlaying(false),
      mImageShowed(false),
      mSkipAudioFlushAfterSuspend(false),
      mSkipVideoFlushAfterSuspend(false),
      mSeeking(false) {
@@ -244,13 +237,7 @@ void NuPlayer::setDataSourceAsync(

    sp<Source> source;
    if (IsHTTPLiveURL(url)) {
        char value[PROPERTY_VALUE_MAX];
        property_get("persist.media.hls.enhancements", value, NULL);
        if (atoi(value)) {
            source = new HTTPLiveSourceCustom(notify, httpService, url, headers);
        } else {
        source = new HTTPLiveSource(notify, httpService, url, headers);
        }
    } else if (!strncasecmp(url, "rtsp://", 7)) {
        source = new RTSPSource(
                notify, httpService, url, headers, mUIDValid, mUID);
@@ -1473,14 +1460,6 @@ status_t NuPlayer::feedDecoderInputData(bool audio, const sp<AMessage> &msg) {
                        getDecoder(audio)->supportsSeamlessFormatChange(newFormat);
                    // treat seamless format change separately
                    formatChange = !seamlessFormatChange;

                    if (mImageShowed && !audio) {
                        // If the image was showed in native window, video
                        // decoder needs to be changed to reconfigure
                        // native window
                        mImageShowed = false;
                        formatChange = true;
                    }
                }
                bool shutdownOrFlush = formatChange || timeChange;

@@ -2303,25 +2282,6 @@ void NuPlayer::onSourceNotify(const sp<AMessage> &msg) {
            break;
        }

        case Source::kWhatShowImage:
        {
            if (mNativeWindow == NULL) {
                ALOGW("native window is null");
                return;
            }
            msg->setObject("native-window", mNativeWindow);
            sp<AMessage> format = new AMessage;
            int32_t width, height;
            ExtendedUtils::showImageInNativeWindow(msg, format);
            if (format->findInt32("width", &width)
                    && format->findInt32("height", &height)) {
                ALOGV("show the image with width = %ld,  height = %ld", width, height);
                notifyListener(MEDIA_SET_VIDEO_SIZE, width, height);
                mImageShowed = true;
            }
            break;
        }

        default:
            TRESPASS();
    }
Loading