예제 #1
0
static void
gst_interleave_set_channel_positions (GstInterleave * self, GstStructure * s)
{
  GValue pos_array = { 0, };
  gint i;

  g_value_init (&pos_array, GST_TYPE_ARRAY);

  if (self->channel_positions
      && self->channels == self->channel_positions->n_values
      && gst_interleave_check_channel_positions (self->channel_positions)) {
    GST_DEBUG_OBJECT (self, "Using provided channel positions");
    for (i = 0; i < self->channels; i++)
      gst_value_array_append_value (&pos_array,
          g_value_array_get_nth (self->channel_positions, i));
  } else {
    GValue pos_none = { 0, };

    GST_WARNING_OBJECT (self, "Using NONE channel positions");

    g_value_init (&pos_none, GST_TYPE_AUDIO_CHANNEL_POSITION);
    g_value_set_enum (&pos_none, GST_AUDIO_CHANNEL_POSITION_NONE);

    for (i = 0; i < self->channels; i++)
      gst_value_array_append_value (&pos_array, &pos_none);

    g_value_unset (&pos_none);
  }
  gst_structure_set_value (s, "channel-positions", &pos_array);
  g_value_unset (&pos_array);
}
예제 #2
0
/* from the given two data buffers, create two streamheader buffers and
 * some caps that match it, and store them in the given pointers
 * returns  one ref to each of the buffers and the caps */
static void
gst_multisocketsink_create_streamheader (const gchar * data1,
    const gchar * data2, GstBuffer ** hbuf1, GstBuffer ** hbuf2,
    GstCaps ** caps)
{
  GstBuffer *buf;
  GValue array = { 0 };
  GValue value = { 0 };
  GstStructure *structure;
  guint size1 = strlen (data1);
  guint size2 = strlen (data2);

  fail_if (hbuf1 == NULL);
  fail_if (hbuf2 == NULL);
  fail_if (caps == NULL);

  /* create caps with streamheader, set the caps, and push the HEADER
   * buffers */
  *hbuf1 = gst_buffer_new_and_alloc (size1);
  GST_BUFFER_FLAG_SET (*hbuf1, GST_BUFFER_FLAG_HEADER);
  gst_buffer_fill (*hbuf1, 0, data1, size1);
  *hbuf2 = gst_buffer_new_and_alloc (size2);
  GST_BUFFER_FLAG_SET (*hbuf2, GST_BUFFER_FLAG_HEADER);
  gst_buffer_fill (*hbuf2, 0, data2, size2);

  g_value_init (&array, GST_TYPE_ARRAY);

  g_value_init (&value, GST_TYPE_BUFFER);
  /* we take a copy, set it on the array (which refs it), then unref our copy */
  buf = gst_buffer_copy (*hbuf1);
  gst_value_set_buffer (&value, buf);
  ASSERT_BUFFER_REFCOUNT (buf, "copied buffer", 2);
  gst_buffer_unref (buf);
  gst_value_array_append_value (&array, &value);
  g_value_unset (&value);

  g_value_init (&value, GST_TYPE_BUFFER);
  buf = gst_buffer_copy (*hbuf2);
  gst_value_set_buffer (&value, buf);
  ASSERT_BUFFER_REFCOUNT (buf, "copied buffer", 2);
  gst_buffer_unref (buf);
  gst_value_array_append_value (&array, &value);
  g_value_unset (&value);

  *caps = gst_caps_from_string ("application/x-gst-check");
  structure = gst_caps_get_structure (*caps, 0);

  gst_structure_set_value (structure, "streamheader", &array);
  g_value_unset (&array);
  ASSERT_CAPS_REFCOUNT (*caps, "streamheader caps", 1);

  /* we want to keep them around for the tests */
  gst_buffer_ref (*hbuf1);
  gst_buffer_ref (*hbuf2);

  GST_DEBUG ("created streamheader caps %p %" GST_PTR_FORMAT, *caps, *caps);
}
예제 #3
0
void
init_value_to_channel_layout (GValue * val, GstAudioChannelPosition pos1,
    GstAudioChannelPosition pos2)
{
  GValue pos = { 0, };

  g_value_init (val, GST_TYPE_ARRAY);
  g_value_init (&pos, GST_TYPE_AUDIO_CHANNEL_POSITION);
  g_value_set_enum (&pos, pos1);
  gst_value_array_append_value (val, &pos);
  g_value_set_enum (&pos, pos2);
  gst_value_array_append_value (val, &pos);
  g_value_unset (&pos);
}
예제 #4
0
static GstCaps *
theora_set_header_on_caps (GstCaps * caps, GstBuffer * buf1,
    GstBuffer * buf2, GstBuffer * buf3)
{
  GstStructure *structure;
  GValue array = { 0 };
  GValue value = { 0 };

  caps = gst_caps_make_writable (caps);
  structure = gst_caps_get_structure (caps, 0);

  /* mark buffers */
  GST_BUFFER_FLAG_SET (buf1, GST_BUFFER_FLAG_IN_CAPS);
  GST_BUFFER_FLAG_SET (buf2, GST_BUFFER_FLAG_IN_CAPS);
  GST_BUFFER_FLAG_SET (buf3, GST_BUFFER_FLAG_IN_CAPS);

  /* Copy buffers, because we can't use the originals -
   * it creates a circular refcount with the caps<->buffers */
  buf1 = gst_buffer_copy (buf1);
  buf2 = gst_buffer_copy (buf2);
  buf3 = gst_buffer_copy (buf3);

  /* put copies of the buffers in a fixed list */
  g_value_init (&array, GST_TYPE_ARRAY);

  g_value_init (&value, GST_TYPE_BUFFER);
  gst_value_set_buffer (&value, buf1);
  gst_value_array_append_value (&array, &value);
  g_value_unset (&value);

  g_value_init (&value, GST_TYPE_BUFFER);
  gst_value_set_buffer (&value, buf2);
  gst_value_array_append_value (&array, &value);
  g_value_unset (&value);

  g_value_init (&value, GST_TYPE_BUFFER);
  gst_value_set_buffer (&value, buf3);
  gst_value_array_append_value (&array, &value);
  g_value_unset (&value);

  gst_structure_set_value (structure, "streamheader", &array);
  g_value_unset (&array);

  /* Unref our copies */
  gst_buffer_unref (buf1);
  gst_buffer_unref (buf2);
  gst_buffer_unref (buf3);

  return caps;
}
예제 #5
0
static void
mpegtsdemux_set_header_on_caps (MpegTsMux * mux)
{
  GstBuffer *buf;
  GstStructure *structure;
  GValue array = { 0 };
  GValue value = { 0 };
  GstCaps *caps = GST_PAD_CAPS (mux->srcpad);
  GList *sh;

  caps = gst_caps_make_writable (caps);
  structure = gst_caps_get_structure (caps, 0);

  g_value_init (&array, GST_TYPE_ARRAY);

  sh = mux->streamheader;
  while (sh) {
    buf = sh->data;
    GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_IN_CAPS);
    g_value_init (&value, GST_TYPE_BUFFER);
    gst_value_take_buffer (&value, buf);
    gst_value_array_append_value (&array, &value);
    g_value_unset (&value);
    sh = g_list_next (sh);
  }

  g_list_free (mux->streamheader);
  mux->streamheader = NULL;

  gst_structure_set_value (structure, "streamheader", &array);
  gst_pad_set_caps (mux->srcpad, caps);
  g_value_unset (&array);
  gst_caps_unref (caps);
}
예제 #6
0
static void
gst_hlsdemux_test_set_input_data (const GstHlsDemuxTestCase * test_case,
    const GstHlsDemuxTestInputData * input, GstTestHTTPSrcInput * output)
{
  output->size = input->size;
  output->context = (gpointer) input;
  if (output->size == 0) {
    output->size = strlen ((gchar *) input->payload);
  }
  fail_unless (input->uri != NULL);
  if (g_str_has_suffix (input->uri, ".m3u8")) {
    output->response_headers = gst_structure_new ("response-headers",
        "Content-Type", G_TYPE_STRING, "application/vnd.apple.mpegurl", NULL);
  } else if (g_str_has_suffix (input->uri, ".ts")) {
    output->response_headers = gst_structure_new ("response-headers",
        "Content-Type", G_TYPE_STRING, "video/mp2t", NULL);
  }
  if (gst_structure_has_field (test_case->state, "requests")) {
    GstHlsDemuxTestAppendUriContext context =
        { g_quark_from_string ("requests"), input->uri };
    gst_structure_map_in_place (test_case->state, append_request_uri, &context);
  } else {
    GValue requests = G_VALUE_INIT;
    GValue uri_val = G_VALUE_INIT;

    g_value_init (&requests, GST_TYPE_ARRAY);
    g_value_init (&uri_val, G_TYPE_STRING);
    g_value_set_string (&uri_val, input->uri);
    gst_value_array_append_value (&requests, &uri_val);
    gst_structure_set_value (test_case->state, "requests", &requests);
    g_value_unset (&uri_val);
    g_value_unset (&requests);
  }
}
예제 #7
0
static void
theora_parse_set_header_on_caps (GstTheoraParse * parse, GstCaps * caps)
{
  GstBuffer **bufs;
  GstStructure *structure;
  gint i;
  GValue array = { 0 };
  GValue value = { 0 };

  bufs = parse->streamheader;
  structure = gst_caps_get_structure (caps, 0);
  g_value_init (&array, GST_TYPE_ARRAY);

  for (i = 0; i < 3; i++) {
    if (bufs[i] == NULL)
      continue;

    bufs[i] = gst_buffer_make_writable (bufs[i]);
    GST_BUFFER_FLAG_SET (bufs[i], GST_BUFFER_FLAG_HEADER);

    g_value_init (&value, GST_TYPE_BUFFER);
    gst_value_set_buffer (&value, bufs[i]);
    gst_value_array_append_value (&array, &value);
    g_value_unset (&value);
  }

  gst_structure_take_value (structure, "streamheader", &array);
}
/**
 * gst_buffer_pool_config_add_option:
 * @config: a #GstBufferPool configuration
 * @option: an option to add
 *
 * Enabled the option in @config. This will instruct the @bufferpool to enable
 * the specified option on the buffers that it allocates.
 *
 * The supported options by @pool can be retrieved with gst_buffer_pool_get_options().
 */
void
gst_buffer_pool_config_add_option (GstStructure * config, const gchar * option)
{
  const GValue *value;
  GValue option_value = { 0, };
  guint i, len;

  g_return_if_fail (config != NULL);

  value = gst_structure_id_get_value (config, GST_QUARK (OPTIONS));
  if (value) {
    len = gst_value_array_get_size (value);
    for (i = 0; i < len; ++i) {
      const GValue *nth_val = gst_value_array_get_value (value, i);

      if (g_str_equal (option, g_value_get_string (nth_val)))
        return;
    }
  } else {
    GValue new_array_val = { 0, };

    g_value_init (&new_array_val, GST_TYPE_ARRAY);
    gst_structure_id_take_value (config, GST_QUARK (OPTIONS), &new_array_val);
    value = gst_structure_id_get_value (config, GST_QUARK (OPTIONS));
  }
  g_value_init (&option_value, G_TYPE_STRING);
  g_value_set_string (&option_value, option);
  gst_value_array_append_value ((GValue *) value, &option_value);
  g_value_unset (&option_value);
}
예제 #9
0
static GstCaps *
theora_set_header_on_caps (GstCaps * caps, GList * buffers)
{
  GstStructure *structure;
  GValue array = { 0 };
  GValue value = { 0 };
  GstBuffer *buffer;
  GList *walk;

  caps = gst_caps_make_writable (caps);
  structure = gst_caps_get_structure (caps, 0);

  /* put copies of the buffers in a fixed list */
  g_value_init (&array, GST_TYPE_ARRAY);

  for (walk = buffers; walk; walk = walk->next) {
    buffer = walk->data;
    g_value_init (&value, GST_TYPE_BUFFER);
    gst_value_set_buffer (&value, buffer);
    gst_value_array_append_value (&array, &value);
    g_value_unset (&value);
  }

  gst_structure_take_value (structure, "streamheader", &array);

  return caps;
}
예제 #10
0
static GstStructure *
make_player_clients_list_msg (SnraManager * manager)
{
  GstStructure *msg;
  GValue p = { 0, };
  GList *cur;

  g_value_init (&p, GST_TYPE_ARRAY);

  msg = gst_structure_new ("json",
      "msg-type", G_TYPE_STRING, "player-clients", NULL);

  for (cur = manager->player_info; cur != NULL; cur = g_list_next (cur)) {
    SnraPlayerInfo *info = (SnraPlayerInfo *) (cur->data);
    if (info->conn != NULL) {
      GValue tmp = { 0, };
      GstStructure *cur_struct = gst_structure_new ("client",
          "client-id", G_TYPE_INT64, (gint64) info->id,
          "enabled", G_TYPE_BOOLEAN, info->enabled,
          "volume", G_TYPE_DOUBLE, info->volume,
          "host", G_TYPE_STRING, info->host,
          NULL);

      g_value_init (&tmp, GST_TYPE_STRUCTURE);
      gst_value_set_structure (&tmp, cur_struct);
      gst_value_array_append_value (&p, &tmp);
      g_value_unset (&tmp);
      gst_structure_free (cur_struct);
    }
  }
  gst_structure_take_value (msg, "player-clients", &p);

  return msg;
}
예제 #11
0
/* prepare the source pad for output */
static gboolean
mpegpsdemux_prepare_srcpad (MpegPsMux * mux)
{
  GstSegment segment;
  GValue val = { 0, };
  GList *headers, *l;
  GstCaps *caps;

  caps = gst_caps_new_simple ("video/mpeg",
      "mpegversion", G_TYPE_INT, 2, "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);

  headers = psmux_get_stream_headers (mux->psmux);
  g_value_init (&val, GST_TYPE_ARRAY);
  for (l = headers; l != NULL; l = l->next) {
    GValue buf_val = { 0, };

    g_value_init (&buf_val, GST_TYPE_BUFFER);
    gst_value_take_buffer (&buf_val, GST_BUFFER (l->data));
    l->data = NULL;
    gst_value_array_append_value (&val, &buf_val);
    g_value_unset (&buf_val);
  }
  gst_caps_set_value (caps, "streamheader", &val);
  g_value_unset (&val);
  g_list_free (headers);

  /* Set caps on src pad and push new segment */
  gst_pad_push_event (mux->srcpad, gst_event_new_caps (caps));
  gst_caps_unref (caps);

  gst_segment_init (&segment, GST_FORMAT_BYTES);
  gst_pad_push_event (mux->srcpad, gst_event_new_segment (&segment));

  return TRUE;
}
/*
 * _gst_caps_set_buffer_array:
 * @caps: (transfer full): a #GstCaps
 * @field: field in caps to set
 * @buf: header buffers
 *
 * Adds given buffers to an array of buffers set as the given @field
 * on the given @caps.  List of buffer arguments must be NULL-terminated.
 *
 * Returns: (transfer full): input caps with a streamheader field added, or NULL
 *     if some error occurred
 */
static GstCaps *
_gst_caps_set_buffer_array (GstCaps * caps, const gchar * field,
    GstBuffer * buf, ...)
{
  GstStructure *structure = NULL;
  va_list va;
  GValue array = { 0 };
  GValue value = { 0 };

  g_return_val_if_fail (caps != NULL, NULL);
  g_return_val_if_fail (gst_caps_is_fixed (caps), NULL);
  g_return_val_if_fail (field != NULL, NULL);

  caps = gst_caps_make_writable (caps);
  structure = gst_caps_get_structure (caps, 0);

  g_value_init (&array, GST_TYPE_ARRAY);

  va_start (va, buf);
  /* put buffers in a fixed list */
  while (buf) {
    g_value_init (&value, GST_TYPE_BUFFER);
    gst_value_set_buffer (&value, buf);
    gst_value_array_append_value (&array, &value);
    g_value_unset (&value);

    buf = va_arg (va, GstBuffer *);
  }
  va_end (va);

  gst_structure_take_value (structure, field, &array);

  return caps;
}
예제 #13
0
/* if channels are less than or equal to 8, we set a default layout,
 * otherwise set layout to an array of GST_AUDIO_CHANNEL_POSITION_NONE */
void
gst_jack_set_layout_on_caps (GstCaps ** caps, gint channels)
{
  int c;
  GValue pos = { 0 };
  GValue chanpos = { 0 };
  gst_caps_unref (*caps);

  if (channels <= 8) {
    g_assert (channels >= 1);
    gst_audio_set_channel_positions (gst_caps_get_structure (*caps, 0),
        default_positions[channels - 1]);
  } else {
    g_value_init (&chanpos, GST_TYPE_ARRAY);
    g_value_init (&pos, GST_TYPE_AUDIO_CHANNEL_POSITION);
    for (c = 0; c < channels; c++) {
      g_value_set_enum (&pos, GST_AUDIO_CHANNEL_POSITION_NONE);
      gst_value_array_append_value (&chanpos, &pos);
    }
    g_value_unset (&pos);
    gst_structure_set_value (gst_caps_get_structure (*caps, 0),
        "channel-positions", &chanpos);
    g_value_unset (&chanpos);
  }
  gst_caps_ref (*caps);
}
static void
gst_spectrum_message_add_array (GValue * cv, gfloat * data, guint num_values)
{
  GValue v = { 0, };
  GValue a = { 0, };
  guint i;

  g_value_init (&a, GST_TYPE_ARRAY);

  g_value_init (&v, G_TYPE_FLOAT);
  for (i = 0; i < num_values; i++) {
    g_value_set_float (&v, data[i]);
    gst_value_array_append_value (&a, &v);      /* copies by value */
  }
  g_value_unset (&v);

  gst_value_array_append_value (cv, &a);        /* copies by value */
  g_value_unset (&a);
}
예제 #15
0
파일: snra-json.c 프로젝트: gkiagia/aurena
static void
snra_json_array_add_to_val (G_GNUC_UNUSED JsonArray *array,
    G_GNUC_UNUSED guint index_,
    JsonNode *element_node, GValue *outval)
{
  GValue v = G_VALUE_INIT;
  snra_json_node_into_val (element_node, &v);
  gst_value_array_append_value (outval, &v); 
  g_value_unset (&v);
}
예제 #16
0
static void
vorbis_parse_set_header_on_caps (GstVorbisParse * parse, GstCaps * caps)
{
    GstBuffer *buf1, *buf2, *buf3;
    GstStructure *structure;
    GValue array = { 0 };
    GValue value = { 0 };

    g_assert (parse);
    g_assert (parse->streamheader);
    g_assert (parse->streamheader->next);
    g_assert (parse->streamheader->next->next);
    buf1 = parse->streamheader->data;
    g_assert (buf1);
    buf2 = parse->streamheader->next->data;
    g_assert (buf2);
    buf3 = parse->streamheader->next->next->data;
    g_assert (buf3);

    structure = gst_caps_get_structure (caps, 0);

    /* mark buffers */
    GST_BUFFER_FLAG_SET (buf1, GST_BUFFER_FLAG_IN_CAPS);
    GST_BUFFER_FLAG_SET (buf2, GST_BUFFER_FLAG_IN_CAPS);
    GST_BUFFER_FLAG_SET (buf3, GST_BUFFER_FLAG_IN_CAPS);

    /* put buffers in a fixed list */
    g_value_init (&array, GST_TYPE_ARRAY);
    g_value_init (&value, GST_TYPE_BUFFER);
    gst_value_set_buffer (&value, buf1);
    gst_value_array_append_value (&array, &value);
    g_value_unset (&value);
    g_value_init (&value, GST_TYPE_BUFFER);
    gst_value_set_buffer (&value, buf2);
    gst_value_array_append_value (&array, &value);
    g_value_unset (&value);
    g_value_init (&value, GST_TYPE_BUFFER);
    gst_value_set_buffer (&value, buf3);
    gst_value_array_append_value (&array, &value);
    gst_structure_set_value (structure, "streamheader", &array);
    g_value_unset (&value);
    g_value_unset (&array);
}
예제 #17
0
static GstCaps *
gst_cmml_enc_set_header_on_caps (GstCmmlEnc * enc, GstCaps * caps,
    GstBuffer * ident, GstBuffer * preamble, GstBuffer * head)
{
  GValue array = { 0 };
  GValue value = { 0 };
  GstStructure *structure;
  GstBuffer *buffer;

  caps = gst_caps_make_writable (caps);
  structure = gst_caps_get_structure (caps, 0);

  g_value_init (&array, GST_TYPE_ARRAY);
  g_value_init (&value, GST_TYPE_BUFFER);

  /* Make copies of header buffers to avoid circular references */
  buffer = gst_buffer_copy (ident);
  gst_value_set_buffer (&value, buffer);
  gst_value_array_append_value (&array, &value);
  gst_buffer_unref (buffer);

  buffer = gst_buffer_copy (preamble);
  gst_value_set_buffer (&value, buffer);
  gst_value_array_append_value (&array, &value);
  gst_buffer_unref (buffer);

  buffer = gst_buffer_copy (head);
  gst_value_set_buffer (&value, buffer);
  gst_value_array_append_value (&array, &value);
  gst_buffer_unref (buffer);

  GST_BUFFER_FLAG_SET (ident, GST_BUFFER_FLAG_IN_CAPS);
  GST_BUFFER_FLAG_SET (preamble, GST_BUFFER_FLAG_IN_CAPS);
  GST_BUFFER_FLAG_SET (head, GST_BUFFER_FLAG_IN_CAPS);

  gst_structure_set_value (structure, "streamheader", &array);

  g_value_unset (&value);
  g_value_unset (&array);

  return caps;
}
예제 #18
0
/* Set a copy of these buffers as 'streamheader' on the caps.
 * We need a copy to avoid these buffers ending up with (indirect) refs on
 * themselves
 */
static GstCaps *
gst_vorbis_enc_set_header_on_caps (GstCaps * caps, GstBuffer * buf1,
    GstBuffer * buf2, GstBuffer * buf3)
{
  GstBuffer *buf;
  GstStructure *structure;
  GValue array = { 0 };
  GValue value = { 0 };

  caps = gst_caps_make_writable (caps);
  structure = gst_caps_get_structure (caps, 0);

  /* mark buffers */
  GST_BUFFER_FLAG_SET (buf1, GST_BUFFER_FLAG_IN_CAPS);
  GST_BUFFER_FLAG_SET (buf2, GST_BUFFER_FLAG_IN_CAPS);
  GST_BUFFER_FLAG_SET (buf3, GST_BUFFER_FLAG_IN_CAPS);

  /* put buffers in a fixed list */
  g_value_init (&array, GST_TYPE_ARRAY);
  g_value_init (&value, GST_TYPE_BUFFER);
  buf = gst_buffer_copy (buf1);
  gst_value_set_buffer (&value, buf);
  gst_buffer_unref (buf);
  gst_value_array_append_value (&array, &value);
  g_value_unset (&value);
  g_value_init (&value, GST_TYPE_BUFFER);
  buf = gst_buffer_copy (buf2);
  gst_value_set_buffer (&value, buf);
  gst_buffer_unref (buf);
  gst_value_array_append_value (&array, &value);
  g_value_unset (&value);
  g_value_init (&value, GST_TYPE_BUFFER);
  buf = gst_buffer_copy (buf3);
  gst_value_set_buffer (&value, buf);
  gst_buffer_unref (buf);
  gst_value_array_append_value (&array, &value);
  gst_structure_set_value (structure, "streamheader", &array);
  g_value_unset (&value);
  g_value_unset (&array);

  return caps;
}
예제 #19
0
static void
value_array_rvalue2gvalue(VALUE value, GValue *result)
{
    guint i, len;

    len = RARRAY_LEN(value);
    for (i = 0; i < len; i++) {
        GValue val = {0};
        rbgobj_initialize_gvalue(&val, RARRAY_PTR(value)[i]);
        gst_value_array_append_value(result, &val);
        g_value_unset(&val);
    }
}
예제 #20
0
static GstCaps *
gst_vorbis_enc_generate_sink_caps (void)
{
  GstCaps *caps = gst_caps_new_empty ();
  int i, c;

  gst_caps_append_structure (caps, gst_structure_new ("audio/x-raw-float",
          "rate", GST_TYPE_INT_RANGE, 1, 200000,
          "channels", G_TYPE_INT, 1,
          "endianness", G_TYPE_INT, G_BYTE_ORDER, "width", G_TYPE_INT, 32,
          NULL));

  gst_caps_append_structure (caps, gst_structure_new ("audio/x-raw-float",
          "rate", GST_TYPE_INT_RANGE, 1, 200000,
          "channels", G_TYPE_INT, 2,
          "endianness", G_TYPE_INT, G_BYTE_ORDER, "width", G_TYPE_INT, 32,
          NULL));

  for (i = 3; i <= 8; i++) {
    GValue chanpos = { 0 };
    GValue pos = { 0 };
    GstStructure *structure;

    g_value_init (&chanpos, GST_TYPE_ARRAY);
    g_value_init (&pos, GST_TYPE_AUDIO_CHANNEL_POSITION);

    for (c = 0; c < i; c++) {
      g_value_set_enum (&pos, gst_vorbis_channel_positions[i - 1][c]);
      gst_value_array_append_value (&chanpos, &pos);
    }
    g_value_unset (&pos);

    structure = gst_structure_new ("audio/x-raw-float",
        "rate", GST_TYPE_INT_RANGE, 1, 200000,
        "channels", G_TYPE_INT, i,
        "endianness", G_TYPE_INT, G_BYTE_ORDER, "width", G_TYPE_INT, 32, NULL);
    gst_structure_set_value (structure, "channel-positions", &chanpos);
    g_value_unset (&chanpos);

    gst_caps_append_structure (caps, structure);
  }

  gst_caps_append_structure (caps, gst_structure_new ("audio/x-raw-float",
          "rate", GST_TYPE_INT_RANGE, 1, 200000,
          "channels", GST_TYPE_INT_RANGE, 9, 256,
          "endianness", G_TYPE_INT, G_BYTE_ORDER, "width", G_TYPE_INT, 32,
          NULL));

  return caps;
}
static void
gst_ogg_parse_append_header (GValue * array, GstBuffer * buf)
{
  GValue value = { 0 };
  /* We require a copy to avoid circular refcounts */
  GstBuffer *buffer = gst_buffer_copy (buf);

  GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_HEADER);

  g_value_init (&value, GST_TYPE_BUFFER);
  gst_value_set_buffer (&value, buffer);
  gst_value_array_append_value (array, &value);
  g_value_unset (&value);

}
예제 #22
0
static gboolean
append_request_uri (GQuark field_id, GValue * value, gpointer user_data)
{
  GstHlsDemuxTestAppendUriContext *context =
      (GstHlsDemuxTestAppendUriContext *) user_data;
  GValue uri_val = G_VALUE_INIT;

  if (context->field_id == field_id) {
    g_value_init (&uri_val, G_TYPE_STRING);
    g_value_set_string (&uri_val, context->uri);
    gst_value_array_append_value (value, &uri_val);
    g_value_unset (&uri_val);
  }
  return TRUE;
}
static void
add_wavelength_list_to_struct (GstStructure * structure,
  gint wavelengthno, gint *wavelengths)
{
  GValue array = { 0 };
  GValue value = { 0 };
  gint i;
  /* put copies of the buffers in a fixed list */
  g_value_init (&array, GST_TYPE_ARRAY);

  for (i=0; i< wavelengthno; i++) {
    g_value_init (&value, G_TYPE_INT);
    g_value_set_int (&value, wavelengths[i]);
    gst_value_array_append_value (&array, &value);
    g_value_unset (&value);
  }

  gst_structure_take_value (structure, "wavelength_ids", &array);
}
예제 #24
0
static gboolean
mpegpsdemux_prepare_srcpad (MpegPsMux * mux)
{
  GValue val = { 0, };
  GList *headers, *l;

  /* prepare the source pad for output */

  GstEvent *new_seg =
      gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES, 0, -1, 0);
  GstCaps *caps = gst_caps_new_simple ("video/mpeg",
      "mpegversion", G_TYPE_INT, 2,
      "systemstream", G_TYPE_BOOLEAN, TRUE,
      NULL);

