コード例 #1
0
ファイル: mxfmux.c プロジェクト: ChinnaSuhas/ossbuild
static void
gst_mxf_mux_reset (GstMXFMux * mux)
{
  GSList *sl;

  while ((sl = mux->collect->data) != NULL) {
    GstMXFMuxPad *cpad = (GstMXFMuxPad *) sl->data;

    g_object_unref (cpad->adapter);
    g_free (cpad->mapping_data);

    gst_collect_pads_remove_pad (mux->collect, cpad->collect.pad);
  }

  mux->state = GST_MXF_MUX_STATE_HEADER;
  mux->n_pads = 0;

  if (mux->metadata) {
    g_hash_table_destroy (mux->metadata);
    mux->preface = NULL;
    g_list_free (mux->metadata_list);
    mux->metadata_list = NULL;
  }
  mux->metadata = mxf_metadata_hash_table_new ();

  mxf_partition_pack_reset (&mux->partition);
  mxf_primer_pack_reset (&mux->primer);
  memset (&mux->min_edit_rate, 0, sizeof (MXFFraction));
  mux->last_gc_timestamp = 0;
  mux->last_gc_position = 0;
  mux->offset = 0;
}
コード例 #2
0
ファイル: mxfmux.c プロジェクト: ndufresne/gst-plugins-bad
static void
gst_mxf_mux_reset (GstMXFMux * mux)
{
  GList *l;

  GST_OBJECT_LOCK (mux);
  while ((l = GST_ELEMENT_CAST (mux)->sinkpads) != NULL) {
    GstPad *pad = (GstPad *) l->data;

    gst_object_ref (pad);
    GST_OBJECT_UNLOCK (mux);
    gst_element_release_request_pad (GST_ELEMENT_CAST (mux), pad);
    gst_object_unref (pad);
    GST_OBJECT_LOCK (mux);
  }
  GST_OBJECT_UNLOCK (mux);

  mux->state = GST_MXF_MUX_STATE_HEADER;
  mux->n_pads = 0;

  if (mux->metadata) {
    g_hash_table_destroy (mux->metadata);
    mux->preface = NULL;
    g_list_free (mux->metadata_list);
    mux->metadata_list = NULL;
  }
  mux->metadata = mxf_metadata_hash_table_new ();

  mxf_partition_pack_reset (&mux->partition);
  mxf_primer_pack_reset (&mux->primer);
  memset (&mux->min_edit_rate, 0, sizeof (MXFFraction));
  mux->last_gc_timestamp = 0;
  mux->last_gc_position = 0;
  mux->offset = 0;
}
コード例 #3
0
ファイル: mxfparse.c プロジェクト: prajnashi/gst-plugins-bad
/* SMPTE 377M 6.1, Table 2 */
gboolean
mxf_partition_pack_parse (const MXFUL * key, MXFPartitionPack * pack,
    const guint8 * data, guint size)
{
  guint i;
#ifndef GST_DISABLE_GST_DEBUG
  gchar str[48];
#endif

  g_return_val_if_fail (data != NULL, FALSE);
  g_return_val_if_fail (size >= 84, FALSE);

  memset (pack, 0, sizeof (MXFPartitionPack));

  GST_DEBUG ("Parsing partition pack:");

  if (key->u[13] == 0x02)
    pack->type = MXF_PARTITION_PACK_HEADER;
  else if (key->u[13] == 0x03)
    pack->type = MXF_PARTITION_PACK_BODY;
  else if (key->u[13] == 0x04)
    pack->type = MXF_PARTITION_PACK_FOOTER;

  GST_DEBUG ("  type = %s",
      (pack->type == MXF_PARTITION_PACK_HEADER) ? "header" : (pack->type ==
          MXF_PARTITION_PACK_BODY) ? "body" : "footer");

  pack->closed = (key->u[14] == 0x02 || key->u[14] == 0x04);
  pack->complete = (key->u[14] == 0x03 || key->u[14] == 0x04);

  GST_DEBUG ("  closed = %s, complete = %s", (pack->closed) ? "yes" : "no",
      (pack->complete) ? "yes" : "no");

  pack->major_version = GST_READ_UINT16_BE (data);
  if (pack->major_version != 1)
    goto error;
  data += 2;
  size -= 2;

  pack->minor_version = GST_READ_UINT16_BE (data);
  data += 2;
  size -= 2;

  GST_DEBUG ("  MXF version = %u.%u", pack->major_version, pack->minor_version);

  pack->kag_size = GST_READ_UINT32_BE (data);
  data += 4;
  size -= 4;

  GST_DEBUG ("  KAG size = %u", pack->kag_size);

  pack->this_partition = GST_READ_UINT64_BE (data);
  data += 8;
  size -= 8;

  GST_DEBUG ("  this partition offset = %" G_GUINT64_FORMAT,
      pack->this_partition);

  pack->prev_partition = GST_READ_UINT64_BE (data);
  data += 8;
  size -= 8;

  GST_DEBUG ("  previous partition offset = %" G_GUINT64_FORMAT,
      pack->prev_partition);

  pack->footer_partition = GST_READ_UINT64_BE (data);
  data += 8;
  size -= 8;

  GST_DEBUG ("  footer partition offset = %" G_GUINT64_FORMAT,
      pack->footer_partition);

  pack->header_byte_count = GST_READ_UINT64_BE (data);
  data += 8;
  size -= 8;

  GST_DEBUG ("  header byte count = %" G_GUINT64_FORMAT,
      pack->header_byte_count);

  pack->index_byte_count = GST_READ_UINT64_BE (data);
  data += 8;
  size -= 8;

  pack->index_sid = GST_READ_UINT32_BE (data);
  data += 4;
  size -= 4;

  GST_DEBUG ("  index sid = %u, size = %" G_GUINT64_FORMAT, pack->index_sid,
      pack->index_byte_count);

  pack->body_offset = GST_READ_UINT64_BE (data);
  data += 8;
  size -= 8;

  pack->body_sid = GST_READ_UINT32_BE (data);
  data += 4;
  size -= 4;

  GST_DEBUG ("  body sid = %u, offset = %" G_GUINT64_FORMAT, pack->body_sid,
      pack->body_offset);

  memcpy (&pack->operational_pattern, data, 16);
  data += 16;
  size -= 16;

  GST_DEBUG ("  operational pattern = %s",
      mxf_ul_to_string (&pack->operational_pattern, str));

  pack->n_essence_containers = GST_READ_UINT32_BE (data);
  data += 4;
  size -= 4;

  GST_DEBUG ("  number of essence containers = %u", pack->n_essence_containers);

  if (GST_READ_UINT32_BE (data) != 16)
    goto error;
  data += 4;
  size -= 4;

  if (size < 16 * pack->n_essence_containers)
    goto error;

  if (pack->n_essence_containers) {
    pack->essence_containers = g_new (MXFUL, pack->n_essence_containers);
    for (i = 0; i < pack->n_essence_containers; i++) {
      memcpy (&pack->essence_containers[i], data + i * 16, 16);
      GST_DEBUG ("  essence container %u = %s", i,
          mxf_ul_to_string (&pack->essence_containers[i], str));
    }
  }

  pack->valid = TRUE;

  return TRUE;

error:
  GST_ERROR ("Invalid partition pack");

  mxf_partition_pack_reset (pack);
  return FALSE;
}