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

Commit 1ea977c1 authored by Manikanta Kanamarlapudi's avatar Manikanta Kanamarlapudi Committed by Steve Kondik
Browse files

httplive: Support embedded images in audio-only playlist

- parse the embedded image from mpeg2-ts with ID3 extractor
- decode the image to RGB565 format with jpeglib
- use nativewindow to display the decoded image during audio only
  playback

Change-Id: I9fc5dbb51217e3d2213541a95dcf058827328271
parent 22f6020c
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/MetaData.h>

#include "ExtendedUtils.h"

namespace android {

NuPlayer::HTTPLiveSourceCustom::HTTPLiveSourceCustom(
@@ -117,10 +119,21 @@ status_t NuPlayer::HTTPLiveSourceCustom::feedMoreTSData() {

status_t NuPlayer::HTTPLiveSourceCustom::dequeueAccessUnit(
        bool audio, sp<ABuffer> *accessUnit) {
    return mLiveSession->dequeueAccessUnit(
    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) {
+31 −1
Original line number Diff line number Diff line
@@ -51,6 +51,8 @@
#include "ESDS.h"
#include <media/stagefright/Utils.h>

#include "ExtendedUtils.h"

namespace android {

static int64_t kLowWaterMarkUs = 2000000ll;  // 2secs
@@ -179,7 +181,8 @@ NuPlayer::NuPlayer()
      mVideoScalingMode(NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW),
      mStarted(false),
      mBuffering(false),
      mPlaying(false) {
      mPlaying(false),
      mImageShowed(false) {

    clearFlushComplete();
    mPlayerExtendedStats = (PlayerExtendedStats *)ExtendedStats::Create(
@@ -1392,6 +1395,14 @@ 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;

@@ -2134,6 +2145,25 @@ 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();
    }
+2 −0
Original line number Diff line number Diff line
@@ -200,6 +200,8 @@ private:
    bool mBuffering;
    bool mPlaying;

    bool mImageShowed;

    inline const sp<Decoder> &getDecoder(bool audio) {
        return audio ? mAudioDecoder : mVideoDecoder;
    }
+1 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ struct NuPlayer::Source : public AHandler {
        kWhatTimedTextData,
        kWhatQueueDecoderShutdown,
        kWhatDrmNoLicense,
        kWhatShowImage,
    };

    // The provides message is used to notify the player about various
+3 −1
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ LOCAL_C_INCLUDES:= \
        $(TOP)/system/netd/include \
        $(TOP)/external/icu/icu4c/source/common \
        $(TOP)/external/icu/icu4c/source/i18n \
        $(TOP)/external/jpeg \

LOCAL_SHARED_LIBRARIES := \
        libbinder \
@@ -104,7 +105,8 @@ LOCAL_SHARED_LIBRARIES := \
        libutils \
        libvorbisidec \
        libz \
        libpowermanager
        libpowermanager \
        libjpeg

ifeq ($(BOARD_USES_QCOM_HARDWARE),true)
ifneq ($(filter msm7x30 msm8660 msm8960,$(TARGET_BOARD_PLATFORM)),)
Loading