ortp协议栈(实时传输协议)
源代码在线查看: ortp-multiplexing-sessions-(in-a-one-thread-design).html
> > >Multiplexing sessions (in a one thread design) > NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ "> REL="HOME" TITLE="oRTP Reference Manual" HREF="book1.html"> REL="UP" TITLE="oRTP API" HREF="ortpapi.html"> REL="PREVIOUS" TITLE="RTP payloads and profiles" HREF="ortp-rtp-payloads-and-profiles.html"> REL="NEXT" TITLE="Telephone events (RFC2833)" HREF="ortp-telephone-events-(rfc2833)-.html"> > CLASS="REFENTRY" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" > CLASS="NAVHEADER" > WIDTH="100%" BORDER="0" BGCOLOR="#000000" CELLPADDING="1" CELLSPACING="0" > > COLSPAN="4" ALIGN="center" > COLOR="#FFFFFF" SIZE="5" >oRTP Reference Manual > > > > WIDTH="25%" BGCOLOR="#C00000" ALIGN="left" > HREF="ortp-rtp-payloads-and-profiles.html" > COLOR="#FFFFFF" SIZE="3" > ><<< Previous Page > > > > WIDTH="25%" BGCOLOR="#0000C0" ALIGN="center" > COLOR="#FFFFFF" SIZE="3" > > HREF="book1.html" > COLOR="#FFFFFF" SIZE="3" > >Home > > > > > > WIDTH="25%" BGCOLOR="#00C000" ALIGN="center" > COLOR="#FFFFFF" SIZE="3" > > HREF="ortpapi.html" > COLOR="#FFFFFF" SIZE="3" > >Up > > > > > > WIDTH="25%" BGCOLOR="#C00000" ALIGN="right" > HREF="ortp-telephone-events-(rfc2833)-.html" > COLOR="#FFFFFF" SIZE="3" > >Next Page >>> > > > > > > > > NAME="ORTP-MULTIPLEXING-SESSIONS-(IN-A-ONE-THREAD-DESIGN)">Multiplexing sessions (in a one thread design) > CLASS="REFNAMEDIV" > NAME="AEN820" > > >Name >Multiplexing sessions (in a one thread design) -- The SessionSet API allows applications to make I/O on mutilple rtp sessions without making blocking I/O, but keeping the main process synchronised. > CLASS="REFSYNOPSISDIV" > NAME="AEN823"> >Synopsis > BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" > > > CLASS="SYNOPSIS" >
#include <ortp.h> struct HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSIONSET" >SessionSet >; HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSIONSET" >SessionSet >* HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSION-SET-NEW" >session_set_new > (); #define HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSION-SET-INIT" >session_set_init > (ss) #define HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSION-SET-SET" >session_set_set > (ss,rtpsession) #define HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSION-SET-IS-SET" >session_set_is_set > (ss,rtpsession) #define HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSION-SET-CLR" >session_set_clr > (ss,rtpsession) int HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSION-SET-SELECT" >session_set_select > ( HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSIONSET" >SessionSet > *recvs, HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSIONSET" >SessionSet > *sends, HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSIONSET" >SessionSet > *errors); void HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSION-SET-DESTROY" >session_set_destroy > ( HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSIONSET" >SessionSet > *set); > > > > > CLASS="REFSECT1" > NAME="AEN839" > > >Description > >The scheduled mode must be enabled for all rtp session that are managed through the SessionSet API. See HREF="ortp-rtpsession-api.html#RTP-SESSION-SET-SCHEDULING-MODE" >rtp_session_set_scheduling_mode >(). > > CLASS="REFSECT1" > NAME="AEN843" > > >Details > CLASS="REFSECT2" > NAME="AEN845" > > > NAME="SESSIONSET" > >struct SessionSet > BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" > > > CLASS="PROGRAMLISTING" >struct SessionSet { fd_set rtpset; }; > > > > > > > CLASS="REFSECT2" > NAME="AEN850" > > > NAME="SESSION-SET-NEW" > >session_set_new () > BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" > > > CLASS="PROGRAMLISTING" > HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSIONSET" >SessionSet >* session_set_new (); > > > > >Allocates and initialize a new empty session set. > > > CLASS="INFORMALTABLE" > NAME="AEN857"> > > BORDER="0" WIDTH="100%" BGCOLOR="#FFD0D0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" > > > WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" > CLASS="emphasis" > CLASS="EMPHASIS" >Returns > > : > WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > the session set. > > > > > > > > CLASS="REFSECT2" > NAME="AEN866" > > > NAME="SESSION-SET-INIT" > >session_set_init() > BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" > > > CLASS="PROGRAMLISTING" >#define session_set_init(ss) FD_ZERO(&(ss)->rtpset) > > > > >Initializes a session set. It is unusefull to call this function on a session set object returned by HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSION-SET-NEW" >session_set_new >(). > > > CLASS="INFORMALTABLE" > NAME="AEN873"> > > BORDER="0" WIDTH="100%" BGCOLOR="#FFD0D0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" > > > WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" > CLASS="PARAMETER" > >ss > > : > WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > a SessionSet statically allocated. > > > > > > > > CLASS="REFSECT2" > NAME="AEN882" > > > NAME="SESSION-SET-SET" > >session_set_set() > BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" > > > CLASS="PROGRAMLISTING" >#define session_set_set(ss,rtpsession) FD_SET((rtpsession)->mask_pos,&(ss)->rtpset) > > > > >This macro adds rtp session CLASS="PARAMETER" > >_session > > to set CLASS="PARAMETER" > >_set > >. > > > CLASS="INFORMALTABLE" > NAME="AEN890"> > > BORDER="0" WIDTH="100%" BGCOLOR="#FFD0D0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" > > > WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" > CLASS="PARAMETER" > >ss > > : > WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > a set ( HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSIONSET" >SessionSet > object) > > > WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" > CLASS="PARAMETER" > >rtpsession > > : > WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > a rtp session > > > > > > > > CLASS="REFSECT2" > NAME="AEN904" > > > NAME="SESSION-SET-IS-SET" > >session_set_is_set() > BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" > > > CLASS="PROGRAMLISTING" >#define session_set_is_set(ss,rtpsession) FD_ISSET((rtpsession)->mask_pos,&(ss)->rtpset) > > > > >This macro tests if CLASS="PARAMETER" > >_session > > is part of CLASS="PARAMETER" > >_set > >. 1 is returned if true, 0 else. > > > CLASS="INFORMALTABLE" > NAME="AEN912"> > > BORDER="0" WIDTH="100%" BGCOLOR="#FFD0D0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" > > > WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" > CLASS="PARAMETER" > >ss > > : > WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > a set ( HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSIONSET" >SessionSet > object) > > > WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" > CLASS="PARAMETER" > >rtpsession > > : > WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > a rtp session > > > > > > > > CLASS="REFSECT2" > NAME="AEN926" > > > NAME="SESSION-SET-CLR" > >session_set_clr() > BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" > > > CLASS="PROGRAMLISTING" >#define session_set_clr(ss,rtpsession) FD_CLR((rtpsession)->mask_pos,&(ss)->rtpset) > > > > >Removes the CLASS="PARAMETER" > >_session > > from the _set. > > > CLASS="INFORMALTABLE" > NAME="AEN933"> > > BORDER="0" WIDTH="100%" BGCOLOR="#FFD0D0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" > > > WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" > CLASS="PARAMETER" > >ss > > : > WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > a set of sessions. > > > WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" > CLASS="PARAMETER" > >rtpsession > > : > WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > a rtp session. > > > > > > > > CLASS="REFSECT2" > NAME="AEN946" > > > NAME="SESSION-SET-SELECT" > >session_set_select () > BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" > > > CLASS="PROGRAMLISTING" >int session_set_select ( HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSIONSET" >SessionSet > *recvs, HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSIONSET" >SessionSet > *sends, HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSIONSET" >SessionSet > *errors); > > > > >This function performs similarly as libc select() function, but performs on HREF="ortp-rtpsession-api.html#RTPSESSION" >RtpSession > instead of file descriptors. HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSION-SET-SELECT" >session_set_select >() suspends the calling process until some events arrive on one of the three sets passed in argument. Two of the sets can be NULL. The first set CLASS="PARAMETER" > >recvs > > is interpreted as a set of RtpSession waiting for receive events: a new buffer (perhaps empty) is availlable on one or more sessions of the set, or the last receive operation with HREF="ortp-rtpsession-api.html#RTP-SESSION-RECV-WITH-TS" >rtp_session_recv_with_ts >() would have finished if it were in blocking mode. The second set is interpreted as a set of RtpSession waiting for send events, i.e. the last HREF="ortp-rtpsession-api.html#RTP-SESSION-SEND-WITH-TS" >rtp_session_send_with_ts >() call on a session would have finished if it were in blocking mode. > >When some events arrived on some of sets, then the function returns and sets are changed to indicate the sessions where events happened. Sessions can be added to sets using HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSION-SET-SET" >session_set_set >(), a session has to be tested to be part of a set using HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSION-SET-IS-SET" >session_set_is_set >(). > > > CLASS="INFORMALTABLE" > NAME="AEN964"> > > BORDER="0" WIDTH="100%" BGCOLOR="#FFD0D0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" > > > WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" > CLASS="PARAMETER" > >recvs > > : > WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > a set of rtp sessions to be watched for read events > > > WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" > CLASS="PARAMETER" > >sends > > : > WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > a set of rtp sessions to be watched for write events > > > WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" > CLASS="PARAMETER" > >errors > > : > WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > a set of rtp sessions to be watched for errors > > > WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" > CLASS="emphasis" > CLASS="EMPHASIS" >Returns > > : > WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > the number of sessions on which the selected events happened. > > > > > > > > CLASS="REFSECT2" > NAME="AEN985" > > > NAME="SESSION-SET-DESTROY" > >session_set_destroy () > BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" > > > CLASS="PROGRAMLISTING" >void session_set_destroy ( HREF="ortp-multiplexing-sessions-(in-a-one-thread-design).html#SESSIONSET" >SessionSet > *set); > > > > > > > > CLASS="INFORMALTABLE" > NAME="AEN992"> > > BORDER="0" WIDTH="100%" BGCOLOR="#FFD0D0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" > > > WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" > CLASS="PARAMETER" > >set > > : > WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > a SessionSet Destroys a session set. > > > > > > > > > CLASS="REFSECT1" > NAME="AEN1001" > > >See Also > >See the mrtprecv.c and mrtpsend.c programs included in the library that uses the SessionSet API to send or receive multiple RTP streams in one thread design. > > CLASS="NAVFOOTER" > CLEAR="all"> WIDTH="100%" BORDER="0" BGCOLOR="#000000" CELLPADDING="1" CELLSPACING="0" > > WIDTH="25%" BGCOLOR="#C00000" ALIGN="left" > HREF="ortp-rtp-payloads-and-profiles.html" > COLOR="#FFFFFF" SIZE="3" > ><<< Previous Page > > > > WIDTH="25%" BGCOLOR="#0000C0" ALIGN="center" > COLOR="#FFFFFF" SIZE="3" > > HREF="book1.html" > COLOR="#FFFFFF" SIZE="3" > >Home > > > > > > WIDTH="25%" BGCOLOR="#00C000" ALIGN="center" > COLOR="#FFFFFF" SIZE="3" > > HREF="ortpapi.html" > COLOR="#FFFFFF" SIZE="3" > >Up > > > > > > WIDTH="25%" BGCOLOR="#C00000" ALIGN="right" > HREF="ortp-telephone-events-(rfc2833)-.html" > COLOR="#FFFFFF" SIZE="3" > >Next Page >>> > > > > > > COLSPAN="2" ALIGN="left" > COLOR="#FFFFFF" SIZE="3" > >RTP payloads and profiles > > > COLSPAN="2" ALIGN="right" > COLOR="#FFFFFF" SIZE="3" > >Telephone events (RFC2833) > > > > > > > >