blob: 8715b102b0f7757dac1773dc636a8387436a892d [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_
18
19#define DUMMY_AUDIOSOURCE_H_
20
21#include <utils/RefBase.h>
22#include <utils/threads.h>
23#include <media/stagefright/MediaBufferGroup.h>
24#include <media/stagefright/MediaSource.h>
25#include <media/stagefright/DataSource.h>
26
27
28namespace android {
29
30
31class MediaBuffer;
32class MetaData;
33struct MediaBufferGroup;
34
35
36
37struct DummyAudioSource : public MediaSource {
38
39public:
40 static sp<DummyAudioSource> Create(int32_t samplingRate,
41 int32_t channelCount,
42 int64_t frameDurationUs,
43 int64_t audioDurationUs);
44 virtual status_t start(MetaData *params = NULL);
45 virtual status_t stop();
46 virtual sp<MetaData> getFormat();
47 virtual status_t read (MediaBuffer **buffer,
48 const MediaSource::ReadOptions *options = NULL);
49 void setDuration (int64_t audioDurationUs);
50
51protected:
52 DummyAudioSource (int32_t samplingRate,
53 int32_t channelCount,
54 int64_t frameDurationUs,
55 int64_t audioDurationUs);
56 virtual ~DummyAudioSource();
57
58private:
59 int32_t mSamplingRate;
60 int32_t mChannelCount;
61 int64_t mFrameDurationUs;
62 int32_t mNumberOfSamplePerFrame;
63 int64_t mAudioDurationUs;
64 int64_t mTimeStampUs;
65 Mutex mLock;
66
67 MediaBufferGroup *mBufferGroup;
68
69 DummyAudioSource(const DummyAudioSource &);
70 DummyAudioSource &operator=(const DummyAudioSource &);
71
72};
73
74}//namespace android
75
76
77#endif //DUMMY_AUDIOSOURCE_H_
78