|
1 /* |
|
2 * Copyright (c) 2010 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: UPnP GStreamer wrapper |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_UPNPGSTWRAPPER_H |
|
19 #define C_UPNPGSTWRAPPER_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <e32base.h> |
|
23 #include <badesca.h> |
|
24 #include <e32debug.h> |
|
25 |
|
26 #include "upnpgstwrapperobserver.h" |
|
27 |
|
28 class CUpnpGstWrapperPimpl; |
|
29 |
|
30 class CUpnpGstWrapper : public CActive |
|
31 { |
|
32 |
|
33 public: // construction / destruction |
|
34 |
|
35 |
|
36 /** |
|
37 * Get wrapper instance. |
|
38 * Increased reference count by 1. |
|
39 * |
|
40 * @return none |
|
41 */ |
|
42 IMPORT_C static CUpnpGstWrapper* GetInstanceL(); |
|
43 |
|
44 /** |
|
45 * Decreses reference count by 1. |
|
46 * If reference count decreses to zero, singleton will be deleted. |
|
47 * |
|
48 * @return none |
|
49 */ |
|
50 IMPORT_C void Close(); |
|
51 |
|
52 private: // construction, private part |
|
53 |
|
54 /** |
|
55 * Constructor |
|
56 */ |
|
57 CUpnpGstWrapper(); |
|
58 |
|
59 /** |
|
60 * Destructor |
|
61 */ |
|
62 IMPORT_C virtual ~CUpnpGstWrapper(); |
|
63 |
|
64 /** |
|
65 * 2nd phrase Constructor |
|
66 */ |
|
67 void ConstructL(); |
|
68 |
|
69 public: |
|
70 |
|
71 /** |
|
72 * Set observer |
|
73 * |
|
74 * @param MUpnpGstWrapperObserver observer to be set |
|
75 * @return none |
|
76 */ |
|
77 IMPORT_C void SetObserverL( MUpnpGstWrapperObserver& aObserver ); |
|
78 |
|
79 /** |
|
80 * Remove observer |
|
81 * |
|
82 * @param MUpnpGstWrapperObserver observer to be removed |
|
83 * @return none |
|
84 */ |
|
85 IMPORT_C void RemoveObserver( MUpnpGstWrapperObserver& aObserver ); |
|
86 |
|
87 /** |
|
88 * Start a pipeline; e.g. transcoding. This is used when client knows |
|
89 * exactly what the pipeline is and the elements inside |
|
90 * |
|
91 * @return none |
|
92 */ |
|
93 IMPORT_C void StartL(); |
|
94 |
|
95 /** |
|
96 * Stop the pipeline; e.g. transcoding |
|
97 * |
|
98 * @param none |
|
99 * @return none |
|
100 */ |
|
101 IMPORT_C void Stop(); |
|
102 |
|
103 /** |
|
104 * Return the error description |
|
105 * |
|
106 * @param None |
|
107 * @return A reference to the error description |
|
108 */ |
|
109 IMPORT_C const TDesC& ErrorMsg(); |
|
110 |
|
111 /** |
|
112 * Return list of currently supported GStreamer features |
|
113 * Note: Ownership of the array is passed to the caller |
|
114 * |
|
115 * @param None |
|
116 * @return A pointer to descriptor array |
|
117 */ |
|
118 IMPORT_C CDesCArray* FeatureListL(); |
|
119 |
|
120 /** |
|
121 * Return the video info descriptor |
|
122 * |
|
123 * E.g.: |
|
124 * video/x-h264, width=(int)1280, height=(int)720, |
|
125 * framerate=(fraction)30000/1, codec_data=(buffer)0164401fffe10010276400 |
|
126 * 1fac2b402802dd80b4078913501000528ee025cb0 |
|
127 * |
|
128 * @param None |
|
129 * @return A reference to video info descriptor |
|
130 */ |
|
131 IMPORT_C const TDesC& VideoInfo(); |
|
132 |
|
133 /** |
|
134 * Return the audio info descriptor |
|
135 * |
|
136 * E.g.: |
|
137 * audio/mpeg, rate=(int)48000, channels=(int)1, |
|
138 * channel-positions=(GstAudioChannelPosition)< |
|
139 * GST_AUDIO_CHANNEL_POSITION_FRONT_MONO >, mpegversion(int)4, |
|
140 * codec_data=(buffer)1188 |
|
141 * |
|
142 * @param None |
|
143 * @return A reference to audio info descriptor |
|
144 */ |
|
145 IMPORT_C const TDesC& AudioInfo(); |
|
146 |
|
147 /** |
|
148 * Return (transoding) position in nanoseconds. |
|
149 * |
|
150 * @return Postion in nanoseconds; KErrNotFound if position not available |
|
151 */ |
|
152 IMPORT_C TInt64 Position(); |
|
153 |
|
154 /** |
|
155 * Return (transoding) duration in nanoseconds. |
|
156 * |
|
157 * @return Duration in nanoseconds; KErrNotFound if duration not available |
|
158 */ |
|
159 IMPORT_C TInt64 Duration(); |
|
160 |
|
161 /** |
|
162 * Return pointter to GStreamer pipeline. |
|
163 * |
|
164 * @return Pointer to GStreamer pipeline. |
|
165 */ |
|
166 IMPORT_C TAny* PipelinePtr(); |
|
167 |
|
168 /** |
|
169 * Initialises gstreamer appsink element named sinkbuffer if there is |
|
170 */ |
|
171 IMPORT_C void InitAppsinkL(); |
|
172 |
|
173 /** |
|
174 * pulls buffer from gstreamer appsink element |
|
175 * |
|
176 * @return boolean true if end of transcoding |
|
177 */ |
|
178 IMPORT_C TBool PullBufferL( TPtr8& aPointer,TInt aMaxBytesLength, RBuf8* aBuf=NULL ); |
|
179 |
|
180 /** |
|
181 * returns count of bytes transcoded so far |
|
182 */ |
|
183 IMPORT_C TInt TranscodedBytes(); |
|
184 |
|
185 /** |
|
186 * Setter |
|
187 */ |
|
188 IMPORT_C void SetTranscodedFileSize( TInt aSize ); |
|
189 |
|
190 /** |
|
191 * getter |
|
192 */ |
|
193 IMPORT_C TInt TranscodedFileSize(); |
|
194 |
|
195 /** |
|
196 * sets pipline has to be set before calling start() |
|
197 * |
|
198 * @param aPipeline |
|
199 */ |
|
200 IMPORT_C void SetPipelineL( const TDesC8& aPipeline ); |
|
201 |
|
202 |
|
203 private: |
|
204 |
|
205 /** |
|
206 * Set error message |
|
207 * |
|
208 * @param TDesC& a reference to error message descriptor |
|
209 * @return none |
|
210 */ |
|
211 void SetErrorMsgL( const TDesC& aErrorMsg ); |
|
212 |
|
213 /** |
|
214 * Set error message |
|
215 * |
|
216 * @param TDesC& a reference to error message descriptor |
|
217 * @return none |
|
218 */ |
|
219 void SetErrorMsg( HBufC* const aErrorMsg ); |
|
220 |
|
221 /** |
|
222 * Convert char array to symbian descriptor |
|
223 * |
|
224 * @param char* the reference of input string |
|
225 * @return HBufC* the pointer to the output |
|
226 */ |
|
227 HBufC* ConvertCharToDescL( const char* aString ); |
|
228 |
|
229 /** |
|
230 * Convert symbian description to char array |
|
231 * |
|
232 * @param TDesC8& the reference of input string |
|
233 * @return char* the pointer to the output |
|
234 */ |
|
235 char* ConvertDescToCharL( const TDesC8& aDescriptor ); |
|
236 |
|
237 /** |
|
238 * Send an event to every registered observer. |
|
239 * |
|
240 * @param Gst::TEvent evnet to be sent |
|
241 * @return None |
|
242 */ |
|
243 void SendEventToObsevers( Gst::TEvent aEvent ); |
|
244 |
|
245 private: // from CActive |
|
246 |
|
247 /** |
|
248 * @see e32base.h |
|
249 */ |
|
250 void RunL(); |
|
251 |
|
252 /** |
|
253 * @see e32base.h |
|
254 */ |
|
255 void DoCancel(); |
|
256 |
|
257 private: |
|
258 |
|
259 CUpnpGstWrapperPimpl* iPimpl; |
|
260 TThreadId iClientThreadId; |
|
261 HBufC* iErrorMsg; //owned |
|
262 HBufC* iVideoInfo; //owned |
|
263 HBufC* iAudioInfo; //owned |
|
264 RArray<Gst::TEvent> iEventQueue; |
|
265 RMutex iMutex; |
|
266 TInt64 iDuration; |
|
267 TInt iSingletonRefCount; |
|
268 RPointerArray<MUpnpGstWrapperObserver> iObservers; |
|
269 TInt iFileSize; |
|
270 |
|
271 HBufC8* iPipeline; |
|
272 |
|
273 private: |
|
274 |
|
275 friend class CUpnpGstWrapperPimpl; |
|
276 |
|
277 }; |
|
278 |
|
279 |
|
280 #endif // C_UPNPGSTWRAPPER_H |
|
281 |