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