Ejemplo n.º 1
0
/**
 * gst_rtp_buffer_allocate_data:
 * @buffer: a #GstBuffer
 * @payload_len: the length of the payload
 * @pad_len: the amount of padding
 * @csrc_count: the number of CSRC entries
 *
 * Allocate enough data in @buffer to hold an RTP packet with @csrc_count CSRCs,
 * a payload length of @payload_len and padding of @pad_len.
 * MALLOCDATA of @buffer will be overwritten and will not be freed. 
 * All other RTP header fields will be set to 0/FALSE.
 */
void
gst_rtp_buffer_allocate_data (GstBuffer * buffer, guint payload_len,
    guint8 pad_len, guint8 csrc_count)
{
  guint len;
  guint8 *data;

  g_return_if_fail (csrc_count <= 15);
  g_return_if_fail (GST_IS_BUFFER (buffer));

  len = GST_RTP_HEADER_LEN + csrc_count * sizeof (guint32)
      + payload_len + pad_len;

  data = g_malloc (len);
  GST_BUFFER_MALLOCDATA (buffer) = data;
  GST_BUFFER_DATA (buffer) = data;
  GST_BUFFER_SIZE (buffer) = len;

  /* fill in defaults */
  GST_RTP_HEADER_VERSION (data) = GST_RTP_VERSION;
  GST_RTP_HEADER_PADDING (data) = FALSE;
  GST_RTP_HEADER_EXTENSION (data) = FALSE;
  GST_RTP_HEADER_CSRC_COUNT (data) = csrc_count;
  memset (GST_RTP_HEADER_CSRC_LIST_OFFSET (data, 0), 0,
      csrc_count * sizeof (guint32));
  GST_RTP_HEADER_MARKER (data) = FALSE;
  GST_RTP_HEADER_PAYLOAD_TYPE (data) = 0;
  GST_RTP_HEADER_SEQ (data) = 0;
  GST_RTP_HEADER_TIMESTAMP (data) = 0;
  GST_RTP_HEADER_SSRC (data) = 0;
}
Ejemplo n.º 2
0
/**
 * gst_rtp_buffer_set_csrc:
 * @buffer: the buffer
 * @idx: the CSRC index to set
 * @csrc: the CSRC in host order to set at @idx
 *
 * Modify the CSRC at index @idx in @buffer to @csrc.
 */
void
gst_rtp_buffer_set_csrc (GstBuffer * buffer, guint8 idx, guint32 csrc)
{
  guint8 *data;

  data = GST_BUFFER_DATA (buffer);

  g_return_if_fail (idx < GST_RTP_HEADER_CSRC_COUNT (data));

  GST_WRITE_UINT32_BE (GST_RTP_HEADER_CSRC_LIST_OFFSET (data, idx), csrc);
}
Ejemplo n.º 3
0
/**
 * gst_rtp_buffer_get_csrc:
 * @buffer: the buffer
 * @idx: the index of the CSRC to get
 *
 * Get the CSRC at index @idx in @buffer.
 * 
 * Returns: the CSRC at index @idx in host order.
 */
guint32
gst_rtp_buffer_get_csrc (GstBuffer * buffer, guint8 idx)
{
  guint8 *data;

  data = GST_BUFFER_DATA (buffer);

  g_return_val_if_fail (idx < GST_RTP_HEADER_CSRC_COUNT (data), 0);

  return GST_READ_UINT32_BE (GST_RTP_HEADER_CSRC_LIST_OFFSET (data, idx));
}
Ejemplo n.º 4
0
EXPORT_C
#endif

void
gst_rtp_buffer_set_csrc (GstBuffer * buffer, guint8 idx, guint32 csrc)
{
  g_return_if_fail (GST_IS_BUFFER (buffer));
  g_return_if_fail (GST_BUFFER_DATA (buffer) != NULL);
  g_return_if_fail (idx < GST_RTP_HEADER_CSRC_COUNT (buffer));

  GST_WRITE_UINT32_BE (GST_RTP_HEADER_CSRC_LIST_OFFSET (buffer, idx), csrc);
}
Ejemplo n.º 5
0
EXPORT_C
#endif

guint32
gst_rtp_buffer_get_csrc (GstBuffer * buffer, guint8 idx)
{
  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 (idx < GST_RTP_HEADER_CSRC_COUNT (buffer), 0);

  return GST_READ_UINT32_BE (GST_RTP_HEADER_CSRC_LIST_OFFSET (buffer, idx));
}