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