Example #1
0
GST_END_TEST
GST_START_TEST (test_date_tags)
{
  GstTagList *tag_list, *tag_list2;
  GDate *date, *date2;
  gchar *str;

  date = g_date_new_dmy (14, 10, 2005);
  tag_list = gst_tag_list_new_empty ();
  gst_tag_list_add (tag_list, GST_TAG_MERGE_APPEND, GST_TAG_DATE, date, NULL);

  str = gst_tag_list_to_string (tag_list);
  fail_if (str == NULL);
  fail_if (strstr (str, "2005-10-14") == NULL);

  tag_list2 = gst_tag_list_new_from_string (str);
  fail_if (tag_list2 == NULL);
  fail_if (!gst_tag_list_get_date (tag_list2, GST_TAG_DATE, &date2));
  fail_unless (gst_tag_list_is_equal (tag_list2, tag_list));
  gst_tag_list_unref (tag_list2);
  g_free (str);

  fail_if (g_date_compare (date, date2) != 0);
  fail_if (g_date_get_day (date) != 14);
  fail_if (g_date_get_month (date) != 10);
  fail_if (g_date_get_year (date) != 2005);
  fail_if (g_date_get_day (date2) != 14);
  fail_if (g_date_get_month (date2) != 10);
  fail_if (g_date_get_year (date2) != 2005);
  g_date_free (date2);

  gst_tag_list_unref (tag_list);
  g_date_free (date);
}
Example #2
0
tag_list from_string(std::string const &p_string)
{
	GstTagList *tag_list_ = gst_tag_list_new_from_string(p_string.c_str());
	if (tag_list_ == nullptr)
		return tag_list();
	else
		return tag_list(tag_list_);
}
static TagNode *
deserialize_tagnode (const gchar ** names, const gchar ** values)
{
  gint i;
  TagNode *tagnode = g_slice_new0 (TagNode);

  for (i = 0; names[i] != NULL; i++) {
    if (g_strcmp0 (names[i], "content") == 0)
      tagnode->taglist = gst_tag_list_new_from_string (values[i]);
  }

  return tagnode;
}
Example #4
0
/*
 * Creates a pipeline in the form:
 * fakesrc num-buffers=1 ! caps ! muxer ! filesink location=file
 *
 * And sets the tags in tag_str into the muxer via tagsetter.
 */
static void
test_mux_tags (const gchar * tag_str, const gchar * caps,
    const gchar * muxer, const gchar * file)
{
  GstElement *pipeline;
  GstBus *bus;
  GMainLoop *loop;
  GstTagList *sent_tags;
  GstElement *mux;
  GstTagSetter *setter;
  gchar *launch_str;
  guint bus_watch = 0;

  GST_DEBUG ("testing xmp muxing on : %s", muxer);

  launch_str = g_strdup_printf ("fakesrc num-buffers=1 format=time ! "
      "%s ! %s name=mux ! filesink location=%s name=sink", caps, muxer, file);
  pipeline = gst_parse_launch (launch_str, NULL);
  g_free (launch_str);
  fail_unless (pipeline != NULL);

  mux = gst_bin_get_by_name (GST_BIN (pipeline), "mux");
  fail_unless (mux != NULL);

  loop = g_main_loop_new (NULL, TRUE);
  fail_unless (loop != NULL);

  bus = gst_element_get_bus (pipeline);
  fail_unless (bus != NULL);
  bus_watch = gst_bus_add_watch (bus, bus_handler, loop);
  gst_object_unref (bus);

  gst_element_set_state (pipeline, GST_STATE_READY);

  setter = GST_TAG_SETTER (mux);
  fail_unless (setter != NULL);
  sent_tags = gst_tag_list_new_from_string (tag_str);
  fail_unless (sent_tags != NULL);
  gst_tag_setter_merge_tags (setter, sent_tags, GST_TAG_MERGE_REPLACE);
  gst_tag_list_free (sent_tags);

  gst_element_set_state (pipeline, GST_STATE_PLAYING);
  g_main_loop_run (loop);

  gst_element_set_state (pipeline, GST_STATE_NULL);

  g_main_loop_unref (loop);
  g_object_unref (mux);
  g_object_unref (pipeline);
  g_source_remove (bus_watch);
}
Example #5
0
/*
 * Makes a pipeline in the form:
 * filesrc location=file ! demuxer ! fakesink
 *
 * And gets the tags that are posted on the bus to compare
 * with the tags in 'tag_str'
 */