/*      gst_static_pad_template_get_caps (&mpegpsmux_src_factory); */

  headers = psmux_get_stream_headers (mux->psmux);
  g_value_init (&val, GST_TYPE_ARRAY);
  for (l = headers; l != NULL; l = l->next) {
    GValue buf_val = { 0, };

    g_value_init (&buf_val, GST_TYPE_BUFFER);
    gst_value_take_buffer (&buf_val, GST_BUFFER (l->data));
    l->data = NULL;
    gst_value_array_append_value (&val, &buf_val);
    g_value_unset (&buf_val);
  }
  gst_caps_set_value (caps, "streamheader", &val);
  g_value_unset (&val);
  g_list_free (headers);

  /* Set caps on src pad from our template and push new segment */
  gst_pad_set_caps (mux->srcpad, caps);

  if (!gst_pad_push_event (mux->srcpad, new_seg)) {
    GST_WARNING_OBJECT (mux, "New segment event was not handled");
    return FALSE;
  }

  return TRUE;
}
예제 #25
0
GstCaps *
gst_kate_util_set_header_on_caps (GstElement * element, GstCaps * caps,
    GList * headers)
{
  GstStructure *structure;
  GValue array = { 0 };

  GST_LOG_OBJECT (element, "caps: %" GST_PTR_FORMAT, caps);

  if (G_UNLIKELY (!caps))
    return NULL;
  if (G_UNLIKELY (!headers))
    return NULL;

  caps = gst_caps_make_writable (caps);
  structure = gst_caps_get_structure (caps, 0);

  g_value_init (&array, GST_TYPE_ARRAY);

  while (headers) {
    GValue value = { 0 };
    GstBuffer *buffer = headers->data;
    g_assert (buffer);
    GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_IN_CAPS);
    g_value_init (&value, GST_TYPE_BUFFER);
    /* as in theoraenc, we need to copy to avoid circular references */
    buffer = gst_buffer_copy (buffer);
    gst_value_set_buffer (&value, buffer);
    gst_buffer_unref (buffer);
    gst_value_array_append_value (&array, &value);
    g_value_unset (&value);
    headers = headers->next;
  }

  gst_structure_set_value (structure, "streamheader", &array);
  g_value_unset (&array);
  GST_LOG_OBJECT (element, "here are the newly set caps: %" GST_PTR_FORMAT,
      caps);

  return caps;
}
예제 #26
0
EXPORT_C
#endif

void
gst_mixer_volume_changed (GstMixer * mixer,
    GstMixerTrack * track, gint * volumes)
{
  GstStructure *s;
  GstMessage *m;
  GValue l = { 0, };
  GValue v = { 0, };
  gint i;

  g_return_if_fail (mixer != NULL);
  g_return_if_fail (GST_IS_ELEMENT (mixer));
  g_return_if_fail (track != NULL);

  s = gst_structure_new (GST_MIXER_MESSAGE_NAME,
      "type", G_TYPE_STRING, "volume-changed",
      "track", GST_TYPE_MIXER_TRACK, track, NULL);

  g_value_init (&l, GST_TYPE_ARRAY);

  g_value_init (&v, G_TYPE_INT);

  /* FIXME 0.11: pass track->num_channels to the function */
  for (i = 0; i < track->num_channels; ++i) {
    g_value_set_int (&v, volumes[i]);
    gst_value_array_append_value (&l, &v);
  }
  g_value_unset (&v);

  gst_structure_set_value (s, "volumes", &l);
  g_value_unset (&l);

  m = gst_message_new_element (GST_OBJECT (mixer), s);
  if (gst_element_post_message (GST_ELEMENT (mixer), m) == FALSE) {
    GST_WARNING ("This element has no bus, therefore no message sent!");
  }
}
예제 #27
0
static GstCaps *
theora_set_header_on_caps (GstCaps * caps, GList * buffers)
{
    GstStructure *structure;
    GValue array = { 0 };
    GValue value = { 0 };
    GstBuffer *buffer;
    GList *walk;

    caps = gst_caps_make_writable (caps);
    structure = gst_caps_get_structure (caps, 0);

    /* put copies of the buffers in a fixed list */
    g_value_init (&array, GST_TYPE_ARRAY);

    for (walk = buffers; walk; walk = walk->next) {
        buffer = walk->data;

        /* mark buffer */
        GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_HEADER);

        /* Copy buffer, because we can't use the original -
         * it creates a circular refcount with the caps<->buffers */
        buffer = gst_buffer_copy (buffer);

        g_value_init (&value, GST_TYPE_BUFFER);
        gst_value_set_buffer (&value, buffer);
        gst_value_array_append_value (&array, &value);
        g_value_unset (&value);

        /* Unref our copy */
        gst_buffer_unref (buffer);
    }

    gst_structure_set_value (structure, "streamheader", &array);
    g_value_unset (&array);

    return caps;
}
예제 #28
0
static void
gst_vp8_enc_set_stream_info (GstVPXEnc * enc, GstCaps * caps,
    GstVideoInfo * info)
{
  GstStructure *s;
  GstVideoEncoder *video_encoder;
  GstBuffer *stream_hdr, *vorbiscomment;
  const GstTagList *iface_tags;
  GValue array = { 0, };
  GValue value = { 0, };
  guint8 *data = NULL;
  GstMapInfo map;

  video_encoder = GST_VIDEO_ENCODER (enc);
  s = gst_caps_get_structure (caps, 0);

  /* put buffers in a fixed list */
  g_value_init (&array, GST_TYPE_ARRAY);
  g_value_init (&value, GST_TYPE_BUFFER);

  /* Create Ogg stream-info */
  stream_hdr = gst_buffer_new_and_alloc (26);
  gst_buffer_map (stream_hdr, &map, GST_MAP_WRITE);
  data = map.data;

  GST_WRITE_UINT8 (data, 0x4F);
  GST_WRITE_UINT32_BE (data + 1, 0x56503830);   /* "VP80" */
  GST_WRITE_UINT8 (data + 5, 0x01);     /* stream info header */
  GST_WRITE_UINT8 (data + 6, 1);        /* Major version 1 */
  GST_WRITE_UINT8 (data + 7, 0);        /* Minor version 0 */
  GST_WRITE_UINT16_BE (data + 8, GST_VIDEO_INFO_WIDTH (info));
  GST_WRITE_UINT16_BE (data + 10, GST_VIDEO_INFO_HEIGHT (info));
  GST_WRITE_UINT24_BE (data + 12, GST_VIDEO_INFO_PAR_N (info));
  GST_WRITE_UINT24_BE (data + 15, GST_VIDEO_INFO_PAR_D (info));
  GST_WRITE_UINT32_BE (data + 18, GST_VIDEO_INFO_FPS_N (info));
  GST_WRITE_UINT32_BE (data + 22, GST_VIDEO_INFO_FPS_D (info));

  gst_buffer_unmap (stream_hdr, &map);

  GST_BUFFER_FLAG_SET (stream_hdr, GST_BUFFER_FLAG_HEADER);
  gst_value_set_buffer (&value, stream_hdr);
  gst_value_array_append_value (&array, &value);
  g_value_unset (&value);
  gst_buffer_unref (stream_hdr);

  iface_tags = gst_tag_setter_get_tag_list (GST_TAG_SETTER (video_encoder));
  if (iface_tags) {
    vorbiscomment =
        gst_tag_list_to_vorbiscomment_buffer (iface_tags,
        (const guint8 *) "OVP80\2 ", 7,
        "Encoded with GStreamer vp8enc " PACKAGE_VERSION);

    GST_BUFFER_FLAG_SET (vorbiscomment, GST_BUFFER_FLAG_HEADER);

    g_value_init (&value, GST_TYPE_BUFFER);
    gst_value_set_buffer (&value, vorbiscomment);
    gst_value_array_append_value (&array, &value);
    g_value_unset (&value);
    gst_buffer_unref (vorbiscomment);
  }

  gst_structure_set_value (s, "streamheader", &array);
  g_value_unset (&array);

}
예제 #29
0
static int
gst_ffmpegdata_write (URLContext * h, unsigned char *buf, int size)
{
  GstProtocolInfo *info;
  GstBuffer *outbuf;

  GST_DEBUG ("Writing %d bytes", size);
  info = (GstProtocolInfo *) h->priv_data;

  g_return_val_if_fail (h->flags != URL_RDONLY, -EIO);

  /*
   * WHISPERCAST BEGIN: set the "streamheader" value on the source pad caps,
   * so we are able to use ffmpegmux with fdsink/multifdsink/etc...
  */
  if (info->set_streamheader) {
    GstCaps *caps;
    GstStructure *structure;
  
    GValue array = { 0 };
    GstBuffer *copy;
    GValue value = { 0 };
  
    caps = gst_pad_get_caps(info->pad);
    caps = gst_caps_make_writable (caps);
  
    structure = gst_caps_get_structure (caps, 0);
  
    /* put buffers in a fixed list */
    g_value_init (&array, GST_TYPE_ARRAY);
  
    g_value_init (&value, GST_TYPE_BUFFER);
    copy = gst_buffer_new_and_alloc (size);
    memcpy (GST_BUFFER_DATA (copy), buf, size);
    gst_value_set_buffer (&value, copy);
    gst_buffer_unref (copy);
    gst_value_array_append_value (&array, &value);
    g_value_unset (&value);
  
    gst_structure_set_value (structure, "streamheader", &array);
    g_value_unset (&array);
  
    gst_pad_set_caps(info->pad, caps);
    gst_caps_unref(caps);
  }
  /* WHISPERCAST END */
  
  /* create buffer and push data further */
  if (gst_pad_alloc_buffer_and_set_caps (info->pad,
          info->offset, size, GST_PAD_CAPS (info->pad), &outbuf) != GST_FLOW_OK)
    return 0;

  /*
   * WHISPERCAST BEGIN: mark the buffer as added to the source pad's caps.
  */
  if (info->set_streamheader) {
    GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_IN_CAPS);
    info->set_streamheader = 0;
  }
  /* WHISPERCAST END */
  
  memcpy (GST_BUFFER_DATA (outbuf), buf, size);

  if (gst_pad_push (info->pad, outbuf) != GST_FLOW_OK)
    return 0;

  info->offset += size;
  return size;
}
예제 #30
0
static GstCaps *
gst_vp8_enc_get_caps (GstBaseVideoEncoder * base_video_encoder)
{
  GstCaps *caps;
  const GstVideoState *state;
  GstTagList *tags = NULL;
  const GstTagList *iface_tags;
  GstBuffer *stream_hdr, *vorbiscomment;
  guint8 *data;
  GstStructure *s;
  GValue array = { 0 };
  GValue value = { 0 };

  state = gst_base_video_encoder_get_state (base_video_encoder);

  caps = gst_caps_new_simple ("video/x-vp8",
      "width", G_TYPE_INT, state->width,
      "height", G_TYPE_INT, state->height,
      "framerate", GST_TYPE_FRACTION, state->fps_n,
      state->fps_d,
      "pixel-aspect-ratio", GST_TYPE_FRACTION, state->par_n,
      state->par_d, NULL);

  s = gst_caps_get_structure (caps, 0);

  /* put buffers in a fixed list */
  g_value_init (&array, GST_TYPE_ARRAY);
  g_value_init (&value, GST_TYPE_BUFFER);

  /* Create Ogg stream-info */
  stream_hdr = gst_buffer_new_and_alloc (26);
  data = GST_BUFFER_DATA (stream_hdr);

  GST_WRITE_UINT8 (data, 0x4F);
  GST_WRITE_UINT32_BE (data + 1, 0x56503830);   /* "VP80" */
  GST_WRITE_UINT8 (data + 5, 0x01);     /* stream info header */
  GST_WRITE_UINT8 (data + 6, 1);        /* Major version 1 */
  GST_WRITE_UINT8 (data + 7, 0);        /* Minor version 0 */
  GST_WRITE_UINT16_BE (data + 8, state->width);
  GST_WRITE_UINT16_BE (data + 10, state->height);
  GST_WRITE_UINT24_BE (data + 12, state->par_n);
  GST_WRITE_UINT24_BE (data + 15, state->par_d);
  GST_WRITE_UINT32_BE (data + 18, state->fps_n);
  GST_WRITE_UINT32_BE (data + 22, state->fps_d);

  GST_BUFFER_FLAG_SET (stream_hdr, GST_BUFFER_FLAG_IN_CAPS);
  gst_value_set_buffer (&value, stream_hdr);
  gst_value_array_append_value (&array, &value);
  g_value_unset (&value);
  gst_buffer_unref (stream_hdr);

  iface_tags =
      gst_tag_setter_get_tag_list (GST_TAG_SETTER (base_video_encoder));
  if (iface_tags) {
    vorbiscomment =
        gst_tag_list_to_vorbiscomment_buffer ((iface_tags) ? iface_tags : tags,
        (const guint8 *) "OVP80\2 ", 7,
        "Encoded with GStreamer vp8enc " PACKAGE_VERSION);

    GST_BUFFER_FLAG_SET (vorbiscomment, GST_BUFFER_FLAG_IN_CAPS);

    g_value_init (&value, GST_TYPE_BUFFER);
    gst_value_set_buffer (&value, vorbiscomment);
    gst_value_array_append_value (&array, &value);
    g_value_unset (&value);
    gst_buffer_unref (vorbiscomment);
  }

  gst_structure_set_value (s, "streamheader", &array);
  g_value_unset (&array);

  return caps;
}