blob: 5f25a8cdbc7fd1318e0bbc3246bddc86eaa553ee [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#ifndef DUMMY_AUDIOSOURCE_H_
Chih-Chung Chang99698662011-06-30 14:21:38 +080018#define DUMMY_AUDIOSOURCE_H_
19
Chih-Chung Chang99698662011-06-30 14:21:38 +080020#include <media/stagefright/MediaSource.h>
Chih-Chung Chang99698662011-06-30 14:21:38 +080021
22
23namespace android {
24
Chih-Chung Chang99698662011-06-30 14:21:38 +080025class MetaData;
26struct MediaBufferGroup;
27
Chih-Chung Chang99698662011-06-30 14:21:38 +080028struct DummyAudioSource : public MediaSource {
29
30public:
James Dong00f742c2012-01-13 17:34:42 -080031 static sp<DummyAudioSource> Create(
32 int32_t samplingRate, int32_t channelCount,
33 int64_t frameDurationUs, int64_t audioDurationUs);
34
Chih-Chung Chang99698662011-06-30 14:21:38 +080035 virtual status_t start(MetaData *params = NULL);
36 virtual status_t stop();
37 virtual sp<MetaData> getFormat();
James Dong00f742c2012-01-13 17:34:42 -080038
39 virtual status_t read(
40 MediaBuffer **buffer,
41 const MediaSource::ReadOptions *options = NULL);
42
43 void setDuration(int64_t audioDurationUs);
Chih-Chung Chang99698662011-06-30 14:21:38 +080044
45protected:
Chih-Chung Chang99698662011-06-30 14:21:38 +080046 virtual ~DummyAudioSource();
47
48private:
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 Dong00f742c2012-01-13 17:34:42 -080059 DummyAudioSource(
60 int32_t samplingRate, int32_t channelCount,
61 int64_t frameDurationUs, int64_t audioDurationUs);
62
63 // Don't call me
Chih-Chung Chang99698662011-06-30 14:21:38 +080064 DummyAudioSource(const DummyAudioSource &);
65 DummyAudioSource &operator=(const DummyAudioSource &);
66
67};
68
69}//namespace android
70
71
72#endif //DUMMY_AUDIOSOURCE_H_
73