Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 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 |
|
Kenny Root | eb5b265 | 2011-02-08 11:13:19 -0800 | [diff] [blame] | 18 | #include <stdint.h>
|
| 19 |
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 20 | #include <utils/RefBase.h>
|
James Dong | e6815bf | 2011-05-02 18:23:42 -0700 | [diff] [blame^] | 21 | #include <utils/threads.h>
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 22 |
|
| 23 | #include <media/stagefright/MediaSource.h>
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 24 |
|
| 25 | #include "AudioBufferProvider.h"
|
| 26 | #include "AudioResampler.h"
|
| 27 |
|
| 28 | namespace android {
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 29 |
|
James Dong | e6815bf | 2011-05-02 18:23:42 -0700 | [diff] [blame^] | 30 | struct MediaBuffer;
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 31 |
|
| 32 | class VideoEditorSRC : public MediaSource , public AudioBufferProvider {
|
| 33 |
|
| 34 | public:
|
| 35 | VideoEditorSRC(
|
| 36 | const sp<MediaSource> &source);
|
| 37 |
|
| 38 | virtual status_t start (MetaData *params = NULL);
|
| 39 | virtual status_t stop();
|
| 40 | virtual sp<MetaData> getFormat();
|
| 41 | virtual status_t read (
|
| 42 | MediaBuffer **buffer, const ReadOptions *options = NULL);
|
| 43 |
|
| 44 | virtual status_t getNextBuffer(Buffer* buffer);
|
| 45 | virtual void releaseBuffer(Buffer* buffer);
|
| 46 |
|
| 47 | void setResampling(int32_t sampleRate=kFreq32000Hz);
|
| 48 |
|
| 49 | enum { //Sampling freq
|
| 50 | kFreq8000Hz = 8000,
|
James Dong | e6815bf | 2011-05-02 18:23:42 -0700 | [diff] [blame^] | 51 | kFreq11025Hz = 11025,
|
| 52 | kFreq12000Hz = 12000,
|
| 53 | kFreq16000Hz = 16000,
|
| 54 | kFreq22050Hz = 22050,
|
| 55 | kFreq240000Hz = 24000,
|
| 56 | kFreq32000Hz = 32000,
|
| 57 | kFreq44100 = 44100,
|
| 58 | kFreq48000 = 48000,
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 59 | };
|
| 60 |
|
| 61 | static const uint16_t UNITY_GAIN = 0x1000;
|
| 62 | static const int32_t DEFAULT_SAMPLING_FREQ = (int32_t)kFreq32000Hz; // kFreq44100;
|
| 63 |
|
| 64 | protected :
|
| 65 | virtual ~VideoEditorSRC();
|
| 66 | private:
|
| 67 |
|
| 68 | VideoEditorSRC();
|
| 69 | VideoEditorSRC &operator=(const VideoEditorSRC &);
|
| 70 |
|
| 71 | AudioResampler *mResampler;
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 72 | sp<MediaSource> mSource;
|
| 73 | MediaBuffer *mCopyBuffer;
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 74 | int mBitDepth;
|
| 75 | int mChannelCnt;
|
| 76 | int mSampleRate;
|
| 77 | int32_t mOutputSampleRate;
|
| 78 | bool mStarted;
|
| 79 | bool mIsResamplingRequired;
|
| 80 | bool mIsChannelConvertionRequired; // for mono to stereo
|
| 81 | sp<MetaData> mOutputFormat;
|
| 82 | Mutex mLock;
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 83 |
|
James Dong | e6815bf | 2011-05-02 18:23:42 -0700 | [diff] [blame^] | 84 | uint8_t* mInterframeBuffer;
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 85 | int32_t mInterframeBufferPosition;
|
| 86 | int32_t mLeftover;
|
| 87 | int32_t mLastReadSize ;
|
| 88 |
|
| 89 | int64_t mInitialTimeStampUs;
|
| 90 | int64_t mAccuOutBufferSize;
|
| 91 |
|
| 92 | int64_t mSeekTimeUs;
|
| 93 | ReadOptions::SeekMode mSeekMode;
|
Santosh Madhava | 9785cdf | 2011-02-08 23:26:18 -0800 | [diff] [blame] | 94 | int16_t *mReSampledBuffer;
|
Dharmaray Kundargi | 643290d | 2011-01-16 16:02:42 -0800 | [diff] [blame] | 95 |
|
| 96 | };
|
| 97 |
|
| 98 | } //namespce android
|
| 99 |
|