|
1 /* |
|
2 * Copyright (c) 2002-2005 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 |
|
21 #ifndef ANYPAYLOADFORMATREAD_H |
|
22 #define ANYPAYLOADFORMATREAD_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 #include <e32std.h> |
|
27 #include <mmf/server/mmfformat.h> |
|
28 #include "rtpheader.h" |
|
29 #include "formatstatemachine.h" |
|
30 #include "mccinternalcodecs.h" |
|
31 |
|
32 |
|
33 // CLASS DECLARATION |
|
34 class CMMFBuffer; |
|
35 |
|
36 /** |
|
37 * |
|
38 */ |
|
39 class CAnyPayloadFormatRead : public CPayloadFormatRead, |
|
40 public MPayloadFormatRead |
|
41 { |
|
42 public: // Constructors and destructor |
|
43 /** |
|
44 * Two-phased constructor. |
|
45 * @param aSource Source of the data for the payload format plugin |
|
46 */ |
|
47 static CAnyPayloadFormatRead* NewL ( MDataSource* aSource ); |
|
48 |
|
49 /** |
|
50 * Destructor. |
|
51 */ |
|
52 virtual ~CAnyPayloadFormatRead ( ); |
|
53 |
|
54 public: // New functions |
|
55 |
|
56 /** |
|
57 * Get number of audio packets received on downlink in last talk spurt. |
|
58 * @since Series-60 2.1 |
|
59 * @return Number of audio packets received |
|
60 */ |
|
61 virtual TInt LastDlPacketCount( ); |
|
62 |
|
63 /** |
|
64 * Cancel any requests from DataPath and Stop state machine also |
|
65 * @since Series-60 2.1 |
|
66 * @return None |
|
67 */ |
|
68 virtual void CancelDlRequest( ); |
|
69 |
|
70 /** |
|
71 * Send full sink buffer with AMR frames to data path. |
|
72 * Sink buffer is decided on one of the two frame buffers |
|
73 * Called by the state machine. |
|
74 * @since Series-60 2.1 |
|
75 * @return None |
|
76 */ |
|
77 void SendDataToSinkL( ); |
|
78 |
|
79 /* |
|
80 * Fill the sink buffer by decoding the RTP payload into AMR frames |
|
81 * Sink buffer is decided on one of the two frame buffers |
|
82 * Called by the state machine. |
|
83 * @since Series-60 2.1 |
|
84 * @return None |
|
85 */ |
|
86 void FillSinkBufferL( ); |
|
87 |
|
88 /** |
|
89 * Request the RTPSource to fill the source buffer with RTP payload |
|
90 * Source buffer is decided by the RTPSource. |
|
91 * Called by the state machine. |
|
92 * @since Series-60 2.1 |
|
93 * @return None |
|
94 */ |
|
95 void FillSourceBufferL( ); |
|
96 |
|
97 public: // From CMMFFormatDecode |
|
98 |
|
99 /** |
|
100 * From CMMFFormatDecode. Return number of audio streams for the given |
|
101 * media Raw audio files can only have 1 audio stream. |
|
102 * |
|
103 * @param aMediaType KUidMediaTypeAudio or KUidMediaTypeVideo |
|
104 * @return Number of audio streams |
|
105 */ |
|
106 TUint Streams( TUid aMediaType ) const; |
|
107 |
|
108 /** |
|
109 * Return the frame time interval for the given media |
|
110 * |
|
111 * @param aMediaType KUidMediaTypeAudio or KUidMediaTypeVideo |
|
112 * |
|
113 * @return Time interval in micro seconds |
|
114 */ |
|
115 TTimeIntervalMicroSeconds FrameTimeInterval( TMediaId aMediaType ) const; |
|
116 |
|
117 /** *** NOT SUPPORTED *** |
|
118 * Return the clip duration for the given media |
|
119 * |
|
120 * @param aMediaType KUidMediaTypeAudio or KUidMediaTypeVideo |
|
121 * |
|
122 * @return Clip duration in micro seconds |
|
123 */ |
|
124 TTimeIntervalMicroSeconds Duration( TMediaId aMediaType ) const; |
|
125 |
|
126 /** |
|
127 * From CMMFFormatDecode |
|
128 */ |
|
129 TFourCC SinkDataTypeCode( TMediaId aMediaId ); |
|
130 |
|
131 public: // From MDataSource. CAmrPayloadFormatRead is data source to the data path and AMR codec. |
|
132 |
|
133 /** |
|
134 * From MDataSource. Read the next block of data from file into the |
|
135 * given buffer. |
|
136 * |
|
137 * @param aBuffer source data buffer for the AMR-NB data read |
|
138 * @param aConsumer data sink pointer |
|
139 * @param aMediaId contains the media type KUidMediaTypeAudio or KUidMediaTypeVideo |
|
140 * |
|
141 * @return |
|
142 */ |
|
143 void FillBufferL( CMMFBuffer* aBuffer, |
|
144 MDataSink* aConsumer, |
|
145 TMediaId aMediaId ); |
|
146 |
|
147 /** |
|
148 * From MDataSource. Primes the source. |
|
149 * @since Series 60 3.0 |
|
150 * @return None |
|
151 */ |
|
152 void SourcePrimeL( ); |
|
153 |
|
154 /** |
|
155 * From MDataSource. Plays the source. |
|
156 * @since Series 60 3.0 |
|
157 * @return None |
|
158 */ |
|
159 void SourcePlayL( ); |
|
160 |
|
161 /** |
|
162 * From MDataSource. Pauses the source. |
|
163 * @since Series 60 3.0 |
|
164 * @return None |
|
165 */ |
|
166 void SourcePauseL( ); |
|
167 |
|
168 /** |
|
169 * From MDataSource. Stops the source. |
|
170 * @since Series 60 3.0 |
|
171 * @return None |
|
172 */ |
|
173 void SourceStopL( ); |
|
174 |
|
175 /** |
|
176 * Create a source buffer for the given media |
|
177 * |
|
178 * @param aMediaId contains the media type KUidMediaTypeAudio or KUidMediaTypeVideo |
|
179 * @param aReference value of False is returned to caller if source buffer is created |
|
180 * |
|
181 * @return Pointer to source buffer created |
|
182 */ |
|
183 CMMFBuffer* CreateSourceBufferL( TMediaId aMediaId, |
|
184 TBool &aReference ); |
|
185 |
|
186 /** |
|
187 * Create a source buffer for the given media, setting frame size to match |
|
188 * the given sink buffer |
|
189 * |
|
190 * @param aMediaId contains the media type KUidMediaTypeAudio or KUidMediaTypeVideo |
|
191 * @param aSinkBuffer address of sink buffer |
|
192 * @param aReference value of False is returned to caller if source buffer is created |
|
193 * |
|
194 * @return Pointer to source buffer created |
|
195 */ |
|
196 CMMFBuffer* CreateSourceBufferL( TMediaId aMediaId, |
|
197 CMMFBuffer& aSinkBuffer, |
|
198 TBool &aReference ); |
|
199 |
|
200 /** |
|
201 * Return the four CC code for the given media |
|
202 * |
|
203 * @param aMediaId contains the media type KUidMediaTypeAudio or KUidMediaTypeVideo |
|
204 * |
|
205 * @return FourCC code |
|
206 */ |
|
207 TFourCC SourceDataTypeCode( TMediaId aMediaId ); |
|
208 |
|
209 /** |
|
210 * Set the source data type to the given four CC code for the given media |
|
211 * |
|
212 * @param aSourceFourCC fourCC code |
|
213 * @param aMediaId contains the media type KUidMediaTypeAudio or KUidMediaTypeVideo |
|
214 * |
|
215 * @return error code KErrNotSupported if invalid media ID, else return KErrNone |
|
216 */ |
|
217 TInt SetSourceDataTypeCode( TFourCC aSourceFourCC, |
|
218 TMediaId aMediaId ); |
|
219 |
|
220 /** |
|
221 * Log in to the source thread - this funtion merely passes the command to |
|
222 * its source clip data source object. The source clip object will handle |
|
223 * the thread log on procedures. |
|
224 * |
|
225 * @param aEventHandler address of event handler |
|
226 * |
|
227 * @return error code returned by source clip |
|
228 */ |
|
229 TInt SourceThreadLogon( MAsyncEventHandler& aEventHandler ); |
|
230 |
|
231 /** |
|
232 * Log out of the source thread - this funtion merely passes the command to |
|
233 * its source clip data source object. The source clip object will handle |
|
234 * the thread log off procedures. |
|
235 * |
|
236 * @return None |
|
237 */ |
|
238 void SourceThreadLogoff( ); |
|
239 |
|
240 /** |
|
241 * Negotiate source settings ( buffer size ) to match |
|
242 * given source object |
|
243 * |
|
244 * @param aDataSink address of sink object |
|
245 * |
|
246 * @return None |
|
247 */ |
|
248 void NegotiateSourceL( MDataSink& aDataSink ); |
|
249 |
|
250 |
|
251 public: // From MDataSink. CAmrPayloadFormatRead is data sink to the RTP data source. |
|
252 |
|
253 /** |
|
254 * Called after the data buffer is filled. Update the number of bytes read |
|
255 * and the current read position for the next read operation. |
|
256 * |
|
257 * @param aBuffer data buffer filled |
|
258 * @param aHeaderInfo RTP packet header information |
|
259 * @return None |
|
260 */ |
|
261 virtual void DataBufferFilledL( CMMFBuffer* aBuffer, |
|
262 const TRtpRecvHeader& aHeaderInfo ); |
|
263 |
|
264 public: // only for videosource-anyformatter-filesink |
|
265 void BufferFilledL( CMMFBuffer* aBuffer ); |
|
266 public: |
|
267 |
|
268 /** |
|
269 * Configures payload format with format spesific parameters. |
|
270 * Leaves with KErrArgument if parameters are invalid. |
|
271 * |
|
272 * @since Series 60 3.0 |
|
273 * @param aConfigParams Configuration parameters |
|
274 * @return void |
|
275 */ |
|
276 virtual void ConfigurePayloadFormatL( const TDesC8& aConfigParams ); |
|
277 |
|
278 |
|
279 protected: // Functions from base classes |
|
280 private: |
|
281 /** |
|
282 * C++ default constructor. |
|
283 */ |
|
284 CAnyPayloadFormatRead(); |
|
285 |
|
286 /** |
|
287 * By default Symbian 2nd phase constructor is private. |
|
288 * |
|
289 * @param aSource Source of the data for the payload format plugin |
|
290 */ |
|
291 void ConstructL( MDataSource* aSource ); |
|
292 |
|
293 /** |
|
294 * Creates a buffer used in data transfer between format read and |
|
295 * its datasource. |
|
296 * |
|
297 * @since Series 60 3.2 |
|
298 * @param aSize Suggested buffer size |
|
299 * @param aIsOwnBuffer Indicates ownership of the buffer |
|
300 * @return Created buffer |
|
301 */ |
|
302 CMMFDataBuffer* CreateClipBufferL( TUint aSize, TBool& aIsOwnBuffer ); |
|
303 |
|
304 private: // data |
|
305 |
|
306 // Flag used to determine which buffer is currently used as a sink buffer |
|
307 enum TCurrentBuffer |
|
308 { |
|
309 EBufferOne = 0, |
|
310 EBufferTwo, |
|
311 EBufferNone |
|
312 }; |
|
313 |
|
314 // Data source providing RTP data |
|
315 MDataSource* iRtpDataSource; |
|
316 |
|
317 TFourCC iFourCC; |
|
318 |
|
319 TMediaId iMediaId; |
|
320 |
|
321 TBool iFillRequested; |
|
322 |
|
323 TBool iBufferToReadExists; |
|
324 |
|
325 // Format decoding state machine |
|
326 CFormatDecodeStateMachine* iStateMachine; |
|
327 |
|
328 // Buffer one to store data |
|
329 CMMFDataBuffer* iFrameBufferOne; |
|
330 |
|
331 // Buffer two to store data |
|
332 CMMFDataBuffer* iFrameBufferTwo; |
|
333 |
|
334 // Current buffer in use |
|
335 CMMFDataBuffer* iCurrentBuffer; |
|
336 |
|
337 // Buffer to hold payload got from RtpSourceSink |
|
338 CMMFDataBuffer* iPayloadBuffer; |
|
339 |
|
340 // Indicates whether payload read has ownership of source buffer |
|
341 TBool iSourceBufOwnership; |
|
342 |
|
343 // Parameters relating to RTP data decoding |
|
344 TMccCodecInfo iCInfo; |
|
345 |
|
346 // MMF AsyncEventHandler |
|
347 MAsyncEventHandler* iEventHandler; |
|
348 |
|
349 TInt iPacketCount; |
|
350 |
|
351 TInt iDroppedPacketCount; |
|
352 |
|
353 private: // Friend classes |
|
354 |
|
355 #ifdef EUNIT_TEST |
|
356 friend class UT_CAnyPayloadFormatRead; |
|
357 #endif |
|
358 }; |
|
359 |
|
360 #endif |