static void
test_demux_tags (const gchar * tag_str, const gchar * demuxer,
    const gchar * file)
{
  GstElement *pipeline;
  GstBus *bus;
  GMainLoop *loop;
  GstTagList *sent_tags;
  gint i, j, k, n_recv, n_sent;
  const gchar *name_sent, *name_recv;
  const GValue *value_sent, *value_recv;
  gboolean found;
  gint comparison;
  GstElement *demux;
  gchar *launch_str;
  guint bus_watch = 0;

  GST_DEBUG ("testing tags : %s", tag_str);

  if (received_tags) {
    gst_tag_list_free (received_tags);
    received_tags = NULL;
  }

  launch_str = g_strdup_printf ("filesrc location=%s ! %s name=demux ! "
      "fakesink", file, demuxer);
  pipeline = gst_parse_launch (launch_str, NULL);
  g_free (launch_str);
  fail_unless (pipeline != NULL);

  demux = gst_bin_get_by_name (GST_BIN (pipeline), "demux");
  fail_unless (demux != NULL);

  loop = g_main_loop_new (NULL, TRUE);
  fail_unless (loop != NULL);

  bus = gst_element_get_bus (pipeline);
  fail_unless (bus != NULL);
  bus_watch = gst_bus_add_watch (bus, bus_handler, loop);
  gst_object_unref (bus);

  sent_tags = gst_tag_list_new_from_string (tag_str);
  fail_unless (sent_tags != NULL);

  gst_element_set_state (pipeline, GST_STATE_PLAYING);
  g_main_loop_run (loop);

  GST_DEBUG ("mainloop done : %p", received_tags);

  /* verify tags */
  fail_unless (received_tags != NULL);
  n_recv = gst_tag_list_n_tags (received_tags);
  n_sent = gst_tag_list_n_tags (sent_tags);
  fail_unless (n_recv >= n_sent);
  /* FIXME: compare taglits values */
  for (i = 0; i < n_sent; i++) {
    name_sent = gst_tag_list_nth_tag_name (sent_tags, i);

    found = FALSE;
    for (j = 0; j < n_recv; j++) {
      name_recv = gst_tag_list_nth_tag_name (received_tags, j);

      if (!strcmp (name_sent, name_recv)) {
        guint sent_len, recv_len;

        sent_len = gst_tag_list_get_tag_size (sent_tags, name_sent);
        recv_len = gst_tag_list_get_tag_size (received_tags, name_recv);

        fail_unless (sent_len == recv_len,
            "tag item %s has been received with different size", name_sent);

        for (k = 0; k < sent_len; k++) {
          value_sent = gst_tag_list_get_value_index (sent_tags, name_sent, k);
          value_recv =
              gst_tag_list_get_value_index (received_tags, name_recv, k);

          comparison = gst_value_compare (value_sent, value_recv);
          if (comparison != GST_VALUE_EQUAL) {
            gchar *vs = g_strdup_value_contents (value_sent);
            gchar *vr = g_strdup_value_contents (value_recv);
            GST_DEBUG ("sent = %s:'%s', recv = %s:'%s'",
                G_VALUE_TYPE_NAME (value_sent), vs,
                G_VALUE_TYPE_NAME (value_recv), vr);
            g_free (vs);
            g_free (vr);
          }
          fail_unless (comparison == GST_VALUE_EQUAL,
              "tag item %s has been received with different type or value",
              name_sent);
          found = TRUE;
          break;
        }
      }
    }
    fail_unless (found, "tag item %s is lost", name_sent);
  }

  gst_tag_list_free (received_tags);
  received_tags = NULL;
  gst_tag_list_free (sent_tags);

  gst_element_set_state (pipeline, GST_STATE_NULL);

  g_main_loop_unref (loop);
  g_object_unref (demux);
  g_object_unref (pipeline);
  g_source_remove (bus_watch);
}