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

Commit 159665dd authored by Lajos Molnar's avatar Lajos Molnar Committed by Gerrit Code Review
Browse files

Merge "VT: StagefrightRecorder: Added a function for TMMBR"

parents 557ec279 8eab0ead
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -570,6 +570,17 @@ status_t StagefrightRecorder::setParamVideoEncodingBitRate(int32_t bitRate) {
    // range that a specific encoder supports. The mismatch between the
    // the target and requested bit rate will NOT be treated as an error.
    mVideoBitRate = bitRate;

    // A new bitrate(TMMBR) should be applied on runtime as well if OutputFormat is RTP_AVP
    if (mOutputFormat == OUTPUT_FORMAT_RTP_AVP &&  mStarted && mPauseStartTimeUs == 0) {
        /* Regular I frames overloads on the network so we should consider about it.
         * Discounted encoding bitrate will be margins for the overloads.
         * But applied bitrate reply(TMMBN) must be sent as same as TMMBR */
        const float coefficient = 0.8f;
        mVideoBitRate = (bitRate * coefficient) / 1000 * 1000;
        mVideoEncoderSource->setEncodingBitrate(mVideoBitRate);
    }

    return OK;
}

+14 −0
Original line number Diff line number Diff line
@@ -435,6 +435,20 @@ void MediaCodecSource::signalBufferReturned(MediaBufferBase *buffer) {
    buffer->release();
}

status_t MediaCodecSource::setEncodingBitrate(int32_t bitRate) {
    ALOGV("setEncodingBitrate (%d)", bitRate);

    if (mEncoder == NULL) {
        ALOGW("setEncodingBitrate (%d) : mEncoder is null", bitRate);
        return BAD_VALUE;
    }

    sp<AMessage> params = new AMessage;
    params->setInt32("video-bitrate", bitRate);

    return mEncoder->setParameters(params);
}

MediaCodecSource::MediaCodecSource(
        const sp<ALooper> &looper,
        const sp<AMessage> &outputFormat,
+1 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ struct MediaCodecSource : public MediaSource,

    // MediaBufferObserver
    virtual void signalBufferReturned(MediaBufferBase *buffer);
    virtual status_t setEncodingBitrate(int32_t bitRate);

    // for AHandlerReflector
    void onMessageReceived(const sp<AMessage> &msg);