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