⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtpsessionapi.sgml

📁 ORTP开源的rtp库
💻 SGML
📖 第 1 页 / 共 4 页
字号:
<para></para><para></para><variablelist role="params"><varlistentry><term><parameter>session</parameter>&nbsp;:</term><listitem><simpara> a rtp session</simpara></listitem></varlistentry><varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> the payload type currently used in outgoing rtp packets</simpara></listitem></varlistentry></variablelist></refsect2><refsect2><title><anchor id="rtp-session-get-recv-payload-type" role="function">rtp_session_get_recv_payload_type ()</title><indexterm><primary>rtp_session_get_recv_payload_type</primary></indexterm><programlisting><link linkend="int">int</link>         rtp_session_get_recv_payload_type                                            (const <link linkend="RtpSession">RtpSession</link> *session);</programlisting><para></para><para></para><variablelist role="params"><varlistentry><term><parameter>session</parameter>&nbsp;:</term><listitem><simpara> a rtp session</simpara></listitem></varlistentry><varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> the payload type currently used in incoming rtp packets</simpara></listitem></varlistentry></variablelist></refsect2><refsect2><title><anchor id="rtp-session-set-payload-type" role="function">rtp_session_set_payload_type ()</title><indexterm><primary>rtp_session_set_payload_type</primary></indexterm><programlisting><link linkend="int">int</link>         rtp_session_set_payload_type    (<link linkend="RtpSession">RtpSession</link> *session,                                             <link linkend="int">int</link> pt);</programlisting><para>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, thusthe "payload_type_changed" signal is emitted.</para><para></para><variablelist role="params"><varlistentry><term><parameter>session</parameter>&nbsp;:</term><listitem><simpara> a rtp session</simpara></listitem></varlistentry><varlistentry><term><parameter>pt</parameter>&nbsp;:</term><listitem><simpara></simpara></listitem></varlistentry><varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> 0 on success, -1 if the payload is not defined.</simpara></listitem></varlistentry></variablelist></refsect2><refsect2><title><anchor id="rtp-session-signal-connect" role="function">rtp_session_signal_connect ()</title><indexterm><primary>rtp_session_signal_connect</primary></indexterm><programlisting><link linkend="int">int</link>         rtp_session_signal_connect      (<link linkend="RtpSession">RtpSession</link> *session,                                             const <link linkend="char">char</link> *signal,                                             <link linkend="RtpCallback">RtpCallback</link> cb,                                             unsigned <link linkend="long-user-data">long user_data</link>);</programlisting><para>This function provides the way for an application to be informed of various events thatmay occur during a rtp session. <parameter>signal</parameter> is a string identifying the event, and <parameter>cb</parameter> is a user supplied function in charge of processing it. The application can registerseveral callbacks for the same signal, in the limit of <link linkend="RTP-CALLBACK-TABLE-MAX-ENTRIES:CAPS"><type>RTP_CALLBACK_TABLE_MAX_ENTRIES</type></link>.Here are name and meaning of supported signals types:</para><para>"ssrc_changed" : the SSRC of the incoming stream has changed.</para><para>"payload_type_changed" : the payload type of the incoming stream has changed.</para><para>"telephone-event_packet" : a telephone-event rtp packet (RFC2833) is received.</para><para>"telephone-event" : a telephone event has occured. This is a high-level shortcut for "telephone-event_packet".</para><para>"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.</para><para>"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 <link linkend="rtp-sesssion-set-time-jump-limit"><function>rtp_sesssion_set_time_jump_limit()</function></link> "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.</para><para></para><variablelist role="params"><varlistentry><term><parameter>session</parameter>&nbsp;:</term><listitem><simpara> 	a rtp session</simpara></listitem></varlistentry><varlistentry><term><parameter>signal</parameter>&nbsp;:</term><listitem><simpara>		the name of a signal</simpara></listitem></varlistentry><varlistentry><term><parameter>cb</parameter>&nbsp;:</term><listitem><simpara>			a <link linkend="RtpCallback"><type>RtpCallback</type></link></simpara></listitem></varlistentry><varlistentry><term><parameter>Param4</parameter>&nbsp;:</term><listitem><simpara></simpara></listitem></varlistentry><varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> 0 on success, -EOPNOTSUPP if the signal does not exists, -1 if no more callbackscan be assigned to the signal type.</simpara></listitem></varlistentry></variablelist></refsect2><refsect2><title><anchor id="rtp-session-signal-disconnect-by-callback" role="function">rtp_session_signal_disconnect_by_callback ()</title><indexterm><primary>rtp_session_signal_disconnect_by_callback</primary></indexterm><programlisting><link linkend="int">int</link>         rtp_session_signal_disconnect_by_callback                                            (<link linkend="RtpSession">RtpSession</link> *session,                                             const <link linkend="char">char</link> *signal,                                             <link linkend="RtpCallback">RtpCallback</link> cb);</programlisting><para>Removes callback function <parameter>cb</parameter> to the list of callbacks for signal <parameter>signal</parameter>.</para><para></para><variablelist role="params"><varlistentry><term><parameter>session</parameter>&nbsp;:</term><listitem><simpara> a rtp session</simpara></listitem></varlistentry><varlistentry><term><parameter>signal</parameter>&nbsp;:</term><listitem><simpara>	a signal name</simpara></listitem></varlistentry><varlistentry><term><parameter>cb</parameter>&nbsp;:</term><listitem><simpara>		a callback function.</simpara></listitem></varlistentry><varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> 0 on success, -ENOENT if the callbacks was not found.</simpara></listitem></varlistentry></variablelist></refsect2><refsect2><title><anchor id="rtp-session-send-with-ts" role="function">rtp_session_send_with_ts ()</title><indexterm><primary>rtp_session_send_with_ts</primary></indexterm><programlisting><link linkend="int">int</link>         rtp_session_send_with_ts        (<link linkend="RtpSession">RtpSession</link> *session,                                             const <link linkend="char">char</link> *buffer,                                             <link linkend="int">int</link> len,                                             <link linkend="uint32-t">uint32_t</link> userts);</programlisting><para>Send a rtp datagram to the destination set by <link linkend="rtp-session-set-remote-addr"><function>rtp_session_set_remote_addr()</function></link> containingthe data from <parameter>buffer</parameter> with timestamp <parameter>userts</parameter>. This is a high level function that uses<link linkend="rtp-session-create-packet"><function>rtp_session_create_packet()</function></link> and <link linkend="rtp-session-sendm-with-ts"><function>rtp_session_sendm_with_ts()</function></link> to send the data.</para><para></para><variablelist role="params"><varlistentry><term><parameter>session</parameter>&nbsp;:</term><listitem><simpara> a rtp session.</simpara></listitem></varlistentry><varlistentry><term><parameter>buffer</parameter>&nbsp;:</term><listitem><simpara>	a buffer containing the data to be sent in a rtp packet.</simpara></listitem></varlistentry><varlistentry><term><parameter>len</parameter>&nbsp;:</term><listitem><simpara>		the length of the data buffer, in bytes.</simpara></listitem></varlistentry><varlistentry><term><parameter>userts</parameter>&nbsp;:</term><listitem><simpara>	the timestamp of the data to be sent. Refer to the rfc to know what it is.</simpara></listitem></varlistentry><varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> the number of bytes sent over the network.</simpara></listitem></varlistentry></variablelist></refsect2><refsect2><title><anchor id="rtp-session-recv-with-ts" role="function">rtp_session_recv_with_ts ()</title><indexterm><primary>rtp_session_recv_with_ts</primary></indexterm><programlisting><link linkend="int">int</link>         rtp_session_recv_with_ts        (<link linkend="RtpSession">RtpSession</link> *session,                                             <link linkend="char">char</link> *buffer,                                             <link linkend="int">int</link> len,                                             <link linkend="uint32-t">uint32_t</link> time,                                             <link linkend="int">int</link> *have_more);</programlisting><para>Tries to read the bytes of the incoming rtp stream related to timestamp <parameter>time</parameter>. In case where the user supplied buffer <parameter>buffer</parameter> is not large enough to get all the data related to timestamp <parameter>time</parameter>, then *( <parameter>have_more</parameter>) is set to 1 to indicate that the applicationshould recall the function with the same timestamp to get more data.</para><para> When the rtp session is scheduled (see <link linkend="rtp-session-set-scheduling-mode"><function>rtp_session_set_scheduling_mode()</function></link> ), and the blocking mode is on (see <link linkend="rtp-session-set-blocking-mode"><function>rtp_session_set_blocking_mode()</function></link> ), then the calling threadis suspended until the timestamp given as argument expires, whatever a received packet fits the query or not.</para><para>Important note: it is clear that the application cannot know the timestamp of the firstpacket of the incoming stream, because it can be random. The <parameter>time</parameter> timestamp given to thefunction is used relatively to first timestamp of the stream. In simple words, 0 is a goodvalue to start calling this function.</para><para>This function internally calls <link linkend="rtp-session-recvm-with-ts"><function>rtp_session_recvm_with_ts()</function></link> to get a rtp packet. The contentof 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 incomingstream has a different packet size.</para><para></para><variablelist role="params"><varlistentry><term><parameter>session</parameter>&nbsp;:</term><listitem><simpara> a rtp session.</simpara></listitem></varlistentry><varlistentry><term><parameter>buffer</parameter>&nbsp;:</term><listitem><simpara>	a user supplied buffer to write the data.</simpara></listitem></varlistentry><varlistentry><term><parameter>len</parameter>&nbsp;:</term><listitem><simpara>		the length in bytes of the user supplied buffer.</simpara></listitem></varlistentry><varlistentry><term><parameter>time</parameter>&nbsp;:</term><listitem><simpara>	the timestamp wanted.</simpara></listitem></varlistentry><varlistentry><term><parameter>have_more</parameter>&nbsp;:</term><listitem><simpara> the address of an integer to indicate if more data is availlable for the given timestamp.</simpara></listitem></varlistentry><varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> 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 packetsare availlable, either because the sender has not started to send the stream, or eitherbecause silence packet are not transmitted, or either because the packet was lost duringnetwork transport, then the function returns zero.</simpara></listitem></varlistentry></variablelist></refsect2><refsect2><title><anchor id="rtp-session-recvm-with-ts" role="function">rtp_session_recvm_with_ts ()</title><indexterm><primary>rtp_session_recvm_with_ts</primary></indexterm><programlisting><link linkend="mblk-t">mblk_t</link>*     rtp_session_recvm_with_ts       (<link linkend="RtpSession">RtpSession</link> *session,                                             <link linkend="uint32-t">uint32_t</link> user_ts);</programlisting><para>Try to get a rtp packet presented as a mblk_t structure from the rtp session.The <parameter>user_ts</parameter> parameter is relative to the first timestamp of the incoming stream. In otherwords, the application does not have to know the first timestamp of the stream, it cansimply call for the first time this function with <parameter>user_ts</parameter>=0, and then incrementing itas it want. The RtpSession takes care of synchronisation between the stream timestampand the user timestamp given here.</para><para></para><variablelist role="params"><varlistentry><term><parameter>session</parameter>&nbsp;:</term>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -