|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: THIS FILE IS A PROTOTYPE AND IS NOT MEANT TO BE USED IN PRODUCTION CODE |
|
14 // |
|
15 // |
|
16 |
|
17 #include "rtpapi.h" |
|
18 #include "rtpmanager.h" |
|
19 |
|
20 /** |
|
21 * Two-phased constructor. |
|
22 */ |
|
23 EXPORT_C CRtpAPI* CRtpAPI::NewL( MRtpErrNotify& aErrNotify ) |
|
24 { |
|
25 CRtpAPI *self = new(ELeave) CRtpAPI(); |
|
26 CleanupStack::PushL(self); |
|
27 self->ConstructL(aErrNotify); |
|
28 CleanupStack::Pop(); |
|
29 return self; |
|
30 } |
|
31 |
|
32 CRtpAPI::~CRtpAPI() |
|
33 { |
|
34 delete iManager; |
|
35 } |
|
36 |
|
37 EXPORT_C TInt CRtpAPI::OpenL( const TRtpSdesParams& aSdesInfo, |
|
38 const TDesC* aRtpPacketDll, |
|
39 const RSocketServ* aSocketServPtr, |
|
40 const RConnection* aConnPtr ) |
|
41 { |
|
42 return iManager->OpenL(aSdesInfo,aRtpPacketDll, aSocketServPtr, aConnPtr); |
|
43 } |
|
44 |
|
45 |
|
46 EXPORT_C TInt CRtpAPI::StartConnection( TInt aIapId ) |
|
47 { |
|
48 return iManager->StartConnection(aIapId); |
|
49 } |
|
50 |
|
51 |
|
52 EXPORT_C TInt CRtpAPI::StartConnection( TRequestStatus& aStatus,TInt aIapId ) |
|
53 { |
|
54 return iManager->StartConnection(aStatus, aIapId); |
|
55 } |
|
56 |
|
57 /** |
|
58 * Cancels asynchoronous start of connection. |
|
59 * Any open requests will be completed with KErrCancel. |
|
60 * @return None |
|
61 */ |
|
62 EXPORT_C void CRtpAPI::CancelStart() |
|
63 { |
|
64 iManager->CancelStart(); |
|
65 return; |
|
66 } |
|
67 |
|
68 /** |
|
69 * Close the CRtpAPI object. |
|
70 */ |
|
71 EXPORT_C void CRtpAPI::Close() |
|
72 { |
|
73 iManager->Close(); |
|
74 return; |
|
75 } |
|
76 |
|
77 /** |
|
78 * Set SDES (Source Description) information of the local participant. |
|
79 * Participant is defined as an application program and |
|
80 * only one local participant is allowed. |
|
81 */ |
|
82 EXPORT_C void CRtpAPI::SetLocalSdes( const TRtpSdesParams& aSdesInfo ) |
|
83 { |
|
84 iManager->SetLocalSdes(aSdesInfo); |
|
85 } |
|
86 |
|
87 /** |
|
88 * Get the local IP address |
|
89 * @param None |
|
90 * @return local ip address. |
|
91 */ |
|
92 EXPORT_C TInetAddr& CRtpAPI::GetLocalIPAddressL() |
|
93 { |
|
94 return iManager->GetLocalIPAddressL(); |
|
95 } |
|
96 |
|
97 /** |
|
98 * Create a new RTP Session and return the Session ID as well as the |
|
99 * local port number assigned for RTP. RTP uses an even port number and |
|
100 * RTCP, if enabled, uses the next higher (odd) port number. |
|
101 */ |
|
102 EXPORT_C TRtpId CRtpAPI::CreateSessionL(const TCreateSessionParams& aSessionParams, |
|
103 TUint& aPort, |
|
104 TBool aEnableRtcp, |
|
105 const TRtcpParams* aRtcpParams ) |
|
106 { |
|
107 return iManager->CreateSessionL(aSessionParams, aPort, aEnableRtcp, aRtcpParams); |
|
108 } |
|
109 /** |
|
110 * Create a new, secure RTP Session and return the Session ID as well as the |
|
111 * local port number assigned for RTP. RTP uses an even port number and |
|
112 * RTCP, if enabled, uses the next higher (odd) port number. |
|
113 * User is expected to create corresponding SRTP session prior to calling this |
|
114 * function. |
|
115 */ |
|
116 |
|
117 EXPORT_C TRtpId CRtpAPI::CreateSessionL( |
|
118 const TCreateSessionParams& aSessionParams, |
|
119 TUint& aPort, |
|
120 TBool aEnableRtcp, |
|
121 const TRtcpParams* aRtcpParams, |
|
122 CSRTPSession& aSession) |
|
123 { |
|
124 return iManager->CreateSessionL(aSessionParams, aPort, aEnableRtcp, aRtcpParams, aSession); |
|
125 } |
|
126 |
|
127 |
|
128 /** |
|
129 * Start an RTP Session. If enabled, RTCP associated with the given |
|
130 * session is also started. |
|
131 */ |
|
132 EXPORT_C TInt CRtpAPI::StartSession( TRtpId aSessionId ) |
|
133 { |
|
134 return iManager->StartSession(aSessionId); |
|
135 } |
|
136 |
|
137 /** |
|
138 * Close an RTP Session. |
|
139 */ |
|
140 EXPORT_C void CRtpAPI::CloseSession( TRtpId aSessionId ) |
|
141 { |
|
142 iManager->CloseSession(aSessionId); |
|
143 return; |
|
144 } |
|
145 |
|
146 /** |
|
147 * Set remote IP address and port number to RTP Session. |
|
148 * Port number for RTP must be an even number and the corresponding |
|
149 * RTCP, if enabled, will be set to use the next higher (odd) port. |
|
150 */ |
|
151 EXPORT_C TInt CRtpAPI::SetRemoteAddress( TRtpId aSessionId,const TInetAddr& aRemoteAddr ) |
|
152 { |
|
153 return iManager->SetRemoteAddress(aSessionId, aRemoteAddr); |
|
154 } |
|
155 |
|
156 /** |
|
157 * Set remote RTCP IP address and port number to RTP Session accoring to RFC 3605 |
|
158 * i.e. this should be used if RTCP port is different than RTP port + 1 |
|
159 */ |
|
160 EXPORT_C TInt CRtpAPI::SetRemoteRtcpAddress( TRtpId aSessionId, const TInetAddr& aRemoteRtcpAddr ) |
|
161 { |
|
162 return iManager->SetRemoteRtcpAddress(aSessionId, aRemoteRtcpAddr); |
|
163 } |
|
164 |
|
165 /** |
|
166 * Create a Receive stream for an RTP Session and return the stream |
|
167 * ID which is unique for all RTP Sessions. |
|
168 */ |
|
169 EXPORT_C TRtpId CRtpAPI::CreateReceiveStreamL( TRtpId aSessionId,const TRcvStreamParams& aParams ) |
|
170 { |
|
171 return iManager->CreateReceiveStreamL(aSessionId, aParams); |
|
172 } |
|
173 |
|
174 /** |
|
175 * Create a Transmit stream for an RTP Session and return the stream |
|
176 * ID which is unique for all RTP Sessions. SSRC value assigned for the |
|
177 * very first Transmit stream will be the same as the default SSRC |
|
178 * value reserved internally by CreateSession function. This function |
|
179 * is normally used to create a transmit stream where SSRC value is |
|
180 * randomly generated. |
|
181 */ |
|
182 EXPORT_C TRtpId CRtpAPI::CreateTransmitStreamL( TRtpId aSessionId, const TTranStreamParams& aParams, TRtpSSRC& aSSRC ) |
|
183 { |
|
184 return iManager->CreateTransmitStreamL(aSessionId,aParams,aSSRC); |
|
185 } |
|
186 |
|
187 /** |
|
188 * Create a Transmit stream, with a given SSRC value, for an RTP Session |
|
189 * and return the stream ID which is unique for all RTP Sessions. This |
|
190 * extended function is used for a special case where a specific SSRC |
|
191 * value needs to be associated with the transmit stream being created, |
|
192 * e.g. for retransmission purpose. |
|
193 */ |
|
194 EXPORT_C TRtpId CRtpAPI::CreateTransmitStreamExtL( TRtpId aSessionId, const TTranStreamParams& aParams, const TRtpSSRC aSSRC ) |
|
195 { |
|
196 return iManager->CreateTransmitStreamExtL(aSessionId, aParams, aSSRC); |
|
197 } |
|
198 |
|
199 /** |
|
200 * Close a Transmit or Receive stream. |
|
201 */ |
|
202 EXPORT_C void CRtpAPI::CloseStream( TRtpId aStreamId ) |
|
203 { |
|
204 iManager->CloseStream(aStreamId); |
|
205 return; |
|
206 } |
|
207 |
|
208 /** |
|
209 * Register a callback object for receiving RTP data packets from an RTP |
|
210 * Session. Only one receiver callback object is allowed to be |
|
211 * registered for one Session. |
|
212 * MRtpObserver::RtpPacketReceived function from aRtpObserver object is |
|
213 * called when an RTP data packet is received. |
|
214 */ |
|
215 EXPORT_C TInt CRtpAPI::RegisterRtpObserver( TRtpId aSessionId, MRtpObserver& aRtpObserver ) |
|
216 { |
|
217 return iManager->RegisterRtpObserver(aSessionId, aRtpObserver); |
|
218 } |
|
219 |
|
220 /** |
|
221 * Unregister RTP observer callback object associated with an RTP |
|
222 * session. |
|
223 */ |
|
224 EXPORT_C void CRtpAPI::UnregisterRtpObserver( TRtpId aSessionId ) |
|
225 { |
|
226 iManager->UnregisterRtpObserver(aSessionId); |
|
227 } |
|
228 |
|
229 /** |
|
230 * Sets/resets the observer for the non-RTP data. |
|
231 * Only one receiver callback object is allowed to be |
|
232 * registered for one Session. |
|
233 */ |
|
234 EXPORT_C TInt CRtpAPI::SetNonRTPDataObserver( TRtpId aSessionId, MNonRTPDataObserver* aNonRTPDataObserver ) |
|
235 { |
|
236 return iManager->SetNonRTPDataObserver(aSessionId, aNonRTPDataObserver); |
|
237 } |
|
238 |
|
239 /** |
|
240 * Send an RTP data packet in a Transmit stream synchronously. |
|
241 */ |
|
242 EXPORT_C TInt CRtpAPI::SendRtpPacket( TRtpId aTranStreamId, const TRtpSendHeader& aHeaderInfo, |
|
243 const TDesC8& aPayloadData ) |
|
244 { |
|
245 return iManager->SendRtpPacket(aTranStreamId, aHeaderInfo, aPayloadData); |
|
246 } |
|
247 |
|
248 /** |
|
249 * Send an RTP data packet in a Transmit stream asynchronously. |
|
250 */ |
|
251 EXPORT_C TInt CRtpAPI::SendRtpPacket( TRtpId aTranStreamId, const TRtpSendHeader& aHeaderInfo, const TDesC8& aPayloadData, |
|
252 TRequestStatus& aStatus ) |
|
253 { |
|
254 return iManager->SendRtpPacket(aTranStreamId, aHeaderInfo, aPayloadData, aStatus); |
|
255 } |
|
256 |
|
257 /** |
|
258 * Send an RTP data packet asynchronously, with a given sequence number, |
|
259 * in a Transmit stream mainly for retransmission purpose. |
|
260 */ |
|
261 EXPORT_C TInt CRtpAPI::SendRtpPacket( TRtpId aTranStreamId, TRtpSequence aSequenceNum, const TRtpSendHeader& aHeaderInfo, |
|
262 const TDesC8& aPayloadData, TRequestStatus& aStatus ) |
|
263 { |
|
264 return iManager->SendRtpPacket(aTranStreamId, aSequenceNum, aHeaderInfo, aPayloadData, aStatus); |
|
265 } |
|
266 |
|
267 |
|
268 /** |
|
269 * Send a non-RTP (control) data packet asynchronously |
|
270 */ |
|
271 EXPORT_C void CRtpAPI::SendDataL( TRtpId aSessionId, TBool aUseRTPSocket, const TDesC8& aData, TRequestStatus& aStatus ) |
|
272 { |
|
273 iManager->SendDataL(aSessionId, aUseRTPSocket, aData, aStatus); |
|
274 } |
|
275 |
|
276 /** |
|
277 * Cancel an outstanding SendRtpPacket() operation. |
|
278 */ |
|
279 EXPORT_C void CRtpAPI::CancelSend( TRtpId aSessionId ) |
|
280 { |
|
281 iManager->CancelSend(aSessionId); |
|
282 return; |
|
283 } |
|
284 |
|
285 /** |
|
286 * Register a callback object for receiving RTCP packets associated with |
|
287 * a given RTP Session. Only one observer callback object is allowed to |
|
288 * be registered. One of aRtcpObserver object's callback functions is |
|
289 * called when an RTCP packet of that type is received. |
|
290 */ |
|
291 EXPORT_C TInt CRtpAPI::RegisterRtcpObserver( TRtpId aSessionId, MRtcpObserver& aRtcpObserver ) |
|
292 { |
|
293 return iManager->RegisterRtcpObserver(aSessionId, aRtcpObserver); |
|
294 } |
|
295 |
|
296 /** |
|
297 * Unregister RTCP observer callback object associated with an RTP |
|
298 * session. |
|
299 */ |
|
300 EXPORT_C void CRtpAPI::UnregisterRtcpObserver( TRtpId aSessionId ) |
|
301 { |
|
302 iManager->UnregisterRtcpObserver(aSessionId); |
|
303 return; |
|
304 } |
|
305 |
|
306 /** |
|
307 * Send an RTCP BYE packet for a Transmit stream. |
|
308 */ |
|
309 EXPORT_C TInt CRtpAPI::SendRtcpByePacket( TRtpId aTranStreamId, const TDesC8& aReason ) |
|
310 { |
|
311 return iManager->SendRtcpByePacket(aTranStreamId, aReason); |
|
312 } |
|
313 |
|
314 /** |
|
315 * Send an RTCP APP packet for a Transmit stream. |
|
316 */ |
|
317 EXPORT_C TInt CRtpAPI::SendRtcpAppPacket( TRtpId aTranStreamId, const TRtcpApp& aApp ) |
|
318 { |
|
319 return iManager->SendRtcpAppPacket(aTranStreamId, aApp); |
|
320 } |
|
321 |
|
322 /** |
|
323 * Send an RTCP RR packet for a Reception stream. |
|
324 */ |
|
325 EXPORT_C TInt CRtpAPI::SendRtcpRrPacket( TRtpId aRcvStreamId ) |
|
326 { |
|
327 return iManager->SendRtcpRrPacket(aRcvStreamId); |
|
328 } |
|
329 |
|
330 /** |
|
331 * Send an RTCP SR packet for a Transmit stream. |
|
332 */ |
|
333 EXPORT_C TInt CRtpAPI::SendRtcpSrPacket( TRtpId aTranStreamId ) |
|
334 { |
|
335 return iManager->SendRtcpSrPacket(aTranStreamId); |
|
336 } |
|
337 |
|
338 /** |
|
339 * Suspend RTCP sending on/off, calculations will continue. |
|
340 */ |
|
341 EXPORT_C TInt CRtpAPI::SuspendRtcpSending( TRtpId aSessionId, TBool aAutoSending ) |
|
342 { |
|
343 return iManager->SuspendRtcpSending(aSessionId, aAutoSending); |
|
344 } |
|
345 |
|
346 /** |
|
347 * Gets the status of automatic RTCP sending. |
|
348 */ |
|
349 EXPORT_C TInt CRtpAPI::IsRtcpSendingSuspended( TRtpId aSessionId, TBool& aAutoSending ) |
|
350 { |
|
351 return iManager->IsRtcpSendingSuspended(aSessionId, aAutoSending); |
|
352 } |
|
353 |
|
354 /** |
|
355 * Get the session ID of a stream, which belongs to that session. |
|
356 */ |
|
357 EXPORT_C TRtpId CRtpAPI::GetSessionId( TRtpId aStreamId ) |
|
358 { |
|
359 return iManager->GetSessionId(aStreamId); |
|
360 } |
|
361 |
|
362 /** |
|
363 * Get address of Socket object used by a given RTP Session |
|
364 * to send/receive RTP data packets. |
|
365 */ |
|
366 EXPORT_C RSocket* CRtpAPI::GetRtpSocket( TRtpId aSessionId ) |
|
367 { |
|
368 return iManager->GetRtpSocket(aSessionId); |
|
369 } |
|
370 |
|
371 /** |
|
372 * Get address of Socket object used by a given RTP Session |
|
373 * to send/receive RTCP control packets. |
|
374 */ |
|
375 EXPORT_C RSocket* CRtpAPI::GetRtcpSocket( TRtpId aSessionId ) |
|
376 { |
|
377 return iManager->GetRtcpSocket(aSessionId); |
|
378 } |
|
379 |
|
380 /** |
|
381 * Retrieve statistical information for a stream |
|
382 * based on the reports from RTCP SR & RR packets. |
|
383 */ |
|
384 EXPORT_C TInt CRtpAPI::GetStreamStatistics( TRtpId aStreamId, TRtpPeerStat& aStat ) |
|
385 { |
|
386 return iManager->GetStreamStatistics(aStreamId, aStat); |
|
387 } |
|
388 |
|
389 /** |
|
390 * Get sampling rate setting for a payload type. |
|
391 */ |
|
392 EXPORT_C TUint32 CRtpAPI::GetSamplingRate( TUint8 aPayloadType ) |
|
393 { |
|
394 return iManager->GetSamplingRate(aPayloadType); |
|
395 } |
|
396 |
|
397 /** |
|
398 * Set sampling rate for a payload type. |
|
399 */ |
|
400 EXPORT_C TInt CRtpAPI::SetSamplingRate( TUint8 aPayloadType, TUint32 aSamplingRate ) |
|
401 { |
|
402 return iManager->SetSamplingRate(aPayloadType, aSamplingRate); |
|
403 } |
|
404 |
|
405 /** |
|
406 * Set RTCP parameters for a given RTP Session. |
|
407 * This function does nothing if RTCP was not enabled previously. |
|
408 */ |
|
409 EXPORT_C TInt CRtpAPI::SetRtcpParameters( TRtpId aSessionId, const TRtcpParams& aRtcpParams ) |
|
410 { |
|
411 return iManager->SetRtcpParameters(aSessionId, aRtcpParams); |
|
412 } |
|
413 |
|
414 /** |
|
415 * Synchronous custom command interface for future extensions. |
|
416 * Input/output data and return value are defined by each custom command |
|
417 */ |
|
418 EXPORT_C TInt CRtpAPI::CustomCommandSync( TInt aFunction, const TDesC8& aInputData1, const TDesC8& aInputData2, |
|
419 TDes8& aOutputData ) |
|
420 { |
|
421 return iManager->CustomCommandSync(aFunction, aInputData1, aInputData2, aOutputData); |
|
422 } |
|
423 |
|
424 /** |
|
425 * ASynchronous custom command interface for future extensions. |
|
426 * Input/output data and return value are defined by each custom command |
|
427 */ |
|
428 EXPORT_C TInt CRtpAPI::CustomCommandAsync( TInt aFunction, const TDesC8& aInputData1, const TDesC8& aInputData2, TDes8& aOutputData, |
|
429 TRequestStatus& aStatus ) |
|
430 { |
|
431 return iManager->CustomCommandAsync(aFunction, aInputData1, aInputData2, aOutputData, aStatus); |
|
432 } |
|
433 /** |
|
434 * Version of RtpService.dll |
|
435 * @return Version of current RtpService.dll |
|
436 */ |
|
437 EXPORT_C TVersion CRtpAPI::Version() const |
|
438 { |
|
439 return TVersion(0,1,1008); |
|
440 } |
|
441 |
|
442 |
|
443 /** |
|
444 * C++ default constructor. |
|
445 */ |
|
446 CRtpAPI::CRtpAPI() |
|
447 { |
|
448 } |
|
449 |
|
450 /** |
|
451 * By default Symbian 2nd phase constructor is private. |
|
452 */ |
|
453 void CRtpAPI::ConstructL( MRtpErrNotify& aErrNotify ) |
|
454 { |
|
455 iManager = CRtpManager::NewL(aErrNotify); |
|
456 } |
|
457 |