|
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 #include "mcertpsink.h" |
|
22 #include "mcecomrtpsink.h" |
|
23 #include "mceevents.h" |
|
24 #include "mceserial.h" |
|
25 |
|
26 #ifdef MCE_COMMON_SERVER_SIDE |
|
27 |
|
28 #include <mmccinterface.h> |
|
29 #include "mcepreconditions.h" |
|
30 #include "mcesdpsession.h" |
|
31 #include "mcemediamanager.h" |
|
32 |
|
33 |
|
34 #endif//MCE_COMMON_SERVER_SIDE |
|
35 |
|
36 // ============================ MEMBER FUNCTIONS =============================== |
|
37 |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CMceComRtpSink::NewL |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CMceComRtpSink* CMceComRtpSink::NewL() |
|
44 { |
|
45 CMceComRtpSink* self = NewLC(); |
|
46 CleanupStack::Pop( self ); |
|
47 return self; |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CMceComRtpSink::NewLC |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CMceComRtpSink* CMceComRtpSink::NewLC() |
|
55 { |
|
56 CMceComRtpSink* self = new (ELeave) CMceComRtpSink(); |
|
57 CleanupStack::PushL( self ); |
|
58 return self; |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CMceComRtpSink::ConstructL |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 void CMceComRtpSink::ConstructL( CMceComRtpSink& aSink ) |
|
66 { |
|
67 Mem::Copy( this, &aSink, sizeof(CMceComMediaSink) ); |
|
68 Zero(); |
|
69 iSuppressRTCP = aSink.iSuppressRTCP; |
|
70 iSSRC = aSink.iSSRC; |
|
71 iLastPacket = aSink.iLastPacket; |
|
72 iIdentity = aSink.iIdentity ? aSink.iIdentity->AllocL() : NULL; |
|
73 |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CMceComRtpSink::~CMceComRtpSink |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 CMceComRtpSink::~CMceComRtpSink() |
|
81 { |
|
82 delete iIdentity; |
|
83 } |
|
84 |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CMceComRtpSink::CMceComRtpSink |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 CMceComRtpSink::CMceComRtpSink() |
|
91 : CMceComMediaSink( KMceRTPSink ), |
|
92 iSuppressRTCP( EFalse ), |
|
93 iSSRC( 0 ), |
|
94 iLastPacket( 0 ), |
|
95 iIdentity( NULL ) |
|
96 { |
|
97 } |
|
98 |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CMceComRtpSink::CloneL |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 CMceComMediaSink* CMceComRtpSink::CloneL() |
|
105 { |
|
106 CMceComRtpSink* copy = new (ELeave) CMceComRtpSink(); |
|
107 CleanupStack::PushL( copy ); |
|
108 copy->ConstructL( *this ); |
|
109 CleanupStack::Pop( copy ); |
|
110 return copy; |
|
111 |
|
112 } |
|
113 |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CMceComRtpSink::InternalizeFlatL |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 void CMceComRtpSink::InternalizeFlatL( RReadStream& aReadStream ) |
|
120 { |
|
121 CMceComMediaSink::InternalizeFlatL( aReadStream ); |
|
122 |
|
123 iSuppressRTCP = static_cast<TBool>( aReadStream.ReadUint8L() ); |
|
124 iSSRC = aReadStream.ReadUint32L(); |
|
125 iLastPacket = aReadStream.ReadUint32L(); |
|
126 MceSerial::DecodeL( iIdentity, aReadStream ); |
|
127 } |
|
128 |
|
129 |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CMceComRtpSink::ExternalizeFlatL |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 void CMceComRtpSink::ExternalizeFlatL( RWriteStream& aWriteStream ) |
|
136 { |
|
137 CMceComMediaSink::ExternalizeFlatL( aWriteStream ); |
|
138 |
|
139 aWriteStream.WriteUint8L( iSuppressRTCP ); |
|
140 aWriteStream.WriteUint32L( iSSRC ); |
|
141 aWriteStream.WriteUint32L( iLastPacket ); |
|
142 MceSerial::EncodeL( iIdentity, aWriteStream ); |
|
143 } |
|
144 |
|
145 |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CMceComRtpSink::UpdateL |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 void CMceComRtpSink::UpdateL( CMceComMediaSink& aUpdate ) |
|
152 { |
|
153 CMceComMediaSink::UpdateL( aUpdate ); |
|
154 CMceComRtpSink& update = static_cast<CMceComRtpSink&>( aUpdate ); |
|
155 |
|
156 iSuppressRTCP = update.iSuppressRTCP; |
|
157 iSSRC = update.iSSRC; |
|
158 iLastPacket = update.iLastPacket; |
|
159 |
|
160 delete iIdentity; |
|
161 iIdentity = NULL; |
|
162 iIdentity = update.iIdentity ? update.iIdentity->AllocL() : NULL; |
|
163 } |
|
164 |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // CMceComRtpSink::EventReceivedL |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 TInt CMceComRtpSink::EventReceivedL( TMceComEvent& aEvent ) |
|
171 { |
|
172 TInt status = CMceComMediaSink::EventReceivedL( aEvent ); |
|
173 if ( status != KMceEventNotConsumed ) |
|
174 { |
|
175 return status; |
|
176 } |
|
177 |
|
178 if ( aEvent.Id().IsSinkId() ) |
|
179 { |
|
180 status = aEvent.Handler().HandleL( *this, aEvent ); |
|
181 } |
|
182 else |
|
183 { |
|
184 status = KMceEventNotConsumed; |
|
185 } |
|
186 |
|
187 return status; |
|
188 |
|
189 } |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // CMceComRtpSink::UseRTCP |
|
193 // ----------------------------------------------------------------------------- |
|
194 // |
|
195 TBool CMceComRtpSink::UseRTCP() |
|
196 { |
|
197 return !iSuppressRTCP; |
|
198 } |
|
199 |
|
200 |
|
201 // ----------------------------------------------------------------------------- |
|
202 // CMceComRtpSink::SetSSRC |
|
203 // ----------------------------------------------------------------------------- |
|
204 // |
|
205 void CMceComRtpSink::SetSSRC( TUint32 aSSRC ) |
|
206 { |
|
207 iSSRC = aSSRC; |
|
208 } |
|
209 |
|
210 |
|
211 #ifdef MCE_COMMON_SERVER_SIDE |
|
212 |
|
213 |
|
214 // ----------------------------------------------------------------------------- |
|
215 // CMceComRtpSink::IsEnabled |
|
216 // ----------------------------------------------------------------------------- |
|
217 // |
|
218 TBool CMceComRtpSink::IsEnabled( TBool aLocally ) const |
|
219 { |
|
220 TBool isEnabled = CMceComEndpoint::IsEnabled(); |
|
221 |
|
222 if ( !aLocally ) |
|
223 { |
|
224 if ( MediaStream() && MediaStream()->Preconditions().Count() ) |
|
225 { |
|
226 for ( int i =0; i < MediaStream()->Preconditions().Count(); i++ ) |
|
227 { |
|
228 |
|
229 isEnabled = isEnabled && |
|
230 !MediaStream()->Preconditions()[ i ]->RemoteReservationNeeded(); |
|
231 } |
|
232 } |
|
233 } |
|
234 |
|
235 return isEnabled; |
|
236 } |
|
237 |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // CMceComRtpSink::MccType |
|
241 // ----------------------------------------------------------------------------- |
|
242 // |
|
243 const TUid CMceComRtpSink::MccType() |
|
244 { |
|
245 return KUidMccRtpSink; |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // CMceComRtpSink::PrepareL |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 void CMceComRtpSink::PrepareL() |
|
253 { |
|
254 if ( MediaStream() && MediaStream()->Session() && |
|
255 iIdentity && |
|
256 iIdentity->Length() > 0 ) |
|
257 { |
|
258 MediaStream()->Session()->SdpSession().Manager().SetCNameL( *this, *iIdentity ); |
|
259 } |
|
260 } |
|
261 |
|
262 #endif//MCE_COMMON_SERVER_SIDE |
|
263 |