|
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 // INCLUDE FILES |
|
22 #include <e32base.h> |
|
23 #include <mmf/common/mmffourcc.h> |
|
24 #include <mmf/server/mmfdatabuffer.h> |
|
25 #include "anypayloadformatread.h" |
|
26 #include "mccrtpdatasource.h" |
|
27 #include "mccinternaldef.h" |
|
28 #include "mccanyformatlogs.h" |
|
29 |
|
30 const TInt KNumValue4(4); |
|
31 const TInt KNumValue16(16); |
|
32 |
|
33 |
|
34 // ============================= LOCAL FUNCTIONS =============================== |
|
35 |
|
36 // ============================ MEMBER FUNCTIONS =============================== |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CAnyPayloadFormatRead::CAnyPayloadFormatRead |
|
40 // |
|
41 // CAnyPayloadFormatRead default constructor, can NOT contain any code, |
|
42 // that might leave |
|
43 // Phase #1 of 2-phase constructor |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CAnyPayloadFormatRead::CAnyPayloadFormatRead ( ) |
|
47 { |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CAnyPayloadFormatRead::ConstructL |
|
52 // Symbian 2nd phase constructor can leave. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 void CAnyPayloadFormatRead::ConstructL ( MDataSource* aSource ) |
|
56 { |
|
57 __ANYFORMAT_CONTROLL( "CAnyPayloadFormatRead::ConstructL" ) |
|
58 __ASSERT_ALWAYS( aSource, User::Leave( KErrArgument ) ); |
|
59 |
|
60 iRtpDataSource = aSource; |
|
61 iClip = aSource; |
|
62 iFillRequested = EFalse; |
|
63 iBufferToReadExists = EFalse; |
|
64 |
|
65 // Initialize decoding state machine |
|
66 iStateMachine = CFormatDecodeStateMachine::NewL( this ); |
|
67 iStateMachine->ChangeState( EDecodeIdle ); |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CAnyPayloadFormatRead::NewL |
|
72 // |
|
73 // Two-phased constructor. |
|
74 // Static function for creating and constructing an instance of |
|
75 // the AMR-NB format. |
|
76 // |
|
77 // Returns: CAnyPayloadFormatRead* : pointer to created instance |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 CAnyPayloadFormatRead* CAnyPayloadFormatRead::NewL( |
|
81 MDataSource* aSource ) |
|
82 { |
|
83 __ASSERT_ALWAYS( aSource, User::Leave( KErrArgument ) ); |
|
84 |
|
85 __ASSERT_ALWAYS( ( KMccRtpSourceUid == aSource->DataSourceType() || |
|
86 KMccVideoSourceUid == aSource->DataSourceType() || |
|
87 KMccMultiplexerUid == aSource->DataSourceType() ), |
|
88 User::Leave( KErrArgument ) ); |
|
89 CAnyPayloadFormatRead* self = |
|
90 new ( ELeave ) CAnyPayloadFormatRead; |
|
91 CleanupStack::PushL ( self ); |
|
92 self->ConstructL ( aSource ); |
|
93 CleanupStack::Pop( self ); |
|
94 return self; |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CAnyPayloadFormatRead::~CAnyPayloadFormatRead |
|
99 // |
|
100 // Destructor. |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 CAnyPayloadFormatRead::~CAnyPayloadFormatRead( ) |
|
104 { |
|
105 delete iFrameBufferOne; |
|
106 delete iFrameBufferTwo; |
|
107 if ( iSourceBufOwnership ) |
|
108 { |
|
109 delete iPayloadBuffer; |
|
110 } |
|
111 else |
|
112 { |
|
113 iPayloadBuffer = NULL; |
|
114 } |
|
115 |
|
116 if ( iStateMachine ) |
|
117 { |
|
118 iStateMachine->Cancel( ); |
|
119 delete iStateMachine; |
|
120 } |
|
121 iCurrentBuffer = NULL; |
|
122 iRtpDataSource = NULL; |
|
123 iClip = NULL; |
|
124 iDataPath = NULL; |
|
125 iEventHandler = NULL; |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CAnyPayloadFormatRead::Streams |
|
130 // Return number of audio streams for the given media |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 TUint CAnyPayloadFormatRead::Streams( TUid /*aMediaType*/ ) const |
|
134 { |
|
135 return 1; |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CAnyPayloadFormatRead::FrameTimeInterval |
|
140 // Return the frame time interval for the given media |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 TTimeIntervalMicroSeconds CAnyPayloadFormatRead::FrameTimeInterval( |
|
144 TMediaId /*aMediaId*/ ) const |
|
145 { |
|
146 return TTimeIntervalMicroSeconds( TInt64( 0 ) ); |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CAnyPayloadFormatRead::FillBufferL |
|
151 // Fill Buffer |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 void CAnyPayloadFormatRead::FillBufferL( CMMFBuffer* aBuffer, |
|
155 MDataSink* aConsumer, |
|
156 TMediaId aMediaId ) |
|
157 { |
|
158 __ANYFORMAT_MEDIA( "CAnyPayloadFormatRead::FillBufferL" ) |
|
159 |
|
160 __ASSERT_ALWAYS( aBuffer, User::Leave( KErrArgument ) ); |
|
161 __ASSERT_ALWAYS( aBuffer->Type() == KUidMmfDataBuffer, User::Leave( KErrArgument ) ); |
|
162 __ASSERT_ALWAYS( aBuffer == iCurrentBuffer, User::Leave( KErrArgument ) ); |
|
163 __ASSERT_ALWAYS( aConsumer, User::Leave( KErrArgument ) ); |
|
164 __ASSERT_ALWAYS( iStateMachine, User::Leave( KErrArgument ) ); |
|
165 __ASSERT_ALWAYS( iFrameBufferOne, User::Leave( KErrArgument ) ); |
|
166 __ASSERT_ALWAYS( iFrameBufferTwo, User::Leave( KErrArgument ) ); |
|
167 |
|
168 iDataPath = aConsumer; |
|
169 iMediaId = aMediaId; |
|
170 iFillRequested = ETrue; |
|
171 |
|
172 if ( iCurrentBuffer ) |
|
173 { |
|
174 iCurrentBuffer->SetStatus( EAvailable ); |
|
175 iCurrentBuffer = NULL; |
|
176 } |
|
177 |
|
178 if (iFrameBufferOne->Status() == EFull ) |
|
179 { |
|
180 iCurrentBuffer = iFrameBufferOne; |
|
181 iStateMachine->ChangeState( ESourceDataReady ); |
|
182 } |
|
183 else if (iFrameBufferTwo->Status() == EFull ) |
|
184 { |
|
185 iCurrentBuffer = iFrameBufferTwo; |
|
186 iStateMachine->ChangeState( ESourceDataReady ); |
|
187 } |
|
188 else |
|
189 { |
|
190 FillSourceBufferL(); |
|
191 } |
|
192 }; |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CAnyPayloadFormatRead::FillSinkBuffer |
|
196 // Read RTP payload and convert it into AMR frames. |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 void CAnyPayloadFormatRead::FillSinkBufferL( ) |
|
200 { |
|
201 __ANYFORMAT_MEDIA( "CAnyPayloadFormatRead::FillSinkBuffer" ) |
|
202 __ASSERT_ALWAYS( iStateMachine, User::Leave( KErrArgument ) ); |
|
203 __ASSERT_ALWAYS( iCurrentBuffer, User::Leave( KErrArgument ) ); |
|
204 |
|
205 iStateMachine->ChangeState( EEmptyDataToSink ); |
|
206 } |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // CAnyPayloadFormatRead::FillSourceBufferL |
|
210 // Send fill buffer request to RTP Data Soure |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 void CAnyPayloadFormatRead::FillSourceBufferL( ) |
|
214 { |
|
215 __ASSERT_ALWAYS( iClip, User::Leave( KErrArgument ) ); |
|
216 __ASSERT_ALWAYS( iPayloadBuffer, User::Leave( KErrArgument ) ); |
|
217 |
|
218 iClip->FillBufferL(iPayloadBuffer, this, iMediaId ); |
|
219 } |
|
220 |
|
221 // ----------------------------------------------------------------------------- |
|
222 // CAnyPayloadFormatRead::SendDataToSinkL |
|
223 // Send full frame buffer to Data Path |
|
224 // ----------------------------------------------------------------------------- |
|
225 // |
|
226 void CAnyPayloadFormatRead::SendDataToSinkL( ) |
|
227 { |
|
228 __ANYFORMAT_MEDIA( "CAnyPayloadFormatRead::SendDataToSinkL" ) |
|
229 __ASSERT_ALWAYS( iDataPath, User::Leave( KErrArgument ) ); |
|
230 __ASSERT_ALWAYS( iCurrentBuffer, User::Leave( KErrArgument ) ); |
|
231 |
|
232 iDataPath->BufferFilledL( iCurrentBuffer ); |
|
233 } |
|
234 |
|
235 // ----------------------------------------------------------------------------- |
|
236 // CAnyPayloadFormatRead::CreateSourceBufferL |
|
237 // Create a source buffer for the given media and indicate in aReference if |
|
238 // buffer is created. |
|
239 // ----------------------------------------------------------------------------- |
|
240 // |
|
241 CMMFBuffer* CAnyPayloadFormatRead::CreateSourceBufferL( |
|
242 TMediaId /*aMediaId*/, |
|
243 TBool &aReference ) |
|
244 { |
|
245 __ANYFORMAT_MEDIA( "CAnyPayloadFormatRead::CreateSourceBufferL" ) |
|
246 // the source buffers belong to AmrPayloadFormatRead not to datapath |
|
247 // aference should be set to ETrue and destried by AmrPayloadFormatRead |
|
248 // itself. |
|
249 aReference = ETrue; |
|
250 iCurrentBuffer = iFrameBufferOne; |
|
251 return iFrameBufferOne; |
|
252 } |
|
253 |
|
254 // ----------------------------------------------------------------------------- |
|
255 // CAnyPayloadFormatRead::CreateSourceBufferL |
|
256 // Create a source buffer for the given media, setting frame size to match |
|
257 // the given sink buffer |
|
258 // ----------------------------------------------------------------------------- |
|
259 // |
|
260 CMMFBuffer* CAnyPayloadFormatRead::CreateSourceBufferL( |
|
261 TMediaId aMediaId, |
|
262 CMMFBuffer& /*aSinkBuffer*/, |
|
263 TBool &aReference ) |
|
264 { |
|
265 __ANYFORMAT_MEDIA( "CAnyPayloadFormatRead::CreateSourceBufferL" ) |
|
266 return CreateSourceBufferL( aMediaId, aReference ); |
|
267 } |
|
268 |
|
269 // ----------------------------------------------------------------------------- |
|
270 // CAnyPayloadFormatRead::SourceDataTypeCode |
|
271 // Return the source data type ( four CC code ) for the given media |
|
272 // ----------------------------------------------------------------------------- |
|
273 // |
|
274 TFourCC CAnyPayloadFormatRead::SourceDataTypeCode( |
|
275 TMediaId /*aMediaId*/ ) |
|
276 { |
|
277 return iFourCC; |
|
278 } |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // CAnyPayloadFormatRead::SetSourceDataTypeCode |
|
282 // Set the source data type to the given four CC code for the given |
|
283 // media |
|
284 // ----------------------------------------------------------------------------- |
|
285 // |
|
286 TInt CAnyPayloadFormatRead::SetSourceDataTypeCode( TFourCC aSourceFourCC, |
|
287 TMediaId aMediaId ) |
|
288 { |
|
289 __ANYFORMAT_CONTROLL( "CAnyPayloadFormatRead::SetSourceDataTypeCode" ) |
|
290 |
|
291 if( iClip ) |
|
292 { |
|
293 iFourCC = aSourceFourCC; |
|
294 iMediaId = aMediaId; |
|
295 |
|
296 iClip->SetSourceDataTypeCode( iFourCC, iMediaId ); |
|
297 |
|
298 return KErrNone; |
|
299 } |
|
300 else |
|
301 { |
|
302 return KErrArgument; |
|
303 } |
|
304 |
|
305 } |
|
306 |
|
307 // ----------------------------------------------------------------------------- |
|
308 // CAnyPayloadFormatRead::SourceThreadLogon |
|
309 // Log in to the source thread |
|
310 // ----------------------------------------------------------------------------- |
|
311 // |
|
312 TInt CAnyPayloadFormatRead::SourceThreadLogon( |
|
313 MAsyncEventHandler& aEventHandler ) |
|
314 { |
|
315 __ANYFORMAT_CONTROLL( "CAnyPayloadFormatRead::SourceThreadLogon" ) |
|
316 if ( iClip ) |
|
317 { |
|
318 iEventHandler = &aEventHandler; |
|
319 iClip->SourceThreadLogon( aEventHandler ); |
|
320 return KErrNone; |
|
321 } |
|
322 else |
|
323 { |
|
324 return KErrArgument; |
|
325 } |
|
326 } |
|
327 |
|
328 // ----------------------------------------------------------------------------- |
|
329 // CAnyPayloadFormatRead::NegotiateSourceL( MDataSink& aDataSink ) |
|
330 // Negotiate source settings to match data sink object. |
|
331 // Re-size frame buffers if needed |
|
332 // ----------------------------------------------------------------------------- |
|
333 // |
|
334 void CAnyPayloadFormatRead::NegotiateSourceL( MDataSink& /*aDataSink*/ ) |
|
335 { |
|
336 __ANYFORMAT_CONTROLL( "CAnyPayloadFormatRead::NegotiateSourceL" ) |
|
337 __ASSERT_ALWAYS( iClip, User::Leave( KErrArgument ) ); |
|
338 iClip->NegotiateSourceL( *this ); |
|
339 } |
|
340 |
|
341 // ----------------------------------------------------------------------------- |
|
342 // CAnyPayloadFormatRead::SourceThreadLogoff |
|
343 // Log out of the source thread. |
|
344 // ----------------------------------------------------------------------------- |
|
345 // |
|
346 void CAnyPayloadFormatRead::SourceThreadLogoff( ) |
|
347 { |
|
348 __ANYFORMAT_CONTROLL( "CAnyPayloadFormatRead::SourceThreadLogoff" ) |
|
349 if ( iClip ) |
|
350 { |
|
351 iClip->SourceThreadLogoff( ); |
|
352 } |
|
353 } |
|
354 |
|
355 // ----------------------------------------------------------------------------- |
|
356 // CAnyPayloadFormatRead::DataBufferFilledL |
|
357 // ----------------------------------------------------------------------------- |
|
358 // |
|
359 void CAnyPayloadFormatRead::DataBufferFilledL( CMMFBuffer* aBuffer, |
|
360 const TRtpRecvHeader& aRtpHeader ) |
|
361 { |
|
362 __ANYFORMAT_MEDIA( "CAnyPayloadFormatRead::DataBufferFilledL" ) |
|
363 __ANYFORMAT_MEDIA_INT1( "CAnyPayloadFormatRead::DataBufferFilledL iPadding:", aRtpHeader.iPadding ) |
|
364 __ANYFORMAT_MEDIA_INT1( "CAnyPayloadFormatRead::DataBufferFilledL iExtension:", aRtpHeader.iExtension ) |
|
365 __ANYFORMAT_MEDIA_INT1( "CAnyPayloadFormatRead::DataBufferFilledL iCsrcCount:", aRtpHeader.iCsrcCount ) |
|
366 __ANYFORMAT_MEDIA_INT1( "CAnyPayloadFormatRead::DataBufferFilledL iMarker:", aRtpHeader.iMarker ) |
|
367 __ANYFORMAT_MEDIA_INT1( "CAnyPayloadFormatRead::DataBufferFilledL iPayloadType:", aRtpHeader.iPayloadType ) |
|
368 __ANYFORMAT_MEDIA_INT1( "CAnyPayloadFormatRead::DataBufferFilledL iSeqNum:", aRtpHeader.iSeqNum ) |
|
369 __ANYFORMAT_MEDIA_INT1( "CAnyPayloadFormatRead::DataBufferFilledL iTimestamp:", aRtpHeader.iTimestamp ); |
|
370 __ANYFORMAT_MEDIA_INT1( "CAnyPayloadFormatRead::DataBufferFilledL iHeaderExtension:", (TInt)aRtpHeader.iHeaderExtension ) |
|
371 __ANYFORMAT_MEDIA_INT1( "CAnyPayloadFormatRead::DataBufferFilledL iCsrcList:", (TInt)aRtpHeader.iCsrcList ) |
|
372 |
|
373 __ASSERT_ALWAYS( aBuffer, User::Leave( KErrArgument ) ); |
|
374 |
|
375 aBuffer->SetTimeToPlay( aRtpHeader.iTimestamp ); |
|
376 aBuffer->SetLastBuffer( aRtpHeader.iMarker ); |
|
377 aBuffer->SetFrameNumber( aRtpHeader.iSeqNum ); |
|
378 |
|
379 BufferFilledL( aBuffer ); |
|
380 } |
|
381 |
|
382 // ----------------------------------------------------------------------------- |
|
383 // CAnyPayloadFormatRead::BufferFilledL |
|
384 // Called after the data buffer is filled. Update the number of bytes read |
|
385 // and the current read position for the next read operation. |
|
386 // ----------------------------------------------------------------------------- |
|
387 // |
|
388 void CAnyPayloadFormatRead::BufferFilledL( CMMFBuffer* aBuffer ) |
|
389 { |
|
390 __ANYFORMAT_MEDIA( "CAnyPayloadFormatRead::BufferFilledL2" ) |
|
391 __ASSERT_ALWAYS( aBuffer, User::Leave( KErrArgument ) ); |
|
392 __ASSERT_ALWAYS( aBuffer->Type() == KUidMmfDataBuffer, User::Leave( KErrArgument ) ); |
|
393 __ASSERT_ALWAYS( iPayloadBuffer == aBuffer , User::Leave( KErrArgument ) ); |
|
394 __ASSERT_ALWAYS( iClip, User::Leave( KErrArgument ) ); |
|
395 __ASSERT_ALWAYS( iStateMachine, User::Leave( KErrArgument ) ); |
|
396 __ASSERT_ALWAYS( iFrameBufferOne , User::Leave( KErrArgument ) ); |
|
397 __ASSERT_ALWAYS( iFrameBufferTwo , User::Leave( KErrArgument ) ); |
|
398 |
|
399 iPacketCount++; |
|
400 |
|
401 CMMFDataBuffer* dataBuffer = static_cast<CMMFDataBuffer*>( aBuffer ); |
|
402 |
|
403 if ( dataBuffer->Data().Length() == 0 ) |
|
404 { |
|
405 __ANYFORMAT_MEDIA( "CAnyPayloadFormatRead::BufferFilledL2, zero length payload" ) |
|
406 |
|
407 // Drop buffer and ask for more |
|
408 FillSourceBufferL(); |
|
409 } |
|
410 else if ( iFrameBufferOne->Status() == EAvailable ) |
|
411 { |
|
412 iFrameBufferOne->Data().Copy( dataBuffer->Data() ); |
|
413 iFrameBufferOne->SetTimeToPlay( aBuffer->TimeToPlay() ); |
|
414 iFrameBufferOne->SetLastBuffer( aBuffer->LastBuffer() ); |
|
415 iFrameBufferOne->SetFrameNumber( aBuffer->FrameNumber() ); |
|
416 |
|
417 iFrameBufferOne->SetStatus( EFull ); |
|
418 |
|
419 if (iFrameBufferTwo->Status() == EAvailable ) |
|
420 { |
|
421 iCurrentBuffer = iFrameBufferOne; |
|
422 iStateMachine->ChangeState( ESourceDataReady ); |
|
423 } |
|
424 } |
|
425 else if ( iFrameBufferTwo->Status() == EAvailable ) |
|
426 { |
|
427 iFrameBufferTwo->Data().Copy( dataBuffer->Data() ); |
|
428 iFrameBufferTwo->SetTimeToPlay( aBuffer->TimeToPlay() ); |
|
429 iFrameBufferTwo->SetLastBuffer( aBuffer->LastBuffer() ); |
|
430 iFrameBufferTwo->SetFrameNumber( aBuffer->FrameNumber() ); |
|
431 iFrameBufferTwo->SetStatus( EFull ); |
|
432 |
|
433 if (iFrameBufferOne->Status() == EAvailable ) |
|
434 { |
|
435 iCurrentBuffer = iFrameBufferTwo; |
|
436 iStateMachine->ChangeState( ESourceDataReady ); |
|
437 } |
|
438 } |
|
439 else |
|
440 { |
|
441 // Neither of the buffers is available |
|
442 User::Leave( KErrNotReady ); |
|
443 } |
|
444 } |
|
445 |
|
446 // ----------------------------------------------------------------------------- |
|
447 // CAnyPayloadFormatRead::Duration |
|
448 // Return the clip duration for the given media. |
|
449 // ----------------------------------------------------------------------------- |
|
450 // |
|
451 TTimeIntervalMicroSeconds CAnyPayloadFormatRead::Duration( |
|
452 TMediaId /*aMediaType*/ ) const |
|
453 { |
|
454 return TTimeIntervalMicroSeconds( TInt64( 0 ) ); |
|
455 } |
|
456 |
|
457 // ----------------------------------------------------------------------------- |
|
458 // CAnyPayloadFormatRead::LastDlPacketCount |
|
459 // Return current packet count for current talk spurt |
|
460 // ----------------------------------------------------------------------------- |
|
461 // |
|
462 TInt CAnyPayloadFormatRead::LastDlPacketCount( ) |
|
463 { |
|
464 return iPacketCount; |
|
465 } |
|
466 |
|
467 // ----------------------------------------------------------------------------- |
|
468 // CAnyPayloadFormatRead::CancelDlRequest( ) |
|
469 // |
|
470 // ----------------------------------------------------------------------------- |
|
471 // |
|
472 void CAnyPayloadFormatRead::CancelDlRequest() |
|
473 { |
|
474 __ANYFORMAT_CONTROLL( "CAnyPayloadFormatRead::CancelDlRequest" ) |
|
475 |
|
476 if( iStateMachine && iFrameBufferOne && iFrameBufferTwo ) |
|
477 { |
|
478 iStateMachine->Cancel(); |
|
479 iStateMachine->ChangeState( EDecodeIdle ); |
|
480 |
|
481 iFrameBufferOne->SetLastBuffer( EFalse ); |
|
482 iFrameBufferTwo->SetLastBuffer( EFalse ); |
|
483 |
|
484 iFrameBufferOne->SetStatus( EAvailable ); |
|
485 iFrameBufferTwo->SetStatus( EAvailable ); |
|
486 |
|
487 iBufferToReadExists = EFalse; |
|
488 iFillRequested = EFalse; |
|
489 } |
|
490 |
|
491 } |
|
492 |
|
493 // ----------------------------------------------------------------------------- |
|
494 // CAnyPayloadFormatRead::SourcePrimeL() |
|
495 // |
|
496 // ----------------------------------------------------------------------------- |
|
497 // |
|
498 void CAnyPayloadFormatRead::SourcePrimeL() |
|
499 { |
|
500 __ANYFORMAT_CONTROLL( "CAnyPayloadFormatRead::SourcePrimeL" ) |
|
501 __ASSERT_ALWAYS( iClip, User::Leave( KErrArgument ) ); |
|
502 iClip->SourcePrimeL(); |
|
503 } |
|
504 |
|
505 // ----------------------------------------------------------------------------- |
|
506 // CAnyPayloadFormatRead::SourcePlayL() |
|
507 // |
|
508 // ----------------------------------------------------------------------------- |
|
509 // |
|
510 void CAnyPayloadFormatRead::SourcePlayL() |
|
511 { |
|
512 __ANYFORMAT_CONTROLL( "CAnyPayloadFormatRead::SourcePlayL" ) |
|
513 __ASSERT_ALWAYS( iClip, User::Leave( KErrArgument ) ); |
|
514 |
|
515 iPacketCount = 0; |
|
516 iClip->SourcePlayL(); |
|
517 }; |
|
518 |
|
519 // ----------------------------------------------------------------------------- |
|
520 // CAnyPayloadFormatRead::SourcePauseL() |
|
521 // |
|
522 // ----------------------------------------------------------------------------- |
|
523 // |
|
524 void CAnyPayloadFormatRead::SourcePauseL() |
|
525 { |
|
526 __ANYFORMAT_CONTROLL( "CAnyPayloadFormatRead::SourcePauseL" ) |
|
527 __ASSERT_ALWAYS( iClip, User::Leave( KErrArgument ) ); |
|
528 this->CancelDlRequest(); |
|
529 iClip->SourcePauseL(); |
|
530 } |
|
531 |
|
532 // ----------------------------------------------------------------------------- |
|
533 // CAnyPayloadFormatRead::SourceStopL( ) |
|
534 // |
|
535 // ----------------------------------------------------------------------------- |
|
536 // |
|
537 void CAnyPayloadFormatRead::SourceStopL() |
|
538 { |
|
539 __ANYFORMAT_CONTROLL( "CAnyPayloadFormatRead::SourceStopL" ) |
|
540 __ASSERT_ALWAYS( iClip, User::Leave( KErrArgument ) ); |
|
541 this->CancelDlRequest(); |
|
542 iClip->SourceStopL(); |
|
543 } |
|
544 |
|
545 // ----------------------------------------------------------------------------- |
|
546 // CAnyPayloadFormatRead::SinkDataTypeCode() |
|
547 // Returns the datatype code for this Format Decoder |
|
548 // ----------------------------------------------------------------------------- |
|
549 // |
|
550 TFourCC CAnyPayloadFormatRead::SinkDataTypeCode( TMediaId /*aMediaId*/ ) |
|
551 { |
|
552 return iFourCC; |
|
553 } |
|
554 |
|
555 // ----------------------------------------------------------------------------- |
|
556 // CAnyPayloadFormatRead::ConfigurePayloadFormatL |
|
557 // Configure payload decoding parameters. |
|
558 // ----------------------------------------------------------------------------- |
|
559 // |
|
560 void CAnyPayloadFormatRead::ConfigurePayloadFormatL( |
|
561 const TDesC8& aConfigParams ) |
|
562 { |
|
563 __ANYFORMAT_CONTROLL( "CAnyPayloadFormatRead::ConfigurePayloadFormatL" ) |
|
564 |
|
565 TMccCodecInfoBuffer infoBuffer; |
|
566 infoBuffer.Copy( aConfigParams ); |
|
567 TMccCodecInfo cInfo = infoBuffer(); |
|
568 |
|
569 if ( cInfo.iIsUpdate && cInfo.iFrameSize == iCInfo.iFrameSize ) |
|
570 { |
|
571 __ANYFORMAT_CONTROLL( "CAnyPayloadFormatRead::ConfigurePayloadFormatL, nothing to configure" ) |
|
572 return; |
|
573 } |
|
574 |
|
575 TUint framesize; |
|
576 if ( iMediaId.iMediaType == KUidMediaTypeVideo ) // for video |
|
577 { |
|
578 __ANYFORMAT_CONTROLL( "CAnyPayloadFormatRead::ConfigurePayloadFormatL, \ |
|
579 iMediaId.iMediaType == KUidMediaTypeVideo" ) |
|
580 |
|
581 framesize = cInfo.iFrameSize * KNumValue4; |
|
582 } |
|
583 else // for audio |
|
584 { |
|
585 if ( !cInfo.iMaxPtime ) |
|
586 { |
|
587 framesize = cInfo.iFrameSize * KNumValue16; |
|
588 } |
|
589 else |
|
590 { |
|
591 if( !cInfo.iHwFrameTime ) |
|
592 { |
|
593 User::Leave( KErrArgument ); |
|
594 } |
|
595 TUint framesPerPackets = cInfo.iMaxPtime / cInfo.iHwFrameTime; |
|
596 framesize = cInfo.iFrameSize * framesPerPackets; |
|
597 } |
|
598 } |
|
599 |
|
600 __ANYFORMAT_CONTROLL_INT1( "CAnyPayloadFormatRead, buffer size", framesize ) |
|
601 if ( !iFrameBufferOne ) |
|
602 { |
|
603 iFrameBufferOne = |
|
604 CMMFDataBuffer::NewL( framesize ); |
|
605 iFrameBufferOne->SetStatus( EAvailable ); |
|
606 } |
|
607 |
|
608 if ( !iFrameBufferTwo ) |
|
609 { |
|
610 iFrameBufferTwo = |
|
611 CMMFDataBuffer::NewL( framesize ); |
|
612 iFrameBufferTwo->SetStatus( EAvailable ); |
|
613 } |
|
614 |
|
615 if ( iPayloadBuffer && iSourceBufOwnership ) |
|
616 { |
|
617 delete iPayloadBuffer; |
|
618 iPayloadBuffer = NULL; |
|
619 } |
|
620 |
|
621 iPayloadBuffer |
|
622 = CreateClipBufferL( framesize, iSourceBufOwnership ); |
|
623 |
|
624 iCurrentBuffer = NULL; |
|
625 |
|
626 iCInfo = cInfo; |
|
627 } |
|
628 |
|
629 // ----------------------------------------------------------------------------- |
|
630 // CAnyPayloadFormatRead::CreateClipBufferL |
|
631 // Creates buffer needed in data transfer with format readers clip. |
|
632 // ----------------------------------------------------------------------------- |
|
633 // |
|
634 CMMFDataBuffer* CAnyPayloadFormatRead::CreateClipBufferL( |
|
635 TUint aSize, TBool& aIsOwnBuffer ) |
|
636 { |
|
637 __ANYFORMAT_CONTROLL( "CAnyPayloadFormatRead::CreateClipBufferL" ); |
|
638 |
|
639 CMMFDataBuffer* buffer( NULL ); |
|
640 |
|
641 if ( iClip->CanCreateSourceBuffer() ) |
|
642 { |
|
643 static_cast<CMMFFormatDecode*>( iClip )->SuggestSourceBufferSize( aSize ); |
|
644 |
|
645 TBool reference( EFalse ); |
|
646 CMMFBuffer* sourceBuf |
|
647 = iClip->CreateSourceBufferL( KUidMediaTypeAudio, reference ); |
|
648 TBool isSupportedBuf |
|
649 = CMMFBuffer::IsSupportedDataBuffer( sourceBuf->Type() ); |
|
650 TBool isOwnBuffer = reference ? EFalse : ETrue; |
|
651 |
|
652 if ( !isSupportedBuf ) |
|
653 { |
|
654 if ( isOwnBuffer ) |
|
655 { |
|
656 delete sourceBuf; |
|
657 } |
|
658 |
|
659 User::Leave( KErrNotSupported ); |
|
660 } |
|
661 |
|
662 aIsOwnBuffer = isOwnBuffer; |
|
663 buffer = static_cast<CMMFDataBuffer*>( sourceBuf ); |
|
664 } |
|
665 else |
|
666 { |
|
667 aIsOwnBuffer = ETrue; |
|
668 buffer = CMMFDataBuffer::NewL( aSize ); |
|
669 } |
|
670 |
|
671 return buffer; |
|
672 } |
|
673 |
|
674 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
675 |
|
676 // End of File |