Пример #1
0
static void
send_ca_pmt (CamSwClient * client, GstStructure * pmt,
             guint8 list_management, guint8 cmd_id)
{
    guint8 *buffer;
    guint buffer_size;
    guint8 *ca_pmt;
    guint ca_pmt_size;
    guint length_field_len;
    guint header_len;

    ca_pmt = cam_build_ca_pmt (pmt, list_management, cmd_id, &ca_pmt_size);

    length_field_len = cam_calc_length_field_size (ca_pmt_size);
    header_len = 3 + length_field_len;
    buffer_size = header_len + ca_pmt_size;

    buffer = g_malloc0 (buffer_size);
    memcpy (buffer + header_len, ca_pmt, ca_pmt_size);

    /* ca_pmt resource_id */
    buffer[0] = 0x9F;
    buffer[1] = 0x80;
    buffer[2] = 0x32;

    cam_write_length_field (&buffer[3], ca_pmt_size);

    if (write (client->sock, buffer, buffer_size) == -1) {
        GST_WARNING ("write failed when sending pmt with errno: %d", errno);
    }

    g_free (ca_pmt);
    g_free (buffer);
}
Пример #2
0
/* get the number of bytes to allocate for a TPDU with a body of body_length
 * bytes. Also get the offset from the beginning of the buffer that marks the
 * position of the first byte of the TPDU body */
void
cam_tl_calc_buffer_size (CamTL * tl, guint body_length,
    guint * buffer_size, guint * offset)
{
  guint length_field_len;

  /* the size of a TPDU is:
   * 1 byte slot number
   * 1 byte connection id 
   * length_field_len bytes length field 
   * 1 byte connection id
   * body_length bytes body
   */

  /* get the length of the lenght_field block */
  length_field_len = cam_calc_length_field_size (body_length);

  *offset = 3 + length_field_len + 1;
  *buffer_size = *offset + body_length;
}