Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 1 | /* |
| 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 | #ifndef DUMMY_AUDIOSOURCE_H_ |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 18 | #define DUMMY_AUDIOSOURCE_H_ |
| 19 | |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 20 | #include <media/stagefright/MediaSource.h> |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 21 | |
| 22 | |
| 23 | namespace android { |
| 24 | |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 25 | class MetaData; |
| 26 | struct MediaBufferGroup; |
| 27 | |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 28 | struct DummyAudioSource : public MediaSource { |
| 29 | |
| 30 | public: |
James Dong | 00f742c | 2012-01-13 17:34:42 -0800 | [diff] [blame] | 31 | static sp<DummyAudioSource> Create( |
| 32 | int32_t samplingRate, int32_t channelCount, |
| 33 | int64_t frameDurationUs, int64_t audioDurationUs); |
| 34 | |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 35 | virtual status_t start(MetaData *params = NULL); |
| 36 | virtual status_t stop(); |
| 37 | virtual sp<MetaData> getFormat(); |
James Dong | 00f742c | 2012-01-13 17:34:42 -0800 | [diff] [blame] | 38 | |
| 39 | virtual status_t read( |
| 40 | MediaBuffer **buffer, |
| 41 | const MediaSource::ReadOptions *options = NULL); |
| 42 | |
| 43 | void setDuration(int64_t audioDurationUs); |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 44 | |
| 45 | protected: |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 46 | virtual ~DummyAudioSource(); |
| 47 | |
| 48 | private: |
| 49 | int32_t mSamplingRate; |
| 50 | int32_t mChannelCount; |
| 51 | int64_t mFrameDurationUs; |
| 52 | int32_t mNumberOfSamplePerFrame; |
| 53 | int64_t mAudioDurationUs; |
| 54 | int64_t mTimeStampUs; |
| 55 | Mutex mLock; |
| 56 | |
| 57 | MediaBufferGroup *mBufferGroup; |
| 58 | |
James Dong | 00f742c | 2012-01-13 17:34:42 -0800 | [diff] [blame] | 59 | DummyAudioSource( |
| 60 | int32_t samplingRate, int32_t channelCount, |
| 61 | int64_t frameDurationUs, int64_t audioDurationUs); |
| 62 | |
| 63 | // Don't call me |
Chih-Chung Chang | 9969866 | 2011-06-30 14:21:38 +0800 | [diff] [blame] | 64 | DummyAudioSource(const DummyAudioSource &); |
| 65 | DummyAudioSource &operator=(const DummyAudioSource &); |
| 66 | |
| 67 | }; |
| 68 | |
| 69 | }//namespace android |
| 70 | |
| 71 | |
| 72 | #endif //DUMMY_AUDIOSOURCE_H_ |
| 73 | |