|
1 /* |
|
2 * Copyright (c) 2004-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 #ifndef __RTPUTIL_H |
|
22 #define __RTPUTIL_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32def.h> |
|
26 #include <e32std.h> |
|
27 #include <f32file.h> |
|
28 |
|
29 // If you need logs in release mode, just comment out the "defined( _DEBUG )" |
|
30 // or change it to 1 |
|
31 #if ( defined( _DEBUG ) && defined ( RTP_OUTPUT_TO_FILE ) ) |
|
32 |
|
33 #define _RTP_LOG_FILE |
|
34 |
|
35 #endif |
|
36 |
|
37 #ifdef RTP_UNIT_TEST_COVERAGE |
|
38 |
|
39 #undef _DEBUG |
|
40 #undef _RTP_LOG_FILE |
|
41 |
|
42 #endif |
|
43 // CONSTANTS |
|
44 |
|
45 // Note: the whole rtp module is using tenth of ms as the internal time unit. |
|
46 const TUint KTenthOfmsPerSecond = 10000; |
|
47 const TUint32 KMicrosecondPerSecond = 1000000; |
|
48 const TUint KMicrosecondPerMillSecond = 1000; |
|
49 const TInt KRandMax = 0x7fff; |
|
50 |
|
51 // how often a packet is dropped, ex. if 10, then a packet is drop every 10 packets |
|
52 // 9.09 (1/11) percent loss ratio |
|
53 const TUint KPacketLoss = 50; |
|
54 |
|
55 const TInt KPayloadTypeMax = 0x7f; |
|
56 |
|
57 // DATA TYPES |
|
58 |
|
59 _LIT( KDefaultPath, "c:\\system\\data\\" ); |
|
60 _LIT( KLogFile, "LogFileRTP.dat" ); |
|
61 |
|
62 enum TRtpRtcpEnum |
|
63 { |
|
64 ERTCP_PACKET_ERROR = -1, // indicates RTCP compound packet error |
|
65 ERTCP_NO_ERROR = KErrNone, // indicates if RTCP compound is completely processed |
|
66 ERTCP_PACKET_MORE = 1, // indicates if RTCP compound is not completely processed |
|
67 ERTCP_FOUND_RXSTREAM = 2 // indicates an receive stream has been found |
|
68 }; |
|
69 |
|
70 enum TPortType |
|
71 { |
|
72 ERTPPort = 0, |
|
73 ERTCPPort |
|
74 }; |
|
75 |
|
76 |
|
77 |
|
78 #ifdef _DEBUG |
|
79 |
|
80 #define RTP_DEBUG_DETAIL( a ) { TRtpUtil::Print( _L8( a ) ); } |
|
81 #define RTP_DEBUG_DETAIL_DVALUE( a, b ) { TRtpUtil::Print( _L8( a ), b ); } |
|
82 |
|
83 #define RTP_DEBUG_PACKET( a ) { TRtpUtil::Print( _L8( a ) ); } |
|
84 #define RTP_DEBUG_PACKET_DVALUE( a, b ) { TRtpUtil::Print( _L8( a ), b ); } |
|
85 |
|
86 #define RTP_DEBUG_STAT( a ) { TRtpUtil::Print( _L8( a ) ); } |
|
87 #define RTP_DEBUG_STAT_DVALUE( a, b ) { TRtpUtil::Print( _L8( a ), b ); } |
|
88 |
|
89 #define RTCP_DEBUG_DETAIL( a ) { TRtpUtil::Print( _L8( a ) ); } |
|
90 #define RTCP_DEBUG_DETAIL_DVALUE( a, b ) { TRtpUtil::Print( _L8( a ), b ); } |
|
91 |
|
92 #else |
|
93 |
|
94 #define RTP_DEBUG_DETAIL( a ) |
|
95 #define RTP_DEBUG_DETAIL_DVALUE( a, b ) |
|
96 #define RTP_DEBUG_PACKET( a ) |
|
97 #define RTP_DEBUG_PACKET_DVALUE( a, b ) |
|
98 #define RTP_DEBUG_STAT( a ) |
|
99 #define RTP_DEBUG_STAT_DVALUE( a, b ) |
|
100 #define RTCP_DEBUG_DETAIL( a ) |
|
101 #define RTCP_DEBUG_DETAIL_DVALUE( a, b ) |
|
102 |
|
103 #endif |
|
104 |
|
105 // CLASS DECLARATION |
|
106 |
|
107 /** |
|
108 * RTP utility class. |
|
109 * |
|
110 * @lib RtpService.dll |
|
111 */ |
|
112 class TRtpUtil |
|
113 { |
|
114 public: |
|
115 static TUint16 Min16( TUint16 aX, TUint16 aY ); |
|
116 static TUint16 Wrap16( TUint16 aX, TUint16 aY ); |
|
117 static TUint32 Sub32( TUint32 aX, TUint32 aY ); |
|
118 |
|
119 static TUint8* Strcpy( TUint8* aTarget, const TUint8* aSource ); |
|
120 |
|
121 static TUint GtGetTime(); |
|
122 static TUint32 Random( TInt64& aSeed ); |
|
123 static TReal FloatRandom( TInt64& aSeed ); |
|
124 |
|
125 #ifdef _DEBUG |
|
126 static void Print( const TDesC8& p ); |
|
127 static void Print( const TDesC8& p, TInt aValue ); |
|
128 #endif |
|
129 |
|
130 #ifdef _RTP_LOG_FILE |
|
131 static void Print( const TDesC& name, const TDesC8& p ); |
|
132 static void Print( const TDesC& name, const TDesC8& p, TUint32 aValue ); |
|
133 #endif |
|
134 |
|
135 }; |
|
136 |
|
137 #ifdef _RTP_LOG_FILE |
|
138 class TFileUtil |
|
139 { |
|
140 public: |
|
141 static TInt LogMessage( const TFileName&, const TDesC8& ); |
|
142 static TInt InitLogFile( const TFileName& name ); |
|
143 }; |
|
144 #endif |
|
145 |
|
146 #endif /* __RTPUTIL_H*/ |
|
147 |
|
148 // End of File |