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

Commit 638df3a5 authored by Lajos Molnar's avatar Lajos Molnar
Browse files

media: miscellaneous fixes to VT contribution

- fix MediaSource.h path
- fix setDataSource binder code
- use MediaCodecConstants instead of OMX/ACodec constants
- fix spacing
- fix typos
- remove unused code
- commented some tricky code segments
- AAVC/HEVCAssembler: re-read next buffer if buffer was deleted
- RTPSource: pull out constants kMinVideoBitrate and kBufferingPollIntervalUs
- RTPSource: check state early in prepareAsync
- RTPSource: fix potential null dereference in setSource
- ARTPAssembler: make showing queue runtime configurable via debug.stagefright.rtp bool property
- ARTPWriter: fix security issues: protect against reading OOB in
  sendSPSPPSIfIFrame and StripStartcode
- ARTPWriter: free buffers early in destructor
- ARTPWriter: create PPS buffer only if there is PPS
- ARTPConnection: fix security issues: protect against reading OOB in
  parseRTPExt, parseTSFB, and parsePSFB. Also remove remote null-dereference.
- AHEVCAssembler: fix security issues: protect against reading OOB in
  addFragmentedNALUnit

Bug: 121230209
Test: build
Merged-in: Iada8b878e396452c1d281c60f3754e13e34bcddb
Change-Id: Iada8b878e396452c1d281c60f3754e13e34bcddb
parent c862b435
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -697,7 +697,7 @@ status_t BnMediaPlayer::onTransact(
        }
        case SET_DATA_SOURCE_RTP: {
            CHECK_INTERFACE(IMediaPlayer, data, reply);
            const String8& rtpParams = data.readString8();
            String8 rtpParams = data.readString8();
            reply->writeInt32(setDataSource(rtpParams));
            return NO_ERROR;
        }
+1 −1
Original line number Diff line number Diff line
@@ -292,7 +292,7 @@ private:
    Mutex                       mLock;
    Mutex                       mNotifyLock;

    int                         mOutputFormat;
    output_format               mOutputFormat;
};

};  // namespace android
+2 −2
Original line number Diff line number Diff line
@@ -244,7 +244,7 @@ status_t MediaRecorder::setOutputFormat(int of)
        mCurrentState = MEDIA_RECORDER_ERROR;
        return ret;
    }
    mOutputFormat = of;
    mOutputFormat = (output_format)of;
    mCurrentState = MEDIA_RECORDER_DATASOURCE_CONFIGURED;
    return ret;
}
@@ -745,7 +745,7 @@ void MediaRecorder::doCleanUp()
    mIsAudioEncoderSet = false;
    mIsVideoEncoderSet = false;
    mIsOutputFileSet   = false;
    mOutputFormat      = 0;
    mOutputFormat      = OUTPUT_FORMAT_DEFAULT;
}

// Release should be OK in any state
+8 −7
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@
#include <media/stagefright/CameraSourceTimeLapse.h>
#include <media/stagefright/MPEG2TSWriter.h>
#include <media/stagefright/MPEG4Writer.h>
#include <media/stagefright/MediaCodecConstants.h>
#include <media/stagefright/MediaDefs.h>
#include <media/stagefright/MetaData.h>
#include <media/stagefright/MediaCodecSource.h>
@@ -578,9 +579,9 @@ status_t StagefrightRecorder::setParamVideoEncodingBitRate(int32_t 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 */
        // Regular I frames may overload the network so we reduce the bitrate to allow
        // margins for the I frame overruns.
        // Still send requested bitrate (TMMBR) in the reply (TMMBN).
        const float coefficient = 0.8f;
        mVideoBitRate = (bitRate * coefficient) / 1000 * 1000;
        mVideoEncoderSource->setEncodingBitrate(mVideoBitRate);
@@ -593,6 +594,7 @@ status_t StagefrightRecorder::setParamVideoEncodingBitRate(int32_t bitRate) {

status_t StagefrightRecorder::setParamVideoBitRateMode(int32_t bitRateMode) {
    ALOGV("setParamVideoBitRateMode: %d", bitRateMode);
    // TODO: clarify what bitrate mode of -1 is as these start from 0
    if (bitRateMode < -1) {
        ALOGE("Unsupported video bitrate mode: %d", bitRateMode);
        return BAD_VALUE;
@@ -1990,7 +1992,6 @@ status_t StagefrightRecorder::setupVideoEncoder(
    }

    format->setInt32("bitrate", mVideoBitRate);
    // OMX encoder option how to control bitrate
    format->setInt32("bitrate-mode", mVideoBitRateMode);
    format->setInt32("frame-rate", mFrameRate);
    format->setInt32("i-frame-interval", mIFramesIntervalSec);
@@ -2414,8 +2415,8 @@ status_t StagefrightRecorder::reset() {
    mVideoHeight   = 144;
    mFrameRate     = -1;
    mVideoBitRate  = 192000;
    // Following ACodec's default
    mVideoBitRateMode = OMX_Video_ControlRateVariable;
    // Following MediaCodec's default
    mVideoBitRateMode = BITRATE_MODE_VBR;
    mSampleRate    = 8000;
    mAudioChannels = 1;
    mAudioBitRate  = 12200;
+0 −2
Original line number Diff line number Diff line
@@ -1928,8 +1928,6 @@ status_t NuPlayer::instantiateDecoder(

    format->setInt32("priority", 0 /* realtime */);

    AString mime;
    format->findString("mime", &mime);
    if (mDataSourceType == DATA_SOURCE_TYPE_RTP) {
        ALOGV("instantiateDecoder: set decoder error free on stream corrupt.");
        format->setInt32("corrupt-free", true);
Loading