1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * 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, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */
16 
17 
18 #ifndef CTSAUDIO_AUDIOREMOTE_H
19 #define CTSAUDIO_AUDIOREMOTE_H
20 #include <utils/StrongPointer.h>
21 #include "AudioHardware.h"
22 // real implementation
23 #include "RemoteAudio.h"
24 
25 
26 // wrapper in AudioHardware interface
27 class AudioRemote: public AudioHardware {
28 public:
29     virtual bool prepare(AudioHardware::SamplingRate samplingRate, int volume,
30             int mode = AudioHardware::EModeVoice);
31 
32 protected:
33     explicit AudioRemote(android::sp<RemoteAudio>& remote);
~AudioRemote()34     virtual ~AudioRemote() {};
35 
36 protected:
37     android::sp<RemoteAudio> mRemote;
38     AudioHardware::SamplingRate mSamplingRate;
39     int mVolume;
40     int mMode;
41 };
42 
43 class AudioRemotePlayback: public AudioRemote {
44 public:
45     explicit AudioRemotePlayback(android::sp<RemoteAudio>& remote);
~AudioRemotePlayback()46     virtual ~AudioRemotePlayback() {};
47     virtual bool startPlaybackOrRecord(android::sp<Buffer>& buffer, int numberRepetition = 1);
48     virtual bool waitForCompletion();
49     virtual void stopPlaybackOrRecord();
50     bool startPlaybackForRemoteData(int id, bool stereo,  int numberRepetition = 1);
51 };
52 
53 class AudioRemoteRecording: public AudioRemote {
54 public:
55     explicit AudioRemoteRecording(android::sp<RemoteAudio>& remote);
~AudioRemoteRecording()56     virtual ~AudioRemoteRecording() {};
57     virtual bool startPlaybackOrRecord(android::sp<Buffer>& buffer, int numberRepetition = 1);
58     virtual bool waitForCompletion();
59     virtual void stopPlaybackOrRecord();
60 };
61 
62 
63 #endif // CTSAUDIO_AUDIOREMOTE_H
64