|
1 /* |
|
2 * Copyright (c) 2004-2006 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 comfort noise generator class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef MCCCNGENERATOR_H |
|
22 #define MCCCNGENERATOR_H |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <mmf/common/mmfutilities.h> |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CMMFDevSound; |
|
29 class CErrorConcealmentIntfc; |
|
30 |
|
31 /** |
|
32 * MCC Comfort noise generator |
|
33 * |
|
34 * @lib MMccJitterBuffer.lib |
|
35 * @since Series 60 3.0 |
|
36 */ |
|
37 NONSHARABLE_CLASS( CMccCnGenerator ) : public CBase |
|
38 { |
|
39 public: // Constructors and destructor |
|
40 |
|
41 /** |
|
42 * Two phased constructor |
|
43 */ |
|
44 static CMccCnGenerator* NewL( const TFourCC& aAudioType, |
|
45 CMMFDevSound& aDevSound ); |
|
46 |
|
47 /** |
|
48 * Destructor |
|
49 */ |
|
50 virtual ~CMccCnGenerator(); |
|
51 |
|
52 public: // New functions |
|
53 |
|
54 /** |
|
55 * Generates an SID packet to given buffer |
|
56 * @since Series 60 3.0 |
|
57 * @param aPayload Buffer to be filled with SID data |
|
58 * @param aRequestSize Amount of data to be generated to buffer. |
|
59 * @return void |
|
60 */ |
|
61 void GenerateSidPacket( TDes8& aPayload, TInt aRequestSize ); |
|
62 |
|
63 /** |
|
64 * Jitterbuffer has noted that frames were missing, so error concealment |
|
65 * needs to be done to some frames. This function calls the error |
|
66 * concealment interface's error concealment function. |
|
67 * @since Series 60 3.0 |
|
68 * @param None |
|
69 * @return void |
|
70 */ |
|
71 void ConcealErrorForNextFrame() const; |
|
72 |
|
73 /** |
|
74 * Returns the current DTX status |
|
75 * @since Series 60 3.0 |
|
76 * @param None |
|
77 * @return TBool ETrue if DTX period ongoing |
|
78 */ |
|
79 inline TBool DtxPeriodStatus() const |
|
80 { |
|
81 return ( iDtxPeriodStarted ); |
|
82 } |
|
83 |
|
84 /** |
|
85 * Decide whether we are in DTX period or in normal speech period |
|
86 * @since Series 60 3.0 |
|
87 * @param aData Buffer containing the data |
|
88 * @return void |
|
89 */ |
|
90 void DoDtxDecision( const TDesC8& aData ); |
|
91 |
|
92 /** |
|
93 * Check if the given databuffer is a SID frame for current codec |
|
94 * @since Series 60 3.0 |
|
95 * @param aData Buffer containing the data |
|
96 * @return TBool ETrue if the aBuffer is a SID for current codec |
|
97 */ |
|
98 TBool IsSidBuffer( const TDesC8& aData ) const; |
|
99 |
|
100 private: // New functions |
|
101 |
|
102 /** |
|
103 * Generates an AMR CN packet into aPayload |
|
104 * @since Series 60 3.0 |
|
105 * @param aPayload |
|
106 * @return void |
|
107 */ |
|
108 void GenerateAmrNoDataPacket( TDes8& aPayload ) const; |
|
109 |
|
110 /** |
|
111 * Generates an VoIP NO_DATA frame into aPayload |
|
112 * @since Series 60 3.0 |
|
113 * @param aPayload Buffer to be filled with VoIP NO_DATA information |
|
114 * @param aRequestSize Amount of data to be generated to buffer. |
|
115 * @return void |
|
116 */ |
|
117 void GenerateVoIPNoDataPacket( TDes8& aPayload, TInt aRequestSize ) const; |
|
118 |
|
119 private: //Constructors |
|
120 |
|
121 /** |
|
122 * C++ default constructor. |
|
123 */ |
|
124 CMccCnGenerator( const TFourCC& aAudioType, CMMFDevSound& aDevSound ); |
|
125 |
|
126 /** |
|
127 * By default Symbian 2nd phase constructor is private. |
|
128 */ |
|
129 void ConstructL(); |
|
130 |
|
131 private: // Data |
|
132 |
|
133 // Audio type |
|
134 TFourCC iAudioType; |
|
135 |
|
136 // Sound device for Error Concealment IF creation |
|
137 CMMFDevSound& iDevSound; |
|
138 |
|
139 // Error concealment interface |
|
140 CErrorConcealmentIntfc* iErrorConcealer; |
|
141 |
|
142 // Generated CN frames |
|
143 TInt iGeneratedCnFrames; |
|
144 |
|
145 // DTX period started |
|
146 TBool iDtxPeriodStarted; |
|
147 |
|
148 private: // Friend classes |
|
149 |
|
150 // Friend class for EUNIT tests |
|
151 #ifdef TEST_EUNIT |
|
152 friend class UT_CMccCnGenerator; |
|
153 #endif |
|
154 }; |
|
155 |
|
156 #endif // MCCCNGENERATOR_H |