📄 transport.h
字号:
void (*detach)(pjmedia_transport *tp,
void *user_data);
/**
* This function is called by the stream to send RTP packet using the
* transport.
*
* Application should call #pjmedia_transport_send_rtp() instead of
* calling this function directly.
*/
pj_status_t (*send_rtp)(pjmedia_transport *tp,
const void *pkt,
pj_size_t size);
/**
* This function is called by the stream to send RTCP packet using the
* transport.
*
* Application should call #pjmedia_transport_send_rtcp() instead of
* calling this function directly.
*/
pj_status_t (*send_rtcp)(pjmedia_transport *tp,
const void *pkt,
pj_size_t size);
/**
* This function can be called to destroy this transport.
*
* Application should call #pjmedia_transport_close() instead of
* calling this function directly.
*/
pj_status_t (*destroy)(pjmedia_transport *tp);
};
/**
* @see pjmedia_transport_op.
*/
typedef struct pjmedia_transport_op pjmedia_transport_op;
/**
* Media transport type.
*/
typedef enum pjmedia_transport_type
{
/** Media transport using standard UDP */
PJMEDIA_TRANSPORT_TYPE_UDP,
/** Media transport using ICE */
PJMEDIA_TRANSPORT_TYPE_ICE
} pjmedia_transport_type;
/**
* This structure declares stream transport. A stream transport is called
* by the stream to transmit a packet, and will notify stream when
* incoming packet is arrived.
*/
struct pjmedia_transport
{
/** Transport name (for logging purpose). */
char name[PJ_MAX_OBJ_NAME];
/** Transport type. */
pjmedia_transport_type type;
/** Transport's "virtual" function table. */
pjmedia_transport_op *op;
};
/**
* Get media socket info from the specified transport. The socket info
* contains information about the local address of this transport, and
* would be needed for example to fill in the "c=" and "m=" line of local
* SDP.
*
* @param tp The transport.
* @param info Media socket info to be initialized.
*
* @return PJ_SUCCESS on success.
*/
PJ_INLINE(pj_status_t) pjmedia_transport_get_info(pjmedia_transport *tp,
pjmedia_sock_info *info)
{
if (tp->op->get_info)
return (*tp->op->get_info)(tp, info);
else
return PJ_ENOTSUP;
}
/**
* Attach callbacks to be called on receipt of incoming RTP/RTCP packets.
* This is just a simple wrapper which calls <tt>attach()</tt> member of
* the transport.
*
* @param tp The media transport.
* @param user_data Arbitrary user data to be set when the callbacks are
* called.
* @param rem_addr Remote RTP address to send RTP packet to.
* @param rem_rtcp Optional remote RTCP address. If the argument is NULL
* or if the address is zero, the RTCP address will be
* calculated from the RTP address (which is RTP port
* plus one).
* @param addr_len Length of the remote address.
* @param rtp_cb Callback to be called when RTP packet is received on
* the transport.
* @param rtcp_cb Callback to be called when RTCP packet is received on
* the transport.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*/
PJ_INLINE(pj_status_t) pjmedia_transport_attach(pjmedia_transport *tp,
void *user_data,
const pj_sockaddr_t *rem_addr,
const pj_sockaddr_t *rem_rtcp,
unsigned addr_len,
void (*rtp_cb)(void *user_data,
const void *pkt,
pj_ssize_t),
void (*rtcp_cb)(void *usr_data,
const void*pkt,
pj_ssize_t))
{
return tp->op->attach(tp, user_data, rem_addr, rem_rtcp, addr_len,
rtp_cb, rtcp_cb);
}
/**
* Detach callbacks from the transport.
* This is just a simple wrapper which calls <tt>detach()</tt> member of
* the transport. After the transport is detached, it will ignore incoming
* RTP/RTCP packets, and will refuse to send outgoing RTP/RTCP packets.
* Application may re-attach the media transport to another transport user
* (e.g. stream) after the transport has been detached.
*
* @param tp The media transport.
* @param user_data User data which must match the previously set value
* on attachment.
*/
PJ_INLINE(void) pjmedia_transport_detach(pjmedia_transport *tp,
void *user_data)
{
tp->op->detach(tp, user_data);
}
/**
* Send RTP packet with the specified media transport. This is just a simple
* wrapper which calls <tt>send_rtp()</tt> member of the transport. The
* RTP packet will be delivered to the destination address specified in
* #pjmedia_transport_attach() function.
*
* @param tp The media transport.
* @param pkt The packet to send.
* @param size Size of the packet.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*/
PJ_INLINE(pj_status_t) pjmedia_transport_send_rtp(pjmedia_transport *tp,
const void *pkt,
pj_size_t size)
{
return (*tp->op->send_rtp)(tp, pkt, size);
}
/**
* Send RTCP packet with the specified media transport. This is just a simple
* wrapper which calls <tt>send_rtcp()</tt> member of the transport. The
* RTCP packet will be delivered to the destination address specified in
* #pjmedia_transport_attach() function.
*
* @param tp The media transport.
* @param pkt The packet to send.
* @param size Size of the packet.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*/
PJ_INLINE(pj_status_t) pjmedia_transport_send_rtcp(pjmedia_transport *tp,
const void *pkt,
pj_size_t size)
{
return (*tp->op->send_rtcp)(tp, pkt, size);
}
/**
* Close media transport. This is just a simple wrapper which calls
* <tt>destroy()</tt> member of the transport. This function will free
* all resources created by this transport (such as sockets, memory, etc.).
*
* @param tp The media transport.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*/
PJ_INLINE(pj_status_t) pjmedia_transport_close(pjmedia_transport *tp)
{
if (tp->op->destroy)
return (*tp->op->destroy)(tp);
else
return PJ_SUCCESS;
}
PJ_END_DECL
/**
* @}
*/
#endif /* __PJMEDIA_TRANSPORT_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -