diff options
author | Chong Zhang <chz@google.com> | 2014-02-06 18:15:49 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-02-06 18:15:50 +0000 |
commit | 7ca6e73bed1d2e1a928104feb6e9ae92953bfff5 (patch) | |
tree | 8c5d766aec7032948ec33172c060c3dc91bb9594 /include/media | |
parent | 96f8436385163764cda10f1d45e13b9bd691a8b4 (diff) | |
parent | 72cecca17d735db6532c45f0a7e10c47ee6f065a (diff) | |
download | frameworks_av-7ca6e73bed1d2e1a928104feb6e9ae92953bfff5.zip frameworks_av-7ca6e73bed1d2e1a928104feb6e9ae92953bfff5.tar.gz frameworks_av-7ca6e73bed1d2e1a928104feb6e9ae92953bfff5.tar.bz2 |
Merge "Change StagefrightRecorder to use MediaCodec"
Diffstat (limited to 'include/media')
-rw-r--r-- | include/media/IOMX.h | 1 | ||||
-rw-r--r-- | include/media/mediarecorder.h | 2 | ||||
-rw-r--r-- | include/media/stagefright/ACodec.h | 2 | ||||
-rw-r--r-- | include/media/stagefright/MediaCodecSource.h | 134 |
4 files changed, 138 insertions, 1 deletions
diff --git a/include/media/IOMX.h b/include/media/IOMX.h index 6643736..3db2c38 100644 --- a/include/media/IOMX.h +++ b/include/media/IOMX.h @@ -143,6 +143,7 @@ public: INTERNAL_OPTION_SUSPEND, // data is a bool INTERNAL_OPTION_REPEAT_PREVIOUS_FRAME_DELAY, // data is an int64_t INTERNAL_OPTION_MAX_TIMESTAMP_GAP, // data is int64_t + INTERNAL_OPTION_START_TIME, // data is an int64_t }; virtual status_t setInternalOption( node_id node, diff --git a/include/media/mediarecorder.h b/include/media/mediarecorder.h index 88a42a0..142cb90 100644 --- a/include/media/mediarecorder.h +++ b/include/media/mediarecorder.h @@ -39,7 +39,7 @@ typedef void (*media_completion_f)(status_t status, void *cookie); enum video_source { VIDEO_SOURCE_DEFAULT = 0, VIDEO_SOURCE_CAMERA = 1, - VIDEO_SOURCE_GRALLOC_BUFFER = 2, + VIDEO_SOURCE_SURFACE = 2, VIDEO_SOURCE_LIST_END // must be last - used to validate audio source type }; diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h index 7ba5acc..e284109 100644 --- a/include/media/stagefright/ACodec.h +++ b/include/media/stagefright/ACodec.h @@ -207,6 +207,8 @@ private: int64_t mRepeatFrameDelayUs; int64_t mMaxPtsGapUs; + bool mCreateInputBuffersSuspended; + status_t setCyclicIntraMacroblockRefresh(const sp<AMessage> &msg, int32_t mode); status_t allocateBuffersOnPort(OMX_U32 portIndex); status_t freeBuffersOnPort(OMX_U32 portIndex); diff --git a/include/media/stagefright/MediaCodecSource.h b/include/media/stagefright/MediaCodecSource.h new file mode 100644 index 0000000..4b18a0b --- /dev/null +++ b/include/media/stagefright/MediaCodecSource.h @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef MediaCodecSource_H_ +#define MediaCodecSource_H_ + +#include <media/stagefright/foundation/ABase.h> +#include <media/stagefright/foundation/AHandlerReflector.h> +#include <media/stagefright/MediaSource.h> + +namespace android { + +class ALooper; +class AMessage; +class IGraphicBufferProducer; +class MediaCodec; +class MetaData; + +struct MediaCodecSource : public MediaSource, + public MediaBufferObserver { + enum FlagBits { + FLAG_USE_SURFACE_INPUT = 1, + FLAG_USE_METADATA_INPUT = 2, + }; + + static sp<MediaCodecSource> Create( + const sp<ALooper> &looper, + const sp<AMessage> &format, + const sp<MediaSource> &source, + uint32_t flags = 0); + + bool isVideo() const { return mIsVideo; } + sp<IGraphicBufferProducer> getGraphicBufferProducer(); + + // MediaSource + virtual status_t start(MetaData *params = NULL); + virtual status_t stop(); + virtual status_t pause(); + virtual sp<MetaData> getFormat() { return mMeta; } + virtual status_t read( + MediaBuffer **buffer, + const ReadOptions *options = NULL); + + // MediaBufferObserver + virtual void signalBufferReturned(MediaBuffer *buffer); + + // for AHandlerReflector + void onMessageReceived(const sp<AMessage> &msg); + +protected: + virtual ~MediaCodecSource(); + +private: + struct Puller; + + enum { + kWhatPullerNotify, + kWhatEncoderActivity, + kWhatStart, + kWhatStop, + kWhatPause, + }; + + MediaCodecSource( + const sp<ALooper> &looper, + const sp<AMessage> &outputFormat, + const sp<MediaSource> &source, + uint32_t flags = 0); + + status_t onStart(MetaData *params); + status_t init(); + status_t initEncoder(); + void releaseEncoder(); + status_t feedEncoderInputBuffers(); + void scheduleDoMoreWork(); + status_t doMoreWork(); + void suspend(); + void resume(int64_t skipFramesBeforeUs = -1ll); + void signalEOS(status_t err = ERROR_END_OF_STREAM); + bool reachedEOS(); + status_t postSynchronouslyAndReturnError(const sp<AMessage> &msg); + + sp<ALooper> mLooper; + sp<ALooper> mCodecLooper; + sp<AHandlerReflector<MediaCodecSource> > mReflector; + sp<AMessage> mOutputFormat; + sp<MetaData> mMeta; + sp<Puller> mPuller; + sp<MediaCodec> mEncoder; + uint32_t mFlags; + List<uint32_t> mStopReplyIDQueue; + bool mIsVideo; + bool mStarted; + bool mStopping; + bool mDoMoreWorkPending; + bool mPullerReachedEOS; + sp<AMessage> mEncoderActivityNotify; + sp<IGraphicBufferProducer> mGraphicBufferProducer; + Vector<sp<ABuffer> > mEncoderInputBuffers; + Vector<sp<ABuffer> > mEncoderOutputBuffers; + List<MediaBuffer *> mInputBufferQueue; + List<size_t> mAvailEncoderInputIndices; + List<int64_t> mDecodingTimeQueue; // decoding time (us) for video + + // audio drift time + int64_t mFirstSampleTimeUs; + List<int64_t> mDriftTimeQueue; + + // following variables are protected by mOutputBufferLock + Mutex mOutputBufferLock; + Condition mOutputBufferCond; + List<MediaBuffer*> mOutputBufferQueue; + bool mEncodedReachedEOS; + status_t mErrorCode; + + DISALLOW_EVIL_CONSTRUCTORS(MediaCodecSource); +}; + +} // namespace android + +#endif /* MediaCodecSource_H_ */ |