|
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 "mcemediastream.h" |
|
23 #include "mcesession.h" |
|
24 #include "mcecomrtpsink.h" |
|
25 #include "mceitcsender.h" |
|
26 #include "mcertpobserver.h" |
|
27 #include "mcemanager.h" |
|
28 #include "mceevents.h" |
|
29 #include "mceserial.h" |
|
30 #include "mceclilogs.h" |
|
31 |
|
32 |
|
33 #define _FLAT_DATA static_cast<CMceComRtpSink*>( iFlatData ) |
|
34 #define FLAT_DATA( data ) _FLAT_DATA->data |
|
35 |
|
36 // ============================ MEMBER FUNCTIONS =============================== |
|
37 |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CMceRtpSink::NewL |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 EXPORT_C CMceRtpSink* CMceRtpSink::NewL() |
|
44 { |
|
45 CMceRtpSink* self = NewLC(); |
|
46 CleanupStack::Pop( self ); |
|
47 return self; |
|
48 } |
|
49 |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CMceRtpSink::NewLC |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 EXPORT_C CMceRtpSink* CMceRtpSink::NewLC() |
|
56 { |
|
57 CMceRtpSink* self = new (ELeave) CMceRtpSink(); |
|
58 CleanupStack::PushL( self ); |
|
59 self->ConstructL( EFalse, NULL ); |
|
60 return self; |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CMceRtpSink::NewL |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 EXPORT_C CMceRtpSink* CMceRtpSink::NewL( TBool aSuppressRTCP, |
|
68 HBufC8* aIdentity ) |
|
69 { |
|
70 CMceRtpSink* self = new (ELeave) CMceRtpSink(); |
|
71 CleanupStack::PushL( self ); |
|
72 self->ConstructL( aSuppressRTCP, aIdentity ); |
|
73 CleanupStack::Pop( self ); |
|
74 return self; |
|
75 |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CMceRtpSink::~CMceRtpSink |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 EXPORT_C CMceRtpSink::~CMceRtpSink() |
|
83 { |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CMceRtpSink::EnableL |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 EXPORT_C void CMceRtpSink::EnableL() |
|
91 { |
|
92 MCECLI_DEBUG("CMceRtpSink::EnableL, Entry"); |
|
93 |
|
94 CMceMediaSink::DoEnableL(); |
|
95 |
|
96 MCECLI_DEBUG("CMceRtpSink::EnableL, Exit"); |
|
97 |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CMceRtpSink::DisableL |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 EXPORT_C void CMceRtpSink::DisableL() |
|
105 { |
|
106 MCECLI_DEBUG("CMceRtpSink::DisableL, Entry"); |
|
107 |
|
108 CMceMediaSink::DoDisableL(); |
|
109 |
|
110 MCECLI_DEBUG("CMceRtpSink::DisableL, Exit"); |
|
111 |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CMceRtpSink::SendSRL |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 EXPORT_C void CMceRtpSink::SendSRL() |
|
119 { |
|
120 MCECLI_DEBUG("CMceRtpSink::SendSRL, Entry"); |
|
121 |
|
122 __ASSERT_ALWAYS( MCE_ENDPOINT_ITC_ALLOWED( *this ), |
|
123 User::Leave( KErrNotReady ) ); |
|
124 |
|
125 DoITCSendL( EMceItcSendSR ); |
|
126 |
|
127 MCECLI_DEBUG("CMceRtpSink::SendSRL, Exit"); |
|
128 |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CMceRtpSink::LastPacket |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 EXPORT_C TUint32 CMceRtpSink::LastPacket() const |
|
136 { |
|
137 return FLAT_DATA( iLastPacket ); |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CMceRtpSink::Ssrc |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 EXPORT_C TUint32 CMceRtpSink::Ssrc() const |
|
145 { |
|
146 return FLAT_DATA( iSSRC ); |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CMceRtpSink::UpdateL |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 EXPORT_C void CMceRtpSink::UpdateL( TBool aSuppressRTCP, HBufC8* aIdentity ) |
|
154 { |
|
155 MCECLI_DEBUG("CMceRtpSink::UpdateL, Entry"); |
|
156 |
|
157 FLAT_DATA( iSuppressRTCP ) = aSuppressRTCP; |
|
158 MCE_DELETE( FLAT_DATA( iIdentity ) ); |
|
159 FLAT_DATA( iIdentity ) = aIdentity ? aIdentity->AllocL() : NULL; |
|
160 |
|
161 MCECLI_DEBUG("CMceRtpSink::UpdateL, Exit"); |
|
162 |
|
163 } |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CMceRtpSink::CMceRtpSink |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 CMceRtpSink::CMceRtpSink() |
|
170 : CMceMediaSink() |
|
171 { |
|
172 } |
|
173 |
|
174 // ----------------------------------------------------------------------------- |
|
175 // CMceRtpSink::ConstructL |
|
176 // ----------------------------------------------------------------------------- |
|
177 // |
|
178 void CMceRtpSink::ConstructL( TBool aSuppressRTCP, HBufC8* aIdentity ) |
|
179 { |
|
180 CMceComRtpSink* sink = CMceComRtpSink::NewLC(); |
|
181 CMceMediaSink::ConstructL( sink ); |
|
182 CleanupStack::Pop( sink ); |
|
183 |
|
184 FLAT_DATA( iSuppressRTCP ) = aSuppressRTCP; |
|
185 FLAT_DATA( iIdentity ) = aIdentity ? aIdentity->AllocL() : NULL; |
|
186 } |
|
187 |
|
188 |
|
189 |
|
190 // ----------------------------------------------------------------------------- |
|
191 // CMceRtpSink::DoITCSendL |
|
192 // ----------------------------------------------------------------------------- |
|
193 // |
|
194 void CMceRtpSink::DoITCSendL( TUint8 aITCFunction ) |
|
195 { |
|
196 __ASSERT_ALWAYS( iStream, User::Leave( KErrNotReady ) ); |
|
197 __ASSERT_ALWAYS( iStream->Session(), User::Leave( KErrNotReady ) ); |
|
198 CMceSession* session = iStream->Session(); |
|
199 |
|
200 if ( session->State() != CMceSession::EIdle ) |
|
201 { |
|
202 TMceIds ids; |
|
203 session->PrepareForITC( ids ); |
|
204 ids.iMediaID = iStream->Id(); |
|
205 ids.iSinkID = Id(); |
|
206 ids.iState = IsEnabled(); |
|
207 |
|
208 session->ITCSender().SendL( ids, static_cast<TMceItcFunctions>( aITCFunction ) ); |
|
209 } |
|
210 } |
|
211 |
|
212 // ----------------------------------------------------------------------------- |
|
213 // CMceRtpSink::EventReceivedL |
|
214 // ----------------------------------------------------------------------------- |
|
215 // |
|
216 TInt CMceRtpSink::EventReceivedL( TMceEvent& aEvent ) |
|
217 { |
|
218 TInt status = CMceMediaSink::EventReceivedL( aEvent ); |
|
219 if ( status != KMceEventNotConsumed ) |
|
220 { |
|
221 return status; |
|
222 } |
|
223 |
|
224 if ( aEvent.Id().IsSinkId() ) |
|
225 { |
|
226 status = HandleEvent( aEvent ); |
|
227 } |
|
228 else |
|
229 { |
|
230 status = KMceEventNotConsumed; |
|
231 } |
|
232 |
|
233 return status; |
|
234 |
|
235 } |
|
236 |
|
237 |
|
238 // ----------------------------------------------------------------------------- |
|
239 // CMceRtpSink::HandleEvent |
|
240 // ----------------------------------------------------------------------------- |
|
241 // |
|
242 TInt CMceRtpSink::HandleEvent( TMceEvent& aEvent ) |
|
243 { |
|
244 MCECLI_DEBUG("CMceRtpSink::HandleEvent, Entry"); |
|
245 |
|
246 TInt status = KMceEventNotConsumed; |
|
247 |
|
248 MMceRtpObserver* observer = iStream->Session()->Manager().RtpObserver(); |
|
249 switch ( aEvent.Action() ) |
|
250 { |
|
251 case EMceItcSRReceived: |
|
252 { |
|
253 MCECLI_DEBUG("CMceRtpSink::HandleEvent, SR received"); |
|
254 if ( observer ) |
|
255 { |
|
256 observer->SRReceived( *( iStream->Session() ), *iStream ); |
|
257 } |
|
258 status = KMceEventConsumed; |
|
259 break; |
|
260 } |
|
261 case EMceItcRRReceived: |
|
262 { |
|
263 MCECLI_DEBUG("CMceRtpSink::HandleEvent, RR received"); |
|
264 if ( observer ) |
|
265 { |
|
266 observer->RRReceived( *( iStream->Session() ), *iStream ); |
|
267 } |
|
268 status = KMceEventConsumed; |
|
269 break; |
|
270 } |
|
271 default: |
|
272 { |
|
273 //NOP |
|
274 MCECLI_DEBUG("CMceRtpSink::HandleEvent, not consumed"); |
|
275 break; |
|
276 } |
|
277 |
|
278 } |
|
279 |
|
280 MCECLI_DEBUG_DVALUE("CMceRtpSink::HandleEvent, Exit. status", status ); |
|
281 |
|
282 return status; |
|
283 |
|
284 } |