|
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 |
|
24 #include <mmf/server/sounddevice.h> |
|
25 #include <mmf/server/mmfbuffer.h> |
|
26 #include <mmf/server/mmfdatabuffer.h> |
|
27 #include <dirent.h> |
|
28 #include <stdlib.h> |
|
29 #include <stdio.h> |
|
30 #include <fcntl.h> |
|
31 #include <sys/stat.h> |
|
32 #include <sys/types.h> |
|
33 #include <unistd.h> |
|
34 #include <semaphore.h> |
|
35 |
|
36 #include <e32def.h> |
|
37 #include <e32cons.h> |
|
38 #include <e32std.h> |
|
39 |
|
40 |
|
41 |
|
42 #include "gstdevsoundsink.h" |
|
43 |
|
44 #include <IlbcDecoderIntfc.h> |
|
45 #include <G711DecoderIntfc.h> |
|
46 #include <G729DecoderIntfc.h> |
|
47 #include <ErrorConcealmentIntfc.h> |
|
48 #include <AudioOutput.h> |
|
49 |
|
50 #include "gstg729decoderinterface.h" |
|
51 #include "gstilbcdecoderinterface.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 }; |
|
78 |
|
79 }; |
|
80 |
|
81 |
|
82 class DevSoundWrapper:public MDevSoundObserver |
|
83 { |
|
84 |
|
85 public: |
|
86 DevSoundWrapper(); |
|
87 |
|
88 CActiveListener *AL; |
|
89 CActiveScheduler *as; |
|
90 TInt init_complete; |
|
91 CMMFBuffer *buffer; |
|
92 CMMFDevSound *dev_sound; |
|
93 TMMFCapabilities caps; |
|
94 int buffersize; |
|
95 int volume; |
|
96 int dev_count; |
|
97 TInt iCallbackError; |
|
98 TUint32 fourcc; |
|
99 bool eosReceived; |
|
100 //sem_t mutex; |
|
101 //RArray<TFourCC> supportedtypes; |
|
102 CErrorConcealmentIntfc* iErrConcealmentIntfc; |
|
103 CG711DecoderIntfc* iG711DecoderIntfc; |
|
104 CG729DecoderIntfc* iG729DecoderIntfc; |
|
105 CIlbcDecoderIntfc* iIlbcDecoderIntfc; |
|
106 CAudioOutput* iAudioOutput; |
|
107 |
|
108 |
|
109 public: |
|
110 void InitializeComplete(TInt aError); |
|
111 void ToneFinished(TInt aError); |
|
112 void BufferToBeFilled(CMMFBuffer* aBuffer); |
|
113 void PlayError(TInt aError); |
|
114 void BufferToBeEmptied(CMMFBuffer* aBuffer); |
|
115 void RecordError(TInt aError); |
|
116 void ConvertError(TInt aError); |
|
117 void DeviceMessage(TUid aMessageType, const TDesC8& aMsg); |
|
118 void SendEventToClient(const TMMFEvent& aEvent); |
|
119 void GetDataTypesL(GstDevsoundSink *ds); |
|
120 }; |
|
121 |
|
122 #ifdef __cplusplus |
|
123 extern "C" { |
|
124 #endif |
|
125 |
|
126 int playinit(DevSoundWrapper *handle); |
|
127 |
|
128 int write_data(DevSoundWrapper *handle,TUint8 *ptr, int length, gboolean lastBuffer); |
|
129 int play_data(DevSoundWrapper *handle); |
|
130 int get_rate(DevSoundWrapper *handle); |
|
131 int get_channels(DevSoundWrapper *handle); |
|
132 int get_encoding(DevSoundWrapper *handle); |
|
133 int get_size(DevSoundWrapper *handle); |
|
134 void set_rate(DevSoundWrapper *handle,int rate); |
|
135 void set_channels(DevSoundWrapper *handle,int channels); |
|
136 void set_encoding(DevSoundWrapper *handle,int encoding); |
|
137 void set_size(DevSoundWrapper *handle,int size); |
|
138 void set_fourcc(DevSoundWrapper *handle,int fourcc); |
|
139 |
|
140 void set_volume(DevSoundWrapper* handle,int volume); |
|
141 |
|
142 int open_devsound(DevSoundWrapper **handle); |
|
143 int open_device(DevSoundWrapper **handle); |
|
144 int initialize_devsound(GstDevsoundSink* sink); |
|
145 int close_devsound(GstDevsoundSink *ds); |
|
146 int check_if_device_open(DevSoundWrapper *handle) ; |
|
147 |
|
148 int get_ds_cb_error(DevSoundWrapper *handle); |
|
149 |
|
150 //Error Concealment custom interface |
|
151 void conceal_error_for_next_buffer(DevSoundWrapper *handle); |
|
152 void set_framemode(DevSoundWrapper *handle,gboolean mode); |
|
153 int framemode_rqrd_for_ec(DevSoundWrapper *handle,gboolean* modereq); |
|
154 |
|
155 //G711 custom interface |
|
156 int set_decodermode(DevSoundWrapper* handle,int aDecodeMode); |
|
157 int set_cng(DevSoundWrapper* handle,gboolean aCng); |
|
158 int get_cng(DevSoundWrapper* handle,gboolean* aCng); |
|
159 int set_plc(DevSoundWrapper* handle,gboolean aPlc); |
|
160 |
|
161 //G729 custom interface |
|
162 gint badlsfnextbuffer(DevSoundWrapper *handle); |
|
163 |
|
164 //Ilbc custom interace |
|
165 gint get_ilbccng(DevSoundWrapper *handle,gboolean* aCng); |
|
166 gint set_ilbccng(DevSoundWrapper *handle,gboolean aCng); |
|
167 gint set_ilbcdecodermode(DevSoundWrapper *handle,enum TIlbcDecodeMode aDecodeMode); |
|
168 |
|
169 |
|
170 int post_init_setconfig(DevSoundWrapper *handle); |
|
171 int reset_devsound(DevSoundWrapper *handle); |
|
172 |
|
173 void populateproperties(GstDevsoundSink *ds); |
|
174 void initproperties(GstDevsoundSink* ds); |
|
175 int pre_init_setconf(GstDevsoundSink *ds); |
|
176 void getsupporteddatatypes(GstDevsoundSink *ds); |
|
177 |
|
178 |
|
179 #ifdef __cplusplus |
|
180 }//extern c |
|
181 #endif |