Loading...
Searching...
No Matches
rtpfwd.h
Go to the documentation of this file.
#ifndef JANUS_RTPFWD_H
#define JANUS_RTPFWD_H
#include "rtp.h"
#include "rtpsrtp.h"
int janus_rtp_forwarders_init(void);
void janus_rtp_forwarders_deinit(void);
typedef struct janus_rtp_forwarder {
/* \brief Opaque pointer to the owner of this forwarder */
void *source;
/* \brief Context of the forwarder */
char *context;
/* \brief Unique ID (within the context) of the forwarder */
uint32_t stream_id;
/* \brief Socket used for sending RTP packets */
int udp_fd;
/* \brief Whether this is a video forwarder */
gboolean is_video;
/* \brief Whether this is an audio forwarder */
gboolean is_data;
/* \brief SSRC to put in forwarded RTP packets */
uint32_t ssrc;
/* \brief Payload type to put in forwarded RTP packets */
int payload_type;
/* \brief Substream to forward, in case this is part of a simulcast stream */
int substream;
/* \brief Recipient address (IPv4) */
struct sockaddr_in serv_addr;
/* \brief Recipient address (IPv6) */
struct sockaddr_in6 serv_addr6;
/* \brief RTCP socket, if needed */
int rtcp_fd;
/* \brief RTCP local and remote ports, if needed */
uint16_t local_rtcp_port, remote_rtcp_port;
/* \brief Callback to invoke when receiving RTCP messages, if any */
void (*rtcp_callback)(struct janus_rtp_forwarder *rf, char *buffer, int len);
/* \brief RTCP GSource, if needed */
GSource *rtcp_recv;
/* \brief Whether simulcast automatic selection is enabled for this forwarder */
gboolean simulcast;
/* \brief RTP switching context, if needed */
janus_rtp_switching_context rtp_context;
/* \brief Simulcast context, if needed */
janus_rtp_simulcasting_context sim_context;
/* \brief Whether SRTP is enabled for this forwarder */
gboolean is_srtp;
/* \brief The SRTP context, in case SRTP is enabled */
srtp_t srtp_ctx;
/* \brief The SRTP policy, in case SRTP is enabled */
srtp_policy_t srtp_policy;
/* \brief Opaque metadata property, in case it's useful to the owner
* \note This can be anything (e.g., a string, an allocated struct, etc.),
* as long as it can be freed with a single call to g_free(), as
* that's all that will be done when getting rid of the forwarder */
void *metadata;
volatile gint destroyed;
janus_refcount ref;
} janus_rtp_forwarder;
janus_rtp_forwarder *janus_rtp_forwarder_create(const char *ctx,
uint32_t stream_id, int udp_fd, const char *host, int port,
uint32_t ssrc, int pt, int srtp_suite, const char *srtp_crypto,
gboolean simulcast, int substream, gboolean is_video, gboolean is_data);
int janus_rtp_forwarder_add_rtcp(janus_rtp_forwarder *rf, int rtcp_port,
void (*rtcp_callback)(janus_rtp_forwarder *rf, char *buffer, int len));
void janus_rtp_forwarder_send_rtp(janus_rtp_forwarder *rf, char *buffer, int len, int substream);
void janus_rtp_forwarder_send_rtp_full(janus_rtp_forwarder *rf, char *buffer, int len, int substream,
uint32_t *ssrcs, char **rids, janus_videocodec vcodec, janus_mutex *rid_mutex);
void janus_rtp_forwarder_destroy(janus_rtp_forwarder *rf);
#endif
janus_mutex
GMutex janus_mutex
Janus mutex implementation.
Definition mutex.h:73
rtp.h
RTP processing (headers).
janus_videocodec
janus_videocodec
Definition rtp.h:139
janus_rtp_forwarder_add_rtcp
int janus_rtp_forwarder_add_rtcp(janus_rtp_forwarder *rf, int rtcp_port, void(*rtcp_callback)(janus_rtp_forwarder *rf, char *buffer, int len))
Helper method to add RTCP support to an existing forwarder.
Definition rtpfwd.c:246
janus_rtp_forwarder_destroy
void janus_rtp_forwarder_destroy(janus_rtp_forwarder *rf)
Helper method to free a janus_rtp_forwarder instance.
Definition rtpfwd.c:409
janus_rtp_forwarder_send_rtp
void janus_rtp_forwarder_send_rtp(janus_rtp_forwarder *rf, char *buffer, int len, int substream)
Helper method to forward an RTP packet within the context of a forwarder.
Definition rtpfwd.c:332
janus_rtp_forwarders_deinit
void janus_rtp_forwarders_deinit(void)
RTP forwarders code de-initialization.
Definition rtpfwd.c:79
janus_rtp_forwarder_create
janus_rtp_forwarder * janus_rtp_forwarder_create(const char *ctx, uint32_t stream_id, int udp_fd, const char *host, int port, uint32_t ssrc, int pt, int srtp_suite, const char *srtp_crypto, gboolean simulcast, int substream, gboolean is_video, gboolean is_data)
Helper method to create a new janus_rtp_forwarder instance.
Definition rtpfwd.c:145
janus_rtp_forwarders_init
int janus_rtp_forwarders_init(void)
RTP forwarders code initialization.
Definition rtpfwd.c:44
janus_rtp_forwarder_send_rtp_full
void janus_rtp_forwarder_send_rtp_full(janus_rtp_forwarder *rf, char *buffer, int len, int substream, uint32_t *ssrcs, char **rids, janus_videocodec vcodec, janus_mutex *rid_mutex)
Extended version of janus_rtp_forwarder_send_rtp, to be used when the forwarder is configured to act ...
Definition rtpfwd.c:337
rtpsrtp.h
SRTP definitions (headers).
janus_refcount
Definition refcount.h:78
janus_rtp_forwarder
Helper struct for implementing RTP forwarders.
Definition rtpfwd.h:30
janus_rtp_forwarder::substream
int substream
Definition rtpfwd.h:48
janus_rtp_forwarder::local_rtcp_port
uint16_t local_rtcp_port
Definition rtpfwd.h:56
janus_rtp_forwarder::destroyed
volatile gint destroyed
Atomic flag to check if this instance has been destroyed.
Definition rtpfwd.h:79
janus_rtp_forwarder::serv_addr
struct sockaddr_in serv_addr
Definition rtpfwd.h:50
janus_rtp_forwarder::context
char * context
Definition rtpfwd.h:34
janus_rtp_forwarder::rtcp_recv
GSource * rtcp_recv
Definition rtpfwd.h:60
janus_rtp_forwarder::is_video
gboolean is_video
Definition rtpfwd.h:40
janus_rtp_forwarder::is_srtp
gboolean is_srtp
Definition rtpfwd.h:68
janus_rtp_forwarder::metadata
void * metadata
Definition rtpfwd.h:77
janus_rtp_forwarder::udp_fd
int udp_fd
Definition rtpfwd.h:38
janus_rtp_forwarder::remote_rtcp_port
uint16_t remote_rtcp_port
Definition rtpfwd.h:56
janus_rtp_forwarder::srtp_ctx
srtp_t srtp_ctx
Definition rtpfwd.h:70
janus_rtp_forwarder::rtp_context
janus_rtp_switching_context rtp_context
Definition rtpfwd.h:64
janus_rtp_forwarder::rtcp_fd
int rtcp_fd
Definition rtpfwd.h:54
janus_rtp_forwarder::stream_id
uint32_t stream_id
Definition rtpfwd.h:36
janus_rtp_forwarder::serv_addr6
struct sockaddr_in6 serv_addr6
Definition rtpfwd.h:52
janus_rtp_forwarder::source
void * source
Definition rtpfwd.h:32
janus_rtp_forwarder::rtcp_callback
void(* rtcp_callback)(struct janus_rtp_forwarder *rf, char *buffer, int len)
Definition rtpfwd.h:58
janus_rtp_forwarder::is_data
gboolean is_data
Definition rtpfwd.h:42
janus_rtp_forwarder::ssrc
uint32_t ssrc
Definition rtpfwd.h:44
janus_rtp_forwarder::srtp_policy
srtp_policy_t srtp_policy
Definition rtpfwd.h:72
janus_rtp_forwarder::ref
janus_refcount ref
Reference counter for this instance.
Definition rtpfwd.h:81
janus_rtp_forwarder::payload_type
int payload_type
Definition rtpfwd.h:46
janus_rtp_forwarder::sim_context
janus_rtp_simulcasting_context sim_context
Definition rtpfwd.h:66
janus_rtp_forwarder::simulcast
gboolean simulcast
Definition rtpfwd.h:62
janus_rtp_simulcasting_context
Helper struct for processing and tracking simulcast streams.
Definition rtp.h:398
janus_rtp_switching_context
RTP context, in order to make sure SSRC changes result in coherent seq/ts increases.
Definition rtp.h:308