mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 07:58:51 +00:00
Fix parsing of RB blocks.
Original commit message from CVS: * docs/libs/gst-plugins-base-libs-sections.txt: * gst-libs/gst/rtp/gstrtcpbuffer.c: (gst_rtcp_packet_get_rb), (gst_rtcp_packet_sdes_copy_entry), (gst_rtcp_ntp_to_unix), (gst_rtcp_unix_to_ntp): * gst-libs/gst/rtp/gstrtcpbuffer.h: Fix parsing of RB blocks. Fix docs. Added helper functions to convert to/from UNIX and NTP time. API: gst_rtcp_ntp_to_unix() API: gst_rtcp_unix_to_ntp() * gst-libs/gst/rtp/gstrtpbuffer.c: (gst_rtp_buffer_validate_data), (gst_rtp_buffer_get_header_len), (gst_rtp_buffer_get_extension_data), (gst_rtp_buffer_get_payload_subbuffer), (gst_rtp_buffer_get_payload_len), (gst_rtp_buffer_get_payload), (gst_rtp_buffer_ext_timestamp): * gst-libs/gst/rtp/gstrtpbuffer.h: Fix some more docs. Implement handling of packets with extensions. Fix padding check in _validate(). Added function to get extension data. API: gst_rtp_buffer_get_header_len() API: gst_rtp_buffer_get_extension_data()
This commit is contained in:
parent
0cfb3152b9
commit
6f93db5ab5
6 changed files with 342 additions and 129 deletions
27
ChangeLog
27
ChangeLog
|
@ -1,3 +1,30 @@
|
||||||
|
2007-09-03 Wim Taymans <wim.taymans@gmail.com>
|
||||||
|
|
||||||
|
* docs/libs/gst-plugins-base-libs-sections.txt:
|
||||||
|
* gst-libs/gst/rtp/gstrtcpbuffer.c: (gst_rtcp_packet_get_rb),
|
||||||
|
(gst_rtcp_packet_sdes_copy_entry), (gst_rtcp_ntp_to_unix),
|
||||||
|
(gst_rtcp_unix_to_ntp):
|
||||||
|
* gst-libs/gst/rtp/gstrtcpbuffer.h:
|
||||||
|
Fix parsing of RB blocks.
|
||||||
|
Fix docs.
|
||||||
|
Added helper functions to convert to/from UNIX and NTP time.
|
||||||
|
API: gst_rtcp_ntp_to_unix()
|
||||||
|
API: gst_rtcp_unix_to_ntp()
|
||||||
|
|
||||||
|
* gst-libs/gst/rtp/gstrtpbuffer.c: (gst_rtp_buffer_validate_data),
|
||||||
|
(gst_rtp_buffer_get_header_len),
|
||||||
|
(gst_rtp_buffer_get_extension_data),
|
||||||
|
(gst_rtp_buffer_get_payload_subbuffer),
|
||||||
|
(gst_rtp_buffer_get_payload_len), (gst_rtp_buffer_get_payload),
|
||||||
|
(gst_rtp_buffer_ext_timestamp):
|
||||||
|
* gst-libs/gst/rtp/gstrtpbuffer.h:
|
||||||
|
Fix some more docs.
|
||||||
|
Implement handling of packets with extensions.
|
||||||
|
Fix padding check in _validate().
|
||||||
|
Added function to get extension data.
|
||||||
|
API: gst_rtp_buffer_get_header_len()
|
||||||
|
API: gst_rtp_buffer_get_extension_data()
|
||||||
|
|
||||||
2007-09-03 Wim Taymans <wim.taymans@gmail.com>
|
2007-09-03 Wim Taymans <wim.taymans@gmail.com>
|
||||||
|
|
||||||
* gst-libs/gst/rtp/gstbasertpdepayload.c:
|
* gst-libs/gst/rtp/gstbasertpdepayload.c:
|
||||||
|
|
|
@ -846,45 +846,61 @@ GstRTCPType
|
||||||
GstRTCPPacket
|
GstRTCPPacket
|
||||||
GstRTCPSDESType
|
GstRTCPSDESType
|
||||||
|
|
||||||
gst_rtcp_buffer_end
|
|
||||||
gst_rtcp_buffer_new
|
|
||||||
gst_rtcp_buffer_add_packet
|
|
||||||
gst_rtcp_buffer_get_first_packet
|
|
||||||
gst_rtcp_buffer_get_packet_count
|
|
||||||
gst_rtcp_buffer_new_copy_data
|
|
||||||
gst_rtcp_buffer_new_take_data
|
gst_rtcp_buffer_new_take_data
|
||||||
gst_rtcp_buffer_validate
|
gst_rtcp_buffer_new_copy_data
|
||||||
|
|
||||||
gst_rtcp_buffer_validate_data
|
gst_rtcp_buffer_validate_data
|
||||||
gst_rtcp_packet_add_rb
|
gst_rtcp_buffer_validate
|
||||||
gst_rtcp_packet_bye_add_ssrc
|
|
||||||
gst_rtcp_packet_bye_add_ssrcs
|
gst_rtcp_buffer_new
|
||||||
gst_rtcp_packet_bye_get_nth_ssrc
|
gst_rtcp_buffer_end
|
||||||
gst_rtcp_packet_bye_get_reason
|
|
||||||
gst_rtcp_packet_bye_get_reason_len
|
gst_rtcp_buffer_get_packet_count
|
||||||
gst_rtcp_packet_bye_get_ssrc_count
|
gst_rtcp_buffer_get_first_packet
|
||||||
gst_rtcp_packet_bye_set_reason
|
|
||||||
gst_rtcp_packet_get_count
|
|
||||||
gst_rtcp_packet_get_length
|
|
||||||
gst_rtcp_packet_get_padding
|
|
||||||
gst_rtcp_packet_get_rb
|
|
||||||
gst_rtcp_packet_get_rb_count
|
|
||||||
gst_rtcp_packet_get_type
|
|
||||||
gst_rtcp_packet_move_to_next
|
gst_rtcp_packet_move_to_next
|
||||||
|
gst_rtcp_buffer_add_packet
|
||||||
gst_rtcp_packet_remove
|
gst_rtcp_packet_remove
|
||||||
gst_rtcp_packet_rr_get_ssrc
|
|
||||||
gst_rtcp_packet_rr_set_ssrc
|
gst_rtcp_packet_get_padding
|
||||||
gst_rtcp_packet_sdes_add_entry
|
gst_rtcp_packet_get_count
|
||||||
gst_rtcp_packet_sdes_add_item
|
gst_rtcp_packet_get_type
|
||||||
gst_rtcp_packet_sdes_first_entry
|
gst_rtcp_packet_get_length
|
||||||
gst_rtcp_packet_sdes_first_item
|
|
||||||
gst_rtcp_packet_sdes_get_entry
|
|
||||||
gst_rtcp_packet_sdes_get_item_count
|
|
||||||
gst_rtcp_packet_sdes_get_ssrc
|
|
||||||
gst_rtcp_packet_sdes_next_entry
|
|
||||||
gst_rtcp_packet_sdes_next_item
|
|
||||||
gst_rtcp_packet_set_rb
|
|
||||||
gst_rtcp_packet_sr_get_sender_info
|
gst_rtcp_packet_sr_get_sender_info
|
||||||
gst_rtcp_packet_sr_set_sender_info
|
gst_rtcp_packet_sr_set_sender_info
|
||||||
|
|
||||||
|
gst_rtcp_packet_rr_get_ssrc
|
||||||
|
gst_rtcp_packet_rr_set_ssrc
|
||||||
|
|
||||||
|
gst_rtcp_packet_get_rb_count
|
||||||
|
gst_rtcp_packet_get_rb
|
||||||
|
gst_rtcp_packet_add_rb
|
||||||
|
gst_rtcp_packet_set_rb
|
||||||
|
|
||||||
|
gst_rtcp_packet_sdes_get_item_count
|
||||||
|
gst_rtcp_packet_sdes_first_item
|
||||||
|
gst_rtcp_packet_sdes_next_item
|
||||||
|
gst_rtcp_packet_sdes_get_ssrc
|
||||||
|
gst_rtcp_packet_sdes_first_entry
|
||||||
|
gst_rtcp_packet_sdes_next_entry
|
||||||
|
gst_rtcp_packet_sdes_get_entry
|
||||||
|
gst_rtcp_packet_sdes_copy_entry
|
||||||
|
|
||||||
|
gst_rtcp_packet_sdes_add_item
|
||||||
|
gst_rtcp_packet_sdes_add_entry
|
||||||
|
|
||||||
|
gst_rtcp_packet_bye_get_ssrc_count
|
||||||
|
gst_rtcp_packet_bye_get_nth_ssrc
|
||||||
|
gst_rtcp_packet_bye_add_ssrc
|
||||||
|
gst_rtcp_packet_bye_add_ssrcs
|
||||||
|
|
||||||
|
gst_rtcp_packet_bye_get_reason_len
|
||||||
|
gst_rtcp_packet_bye_get_reason
|
||||||
|
gst_rtcp_packet_bye_set_reason
|
||||||
|
|
||||||
|
gst_rtcp_ntp_to_unix
|
||||||
|
gst_rtcp_unix_to_ntp
|
||||||
|
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
|
@ -896,42 +912,63 @@ GstRTPPayload
|
||||||
GST_RTP_VERSION
|
GST_RTP_VERSION
|
||||||
|
|
||||||
gst_rtp_buffer_allocate_data
|
gst_rtp_buffer_allocate_data
|
||||||
|
|
||||||
|
gst_rtp_buffer_new_take_data
|
||||||
|
gst_rtp_buffer_new_copy_data
|
||||||
|
gst_rtp_buffer_new_allocate
|
||||||
|
gst_rtp_buffer_new_allocate_len
|
||||||
|
|
||||||
gst_rtp_buffer_calc_header_len
|
gst_rtp_buffer_calc_header_len
|
||||||
gst_rtp_buffer_calc_packet_len
|
gst_rtp_buffer_calc_packet_len
|
||||||
gst_rtp_buffer_calc_payload_len
|
gst_rtp_buffer_calc_payload_len
|
||||||
gst_rtp_buffer_default_clock_rate
|
|
||||||
gst_rtp_buffer_get_csrc
|
gst_rtp_buffer_validate
|
||||||
gst_rtp_buffer_get_csrc_count
|
gst_rtp_buffer_validate_data
|
||||||
gst_rtp_buffer_get_extension
|
|
||||||
gst_rtp_buffer_get_marker
|
gst_rtp_buffer_set_packet_len
|
||||||
gst_rtp_buffer_get_packet_len
|
gst_rtp_buffer_get_packet_len
|
||||||
|
|
||||||
|
gst_rtp_buffer_get_header_len
|
||||||
|
|
||||||
|
gst_rtp_buffer_get_version
|
||||||
|
gst_rtp_buffer_set_version
|
||||||
|
|
||||||
gst_rtp_buffer_get_padding
|
gst_rtp_buffer_get_padding
|
||||||
gst_rtp_buffer_get_payload
|
gst_rtp_buffer_set_padding
|
||||||
|
gst_rtp_buffer_pad_to
|
||||||
|
|
||||||
|
gst_rtp_buffer_get_extension
|
||||||
|
gst_rtp_buffer_set_extension
|
||||||
|
gst_rtp_buffer_get_extension_data
|
||||||
|
|
||||||
|
gst_rtp_buffer_get_ssrc
|
||||||
|
gst_rtp_buffer_set_ssrc
|
||||||
|
|
||||||
|
gst_rtp_buffer_get_csrc_count
|
||||||
|
gst_rtp_buffer_get_csrc
|
||||||
|
gst_rtp_buffer_set_csrc
|
||||||
|
|
||||||
|
gst_rtp_buffer_get_marker
|
||||||
|
gst_rtp_buffer_set_marker
|
||||||
|
|
||||||
|
gst_rtp_buffer_get_payload_type
|
||||||
|
gst_rtp_buffer_set_payload_type
|
||||||
|
|
||||||
|
gst_rtp_buffer_get_seq
|
||||||
|
gst_rtp_buffer_set_seq
|
||||||
|
|
||||||
|
gst_rtp_buffer_get_timestamp
|
||||||
|
gst_rtp_buffer_set_timestamp
|
||||||
|
|
||||||
gst_rtp_buffer_get_payload_buffer
|
gst_rtp_buffer_get_payload_buffer
|
||||||
gst_rtp_buffer_get_payload_subbuffer
|
gst_rtp_buffer_get_payload_subbuffer
|
||||||
gst_rtp_buffer_get_payload_len
|
gst_rtp_buffer_get_payload_len
|
||||||
gst_rtp_buffer_get_payload_type
|
gst_rtp_buffer_get_payload
|
||||||
gst_rtp_buffer_get_seq
|
|
||||||
gst_rtp_buffer_get_ssrc
|
gst_rtp_buffer_default_clock_rate
|
||||||
gst_rtp_buffer_get_timestamp
|
gst_rtp_buffer_compare_seqnum
|
||||||
gst_rtp_buffer_get_version
|
gst_rtp_buffer_ext_timestamp
|
||||||
gst_rtp_buffer_new_allocate
|
|
||||||
gst_rtp_buffer_new_allocate_len
|
|
||||||
gst_rtp_buffer_new_copy_data
|
|
||||||
gst_rtp_buffer_new_take_data
|
|
||||||
gst_rtp_buffer_pad_to
|
|
||||||
gst_rtp_buffer_set_csrc
|
|
||||||
gst_rtp_buffer_set_extension
|
|
||||||
gst_rtp_buffer_set_marker
|
|
||||||
gst_rtp_buffer_set_packet_len
|
|
||||||
gst_rtp_buffer_set_padding
|
|
||||||
gst_rtp_buffer_set_payload_type
|
|
||||||
gst_rtp_buffer_set_seq
|
|
||||||
gst_rtp_buffer_set_ssrc
|
|
||||||
gst_rtp_buffer_set_timestamp
|
|
||||||
gst_rtp_buffer_set_version
|
|
||||||
gst_rtp_buffer_validate
|
|
||||||
gst_rtp_buffer_validate_data
|
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
GST_RTP_PAYLOAD_DYNAMIC_STRING
|
GST_RTP_PAYLOAD_DYNAMIC_STRING
|
||||||
GST_RTP_PAYLOAD_G723_53_STRING
|
GST_RTP_PAYLOAD_G723_53_STRING
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
/**
|
/**
|
||||||
* SECTION:gstrtcpbuffer
|
* SECTION:gstrtcpbuffer
|
||||||
* @short_description: Helper methods for dealing with RTCP buffers
|
* @short_description: Helper methods for dealing with RTCP buffers
|
||||||
* @see_also: gstbasertppayload, gstbasertpdepayload
|
* @see_also: #GstBaseRTPPayload, #GstBaseRTPDepayload, #gstrtpbuffer
|
||||||
*
|
*
|
||||||
* Note: The API in this module is not yet declared stable.
|
* Note: The API in this module is not yet declared stable.
|
||||||
*
|
*
|
||||||
|
@ -246,6 +246,9 @@ gst_rtcp_buffer_new (guint mtu)
|
||||||
*
|
*
|
||||||
* Finish @buffer after being constructured. This function is usually called
|
* Finish @buffer after being constructured. This function is usually called
|
||||||
* after gst_rtcp_buffer_new() and after adding the RTCP items to the new buffer.
|
* after gst_rtcp_buffer_new() and after adding the RTCP items to the new buffer.
|
||||||
|
*
|
||||||
|
* The function adjusts the size of @buffer with the total length of all the
|
||||||
|
* added packets.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_rtcp_buffer_end (GstBuffer * buffer)
|
gst_rtcp_buffer_end (GstBuffer * buffer)
|
||||||
|
@ -758,7 +761,6 @@ gst_rtcp_packet_get_rb (GstRTCPPacket * packet, guint nth, guint32 * ssrc,
|
||||||
*ssrc = GST_READ_UINT32_BE (data);
|
*ssrc = GST_READ_UINT32_BE (data);
|
||||||
data += 4;
|
data += 4;
|
||||||
tmp = GST_READ_UINT32_BE (data);
|
tmp = GST_READ_UINT32_BE (data);
|
||||||
data += 4;
|
|
||||||
if (fractionlost)
|
if (fractionlost)
|
||||||
*fractionlost = (tmp >> 24);
|
*fractionlost = (tmp >> 24);
|
||||||
if (packetslost) {
|
if (packetslost) {
|
||||||
|
@ -1563,8 +1565,6 @@ gst_rtcp_packet_bye_get_reason (GstRTCPPacket * packet)
|
||||||
* Set the reason string to @reason in @packet.
|
* Set the reason string to @reason in @packet.
|
||||||
*
|
*
|
||||||
* Returns: TRUE if the string could be set.
|
* Returns: TRUE if the string could be set.
|
||||||
*
|
|
||||||
* Note: Not implemented.
|
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_rtcp_packet_bye_set_reason (GstRTCPPacket * packet, const gchar * reason)
|
gst_rtcp_packet_bye_set_reason (GstRTCPPacket * packet, const gchar * reason)
|
||||||
|
@ -1618,3 +1618,55 @@ no_space:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_rtcp_ntp_to_unix:
|
||||||
|
* @ntptime: an NTP timestamp
|
||||||
|
*
|
||||||
|
* Converts an NTP time to UNIX nanoseconds. @ntptime can typically be
|
||||||
|
* the NTP time of an SR RTCP message and contains, in the upper 32 bits, the
|
||||||
|
* number of seconds since 1900 and, in the lower 32 bits, the fractional
|
||||||
|
* seconds. The resulting value will be the number of nanoseconds since 1970.
|
||||||
|
*
|
||||||
|
* Returns: the UNIX time for @ntptime in nanoseconds.
|
||||||
|
*/
|
||||||
|
guint64
|
||||||
|
gst_rtcp_ntp_to_unix (guint64 ntptime)
|
||||||
|
{
|
||||||
|
guint64 unixtime;
|
||||||
|
|
||||||
|
/* conversion from NTP timestamp (seconds since 1900) to seconds since
|
||||||
|
* 1970. */
|
||||||
|
unixtime = ntptime - (2208988800LL << 32);
|
||||||
|
/* conversion to nanoseconds */
|
||||||
|
unixtime = gst_util_uint64_scale (unixtime, GST_SECOND, (1LL << 32));
|
||||||
|
|
||||||
|
return unixtime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_rtcp_unix_to_ntp:
|
||||||
|
* @unixtime: an UNIX timestamp in nanoseconds
|
||||||
|
*
|
||||||
|
* Converts a UNIX timestamp in nanoseconds to an NTP time. The caller should
|
||||||
|
* pass a value with nanoseconds since 1970. The NTP time will, in the upper
|
||||||
|
* 32 bits, contain the number of seconds since 1900 and, in the lower 32
|
||||||
|
* bits, the fractional seconds. The resulting value can be used as an ntptime
|
||||||
|
* for constructing SR RTCP packets.
|
||||||
|
*
|
||||||
|
* Returns: the NTP time for @gsttime.
|
||||||
|
*/
|
||||||
|
guint64
|
||||||
|
gst_rtcp_unix_to_ntp (guint64 unixtime)
|
||||||
|
{
|
||||||
|
guint64 ntptime;
|
||||||
|
|
||||||
|
/* convert clock time to NTP time. upper 32 bits should contain the seconds
|
||||||
|
* and the lower 32 bits, the fractions of a second. */
|
||||||
|
ntptime = gst_util_uint64_scale (unixtime, (1LL << 32), GST_SECOND);
|
||||||
|
/* conversion from UNIX timestamp (seconds since 1970) to NTP (seconds
|
||||||
|
* since 1900). */
|
||||||
|
ntptime += (2208988800LL << 32);
|
||||||
|
|
||||||
|
return ntptime;
|
||||||
|
}
|
||||||
|
|
|
@ -179,15 +179,15 @@ guint16 gst_rtcp_packet_get_length (GstRTCPPacket *packet);
|
||||||
|
|
||||||
|
|
||||||
/* sender reports */
|
/* sender reports */
|
||||||
void gst_rtcp_packet_sr_get_sender_info (GstRTCPPacket *packet, guint32 *ssrc,
|
void gst_rtcp_packet_sr_get_sender_info (GstRTCPPacket *packet, guint32 *ssrc,
|
||||||
guint64 *ntptime, guint32 *rtptime,
|
guint64 *ntptime, guint32 *rtptime,
|
||||||
guint32 *packet_count, guint32 *octet_count);
|
guint32 *packet_count, guint32 *octet_count);
|
||||||
void gst_rtcp_packet_sr_set_sender_info (GstRTCPPacket *packet, guint32 ssrc,
|
void gst_rtcp_packet_sr_set_sender_info (GstRTCPPacket *packet, guint32 ssrc,
|
||||||
guint64 ntptime, guint32 rtptime,
|
guint64 ntptime, guint32 rtptime,
|
||||||
guint32 packet_count, guint32 octet_count);
|
guint32 packet_count, guint32 octet_count);
|
||||||
/* receiver reports */
|
/* receiver reports */
|
||||||
guint32 gst_rtcp_packet_rr_get_ssrc (GstRTCPPacket *packet);
|
guint32 gst_rtcp_packet_rr_get_ssrc (GstRTCPPacket *packet);
|
||||||
void gst_rtcp_packet_rr_set_ssrc (GstRTCPPacket *packet, guint32 ssrc);
|
void gst_rtcp_packet_rr_set_ssrc (GstRTCPPacket *packet, guint32 ssrc);
|
||||||
|
|
||||||
|
|
||||||
/* report blocks for SR and RR */
|
/* report blocks for SR and RR */
|
||||||
|
@ -224,13 +224,17 @@ gboolean gst_rtcp_packet_sdes_add_entry (GstRTCPPacket *packet, Gs
|
||||||
guint8 len, const guint8 *data);
|
guint8 len, const guint8 *data);
|
||||||
|
|
||||||
/* bye packet */
|
/* bye packet */
|
||||||
guint gst_rtcp_packet_bye_get_ssrc_count (GstRTCPPacket *packet);
|
guint gst_rtcp_packet_bye_get_ssrc_count (GstRTCPPacket *packet);
|
||||||
guint32 gst_rtcp_packet_bye_get_nth_ssrc (GstRTCPPacket *packet, guint nth);
|
guint32 gst_rtcp_packet_bye_get_nth_ssrc (GstRTCPPacket *packet, guint nth);
|
||||||
gboolean gst_rtcp_packet_bye_add_ssrc (GstRTCPPacket *packet, guint32 ssrc);
|
gboolean gst_rtcp_packet_bye_add_ssrc (GstRTCPPacket *packet, guint32 ssrc);
|
||||||
gboolean gst_rtcp_packet_bye_add_ssrcs (GstRTCPPacket *packet, guint32 *ssrc, guint len);
|
gboolean gst_rtcp_packet_bye_add_ssrcs (GstRTCPPacket *packet, guint32 *ssrc, guint len);
|
||||||
guint8 gst_rtcp_packet_bye_get_reason_len (GstRTCPPacket *packet);
|
guint8 gst_rtcp_packet_bye_get_reason_len (GstRTCPPacket *packet);
|
||||||
gchar* gst_rtcp_packet_bye_get_reason (GstRTCPPacket *packet);
|
gchar* gst_rtcp_packet_bye_get_reason (GstRTCPPacket *packet);
|
||||||
gboolean gst_rtcp_packet_bye_set_reason (GstRTCPPacket *packet, const gchar *reason);
|
gboolean gst_rtcp_packet_bye_set_reason (GstRTCPPacket *packet, const gchar *reason);
|
||||||
|
|
||||||
|
/* helper functions */
|
||||||
|
guint64 gst_rtcp_ntp_to_unix (guint64 ntptime);
|
||||||
|
guint64 gst_rtcp_unix_to_ntp (guint64 unixtime);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
/**
|
/**
|
||||||
* SECTION:gstrtpbuffer
|
* SECTION:gstrtpbuffer
|
||||||
* @short_description: Helper methods for dealing with RTP buffers
|
* @short_description: Helper methods for dealing with RTP buffers
|
||||||
* @see_also: gstbasertppayload, gstbasertpdepayload
|
* @see_also: #GstBaseRTPPayload, #GstBaseRTPDepayload, gstrtcpbuffer
|
||||||
*
|
*
|
||||||
* <refsect2>
|
* <refsect2>
|
||||||
* <para>
|
* <para>
|
||||||
|
@ -308,8 +308,29 @@ gst_rtp_buffer_validate_data (guint8 * data, guint len)
|
||||||
csrc_count = (data[0] & 0x0f);
|
csrc_count = (data[0] & 0x0f);
|
||||||
header_len += csrc_count * sizeof (guint32);
|
header_len += csrc_count * sizeof (guint32);
|
||||||
|
|
||||||
|
/* calc extension length when present. */
|
||||||
|
if (data[0] & 0x10) {
|
||||||
|
guint8 *extpos;
|
||||||
|
guint16 extlen;
|
||||||
|
|
||||||
|
/* this points to the extenstion bits and header length */
|
||||||
|
extpos = &data[header_len];
|
||||||
|
|
||||||
|
/* skip the header and check that we have enough space */
|
||||||
|
header_len += 4;
|
||||||
|
if (G_UNLIKELY (len < header_len))
|
||||||
|
goto wrong_length;
|
||||||
|
|
||||||
|
/* skip id */
|
||||||
|
extpos += 2;
|
||||||
|
/* read length as the number of 32 bits words */
|
||||||
|
extlen = GST_READ_UINT16_BE (extpos);
|
||||||
|
|
||||||
|
header_len += extlen * sizeof (guint32);
|
||||||
|
}
|
||||||
|
|
||||||
/* check for padding */
|
/* check for padding */
|
||||||
if (data[0] & 0x40)
|
if (data[0] & 0x20)
|
||||||
padding = data[len - 1];
|
padding = data[len - 1];
|
||||||
else
|
else
|
||||||
padding = 0;
|
padding = 0;
|
||||||
|
@ -408,6 +429,29 @@ gst_rtp_buffer_get_packet_len (GstBuffer * buffer)
|
||||||
return GST_BUFFER_SIZE (buffer);
|
return GST_BUFFER_SIZE (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_rtp_buffer_get_header_len:
|
||||||
|
* @buffer: the buffer
|
||||||
|
*
|
||||||
|
* Return the total length of the header in @buffer. This include the length of
|
||||||
|
* the fixed header, the CSRC list and the extension header.
|
||||||
|
*
|
||||||
|
* Returns: The total length of the header in @buffer.
|
||||||
|
*/
|
||||||
|
guint
|
||||||
|
gst_rtp_buffer_get_header_len (GstBuffer * buffer)
|
||||||
|
{
|
||||||
|
guint len;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_IS_BUFFER (buffer), 0);
|
||||||
|
|
||||||
|
len = GST_RTP_HEADER_LEN + GST_RTP_HEADER_CSRC_SIZE (buffer);
|
||||||
|
if (GST_RTP_HEADER_EXTENSION (buffer))
|
||||||
|
len += GST_READ_UINT16_BE (GST_BUFFER_DATA (buffer) + len + 2) * 4 + 4;
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_rtp_buffer_get_version:
|
* gst_rtp_buffer_get_version:
|
||||||
* @buffer: the buffer
|
* @buffer: the buffer
|
||||||
|
@ -480,7 +524,7 @@ gst_rtp_buffer_set_padding (GstBuffer * buffer, gboolean padding)
|
||||||
* @buffer: the buffer
|
* @buffer: the buffer
|
||||||
* @len: the new amount of padding
|
* @len: the new amount of padding
|
||||||
*
|
*
|
||||||
* Set the amount of padding in the RTP packing in @buffer to
|
* Set the amount of padding in the RTP packet in @buffer to
|
||||||
* @len. If @len is 0, the padding is removed.
|
* @len. If @len is 0, the padding is removed.
|
||||||
*
|
*
|
||||||
* NOTE: This function does not work correctly.
|
* NOTE: This function does not work correctly.
|
||||||
|
@ -532,6 +576,51 @@ gst_rtp_buffer_set_extension (GstBuffer * buffer, gboolean extension)
|
||||||
GST_RTP_HEADER_EXTENSION (buffer) = extension;
|
GST_RTP_HEADER_EXTENSION (buffer) = extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_rtp_buffer_get_extension_data:
|
||||||
|
* @buffer: the buffer
|
||||||
|
* @bits: location for result bits
|
||||||
|
* @data: location for data
|
||||||
|
* @wordlen: location for length of @data in 32 bits words
|
||||||
|
*
|
||||||
|
* Get the extension data. @bits will contain the extrnsion 16 bits of custom
|
||||||
|
* data. @data will point to the data in the extension and @wordlen will contain
|
||||||
|
* the length of @data in 32 bits words.
|
||||||
|
*
|
||||||
|
* If @buffer did not contain an extenstion, this function will return %FALSE
|
||||||
|
* with @bits, @data and @wordlen unchanged.
|
||||||
|
*
|
||||||
|
* Returns: TRUE if @buffer had the extension bit set.
|
||||||
|
*
|
||||||
|
* Since: 0.10.15
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gst_rtp_buffer_get_extension_data (GstBuffer * buffer, guint16 * bits,
|
||||||
|
gpointer * data, guint * wordlen)
|
||||||
|
{
|
||||||
|
guint len;
|
||||||
|
guint8 *pdata;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
|
||||||
|
g_return_val_if_fail (GST_BUFFER_DATA (buffer) != NULL, FALSE);
|
||||||
|
|
||||||
|
if (GST_RTP_HEADER_EXTENSION (buffer))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/* move to the extension */
|
||||||
|
len = GST_RTP_HEADER_LEN + GST_RTP_HEADER_CSRC_SIZE (buffer);
|
||||||
|
pdata = GST_BUFFER_DATA (buffer) + len;
|
||||||
|
|
||||||
|
if (bits)
|
||||||
|
*bits = GST_READ_UINT16_BE (pdata);
|
||||||
|
if (wordlen)
|
||||||
|
*wordlen = GST_READ_UINT16_BE (pdata + 2);
|
||||||
|
if (data)
|
||||||
|
*data = pdata + 4;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_rtp_buffer_get_ssrc:
|
* gst_rtp_buffer_get_ssrc:
|
||||||
* @buffer: the buffer
|
* @buffer: the buffer
|
||||||
|
@ -780,10 +869,10 @@ gst_rtp_buffer_get_payload_subbuffer (GstBuffer * buffer, guint offset,
|
||||||
g_return_val_if_fail (offset < plen, NULL);
|
g_return_val_if_fail (offset < plen, NULL);
|
||||||
|
|
||||||
/* apply offset */
|
/* apply offset */
|
||||||
poffset = GST_RTP_HEADER_LEN + GST_RTP_HEADER_CSRC_SIZE (buffer) + offset;
|
poffset = gst_rtp_buffer_get_header_len (buffer) + offset;
|
||||||
plen -= offset;
|
plen -= offset;
|
||||||
|
|
||||||
/* see if we need to shrink the buffer even based on @len */
|
/* see if we need to shrink the buffer based on @len */
|
||||||
if (len != -1 && len < plen)
|
if (len != -1 && len < plen)
|
||||||
plen = len;
|
plen = len;
|
||||||
|
|
||||||
|
@ -817,16 +906,17 @@ gst_rtp_buffer_get_payload_buffer (GstBuffer * buffer)
|
||||||
guint
|
guint
|
||||||
gst_rtp_buffer_get_payload_len (GstBuffer * buffer)
|
gst_rtp_buffer_get_payload_len (GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
guint len;
|
guint len, size;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_BUFFER (buffer), 0);
|
g_return_val_if_fail (GST_IS_BUFFER (buffer), 0);
|
||||||
g_return_val_if_fail (GST_BUFFER_DATA (buffer) != NULL, 0);
|
g_return_val_if_fail (GST_BUFFER_DATA (buffer) != NULL, 0);
|
||||||
|
|
||||||
len = GST_BUFFER_SIZE (buffer)
|
size = GST_BUFFER_SIZE (buffer);
|
||||||
- GST_RTP_HEADER_LEN - GST_RTP_HEADER_CSRC_SIZE (buffer);
|
|
||||||
|
len = size - gst_rtp_buffer_get_header_len (buffer);
|
||||||
|
|
||||||
if (GST_RTP_HEADER_PADDING (buffer))
|
if (GST_RTP_HEADER_PADDING (buffer))
|
||||||
len -= ((guint8 *) GST_BUFFER_DATA (buffer))[GST_BUFFER_SIZE (buffer) - 1];
|
len -= GST_BUFFER_DATA (buffer)[size - 1];
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
@ -846,8 +936,7 @@ gst_rtp_buffer_get_payload (GstBuffer * buffer)
|
||||||
g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
|
g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
|
||||||
g_return_val_if_fail (GST_BUFFER_DATA (buffer) != NULL, NULL);
|
g_return_val_if_fail (GST_BUFFER_DATA (buffer) != NULL, NULL);
|
||||||
|
|
||||||
return GST_BUFFER_DATA (buffer) + GST_RTP_HEADER_LEN
|
return GST_BUFFER_DATA (buffer) + gst_rtp_buffer_get_header_len (buffer);
|
||||||
+ GST_RTP_HEADER_CSRC_SIZE (buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -160,63 +160,67 @@ typedef enum
|
||||||
#define GST_RTP_PAYLOAD_DYNAMIC_STRING "[96, 127]"
|
#define GST_RTP_PAYLOAD_DYNAMIC_STRING "[96, 127]"
|
||||||
|
|
||||||
/* creating buffers */
|
/* creating buffers */
|
||||||
void gst_rtp_buffer_allocate_data (GstBuffer *buffer, guint payload_len,
|
void gst_rtp_buffer_allocate_data (GstBuffer *buffer, guint payload_len,
|
||||||
guint8 pad_len, guint8 csrc_count);
|
guint8 pad_len, guint8 csrc_count);
|
||||||
|
|
||||||
GstBuffer* gst_rtp_buffer_new_take_data (gpointer data, guint len);
|
GstBuffer* gst_rtp_buffer_new_take_data (gpointer data, guint len);
|
||||||
GstBuffer* gst_rtp_buffer_new_copy_data (gpointer data, guint len);
|
GstBuffer* gst_rtp_buffer_new_copy_data (gpointer data, guint len);
|
||||||
GstBuffer* gst_rtp_buffer_new_allocate (guint payload_len, guint8 pad_len, guint8 csrc_count);
|
GstBuffer* gst_rtp_buffer_new_allocate (guint payload_len, guint8 pad_len, guint8 csrc_count);
|
||||||
GstBuffer* gst_rtp_buffer_new_allocate_len (guint packet_len, guint8 pad_len, guint8 csrc_count);
|
GstBuffer* gst_rtp_buffer_new_allocate_len (guint packet_len, guint8 pad_len, guint8 csrc_count);
|
||||||
|
|
||||||
guint gst_rtp_buffer_calc_header_len (guint8 csrc_count);
|
guint gst_rtp_buffer_calc_header_len (guint8 csrc_count);
|
||||||
guint gst_rtp_buffer_calc_packet_len (guint payload_len, guint8 pad_len, guint8 csrc_count);
|
guint gst_rtp_buffer_calc_packet_len (guint payload_len, guint8 pad_len, guint8 csrc_count);
|
||||||
guint gst_rtp_buffer_calc_payload_len (guint packet_len, guint8 pad_len, guint8 csrc_count);
|
guint gst_rtp_buffer_calc_payload_len (guint packet_len, guint8 pad_len, guint8 csrc_count);
|
||||||
|
|
||||||
gboolean gst_rtp_buffer_validate_data (guint8 *data, guint len);
|
gboolean gst_rtp_buffer_validate_data (guint8 *data, guint len);
|
||||||
gboolean gst_rtp_buffer_validate (GstBuffer *buffer);
|
gboolean gst_rtp_buffer_validate (GstBuffer *buffer);
|
||||||
|
|
||||||
void gst_rtp_buffer_set_packet_len (GstBuffer *buffer, guint len);
|
void gst_rtp_buffer_set_packet_len (GstBuffer *buffer, guint len);
|
||||||
guint gst_rtp_buffer_get_packet_len (GstBuffer *buffer);
|
guint gst_rtp_buffer_get_packet_len (GstBuffer *buffer);
|
||||||
|
|
||||||
guint8 gst_rtp_buffer_get_version (GstBuffer *buffer);
|
guint gst_rtp_buffer_get_header_len (GstBuffer *buffer);
|
||||||
void gst_rtp_buffer_set_version (GstBuffer *buffer, guint8 version);
|
|
||||||
|
|
||||||
gboolean gst_rtp_buffer_get_padding (GstBuffer *buffer);
|
guint8 gst_rtp_buffer_get_version (GstBuffer *buffer);
|
||||||
void gst_rtp_buffer_set_padding (GstBuffer *buffer, gboolean padding);
|
void gst_rtp_buffer_set_version (GstBuffer *buffer, guint8 version);
|
||||||
void gst_rtp_buffer_pad_to (GstBuffer *buffer, guint len);
|
|
||||||
|
|
||||||
gboolean gst_rtp_buffer_get_extension (GstBuffer *buffer);
|
gboolean gst_rtp_buffer_get_padding (GstBuffer *buffer);
|
||||||
void gst_rtp_buffer_set_extension (GstBuffer *buffer, gboolean extension);
|
void gst_rtp_buffer_set_padding (GstBuffer *buffer, gboolean padding);
|
||||||
|
void gst_rtp_buffer_pad_to (GstBuffer *buffer, guint len);
|
||||||
|
|
||||||
guint32 gst_rtp_buffer_get_ssrc (GstBuffer *buffer);
|
gboolean gst_rtp_buffer_get_extension (GstBuffer *buffer);
|
||||||
void gst_rtp_buffer_set_ssrc (GstBuffer *buffer, guint32 ssrc);
|
void gst_rtp_buffer_set_extension (GstBuffer *buffer, gboolean extension);
|
||||||
|
gboolean gst_rtp_buffer_get_extension_data (GstBuffer *buffer, guint16 *bits,
|
||||||
|
gpointer *data, guint *wordlen);
|
||||||
|
|
||||||
guint8 gst_rtp_buffer_get_csrc_count (GstBuffer *buffer);
|
guint32 gst_rtp_buffer_get_ssrc (GstBuffer *buffer);
|
||||||
guint32 gst_rtp_buffer_get_csrc (GstBuffer *buffer, guint8 idx);
|
void gst_rtp_buffer_set_ssrc (GstBuffer *buffer, guint32 ssrc);
|
||||||
void gst_rtp_buffer_set_csrc (GstBuffer *buffer, guint8 idx, guint32 csrc);
|
|
||||||
|
|
||||||
gboolean gst_rtp_buffer_get_marker (GstBuffer *buffer);
|
guint8 gst_rtp_buffer_get_csrc_count (GstBuffer *buffer);
|
||||||
void gst_rtp_buffer_set_marker (GstBuffer *buffer, gboolean marker);
|
guint32 gst_rtp_buffer_get_csrc (GstBuffer *buffer, guint8 idx);
|
||||||
|
void gst_rtp_buffer_set_csrc (GstBuffer *buffer, guint8 idx, guint32 csrc);
|
||||||
|
|
||||||
guint8 gst_rtp_buffer_get_payload_type (GstBuffer *buffer);
|
gboolean gst_rtp_buffer_get_marker (GstBuffer *buffer);
|
||||||
void gst_rtp_buffer_set_payload_type (GstBuffer *buffer, guint8 payload_type);
|
void gst_rtp_buffer_set_marker (GstBuffer *buffer, gboolean marker);
|
||||||
|
|
||||||
guint16 gst_rtp_buffer_get_seq (GstBuffer *buffer);
|
guint8 gst_rtp_buffer_get_payload_type (GstBuffer *buffer);
|
||||||
void gst_rtp_buffer_set_seq (GstBuffer *buffer, guint16 seq);
|
void gst_rtp_buffer_set_payload_type (GstBuffer *buffer, guint8 payload_type);
|
||||||
|
|
||||||
guint32 gst_rtp_buffer_get_timestamp (GstBuffer *buffer);
|
guint16 gst_rtp_buffer_get_seq (GstBuffer *buffer);
|
||||||
void gst_rtp_buffer_set_timestamp (GstBuffer *buffer, guint32 timestamp);
|
void gst_rtp_buffer_set_seq (GstBuffer *buffer, guint16 seq);
|
||||||
|
|
||||||
|
guint32 gst_rtp_buffer_get_timestamp (GstBuffer *buffer);
|
||||||
|
void gst_rtp_buffer_set_timestamp (GstBuffer *buffer, guint32 timestamp);
|
||||||
|
|
||||||
GstBuffer* gst_rtp_buffer_get_payload_buffer (GstBuffer *buffer);
|
GstBuffer* gst_rtp_buffer_get_payload_buffer (GstBuffer *buffer);
|
||||||
GstBuffer* gst_rtp_buffer_get_payload_subbuffer (GstBuffer *buffer, guint offset, guint len);
|
GstBuffer* gst_rtp_buffer_get_payload_subbuffer (GstBuffer *buffer, guint offset, guint len);
|
||||||
|
|
||||||
guint gst_rtp_buffer_get_payload_len (GstBuffer *buffer);
|
guint gst_rtp_buffer_get_payload_len (GstBuffer *buffer);
|
||||||
gpointer gst_rtp_buffer_get_payload (GstBuffer *buffer);
|
gpointer gst_rtp_buffer_get_payload (GstBuffer *buffer);
|
||||||
|
|
||||||
/* some helpers */
|
/* some helpers */
|
||||||
guint32 gst_rtp_buffer_default_clock_rate (guint8 payload_type);
|
guint32 gst_rtp_buffer_default_clock_rate (guint8 payload_type);
|
||||||
gint gst_rtp_buffer_compare_seqnum (guint16 seqnum1, guint16 seqnum2);
|
gint gst_rtp_buffer_compare_seqnum (guint16 seqnum1, guint16 seqnum2);
|
||||||
guint64 gst_rtp_buffer_ext_timestamp (guint64 *exttimestamp, guint32 timestamp);
|
guint64 gst_rtp_buffer_ext_timestamp (guint64 *exttimestamp, guint32 timestamp);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue