|
1 /* |
|
2 * Copyright (c) 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 |
|
22 |
|
23 #ifndef MCEMMLOGS_H |
|
24 #define MCEMMLOGS_H |
|
25 |
|
26 #include <sdpcodecstringconstants.h> |
|
27 #include "mcelogs.h" |
|
28 #include "mcesrvsink.h" |
|
29 #include "mcesrvsource.h" |
|
30 #include "mcecommediasink.h" |
|
31 #include "mcecommediasource.h" |
|
32 #include "mcecomcodec.h" |
|
33 #include "mceaudiostream.h" |
|
34 #include "mcevideostream.h" |
|
35 |
|
36 // INCLUDES |
|
37 |
|
38 // FORWARD DECLARATIONS |
|
39 |
|
40 // CLASS DECLARATION |
|
41 |
|
42 #ifdef MCEMM_UNIT_TEST_COVERAGE |
|
43 |
|
44 #undef _DEBUG |
|
45 |
|
46 #endif |
|
47 |
|
48 /** |
|
49 * Class provides logging through RDebug in debug builds |
|
50 * 'MCE: ' added automatically in fron of every logged line |
|
51 */ |
|
52 class TMceMMDebug |
|
53 { |
|
54 public: |
|
55 |
|
56 #ifdef _DEBUG |
|
57 |
|
58 inline static void Print(const TDesC16& aStr) |
|
59 { |
|
60 TChar notAllowed('%'); |
|
61 if ( aStr.Locate( notAllowed ) == KErrNotFound ) |
|
62 { |
|
63 _LIT(KMceFormat, "[Media Manager] %S"); |
|
64 |
|
65 TBuf<256> str; |
|
66 str.Format(KMceFormat, &aStr); |
|
67 TMceDebug::Print( str, ETrue ); |
|
68 } |
|
69 else |
|
70 { |
|
71 _LIT(KMceWarning, "MCE: Text contains not allowed characters, log ignored"); |
|
72 RDebug::Print( KMceWarning ); |
|
73 } |
|
74 } |
|
75 |
|
76 inline static void Print(const TDesC16& aStr1, TUint32 aValue1 ) |
|
77 { |
|
78 TChar notAllowed('%'); |
|
79 if ( aStr1.Locate( notAllowed ) == KErrNotFound ) |
|
80 { |
|
81 _LIT(KMceFormat, "[Media Manager] %S=%d"); |
|
82 TBuf<256> str; |
|
83 str.Format(KMceFormat, &aStr1, aValue1); |
|
84 TMceDebug::Print( str, ETrue ); |
|
85 } |
|
86 else |
|
87 { |
|
88 _LIT(KMceWarning, "MCE: Text contains not allowed characters, log ignored"); |
|
89 RDebug::Print( KMceWarning ); |
|
90 } |
|
91 } |
|
92 |
|
93 inline static void Print( const TDesC16& aStr1, const TDesC16& aStr2 ) |
|
94 { |
|
95 TChar notAllowed('%'); |
|
96 if ( aStr1.Locate( notAllowed ) == KErrNotFound && |
|
97 aStr2.Locate( notAllowed ) == KErrNotFound ) |
|
98 { |
|
99 _LIT(KMceFormat, "[Media Manager] %S=%S"); |
|
100 TBuf<256> str; |
|
101 str.Format(KMceFormat, &aStr1, &aStr2); |
|
102 TMceDebug::Print( str, ETrue ); |
|
103 } |
|
104 else |
|
105 { |
|
106 _LIT(KMceWarning, "MCE: Text contains not allowed characters, log ignored"); |
|
107 RDebug::Print( KMceWarning ); |
|
108 } |
|
109 } |
|
110 |
|
111 inline static void Print(const TDesC16& aStr1, TUint32 aValue1, const TDesC16& aStr2, TUint32 aValue2 ) |
|
112 { |
|
113 TChar notAllowed('%'); |
|
114 if ( aStr1.Locate( notAllowed ) == KErrNotFound ) |
|
115 { |
|
116 _LIT(KMceFormat, "[Media Manager] %S=%d, %S=%d"); |
|
117 TBuf<256> str; |
|
118 str.Format(KMceFormat, &aStr1, aValue1, &aStr2, aValue2 ); |
|
119 TMceDebug::Print( str ); |
|
120 } |
|
121 else |
|
122 { |
|
123 _LIT(KMceWarning, "MCE: Text contains not allowed characters, log ignored"); |
|
124 RDebug::Print( KMceWarning ); |
|
125 } |
|
126 } |
|
127 |
|
128 inline static void Print( const TDesC16& aStr1, const TDesC8& aValue1 ) |
|
129 { |
|
130 TChar notAllowed('%'); |
|
131 if ( aStr1.Locate( notAllowed ) == KErrNotFound ) |
|
132 { |
|
133 TBuf<100> str2; |
|
134 CnvUtfConverter::ConvertToUnicodeFromUtf8(str2, aValue1); |
|
135 |
|
136 _LIT(KMceFormat, "[Media Manager] %S=\"%S\""); |
|
137 TBuf<256> str; |
|
138 str.Format(KMceFormat, &aStr1, &str2); |
|
139 TMceDebug::Print( str ); |
|
140 } |
|
141 else |
|
142 { |
|
143 _LIT(KMceWarning, "MCE: Text contains not allowed characters, log ignored"); |
|
144 RDebug::Print( KMceWarning ); |
|
145 } |
|
146 } |
|
147 |
|
148 |
|
149 #endif |
|
150 |
|
151 }; |
|
152 |
|
153 |
|
154 |
|
155 #if ( defined _DEBUG ) && ( !defined EUNIT_UNIT_TEST_COVERAGE ) |
|
156 |
|
157 #define MCEMM_DEBUG( a ) { TMceMMDebug::Print( _L( a ) ); } |
|
158 #define MCEMM_DEBUG2( a, b ) { TMceMMDebug::Print( _L( a ), _L( b ) ); } |
|
159 #define MCEMM_DEBUG_DVALUE( a, b ) { TMceMMDebug::Print( _L( a ), b ); } |
|
160 #define MCEMM_DEBUG_DVALUES( a, b, c, d ) { TMceMMDebug::Print( _L( a ), b, _L( c ), d ); } |
|
161 #define MCEMM_DEBUG_SVALUE( a, b ) { TMceMMDebug::Print( _L( a ), b ); } |
|
162 #define MCEMM_DEBUG_SVALUE16( a, b ) { TMceMMDebug::Print( _L( a ), b ); } |
|
163 #define MCEMM_DEBUG_STATE( str, state )\ |
|
164 switch( state )\ |
|
165 {\ |
|
166 case KMceMediaIdle:{ MCEMM_DEBUG2( str, "KMceMediaIdle" );break; }\ |
|
167 case KMceOfferingMedia:{ MCEMM_DEBUG2( str, "KMceOfferingMedia" );break; }\ |
|
168 case KMceAnsweringMedia:{ MCEMM_DEBUG2( str, "KMceAnsweringMedia" );break; }\ |
|
169 case KMceAnsweringMediaUpdate:{ MCEMM_DEBUG2( str, "KMceAnsweringMediaUpdate" );break; }\ |
|
170 case KMceMediaNegotiated:{ MCEMM_DEBUG2( str, "KMceMediaNegotiated" );break; }\ |
|
171 case KMcePreparingOffererStreams:{ MCEMM_DEBUG2( str, "KMcePreparingOffererStreams" );break; }\ |
|
172 case KMceStartingOffererReceiveStreams:{ MCEMM_DEBUG2( str, "KMceStartingOffererReceiveStreams" );break; }\ |
|
173 case KMceStartingOffererSendStreams:{ MCEMM_DEBUG2( str, "KMceStartingOffererSendStreams" );break; }\ |
|
174 case KMcePreparingAnswererStreams:{ MCEMM_DEBUG2( str, "KMcePreparingAnswererStreams" );break; }\ |
|
175 case KMceStartingAnswererStreams:{ MCEMM_DEBUG2( str, "KMceStartingAnswererStreams" );break; }\ |
|
176 default:{ MCEMM_DEBUG_DVALUE( str, state );break; }\ |
|
177 } |
|
178 |
|
179 #define MCEMM_DEBUG_STATE_1( str, session )\ |
|
180 if ( &session.NegotiationState() )\ |
|
181 {\ |
|
182 MCEMM_DEBUG_STATE( str, session.NegotiationState().Id() );\ |
|
183 }\ |
|
184 else\ |
|
185 {\ |
|
186 MCEMM_DEBUG( "no state!" );\ |
|
187 } |
|
188 |
|
189 |
|
190 #define MCEMM_DEBUG_MEDIASTATE( str, state )\ |
|
191 switch( state )\ |
|
192 {\ |
|
193 case CMceSrvStream::EAdopted:{ MCEMM_DEBUG2( str, "EAdopted" );break; }\ |
|
194 case CMceSrvStream::ECreated:{ MCEMM_DEBUG2( str, "ECreated" );break; }\ |
|
195 case CMceSrvStream::ECreatingLink:{ MCEMM_DEBUG2( str, "ECreatingLink" );break; }\ |
|
196 case CMceSrvStream::ELinkCreated:{ MCEMM_DEBUG2( str, "ELinkCreated" );break; }\ |
|
197 case CMceSrvStream::EPreparing:{ MCEMM_DEBUG2( str, "EPreparing" );break; }\ |
|
198 case CMceSrvStream::EPrepared:{ MCEMM_DEBUG2( str, "EPrepared" );break; }\ |
|
199 case CMceSrvStream::EStarting:{ MCEMM_DEBUG2( str, "EStarting" );break; }\ |
|
200 case CMceSrvStream::EPending:{ MCEMM_DEBUG2( str, "EPending" );break; }\ |
|
201 case CMceSrvStream::EStopped:{ MCEMM_DEBUG2( str, "EStopped" );break; }\ |
|
202 case CMceSrvStream::EInactive:{ MCEMM_DEBUG2( str, "EInactive" );break; }\ |
|
203 case CMceSrvStream::EStarted:{ MCEMM_DEBUG2( str, "EStarted" );break; }\ |
|
204 case CMceSrvStream::EPausing:{ MCEMM_DEBUG2( str, "EPausing" );break; }\ |
|
205 case CMceSrvStream::EPaused:{ MCEMM_DEBUG2( str, "EPaused" );break; }\ |
|
206 default:{ MCEMM_DEBUG_DVALUE( str, state );break; }\ |
|
207 } |
|
208 |
|
209 #define MCEMM_DEBUG_STREAMMEDIA( str, type )\ |
|
210 switch( type )\ |
|
211 {\ |
|
212 case KMceAudio:{ MCEMM_DEBUG2( str, "audio" );break; }\ |
|
213 case KMceVideo:{ MCEMM_DEBUG2( str, "video" );break; }\ |
|
214 default:{ MCEMM_DEBUG_DVALUE( str, type );break; }\ |
|
215 } |
|
216 |
|
217 #define MCEMM_DEBUG_STREAMTYPE( str, type )\ |
|
218 switch( type )\ |
|
219 {\ |
|
220 case CMceComMediaStream::ELocalStream:{ MCEMM_DEBUG2( str, "ELocalStream" );break; }\ |
|
221 case CMceComMediaStream::ESendOnlyStream:{ MCEMM_DEBUG2( str, "ESendOnlyStream" );break; }\ |
|
222 case CMceComMediaStream::EReceiveOnlyStream:{ MCEMM_DEBUG2( str, "EReceiveOnlyStream" );break; }\ |
|
223 case CMceComMediaStream::ESendStream:{ MCEMM_DEBUG2( str, "ESendStream" );break; }\ |
|
224 case CMceComMediaStream::EReceiveStream:{ MCEMM_DEBUG2( str, "EReceiveStream" );break; }\ |
|
225 default:{ MCEMM_DEBUG_DVALUE( str, type );break; }\ |
|
226 } |
|
227 |
|
228 #define MCEMM_DEBUG_STREAMDIRECTION( str, type )\ |
|
229 switch( type )\ |
|
230 {\ |
|
231 case SdpCodecStringConstants::EAttributeSendrecv:{ MCEMM_DEBUG2( str, "sendrecv" );break; }\ |
|
232 case SdpCodecStringConstants::EAttributeRecvonly:{ MCEMM_DEBUG2( str, "recvonly" );break; }\ |
|
233 case SdpCodecStringConstants::EAttributeSendonly:{ MCEMM_DEBUG2( str, "sendonly" );break; }\ |
|
234 case SdpCodecStringConstants::EAttributeInactive:{ MCEMM_DEBUG2( str, "inactive" );break; }\ |
|
235 default:{ MCEMM_DEBUG_DVALUE( str, type );break; }\ |
|
236 } |
|
237 |
|
238 /*lint -e666 */ |
|
239 #define MCEMM_DEBUG_STREAM( str, stream )\ |
|
240 MCEMM_DEBUG( str );\ |
|
241 if ( !(stream).IsAdopted() )\ |
|
242 {\ |
|
243 MCEMM_DEBUG_DVALUE(" Session id ", (stream).SessionId() );\ |
|
244 MCEMM_DEBUG_STREAMMEDIA(" Stream media ", (stream).Data().iType );\ |
|
245 MCEMM_DEBUG_DVALUE(" Stream id ", (stream).Id() );\ |
|
246 MCEMM_DEBUG_DVALUE(" Stream link id ", (stream).LinkId() );\ |
|
247 MCEMM_DEBUG_STREAMTYPE(" Stream type ", (stream).StreamType() );\ |
|
248 MCEMM_DEBUG_DVALUE(" Stream enabled ", (stream).Data().IsEnabled() );\ |
|
249 MCEMM_DEBUG_STREAMDIRECTION(" Stream direction ", (stream).Data().Direction() );\ |
|
250 MCEMM_DEBUG_MEDIASTATE(" Stream state ", (stream).State() );\ |
|
251 MCEMM_DEBUG_SVALUE( " Codec name ", (stream).Codec().iSdpName );\ |
|
252 MCEMM_DEBUG_DVALUE( " Codec enabled ", (stream).Codec().iIsEnabled );\ |
|
253 MCEMM_DEBUG_DVALUE( " Codec payload ", (stream).Codec().iPayloadType );\ |
|
254 MCEMM_DEBUG_DVALUE(" Sink id ", (stream).Sink().Id() );\ |
|
255 MCEMM_DEBUG_MEDIASTATE(" Sink state ", (stream).Sink().State() );\ |
|
256 MCEMM_DEBUG_DVALUE(" Sink enabled (l) ", (stream).Sink().Data().IsEnabled() );\ |
|
257 MCEMM_DEBUG_DVALUE(" Sink enabled (e2e) ", (stream).Sink().Data().IsEnabled( KMceEnabledE2e ) );\ |
|
258 MCEMM_DEBUG_DVALUE(" Source id ", (stream).Source().Id() );\ |
|
259 MCEMM_DEBUG_MEDIASTATE(" Source state ", (stream).Source().State() );\ |
|
260 MCEMM_DEBUG_DVALUE(" Source enabled (l) ", (stream).Source().Data().IsEnabled() );\ |
|
261 MCEMM_DEBUG_DVALUE(" Source enabled (e2e)", (stream).Source().Data().IsEnabled( KMceEnabledE2e ) );\ |
|
262 }\ |
|
263 else\ |
|
264 {\ |
|
265 MCEMM_DEBUG_DVALUE(" Session id ", (stream).SessionId() );\ |
|
266 MCEMM_DEBUG_DVALUE(" Stream id ", (stream).Id() );\ |
|
267 MCEMM_DEBUG_DVALUE(" Stream link id ", (stream).LinkId() );\ |
|
268 } |
|
269 |
|
270 #else |
|
271 |
|
272 |
|
273 #define MCEMM_DEBUG( a ) |
|
274 #define MCEMM_DEBUG2( a, b ) |
|
275 #define MCEMM_DEBUG_DVALUE( a, b ) |
|
276 #define MCEMM_DEBUG_DVALUES( a, b, c, d ) |
|
277 #define MCEMM_DEBUG_SVALUE( a, b ) |
|
278 #define MCEMM_DEBUG_STATE( str, state ) |
|
279 #define MCEMM_DEBUG_STATE_1( str, session ) |
|
280 #define MCEMM_DEBUG_MEDIASTATE( str, state ) |
|
281 #define MCEMM_DEBUG_STREAMTYPE( str, type ) |
|
282 #define MCEMM_DEBUG_STREAMDIRECTION( str, type ) |
|
283 #define MCEMM_DEBUG_STREAM( str, stream ) |
|
284 #define MCEMM_DEBUG_STREAMMEDIA( str, type ) |
|
285 |
|
286 |
|
287 #endif |
|
288 |
|
289 #endif |
|
290 |
|
291 // End of File |