|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. |
|
3 * |
|
4 * This library is free software; you can redistribute it and/or |
|
5 * modify it under the terms of the GNU Lesser General Public |
|
6 * License as published by the Free Software Foundation; either |
|
7 * version 2 of the License, or (at your option) any later version. |
|
8 * |
|
9 * This library is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
12 * Lesser General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU Lesser General Public |
|
15 * License along with this library; if not, write to the |
|
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
17 * Boston, MA 02111-1307, USA. |
|
18 * |
|
19 * Description: |
|
20 * |
|
21 */ |
|
22 |
|
23 #include <mmf/server/sounddevice.h> |
|
24 #include <mmf/server/mmfbuffer.h> |
|
25 #include <mmf/server/mmfdatabuffer.h> |
|
26 #include <dirent.h> |
|
27 #include <stdlib.h> |
|
28 #include <stdio.h> |
|
29 #include <fcntl.h> |
|
30 #include <sys/stat.h> |
|
31 #include <sys/types.h> |
|
32 #include <unistd.h> |
|
33 #include <pthread.h> |
|
34 #include <pthreadtypes.h> |
|
35 #include <e32def.h> |
|
36 #include <e32cons.h> |
|
37 #include <e32std.h> |
|
38 #include <e32debug.h> |
|
39 #include <gst/gstbuffer.h> |
|
40 #include <gst/gst.h> |
|
41 |
|
42 |
|
43 #include <SpeechEncoderConfig.h> |
|
44 #include <G711EncoderIntfc.h> |
|
45 #include <IlbcEncoderIntfc.h> |
|
46 #include <G729EncoderIntfc.h> |
|
47 |
|
48 #include "gstdevsoundsrc.h" |
|
49 |
|
50 #include "gstg711encoderinterface.h" |
|
51 #include "gstilbcencoderinterface.h" |
|
52 |
|
53 class CActiveListener : public CActive |
|
54 { |
|
55 public: |
|
56 CActiveSchedulerWait *asw; |
|
57 CActiveListener() : CActive(CActive::EPriorityStandard) |
|
58 { |
|
59 CActiveScheduler::Add(this); |
|
60 } |
|
61 void InitialiseActiveListener() |
|
62 { |
|
63 iStatus = KRequestPending; SetActive(); |
|
64 } |
|
65 // From CActive |
|
66 virtual void RunL() |
|
67 { |
|
68 asw->AsyncStop(); |
|
69 } |
|
70 void StartActiveScheduler() |
|
71 { |
|
72 asw->Start(); |
|
73 } |
|
74 virtual void DoCancel() |
|
75 { |
|
76 asw->AsyncStop(); |
|
77 //iWait->Stop(); |
|
78 }; |
|
79 |
|
80 }; |
|
81 |
|
82 |
|
83 class DevSoundWrapperSrc :public MDevSoundObserver |
|
84 { |
|
85 |
|
86 public: |
|
87 CActiveListener *AL; |
|
88 CActiveScheduler *as; |
|
89 TInt init_complete; |
|
90 CMMFBuffer *buffer; |
|
91 CMMFDevSound *dev_sound; |
|
92 TMMFCapabilities caps; |
|
93 int buffersize; |
|
94 int gain; |
|
95 int dev_count; |
|
96 TInt iCallbackError; |
|
97 TUint32 fourcc; |
|
98 int bufferreadpos; |
|
99 guint* supportedbitrates; |
|
100 CSpeechEncoderConfig* iSpeechEncoderConfig; |
|
101 CG711EncoderIntfc* iG711EncoderIntfc; |
|
102 CG729EncoderIntfc* iG729EncoderIntfc; |
|
103 CIlbcEncoderIntfc* iIlbcEncoderIntfc; |
|
104 |
|
105 public: |
|
106 DevSoundWrapperSrc(); |
|
107 |
|
108 void InitializeComplete(TInt aError); |
|
109 void ToneFinished(TInt aError); |
|
110 void BufferToBeFilled(CMMFBuffer* aBuffer); |
|
111 void PlayError(TInt aError); |
|
112 void BufferToBeEmptied(CMMFBuffer* aBuffer); |
|
113 void RecordError(TInt aError); |
|
114 void ConvertError(TInt aError); |
|
115 void DeviceMessage(TUid aMessageType, const TDesC8& aMsg); |
|
116 void SendEventToClient(const TMMFEvent& aEvent); |
|
117 void GetDataTypesL(GstDevsoundSrc *ds); |
|
118 int GetSupportedBitratesL(GstDevsoundSrc* ds); |
|
119 void GetSpeechEncoderProperties(GstDevsoundSrc* ds); |
|
120 |
|
121 }; |
|
122 |
|
123 #ifdef __cplusplus |
|
124 extern "C" { |
|
125 #endif |
|
126 |
|
127 |
|
128 int recordinit(DevSoundWrapperSrc *handle); |
|
129 int read_data(DevSoundWrapperSrc *handle,void *ptr, int length); |
|
130 int record_data(DevSoundWrapperSrc *handle); |
|
131 int get_rate(DevSoundWrapperSrc *handle); |
|
132 int get_channels(DevSoundWrapperSrc *handle); |
|
133 int get_encoding(DevSoundWrapperSrc *handle); |
|
134 int get_size(DevSoundWrapperSrc *handle); |
|
135 void set_rate(DevSoundWrapperSrc *handle,int rate); |
|
136 void set_channels(DevSoundWrapperSrc *handle,int channels); |
|
137 void set_encoding(DevSoundWrapperSrc *handle,int encoding); |
|
138 void set_size(DevSoundWrapperSrc *handle,int size); |
|
139 void set_fourcc(DevSoundWrapperSrc *handle,int fourcc); |
|
140 |
|
141 int open_devsound(DevSoundWrapperSrc **handle); |
|
142 int open_device(DevSoundWrapperSrc **handle); |
|
143 int initialize_devsound(GstDevsoundSrc* ds); |
|
144 int close_devsound(GstDevsoundSrc* ds); |
|
145 |
|
146 int SetConfigurations(DevSoundWrapperSrc *handle); |
|
147 int reset_devsound(DevSoundWrapperSrc *handle); |
|
148 |
|
149 int get_databuffer(DevSoundWrapperSrc *handle, const TUint8** buffer); |
|
150 int get_databuffer_size(DevSoundWrapperSrc *handle); |
|
151 |
|
152 int post_init_setconfig(DevSoundWrapperSrc *handle); |
|
153 void populateproperties(GstDevsoundSrc *ds); |
|
154 void initproperties(GstDevsoundSrc* ds); |
|
155 int pre_init_setconf(GstDevsoundSrc *ds); |
|
156 void getsupporteddatatypes(GstDevsoundSrc *ds); |
|
157 |
|
158 int get_speech_encoder_bit_rate(DevSoundWrapperSrc *handle,guint* aBitrate); |
|
159 int get_speech_encoder_supported_bit_rates(GstDevsoundSrc *ds); |
|
160 int get_speech_encoder_vad_mode(DevSoundWrapperSrc *handle,gboolean* aVadMode); |
|
161 int set_speech_encoder_bit_rate(DevSoundWrapperSrc *handle,guint aBitrate); |
|
162 int set_speech_encoder_vad_mode(DevSoundWrapperSrc *handle,gboolean aVadMode); |
|
163 |
|
164 int get_g711_encoder_vad_mode(DevSoundWrapperSrc *handle,gboolean* aVadMode); |
|
165 int set_g711_encoder_mode(DevSoundWrapperSrc *handle,enum TG711EncodeMode aEncodeMode); |
|
166 int set_g711_vad_mode(DevSoundWrapperSrc *handle,gboolean aVadMode); |
|
167 |
|
168 int set_g729_vad_mode(DevSoundWrapperSrc *handle,TBool aVadMode); |
|
169 int get_g729_vad_mode(DevSoundWrapperSrc *handle,TBool* aVadMode); |
|
170 |
|
171 int set_ilbc_encoder_mode(DevSoundWrapperSrc *handle,enum TIlbcEncodeMode aEncodeMode); |
|
172 int set_ilbc_vad_mode(DevSoundWrapperSrc *handle,gboolean aVadMode); |
|
173 int get_ilbc_vad_mode(DevSoundWrapperSrc *handle,gboolean* aVadMode); |
|
174 |
|
175 |
|
176 #ifdef __cplusplus |
|
177 }//extern c |
|
178 #endif |