#include <ortp/port.h>
#include <ortp/rtp.h>
#include <ortp/payloadtype.h>
#include <ortp/sessionset.h>
#include <ortp/rtcp.h>
#include <ortp/str_utils.h>
#include <ortp/rtpsignaltable.h>
#include <ortp/event.h>
Go to the source code of this file.
Data Structures | |
struct | _JitterControl |
struct | _WaitPoint |
struct | _RtpTransport |
struct | _RtpStream |
struct | _RtcpStream |
struct | _RtpSession |
Defines | |
#define | rtp_session_set_flag(session, flag) (session)->flags|=(flag) |
#define | rtp_session_unset_flag(session, flag) (session)->flags&=~(flag) |
Typedefs | |
typedef _JitterControl | JitterControl |
typedef _WaitPoint | WaitPoint |
typedef _RtpTransport | RtpTransport |
typedef _RtpStream | RtpStream |
typedef _RtcpStream | RtcpStream |
typedef _RtpSession | RtpSession |
Enumerations | |
enum | RtpSessionMode { RTP_SESSION_RECVONLY, RTP_SESSION_SENDONLY, RTP_SESSION_SENDRECV } |
Functions | |
RtpSession * | rtp_session_new (int mode) |
void | rtp_session_set_scheduling_mode (RtpSession *session, int yesno) |
void | rtp_session_set_blocking_mode (RtpSession *session, int yesno) |
void | rtp_session_set_profile (RtpSession *session, RtpProfile *profile) |
void | rtp_session_set_send_profile (RtpSession *session, RtpProfile *profile) |
void | rtp_session_set_recv_profile (RtpSession *session, RtpProfile *profile) |
RtpProfile * | rtp_session_get_profile (RtpSession *session) |
RtpProfile * | rtp_session_get_send_profile (RtpSession *session) |
RtpProfile * | rtp_session_get_recv_profile (RtpSession *session) |
int | rtp_session_signal_connect (RtpSession *session, const char *signal_name, RtpCallback cb, unsigned long user_data) |
int | rtp_session_signal_disconnect_by_callback (RtpSession *session, const char *signal_name, RtpCallback cb) |
void | rtp_session_set_ssrc (RtpSession *session, uint32_t ssrc) |
void | rtp_session_set_seq_number (RtpSession *session, uint16_t seq) |
uint16_t | rtp_session_get_seq_number (RtpSession *session) |
void | rtp_session_set_jitter_compensation (RtpSession *session, int milisec) |
void | rtp_session_enable_adaptive_jitter_compensation (RtpSession *session, bool_t val) |
bool_t | rtp_session_adaptive_jitter_compensation_enabled (RtpSession *session) |
void | rtp_session_set_time_jump_limit (RtpSession *session, int miliseconds) |
int | rtp_session_set_local_addr (RtpSession *session, const char *addr, int port) |
int | rtp_session_get_local_port (const RtpSession *session) |
int | rtp_session_set_remote_addr (RtpSession *session, const char *addr, int port) |
void | rtp_session_set_sockets (RtpSession *session, int rtpfd, int rtcpfd) |
void | rtp_session_set_transports (RtpSession *session, RtpTransport *rtptr, RtpTransport *rtcptr) |
ortp_socket_t | rtp_session_get_rtp_socket (const RtpSession *session) |
ortp_socket_t | rtp_session_get_rtcp_socket (const RtpSession *session) |
int | rtp_session_set_dscp (RtpSession *session, int dscp) |
int | rtp_session_get_dscp (const RtpSession *session) |
int | rtp_session_set_multicast_ttl (RtpSession *session, int ttl) |
int | rtp_session_get_multicast_ttl (RtpSession *session) |
int | rtp_session_set_multicast_loopback (RtpSession *session, int yesno) |
int | rtp_session_get_multicast_loopback (RtpSession *session) |
int | rtp_session_set_send_payload_type (RtpSession *session, int paytype) |
int | rtp_session_get_send_payload_type (const RtpSession *session) |
int | rtp_session_get_recv_payload_type (const RtpSession *session) |
int | rtp_session_set_recv_payload_type (RtpSession *session, int pt) |
int | rtp_session_set_payload_type (RtpSession *session, int pt) |
void | rtp_session_set_symmetric_rtp (RtpSession *session, bool_t yesno) |
void | rtp_session_set_connected_mode (RtpSession *session, bool_t yesno) |
mblk_t * | rtp_session_recvm_with_ts (RtpSession *session, uint32_t user_ts) |
mblk_t * | rtp_session_create_packet (RtpSession *session, int header_size, const uint8_t *payload, int payload_size) |
mblk_t * | rtp_session_create_packet_with_data (RtpSession *session, uint8_t *payload, int payload_size, void(*freefn)(void *)) |
mblk_t * | rtp_session_create_packet_in_place (RtpSession *session, uint8_t *buffer, int size, void(*freefn)(void *)) |
int | rtp_session_sendm_with_ts (RtpSession *session, mblk_t *mp, uint32_t userts) |
int | rtp_session_recv_with_ts (RtpSession *session, uint8_t *buffer, int len, uint32_t ts, int *have_more) |
int | rtp_session_send_with_ts (RtpSession *session, const uint8_t *buffer, int len, uint32_t userts) |
void | rtp_session_register_event_queue (RtpSession *session, OrtpEvQueue *q) |
void | rtp_session_unregister_event_queue (RtpSession *session, OrtpEvQueue *q) |
float | rtp_session_compute_send_bandwidth (RtpSession *session) |
float | rtp_session_compute_recv_bandwidth (RtpSession *session) |
void | rtp_session_send_rtcp_APP (RtpSession *session, uint8_t subtype, const char *name, const uint8_t *data, int datalen) |
uint32_t | rtp_session_get_current_send_ts (RtpSession *session) |
uint32_t | rtp_session_get_current_recv_ts (RtpSession *session) |
void | rtp_session_flush_sockets (RtpSession *session) |
void | rtp_session_release_sockets (RtpSession *session) |
void | rtp_session_resync (RtpSession *session) |
void | rtp_session_reset (RtpSession *session) |
void | rtp_session_destroy (RtpSession *session) |
const rtp_stats_t * | rtp_session_get_stats (const RtpSession *session) |
void | rtp_session_reset_stats (RtpSession *session) |
void | rtp_session_set_data (RtpSession *session, void *data) |
void * | rtp_session_get_data (const RtpSession *session) |
void | rtp_session_set_recv_buf_size (RtpSession *session, int bufsize) |
uint32_t | rtp_session_ts_to_time (RtpSession *session, uint32_t timestamp) |
uint32_t | rtp_session_time_to_ts (RtpSession *session, int millisecs) |
void | rtp_session_make_time_distorsion (RtpSession *session, int milisec) |
void | rtp_session_set_source_description (RtpSession *session, const char *cname, const char *name, const char *email, const char *phone, const char *loc, const char *tool, const char *note) |
void | rtp_session_add_contributing_source (RtpSession *session, uint32_t csrc, const char *cname, const char *name, const char *email, const char *phone, const char *loc, const char *tool, const char *note) |
void | rtp_session_remove_contributing_sources (RtpSession *session, uint32_t csrc) |
mblk_t * | rtp_session_create_rtcp_sdes_packet (RtpSession *session) |
void | rtp_session_get_last_recv_time (RtpSession *session, struct timeval *tv) |
int | rtp_session_bye (RtpSession *session, const char *reason) |
void | rtp_session_init (RtpSession *session, int mode) |
void | rtp_session_uninit (RtpSession *session) |
The RtpSession objects represent a RTP session: once it is configured with local and remote network addresses and a payload type is given, it let you send and recv a media stream.
|
Sends a RTCP bye packet.
|
|
Allocates a new rtp packet. In the header, ssrc and payload_type according to the session's context. Timestamp and seq number are not set, there will be set when the packet is going to be sent with rtp_session_sendm_with_ts(). If payload_size is zero, thus an empty packet (just a RTP header) is returned.
|
|
Creates a new rtp packet using the buffer given in arguments (no copy). In the header, ssrc and payload_type according to the session's context. Timestamp and seq number are not set, there will be set when the packet is going to be sent with rtp_session_sendm_with_ts(). can be NULL, in that case payload will be kept untouched.
|
|
Creates a new rtp packet using the given payload buffer (no copy). The header will be allocated separetely. In the header, ssrc and payload_type according to the session's context. Timestamp and seq number are not set, there will be set when the packet is going to be sent with rtp_session_sendm_with_ts(). oRTP will send this packet using libc's sendmsg() (if this function is availlable!) so that there will be no packet concatenation involving copies to be done in user-space. can be NULL, in that case payload will be kept untouched.
|
|
Destroys a rtp session. All memory allocated for the RtpSession is freed.
|
|
rtp_session_flush_sockets: : a rtp session Flushes the sockets for all pending incoming packets. This can be usefull if you did not listen to the stream for a while and wishes to start to receive again. During the time no receive is made packets get bufferised into the internal kernel socket structure. |
|
Same thing as rtp_session_get_current_send_ts() except that it's for an incoming stream. Works only on scheduled mode.
|
|
When the rtp session is scheduled and has started to send packets, this function computes the timestamp that matches to the present time. Using this function can be usefull when sending discontinuous streams. Some time can be elapsed between the end of a stream burst and the begin of a new stream burst, and the application may be not not aware of this elapsed time. In order to get a valid (current) timestamp to pass to rtp_session_send_with_ts() or rtp_session_sendm_with_ts(), the application may use rtp_session_get_current_send_ts().
|
|
|
|
rtp_session_get_dscp: : a rtp session Returns the DSCP (Differentiated Services Code Point) for outgoing RTP packets. |
|
Gets last time a valid RTP or RTCP packet was received.
|
|
rtp_session_get_local_port: : a rtp session for which rtp_session_set_local_addr() or rtp_session_set_remote_addr() has been called This function can be useful to retrieve the local port that was randomly choosen by rtp_session_set_remote_addr() when rtp_session_set_local_addr() was not called. Returns: the local port used to listen for rtp packets, -1 if not set. |
|
rtp_session_get_multicast_loopback: : a rtp session Returns the multicast loopback state of rtp session (true or false). |
|
rtp_session_get_multicast_ttl: : a rtp session Returns the TTL (Time-To-Live) for outgoing multicast packets. |
|
|
|
|
|
|
|
|
|
|
|
Retrieve the session's statistics. |
|
Creates a new rtp session. If the session is able to send data (RTP_SESSION_SENDONLY or RTP_SESSION_SENDRECV), then a random SSRC number is choosed for the outgoing stream.
|
|
NOTE: use of this function is discouraged when sending payloads other than pcm/pcmu/pcma/adpcm types. rtp_session_recvm_with_ts() does better job. Tries to read the bytes of the incoming rtp stream related to timestamp ts. In case where the user supplied buffer is not large enough to get all the data related to timestamp ts, then *( have_more) is set to 1 to indicate that the application should recall the function with the same timestamp to get more data. When the rtp session is scheduled (see rtp_session_set_scheduling_mode() ), and the blocking mode is on (see rtp_session_set_blocking_mode() ), then the calling thread is suspended until the timestamp given as argument expires, whatever a received packet fits the query or not. Important note: it is clear that the application cannot know the timestamp of the first packet of the incoming stream, because it can be random. The timestamp given to the function is used relatively to first timestamp of the stream. In simple words, 0 is a good value to start calling this function. This function internally calls rtp_session_recvm_with_ts() to get a rtp packet. The content of this packet is then copied into the user supplied buffer in an intelligent manner: the function takes care of the size of the supplied buffer and the timestamp given in argument. Using this function it is possible to read continous audio data (e.g. pcma,pcmu...) with for example a standart buffer of size of 160 with timestamp incrementing by 160 while the incoming stream has a different packet size. Returns: if a packet was availlable with the corresponding timestamp supplied in argument then the number of bytes written in the user supplied buffer is returned. If no packets are availlable, either because the sender has not started to send the stream, or either because silence packet are not transmitted, or either because the packet was lost during network transport, then the function returns zero.
|
|
Try to get a rtp packet presented as a mblk_t structure from the rtp session. The parameter is relative to the first timestamp of the incoming stream. In other words, the application does not have to know the first timestamp of the stream, it can simply call for the first time this function with =0, and then incrementing it as it want. The RtpSession takes care of synchronisation between the stream timestamp and the user timestamp given here.
|
|
Register an event queue. An application can use an event queue to get informed about various RTP events. |
|
Closes the rtp and rtcp sockets. |
|
Reset the session: local and remote addresses are kept. It resets timestamp, sequence number, and calls rtp_session_resync().
|
|
Resynchronize to the incoming RTP streams. This can be useful to handle discoutinuous timestamps. For example, call this function from the timestamp_jump signal handler.
|
|
Send a rtp datagram to the destination set by rtp_session_set_remote_addr() containing the data from with timestamp . This is a high level function that uses rtp_session_create_packet() and rtp_session_sendm_with_ts() to send the data.
|
|
Send the rtp datagram to the destination set by rtp_session_set_remote_addr() with timestamp . For audio data, the timestamp is the number of the first sample resulting of the data transmitted. See rfc1889 for details. The packet () is freed once it is sended.
|
|
This function implicitely enables the scheduling mode if yesno is TRUE. rtp_session_set_blocking_mode() defines the behaviour of the rtp_session_recv_with_ts() and rtp_session_send_with_ts() functions. If is TRUE, rtp_session_recv_with_ts() will block until it is time for the packet to be received, according to the timestamp passed to the function. After this time, the function returns. For rtp_session_send_with_ts(), it will block until it is time for the packet to be sent. If is FALSE, then the two functions will return immediately.
|
|
If yesno is TRUE, thus a connect() syscall is done on the socket to the destination address set by rtp_session_set_remote_addr(), or if the session does symmetric rtp (see rtp_session_set_symmetric_rtp()) a the connect() is done to the source address of the first packet received. Connecting a socket has effect of rejecting all incoming packets that don't come from the address specified in connect(). It also makes ICMP errors (such as connection refused) available to the application.
|
|
Stores some application specific data into the session, so that it is easy to retrieve it from the signal callbacks using rtp_session_get_data().
|
|
rtp_session_set_dscp: : a rtp session : desired DSCP PHB value Sets the DSCP (Differentiated Services Code Point) for outgoing RTP packets. Returns: 0 on success. |
|
rtp_session_set_jitter_compensation: : a RtpSession : the time interval in milisec to be jitter compensed. Sets the time interval for which packet are buffered instead of being delivered to the application. |
|
rtp_session_set_local_addr: : a rtp session freshly created. : a local IP address in the xxx.xxx.xxx.xxx form. : a local port or -1 to let oRTP choose the port randomly Specify the local addr to be use to listen for rtp packets or to send rtp packet from. In case where the rtp session is send-only, then it is not required to call this function: when calling rtp_session_set_remote_addr(), if no local address has been set, then the default INADRR_ANY (0.0.0.0) IP address with a random port will be used. Calling rtp_sesession_set_local_addr() is mandatory when the session is recv-only or duplex. Returns: 0 on success. |
|
rtp_session_set_multicast_loopback: : a rtp session : desired Multicast Time-To-Live Sets the TTL (Time-To-Live) for outgoing multicast packets. Returns: 0 on success. |
|
rtp_session_set_multicast_ttl: : a rtp session : desired Multicast Time-To-Live Sets the TTL (Time-To-Live) for outgoing multicast packets. Returns: 0 on success. |
|
Sets the expected payload type for incoming packets and payload type to be used for outgoing packets. If the actual payload type in incoming packets is different that this expected payload type, thus the "payload_type_changed" signal is emitted.
|
|
Set the RTP profile to be used for the session. By default, all session are created by rtp_session_new() are initialized with the AV profile, as defined in RFC 3551. The application can set any other profile instead using that function.
|
|
The default value is 65535 bytes, a big value which is working for everyone. However if your application can make assumption on the MTU, it can be interesting to set it to a lower value in order to save memory.
|
|
Sets the expected payload type for incoming packets. If the actual payload type in incoming packets is different that this expected payload type, thus the "payload_type_changed" signal is emitted.
|
|
Set the RTP profile to be used for the receiveing by this session. By default, all session are created by rtp_session_new() are initialized with the AV profile, as defined in RFC 3551. The application can set any other profile instead using that function.
|
|
rtp_session_set_remote_addr: : a rtp session freshly created. : a local IP address in the xxx.xxx.xxx.xxx form. : a local port. Sets the remote address of the rtp session, ie the destination address where rtp packet are sent. If the session is recv-only or duplex, it also sets the origin of incoming RTP packets. Rtp packets that don't come from addr:port are discarded. Returns: 0 on success. |
|
Sets the scheduling mode of the rtp session. If is TRUE, the rtp session is in the scheduled mode, that means that you can use session_set_select() to block until it's time to receive or send on this session according to the timestamp passed to the respective functions. You can also use blocking mode (see rtp_session_set_blocking_mode() ), to simply block within the receive and send functions. If is FALSE, the ortp scheduler will not manage those sessions, meaning that blocking mode and the use of session_set_select() for this session are disabled.
|
|
Sets the payload type of the rtp session. It decides of the payload types written in the of the rtp header for the outgoing stream, if the session is SENDRECV or SENDONLY. For payload type in incoming packets, the application can be informed by registering for the "payload_type_changed" signal, so that it can make the necessary changes on the downstream decoder that deals with the payload of the packets.
|
|
Set the RTP profile to be used for the sending by this session. By default, all session are created by rtp_session_new() are initialized with the AV profile, as defined in RFC 3551. The application can set any other profile instead using that function.
|
|
sets the initial sequence number of a sending session.
|
|
Set session's SDES item for automatic sending of RTCP compound packets. If some items are not specified, use NULL. |
|
Sets the SSRC for the outgoing stream. If not done, a random ssrc is used.
|
|
Enable or disable the "rtp symmetric" hack which consists of the following: after the first packet is received, the source address of the packet is set to be the destination address for all next packets. This is useful to pass-through firewalls.
|
|
oRTP has the possibility to inform the application through a callback registered with rtp_session_signal_connect about crazy incoming RTP stream that jumps from a timestamp N to N+some_crazy_value. This lets the opportunity for the application to reset the session in order to resynchronize, or any other action like stopping the call and reporting an error.
|
|
This function provides the way for an application to be informed of various events that may occur during a rtp session. is a string identifying the event, and is a user supplied function in charge of processing it. The application can register several callbacks for the same signal, in the limit of RTP_CALLBACK_TABLE_MAX_ENTRIES. Here are name and meaning of supported signals types: "ssrc_changed" : the SSRC of the incoming stream has changed. "payload_type_changed" : the payload type of the incoming stream has changed. "telephone-event_packet" : a telephone-event rtp packet (RFC2833) is received. "telephone-event" : a telephone event has occured. This is a high-level shortcut for "telephone-event_packet". "network_error" : a network error happened on a socket. Arguments of the callback functions are a const char * explaining the error, an int errno error code and the user_data as usual. "timestamp_jump" : we have received a packet with timestamp in far future compared to last timestamp received. The farness of far future is set by rtp_sesssion_set_time_jump_limit() "rtcp_bye": we have received a RTCP bye packet. Arguments of the callback functions are a const char * containing the leaving reason and the user_data. Returns: 0 on success, -EOPNOTSUPP if the signal does not exists, -1 if no more callbacks can be assigned to the signal type.
|
|
Removes callback function to the list of callbacks for signal .
|