|
1 /* |
|
2 * Copyright (c) 2006 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 // INCLUDES |
|
21 #ifndef MCCVIDEOSOURCE_H |
|
22 #define MCCVIDEOSOURCE_H |
|
23 |
|
24 #include <e32std.h> |
|
25 #include "mccdatasource.h" |
|
26 #include "mccinternalcodecs.h" |
|
27 |
|
28 class CMccVideoSourceImpl; |
|
29 class CMccFileSourceImpl; |
|
30 class TMccCodecInfo; |
|
31 class MMccCameraHandler; |
|
32 |
|
33 // CLASS DECLARATIONS |
|
34 |
|
35 /** |
|
36 * Helper class to contain user information |
|
37 */ |
|
38 class TMccVideoSourceUser |
|
39 { |
|
40 public: |
|
41 |
|
42 TMccVideoSourceUser( MAsyncEventHandler* aEventHandler ) : |
|
43 iEventHandler( aEventHandler ), |
|
44 iCodecInfo(), |
|
45 iReserved1( 0 ), |
|
46 iReserved2( 0 ) |
|
47 { |
|
48 } |
|
49 |
|
50 public: |
|
51 MAsyncEventHandler* iEventHandler; |
|
52 TMccCodecInfo iCodecInfo; |
|
53 TUint32 iReserved1; |
|
54 TUint32 iReserved2; |
|
55 }; |
|
56 |
|
57 /** |
|
58 * Video source is used to get video data from camera. |
|
59 * |
|
60 */ |
|
61 class CMccVideoSource: public CMccDataSource |
|
62 { |
|
63 |
|
64 public: // Methods called internally or by the controller |
|
65 |
|
66 /** |
|
67 * Two-phased constructor. |
|
68 */ |
|
69 static MDataSource* NewSourceL( TUid aImplementationUid, |
|
70 const TDesC8& aInitData ); |
|
71 |
|
72 void ConstructSourceL ( const TDesC8& aInitData ); |
|
73 |
|
74 CMccVideoSource(); |
|
75 |
|
76 virtual ~CMccVideoSource(); |
|
77 |
|
78 public: // new |
|
79 |
|
80 virtual void SetCameraHandler( MMccCameraHandler& aCameraHandler ); |
|
81 |
|
82 virtual TInt CameraIndex() const; |
|
83 |
|
84 virtual void SetVideoCodecL( const TMccCodecInfo& aVideoCodec ); |
|
85 |
|
86 virtual void GetVideoCodecL( TMccCodecInfo& aVideoCodec ); |
|
87 |
|
88 virtual void GetSupportedVideoCodecsL( RArray<TFourCC>& aVideoTypes ); |
|
89 |
|
90 virtual void SetAudioCodecL( const TMccCodecInfo& aAudioCodec ); |
|
91 |
|
92 virtual void GetAudioCodecL( TMccCodecInfo& aAudioCodec ); |
|
93 |
|
94 virtual void GetSupportedAudioCodecsL( RArray<TFourCC>& aAudioTypes ); |
|
95 |
|
96 virtual void SetAudioEnabledL( TBool aEnabled ); |
|
97 |
|
98 virtual TBool AudioEnabledL() const; |
|
99 |
|
100 virtual void SetGainL( TInt aGain ); |
|
101 |
|
102 virtual TInt GainL() const; |
|
103 |
|
104 virtual TInt MaxGainL() const; |
|
105 |
|
106 public: // From MMccSourceSink |
|
107 |
|
108 virtual TInt AddUser( MAsyncEventHandler* aUser ); |
|
109 |
|
110 virtual void RemoveUser( MAsyncEventHandler* aUser ); |
|
111 |
|
112 virtual void SetCurrentUser( MAsyncEventHandler* aUser ); |
|
113 |
|
114 virtual void UpdateL( const TDesC8& aVal ); |
|
115 |
|
116 virtual void GetParameterL( TUint32 aParam, TDes8& aVal ); |
|
117 |
|
118 virtual void SetParameterL( TUint32 aParam, const TDesC8& aVal ); |
|
119 |
|
120 public: // From MDataSource |
|
121 |
|
122 /** |
|
123 * From MDataSource. Returns the data type as a fourCC code of the data source. |
|
124 * |
|
125 * @since Series 60 3.0 |
|
126 * @param "aMediaId" |
|
127 * This identifies the type of media eg audio or video and the stream id. |
|
128 * Only KUidMediaTypeAudio -mediatype is supported. |
|
129 * @return The fourCC code identifying the source datatype for the specified aMediaId. |
|
130 */ |
|
131 TFourCC SourceDataTypeCode( TMediaId aMediaId ); |
|
132 |
|
133 /** |
|
134 * From MDataSource. Sets the data type as a fourCC code for the data source |
|
135 * |
|
136 * @since Series 60 3.0 |
|
137 * @param "aSourceFourCC" |
|
138 * This specifies the data type as a fourCC code to set the source to. |
|
139 * |
|
140 * @param "aMediaId" |
|
141 * This identifies the type of media eg audio or video and the stream id. |
|
142 * Only KUidMediaTypeAudio -mediatype is supported. |
|
143 * |
|
144 * @return KErrNone if successful, KErrNotSupported if the source does not support having |
|
145 * it's data type set, otherwise a system wide error code. |
|
146 */ |
|
147 TInt SetSourceDataTypeCode( TFourCC aCodec, |
|
148 TMediaId aMedia ); |
|
149 |
|
150 /** |
|
151 * From MDataSource. Not used. Leaves with KErrNotSupported. |
|
152 * |
|
153 * @since Series 60 3.0 |
|
154 * @param "aBuffer" |
|
155 * The buffer that has been emptied by a data sink and is now available for reuse |
|
156 * @return None |
|
157 */ |
|
158 void BufferEmptiedL( CMMFBuffer* aBuffer ); |
|
159 |
|
160 /** |
|
161 * From MDataSource. Method to indicate whether the data source can create a buffer. |
|
162 * |
|
163 * @since Series 60 3.0 |
|
164 * |
|
165 * @return EFalse |
|
166 */ |
|
167 TBool CanCreateSourceBuffer(); |
|
168 |
|
169 /** |
|
170 * From MDataSource. Not used. Leaves with KErrNotSupported. |
|
171 * |
|
172 * @since Series 60 3.0 |
|
173 * @param "aMediaId" |
|
174 * This identifies the type of media eg audio or video and the stream id. |
|
175 * This parameter is required in cases where the source can supply data |
|
176 * of more than one media type and/or multiple strams of data eg a multimedia file. |
|
177 * |
|
178 * @param "aReference" |
|
179 * This must be written to by the method to indicate whether the created buffer is |
|
180 * a 'reference' buffer. A 'reference' buffer is a buffer that is owned by the source |
|
181 * and should be used in preference to the sink buffer provided the sink buffer |
|
182 * is also not a reference buffer. |
|
183 * . |
|
184 * @return The created buffer |
|
185 */ |
|
186 CMMFBuffer* CreateSourceBufferL( TMediaId, |
|
187 TBool& aReference ); |
|
188 |
|
189 /** |
|
190 * From MDataSource. Method to 'logon' the data source to the same thread that source will be supplying data in. |
|
191 * |
|
192 * Jitterbuffer for incoming packets and downlink timeout timer are created here. |
|
193 * |
|
194 * @param "aEventHandler" |
|
195 * This is an MAsyncEventHandler to handle asynchronous events that occur during the |
|
196 * transfer of multimedia data. The event handler must be in the same thread as the data transfer |
|
197 * thread - hence the reason it is passed in the SourceThreadLogon as opposed to say the constructor. |
|
198 * |
|
199 * |
|
200 * @return KErrNone if successful, otherwise a system wide error code. |
|
201 */ |
|
202 TInt SourceThreadLogon( MAsyncEventHandler& aEventHandler ); |
|
203 |
|
204 /** |
|
205 * From MDataSource. Method to 'logoff' the data source from the same thread that source supplies data in. |
|
206 * |
|
207 * Jitterbuffer for incoming packets and downlink timeout timer are deleted. Datasource deletes the |
|
208 * stream(s) and unregisters itself as an observer for the RTP session for incoming RTP and RTCP packets. |
|
209 * |
|
210 * @return None |
|
211 */ |
|
212 void SourceThreadLogoff(); |
|
213 |
|
214 /** |
|
215 * From MDataSource. Method to 'prime' the data source. |
|
216 * |
|
217 * Datasource is set to primed state. |
|
218 * |
|
219 * @since Series 60 3.0 |
|
220 * @return None |
|
221 */ |
|
222 void SourcePrimeL(); |
|
223 |
|
224 /** |
|
225 * From MDataSource. Method to 'play' the data source. |
|
226 * |
|
227 * Downlink timeout timer is started and datasource is set to playing state. |
|
228 * |
|
229 * @since Series 60 3.0 |
|
230 * @return None |
|
231 */ |
|
232 void SourcePlayL(); |
|
233 |
|
234 /** |
|
235 * From MDataSource. Method to 'pause' the data source. |
|
236 * |
|
237 * Downlink timeout timer is stopped and datasource is set to paused state. |
|
238 * |
|
239 * @since Series 60 3.0 |
|
240 * @return None |
|
241 */ |
|
242 void SourcePauseL(); |
|
243 |
|
244 /** |
|
245 * From MDataSource. Method to 'stop' the data source. |
|
246 * |
|
247 * Downlink timeout timer is stopped and datasource is set to stopped state. |
|
248 * |
|
249 * @since Series 60 3.0 |
|
250 * @return None |
|
251 */ |
|
252 void SourceStopL(); |
|
253 |
|
254 /** |
|
255 * From MDataSource. Method called by a MDataSink to request the data source to fill aBuffer with data. |
|
256 * |
|
257 * Datasource gets packet from jitterbuffer and forwards it to the payloadformatdecoder |
|
258 * for further processing. Datasource works synchronously; consumers BufferFilledL |
|
259 * is called when RTP packet is got succesfully from jitterbuffer. |
|
260 * |
|
261 * @since Series 60 3.0 |
|
262 * @param "aBuffer" |
|
263 * The buffer that needs filling with data |
|
264 * |
|
265 * @param "aConsumer" |
|
266 * The data sink that consumes the data. The data source needs this to make the BufferFilledL |
|
267 * callback on aConsumer when the data source has completed filling the aBuffer. |
|
268 * |
|
269 * @param "aMediaId" |
|
270 * This identifies the type of media eg audio or video and the stream id. |
|
271 * This parameter is required in cases where the source can supply data |
|
272 * of more than one media type and/or multiple strams of data eg a multimedia file. |
|
273 * @return None |
|
274 */ |
|
275 void FillBufferL( CMMFBuffer* aBuffer, |
|
276 MDataSink* aConsumer, |
|
277 TMediaId aMediaId ); |
|
278 |
|
279 /** |
|
280 * From MDataSource |
|
281 */ |
|
282 void NegotiateSourceL( MDataSink& aDataSink ); |
|
283 |
|
284 public: // From MMccRateAdaptationObserver |
|
285 |
|
286 TInt RateAdaptationRequest( const TMccEvent& aInputData, |
|
287 TMccEvent& aOutputData ); |
|
288 |
|
289 |
|
290 private: |
|
291 |
|
292 void AddUserL( MAsyncEventHandler* aUser ); |
|
293 |
|
294 TBool MultipleCodecs() const; |
|
295 |
|
296 void UpdateCurrentUserL(); |
|
297 |
|
298 private: |
|
299 |
|
300 #if ( ( defined(MCC_VIDEO_SOURCE_FOR_EMU) || defined(_lint) ) && !defined(TEST_EUNIT) ) |
|
301 CMccFileSourceImpl* iSourceImpl; |
|
302 #else |
|
303 CMccVideoSourceImpl* iSourceImpl; |
|
304 #endif |
|
305 |
|
306 TUint iCameraIndex; |
|
307 |
|
308 RPointerArray<TMccVideoSourceUser> iUsers; |
|
309 |
|
310 MAsyncEventHandler* iCurrentUser; |
|
311 |
|
312 TUint32 iReserved1; |
|
313 TUint32 iReserved2; |
|
314 |
|
315 private: |
|
316 |
|
317 #ifdef TEST_EUNIT |
|
318 friend class UT_CMccVideoSource; |
|
319 #endif |
|
320 |
|
321 |
|
322 }; |
|
323 |
|
324 |
|
325 #endif |
|
326 |
|
327 |
|
328 // End of file |