1
/* $Id: transport.h 4345 2013-02-13 07:43:32Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
#ifndef __PJMEDIA_TRANSPORT_H__
21
#define __PJMEDIA_TRANSPORT_H__
25
* @file transport.h Media Transport Interface
26
* @brief Transport interface.
29
#include <pjmedia/types.h>
30
#include <pjmedia/errno.h>
31
#include <pj/string.h>
34
* @defgroup PJMEDIA_TRANSPORT Media Transport
37
* The media transport (#pjmedia_transport) is the object to send and
38
* receive media packets over the network. The media transport interface
39
* allows the library to be extended to support different types of
40
* transports to send and receive packets.
42
* The media transport is declared as #pjmedia_transport "class", which
43
* declares "interfaces" to use the class in #pjmedia_transport_op
44
* structure. For the user of the media transport (normally the user of
45
* media transport is media stream, see \ref PJMED_STRM), these transport
46
* "methods" are wrapped with API such as #pjmedia_transport_attach(),
47
* so it should not need to call the function pointer inside
48
* #pjmedia_transport_op directly.
50
* The connection between \ref PJMED_STRM and media transport is shown in
53
\image html media-transport.PNG
56
* \section PJMEDIA_TRANSPORT_H_USING Basic Media Transport Usage
58
* The media transport's life-cycle normally follows the following stages.
60
* \subsection PJMEDIA_TRANSPORT_H_CREATE Creating the Media Transport
62
* Application creates the media transport when it needs to establish
63
* media session to remote peer. The media transport is created using
64
* specific function to create that particular transport; for example,
65
* for UDP media transport, it is created with #pjmedia_transport_udp_create()
66
* or #pjmedia_transport_udp_create2() functions. Different media
67
* transports will provide different API to create those transports.
69
* Alternatively, application may create pool of media transports when
70
* it is first started up. Using this approach probably is better, since
71
* application has to specify the RTP port when sending the initial
72
* session establishment request (e.g. SIP INVITE request), thus if
73
* application only creates the media transport later when media is to be
74
* established (normally when 200/OK is received, or when 18x is received
75
* for early media), there is a possibility that the particular RTP
76
* port might have been occupied by other programs. Also it is more
77
* efficient since sockets don't need to be closed and re-opened between
81
* \subsection PJMEDIA_TRANSPORT_H_ATTACH Attaching and Using the Media Transport.
83
* Application specifies the media transport instance when creating
84
* the media session (#pjmedia_session_create()). Alternatively, it
85
* may create the media stream directly with #pjmedia_stream_create()
86
* and specify the transport instance in the argument. (Note: media
87
* session is a high-level abstraction for media communications between
88
* two endpoints, and it may contain more than one media streams, for
89
* example, an audio stream and a video stream).
91
* When stream is created, it will "attach" itself to the media
92
* transport by calling #pjmedia_transport_attach(), which is a thin
93
* wrapper which calls "attach()" method of the media transport's
94
* "virtual function pointer" (#pjmedia_transport_op). Among other things,
95
* the stream specifies two callback functions to the transport: one
96
* callback function will be called by transport when it receives RTP
97
* packet, and another callback for incoming RTCP packet. The
98
* #pjmedia_transport_attach() function also establish the destination
99
* of the outgoing RTP and RTCP packets.
101
* When the stream needs to send outgoing RTP/RTCP packets, it will
102
* call #pjmedia_transport_send_rtp() and #pjmedia_transport_send_rtcp()
103
* of the media transport API, which is a thin wrapper to call send_rtp()
104
* and send_rtcp() methods in the media transport's "virtual function
105
* pointer" (#pjmedia_transport_op).
107
* When the stream is destroyed, it will "detach" itself from
108
* the media transport by calling #pjmedia_transport_detach(), which is
109
* a thin wrapper which calls "detach()" method of the media transport's
110
* "virtual function pointer" (#pjmedia_transport_op). After the transport
111
* is detached from its user (the stream), it will no longer report
112
* incoming RTP/RTCP packets to the stream, and it will refuse to send
113
* outgoing packets since the destination has been cleared.
116
* \subsection PJMEDIA_TRANSPORT_H_REUSE Reusing the Media Transport.
118
* After transport has been detached, application may re-attach the
119
* transport to another stream if it wants to. Detaching and re-attaching
120
* media transport may be preferable than closing and re-opening the
121
* transport, since it is more efficient (sockets don't need to be
122
* closed and re-opened). However it is up to the application to choose
123
* which method is most suitable for its uses.
126
* \subsection PJMEDIA_TRANSPORT_H_DESTROY Destroying the Media Transport.
128
* Finally if application no longer needs the media transport, it will
129
* call #pjmedia_transport_close() function, which is thin wrapper which
130
* calls "destroy()" method of the media transport's "virtual function
131
* pointer" (#pjmedia_transport_op). This function releases
132
* all resources used by the transport, such as sockets and memory.
135
* \section offer_answer Interaction with SDP Offer/Answer
137
For basic UDP transport, the \ref PJMEDIA_TRANSPORT_H_USING above is
138
sufficient to use the media transport. However, more complex media
139
transports such as \ref PJMEDIA_TRANSPORT_SRTP and \ref
140
PJMEDIA_TRANSPORT_ICE requires closer interactions with SDP offer and
143
The media transports can interact with the SDP offer/answer via
145
- #pjmedia_transport_media_create(), to initialize the media transport
146
for new media session,
147
- #pjmedia_transport_encode_sdp(), to encode SDP offer or answer,
148
- #pjmedia_transport_media_start(), to activate the settings that
149
have been negotiated by SDP offer answer, and
150
- #pjmedia_transport_media_stop(), to deinitialize the media transport
151
and reset the transport to its idle state.
153
The usage of these API in the context of SDP offer answer will be
156
\subsection media_create Initializing Transport for New Session
158
Application must call #pjmedia_transport_media_create() before using
159
the transport for a new session.
161
\subsection creat_oa Creating SDP Offer and Answer
163
The #pjmedia_transport_encode_sdp() is used to put additional information
164
from the transport to the local SDP, before the SDP is sent and negotiated
167
When creating an offer, call #pjmedia_transport_encode_sdp() with
168
local SDP (and NULL as \a rem_sdp). The media transport will add the
169
relevant attributes in the local SDP. Application then gives the local
170
SDP to the invite session to be sent to remote agent.
172
When creating an answer, also call #pjmedia_transport_encode_sdp(),
173
but this time specify both local and remote SDP to the function. The
174
media transport will once again modify the local SDP and add relevant
175
attributes to the local SDP, if the appropriate attributes related to
176
the transport functionality are present in remote offer. The remote
177
SDP does not contain the relevant attributes, then the specific transport
178
functionality will not be activated for the session.
180
The #pjmedia_transport_encode_sdp() should also be called when application
181
sends subsequent SDP offer or answer. The media transport will encode
182
the appropriate attributes based on the state of the session.
184
\subsection media_start Offer/Answer Completion
186
Once both local and remote SDP have been negotiated by the
187
\ref PJMEDIA_SDP_NEG (normally this is part of PJSIP invite session),
188
application should give both local and remote SDP to
189
#pjmedia_transport_media_start() so that the settings are activated
190
for the session. This function should be called for both initial and
191
subsequent SDP negotiation.
193
\subsection media_stop Stopping Transport
195
Once session is stop application must call #pjmedia_transport_media_stop()
196
to deactivate the transport feature. Application may reuse the transport
197
for subsequent media session by repeating the #pjmedia_transport_media_create(),
198
#pjmedia_transport_encode_sdp(), #pjmedia_transport_media_start(), and
199
#pjmedia_transport_media_stop() above.
201
* \section PJMEDIA_TRANSPORT_H_IMPL Implementing Media Transport
203
* To implement a new type of media transport, one needs to "subclass" the
204
* media transport "class" (#pjmedia_transport) by providing the "methods"
205
* in the media transport "interface" (#pjmedia_transport_op), and provides
206
* a function to create this new type of transport (similar to
207
* #pjmedia_transport_udp_create() function).
209
* The media transport is expected to run indepently, that is there should
210
* be no polling like function to poll the transport for incoming RTP/RTCP
211
* packets. This normally can be done by registering the media sockets to
212
* the media endpoint's IOQueue, which allows the transport to be notified
213
* when incoming packet has arrived.
215
* Alternatively, media transport may utilize thread(s) internally to wait
216
* for incoming packets. The thread then will call the appropriate RTP or
217
* RTCP callback provided by its user (stream) whenever packet is received.
218
* If the transport's user is a stream, then the callbacks provided by the
219
* stream will be thread-safe, so the transport may call these callbacks
220
* without having to serialize the access with some mutex protection. But
221
* the media transport may still have to protect its internal data with
222
* mutex protection, since it may be called by application's thread (for
223
* example, to send RTP/RTCP packets).
228
#include <pjmedia/sdp.h>
234
* Forward declaration for media transport.
236
typedef struct pjmedia_transport pjmedia_transport;
239
* Forward declaration for media transport info.
241
typedef struct pjmedia_transport_info pjmedia_transport_info;
244
* This enumeration specifies the general behaviour of media processing
246
typedef enum pjmedia_tranport_media_option
249
* When this flag is specified, the transport will not perform media
250
* transport validation, this is useful when transport is stacked with
251
* other transport, for example when transport UDP is stacked under
252
* transport SRTP, media transport validation only need to be done by
255
PJMEDIA_TPMED_NO_TRANSPORT_CHECKING = 1
257
} pjmedia_tranport_media_option;
261
* Media socket info is used to describe the underlying sockets
262
* to be used as media transport.
264
typedef struct pjmedia_sock_info
266
/** The RTP socket handle */
269
/** Address to be advertised as the local address for the RTP
270
* socket, which does not need to be equal as the bound
271
* address (for example, this address can be the address resolved
274
pj_sockaddr rtp_addr_name;
276
/** The RTCP socket handle. */
279
/** Address to be advertised as the local address for the RTCP
280
* socket, which does not need to be equal as the bound
281
* address (for example, this address can be the address resolved
284
pj_sockaddr rtcp_addr_name;
290
* This structure describes the operations for the stream transport.
292
struct pjmedia_transport_op
295
* Get media socket info from the specified transport.
297
* Application should call #pjmedia_transport_get_info() instead
299
pj_status_t (*get_info)(pjmedia_transport *tp,
300
pjmedia_transport_info *info);
303
* This function is called by the stream when the transport is about
304
* to be used by the stream for the first time, and it tells the transport
305
* about remote RTP address to send the packet and some callbacks to be
306
* called for incoming packets.
308
* Application should call #pjmedia_transport_attach() instead of
309
* calling this function directly.
311
pj_status_t (*attach)(pjmedia_transport *tp,
313
const pj_sockaddr_t *rem_addr,
314
const pj_sockaddr_t *rem_rtcp,
316
void (*rtp_cb)(void *user_data,
319
void (*rtcp_cb)(void *user_data,
324
* This function is called by the stream when the stream no longer
325
* needs the transport (normally when the stream is about to be closed).
326
* After the transport is detached, it will ignore incoming
327
* RTP/RTCP packets, and will refuse to send outgoing RTP/RTCP packets.
328
* Application may re-attach the media transport to another transport
329
* user (e.g. stream) after the transport has been detached.
331
* Application should call #pjmedia_transport_detach() instead of
332
* calling this function directly.
334
void (*detach)(pjmedia_transport *tp,
338
* This function is called by the stream to send RTP packet using the
341
* Application should call #pjmedia_transport_send_rtp() instead of
342
* calling this function directly.
344
pj_status_t (*send_rtp)(pjmedia_transport *tp,
349
* This function is called by the stream to send RTCP packet using the
352
* Application should call #pjmedia_transport_send_rtcp() instead of
353
* calling this function directly.
355
pj_status_t (*send_rtcp)(pjmedia_transport *tp,
360
* This function is called by the stream to send RTCP packet using the
361
* transport with destination address other than default specified in
362
* #pjmedia_transport_attach().
364
* Application should call #pjmedia_transport_send_rtcp2() instead of
365
* calling this function directly.
367
pj_status_t (*send_rtcp2)(pjmedia_transport *tp,
368
const pj_sockaddr_t *addr,
374
* Prepare the transport for a new media session.
376
* Application should call #pjmedia_transport_media_create() instead of
377
* calling this function directly.
379
pj_status_t (*media_create)(pjmedia_transport *tp,
382
const pjmedia_sdp_session *remote_sdp,
383
unsigned media_index);
386
* This function is called by application to generate the SDP parts
387
* related to transport type, e.g: ICE, SRTP.
389
* Application should call #pjmedia_transport_encode_sdp() instead of
390
* calling this function directly.
392
pj_status_t (*encode_sdp)(pjmedia_transport *tp,
394
pjmedia_sdp_session *sdp_local,
395
const pjmedia_sdp_session *rem_sdp,
396
unsigned media_index);
399
* This function is called by application to start the transport
400
* based on local and remote SDP.
402
* Application should call #pjmedia_transport_media_start() instead of
403
* calling this function directly.
405
pj_status_t (*media_start) (pjmedia_transport *tp,
407
const pjmedia_sdp_session *sdp_local,
408
const pjmedia_sdp_session *sdp_remote,
409
unsigned media_index);
412
* This function is called by application to stop the transport.
414
* Application should call #pjmedia_transport_media_stop() instead of
415
* calling this function directly.
417
pj_status_t (*media_stop) (pjmedia_transport *tp);
420
* This function can be called to simulate packet lost.
422
* Application should call #pjmedia_transport_simulate_lost() instead of
423
* calling this function directly.
425
pj_status_t (*simulate_lost)(pjmedia_transport *tp,
430
* This function can be called to destroy this transport.
432
* Application should call #pjmedia_transport_close() instead of
433
* calling this function directly.
435
pj_status_t (*destroy)(pjmedia_transport *tp);
440
* @see pjmedia_transport_op.
442
typedef struct pjmedia_transport_op pjmedia_transport_op;
446
* Media transport type.
448
typedef enum pjmedia_transport_type
450
/** Media transport using standard UDP */
451
PJMEDIA_TRANSPORT_TYPE_UDP,
453
/** Media transport using ICE */
454
PJMEDIA_TRANSPORT_TYPE_ICE,
457
* Media transport SRTP, this transport is actually security adapter to be
458
* stacked with other transport to enable encryption on the underlying
461
PJMEDIA_TRANSPORT_TYPE_SRTP,
464
* Start of user defined transport.
466
PJMEDIA_TRANSPORT_TYPE_USER
468
} pjmedia_transport_type;
472
* This structure declares media transport. A media transport is called
473
* by the stream to transmit a packet, and will notify stream when
474
* incoming packet is arrived.
476
struct pjmedia_transport
478
/** Transport name (for logging purpose). */
479
char name[PJ_MAX_OBJ_NAME];
481
/** Transport type. */
482
pjmedia_transport_type type;
484
/** Transport's "virtual" function table. */
485
pjmedia_transport_op *op;
487
/** Application/user data */
492
* This structure describes storage buffer of transport specific info.
493
* The actual transport specific info contents will be defined by transport
494
* implementation. Note that some transport implementations do not need to
495
* provide specific info, since the general socket info is enough.
497
typedef struct pjmedia_transport_specific_info
500
* Specify media transport type.
502
pjmedia_transport_type type;
505
* Specify storage buffer size of transport specific info.
510
* Storage buffer of transport specific info.
512
char buffer[PJMEDIA_TRANSPORT_SPECIFIC_INFO_MAXSIZE];
514
} pjmedia_transport_specific_info;
518
* This structure describes transport informations, including general
519
* socket information and specific information of single transport or
520
* stacked transports (e.g: SRTP stacked on top of UDP)
522
struct pjmedia_transport_info
525
* General socket info.
527
pjmedia_sock_info sock_info;
530
* Remote address where RTP/RTCP originated from. In case this transport
531
* hasn't ever received packet, the
533
pj_sockaddr src_rtp_name;
534
pj_sockaddr src_rtcp_name;
537
* Specifies number of transport specific info included.
539
unsigned specific_info_cnt;
542
* Buffer storage of transport specific info.
544
pjmedia_transport_specific_info spc_info[PJMEDIA_TRANSPORT_SPECIFIC_INFO_MAXCNT];
550
* Initialize transport info.
552
* @param info Transport info to be initialized.
554
PJ_INLINE(void) pjmedia_transport_info_init(pjmedia_transport_info *info)
556
pj_bzero(&info->sock_info, sizeof(pjmedia_sock_info));
557
info->sock_info.rtp_sock = info->sock_info.rtcp_sock = PJ_INVALID_SOCKET;
558
info->specific_info_cnt = 0;
563
* Get media transport info from the specified transport and all underlying
564
* transports if any. The transport also contains information about socket info
565
* which describes the local address of the transport, and would be needed
566
* for example to fill in the "c=" and "m=" line of local SDP.
568
* @param tp The transport.
569
* @param info Media transport info to be initialized.
571
* @return PJ_SUCCESS on success.
573
PJ_INLINE(pj_status_t) pjmedia_transport_get_info(pjmedia_transport *tp,
574
pjmedia_transport_info *info)
576
if (tp && tp->op && tp->op->get_info)
577
return (*tp->op->get_info)(tp, info);
584
* Utility API to get transport type specific info from the specified media
587
* @param info Media transport info.
588
* @param type Media transport type.
590
* @return Pointer to media transport specific info, or NULL if
591
* specific info for the transport type is not found.
593
PJ_INLINE(void*) pjmedia_transport_info_get_spc_info(
594
pjmedia_transport_info *info,
595
pjmedia_transport_type type)
598
for (i = 0; i < info->specific_info_cnt; ++i) {
599
if (info->spc_info[i].type == type)
600
return (void*)info->spc_info[i].buffer;
607
* Attach callbacks to be called on receipt of incoming RTP/RTCP packets.
608
* This is just a simple wrapper which calls <tt>attach()</tt> member of
611
* @param tp The media transport.
612
* @param user_data Arbitrary user data to be set when the callbacks are
614
* @param rem_addr Remote RTP address to send RTP packet to.
615
* @param rem_rtcp Optional remote RTCP address. If the argument is NULL
616
* or if the address is zero, the RTCP address will be
617
* calculated from the RTP address (which is RTP port
619
* @param addr_len Length of the remote address.
620
* @param rtp_cb Callback to be called when RTP packet is received on
622
* @param rtcp_cb Callback to be called when RTCP packet is received on
625
* @return PJ_SUCCESS on success, or the appropriate error code.
627
PJ_INLINE(pj_status_t) pjmedia_transport_attach(pjmedia_transport *tp,
629
const pj_sockaddr_t *rem_addr,
630
const pj_sockaddr_t *rem_rtcp,
632
void (*rtp_cb)(void *user_data,
635
void (*rtcp_cb)(void *usr_data,
639
return tp->op->attach(tp, user_data, rem_addr, rem_rtcp, addr_len,
645
* Detach callbacks from the transport.
646
* This is just a simple wrapper which calls <tt>detach()</tt> member of
647
* the transport. After the transport is detached, it will ignore incoming
648
* RTP/RTCP packets, and will refuse to send outgoing RTP/RTCP packets.
649
* Application may re-attach the media transport to another transport user
650
* (e.g. stream) after the transport has been detached.
652
* @param tp The media transport.
653
* @param user_data User data which must match the previously set value
656
PJ_INLINE(void) pjmedia_transport_detach(pjmedia_transport *tp,
659
tp->op->detach(tp, user_data);
664
* Send RTP packet with the specified media transport. This is just a simple
665
* wrapper which calls <tt>send_rtp()</tt> member of the transport. The
666
* RTP packet will be delivered to the destination address specified in
667
* #pjmedia_transport_attach() function.
669
* @param tp The media transport.
670
* @param pkt The packet to send.
671
* @param size Size of the packet.
673
* @return PJ_SUCCESS on success, or the appropriate error code.
675
PJ_INLINE(pj_status_t) pjmedia_transport_send_rtp(pjmedia_transport *tp,
679
return (*tp->op->send_rtp)(tp, pkt, size);
684
* Send RTCP packet with the specified media transport. This is just a simple
685
* wrapper which calls <tt>send_rtcp()</tt> member of the transport. The
686
* RTCP packet will be delivered to the destination address specified in
687
* #pjmedia_transport_attach() function.
689
* @param tp The media transport.
690
* @param pkt The packet to send.
691
* @param size Size of the packet.
693
* @return PJ_SUCCESS on success, or the appropriate error code.
695
PJ_INLINE(pj_status_t) pjmedia_transport_send_rtcp(pjmedia_transport *tp,
699
return (*tp->op->send_rtcp)(tp, pkt, size);
704
* Send RTCP packet with the specified media transport. This is just a simple
705
* wrapper which calls <tt>send_rtcp2()</tt> member of the transport. The
706
* RTCP packet will be delivered to the destination address specified in
707
* param addr, if addr is NULL, RTCP packet will be delivered to destination
708
* address specified in #pjmedia_transport_attach() function.
710
* @param tp The media transport.
711
* @param addr The destination address.
712
* @param addr_len Length of destination address.
713
* @param pkt The packet to send.
714
* @param size Size of the packet.
716
* @return PJ_SUCCESS on success, or the appropriate error code.
718
PJ_INLINE(pj_status_t) pjmedia_transport_send_rtcp2(pjmedia_transport *tp,
719
const pj_sockaddr_t *addr,
724
return (*tp->op->send_rtcp2)(tp, addr, addr_len, pkt, size);
729
* Prepare the media transport for a new media session, Application must
730
* call this function before starting a new media session using this
733
* This is just a simple wrapper which calls <tt>media_create()</tt> member
736
* @param tp The media transport.
737
* @param sdp_pool Pool object to allocate memory related to SDP
738
* messaging components.
739
* @param options Option flags, from #pjmedia_tranport_media_option
740
* @param rem_sdp Remote SDP if local SDP is an answer, otherwise
741
* specify NULL if SDP is an offer.
742
* @param media_index Media index in SDP.
744
* @return PJ_SUCCESS on success, or the appropriate error code.
746
PJ_INLINE(pj_status_t) pjmedia_transport_media_create(pjmedia_transport *tp,
749
const pjmedia_sdp_session *rem_sdp,
750
unsigned media_index)
752
return (*tp->op->media_create)(tp, sdp_pool, options, rem_sdp,
758
* Put transport specific information into the SDP. This function can be
759
* called to put transport specific information in the initial or
760
* subsequent SDP offer or answer.
762
* This is just a simple wrapper which calls <tt>encode_sdp()</tt> member
765
* @param tp The media transport.
766
* @param sdp_pool Pool object to allocate memory related to SDP
767
* messaging components.
768
* @param sdp The local SDP to be filled in information from the
770
* @param rem_sdp Remote SDP if local SDP is an answer, otherwise
771
* specify NULL if SDP is an offer.
772
* @param media_index Media index in SDP.
774
* @return PJ_SUCCESS on success, or the appropriate error code.
776
PJ_INLINE(pj_status_t) pjmedia_transport_encode_sdp(pjmedia_transport *tp,
778
pjmedia_sdp_session *sdp,
779
const pjmedia_sdp_session *rem_sdp,
780
unsigned media_index)
782
return (*tp->op->encode_sdp)(tp, sdp_pool, sdp, rem_sdp, media_index);
787
* Start the transport session with the settings in both local and remote
788
* SDP. The actual work that is done by this function depends on the
789
* underlying transport type. For SRTP, this will activate the encryption
790
* and decryption based on the keys found the SDPs. For ICE, this will
791
* start ICE negotiation according to the information found in the SDPs.
793
* This is just a simple wrapper which calls <tt>media_start()</tt> member
796
* @param tp The media transport.
797
* @param tmp_pool The memory pool for allocating temporary objects.
798
* @param sdp_local Local SDP.
799
* @param sdp_remote Remote SDP.
800
* @param media_index Media index in the SDP.
802
* @return PJ_SUCCESS on success, or the appropriate error code.
804
PJ_INLINE(pj_status_t) pjmedia_transport_media_start(pjmedia_transport *tp,
806
const pjmedia_sdp_session *sdp_local,
807
const pjmedia_sdp_session *sdp_remote,
808
unsigned media_index)
810
return (*tp->op->media_start)(tp, tmp_pool, sdp_local, sdp_remote,
816
* This API should be called when the session is stopped, to allow the media
817
* transport to release its resources used for the session.
819
* This is just a simple wrapper which calls <tt>media_stop()</tt> member
822
* @param tp The media transport.
824
* @return PJ_SUCCESS on success, or the appropriate error code.
826
PJ_INLINE(pj_status_t) pjmedia_transport_media_stop(pjmedia_transport *tp)
828
return (*tp->op->media_stop)(tp);
832
* Close media transport. This is just a simple wrapper which calls
833
* <tt>destroy()</tt> member of the transport. This function will free
834
* all resources created by this transport (such as sockets, memory, etc.).
836
* @param tp The media transport.
838
* @return PJ_SUCCESS on success, or the appropriate error code.
840
PJ_INLINE(pj_status_t) pjmedia_transport_close(pjmedia_transport *tp)
843
return (*tp->op->destroy)(tp);
849
* Simulate packet lost in the specified direction (for testing purposes).
850
* When enabled, the transport will randomly drop packets to the specified
853
* @param tp The media transport.
854
* @param dir Media direction to which packets will be randomly dropped.
855
* @param pct_lost Percent lost (0-100). Set to zero to disable packet
858
* @return PJ_SUCCESS on success.
860
PJ_INLINE(pj_status_t) pjmedia_transport_simulate_lost(pjmedia_transport *tp,
864
return (*tp->op->simulate_lost)(tp, dir, pct_lost);
875
#endif /* __PJMEDIA_TRANSPORT_H__ */