sipxmedialib  Version 3.3
MpidAndroid.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2010 SIPez LLC.
3 // Licensed to SIPfoundry under a Contributor Agreement.
4 //
5 // Copyright (C) 2010 SIPfoundry Inc.
6 // Licensed by SIPfoundry under the LGPL license.
7 //
8 // $$
10 
11 // Author: Alexander Chemeris <Alexander DOT Chemeris AT SIPez DOT com>
12 
13 #ifndef _MpidAndroid_h_
14 #define _MpidAndroid_h_
15 
16 // SIPX INCLUDES
17 #include <mp/MpInputDeviceDriver.h>
19 
20 // SYSTEM INCLUDES
21 #include <utils/threads.h>
22 
23 // DEFINES
24 // MACROS
25 // EXTERNAL FUNCTIONS
26 // EXTERNAL VARIABLES
27 // CONSTANTS
28 // STRUCTS
29 // TYPEDEFS
30 // FORWARD DECLARATIONS
31 class MpResamplerBase;
32 using namespace android;
33 
41 {
42 /* //////////////////////////// PUBLIC //////////////////////////////////// */
43 public:
44 
45 /* ============================ CREATORS ================================== */
47 
48 
50  enum audio_source {
51  AUDIO_SOURCE_DEFAULT = 0,
52  AUDIO_SOURCE_MIC = 1,
53  AUDIO_SOURCE_VOICE_UPLINK = 2, // Don't work on Droid/Milestone
54  AUDIO_SOURCE_VOICE_DOWNLINK = 3, // Don't work on Droid/Milestone
55  AUDIO_SOURCE_VOICE_CALL = 4, // Don't work on Droid/Milestone
56  AUDIO_SOURCE_CAMCORDER = 5, // Seems equal to MIC on Droid/Milestone
57  AUDIO_SOURCE_VOICE_RECOGNITION = 6, // Seems equal to MIC on Droid/Milestone
58  AUDIO_SOURCE_MAX = AUDIO_SOURCE_VOICE_RECOGNITION,
59 
60  AUDIO_SOURCE_LIST_END // must be last - used to validate audio source type
61  };
62 
65  MpInputDeviceManager& deviceManager);
72  virtual
74  ~MpidAndroid();
75 
77 
78 /* ============================ MANIPULATORS ============================== */
80 
81 
83  virtual OsStatus enableDevice(unsigned samplesPerFrame,
84  unsigned samplesPerSec,
85  MpFrameTime currentFrameTime=0);
86 
88  virtual OsStatus disableDevice();
89 
91 
92 /* ============================ ACCESSORS ================================= */
94 
95 
97 
98 /* ============================ INQUIRY =================================== */
100 
101 
103  virtual UtlBoolean isDeviceValid();
104 
106 
107 /* //////////////////////////// PROTECTED ///////////////////////////////// */
108 protected:
109 
110  enum DriverState {
117  };
118 
121 
126  int mBufInternalSamples;
128  Mutex mLock;
129  Condition mWaitCbkCond;
131  MpResamplerBase *mpResampler;
133  MpAudioSample *mpResampleBuf;
135 
137  static const int mpSampleRatesList[];
138  static const int mSampleRatesListLen;
140 
142  bool initAudioRecord();
143 
145  bool probeSampleRate(int targetRate, int targetFrameSize,
146  const int *ratesList, int ratesListLen,
147  bool probeDefault=true);
148 
150  static void audioCallback(int event, void* user, void *info);
151 
152 /* //////////////////////////// PRIVATE /////////////////////////////////// */
153 private:
154 
156  MpidAndroid(const MpidAndroid& rMpidAndroid);
157 
159  MpidAndroid& operator=(const MpidAndroid& rhs);
160 };
161 
162 /* ============================ INLINE METHODS ============================ */
163 
164 #endif // _MpidAndroid_h_
int samplesPerFrame
Driver has been successfully initialized and is not playing.
Definition: MpidAndroid.h:112
Generic audio resampler.
Definition: MpResampler.h:34
uint32_t MpFrameTime
Definition: MpTypes.h:53
Driver is stopping.
Definition: MpidAndroid.h:115
Driver is being initialized or initialization failed.
Definition: MpidAndroid.h:111
MpAndroidAudioRecord * mpAudioRecord
Pointer to audio track used for record.
Definition: MpidAndroid.h:122
Mutex mLock
Definition: MpidAndroid.h:128
audio_source
Audio input source. Refer to Android OS sources.
Definition: MpidAndroid.h:50
int16_t MpAudioSample
Definition: MpTypes.h:44
Container of input devices for input drivers and resources.
Definition: MpInputDeviceManager.h:79
DriverState
Definition: MpidAndroid.h:110
Driver is starting playing.
Definition: MpidAndroid.h:113
Driver is stopped: the AudioRecord will be stopped.
Definition: MpidAndroid.h:116
int mSamplesPerSecInternal
Sample rate of AudioRecord.
Definition: MpidAndroid.h:123
DriverState mState
Driver internal state.
Definition: MpidAndroid.h:120
Audio input driver for Android OS.
Definition: MpidAndroid.h:40
Container for device specific input driver.
Definition: MpInputDeviceDriver.h:58
audio_source mStreamSource
Source of a stream we&#39;re recording.
Definition: MpidAndroid.h:119
Driver is playing.
Definition: MpidAndroid.h:114
MpAudioSample * mpBufInternal
full buffer. Have mSamplesPerFrameInternal size.
Definition: MpidAndroid.h:125
int mSamplesPerFrameInternal
Number of sample per frame we use with AudioRecord.
Definition: MpidAndroid.h:124
Audio input driver for Android OS.
Definition: MpAndroidAudioRecord.h:34