blob: 6e6ead4813f1c304304c57e4c5dc92da345bb95b [file] [log] [blame]
Dharmaray Kundargi643290d2011-01-16 16:02:42 -08001/*
2 * Copyright (C) 2011 NXP Software
3 * Copyright (C) 2011 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef DUMMY_AUDIOSOURCE_H_
19
20#define DUMMY_AUDIOSOURCE_H_
21
22#include <utils/RefBase.h>
23#include <utils/threads.h>
24#include <media/stagefright/MediaBufferGroup.h>
25#include <media/stagefright/MediaSource.h>
26#include <media/stagefright/DataSource.h>
27
28
29namespace android {
30
31
32class MediaBuffer;
33class MetaData;
34struct MediaBufferGroup;
35
36
37
38struct DummyAudioSource : public MediaSource {
39
40public:
41 static sp<DummyAudioSource> Create(int32_t samplingRate,
42 int32_t channelCount,
43 int64_t frameDurationUs,
44 int64_t audioDurationUs);
45 virtual status_t start(MetaData *params = NULL);
46 virtual status_t stop();
47 virtual sp<MetaData> getFormat();
Rajneesh Chowdury1c97d9a2011-02-21 15:43:33 -080048 virtual status_t read (MediaBuffer **buffer,
Dharmaray Kundargi643290d2011-01-16 16:02:42 -080049 const MediaSource::ReadOptions *options = NULL);
Rajneesh Chowdury1c97d9a2011-02-21 15:43:33 -080050 void setDuration (int64_t audioDurationUs);
Dharmaray Kundargi643290d2011-01-16 16:02:42 -080051
52protected:
53 DummyAudioSource (int32_t samplingRate,
54 int32_t channelCount,
55 int64_t frameDurationUs,
56 int64_t audioDurationUs);
57 virtual ~DummyAudioSource();
58
59private:
60 int32_t mSamplingRate;
61 int32_t mChannelCount;
62 int64_t mFrameDurationUs;
63 int32_t mNumberOfSamplePerFrame;
64 int64_t mAudioDurationUs;
65 int64_t mTimeStampUs;
66 int32_t mNbBuffer;
Rajneesh Chowdury1c97d9a2011-02-21 15:43:33 -080067 Mutex mLock;
68
Dharmaray Kundargi643290d2011-01-16 16:02:42 -080069 MediaBufferGroup *mBufferGroup;
70
71 DummyAudioSource(const DummyAudioSource &);
72 DummyAudioSource &operator=(const DummyAudioSource &);
73
74};
75
76}//namespace android
77
78
79#endif //DUMMY_AUDIOSOURCE_H_
80