|
1 /* |
|
2 * Copyright (c) 2008 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 RTP observation class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "svprtpobserver.h" |
|
20 #include "svprtpobserverrequest.h" |
|
21 #include "svpsessionbase.h" |
|
22 #include "svplogger.h" |
|
23 |
|
24 // --------------------------------------------------------------------------- |
|
25 // CSVPRtpObserver::CSVPRtpObserver |
|
26 // --------------------------------------------------------------------------- |
|
27 // |
|
28 CSVPRtpObserver::CSVPRtpObserver() |
|
29 { |
|
30 // No implementation required |
|
31 } |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // CSVPRtpObserver::~CSVPRtpObserver |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CSVPRtpObserver::~CSVPRtpObserver() |
|
38 { |
|
39 iRequestArray.ResetAndDestroy(); |
|
40 iRequestArray.Close(); |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // CSVPRtpObserver::NewLC |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 CSVPRtpObserver* CSVPRtpObserver::NewLC() |
|
48 { |
|
49 CSVPRtpObserver* self = new ( ELeave ) CSVPRtpObserver(); |
|
50 CleanupStack::PushL( self ); |
|
51 return self; |
|
52 } |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // CSVPRtpObserver::NewL |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 CSVPRtpObserver* CSVPRtpObserver::NewL() |
|
59 { |
|
60 CSVPRtpObserver* self = CSVPRtpObserver::NewLC(); |
|
61 CleanupStack::Pop( self ); |
|
62 return self; |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // CSVPRtpObserver::SRReceived |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 void CSVPRtpObserver::SRReceived( CMceSession& aSession, |
|
70 CMceMediaStream& aStream ) |
|
71 { |
|
72 SVPDEBUG1( "CSVPRtpObserver::SRReceived" ) |
|
73 |
|
74 CSVPRtpObserverRequest* assocReq = FindByMceSession( &aSession ); |
|
75 if ( assocReq ) |
|
76 { |
|
77 assocReq->RtcpPacketReceived( |
|
78 CSVPRtpObserverRequest::ERtcpSrPacket, aSession, aStream ); |
|
79 } |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CSVPRtpObserver::RRReceived |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 void CSVPRtpObserver::RRReceived( CMceSession& aSession, |
|
87 CMceMediaStream& aStream ) |
|
88 { |
|
89 SVPDEBUG1( "CSVPRtpObserver::RRReceived" ) |
|
90 |
|
91 CSVPRtpObserverRequest* assocReq = FindByMceSession( &aSession ); |
|
92 if ( assocReq ) |
|
93 { |
|
94 assocReq->RtcpPacketReceived( |
|
95 CSVPRtpObserverRequest::ERtcpRrPacket, aSession, aStream ); |
|
96 } |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // CSVPRtpObserver::InactivityTimeout |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 void CSVPRtpObserver::InactivityTimeout( CMceMediaStream& /*aStream*/, |
|
104 CMceRtpSource& /*aSource*/ ) |
|
105 { |
|
106 SVPDEBUG1( "CSVPRtpObserver::InactivityTimeout" ) |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // CSVPRtpObserver::SsrcAdded |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 void CSVPRtpObserver::SsrcAdded( CMceMediaStream& /*aStream*/, |
|
114 CMceRtpSource& /*aSource*/, TUint /*aSsrc*/ ) |
|
115 { |
|
116 SVPDEBUG1( "CSVPRtpObserver::SsrcAdded" ) |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // CSVPRtpObserver::SsrcRemoved |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 void CSVPRtpObserver::SsrcRemoved( CMceMediaStream& /*aStream*/, |
|
124 CMceRtpSource& /*aSource*/, TUint /*aSsrc*/ ) |
|
125 { |
|
126 SVPDEBUG1( "CSVPRtpObserver::SsrcRemoved" ) |
|
127 } |
|
128 |
|
129 // --------------------------------------------------------------------------- |
|
130 // CSVPRtpObserver::AddSessionForObservingL |
|
131 // --------------------------------------------------------------------------- |
|
132 // |
|
133 void CSVPRtpObserver::AddSessionForObservingL( CSVPSessionBase* aSession ) |
|
134 { |
|
135 SVPDEBUG2( "CSVPRtpObserver::AddSessionForObservingL aSession: 0x%x", |
|
136 aSession ) |
|
137 |
|
138 __ASSERT_ALWAYS( aSession, User::Leave( KErrArgument ) ); |
|
139 __ASSERT_ALWAYS( !FindBySvpSession( aSession ), |
|
140 User::Leave( KErrAlreadyExists ) ); |
|
141 |
|
142 CSVPRtpObserverRequest* req = CSVPRtpObserverRequest::NewLC( *aSession ); |
|
143 iRequestArray.AppendL( req ); |
|
144 CleanupStack::Pop( req ); |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------------------------- |
|
148 // CSVPRtpObserver::RemoveSessionFromObserving |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 TInt CSVPRtpObserver::RemoveSessionFromObserving( CSVPSessionBase* aSession ) |
|
152 { |
|
153 SVPDEBUG2( "CSVPRtpObserver::RemoveSessionFromObserving aSession: 0x%x", |
|
154 aSession ) |
|
155 |
|
156 TInt ret = KErrNone; |
|
157 if ( !aSession ) |
|
158 { |
|
159 ret = KErrArgument; |
|
160 } |
|
161 else |
|
162 { |
|
163 CSVPRtpObserverRequest* todel = FindBySvpSession( aSession ); |
|
164 if ( todel ) |
|
165 { |
|
166 TInt index = iRequestArray.Find( todel ); |
|
167 iRequestArray.Remove( index ); |
|
168 delete todel; |
|
169 } |
|
170 else |
|
171 { |
|
172 ret = KErrNotFound; |
|
173 } |
|
174 } |
|
175 |
|
176 SVPDEBUG2( "CSVPRtpObserver::RemoveSessionFromObserving ret: %d", ret ) |
|
177 |
|
178 return ret; |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------------------------- |
|
182 // CSVPRtpObserver::ResetSessionInObserving |
|
183 // --------------------------------------------------------------------------- |
|
184 // |
|
185 TInt CSVPRtpObserver::ResetSessionInObserving( CSVPSessionBase* aSession ) |
|
186 { |
|
187 SVPDEBUG2( "CSVPRtpObserver::ResetSessionInObserving aSession: 0x%x", |
|
188 aSession ) |
|
189 |
|
190 TInt ret = KErrNone; |
|
191 if ( !aSession ) |
|
192 { |
|
193 ret = KErrArgument; |
|
194 } |
|
195 else |
|
196 { |
|
197 CSVPRtpObserverRequest* toreset = FindBySvpSession( aSession ); |
|
198 if ( toreset ) |
|
199 { |
|
200 toreset->Reset(); |
|
201 } |
|
202 else |
|
203 { |
|
204 ret = KErrNotFound; |
|
205 } |
|
206 } |
|
207 |
|
208 SVPDEBUG2( "CSVPRtpObserver::ResetSessionInObserving ret: %d", ret ) |
|
209 |
|
210 return ret; |
|
211 } |
|
212 |
|
213 // --------------------------------------------------------------------------- |
|
214 // CSVPRtpObserver::FindBySvpSession |
|
215 // --------------------------------------------------------------------------- |
|
216 // |
|
217 CSVPRtpObserverRequest* CSVPRtpObserver::FindBySvpSession( |
|
218 const CSVPSessionBase* aSession ) |
|
219 { |
|
220 TInt count = iRequestArray.Count(); |
|
221 CSVPRtpObserverRequest* ret( NULL ); |
|
222 while( count-- && !ret && aSession ) |
|
223 { |
|
224 if ( aSession == iRequestArray[count]->SvpSession() ) |
|
225 { |
|
226 ret = iRequestArray[count]; |
|
227 } |
|
228 } |
|
229 |
|
230 SVPDEBUG2( "CSVPRtpObserver::FindBySvpSession ret: 0x%x", ret ) |
|
231 |
|
232 return ret; |
|
233 } |
|
234 |
|
235 // --------------------------------------------------------------------------- |
|
236 // CSVPRtpObserver::FindByMceSession |
|
237 // --------------------------------------------------------------------------- |
|
238 // |
|
239 CSVPRtpObserverRequest* CSVPRtpObserver::FindByMceSession( |
|
240 const CMceSession* aSession ) |
|
241 { |
|
242 TInt count = iRequestArray.Count(); |
|
243 CSVPRtpObserverRequest* ret( NULL ); |
|
244 while( count-- && !ret && aSession ) |
|
245 { |
|
246 if ( aSession == iRequestArray[count]->MceSession() ) |
|
247 { |
|
248 ret = iRequestArray[count]; |
|
249 } |
|
250 } |
|
251 |
|
252 SVPDEBUG2( "CSVPRtpObserver::FindByMceSession ret: 0x%x", ret ) |
|
253 |
|
254 return ret; |
|
255 } |