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

Commit bc704ddd authored by James Dong's avatar James Dong Committed by Android Git Automerger
Browse files

am 6feaa464: Enable passing parameters to the MediaWriter at runtime (at start() call).

Merge commit '6feaa464' into gingerbread-plus-aosp

* commit '6feaa464':
  Enable passing parameters to the MediaWriter at runtime (at start() call).
parents 3b335078 6feaa464
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
namespace android {

struct MediaSource;
struct MetaData;

struct AMRWriter : public MediaWriter {
    AMRWriter(const char *filename);
@@ -35,7 +36,7 @@ struct AMRWriter : public MediaWriter {

    virtual status_t addSource(const sp<MediaSource> &source);
    virtual bool reachedEOS();
    virtual status_t start();
    virtual status_t start(MetaData *params = NULL);
    virtual void stop();
    virtual void pause();

+2 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ public:
    MPEG4Writer(int fd);

    virtual status_t addSource(const sp<MediaSource> &source);
    virtual status_t start();
    virtual status_t start(MetaData *param = NULL);
    virtual bool reachedEOS();
    virtual void stop();
    virtual void pause();
@@ -83,6 +83,7 @@ private:
    int64_t getStartTimestampUs();  // Not const
    status_t startTracks();
    size_t numTracks();
    int64_t estimateMoovBoxSize(int32_t bitRate);

    void lock();
    void unlock();
+2 −1
Original line number Diff line number Diff line
@@ -24,13 +24,14 @@
namespace android {

struct MediaSource;
struct MetaData;

struct MediaWriter : public RefBase {
    MediaWriter() {}

    virtual status_t addSource(const sp<MediaSource> &source) = 0;
    virtual bool reachedEOS() = 0;
    virtual status_t start() = 0;
    virtual status_t start(MetaData *params = NULL) = 0;
    virtual void stop() = 0;
    virtual void pause() = 0;
    virtual void setMaxFileSize(int64_t bytes) { mMaxFileSizeLimitBytes = bytes; }
+2 −1
Original line number Diff line number Diff line
@@ -36,13 +36,14 @@ enum {
    kKeyStride            = 'strd',  // int32_t
    kKeySliceHeight       = 'slht',  // int32_t
    kKeyChannelCount      = '#chn',  // int32_t
    kKeySampleRate        = 'srte',  // int32_t
    kKeySampleRate        = 'srte',  // int32_t (also video frame rate)
    kKeyBitRate           = 'brte',  // int32_t (bps)
    kKeyESDS              = 'esds',  // raw data
    kKeyAVCC              = 'avcc',  // raw data
    kKeyVorbisInfo        = 'vinf',  // raw data
    kKeyVorbisBooks       = 'vboo',  // raw data
    kKeyWantsNALFragments = 'NALf',
    kKey64BitFileOffset   = 'fobt',  // int32_t (bool)
    kKeyIsSyncFrame       = 'sync',  // int32_t (bool)
    kKeyIsCodecConfig     = 'conf',  // int32_t (bool)
    kKeyTime              = 'time',  // int64_t (usecs)
+22 −4
Original line number Diff line number Diff line
@@ -316,6 +316,13 @@ status_t StagefrightRecorder::setParamIFramesInterval(int32_t interval) {
    return OK;
}

status_t StagefrightRecorder::setParam64BitFileOffset(bool use64Bit) {
    LOGV("setParam64BitFileOffset: %s",
        use64Bit? "use 64 bit file offset": "use 32 bit file offset");
    mUse64BitFileOffset = use64Bit;
    return OK;
}

status_t StagefrightRecorder::setParameter(
        const String8 &key, const String8 &value) {
    LOGV("setParameter: key (%s) => value (%s)", key.string(), value.string());
@@ -361,6 +368,11 @@ status_t StagefrightRecorder::setParameter(
        if (safe_strtoi32(value.string(), &interval)) {
            return setParamIFramesInterval(interval);
        }
    } else if (key == "param-use-64bit-offset") {
        int32_t use64BitOffset;
        if (safe_strtoi32(value.string(), &use64BitOffset)) {
            return setParam64BitFileOffset(use64BitOffset != 0);
        }
    } else {
        LOGE("setParameter: failed to find key %s", key.string());
    }
@@ -633,6 +645,7 @@ void StagefrightRecorder::clipVideoFrameHeight() {

status_t StagefrightRecorder::startMPEG4Recording() {
    mWriter = new MPEG4Writer(dup(mOutputFd));
    int32_t totalBitRate = 0;

    // Add audio source first if it exists
    if (mAudioSource != AUDIO_SOURCE_LIST_END) {
@@ -651,7 +664,7 @@ status_t StagefrightRecorder::startMPEG4Recording() {
        if (audioEncoder == NULL) {
            return UNKNOWN_ERROR;
        }

        totalBitRate += mAudioBitRate;
        mWriter->addSource(audioEncoder);
    }
    if (mVideoSource == VIDEO_SOURCE_DEFAULT
@@ -704,7 +717,7 @@ status_t StagefrightRecorder::startMPEG4Recording() {

        sp<MetaData> enc_meta = new MetaData;
        enc_meta->setInt32(kKeyBitRate, mVideoBitRate);
        enc_meta->setInt32(kKeySampleRate, mFrameRate);  // XXX: kKeySampleRate?
        enc_meta->setInt32(kKeySampleRate, mFrameRate);

        switch (mVideoEncoder) {
            case VIDEO_ENCODER_H263:
@@ -747,12 +760,13 @@ status_t StagefrightRecorder::startMPEG4Recording() {
                    true /* createEncoder */, cameraSource);

        CHECK(mOutputFd >= 0);
        totalBitRate += mVideoBitRate;
        mWriter->addSource(encoder);
    }

    {
        // MPEGWriter specific handling
        MPEG4Writer *writer = ((MPEG4Writer *) mWriter.get());  // mWriter is an MPEGWriter
        MPEG4Writer *writer = ((MPEG4Writer *) mWriter.get());
        writer->setInterleaveDuration(mInterleaveDurationUs);
    }

@@ -763,7 +777,10 @@ status_t StagefrightRecorder::startMPEG4Recording() {
        mWriter->setMaxFileSize(mMaxFileSizeBytes);
    }
    mWriter->setListener(mListener);
    mWriter->start();
    sp<MetaData> meta = new MetaData;
    meta->setInt32(kKeyBitRate, totalBitRate);
    meta->setInt32(kKey64BitFileOffset, mUse64BitFileOffset);
    mWriter->start(meta.get());
    return OK;
}

@@ -824,6 +841,7 @@ status_t StagefrightRecorder::reset() {
    mInterleaveDurationUs = 0;
    mIFramesInterval = 1;
    mAudioSourceNode = 0;
    mUse64BitFileOffset = false;
    mEncoderProfiles = MediaProfiles::getInstance();

    mOutputFd = -1;
Loading