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

Commit 8f935263 authored by Byeongjo Park's avatar Byeongjo Park Committed by Lajos Molnar
Browse files

VT: SFP: H264: CVO implementation for Rx side



CVO(Coordination of Video Orientation) implemented for H264.

Support Coordination of Video Orientation (CVO) feature that carried in RTP Header extension.
it parses a device degrees(orientation) in RTP extension that remote sent.
(6.2.3 of 3GPP Release 12 TS 26.114)

Once AAVCAssembler parsed a video degress from RTP(CVO) extension,
A native window will be rotated as per parsed video degress.

Change-Id: I802a9e43d9ee54b7970d2541f18fb4af8022336a
Signed-off-by: default avatarByeongjo Park <bjo.park@samsung.com>
Signed-off-by: default avatarKim Sungyeon <sy85.kim@samsung.com>
Merged-In: I802a9e43d9ee54b7970d2541f18fb4af8022336a
parent 6552d60d
Loading
Loading
Loading
Loading
+17 −11
Original line number Diff line number Diff line
@@ -2838,28 +2838,34 @@ void NuPlayer::sendTimedTextData(const sp<ABuffer> &buffer) {
}

void NuPlayer::sendIMSRxNotice(const sp<AMessage> &msg) {
    int32_t notice, payloadType, feedbackType, id, bitrate;
    int32_t payloadType;

    CHECK(msg->findInt32("IMS-Rx-notice", &notice));
    CHECK(msg->findInt32("payload-type", &payloadType));
    CHECK(msg->findInt32("feedback-type", &feedbackType));
    CHECK(msg->findInt32("sender", &id));

    Parcel in;
    in.writeInt32(payloadType);
    in.writeInt32(feedbackType);
    in.writeInt32(id);

    switch (payloadType) {
        case 205:   // TSFB
        case NuPlayer::RTPSource::RTCP_TSFB:   // RTCP TSFB
        case NuPlayer::RTPSource::RTCP_PSFB:   // RTCP PSFB
        {
            int32_t feedbackType, id;
            CHECK(msg->findInt32("feedback-type", &feedbackType));
            CHECK(msg->findInt32("sender", &id));
            in.writeInt32(feedbackType);
            in.writeInt32(id);
            if (payloadType == NuPlayer::RTPSource::RTCP_TSFB) {
                int32_t bitrate;
                CHECK(msg->findInt32("bit-rate", &bitrate));
                in.writeInt32(bitrate);
            }
            break;
        }
        case 206:   // PSFB
        case NuPlayer::RTPSource::RTP_CVO:
        {
            // nothing to do yet
            int32_t cvo;
            CHECK(msg->findInt32("cvo", &cvo));
            in.writeInt32(cvo);
            break;
        }
        default:
+19 −1
Original line number Diff line number Diff line
@@ -1050,7 +1050,7 @@ bool NuPlayer::Decoder::onInputBufferFetched(const sp<AMessage> &msg) {
        uint32_t flags = 0;
        CHECK(buffer->meta()->findInt64("timeUs", &timeUs));

        int32_t eos, csd;
        int32_t eos, csd, cvo;
        // we do not expect SYNCFRAME for decoder
        if (buffer->meta()->findInt32("eos", &eos) && eos) {
            flags |= MediaCodec::BUFFER_FLAG_EOS;
@@ -1058,6 +1058,24 @@ bool NuPlayer::Decoder::onInputBufferFetched(const sp<AMessage> &msg) {
            flags |= MediaCodec::BUFFER_FLAG_CODECCONFIG;
        }

        if (buffer->meta()->findInt32("cvo", (int32_t*)&cvo)) {
            ALOGV("[%s] cvo(%d) found at %lld us", mComponentName.c_str(), cvo, (long long)timeUs);
            switch (cvo) {
                case 0:
                    codecBuffer->meta()->setInt32("cvo", MediaCodec::CVO_DEGREE_0);
                    break;
                case 1:
                    codecBuffer->meta()->setInt32("cvo", MediaCodec::CVO_DEGREE_90);
                    break;
                case 2:
                    codecBuffer->meta()->setInt32("cvo", MediaCodec::CVO_DEGREE_180);
                    break;
                case 3:
                    codecBuffer->meta()->setInt32("cvo", MediaCodec::CVO_DEGREE_270);
                    break;
            }
        }

        // Modular DRM
        MediaBufferBase *mediaBuf = NULL;
        NuPlayerDrm::CryptoInfo *cryptInfo = NULL;
+28 −3
Original line number Diff line number Diff line
@@ -44,7 +44,8 @@ NuPlayer::RTPSource::RTPSource(
      mInPreparationPhase(true),
      mRTPConn(new ARTPConnection),
      mEOSTimeoutAudio(0),
      mEOSTimeoutVideo(0) {
      mEOSTimeoutVideo(0),
      mLastCVOUpdated(-1) {
      ALOGD("RTPSource initialized with rtpParams=%s", rtpParams.string());
}

@@ -92,7 +93,7 @@ void NuPlayer::RTPSource::prepareAsync() {
        AString sdp;
        ASessionDescription::SDPStringFactory(sdp, info->mLocalIp,
                info->mIsAudio, info->mLocalPort, info->mPayloadType, info->mAS, info->mCodecName,
                NULL, info->mWidth, info->mHeight);
                NULL, info->mWidth, info->mHeight, info->mCVOExtMap);
        ALOGD("RTPSource SDP =>\n%s", sdp.c_str());

        sp<ASessionDescription> desc = new ASessionDescription;
@@ -273,7 +274,29 @@ status_t NuPlayer::RTPSource::dequeueAccessUnit(

    setEOSTimeout(audio, 0);

    return source->dequeueAccessUnit(accessUnit);
    finalResult = source->dequeueAccessUnit(accessUnit);
    if (finalResult != OK) {
        return finalResult;
    }

    int32_t cvo;
    if ((*accessUnit) != NULL && (*accessUnit)->meta()->findInt32("cvo", &cvo)) {
        if (cvo != mLastCVOUpdated) {
            sp<AMessage> msg = new AMessage();
            msg->setInt32("payload-type", NuPlayer::RTPSource::RTP_CVO);
            msg->setInt32("cvo", cvo);

            sp<AMessage> notify = dupNotify();
            notify->setInt32("what", kWhatIMSRxNotice);
            notify->setMessage("message", msg);
            notify->post();

            ALOGV("notify cvo updated (%d)->(%d) to upper layer", mLastCVOUpdated, cvo);
            mLastCVOUpdated = cvo;
        }
    }

    return finalResult;
}

sp<AnotherPacketSource> NuPlayer::RTPSource::getSource(bool audio) {
@@ -666,6 +689,8 @@ status_t NuPlayer::RTPSource::setParameter(const String8 &key, const String8 &va
    } else if (key == "rtp-param-time-scale") {
    } else if (key == "rtp-param-self-id") {
        info->mSelfID = atoi(value);
    } else if (key == "rtp-param-ext-cvo-extmap") {
        info->mCVOExtMap = atoi(value);
    }

    return OK;
+9 −0
Original line number Diff line number Diff line
@@ -53,6 +53,12 @@ struct NuPlayer::RTPSource : public NuPlayer::Source {
            const sp<AMessage> &notify,
            const String8& rtpParams);

    enum {
        RTCP_TSFB = 205,
        RTCP_PSFB = 206,
        RTP_CVO = 300,
    };

    virtual status_t getBufferingSettings(
            BufferingSettings* buffering /* nonnull */) override;
    virtual status_t setBufferingSettings(const BufferingSettings& buffering) override;
@@ -116,6 +122,8 @@ private:

        /* Unique ID indicates itself */
        uint32_t mSelfID;
        /* extmap:<value> for CVO will be set to here */
        int32_t mCVOExtMap;

        /* a copy of TrackInfo in RTSPSource */
        sp<AnotherPacketSource> mSource;
@@ -168,6 +176,7 @@ private:
    int64_t mMediaAnchorUs;
    int64_t mLastMediaTimeUs;
    int64_t mNumAccessUnitsReceived;
    int32_t mLastCVOUpdated;
    bool mReceivedFirstRTCPPacket;
    bool mReceivedFirstRTPPacket;
    bool mPausing;
+7 −0
Original line number Diff line number Diff line
@@ -6164,6 +6164,13 @@ void ACodec::BaseState::onInputBufferFilled(const sp<AMessage> &msg) {
        return;
    }

    int32_t cvo;
    if (mCodec->mNativeWindow != NULL && buffer != NULL &&
            buffer->meta()->findInt32("cvo", &cvo)) {
        ALOGV("cvo(%d) found in buffer #%u", cvo, bufferID);
        setNativeWindowRotation(mCodec->mNativeWindow.get(), cvo);
    }

    info->mStatus = BufferInfo::OWNED_BY_US;
    info->mData = buffer;

Loading