VideoEditorSRC.h revision be47966ced9cfbbd522f2d12dfca2dffd44394a9
1/* 2 * Copyright (C) 2011 NXP Software 3 * Copyright (C) 2011 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18#include <utils/RefBase.h> 19#include <media/stagefright/MediaErrors.h> 20 21#include <media/stagefright/MediaSource.h> 22#include <media/stagefright/MediaBuffer.h> 23#include <media/stagefright/MediaBufferGroup.h> 24#include <media/stagefright/MediaDefs.h> 25 26#include "AudioBufferProvider.h" 27#include "AudioResampler.h" 28 29namespace android { 30//struct MediaSource; 31 32 33class VideoEditorSRC : public MediaSource , public AudioBufferProvider { 34 35 public: 36 VideoEditorSRC( 37 const sp<MediaSource> &source); 38 39 virtual status_t start (MetaData *params = NULL); 40 virtual status_t stop(); 41 virtual sp<MetaData> getFormat(); 42 virtual status_t read ( 43 MediaBuffer **buffer, const ReadOptions *options = NULL); 44 45 virtual status_t getNextBuffer(Buffer* buffer); 46 virtual void releaseBuffer(Buffer* buffer); 47 48 void setResampling(int32_t sampleRate=kFreq32000Hz); 49 50 enum { //Sampling freq 51 kFreq8000Hz = 8000, 52 kFreq11025Hz = 11025, 53 kFreq12000Hz = 12000, 54 kFreq16000Hz = 16000, 55 kFreq22050Hz = 22050, 56 kFreq240000Hz = 24000, 57 kFreq32000Hz = 32000, 58 kFreq44100 = 44100, 59 kFreq48000 = 48000, 60 }; 61 62 static const uint16_t UNITY_GAIN = 0x1000; 63 static const int32_t DEFAULT_SAMPLING_FREQ = (int32_t)kFreq32000Hz; // kFreq44100; 64 65 protected : 66 virtual ~VideoEditorSRC(); 67 private: 68 69 VideoEditorSRC(); 70 VideoEditorSRC &operator=(const VideoEditorSRC &); 71 72 AudioResampler *mResampler; 73 AudioBufferProvider *mbufferProvider; 74 sp<MediaSource> mSource; 75 MediaBuffer *mCopyBuffer; 76 MediaBufferGroup *mGroup; 77 uint8_t *mInputByteBuffer; 78 int32_t mInputBufferLength; 79 int mInputFrameSize; 80 int mBitDepth; 81 int mChannelCnt; 82 int mSampleRate; 83 int32_t mOutputSampleRate; 84 bool mStarted; 85 bool mIsResamplingRequired; 86 bool mIsChannelConvertionRequired; // for mono to stereo 87 sp<MetaData> mOutputFormat; 88 Mutex mLock; 89 int32_t *pTmpBuffer; 90 91 uint8_t* pInterframeBuffer; 92 int32_t mInterframeBufferPosition; 93 int32_t mLeftover; 94 int32_t mLastReadSize ; 95 96 int64_t mInitialTimeStampUs; 97 int64_t mAccuOutBufferSize; 98 99 int64_t mSeekTimeUs; 100 ReadOptions::SeekMode mSeekMode; 101 102}; 103 104} //namespce android 105 106