|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <mmf/server/sounddevice.h> |
|
20 #include <mmf/server/mmfbuffer.h> |
|
21 #include <mmf/server/mmfdatabuffer.h> |
|
22 #include <dirent.h> |
|
23 #include <stdlib.h> |
|
24 #include <stdio.h> |
|
25 #include <fcntl.h> |
|
26 #include <sys/stat.h> |
|
27 #include <sys/types.h> |
|
28 #include <unistd.h> |
|
29 #include <pthread.h> |
|
30 #include <pthreadtypes.h> |
|
31 #include <e32def.h> |
|
32 #include <e32cons.h> |
|
33 #include <e32std.h> |
|
34 #include <e32debug.h> |
|
35 #include <gst/gstbuffer.h> |
|
36 #include <gst/gst.h> |
|
37 |
|
38 |
|
39 #include <SpeechEncoderConfig.h> |
|
40 #include <G711EncoderIntfc.h> |
|
41 #include <IlbcEncoderIntfc.h> |
|
42 #include <G729EncoderIntfc.h> |
|
43 |
|
44 #include "gstdevsoundsrc.h" |
|
45 |
|
46 #include "gstg711encoderinterface.h" |
|
47 #include "gstilbcencoderinterface.h" |
|
48 |
|
49 class CActiveListener : public CActive |
|
50 { |
|
51 public: |
|
52 CActiveSchedulerWait *asw; |
|
53 CActiveListener() : CActive(CActive::EPriorityStandard) |
|
54 { |
|
55 CActiveScheduler::Add(this); |
|
56 } |
|
57 void InitialiseActiveListener() |
|
58 { |
|
59 iStatus = KRequestPending; SetActive(); |
|
60 } |
|
61 // From CActive |
|
62 virtual void RunL() |
|
63 { |
|
64 asw->AsyncStop(); |
|
65 } |
|
66 void StartActiveScheduler() |
|
67 { |
|
68 asw->Start(); |
|
69 } |
|
70 virtual void DoCancel() |
|
71 { |
|
72 asw->AsyncStop(); |
|
73 //iWait->Stop(); |
|
74 }; |
|
75 |
|
76 }; |
|
77 |
|
78 |
|
79 class DevSoundWrapperSrc :public MDevSoundObserver |
|
80 { |
|
81 |
|
82 public: |
|
83 CActiveListener *AL; |
|
84 CActiveScheduler *as; |
|
85 TInt init_complete; |
|
86 CMMFBuffer *buffer; |
|
87 CMMFDevSound *dev_sound; |
|
88 TMMFCapabilities caps; |
|
89 int buffersize; |
|
90 int gain; |
|
91 int dev_count; |
|
92 TInt iCallbackError; |
|
93 TUint32 fourcc; |
|
94 int bufferreadpos; |
|
95 guint* supportedbitrates; |
|
96 CSpeechEncoderConfig* iSpeechEncoderConfig; |
|
97 CG711EncoderIntfc* iG711EncoderIntfc; |
|
98 CG729EncoderIntfc* iG729EncoderIntfc; |
|
99 CIlbcEncoderIntfc* iIlbcEncoderIntfc; |
|
100 |
|
101 public: |
|
102 DevSoundWrapperSrc(); |
|
103 |
|
104 void InitializeComplete(TInt aError); |
|
105 void ToneFinished(TInt aError); |
|
106 void BufferToBeFilled(CMMFBuffer* aBuffer); |
|
107 void PlayError(TInt aError); |
|
108 void BufferToBeEmptied(CMMFBuffer* aBuffer); |
|
109 void RecordError(TInt aError); |
|
110 void ConvertError(TInt aError); |
|
111 void DeviceMessage(TUid aMessageType, const TDesC8& aMsg); |
|
112 void SendEventToClient(const TMMFEvent& aEvent); |
|
113 void GetDataTypesL(GstDevsoundSrc *ds); |
|
114 int GetSupportedBitratesL(GstDevsoundSrc* ds); |
|
115 void GetSpeechEncoderProperties(GstDevsoundSrc* ds); |
|
116 |
|
117 }; |
|
118 |
|
119 #ifdef __cplusplus |
|
120 extern "C" { |
|
121 #endif |
|
122 |
|
123 |
|
124 int recordinit(DevSoundWrapperSrc *handle); |
|
125 int read_data(DevSoundWrapperSrc *handle,void *ptr, int length); |
|
126 int record_data(DevSoundWrapperSrc *handle); |
|
127 int get_rate(DevSoundWrapperSrc *handle); |
|
128 int get_channels(DevSoundWrapperSrc *handle); |
|
129 int get_encoding(DevSoundWrapperSrc *handle); |
|
130 int get_size(DevSoundWrapperSrc *handle); |
|
131 void set_rate(DevSoundWrapperSrc *handle,int rate); |
|
132 void set_channels(DevSoundWrapperSrc *handle,int channels); |
|
133 void set_encoding(DevSoundWrapperSrc *handle,int encoding); |
|
134 void set_size(DevSoundWrapperSrc *handle,int size); |
|
135 void set_fourcc(DevSoundWrapperSrc *handle,int fourcc); |
|
136 |
|
137 int open_devsound(DevSoundWrapperSrc **handle); |
|
138 int open_device(DevSoundWrapperSrc **handle); |
|
139 int initialize_devsound(GstDevsoundSrc* ds); |
|
140 int close_devsound(GstDevsoundSrc* ds); |
|
141 |
|
142 int SetConfigurations(DevSoundWrapperSrc *handle); |
|
143 int reset_devsound(DevSoundWrapperSrc *handle); |
|
144 |
|
145 int get_databuffer(DevSoundWrapperSrc *handle, const TUint8** buffer); |
|
146 int get_databuffer_size(DevSoundWrapperSrc *handle); |
|
147 |
|
148 int post_init_setconfig(DevSoundWrapperSrc *handle); |
|
149 void populateproperties(GstDevsoundSrc *ds); |
|
150 void initproperties(GstDevsoundSrc* ds); |
|
151 int pre_init_setconf(GstDevsoundSrc *ds); |
|
152 void getsupporteddatatypes(GstDevsoundSrc *ds); |
|
153 |
|
154 int get_speech_encoder_bit_rate(DevSoundWrapperSrc *handle,guint* aBitrate); |
|
155 int get_speech_encoder_supported_bit_rates(GstDevsoundSrc *ds); |
|
156 int get_speech_encoder_vad_mode(DevSoundWrapperSrc *handle,gboolean* aVadMode); |
|
157 int set_speech_encoder_bit_rate(DevSoundWrapperSrc *handle,guint aBitrate); |
|
158 int set_speech_encoder_vad_mode(DevSoundWrapperSrc *handle,gboolean aVadMode); |
|
159 |
|
160 int get_g711_encoder_vad_mode(DevSoundWrapperSrc *handle,gboolean* aVadMode); |
|
161 int set_g711_encoder_mode(DevSoundWrapperSrc *handle,enum TG711EncodeMode aEncodeMode); |
|
162 int set_g711_vad_mode(DevSoundWrapperSrc *handle,gboolean aVadMode); |
|
163 |
|
164 int set_g729_vad_mode(DevSoundWrapperSrc *handle,TBool aVadMode); |
|
165 int get_g729_vad_mode(DevSoundWrapperSrc *handle,TBool* aVadMode); |
|
166 |
|
167 int set_ilbc_encoder_mode(DevSoundWrapperSrc *handle,enum TIlbcEncodeMode aEncodeMode); |
|
168 int set_ilbc_vad_mode(DevSoundWrapperSrc *handle,gboolean aVadMode); |
|
169 int get_ilbc_vad_mode(DevSoundWrapperSrc *handle,gboolean* aVadMode); |
|
170 |
|
171 |
|
172 #ifdef __cplusplus |
|
173 }//extern c |
|
174 #endif |