blob: a5e8e22195d4f345fd75c530175e198dfbe82df0 [file] [log] [blame]
Chih-Chung Chang99698662011-06-30 14:21:38 +08001/*
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
17#include <stdint.h>
18
19#include <utils/RefBase.h>
20#include <utils/threads.h>
21
22#include <media/stagefright/MediaSource.h>
23
24#include "AudioBufferProvider.h"
25#include "AudioResampler.h"
26
27namespace android {
28
29struct MediaBuffer;
30
31class 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
Chih-Chung Chang99698662011-06-30 14:21:38 +080046 enum { //Sampling freq
47 kFreq8000Hz = 8000,
48 kFreq11025Hz = 11025,
49 kFreq12000Hz = 12000,
50 kFreq16000Hz = 16000,
51 kFreq22050Hz = 22050,
52 kFreq240000Hz = 24000,
53 kFreq32000Hz = 32000,
54 kFreq44100 = 44100,
55 kFreq48000 = 48000,
56 };
57
58 static const uint16_t UNITY_GAIN = 0x1000;
Chih-Chung Chang3d974e72011-08-18 19:41:30 +080059 static const int32_t DEFAULT_SAMPLING_FREQ = (int32_t)kFreq32000Hz;
Chih-Chung Chang99698662011-06-30 14:21:38 +080060
61 protected :
62 virtual ~VideoEditorSRC();
63 private:
64
65 VideoEditorSRC();
66 VideoEditorSRC &operator=(const VideoEditorSRC &);
67
Chih-Chung Chang3d974e72011-08-18 19:41:30 +080068 void checkAndSetResampler();
Rajneesh Chowdury1c3c5432011-07-20 13:47:34 -070069
Chih-Chung Chang99698662011-06-30 14:21:38 +080070 AudioResampler *mResampler;
71 sp<MediaSource> mSource;
Chih-Chung Chang99698662011-06-30 14:21:38 +080072 int mChannelCnt;
73 int mSampleRate;
74 int32_t mOutputSampleRate;
75 bool mStarted;
Chih-Chung Chang99698662011-06-30 14:21:38 +080076 sp<MetaData> mOutputFormat;
Chih-Chung Chang99698662011-06-30 14:21:38 +080077
Chih-Chung Chang3d974e72011-08-18 19:41:30 +080078 MediaBuffer* mBuffer;
Chih-Chung Chang99698662011-06-30 14:21:38 +080079 int32_t mLeftover;
Chih-Chung Chang3d974e72011-08-18 19:41:30 +080080 bool mFormatChanged;
Chih-Chung Chang99698662011-06-30 14:21:38 +080081
82 int64_t mInitialTimeStampUs;
83 int64_t mAccuOutBufferSize;
84
85 int64_t mSeekTimeUs;
86 ReadOptions::SeekMode mSeekMode;
Chih-Chung Chang99698662011-06-30 14:21:38 +080087};
88
89} //namespce android
90