|
1 /* |
|
2 * Copyright (c) 2004-2008 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: Provides a baseclass for symmetric subthread streams |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef MCCSYMSTREAMBASE_H |
|
21 #define MCCSYMSTREAMBASE_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 |
|
26 #include "mccinternalcodecs.h" |
|
27 #include "mmccevents.h" |
|
28 |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class TMMFPrioritySettings; |
|
32 class CMccDataPathBase; |
|
33 class MDataSink; |
|
34 class MDataSource; |
|
35 class CMccRtpManager; |
|
36 class CMMFDevSound; |
|
37 class MMccResources; |
|
38 class CMccMultiplexer; |
|
39 class CMccRtpMediaClock; |
|
40 class TMccCryptoContext; |
|
41 |
|
42 // CLASS DECLARATION |
|
43 |
|
44 /** |
|
45 * Mcc Symmetric subthread stream baseclass |
|
46 * |
|
47 * @lib Mccsubthreads.lib |
|
48 * @since Series 60 3.0 |
|
49 */ |
|
50 NONSHARABLE_CLASS( CMccSymStreamBase ) : public CBase, |
|
51 public MAsyncEventHandler |
|
52 { |
|
53 public: // Enumerations |
|
54 |
|
55 enum TStreamState |
|
56 { |
|
57 EStateNone = 0, |
|
58 EStatePrepared = 1, |
|
59 EStateStreaming = 2, |
|
60 EStatePaused = 3, |
|
61 EStateStopped = 4 |
|
62 }; |
|
63 |
|
64 enum TCodecState |
|
65 { |
|
66 EStateCodecNone = 0, |
|
67 EStateCodecNegotiated = 1, |
|
68 EStateCodecPrepared = 2, |
|
69 EStateCodecLoaded = 3, |
|
70 EStateCodecLoadedAndUpdating = 4 |
|
71 }; |
|
72 |
|
73 public: // Constructors and destructor |
|
74 |
|
75 /** |
|
76 * Destructor. |
|
77 */ |
|
78 virtual ~CMccSymStreamBase(); |
|
79 |
|
80 public: // Functions from MAsyncEventHandler |
|
81 |
|
82 TInt SendEventToClient( const TMMFEvent& aEvent ); |
|
83 |
|
84 public: // New functions |
|
85 |
|
86 /** |
|
87 * Returns the streams identifier |
|
88 * @since Series 60 3.0 |
|
89 * @param None |
|
90 * @return TInt stream identifier |
|
91 */ |
|
92 inline TUint32 MccStreamId() |
|
93 { |
|
94 return iMccStreamId; |
|
95 }; |
|
96 |
|
97 /** |
|
98 * Sets the priority settings for this stream |
|
99 * @since Series 60 3.0 |
|
100 * @param aPriority MMF Priority settings |
|
101 * @return void |
|
102 */ |
|
103 virtual void SetPrioritySettingsL( |
|
104 const TMMFPrioritySettings& aPriority ) = 0; |
|
105 |
|
106 /** |
|
107 * Adds the sink and source to the stream |
|
108 * @since Series 60 3.0 |
|
109 * @param aDatasink MDataSink |
|
110 * @param aDatasource MDataSource |
|
111 * @return void |
|
112 */ |
|
113 virtual void AddSinkAndSourceL( MDataSink* aDatasink, |
|
114 MDataSource* aDatasource ) = 0; |
|
115 |
|
116 /** |
|
117 * Loads a codec in the stream |
|
118 * @since Series 60 3.0 |
|
119 * @param aCodecInfo TMccCodecInfo |
|
120 * @return void |
|
121 */ |
|
122 virtual void LoadCodecL( const TMccCodecInfo& aCodecInfo, |
|
123 const TDesC8& aFmtp ) = 0; |
|
124 |
|
125 /** |
|
126 * Primes the audio stream ready |
|
127 * @since Series 60 3.0 |
|
128 * @param None |
|
129 * @return void |
|
130 */ |
|
131 virtual void PrimeL( const TUint32 aEndpointId ) = 0; |
|
132 |
|
133 /** |
|
134 * Starts the audio streaming |
|
135 * @since Series 60 3.0 |
|
136 * @param None |
|
137 * @return void |
|
138 */ |
|
139 virtual void PlayL( const TUint32 aEndpointId, |
|
140 TBool aStreamPaused, |
|
141 TBool aEnableRtcp ) = 0; |
|
142 |
|
143 /** |
|
144 * Pauses the audio streaming |
|
145 * @since Series 60 3.0 |
|
146 * @param None |
|
147 * @return void |
|
148 */ |
|
149 virtual void PauseL( const TUint32 aEndpointId, |
|
150 TBool aEnableRtcp ) = 0; |
|
151 |
|
152 /** |
|
153 * Resumes the audio streaming |
|
154 * @since Series 60 3.0 |
|
155 * @param None |
|
156 * @return void |
|
157 */ |
|
158 virtual void ResumeL( const TUint32 aEndpointId, |
|
159 TBool aEnableRtcp ) = 0; |
|
160 |
|
161 /** |
|
162 * Stops the audio streaming |
|
163 * @since Series 60 3.0 |
|
164 * @param None |
|
165 * @return void |
|
166 */ |
|
167 virtual void StopL( const TUint32 aEndpointId ) = 0; |
|
168 |
|
169 /** |
|
170 * Sets the current record gain |
|
171 * @since Series 60 3.0 |
|
172 * @param aGain New gain |
|
173 * @return void |
|
174 */ |
|
175 void SetGainL( TInt aGain ); |
|
176 |
|
177 /** |
|
178 * Sets the current playback volume |
|
179 * @since Series 60 3.0 |
|
180 * @param aVolume New volume |
|
181 * @return void |
|
182 */ |
|
183 void SetVolumeL( TInt aVolume ); |
|
184 |
|
185 /** |
|
186 * Returns the maximum volume |
|
187 * @since Series 60 3.0 |
|
188 * @param None |
|
189 * @return TInt |
|
190 */ |
|
191 TInt MaxVolumeL(); |
|
192 |
|
193 /** |
|
194 * Returns the maximum gain |
|
195 * @since Series 60 3.0 |
|
196 * @param None |
|
197 * @return TInt |
|
198 */ |
|
199 TInt MaxGainL(); |
|
200 |
|
201 /** |
|
202 * Returns the current volume |
|
203 * @since Series 60 3.0 |
|
204 * @param None |
|
205 * @return TInt |
|
206 */ |
|
207 TInt VolumeL(); |
|
208 |
|
209 /** |
|
210 * Returns the current gain |
|
211 * @since Series 60 3.0 |
|
212 * @param None |
|
213 * @return TInt |
|
214 */ |
|
215 TInt GainL(); |
|
216 |
|
217 /** |
|
218 * Resets Jitterbuffer |
|
219 * @since Series 60 3.0 |
|
220 * @param None |
|
221 * @return void |
|
222 */ |
|
223 virtual void ResetCountersL() = 0; |
|
224 |
|
225 /** |
|
226 * Sets the current record/play balance depending on the stream type |
|
227 * @since Series 60 3.0 |
|
228 * @param aLeftbal Left balance |
|
229 * @param aRightbal Right balance |
|
230 * @return void |
|
231 */ |
|
232 virtual void SetBalanceL( TInt aLeftbal, TInt aRightbal ) = 0; |
|
233 |
|
234 /** |
|
235 * Reuturns the current record/play balance depending on the stream type |
|
236 * @since Series 60 3.0 |
|
237 * @param aLeftbal Left balance |
|
238 * @param aRightbal Right balance |
|
239 * @return void |
|
240 */ |
|
241 virtual void GetBalanceL( TInt& aLeftbal, TInt& aRightbal ) = 0; |
|
242 |
|
243 /** |
|
244 * Sends a media event in a uplink stream. Default implementation will |
|
245 * leave with error code KErrNotSupported |
|
246 * @since Series 60 3.0 |
|
247 * @param aEvent Event to be sent |
|
248 * @return void |
|
249 */ |
|
250 virtual void SendMediaSignalL( const TMccEvent& aEvent ); |
|
251 |
|
252 /** |
|
253 * Sends RTCP receiver report to uplink if possible. |
|
254 * @param none |
|
255 * @return One of the standard system-wide error codes. |
|
256 */ |
|
257 virtual void SendRTCPReceiverReportL(); |
|
258 |
|
259 /** |
|
260 * Sends RTCP sender report to uplink if possible. |
|
261 * @param none |
|
262 * @return One of the standard system-wide error codes. |
|
263 */ |
|
264 virtual void SendRTCPSenderReportL(); |
|
265 |
|
266 /** |
|
267 * Sends Non-RTCP data to uplink if possible. |
|
268 * @param aData - [input] Data to send |
|
269 * @return One of the standard system-wide error codes. |
|
270 */ |
|
271 virtual void SendRTCPDataL( const TDesC8& aData ); |
|
272 |
|
273 /** |
|
274 * Starts inactivity timer for a stream in a given session. |
|
275 * @since Series 60 3.0 |
|
276 * @param aMessage Message from client |
|
277 * @return TBool Was function Sync/Async |
|
278 */ |
|
279 virtual void StartInactivityTimerL( TUint32 aTimeoutTime ); |
|
280 |
|
281 /** |
|
282 * Stops inactivity timer for a stream in a given session. |
|
283 * @since Series 60 3.0 |
|
284 * @param aMessage Message from client |
|
285 * @return TBool Was function Sync/Async |
|
286 */ |
|
287 virtual void StopInactivityTimerL(); |
|
288 |
|
289 virtual void GetSSRCL( TUint32& aSSRCValue ) = 0; |
|
290 |
|
291 /** |
|
292 * Function for dynamic bitrate change. This is used only for AMR |
|
293 * encoder, but this will trap the call to DoChangeBitrateL() function |
|
294 * which will be inherited by subclasses. |
|
295 * @param aBitrate New encoder bitrate |
|
296 * @return TInt System-wide error code |
|
297 */ |
|
298 TInt ChangeBitrate( TInt aBitrate ); |
|
299 |
|
300 /** |
|
301 * Fetches FMTP |
|
302 * @since Series 60 3.0 |
|
303 */ |
|
304 void GetFmtpL( TDes8& aFmtp ); |
|
305 |
|
306 /** |
|
307 * Fetches codec info |
|
308 * @since Series 60 3.0 |
|
309 */ |
|
310 virtual void GetCodecL( TMccCodecInfo& aCodec ); |
|
311 |
|
312 /** |
|
313 * |
|
314 */ |
|
315 virtual TBool IsUplink() = 0; |
|
316 |
|
317 /** |
|
318 * |
|
319 */ |
|
320 virtual void StandByL() = 0; |
|
321 |
|
322 /** |
|
323 * |
|
324 */ |
|
325 virtual void SetAudioRouteL( TUint32 aRoutingDestination ); |
|
326 |
|
327 /** |
|
328 * |
|
329 */ |
|
330 virtual void GetAudioRouteL( TUint32& aRoutingDestination ); |
|
331 |
|
332 /** |
|
333 * |
|
334 */ |
|
335 MDataSink* DataSink() { return iDatasink; }; |
|
336 |
|
337 /** |
|
338 * |
|
339 */ |
|
340 MDataSource* DataSource() { return iDatasource; }; |
|
341 |
|
342 /** |
|
343 * |
|
344 */ |
|
345 const TUid Type(); |
|
346 |
|
347 /** |
|
348 * |
|
349 */ |
|
350 TBool LocalStream() const; |
|
351 |
|
352 /** |
|
353 * |
|
354 */ |
|
355 TBool StandbyStream() const; |
|
356 |
|
357 /** |
|
358 * |
|
359 */ |
|
360 void InformStreamStateChange( TMccEventType aEventType, |
|
361 TUint32 aEndpointId ); |
|
362 |
|
363 /** |
|
364 * Bind context into stream. |
|
365 * @since Series 60 3.2 |
|
366 * @param aEndpointId The endpoint id |
|
367 * @param aContextParams Crypto context |
|
368 * @return void |
|
369 */ |
|
370 virtual void BindContextIntoStreamL( TUint32 aEndpointId, |
|
371 const TMccCryptoContext& aContextParams ); |
|
372 |
|
373 /** |
|
374 * Remove crypto context. |
|
375 * @since Series 60 3.2 |
|
376 * @param aEndpointId The endpoint id, If 0 |
|
377 * will remove context from all existing endpoints |
|
378 * @return Error code. |
|
379 */ |
|
380 virtual TInt RemoveContext( TUint32 aEndpointId ); |
|
381 |
|
382 protected: // New functions |
|
383 |
|
384 /** |
|
385 * Gets sink of the multiplexer |
|
386 */ |
|
387 virtual MDataSink* MultiplexerSink(); |
|
388 |
|
389 /** |
|
390 * Sets the state of the stream |
|
391 * @since Series 60 3.0 |
|
392 * @param TStreamState New state |
|
393 * @return void |
|
394 */ |
|
395 TBool SetStateL( TStreamState aState, TUint32 aEndpointId ); |
|
396 |
|
397 /** |
|
398 * Worker function for dynamic bitrate change |
|
399 * @since Series 60 3.0 |
|
400 * @param aBitrate New bitrate |
|
401 * @return void |
|
402 */ |
|
403 virtual void DoChangeBitrateL( TInt aBitrate ); |
|
404 |
|
405 /** |
|
406 * Returns the current state of the stream |
|
407 * @since Series 60 3.0 |
|
408 * @param None |
|
409 * @return TStreamState |
|
410 */ |
|
411 TStreamState CurrentState(); |
|
412 |
|
413 /** |
|
414 * Standby activation/deactivation |
|
415 */ |
|
416 void HandleStandby( TUint32 aEndpointId, TBool aStreamPaused ); |
|
417 |
|
418 /** |
|
419 * Send streaming events of uncontrolled/MMF endpoints. |
|
420 */ |
|
421 TInt SendStreamEventToClient( TMccEventType aEventType, |
|
422 TUint32 aEndpointId, |
|
423 TInt aError = KErrNone ); |
|
424 |
|
425 /** |
|
426 * Updates multiplexer. |
|
427 */ |
|
428 void HandleMultiplexerL(); |
|
429 |
|
430 /** |
|
431 * Updates sink/source if needed. |
|
432 */ |
|
433 void HandleSpecialSinksAndSources(); |
|
434 |
|
435 /** |
|
436 * |
|
437 */ |
|
438 void MultiplexerCleanup(); |
|
439 |
|
440 void DoPrimeL(); |
|
441 |
|
442 void DoPlayL(); |
|
443 |
|
444 void DoPauseL(); |
|
445 |
|
446 void DoResumeL(); |
|
447 |
|
448 void DoStopL(); |
|
449 |
|
450 void ParsePayloadTypesL( RArray<TUint>& aPayloadTypes, |
|
451 const TMccCodecInfo& aCodecInfo ) const; |
|
452 |
|
453 TBool IsControllingMmfEndpoint() const; |
|
454 |
|
455 TCodecState CurrentCodecState() const; |
|
456 |
|
457 void SetCodecState( TCodecState aState ); |
|
458 |
|
459 void UpdateCodecLoadingPermission( TBool aLoadingAllowed ); |
|
460 |
|
461 TBool CodecLoadingAllowed() const; |
|
462 |
|
463 TBool IsControlled( TUint32 aEndpointId ) const; |
|
464 |
|
465 TBool IsCodecOperationAllowed() const; |
|
466 |
|
467 void ClearStateChangeEvent(); |
|
468 |
|
469 |
|
470 public: // Functions from base classes |
|
471 // Set priority settings |
|
472 void SetMMFPriority ( |
|
473 const TMMFPrioritySettings& aPriority ); |
|
474 |
|
475 protected: // Constructor |
|
476 |
|
477 /** |
|
478 * Constructor |
|
479 */ |
|
480 CMccSymStreamBase( TUint32 aMccStreamId, |
|
481 MAsyncEventHandler* aEventhandler, |
|
482 MMccResources* aMccResources, |
|
483 CMccRtpManager* aManager, |
|
484 TInt aStreamType ); |
|
485 |
|
486 private: // Consturctor |
|
487 |
|
488 /** |
|
489 * Private constructor |
|
490 */ |
|
491 inline CMccSymStreamBase() : iDatapath( NULL ), iEventhandler( NULL ), |
|
492 iDatasink( NULL ), iDatasource( NULL ), |
|
493 iCodecInfo( TMccCodecInfo() ), iRtpmanager( NULL ), |
|
494 iSoundDevice( NULL ), iMccStreamId( (TUint) KErrNotFound ), |
|
495 iState ( EStateNone ) |
|
496 { }; |
|
497 |
|
498 protected: // Data |
|
499 |
|
500 // Streams datapath |
|
501 CMccDataPathBase* iDatapath; |
|
502 |
|
503 // Eventhandler for the stream |
|
504 MAsyncEventHandler* iEventhandler; |
|
505 |
|
506 MMccResources* iMccResources; |
|
507 |
|
508 // Datasink |
|
509 MDataSink* iDatasink; |
|
510 |
|
511 // Datasource |
|
512 MDataSource* iDatasource; |
|
513 |
|
514 // Codec information |
|
515 TMccCodecInfo iCodecInfo; |
|
516 |
|
517 // fmtp string |
|
518 HBufC8* iFmtpAttr; |
|
519 |
|
520 // RTP Manager instance |
|
521 CMccRtpManager* iRtpmanager; |
|
522 |
|
523 // Devsound instance used by this stream |
|
524 CMMFDevSound* iSoundDevice; |
|
525 |
|
526 // Identifier of this stream |
|
527 TUint32 iMccStreamId; |
|
528 |
|
529 // Type of the stream |
|
530 TUint8 iType; |
|
531 |
|
532 RArray<TUint32> iControlledEndpoints; |
|
533 |
|
534 RArray<TUint32> iUncontrolledEndpoints; |
|
535 |
|
536 // Multiplexer, not owned |
|
537 CMccMultiplexer* iMultiplexer; |
|
538 |
|
539 // Rtp media clock |
|
540 CMccRtpMediaClock* iRtpMediaClock; |
|
541 |
|
542 TMMFPrioritySettings iPrioritySettings; |
|
543 |
|
544 private: // Data |
|
545 // Current state |
|
546 TStreamState iState; |
|
547 |
|
548 TCodecState iCodecState; |
|
549 |
|
550 TBool iCodecLoadingAllowed; |
|
551 |
|
552 // Currently used state change event |
|
553 TMccEvent iStreamStateChangeEvent; |
|
554 |
|
555 private: // Friend classes |
|
556 #if defined( TEST_EUNIT ) |
|
557 friend class UT_CMccSymDlStream; |
|
558 friend class UT_CMccSymUlStream; |
|
559 friend class UT_CMccSymSimpleDlStream; |
|
560 #endif |
|
561 }; |
|
562 |
|
563 #endif // MCCSYMSTREAMBASE_H |
|
564 |
|
565 // End of File |