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