blob: 1707d4d4182c87660768c81f728540d4e91bb03d [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
James Dong00f742c2012-01-13 17:34:42 -080017
Chih-Chung Chang99698662011-06-30 14:21:38 +080018#include <stdint.h>
Chih-Chung Chang99698662011-06-30 14:21:38 +080019#include <media/stagefright/MediaSource.h>
Glenn Kasten2dd4bdd2012-08-29 11:10:32 -070020#include <media/AudioBufferProvider.h>
Chih-Chung Chang99698662011-06-30 14:21:38 +080021#include "AudioResampler.h"
22
23namespace android {
24
25struct MediaBuffer;
26
27class VideoEditorSRC : public MediaSource , public AudioBufferProvider {
28
James Dong00f742c2012-01-13 17:34:42 -080029public:
30 VideoEditorSRC(const sp<MediaSource> &source);
Chih-Chung Chang99698662011-06-30 14:21:38 +080031
James Dong00f742c2012-01-13 17:34:42 -080032 virtual status_t start (MetaData *params = NULL);
33 virtual status_t stop();
34 virtual sp<MetaData> getFormat();
35 virtual status_t read (
36 MediaBuffer **buffer, const ReadOptions *options = NULL);
Chih-Chung Chang99698662011-06-30 14:21:38 +080037
John Grossman7719f632012-02-10 13:46:24 -080038 virtual status_t getNextBuffer(Buffer* buffer, int64_t pts);
James Dong00f742c2012-01-13 17:34:42 -080039 virtual void releaseBuffer(Buffer* buffer);
Chih-Chung Chang99698662011-06-30 14:21:38 +080040
James Dong00f742c2012-01-13 17:34:42 -080041 // Sampling freqencies
42 enum {
43 kFreq8000Hz = 8000,
Chih-Chung Chang99698662011-06-30 14:21:38 +080044 kFreq11025Hz = 11025,
45 kFreq12000Hz = 12000,
46 kFreq16000Hz = 16000,
47 kFreq22050Hz = 22050,
James Dong7a4097c2012-01-17 14:23:29 -080048 kFreq24000Hz = 24000,
Chih-Chung Chang99698662011-06-30 14:21:38 +080049 kFreq32000Hz = 32000,
James Dong00f742c2012-01-13 17:34:42 -080050 kFreq44100Hz = 44100,
51 kFreq48000Hz = 48000,
Chih-Chung Chang99698662011-06-30 14:21:38 +080052 };
53
James Dong00f742c2012-01-13 17:34:42 -080054protected :
55 virtual ~VideoEditorSRC();
Chih-Chung Chang99698662011-06-30 14:21:38 +080056
James Dong00f742c2012-01-13 17:34:42 -080057private:
58 AudioResampler *mResampler;
59 sp<MediaSource> mSource;
60 int mChannelCnt;
61 int mSampleRate;
62 int32_t mOutputSampleRate;
63 bool mStarted;
64 sp<MetaData> mOutputFormat;
Chih-Chung Chang99698662011-06-30 14:21:38 +080065
James Dong00f742c2012-01-13 17:34:42 -080066 MediaBuffer* mBuffer;
67 int32_t mLeftover;
68 bool mFormatChanged;
69 bool mStopPending;
Chih-Chung Chang99698662011-06-30 14:21:38 +080070
James Dong00f742c2012-01-13 17:34:42 -080071 int64_t mInitialTimeStampUs;
72 int64_t mAccuOutBufferSize;
Rajneesh Chowdury1c3c5432011-07-20 13:47:34 -070073
James Dong00f742c2012-01-13 17:34:42 -080074 int64_t mSeekTimeUs;
75 ReadOptions::SeekMode mSeekMode;
Chih-Chung Chang99698662011-06-30 14:21:38 +080076
James Dong00f742c2012-01-13 17:34:42 -080077 VideoEditorSRC();
78 void checkAndSetResampler();
Chih-Chung Chang99698662011-06-30 14:21:38 +080079
James Dong00f742c2012-01-13 17:34:42 -080080 // Don't call me
81 VideoEditorSRC(const VideoEditorSRC&);
82 VideoEditorSRC &operator=(const VideoEditorSRC &);
Chih-Chung Chang99698662011-06-30 14:21:38 +080083
Chih-Chung Chang99698662011-06-30 14:21:38 +080084};
85
86} //namespce android
87