author | vnuitven <> |
Mon, 06 Sep 2010 18:50:40 +0530 | |
branch | rcs |
changeset 50 | 1d8943dd8be6 |
parent 49 | 64c62431ac08 |
child 51 | a13dcee59a62 |
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) 2010Nokia 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 |
// INCLUDE FILES |
|
20 |
#include <E32base.h> |
|
21 |
#include <mmffourcc.h> |
|
22 |
#include <mmfdatabuffer.h> |
|
23 |
#include <utf.h> // charconv.lib |
|
24 |
||
25 |
#include "MsrpPayloadFormatRead.h" |
|
26 |
#include "MsrpPayloadFormatWrite.h" // TStringElement, move independent |
|
27 |
#include "MccRtpDataSource.h" |
|
28 |
#include "Mccinternaldef.h" |
|
29 |
#include "MccMsrpFormatLogs.h" |
|
30 |
#include "msrppayloadformatdefs.h" |
|
31 |
||
32 |
||
33 |
// ============================= LOCAL FUNCTIONS =============================== |
|
34 |
||
35 |
const TUint KLostChar = 0xFFFD; |
|
36 |
||
37 |
// ============================ MEMBER FUNCTIONS =============================== |
|
38 |
||
39 |
// ----------------------------------------------------------------------------- |
|
40 |
// CMsrpPayloadFormatRead::CMsrpPayloadFormatRead |
|
41 |
// |
|
42 |
// CMsrpPayloadFormatRead default constructor, can NOT contain Msrp code, |
|
43 |
// that might leave |
|
44 |
// Phase #1 of 2-phase constructor |
|
45 |
// ----------------------------------------------------------------------------- |
|
46 |
// |
|
47 |
CMsrpPayloadFormatRead::CMsrpPayloadFormatRead ( ) : iFirstPacketsMissing (EFalse), |
|
48 |
iPacketSecNumber(EFalse) |
|
49 |
{ |
|
50 |
} |
|
51 |
||
52 |
||
53 |
// ----------------------------------------------------------------------------- |
|
54 |
// CMsrpPayloadFormatRead::ConstructL |
|
55 |
// Symbian 2nd phase constructor can leave. |
|
56 |
// ----------------------------------------------------------------------------- |
|
57 |
// |
|
58 |
void CMsrpPayloadFormatRead::ConstructL ( MDataSource* aSource ) |
|
59 |
{ |
|
60 |
||
61 |
DP_MSRP_WRITE( "CMsrpPayloadFormatRead::ConstructL" ); |
|
62 |
__ASSERT_ALWAYS( aSource, User::Leave( KErrArgument ) ); |
|
63 |
||
64 |
// we are coming downstream, the clip is now the source and |
|
65 |
// datapath the sink. If we use RTP source if of source the RTPSource |
|
66 |
||
67 |
iRtpDataSource = aSource; |
|
68 |
iClip = aSource; |
|
69 |
||
70 |
//Flags to indicate actions |
|
71 |
iFillRequested = EFalse; |
|
72 |
iBufferToReadExists = EFalse; |
|
73 |
||
74 |
iFourCC = KMccFourCCIdMSRP ; |
|
75 |
//iFourCC.Set( TFourCC( 'T','1','4','0' ) ); |
|
76 |
||
77 |
iRedData = new(ELeave)CArrayFixFlat<TStringElement>(3); |
|
78 |
TStringElement empty; |
|
79 |
iRedData->AppendL(empty); |
|
80 |
iRedData->AppendL(empty); |
|
81 |
iRedData->AppendL(empty); |
|
82 |
||
83 |
// TODO : refine my sizes |
|
84 |
iCharData = HBufC8::NewL( KDataSize ); |
|
85 |
iDecodedBuffer = CMMFDataBuffer::NewL( KRedHeaderSize + KDataSize ); |
|
86 |
||
87 |
// Initialize decoding state machine |
|
88 |
iStateMachine = CFormatDecodeStateMachine::NewL( this ); |
|
89 |
iStateMachine->ChangeState( EDecodeIdle ); |
|
90 |
||
91 |
} |
|
92 |
||
93 |
||
94 |
// ----------------------------------------------------------------------------- |
|
95 |
// CMsrpPayloadFormatRead::NewL |
|
96 |
// Two-phased constructor. |
|
97 |
// Static function for creating and constructing an instance of |
|
98 |
// the Text/Msrp Format |
|
99 |
// Returns: CMsrpPayloadFormatRead* : pointer to created instance |
|
100 |
// ----------------------------------------------------------------------------- |
|
101 |
// |
|
102 |
CMsrpPayloadFormatRead* CMsrpPayloadFormatRead::NewL( |
|
103 |
MDataSource* aSource ) |
|
104 |
||
105 |
{ |
|
106 |
||
107 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::NewL"); |
|
108 |
||
109 |
__ASSERT_ALWAYS( aSource, User::Leave( KErrArgument ) ); |
|
110 |
||
111 |
//__ASSERT_ALWAYS( ( KMccRtpSourceUid == aSource->DataSourceType() || |
|
112 |
// KMccMsrpSourceUid == aSource->DataSourceType() ), |
|
113 |
// User::Leave( KErrArgument ) ); |
|
114 |
CMsrpPayloadFormatRead* self = new ( ELeave ) CMsrpPayloadFormatRead; |
|
115 |
CleanupStack::PushL ( self ); |
|
116 |
self->ConstructL ( aSource ); |
|
117 |
CleanupStack::Pop( self ); |
|
118 |
return self; |
|
119 |
||
120 |
} |
|
121 |
||
122 |
||
123 |
||
124 |
// ----------------------------------------------------------------------------- |
|
125 |
// CMsrpPayloadFormatRead::~CMsrpPayloadFormatRead |
|
126 |
// |
|
127 |
// Destructor. |
|
128 |
// ----------------------------------------------------------------------------- |
|
129 |
// |
|
130 |
CMsrpPayloadFormatRead::~CMsrpPayloadFormatRead( ) |
|
131 |
{ |
|
132 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::~CMsrpPayloadFormatRead"); |
|
133 |
delete iFrameBufferOne; |
|
134 |
delete iFrameBufferTwo; |
|
135 |
||
136 |
if ( iSourceBufOwnership ) |
|
137 |
{ |
|
138 |
delete iPayloadBuffer; |
|
139 |
} |
|
140 |
else |
|
141 |
{ |
|
142 |
iPayloadBuffer = NULL; |
|
143 |
} |
|
144 |
||
145 |
if(iRedData) |
|
146 |
{ |
|
147 |
delete iRedData; |
|
148 |
iRedData = NULL; |
|
149 |
} |
|
150 |
||
151 |
if(iCharData) |
|
152 |
{ |
|
153 |
delete iCharData; |
|
154 |
iCharData = NULL; |
|
155 |
} |
|
156 |
||
157 |
if(iDecodedBuffer) |
|
158 |
{ |
|
159 |
delete iDecodedBuffer; |
|
160 |
iDecodedBuffer = NULL; |
|
161 |
} |
|
162 |
||
163 |
if ( iStateMachine ) |
|
164 |
{ |
|
165 |
iStateMachine->Cancel( ); |
|
166 |
delete iStateMachine; |
|
167 |
} |
|
168 |
iCurrentBuffer = NULL; |
|
169 |
iRtpDataSource = NULL; |
|
170 |
iClip = NULL; |
|
171 |
iDataPath = NULL; |
|
172 |
iEventHandler = NULL; |
|
173 |
} |
|
174 |
||
175 |
// ----------------------------------------------------------------------------- |
|
176 |
// CMsrpPayloadFormatRead::Streams |
|
177 |
// Return number of message streams for the given media |
|
178 |
// ----------------------------------------------------------------------------- |
|
179 |
// |
|
180 |
TUint CMsrpPayloadFormatRead::Streams( TUid /*aMediaType*/) const |
|
181 |
{ |
|
182 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::Streams"); |
|
183 |
return 1; |
|
184 |
} |
|
185 |
||
186 |
// ----------------------------------------------------------------------------- |
|
187 |
// CMsrpPayloadFormatRead::FrameTimeInterval |
|
188 |
// Return the frame time interval for the given media |
|
189 |
// ----------------------------------------------------------------------------- |
|
190 |
// |
|
191 |
TTimeIntervalMicroSeconds CMsrpPayloadFormatRead::FrameTimeInterval( |
|
192 |
TMediaId /*aMediaId*/ ) const |
|
193 |
{ |
|
194 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::FrameTimeInterval"); |
|
195 |
||
196 |
return TTimeIntervalMicroSeconds( TInt64( 0 ) ); |
|
197 |
} |
|
198 |
||
199 |
||
200 |
// ----------------------------------------------------------------------------- |
|
201 |
// CMsrpPayloadFormatRead:: |
|
202 |
// Fill Buffer. If DataSink asks to Fill a buffer |
|
203 |
// ----------------------------------------------------------------------------- |
|
204 |
// |
|
205 |
void CMsrpPayloadFormatRead::FillBufferL( CMMFBuffer* aBuffer, |
|
206 |
MDataSink* aConsumer, |
|
207 |
TMediaId aMediaId ) |
|
208 |
{ |
|
209 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::FillBufferL"); |
|
210 |
__ASSERT_ALWAYS( aBuffer, User::Leave( KErrArgument ) ); |
|
211 |
__ASSERT_ALWAYS( aBuffer->Type() == KUidMmfDataBuffer, User::Leave( KErrArgument ) ); |
|
212 |
__ASSERT_ALWAYS( aConsumer, User::Leave( KErrArgument ) ); |
|
213 |
__ASSERT_ALWAYS( iStateMachine, User::Leave( KErrArgument ) ); |
|
214 |
__ASSERT_ALWAYS( iFrameBufferOne, User::Leave( KErrArgument ) ); |
|
215 |
__ASSERT_ALWAYS( iFrameBufferTwo, User::Leave( KErrArgument ) ); |
|
216 |
||
217 |
iDataPath = aConsumer; |
|
218 |
iMediaId = aMediaId; |
|
219 |
iFillRequested = ETrue; |
|
220 |
||
221 |
if ( iCurrentBuffer ) |
|
222 |
{ |
|
223 |
iCurrentBuffer->SetStatus( EAvailable ); |
|
224 |
iCurrentBuffer = NULL; |
|
225 |
} |
|
226 |
||
227 |
if (iFrameBufferOne->Status() == EFull ) |
|
228 |
{ |
|
229 |
iCurrentBuffer = iFrameBufferOne; |
|
230 |
iStateMachine->ChangeState( ESourceDataReady ); |
|
231 |
} |
|
232 |
else if (iFrameBufferTwo->Status() == EFull ) |
|
233 |
{ |
|
234 |
iCurrentBuffer = iFrameBufferTwo; |
|
235 |
iStateMachine->ChangeState( ESourceDataReady ); |
|
236 |
} |
|
237 |
else |
|
238 |
{ |
|
239 |
FillSourceBufferL(); |
|
240 |
} |
|
241 |
// ResetBuffers(); |
|
242 |
} |
|
243 |
||
244 |
||
245 |
||
246 |
// ----------------------------------------------------------------------------- |
|
247 |
// CMsrpPayloadFormatRead::FillSinkBuffer |
|
248 |
// Read RTP payload and convert it into Text/Msrp Data |
|
249 |
// ----------------------------------------------------------------------------- |
|
250 |
// |
|
251 |
void CMsrpPayloadFormatRead::FillSinkBufferL() |
|
252 |
{ |
|
253 |
||
254 |
// reset all bufs |
|
255 |
ResetPacketBuffers(); |
|
256 |
const TDesC8& srcBuf( iCurrentBuffer->Data() ); |
|
257 |
||
258 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::FillSinkBufferL, iPacketCount: %d ", iPacketCount ); |
|
259 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::FillSinkBufferL, iFirstPacketsMissing: %d ", iFirstPacketsMissing ); |
|
260 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::FillSinkBufferL, iSatisfySecNumber: %d ", iSatisfySecNumber ); |
|
261 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::FillSinkBufferL, iLevelsMissing: %d ", iLevelsMissing ); |
|
262 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::FillSinkBufferL, iDroppedPacketCount: %d ", iDroppedPacketCount ); |
|
263 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::FillSinkBufferL, iCurrentBuffer Size() : %d ", iCurrentBuffer->Data().Size() ); |
|
264 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::FillSinkBufferL, Currentbuffer BufferSize() : %d ", iCurrentBuffer->BufferSize() ); |
|
265 |
||
266 |
||
267 |
// Do not forward zero length buffers, even though we filtered all unwanted data |
|
268 |
// allready in BufferFilledL() -method |
|
269 |
if ( iCurrentBuffer->BufferSize() > 0 ) |
|
270 |
{ |
|
271 |
||
272 |
TInt pValue(0); |
|
273 |
switch ( iCodecInfo.iRedundancyCount ) |
|
274 |
{ |
|
275 |
case 0: |
|
276 |
iDecodedBuffer->Data().Append( iCurrentBuffer->Data() ); |
|
277 |
iSatisfySecNumber++; |
|
278 |
break; |
|
279 |
||
280 |
case 2: |
|
281 |
pValue = DecodePayloadL( srcBuf ); |
|
282 |
User::LeaveIfError(HandleRedundancyL(pValue)); |
|
283 |
break; |
|
284 |
} |
|
285 |
||
286 |
if ( !pValue ) |
|
287 |
{ |
|
288 |
iStateMachine->ChangeState( EEmptyDataToSink ); |
|
289 |
} |
|
290 |
else |
|
291 |
{ |
|
292 |
FillSourceBufferL(); |
|
293 |
} |
|
294 |
} |
|
295 |
else |
|
296 |
{ |
|
297 |
// No payload or Data sent by SipCon1, ask for more |
|
298 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::FillSinkBufferL - Empty Data"); |
|
299 |
iStateMachine->ChangeState( EWaitSourceData ); |
|
300 |
} |
|
301 |
} |
|
302 |
||
303 |
||
304 |
||
305 |
||
306 |
// ----------------------------------------------------------------------------- |
|
307 |
// CMsrpPayloadFormatRead::ResetBuffers() |
|
308 |
// Send fill buffer request to RTP Data Source |
|
309 |
// ----------------------------------------------------------------------------- |
|
310 |
// |
|
311 |
void CMsrpPayloadFormatRead::ResetBuffers() |
|
312 |
{ |
|
313 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::ResetBuffers"); |
|
314 |
if ( iCurrentBuffer ) |
|
315 |
{ |
|
316 |
iCurrentBuffer->SetStatus( EAvailable ); |
|
317 |
iCurrentBuffer = NULL; |
|
318 |
} |
|
319 |
||
320 |
if (iFrameBufferOne->Status() == EFull ) |
|
321 |
{ |
|
322 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::ResetBuffers() - FB1 - was FULL"); |
|
323 |
iCurrentBuffer = iFrameBufferOne; |
|
324 |
iStateMachine->ChangeState( ESourceDataReady ); |
|
325 |
} |
|
326 |
else if (iFrameBufferTwo->Status() == EFull ) |
|
327 |
{ |
|
328 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::ResetBuffers() - FB2 - was FULL"); |
|
329 |
iCurrentBuffer = iFrameBufferTwo; |
|
330 |
iStateMachine->ChangeState( ESourceDataReady ); |
|
331 |
} |
|
332 |
else |
|
333 |
{ |
|
334 |
iStateMachine->ChangeState( EWaitSourceData ); |
|
335 |
} |
|
336 |
} |
|
337 |
||
338 |
||
339 |
// ----------------------------------------------------------------------------- |
|
340 |
// CMsrpPayloadFormatRead::FillSourceBufferL |
|
341 |
// Send fill buffer request to RTP Data Source |
|
342 |
// ----------------------------------------------------------------------------- |
|
343 |
// |
|
344 |
void CMsrpPayloadFormatRead::FillSourceBufferL() |
|
345 |
{ |
|
346 |
||
347 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::FillSourceBufferL"); |
|
348 |
__ASSERT_ALWAYS( iClip, User::Leave( KErrArgument ) ); |
|
349 |
__ASSERT_ALWAYS( iPayloadBuffer, User::Leave( KErrArgument ) ); |
|
350 |
||
351 |
iClip->FillBufferL(iPayloadBuffer, this, iMediaId ); |
|
352 |
} |
|
353 |
||
354 |
// ----------------------------------------------------------------------------- |
|
355 |
// CMsrpPayloadFormatRead::SendDataToSinkL |
|
356 |
// Send full frame buffer to Data Path |
|
357 |
// ----------------------------------------------------------------------------- |
|
358 |
// |
|
359 |
void CMsrpPayloadFormatRead::SendDataToSinkL( ) |
|
360 |
{ |
|
361 |
||
362 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::SendDataToSinkL()"); |
|
363 |
iFillRequested = EFalse; |
|
364 |
iDataPath->BufferFilledL( iDecodedBuffer ); |
|
365 |
||
366 |
} |
|
367 |
||
368 |
// ----------------------------------------------------------------------------- |
|
369 |
// CMsrpPayloadFormatRead::CreateSourceBufferL |
|
370 |
// Create a source buffer for the given media and indicate in aReference if |
|
371 |
// buffer is created. |
|
372 |
// ----------------------------------------------------------------------------- |
|
373 |
// |
|
374 |
CMMFBuffer* CMsrpPayloadFormatRead::CreateSourceBufferL( |
|
375 |
TMediaId /*aMediaId*/, |
|
376 |
TBool &aReference ) |
|
377 |
{ |
|
378 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::CreateSourceBufferL"); |
|
379 |
// the source buffers belong to MsrpPayloadFormatRead not to datapath |
|
380 |
// aReference should be set to ETrue and destroyed by MsrpPayloadFormatRead |
|
381 |
// itself. |
|
382 |
aReference = ETrue; |
|
383 |
iCurrentBuffer = iFrameBufferOne; |
|
384 |
return iFrameBufferOne; |
|
385 |
||
386 |
} |
|
387 |
||
388 |
||
389 |
// ----------------------------------------------------------------------------- |
|
390 |
// CMsrpPayloadFormatRead::CreateSourceBufferL |
|
391 |
// Create a source buffer for the given media, setting frame size to match |
|
392 |
// the given sink buffer |
|
393 |
// ----------------------------------------------------------------------------- |
|
394 |
// |
|
395 |
CMMFBuffer* CMsrpPayloadFormatRead::CreateSourceBufferL( |
|
396 |
TMediaId aMediaId, |
|
397 |
CMMFBuffer& /*aSinkBuffer*/, |
|
398 |
TBool &aReference ) |
|
399 |
{ |
|
400 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::CreateSourceBufferL"); |
|
401 |
return CreateSourceBufferL( aMediaId, aReference ); |
|
402 |
} |
|
403 |
||
404 |
||
405 |
// ----------------------------------------------------------------------------- |
|
406 |
// CMsrpPayloadFormatRead::SourceDataTypeCode |
|
407 |
// Return the source data type ( four CC code ) for the given media |
|
408 |
// ----------------------------------------------------------------------------- |
|
409 |
// |
|
410 |
TFourCC CMsrpPayloadFormatRead::SourceDataTypeCode( |
|
411 |
TMediaId aMediaId ) |
|
412 |
{ |
|
413 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::SourceDataTypeCode"); |
|
414 |
//TODO: Change me when platform supports |
|
415 |
if ( KUidMediaTypeAudio == aMediaId.iMediaType ) |
|
416 |
{ |
|
417 |
return iFourCC; |
|
418 |
} |
|
419 |
else |
|
420 |
{ |
|
421 |
return TFourCC( ); //defaults to 'NULL' fourCC |
|
422 |
} |
|
423 |
||
424 |
} |
|
425 |
||
426 |
// ----------------------------------------------------------------------------- |
|
427 |
// CMsrpPayloadFormatRead::SetSourceDataTypeCode |
|
428 |
// Set the source data type to the given four CC code for the given |
|
429 |
// media |
|
430 |
// ----------------------------------------------------------------------------- |
|
431 |
// |
|
432 |
TInt CMsrpPayloadFormatRead::SetSourceDataTypeCode( TFourCC aSourceFourCC, |
|
433 |
TMediaId aMediaId ) |
|
434 |
{ |
|
435 |
||
436 |
//TODO Change me when platform supports |
|
437 |
/* |
|
438 |
if ( KUidMediaTypeAudio != aMediaId.iMediaType ) |
|
439 |
{ |
|
440 |
return KErrNotSupported; |
|
441 |
} |
|
442 |
*/ |
|
443 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::SetSourceDataTypeCode"); |
|
444 |
iFourCC = aSourceFourCC; |
|
445 |
iMediaId = aMediaId; |
|
446 |
iClip->SetSourceDataTypeCode( iFourCC, iMediaId ); |
|
447 |
return KErrNone; |
|
448 |
||
449 |
} |
|
450 |
||
451 |
// ----------------------------------------------------------------------------- |
|
452 |
// CMsrpPayloadFormatRead::SourceThreadLogon |
|
453 |
// Log in to the source thread |
|
454 |
// ----------------------------------------------------------------------------- |
|
455 |
// |
|
456 |
TInt CMsrpPayloadFormatRead::SourceThreadLogon( |
|
457 |
MAsyncEventHandler& aEventHandler ) |
|
458 |
{ |
|
459 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::SourceThreadLogon"); |
|
460 |
iEventHandler = &aEventHandler; |
|
461 |
iClip->SourceThreadLogon( aEventHandler ); |
|
462 |
return KErrNone; |
|
463 |
||
464 |
} |
|
465 |
||
466 |
// ----------------------------------------------------------------------------- |
|
467 |
// CMsrpPayloadFormatRead::NegotiateSourceL( MDataSink& aDataSink ) |
|
468 |
// Negotiate source settings to match data sink object. |
|
469 |
// Re-size frame buffers if needed |
|
470 |
// ----------------------------------------------------------------------------- |
|
471 |
// |
|
472 |
void CMsrpPayloadFormatRead::NegotiateSourceL( MDataSink& /*aDataSink*/ ) |
|
473 |
{ |
|
474 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::NegotiateSourceL"); |
|
475 |
__ASSERT_ALWAYS( iClip, User::Leave( KErrArgument ) ); |
|
476 |
iClip->NegotiateSourceL( *this ); |
|
477 |
||
478 |
} |
|
479 |
||
480 |
// ----------------------------------------------------------------------------- |
|
481 |
// CMsrpPayloadFormatRead::SourceThreadLogoff |
|
482 |
// Log out of the source thread. |
|
483 |
// ----------------------------------------------------------------------------- |
|
484 |
// |
|
485 |
void CMsrpPayloadFormatRead::SourceThreadLogoff() |
|
486 |
{ |
|
487 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::SourceThreadLogoff"); |
|
488 |
iClip->SourceThreadLogoff( ); |
|
489 |
} |
|
490 |
||
491 |
||
492 |
// ----------------------------------------------------------------------------- |
|
493 |
// CMsrpPayloadFormatRead::FilterUnwantedData |
|
494 |
// this method can be used to filter unwanted data off |
|
495 |
// |
|
496 |
// e.g SipCon1 sends BOM data in first String and PS data as carriage return |
|
497 |
// Engine should NOT touch these but Presentation layer should take care of these |
|
498 |
||
499 |
// Method can be used to filtering pusposes if needed |
|
500 |
// ----------------------------------------------------------------------------- |
|
501 |
// |
|
502 |
TBool CMsrpPayloadFormatRead::FilterUnwantedData(const TDesC8& aBuffer) |
|
503 |
{ |
|
504 |
||
505 |
//TODO: We must do a entity recognizer, which handles this kind of data |
|
506 |
// This does not affect to actual formatter, instead we |
|
507 |
// a) must do it to application side |
|
508 |
// b) we must define an interface, which can be called |
|
509 |
TBool ret = ETrue; |
|
510 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::FilterUnwantedData() - BufferSize:%d",aBuffer.Length()); |
|
511 |
||
512 |
//get Three first or Three last chars |
|
513 |
if( aBuffer.Length() >= 3 ) |
|
514 |
{ |
|
515 |
//SipCon sends BOM for the first time |
|
516 |
TPtrC8 pBOM = aBuffer.Left(3); |
|
517 |
if ( pBOM[0] == 0xEF && pBOM[1] == 0xBB && pBOM[2]== 0xBF) |
|
518 |
{ |
|
519 |
//return EFalse if want to filter the whole message |
|
520 |
ret = ETrue; |
|
521 |
} |
|
522 |
||
523 |
||
524 |
// last are unicode PS char ( return ) |
|
525 |
TPtrC8 pPS = aBuffer.Right(3); |
|
526 |
if ( pPS[0] == 0xE2 && pPS[1] == 0x80 && pPS[2]== 0xA8) |
|
527 |
{ |
|
528 |
//return EFalse if want to filter |
|
529 |
ret = ETrue; |
|
530 |
} |
|
531 |
||
532 |
} |
|
533 |
//There might be back spaces and other marks |
|
534 |
else if( aBuffer.Length() >= 1 ) |
|
535 |
{ |
|
536 |
TPtrC8 pChar = aBuffer.Left(1); |
|
537 |
if( pChar[0] == 0x08 ) |
|
538 |
{ |
|
539 |
ret = ETrue; |
|
540 |
} |
|
541 |
//bell |
|
542 |
else if( pChar[0] == 0x07) |
|
543 |
{ |
|
544 |
ret = ETrue; |
|
545 |
} |
|
546 |
//tab |
|
547 |
else if( pChar[0] == 0x09) |
|
548 |
{ |
|
549 |
ret = ETrue; |
|
550 |
} |
|
551 |
//escape |
|
552 |
else if( pChar[0] == 0x1B) |
|
553 |
{ |
|
554 |
ret = ETrue; |
|
555 |
} |
|
556 |
||
557 |
//etc |
|
558 |
} |
|
559 |
||
560 |
return ret; |
|
561 |
} |
|
562 |
// ----------------------------------------------------------------------------- |
|
563 |
// CMsrpPayloadFormatRead::BufferFilledL |
|
564 |
// Called after the data buffer is filled. Update the number of bytes read |
|
565 |
// and the current read position for the next read operation. |
|
566 |
// ----------------------------------------------------------------------------- |
|
567 |
// |
|
568 |
void CMsrpPayloadFormatRead::DataBufferFilledL( CMMFBuffer* aBuffer, |
|
569 |
const TRtpRecvHeader& aRtpHeader ) |
|
570 |
{ |
|
571 |
||
572 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::SendDataToSinkL() - BufferSize:%d",aBuffer->BufferSize()); |
|
573 |
||
574 |
__ASSERT_ALWAYS( aBuffer, User::Leave( KErrArgument ) ); |
|
575 |
__ASSERT_ALWAYS( aBuffer->Type() == KUidMmfDataBuffer, User::Leave( KErrArgument ) ); |
|
576 |
__ASSERT_ALWAYS( iClip, User::Leave( KErrArgument ) ); |
|
577 |
__ASSERT_ALWAYS( iStateMachine, User::Leave( KErrArgument ) ); |
|
578 |
__ASSERT_ALWAYS( iFrameBufferOne , User::Leave( KErrArgument ) ); |
|
579 |
__ASSERT_ALWAYS( iFrameBufferTwo , User::Leave( KErrArgument ) ); |
|
580 |
||
581 |
||
582 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::BufferFilledL with RTP header param:"); |
|
583 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::BufferFilledL iPadding: %d", aRtpHeader.iPadding ); |
|
584 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::BufferFilledL iExtension: %d", aRtpHeader.iExtension ); |
|
585 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::BufferFilledL iCsrcCount: %d", aRtpHeader.iCsrcCount ); |
|
586 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::BufferFilledL iMarker: %d", aRtpHeader.iMarker ); |
|
587 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::BufferFilledL iPayloadType: %d", aRtpHeader.iPayloadType ); |
|
588 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::BufferFilledL iSeqNum: %d", aRtpHeader.iSeqNum ); |
|
589 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::BufferFilledL iTimestamp: %d", aRtpHeader.iTimestamp ); |
|
590 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::BufferFilledL iHeaderExtension: %d", (TInt)aRtpHeader.iHeaderExtension ); |
|
591 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::BufferFilledL iCsrcList: %d", (TInt)aRtpHeader.iCsrcList ); |
|
592 |
||
593 |
// Do not forward smaller zero length buffers or unwanted data |
|
594 |
if ( aBuffer->BufferSize() > 0 && FilterUnwantedData(static_cast<CMMFDataBuffer*>( aBuffer )->Data()) ) |
|
595 |
{ |
|
596 |
//check seqnumber, if first packet get sequence Nr. from it |
|
597 |
if ( iPacketCount == 0 ) |
|
598 |
{ |
|
599 |
//if marker == 1, then we know this is the first packet |
|
600 |
if(aRtpHeader.iMarker == 1) |
|
601 |
{ |
|
602 |
// flag to indicate, because first of idle sends this also |
|
603 |
if ( !iPacketSecNumber ) |
|
604 |
{ |
|
605 |
iSatisfySecNumber = aRtpHeader.iSeqNum; |
|
606 |
iCheckSum = iSatisfySecNumber; |
|
607 |
iPacketSecNumber = ETrue; |
|
608 |
} |
|
609 |
} |
|
610 |
else |
|
611 |
{ |
|
612 |
// first packet was missing, signal this |
|
613 |
iFirstPacketsMissing = ETrue; |
|
614 |
DP_MSRP_WRITE("First Packet Is MISSING!"); |
|
615 |
} |
|
616 |
||
617 |
} |
|
618 |
else |
|
619 |
{ |
|
620 |
// 0, -1, -2; ( 0 means expected packet arrived ) |
|
621 |
//iLevelsMissing = iSatisfySecNumber - aRtpHeader.iSeqNum; |
|
622 |
iLevelsMissing = 0; |
|
623 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::BufferFilledL iLevelsMissing: %d", iLevelsMissing ); |
|
624 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::BufferFilledL aRtpHeader.iSeqNum: %d", aRtpHeader.iSeqNum ); |
|
625 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::BufferFilledL iSatisfySecNumber: %d", iSatisfySecNumber ); |
|
626 |
} |
|
627 |
||
628 |
||
629 |
iPacketCount++; |
|
630 |
// check for packets arriving late, redundant data allready got |
|
631 |
if ( iLevelsMissing <= 0) |
|
632 |
{ |
|
633 |
// we add packet count here. This is for physical packets, not for redundant data |
|
634 |
||
635 |
if ( iFrameBufferOne->Status() == EAvailable ) |
|
636 |
{ |
|
637 |
iFrameBufferOne->Data().Copy( static_cast<CMMFDataBuffer*>( aBuffer )->Data() ); |
|
638 |
iFrameBufferOne->SetTimeToPlay( aRtpHeader.iTimestamp ); |
|
639 |
iFrameBufferOne->SetLastBuffer( aRtpHeader.iMarker ); |
|
640 |
iFrameBufferOne->SetFrameNumber( aRtpHeader.iSeqNum ); |
|
641 |
iFrameBufferOne->SetStatus( EFull ); |
|
642 |
||
643 |
if (iFrameBufferTwo->Status() == EAvailable ) |
|
644 |
{ |
|
645 |
iCurrentBuffer = iFrameBufferOne; |
|
646 |
iStateMachine->ChangeState( ESourceDataReady ); |
|
647 |
} |
|
648 |
} |
|
649 |
else if ( iFrameBufferTwo->Status() == EAvailable ) |
|
650 |
{ |
|
651 |
iFrameBufferTwo->Data().Copy( static_cast<CMMFDataBuffer*>( aBuffer )->Data() ); |
|
652 |
iFrameBufferTwo->SetTimeToPlay( aRtpHeader.iTimestamp ); |
|
653 |
iFrameBufferTwo->SetLastBuffer( aRtpHeader.iMarker ); |
|
654 |
iFrameBufferTwo->SetFrameNumber( aRtpHeader.iSeqNum ); |
|
655 |
iFrameBufferTwo->SetStatus( EFull ); |
|
656 |
||
657 |
if (iFrameBufferOne->Status() == EAvailable ) |
|
658 |
{ |
|
659 |
iCurrentBuffer = iFrameBufferTwo; |
|
660 |
iStateMachine->ChangeState( ESourceDataReady ); |
|
661 |
} |
|
662 |
} |
|
663 |
else |
|
664 |
{ |
|
665 |
// Neither of the buffers is available and leave |
|
666 |
User::Leave( KErrNotReady ); |
|
667 |
} |
|
668 |
} |
|
669 |
else |
|
670 |
{ |
|
671 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::BufferFilledL IGNORING Packet, data recovered!"); |
|
672 |
} |
|
673 |
||
674 |
} |
|
675 |
else |
|
676 |
{ |
|
677 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::BufferFilledL NO PAYLOAD, Data smaller than 8 bytes "); |
|
678 |
iStateMachine->ChangeState( EWaitSourceData ); |
|
679 |
} |
|
680 |
||
681 |
||
682 |
} |
|
683 |
||
684 |
||
685 |
||
686 |
// ----------------------------------------------------------------------------- |
|
687 |
// CMsrpPayloadFormatRead::DecodePayloadL( const TDesC8& aBuffer ) |
|
688 |
// |
|
689 |
// Decodec payload according level 2 redundancy ( RFC 4103 ) |
|
690 |
// First there are Normal RTP Header, which was extracted by RTP Stack. |
|
691 |
// Then there are two 32-bit Redundant headers and one 8 -bit primary Header. |
|
692 |
// Then there are R2, R1 and Primary data appended respectively. |
|
693 |
// ----------------------------------------------------------------------------- |
|
694 |
// |
|
695 |
TInt CMsrpPayloadFormatRead::DecodePayloadL( const TDesC8& aBuffer ) |
|
696 |
{ |
|
697 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::DecodePayload()"); |
|
698 |
||
699 |
TInt ret = KErrNone; |
|
700 |
RDebug::Print( _L("CMsrpPayloadFormatRead::DecodePayload() -> %d") , aBuffer.Size() ); |
|
701 |
const TUint8* aPtr = aBuffer.Ptr(); |
|
702 |
TInt ctr(0); |
|
703 |
||
704 |
// get 1st 32 = R2 header |
|
705 |
TUint32 r2Header = Read32( aPtr ); |
|
706 |
||
707 |
RDebug::Print( _L("CMsrpPayloadFormatRead R2 Header Data : %x"), r2Header ); |
|
708 |
aPtr += 4; |
|
709 |
ctr+= 4; |
|
710 |
TUint16 aR2Lenght(0), aR2TimeStamp(0); |
|
711 |
TInt err = ParseRedHeader( r2Header, aR2Lenght, aR2TimeStamp ); |
|
712 |
||
713 |
RDebug::Print( _L("CMsrpPayloadFormatRead R2 Lengt : %d , TimeStamp %x "), aR2Lenght, aR2TimeStamp ); |
|
714 |
if( err ) |
|
715 |
{ |
|
716 |
User::Leave( err ); |
|
717 |
} |
|
718 |
||
719 |
// get 2nd 32 = R1 header |
|
720 |
TUint32 r1Header = Read32( aPtr ); |
|
721 |
RDebug::Print( _L("CMsrpPayloadFormatRead R1 Header Data : %x"), r1Header ); |
|
722 |
aPtr += 4; |
|
723 |
ctr +=4; |
|
724 |
TUint16 aR1Lenght(0), aR1TimeStamp(0); |
|
725 |
err = ParseRedHeader( r1Header, aR1Lenght, aR1TimeStamp ); |
|
726 |
RDebug::Print( _L("CMsrpPayloadFormatRead R1 Lengt : %x , TimeStamp %x "), aR1Lenght, aR1TimeStamp ); |
|
727 |
if( err ) |
|
728 |
{ |
|
729 |
User::Leave( err ); |
|
730 |
} |
|
731 |
||
732 |
// get |
|
733 |
TUint8 aPt = ( Read8( aPtr ) & 255 ); |
|
734 |
aPtr += 1; |
|
735 |
ctr += 1; |
|
736 |
TUint8 pPayloadType = ( aPt & 127 ); |
|
737 |
TUint8 pBit = ( aPt >> 7 ); |
|
738 |
||
739 |
RDebug::Print( _L("CMsrpPayloadFormatRead Primary data : %d "), aPt ); |
|
740 |
RDebug::Print( _L("CMsrpPayloadFormatRead Primary bit : %d , PT %d "), pBit, pPayloadType ); |
|
741 |
||
742 |
//TODO: When IOP-Tests Are done clean me out. |
|
743 |
TPtr8 pP = iCharData->Des(); |
|
744 |
pP.FillZ(); |
|
745 |
pP.Zero(); |
|
746 |
pP.Append(aPtr, aR2Lenght); |
|
747 |
aPtr += aR2Lenght; |
|
748 |
TBuf16<KDataSize> unicode; |
|
749 |
User::LeaveIfError( |
|
750 |
CnvUtfConverter::ConvertToUnicodeFromUtf8(unicode, pP )); |
|
751 |
TStringElement data; |
|
752 |
data.iData = unicode; |
|
753 |
iRedData->AppendL(data); |
|
754 |
||
755 |
RDebug::Print( _L("CMsrpPayloadFormatRead GOT Data %S "), &pP ); |
|
756 |
||
757 |
pP.FillZ(); |
|
758 |
pP.Zero(); |
|
759 |
pP.Append(aPtr, aR1Lenght); |
|
760 |
aPtr += aR2Lenght; |
|
761 |
unicode.FillZ(); |
|
762 |
unicode.Zero(); |
|
763 |
User::LeaveIfError( |
|
764 |
CnvUtfConverter::ConvertToUnicodeFromUtf8(unicode, pP )); |
|
765 |
data.iData = unicode; |
|
766 |
iRedData->AppendL(data); |
|
767 |
||
768 |
RDebug::Print( _L("CMsrpPayloadFormatRead GOT Data %S "), &pP ); |
|
769 |
TInt rest = aBuffer.Size() - ( ctr + aR2Lenght + aR1Lenght); |
|
770 |
||
771 |
//NO PRIMARY DATA, means redundant packet |
|
772 |
if( rest == 0) |
|
773 |
{ |
|
774 |
ret = KErrNotFound; |
|
775 |
} |
|
776 |
||
777 |
RDebug::Print( _L("CMsrpPayloadFormatRead Rest %d "), rest ); |
|
778 |
||
779 |
pP.FillZ(); |
|
780 |
pP.Zero(); |
|
781 |
pP.Append(aPtr, rest ); |
|
782 |
aPtr += aBuffer.Size(); |
|
783 |
unicode.FillZ(); |
|
784 |
unicode.Zero(); |
|
785 |
User::LeaveIfError( |
|
786 |
CnvUtfConverter::ConvertToUnicodeFromUtf8(unicode, pP )); |
|
787 |
data.iData = unicode; |
|
788 |
iRedData->AppendL(data); |
|
789 |
||
790 |
RDebug::Print( _L("CMsrpPayloadFormatRead GOT Data %S "), &pP ); |
|
791 |
return ret; |
|
792 |
||
793 |
} |
|
794 |
||
795 |
||
796 |
// ----------------------------------------------------------------------------- |
|
797 |
// CMsrpPayloadFormatRead::ParseRedHeader |
|
798 |
// Small helper method that parses the 32-bit redundant header |
|
799 |
// according to RFC 4103 |
|
800 |
// ----------------------------------------------------------------------------- |
|
801 |
// |
|
802 |
TInt CMsrpPayloadFormatRead::ParseRedHeader(TUint32 /*aHeader*/, TUint16& /*aLenght*/, TUint16& /*aTimeStamp*/ ) |
|
803 |
{ |
|
804 |
// Not Supported |
|
805 |
#if 0 |
|
806 |
TUint8 aPt = ( aHeader >> 24 ) & 255; |
|
807 |
TUint8 aTest = ( aHeader ) & 255; |
|
808 |
||
809 |
TUint8 aBit = ( aPt >> 7 ) & 1; |
|
810 |
TUint8 aPayloadType = ( aPt & 127 ); |
|
811 |
//TODO: Checks fi PayloadTypes and bits match |
|
812 |
||
813 |
aTimeStamp = ( aHeader >> 10 ) & 0x3FFF; |
|
814 |
aLenght = ( aHeader & 0x3FF ); |
|
815 |
//TODO: Checks if timestampoffset and lenght is ok |
|
816 |
#endif |
|
817 |
return KErrNone; |
|
818 |
} |
|
819 |
||
820 |
||
821 |
// ----------------------------------------------------------------------------- |
|
822 |
// CMsrpPayloadFormatRead::HandleRedundancyL |
|
823 |
// Logic method, that updates all counters and decides what data we should |
|
824 |
// append to userBuffer. If packets are missing, we must use redundant data |
|
825 |
// ----------------------------------------------------------------------------- |
|
826 |
// |
|
827 |
TInt CMsrpPayloadFormatRead::HandleRedundancyL(TInt aErrNo) |
|
828 |
{ |
|
829 |
||
830 |
DP_MSRP_WRITE2("CAnyPayloadFormatRead::BufferFilledL iLevelsMissing: %d", iLevelsMissing ); |
|
831 |
DP_MSRP_WRITE2("CAnyPayloadFormatRead::BufferFilledL iFirstPacketsMissing: %d", iFirstPacketsMissing ); |
|
832 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::HandleRedundancy() -> 0 :%S", &iRedData->At(0).iData ); |
|
833 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::HandleRedundancy() -> 1 :%S", &iRedData->At(1).iData ); |
|
834 |
DP_MSRP_WRITE2("CMsrpPayloadFormatRead::HandleRedundancy() -> 2 :%S", &iRedData->At(2).iData ); |
|
835 |
||
836 |
//if first packet is missing handle all redData |
|
837 |
if( iFirstPacketsMissing ) |
|
838 |
{ |
|
839 |
iDecodedBuffer->Data().Append( iRedData->At(2).iData ); |
|
840 |
iDecodedBuffer->Data().Append( iRedData->At(1).iData ); |
|
841 |
iDecodedBuffer->Data().Append( iRedData->At(0).iData ); |
|
842 |
iSatisfySecNumber += 3; |
|
843 |
} |
|
844 |
else // check levels from |
|
845 |
{ |
|
846 |
switch(iLevelsMissing) |
|
847 |
{ |
|
848 |
case(0): |
|
849 |
// expected packet errived |
|
850 |
iDecodedBuffer->Data().Append(iRedData->At(2).iData); |
|
851 |
iSatisfySecNumber ++; |
|
852 |
break; |
|
853 |
||
854 |
case(-1): // one packet missing |
|
855 |
if( aErrNo ) |
|
856 |
{ |
|
857 |
iDecodedBuffer->Data().Append(iRedData->At(2).iData); |
|
858 |
} |
|
859 |
if ( iRedData->At(1).iData.Length() != 0 ) |
|
860 |
{ |
|
861 |
iDecodedBuffer->Data().Append(iRedData->At(1).iData); |
|
862 |
} |
|
863 |
iSatisfySecNumber += 2; |
|
864 |
iDroppedPacketCount += 1; |
|
865 |
break; |
|
866 |
||
867 |
case(-2): // two packets missing |
|
868 |
if( aErrNo ) |
|
869 |
{ |
|
870 |
iDecodedBuffer->Data().Append(iRedData->At(2).iData); |
|
871 |
} |
|
872 |
if ( iRedData->At(1).iData.Length() != 0 ) |
|
873 |
{ |
|
874 |
iDecodedBuffer->Data().Append(iRedData->At(1).iData); |
|
875 |
} |
|
876 |
if ( iRedData->At(0).iData.Length() != 0 ) |
|
877 |
{ |
|
878 |
iPayloadBuffer->Data().Append(iRedData->At(0).iData); |
|
879 |
} |
|
880 |
iSatisfySecNumber += 3; |
|
881 |
iDroppedPacketCount += 2; |
|
882 |
break; |
|
883 |
||
884 |
default: |
|
885 |
//bacause if network idles or in debugging state |
|
886 |
// a lot of packets might not be received. |
|
887 |
//we are handlng all as missing chars |
|
888 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::LevelsMissing > 2!"); |
|
889 |
||
890 |
iDecodedBuffer->Data().Append(KLostChar); |
|
891 |
iSatisfySecNumber += (-iLevelsMissing ) +1; |
|
892 |
iDroppedPacketCount += (-iLevelsMissing ); |
|
893 |
||
894 |
break; |
|
895 |
} |
|
896 |
} |
|
897 |
return KErrNone; |
|
898 |
} |
|
899 |
||
900 |
||
901 |
||
902 |
// ----------------------------------------------------------------------------- |
|
903 |
// CMsrpPayloadFormatRead::ResetPacketBuffers() |
|
904 |
// Helper method that that resets all buffers used |
|
905 |
// ----------------------------------------------------------------------------- |
|
906 |
// |
|
907 |
void CMsrpPayloadFormatRead::ResetPacketBuffers() |
|
908 |
{ |
|
909 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::ResetPacketBuffers()"); |
|
910 |
iRedData->Reset(); |
|
911 |
iCharData->Des().FillZ(); |
|
912 |
iCharData->Des().Zero(); |
|
913 |
iDecodedBuffer->Data().FillZ(); |
|
914 |
iDecodedBuffer->Data().Zero(); |
|
915 |
} |
|
916 |
||
917 |
||
918 |
// NOT CALLED, BECAUSE WE ARE USING RTP ONLY |
|
919 |
void CMsrpPayloadFormatRead::BufferFilledL( CMMFBuffer* /*aBuffer*/ ) |
|
920 |
{ |
|
921 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::BufferFilledL"); |
|
922 |
User::Leave( KErrNotSupported ); |
|
923 |
} |
|
924 |
||
925 |
||
926 |
// ----------------------------------------------------------------------------- |
|
927 |
// CMsrpPayloadFormatRead::Duration |
|
928 |
// Return the clip duration for the given media. |
|
929 |
// ----------------------------------------------------------------------------- |
|
930 |
// |
|
931 |
TTimeIntervalMicroSeconds CMsrpPayloadFormatRead::Duration( |
|
932 |
TMediaId /*aMediaType*/ ) const |
|
933 |
{ |
|
934 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::Duration"); |
|
935 |
return TTimeIntervalMicroSeconds( TInt64( 0 ) ); |
|
936 |
} |
|
937 |
||
938 |
||
939 |
||
940 |
// ----------------------------------------------------------------------------- |
|
941 |
// CMsrpPayloadFormatRead::LastDlPacketCount |
|
942 |
// Return current packet count for current talk spurt |
|
943 |
// ----------------------------------------------------------------------------- |
|
944 |
// |
|
945 |
TInt CMsrpPayloadFormatRead::LastDlPacketCount( ) |
|
946 |
{ |
|
947 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::LastDlPacketCount"); |
|
948 |
return iPacketCount; |
|
949 |
} |
|
950 |
||
951 |
||
952 |
||
953 |
// ----------------------------------------------------------------------------- |
|
954 |
// CMsrpPayloadFormatRead::CancelDlRequest( ) |
|
955 |
// |
|
956 |
// ----------------------------------------------------------------------------- |
|
957 |
// |
|
958 |
void CMsrpPayloadFormatRead::CancelDlRequest() |
|
959 |
{ |
|
960 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::CancelDlRequest"); |
|
961 |
iStateMachine->Cancel(); |
|
962 |
iStateMachine->ChangeState( EDecodeIdle ); |
|
963 |
||
964 |
if ( iFrameBufferOne && iFrameBufferTwo ) |
|
965 |
{ |
|
966 |
iFrameBufferOne->SetLastBuffer( EFalse ); |
|
967 |
iFrameBufferTwo->SetLastBuffer( EFalse ); |
|
968 |
||
969 |
iFrameBufferOne->SetStatus( EAvailable ); |
|
970 |
iFrameBufferTwo->SetStatus( EAvailable ); |
|
971 |
} |
|
972 |
||
973 |
iBufferToReadExists = EFalse; |
|
974 |
iCurrentBuffer = iFrameBufferOne; |
|
975 |
iFillRequested = EFalse; |
|
976 |
||
977 |
} |
|
978 |
||
979 |
// ----------------------------------------------------------------------------- |
|
980 |
// CMsrpPayloadFormatRead::SourcePrimeL() |
|
981 |
// |
|
982 |
// ----------------------------------------------------------------------------- |
|
983 |
// |
|
984 |
void CMsrpPayloadFormatRead::SourcePrimeL() |
|
985 |
{ |
|
986 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::SourcePrimeL"); |
|
987 |
__ASSERT_ALWAYS( iClip, User::Leave( KErrArgument ) ); |
|
988 |
iClip->SourcePrimeL(); |
|
989 |
} |
|
990 |
||
991 |
||
992 |
// ----------------------------------------------------------------------------- |
|
993 |
// CMsrpPayloadFormatRead::SourcePlayL() |
|
994 |
// |
|
995 |
// ----------------------------------------------------------------------------- |
|
996 |
// |
|
997 |
void CMsrpPayloadFormatRead::SourcePlayL() |
|
998 |
{ |
|
999 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::SourcePlayL"); |
|
1000 |
__ASSERT_ALWAYS( iClip, User::Leave( KErrArgument ) ); |
|
1001 |
||
1002 |
// init packet count |
|
1003 |
iPacketCount = 0; |
|
1004 |
||
1005 |
//init satisfiable sec number count |
|
1006 |
iSatisfySecNumber = 0; |
|
1007 |
||
1008 |
iCheckSum = 0; |
|
1009 |
||
1010 |
// init levelsMissingNumber |
|
1011 |
iLevelsMissing = 0; |
|
1012 |
||
1013 |
//init flag |
|
1014 |
iPacketSecNumber = EFalse; |
|
1015 |
||
1016 |
iClip->SourcePlayL(); |
|
1017 |
||
1018 |
} |
|
1019 |
||
1020 |
// ----------------------------------------------------------------------------- |
|
1021 |
// CMsrpPayloadFormatRead::SourcePauseL() |
|
1022 |
// |
|
1023 |
// ----------------------------------------------------------------------------- |
|
1024 |
// |
|
1025 |
void CMsrpPayloadFormatRead::SourcePauseL() |
|
1026 |
{ |
|
1027 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::SourcePauseL"); |
|
1028 |
__ASSERT_ALWAYS( iClip, User::Leave( KErrArgument ) ); |
|
1029 |
||
1030 |
this->CancelDlRequest(); |
|
1031 |
iClip->SourcePauseL(); |
|
1032 |
||
1033 |
} |
|
1034 |
||
1035 |
// ----------------------------------------------------------------------------- |
|
1036 |
// CMsrpPayloadFormatRead::SourceStopL( ) |
|
1037 |
// |
|
1038 |
// ----------------------------------------------------------------------------- |
|
1039 |
// |
|
1040 |
void CMsrpPayloadFormatRead::SourceStopL() |
|
1041 |
{ |
|
1042 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::SourceStopL"); |
|
1043 |
__ASSERT_ALWAYS( iClip, User::Leave( KErrArgument ) ); |
|
1044 |
||
1045 |
this->CancelDlRequest(); |
|
1046 |
iClip->SourceStopL(); |
|
1047 |
||
1048 |
} |
|
1049 |
||
1050 |
// ----------------------------------------------------------------------------- |
|
1051 |
// CMsrpPayloadFormatRead::SinkDataTypeCode() |
|
1052 |
// Returns the datatype code for this Format Decoder |
|
1053 |
// ----------------------------------------------------------------------------- |
|
1054 |
// |
|
1055 |
TFourCC CMsrpPayloadFormatRead::SinkDataTypeCode( TMediaId aMediaId ) |
|
1056 |
{ |
|
1057 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::SinkDataTypeCode"); |
|
1058 |
//TODO: We have to check that media type text |
|
1059 |
||
1060 |
if ( KUidMediaTypeAudio == aMediaId.iMediaType ) |
|
1061 |
{ |
|
1062 |
return iFourCC; |
|
1063 |
} |
|
1064 |
else |
|
1065 |
{ |
|
1066 |
return TFourCC(); //defaults to 'NULL' fourCC |
|
1067 |
} |
|
1068 |
||
1069 |
} |
|
1070 |
||
1071 |
// ----------------------------------------------------------------------------- |
|
1072 |
// CMsrpPayloadFormatRead::ConfigurePayloadFormatL |
|
1073 |
// Configure payload decoding parameters. |
|
1074 |
// ----------------------------------------------------------------------------- |
|
1075 |
// |
|
1076 |
void CMsrpPayloadFormatRead::ConfigurePayloadFormatL( |
|
1077 |
const TDesC8& aConfigParams ) |
|
1078 |
||
1079 |
{ |
|
1080 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::ConfigurePayloadFormatL"); |
|
1081 |
TMccCodecInfoBuffer infoBuffer; |
|
1082 |
infoBuffer.Copy( aConfigParams ); |
|
1083 |
TMccCodecInfo cInfo = infoBuffer(); |
|
1084 |
||
1085 |
if ( cInfo.iIsUpdate && cInfo.iFrameSize == iCodecInfo.iFrameSize ) |
|
1086 |
{ |
|
1087 |
//__MsrpFORMAT_CONTROLL( "CMsrpPayloadFormatRead::ConfigurePayloadFormatL, nothing to configure" ) |
|
1088 |
return; |
|
1089 |
} |
|
1090 |
||
1091 |
UpdateConfigurationL( aConfigParams ); |
|
1092 |
||
1093 |
} |
|
1094 |
||
1095 |
||
1096 |
void CMsrpPayloadFormatRead::UpdateConfigurationL(const TDesC8& aConfigParams) |
|
1097 |
{ |
|
1098 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::UpdateConfigurationL"); |
|
1099 |
TMccCodecInfoBuffer infoBuffer; |
|
1100 |
infoBuffer.Copy( aConfigParams ); |
|
1101 |
TMccCodecInfo cInfo = infoBuffer(); |
|
1102 |
||
1103 |
//TODO: get me right |
|
1104 |
// iCodecInfo = cInfo; |
|
1105 |
// iCodecInfo.iRedundancyCount = 0; |
|
1106 |
iCodecInfo = cInfo; |
|
1107 |
||
1108 |
//Create buffers respectively |
|
1109 |
if ( !iFrameBufferOne ) |
|
1110 |
{ |
|
1111 |
iFrameBufferOne = |
|
1112 |
CMMFDataBuffer::NewL( KRedHeaderSize + KDataSize ); |
|
1113 |
iFrameBufferOne->SetStatus( EAvailable ); |
|
1114 |
} |
|
1115 |
||
1116 |
if ( !iFrameBufferTwo ) |
|
1117 |
{ |
|
1118 |
iFrameBufferTwo = |
|
1119 |
CMMFDataBuffer::NewL( KRedHeaderSize + KDataSize ); |
|
1120 |
iFrameBufferTwo->SetStatus( EAvailable ); |
|
1121 |
} |
|
1122 |
||
1123 |
if ( iPayloadBuffer && iSourceBufOwnership ) |
|
1124 |
{ |
|
1125 |
delete iPayloadBuffer; |
|
1126 |
iPayloadBuffer = NULL; |
|
1127 |
} |
|
1128 |
||
1129 |
iPayloadBuffer |
|
1130 |
= CreateClipBufferL( KRedHeaderSize + KDataSize, iSourceBufOwnership ); |
|
1131 |
||
1132 |
iCurrentBuffer = NULL; |
|
1133 |
||
1134 |
} |
|
1135 |
// ----------------------------------------------------------------------------- |
|
1136 |
// CMsrpPayloadFormatRead::CreateClipBufferL |
|
1137 |
// Creates buffer needed in data transfer with format readers clip. |
|
1138 |
// ----------------------------------------------------------------------------- |
|
1139 |
// |
|
1140 |
CMMFDataBuffer* CMsrpPayloadFormatRead::CreateClipBufferL( |
|
1141 |
TUint aSize, TBool& aIsOwnBuffer ) |
|
1142 |
{ |
|
1143 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::CreateClipBufferL"); |
|
1144 |
CMMFDataBuffer* buffer( NULL ); |
|
1145 |
||
1146 |
if ( iClip->CanCreateSourceBuffer() ) |
|
1147 |
{ |
|
1148 |
static_cast<CMMFFormatDecode*>( iClip )->SuggestSourceBufferSize( aSize ); |
|
1149 |
TBool reference( EFalse ); |
|
1150 |
||
1151 |
//TODO: We have to change media type |
|
1152 |
CMMFBuffer* sourceBuf |
|
1153 |
= iClip->CreateSourceBufferL( KUidMediaTypeAudio, reference ); |
|
1154 |
||
1155 |
TBool isSupportedBuf |
|
1156 |
= CMMFBuffer::IsSupportedDataBuffer( sourceBuf->Type() ); |
|
1157 |
||
1158 |
TBool isOwnBuffer = reference ? EFalse : ETrue; |
|
1159 |
||
1160 |
if ( !isSupportedBuf ) |
|
1161 |
{ |
|
1162 |
if ( isOwnBuffer ) |
|
1163 |
{ |
|
1164 |
delete sourceBuf; |
|
1165 |
} |
|
1166 |
||
1167 |
User::Leave( KErrNotSupported ); |
|
1168 |
} |
|
1169 |
||
1170 |
aIsOwnBuffer = isOwnBuffer; |
|
1171 |
buffer = static_cast<CMMFDataBuffer*>( sourceBuf ); |
|
1172 |
||
1173 |
} |
|
1174 |
else |
|
1175 |
{ |
|
1176 |
aIsOwnBuffer = ETrue; |
|
1177 |
buffer = CMMFDataBuffer::NewL( aSize ); |
|
1178 |
} |
|
1179 |
||
1180 |
||
1181 |
return buffer; |
|
1182 |
||
1183 |
} |
|
1184 |
||
1185 |
// ========================== HELPER FUNCTIONS ========================= |
|
1186 |
// ========================== ========================= |
|
1187 |
// ========================== ========================= |
|
1188 |
||
1189 |
||
1190 |
// ----------------------------------------------------------------------------- |
|
1191 |
// CMsrpPayloadFormatRead::Read32 |
|
1192 |
// Helper method that reads 32-bit unsigned integer from databuffer |
|
1193 |
// ----------------------------------------------------------------------------- |
|
1194 |
// |
|
1195 |
TUint32 CMsrpPayloadFormatRead::Read32( const TUint8* const aPointer ) |
|
1196 |
{ |
|
1197 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::Read32"); |
|
1198 |
return ( aPointer[3] + |
|
1199 |
( static_cast<TUint32>( aPointer[2] ) << 8 ) + |
|
1200 |
( static_cast<TUint32>( aPointer[1] ) << 16 ) + |
|
1201 |
( static_cast<TUint32>( aPointer[0] ) << 24 ) ); |
|
1202 |
} |
|
1203 |
||
1204 |
// ----------------------------------------------------------------------------- |
|
1205 |
// CMsrpPayloadFormatRead::Read8 |
|
1206 |
// Helper method that reads 8-bit unsigned integer from databuffer |
|
1207 |
// ----------------------------------------------------------------------------- |
|
1208 |
TUint32 CMsrpPayloadFormatRead::Read8( const TUint8 *const aPointer ) |
|
1209 |
{ |
|
1210 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::Read8"); |
|
1211 |
||
1212 |
return static_cast<TUint32> ( aPointer[0] ); |
|
1213 |
} |
|
1214 |
||
1215 |
// ----------------------------------------------------------------------------- |
|
1216 |
// CMsrpPayloadFormatRead::Read24 |
|
1217 |
// Helper method that reads 24-bit unsigned integer from databuffer |
|
1218 |
// ----------------------------------------------------------------------------- |
|
1219 |
TUint32 CMsrpPayloadFormatRead::Read24( const TUint8 *const aPointer ) |
|
1220 |
{ |
|
1221 |
DP_MSRP_WRITE("CMsrpPayloadFormatRead::Read24"); |
|
1222 |
||
1223 |
return ( aPointer[2] + ( static_cast<TUint32>( aPointer[1] ) << 8 ) + |
|
1224 |
( static_cast<TUint32>( aPointer[0] ) << 16 ) ); |
|
1225 |
} |
|
1226 |
||
1227 |
||
1228 |
// ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
1229 |
||
1230 |
// End of File |