static gchar * gst_stream_video_information_to_string (GstDiscovererStreamInfo * info, gint depth) { GstDiscovererVideoInfo *video_info; GString *s; gchar *tmp; int len = 500; const GstTagList *tags; g_return_val_if_fail (info != NULL, NULL); s = g_string_sized_new (len); gst_stream_information_to_string (info, s, depth); video_info = (GstDiscovererVideoInfo *) info; my_g_string_append_printf (s, depth, "Width: %u\n", gst_discoverer_video_info_get_width (video_info)); my_g_string_append_printf (s, depth, "Height: %u\n", gst_discoverer_video_info_get_height (video_info)); my_g_string_append_printf (s, depth, "Depth: %u\n", gst_discoverer_video_info_get_depth (video_info)); my_g_string_append_printf (s, depth, "Frame rate: %u/%u\n", gst_discoverer_video_info_get_framerate_num (video_info), gst_discoverer_video_info_get_framerate_denom (video_info)); my_g_string_append_printf (s, depth, "Pixel aspect ratio: %u/%u\n", gst_discoverer_video_info_get_par_num (video_info), gst_discoverer_video_info_get_par_denom (video_info)); my_g_string_append_printf (s, depth, "Interlaced: %s\n", gst_discoverer_video_info_is_interlaced (video_info) ? "true" : "false"); my_g_string_append_printf (s, depth, "Bitrate: %u\n", gst_discoverer_video_info_get_bitrate (video_info)); my_g_string_append_printf (s, depth, "Max bitrate: %u\n", gst_discoverer_video_info_get_max_bitrate (video_info)); my_g_string_append_printf (s, depth, "Tags:\n"); tags = gst_discoverer_stream_info_get_tags (info); if (tags) { tmp = gst_tag_list_to_string (tags); my_g_string_append_printf (s, depth, " %s\n", tmp); g_free (tmp); } else { my_g_string_append_printf (s, depth, " None\n"); } if (verbose) my_g_string_append_printf (s, depth, "\n"); return g_string_free (s, FALSE); }
static GstCaps * caps_from_video_stream_info (GstDiscovererStreamInfo *info) { GstCaps *temp = gst_discoverer_stream_info_get_caps (info); GstCaps *caps = gst_caps_copy (temp); const GstDiscovererVideoInfo *video_info = GST_DISCOVERER_VIDEO_INFO (info); const GstTagList *stream_tag_list; guint n, d, data; gboolean value; gst_caps_unref (temp); data = gst_discoverer_video_info_get_height (video_info); if (data) gst_caps_set_simple (caps, "height", G_TYPE_INT, data, NULL); data = gst_discoverer_video_info_get_width (video_info); if (data) gst_caps_set_simple (caps, "width", G_TYPE_INT, data, NULL); data = gst_discoverer_video_info_get_depth (video_info); if (data) gst_caps_set_simple (caps, "depth", G_TYPE_INT, data, NULL); n = gst_discoverer_video_info_get_framerate_num (video_info); d = gst_discoverer_video_info_get_framerate_denom (video_info); if (n && d) gst_caps_set_simple (caps, "framerate", GST_TYPE_FRACTION, n, d, NULL); n = gst_discoverer_video_info_get_par_num (video_info); d = gst_discoverer_video_info_get_par_denom (video_info); if (n && d) gst_caps_set_simple (caps, "pixel-aspect-ratio", GST_TYPE_FRACTION, n, d, NULL); value = gst_discoverer_video_info_is_interlaced (video_info); if (value) gst_caps_set_simple (caps, "interlaced", G_TYPE_BOOLEAN, value, NULL); stream_tag_list = gst_discoverer_stream_info_get_tags (info); if (stream_tag_list) { guint bitrate; if (gst_tag_list_get_uint (stream_tag_list, "bitrate", &bitrate)) gst_caps_set_simple (caps, "bitrate", G_TYPE_INT, (int) bitrate, NULL); if (gst_tag_list_get_uint (stream_tag_list, "maximum-bitrate", &bitrate)) gst_caps_set_simple (caps, "maximum-bitrate", G_TYPE_INT, (int) bitrate, NULL); } return caps; }