2010-09-20 09:24:10 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-03 23:05:09 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2010-09-20 09:24:10 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2014-01-28 13:28:27 +00:00
|
|
|
#include <locale.h>
|
|
|
|
|
2010-09-20 09:24:10 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <glib.h>
|
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <gst/pbutils/pbutils.h>
|
2017-06-13 00:18:19 +00:00
|
|
|
#include <gst/audio/audio.h>
|
2010-09-20 09:24:10 +00:00
|
|
|
|
2023-01-11 10:17:13 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
#include <TargetConditionals.h>
|
|
|
|
#endif
|
|
|
|
|
2014-07-21 12:54:05 +00:00
|
|
|
#define MAX_INDENT 40
|
|
|
|
|
2013-11-04 10:34:38 +00:00
|
|
|
/* *INDENT-OFF* */
|
|
|
|
static void my_g_string_append_printf (GString * str, int depth, const gchar * format, ...) G_GNUC_PRINTF (3, 4);
|
|
|
|
/* *INDENT-ON* */
|
|
|
|
|
2010-09-20 09:24:10 +00:00
|
|
|
static gboolean async = FALSE;
|
2012-05-20 23:01:17 +00:00
|
|
|
static gboolean show_toc = FALSE;
|
2010-09-20 09:24:10 +00:00
|
|
|
static gboolean verbose = FALSE;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GstDiscoverer *dc;
|
|
|
|
int argc;
|
|
|
|
char **argv;
|
|
|
|
} PrivStruct;
|
|
|
|
|
2020-04-03 13:36:02 +00:00
|
|
|
static gboolean
|
2024-08-29 17:09:52 +00:00
|
|
|
structure_remove_buffers_ip (const GstIdStr * fieldname, GValue * value,
|
2020-04-03 13:36:02 +00:00
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
if (G_VALUE_HOLDS (value, GST_TYPE_BUFFER))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (GST_VALUE_HOLDS_ARRAY (value)) {
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < gst_value_array_get_size (value); i++) {
|
|
|
|
if (structure_remove_buffers_ip (0,
|
|
|
|
(GValue *) gst_value_array_get_value (value, i), user_data))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
caps_remove_buffers_ip (GstCapsFeatures * features, GstStructure * structure,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2024-08-29 17:09:52 +00:00
|
|
|
gst_structure_filter_and_map_in_place_id_str (structure,
|
2020-04-03 13:36:02 +00:00
|
|
|
structure_remove_buffers_ip, NULL);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-01-05 12:23:08 +00:00
|
|
|
static void
|
|
|
|
my_g_string_append_printf (GString * str, int depth, const gchar * format, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
while (depth-- > 0) {
|
|
|
|
g_string_append (str, " ");
|
|
|
|
}
|
|
|
|
|
|
|
|
va_start (args, format);
|
|
|
|
g_string_append_vprintf (str, format, args);
|
|
|
|
va_end (args);
|
|
|
|
}
|
2010-09-20 09:24:10 +00:00
|
|
|
|
2020-04-03 13:36:02 +00:00
|
|
|
static gchar *
|
|
|
|
caps_to_string (GstCaps * caps)
|
|
|
|
{
|
|
|
|
gchar *res = NULL;
|
|
|
|
|
|
|
|
if (verbose) {
|
|
|
|
res = gst_caps_to_string (caps);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
caps = gst_caps_make_writable (caps);
|
|
|
|
|
|
|
|
gst_caps_map_in_place (caps, caps_remove_buffers_ip, NULL);
|
|
|
|
res = gst_caps_to_string (caps);
|
|
|
|
|
|
|
|
done:
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-10-03 17:52:58 +00:00
|
|
|
static void
|
|
|
|
gst_stream_information_to_string (GstDiscovererStreamInfo * info, GString * s,
|
2014-07-21 12:54:05 +00:00
|
|
|
guint depth)
|
2010-09-20 09:24:10 +00:00
|
|
|
{
|
|
|
|
gchar *tmp;
|
|
|
|
GstCaps *caps;
|
2018-04-02 06:43:17 +00:00
|
|
|
#ifndef GST_DISABLE_DEPRECATED
|
2013-10-03 17:52:58 +00:00
|
|
|
const GstStructure *misc;
|
2018-04-02 06:43:17 +00:00
|
|
|
#endif
|
2010-09-20 09:24:10 +00:00
|
|
|
|
2020-04-03 13:36:02 +00:00
|
|
|
if (verbose) {
|
|
|
|
my_g_string_append_printf (s, depth, "Codec:\n");
|
|
|
|
caps = gst_discoverer_stream_info_get_caps (info);
|
|
|
|
tmp = caps_to_string (caps);
|
2012-01-05 12:23:08 +00:00
|
|
|
my_g_string_append_printf (s, depth, " %s\n", tmp);
|
2010-09-20 09:24:10 +00:00
|
|
|
g_free (tmp);
|
2020-04-03 13:36:02 +00:00
|
|
|
}
|
|
|
|
#ifndef GST_DISABLE_DEPRECATED
|
|
|
|
if (verbose) {
|
|
|
|
misc = gst_discoverer_stream_info_get_misc (info);
|
|
|
|
if (misc) {
|
|
|
|
my_g_string_append_printf (s, depth, "Additional info:\n");
|
|
|
|
tmp = gst_structure_to_string (misc);
|
|
|
|
my_g_string_append_printf (s, depth, " %s\n", tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
}
|
2010-09-20 09:24:10 +00:00
|
|
|
}
|
2018-04-02 06:43:17 +00:00
|
|
|
#endif
|
2010-09-20 09:24:10 +00:00
|
|
|
|
2012-11-20 13:56:45 +00:00
|
|
|
my_g_string_append_printf (s, depth, "Stream ID: %s\n",
|
|
|
|
gst_discoverer_stream_info_get_stream_id (info));
|
2013-10-03 17:52:58 +00:00
|
|
|
}
|
|
|
|
|
2014-07-21 12:54:05 +00:00
|
|
|
static void
|
|
|
|
print_tag_foreach (const GstTagList * tags, const gchar * tag,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GValue val = { 0, };
|
|
|
|
gchar *str;
|
|
|
|
guint depth = GPOINTER_TO_UINT (user_data);
|
|
|
|
|
2014-10-03 11:42:46 +00:00
|
|
|
if (!gst_tag_list_copy_value (&val, tags, tag))
|
|
|
|
return;
|
2014-07-21 12:54:05 +00:00
|
|
|
|
|
|
|
if (G_VALUE_HOLDS_STRING (&val)) {
|
|
|
|
str = g_value_dup_string (&val);
|
|
|
|
} else if (G_VALUE_TYPE (&val) == GST_TYPE_SAMPLE) {
|
|
|
|
GstSample *sample = gst_value_get_sample (&val);
|
|
|
|
GstBuffer *img = gst_sample_get_buffer (sample);
|
|
|
|
GstCaps *caps = gst_sample_get_caps (sample);
|
|
|
|
|
|
|
|
if (img) {
|
|
|
|
if (caps) {
|
|
|
|
gchar *caps_str;
|
|
|
|
|
2020-04-03 13:36:02 +00:00
|
|
|
caps_str = caps_to_string (gst_caps_ref (caps));
|
2014-07-21 12:54:05 +00:00
|
|
|
str = g_strdup_printf ("buffer of %" G_GSIZE_FORMAT " bytes, "
|
|
|
|
"type: %s", gst_buffer_get_size (img), caps_str);
|
|
|
|
g_free (caps_str);
|
|
|
|
} else {
|
|
|
|
str = g_strdup_printf ("buffer of %" G_GSIZE_FORMAT " bytes",
|
|
|
|
gst_buffer_get_size (img));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
str = g_strdup ("NULL buffer");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
str = gst_value_serialize (&val);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_print ("%*s%s: %s\n", 2 * depth, " ", gst_tag_get_nick (tag), str);
|
|
|
|
g_free (str);
|
|
|
|
|
|
|
|
g_value_unset (&val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_tags_topology (guint depth, const GstTagList * tags)
|
|
|
|
{
|
2020-04-03 13:36:02 +00:00
|
|
|
if (!verbose)
|
|
|
|
return;
|
|
|
|
|
2014-07-21 12:54:05 +00:00
|
|
|
g_print ("%*sTags:\n", 2 * depth, " ");
|
|
|
|
if (tags) {
|
|
|
|
gst_tag_list_foreach (tags, print_tag_foreach,
|
|
|
|
GUINT_TO_POINTER (depth + 1));
|
|
|
|
} else {
|
|
|
|
g_print ("%*sNone\n", 2 * (depth + 1), " ");
|
|
|
|
}
|
2020-04-03 13:36:02 +00:00
|
|
|
g_print ("%*s\n", 2 * depth, " ");
|
2014-07-21 12:54:05 +00:00
|
|
|
}
|
|
|
|
|
2017-06-13 00:18:19 +00:00
|
|
|
static gchar *
|
|
|
|
format_channel_mask (GstDiscovererAudioInfo * ainfo)
|
|
|
|
{
|
|
|
|
GString *s = g_string_sized_new (32);
|
|
|
|
GstAudioChannelPosition position[64];
|
|
|
|
guint channels = gst_discoverer_audio_info_get_channels (ainfo);
|
|
|
|
GEnumClass *enum_class = g_type_class_ref (GST_TYPE_AUDIO_CHANNEL_POSITION);
|
|
|
|
guint i;
|
2018-06-13 12:29:46 +00:00
|
|
|
guint64 channel_mask;
|
2017-06-13 00:18:19 +00:00
|
|
|
|
|
|
|
if (channels == 0)
|
|
|
|
goto done;
|
|
|
|
|
2018-06-13 12:29:46 +00:00
|
|
|
channel_mask = gst_discoverer_audio_info_get_channel_mask (ainfo);
|
2017-06-13 00:18:19 +00:00
|
|
|
|
2018-06-13 12:29:46 +00:00
|
|
|
if (channel_mask != 0) {
|
|
|
|
gst_audio_channel_positions_from_mask (channels, channel_mask, position);
|
|
|
|
|
|
|
|
for (i = 0; i < channels; i++) {
|
|
|
|
GEnumValue *value = g_enum_get_value (enum_class, position[i]);
|
|
|
|
my_g_string_append_printf (s, 0, "%s%s", value->value_nick,
|
|
|
|
i + 1 == channels ? "" : ", ");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
g_string_append (s, "unknown layout");
|
2017-06-13 00:18:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_type_class_unref (enum_class);
|
|
|
|
|
|
|
|
done:
|
|
|
|
return g_string_free (s, FALSE);
|
|
|
|
}
|
|
|
|
|
2013-10-03 17:52:58 +00:00
|
|
|
static gchar *
|
|
|
|
gst_stream_audio_information_to_string (GstDiscovererStreamInfo * info,
|
2014-07-21 12:54:05 +00:00
|
|
|
guint depth)
|
2013-10-03 17:52:58 +00:00
|
|
|
{
|
|
|
|
GstDiscovererAudioInfo *audio_info;
|
|
|
|
GString *s;
|
|
|
|
const gchar *ctmp;
|
|
|
|
int len = 400;
|
|
|
|
const GstTagList *tags;
|
2017-06-13 00:18:19 +00:00
|
|
|
gchar *channel_positions;
|
2013-10-03 17:52:58 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
|
|
|
s = g_string_sized_new (len);
|
|
|
|
|
|
|
|
gst_stream_information_to_string (info, s, depth);
|
2012-11-20 13:56:45 +00:00
|
|
|
|
2010-10-30 10:41:23 +00:00
|
|
|
audio_info = (GstDiscovererAudioInfo *) info;
|
2011-08-24 15:29:08 +00:00
|
|
|
ctmp = gst_discoverer_audio_info_get_language (audio_info);
|
2012-01-05 12:23:08 +00:00
|
|
|
my_g_string_append_printf (s, depth, "Language: %s\n",
|
|
|
|
ctmp ? ctmp : "<unknown>");
|
2017-06-13 00:18:19 +00:00
|
|
|
|
|
|
|
channel_positions = format_channel_mask (audio_info);
|
|
|
|
my_g_string_append_printf (s, depth, "Channels: %u (%s)\n",
|
|
|
|
gst_discoverer_audio_info_get_channels (audio_info), channel_positions);
|
|
|
|
g_free (channel_positions);
|
|
|
|
|
2012-01-05 12:23:08 +00:00
|
|
|
my_g_string_append_printf (s, depth, "Sample rate: %u\n",
|
2010-10-30 10:41:23 +00:00
|
|
|
gst_discoverer_audio_info_get_sample_rate (audio_info));
|
2012-01-05 12:23:08 +00:00
|
|
|
my_g_string_append_printf (s, depth, "Depth: %u\n",
|
2010-10-30 10:41:23 +00:00
|
|
|
gst_discoverer_audio_info_get_depth (audio_info));
|
2010-09-20 09:24:10 +00:00
|
|
|
|
2012-01-05 12:23:08 +00:00
|
|
|
my_g_string_append_printf (s, depth, "Bitrate: %u\n",
|
2010-10-30 10:41:23 +00:00
|
|
|
gst_discoverer_audio_info_get_bitrate (audio_info));
|
2012-01-05 12:23:08 +00:00
|
|
|
my_g_string_append_printf (s, depth, "Max bitrate: %u\n",
|
2010-10-30 10:41:23 +00:00
|
|
|
gst_discoverer_audio_info_get_max_bitrate (audio_info));
|
2010-09-20 09:24:10 +00:00
|
|
|
|
|
|
|
tags = gst_discoverer_stream_info_get_tags (info);
|
2014-07-21 12:54:05 +00:00
|
|
|
print_tags_topology (depth, tags);
|
2010-09-20 09:24:10 +00:00
|
|
|
|
|
|
|
return g_string_free (s, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
gst_stream_video_information_to_string (GstDiscovererStreamInfo * info,
|
2014-07-21 12:54:05 +00:00
|
|
|
guint depth)
|
2010-09-20 09:24:10 +00:00
|
|
|
{
|
2010-10-30 10:41:23 +00:00
|
|
|
GstDiscovererVideoInfo *video_info;
|
2010-09-20 09:24:10 +00:00
|
|
|
GString *s;
|
|
|
|
int len = 500;
|
|
|
|
const GstTagList *tags;
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
|
|
|
s = g_string_sized_new (len);
|
|
|
|
|
2013-10-03 17:52:58 +00:00
|
|
|
gst_stream_information_to_string (info, s, depth);
|
2012-11-20 13:56:45 +00:00
|
|
|
|
2010-10-30 10:41:23 +00:00
|
|
|
video_info = (GstDiscovererVideoInfo *) info;
|
2012-01-05 12:23:08 +00:00
|
|
|
my_g_string_append_printf (s, depth, "Width: %u\n",
|
2010-10-30 10:41:23 +00:00
|
|
|
gst_discoverer_video_info_get_width (video_info));
|
2012-01-05 12:23:08 +00:00
|
|
|
my_g_string_append_printf (s, depth, "Height: %u\n",
|
2010-10-30 10:41:23 +00:00
|
|
|
gst_discoverer_video_info_get_height (video_info));
|
2012-01-05 12:23:08 +00:00
|
|
|
my_g_string_append_printf (s, depth, "Depth: %u\n",
|
2010-10-30 10:41:23 +00:00
|
|
|
gst_discoverer_video_info_get_depth (video_info));
|
2010-09-20 09:24:10 +00:00
|
|
|
|
2012-01-05 12:23:08 +00:00
|
|
|
my_g_string_append_printf (s, depth, "Frame rate: %u/%u\n",
|
2010-10-30 10:41:23 +00:00
|
|
|
gst_discoverer_video_info_get_framerate_num (video_info),
|
|
|
|
gst_discoverer_video_info_get_framerate_denom (video_info));
|
2010-09-20 09:24:10 +00:00
|
|
|
|
2012-01-05 12:23:08 +00:00
|
|
|
my_g_string_append_printf (s, depth, "Pixel aspect ratio: %u/%u\n",
|
2010-10-30 10:41:23 +00:00
|
|
|
gst_discoverer_video_info_get_par_num (video_info),
|
|
|
|
gst_discoverer_video_info_get_par_denom (video_info));
|
2010-09-20 09:24:10 +00:00
|
|
|
|
2012-01-05 12:23:08 +00:00
|
|
|
my_g_string_append_printf (s, depth, "Interlaced: %s\n",
|
2010-10-28 15:51:08 +00:00
|
|
|
gst_discoverer_video_info_is_interlaced (video_info) ? "true" : "false");
|
2010-09-20 09:24:10 +00:00
|
|
|
|
2012-01-05 12:23:08 +00:00
|
|
|
my_g_string_append_printf (s, depth, "Bitrate: %u\n",
|
2010-10-30 10:41:23 +00:00
|
|
|
gst_discoverer_video_info_get_bitrate (video_info));
|
2012-01-05 12:23:08 +00:00
|
|
|
my_g_string_append_printf (s, depth, "Max bitrate: %u\n",
|
2010-10-30 10:41:23 +00:00
|
|
|
gst_discoverer_video_info_get_max_bitrate (video_info));
|
2010-09-20 09:24:10 +00:00
|
|
|
|
|
|
|
tags = gst_discoverer_stream_info_get_tags (info);
|
2014-07-21 12:54:05 +00:00
|
|
|
print_tags_topology (depth, tags);
|
2010-09-20 09:24:10 +00:00
|
|
|
|
|
|
|
return g_string_free (s, FALSE);
|
|
|
|
}
|
|
|
|
|
2011-08-24 14:04:50 +00:00
|
|
|
static gchar *
|
|
|
|
gst_stream_subtitle_information_to_string (GstDiscovererStreamInfo * info,
|
2014-07-21 12:54:05 +00:00
|
|
|
guint depth)
|
2011-08-24 14:04:50 +00:00
|
|
|
{
|
|
|
|
GstDiscovererSubtitleInfo *subtitle_info;
|
|
|
|
GString *s;
|
|
|
|
const gchar *ctmp;
|
|
|
|
int len = 400;
|
|
|
|
const GstTagList *tags;
|
|
|
|
|
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
|
|
|
|
|
|
|
s = g_string_sized_new (len);
|
|
|
|
|
2013-10-03 17:52:58 +00:00
|
|
|
gst_stream_information_to_string (info, s, depth);
|
2012-11-20 13:56:45 +00:00
|
|
|
|
2011-08-24 14:04:50 +00:00
|
|
|
subtitle_info = (GstDiscovererSubtitleInfo *) info;
|
|
|
|
ctmp = gst_discoverer_subtitle_info_get_language (subtitle_info);
|
2012-01-05 12:23:08 +00:00
|
|
|
my_g_string_append_printf (s, depth, "Language: %s\n",
|
|
|
|
ctmp ? ctmp : "<unknown>");
|
2011-08-24 14:04:50 +00:00
|
|
|
|
|
|
|
tags = gst_discoverer_stream_info_get_tags (info);
|
2014-07-21 12:54:05 +00:00
|
|
|
print_tags_topology (depth, tags);
|
2011-08-24 14:04:50 +00:00
|
|
|
|
|
|
|
return g_string_free (s, FALSE);
|
|
|
|
}
|
|
|
|
|
2010-09-20 09:24:10 +00:00
|
|
|
static void
|
|
|
|
print_stream_info (GstDiscovererStreamInfo * info, void *depth)
|
|
|
|
{
|
|
|
|
gchar *desc = NULL;
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
caps = gst_discoverer_stream_info_get_caps (info);
|
|
|
|
|
|
|
|
if (caps) {
|
|
|
|
if (gst_caps_is_fixed (caps) && !verbose)
|
|
|
|
desc = gst_pb_utils_get_codec_description (caps);
|
|
|
|
else
|
2020-04-03 13:36:02 +00:00
|
|
|
desc = caps_to_string (gst_caps_ref (caps));
|
2010-09-20 09:24:10 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
}
|
|
|
|
|
2021-02-09 22:56:49 +00:00
|
|
|
g_print ("%*s%s #%d: %s\n", 2 * GPOINTER_TO_INT (depth), " ",
|
build: fix debug output werror build with newer gcc
In file included from ../../../../dist/linux_x86_64/include/gstreamer-1.0/gst/gst.h:55,
from ../gst-libs/gst/tag/tag.h:25,
from ../gst-libs/gst/tag/gsttageditingprivate.h:24,
from ../gst-libs/gst/tag/gsttageditingprivate.c:23:
../gst-libs/gst/tag/gsttageditingprivate.c: In function ‘__exif_tag_capturing_white_balance_to_exif_value’:
../../../../dist/linux_x86_64/include/gstreamer-1.0/gst/gstinfo.h:645:5: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
645 | gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__, \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
646 | (GObject *) (object), __VA_ARGS__); \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../dist/linux_x86_64/include/gstreamer-1.0/gst/gstinfo.h:1068:27: note: in expansion of macro ‘GST_CAT_LEVEL_LOG’
1068 | #define GST_WARNING(...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
../gst-libs/gst/tag/gsttageditingprivate.c:265:3: note: in expansion of macro ‘GST_WARNING’
265 | GST_WARNING ("Invalid white balance: %s", str);
| ^~~~~~~~~~~
../gst-libs/gst/tag/gsttageditingprivate.c:265:40: note: format string is defined here
265 | GST_WARNING ("Invalid white balance: %s", str);
| ^~
In file included from ../../../../dist/linux_x86_64/include/gstreamer-1.0/gst/gst.h:55,
from ../gst-libs/gst/tag/tag.h:25,
from ../gst-libs/gst/tag/gstxmptag.c:39:
../gst-libs/gst/tag/gstxmptag.c: In function ‘deserialize_exif_gps_direction’:
../../../../dist/linux_x86_64/include/gstreamer-1.0/gst/gstinfo.h:645:5: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
645 | gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__, \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
646 | (GObject *) (object), __VA_ARGS__); \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../dist/linux_x86_64/include/gstreamer-1.0/gst/gstinfo.h:1068:27: note: in expansion of macro ‘GST_CAT_LEVEL_LOG’
1068 | #define GST_WARNING(...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
../gst-libs/gst/tag/gstxmptag.c:818:5: note: in expansion of macro ‘GST_WARNING’
818 | GST_WARNING ("Missing %s tag", dirref_str);
| ^~~~~~~~~~~
../gst-libs/gst/tag/gstxmptag.c:818:27: note: format string is defined here
818 | GST_WARNING ("Missing %s tag", dirref_str);
| ^~
In file included from ../../../../dist/linux_x86_64/include/gstreamer-1.0/gst/gst.h:55,
from ../gst-libs/gst/tag/tag.h:25,
from ../gst-libs/gst/tag/gstxmptag.c:39:
../../../../dist/linux_x86_64/include/gstreamer-1.0/gst/gstinfo.h:645:5: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
645 | gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__, \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
646 | (GObject *) (object), __VA_ARGS__); \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../dist/linux_x86_64/include/gstreamer-1.0/gst/gstinfo.h:1068:27: note: in expansion of macro ‘GST_CAT_LEVEL_LOG’
1068 | #define GST_WARNING(...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
../gst-libs/gst/tag/gstxmptag.c:814:5: note: in expansion of macro ‘GST_WARNING’
814 | GST_WARNING ("Missing %s tag", dir_str);
| ^~~~~~~~~~~
../gst-libs/gst/tag/gstxmptag.c:814:27: note: format string is defined here
814 | GST_WARNING ("Missing %s tag", dir_str);
| ^~
In file included from ../../../../dist/linux_x86_64/include/gstreamer-1.0/gst/gst.h:55,
from ../gst-libs/gst/gl/gstgl_fwd.h:24,
from ../gst-libs/gst/gl/gl.h:24,
from ../gst-libs/gst/gl/gstglsl.c:25:
../gst-libs/gst/gl/gstglsl.c: In function ‘gst_glsl_version_profile_from_string’:
../../../../dist/linux_x86_64/include/gstreamer-1.0/gst/gstinfo.h:645:5: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
645 | gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__, \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
646 | (GObject *) (object), __VA_ARGS__); \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../dist/linux_x86_64/include/gstreamer-1.0/gst/gstinfo.h:1068:27: note: in expansion of macro ‘GST_CAT_LEVEL_LOG’
1068 | #define GST_WARNING(...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
../gst-libs/gst/gl/gstglsl.c:333:7: note: in expansion of macro ‘GST_WARNING’
333 | GST_WARNING ("Invalid preprocesser directive detected: %s", version_s);
| ^~~~~~~~~~~
../gst-libs/gst/gl/gstglsl.c:333:62: note: format string is defined here
333 | GST_WARNING ("Invalid preprocesser directive detected: %s", version_s);
| ^~
In function ‘print_stream_info’,
inlined from ‘print_topology’ at ../tools/gst-discoverer.c:352:3:
../tools/gst-discoverer.c:316:3: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
316 | g_print ("%*s%s: %s\n", 2 * GPOINTER_TO_INT (depth), " ",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
317 | gst_discoverer_stream_info_get_stream_type_nick (info), desc);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-09-23 05:39:55 +00:00
|
|
|
gst_discoverer_stream_info_get_stream_type_nick (info),
|
2021-02-09 22:56:49 +00:00
|
|
|
gst_discoverer_stream_info_get_stream_number (info), GST_STR_NULL (desc));
|
2010-09-20 09:24:10 +00:00
|
|
|
|
|
|
|
if (desc) {
|
|
|
|
g_free (desc);
|
|
|
|
desc = NULL;
|
|
|
|
}
|
|
|
|
|
2020-04-03 13:36:02 +00:00
|
|
|
if (GST_IS_DISCOVERER_AUDIO_INFO (info))
|
|
|
|
desc =
|
|
|
|
gst_stream_audio_information_to_string (info,
|
|
|
|
GPOINTER_TO_INT (depth) + 1);
|
|
|
|
else if (GST_IS_DISCOVERER_VIDEO_INFO (info))
|
|
|
|
desc =
|
|
|
|
gst_stream_video_information_to_string (info,
|
|
|
|
GPOINTER_TO_INT (depth) + 1);
|
|
|
|
else if (GST_IS_DISCOVERER_SUBTITLE_INFO (info))
|
|
|
|
desc =
|
|
|
|
gst_stream_subtitle_information_to_string (info,
|
|
|
|
GPOINTER_TO_INT (depth) + 1);
|
2021-10-10 16:07:33 +00:00
|
|
|
else if (GST_IS_DISCOVERER_CONTAINER_INFO (info)) {
|
|
|
|
const GstTagList *tags =
|
|
|
|
gst_discoverer_container_info_get_tags (GST_DISCOVERER_CONTAINER_INFO
|
|
|
|
(info));
|
|
|
|
print_tags_topology (GPOINTER_TO_INT (depth) + 1, tags);
|
|
|
|
}
|
2020-04-03 13:36:02 +00:00
|
|
|
if (desc) {
|
|
|
|
g_print ("%s", desc);
|
|
|
|
g_free (desc);
|
2010-09-20 09:24:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-07-21 12:54:05 +00:00
|
|
|
print_topology (GstDiscovererStreamInfo * info, guint depth)
|
2010-09-20 09:24:10 +00:00
|
|
|
{
|
|
|
|
GstDiscovererStreamInfo *next;
|
|
|
|
|
|
|
|
if (!info)
|
|
|
|
return;
|
|
|
|
|
|
|
|
print_stream_info (info, GINT_TO_POINTER (depth));
|
|
|
|
|
|
|
|
next = gst_discoverer_stream_info_get_next (info);
|
|
|
|
if (next) {
|
|
|
|
print_topology (next, depth + 1);
|
|
|
|
gst_discoverer_stream_info_unref (next);
|
|
|
|
} else if (GST_IS_DISCOVERER_CONTAINER_INFO (info)) {
|
|
|
|
GList *tmp, *streams;
|
|
|
|
|
2010-11-08 03:56:27 +00:00
|
|
|
streams =
|
|
|
|
gst_discoverer_container_info_get_streams (GST_DISCOVERER_CONTAINER_INFO
|
|
|
|
(info));
|
2010-09-20 09:24:10 +00:00
|
|
|
for (tmp = streams; tmp; tmp = tmp->next) {
|
|
|
|
GstDiscovererStreamInfo *tmpinf = (GstDiscovererStreamInfo *) tmp->data;
|
|
|
|
print_topology (tmpinf, depth + 1);
|
|
|
|
}
|
|
|
|
gst_discoverer_stream_info_list_free (streams);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-20 23:01:17 +00:00
|
|
|
static void
|
|
|
|
print_toc_entry (gpointer data, gpointer user_data)
|
|
|
|
{
|
|
|
|
GstTocEntry *entry = (GstTocEntry *) data;
|
2014-07-21 12:54:05 +00:00
|
|
|
guint depth = GPOINTER_TO_UINT (user_data);
|
2012-05-20 23:01:17 +00:00
|
|
|
guint indent = MIN (GPOINTER_TO_UINT (user_data), MAX_INDENT);
|
2012-07-05 09:03:52 +00:00
|
|
|
GstTagList *tags;
|
|
|
|
GList *subentries;
|
2012-05-20 23:01:17 +00:00
|
|
|
gint64 start, stop;
|
|
|
|
|
2012-07-05 09:03:52 +00:00
|
|
|
gst_toc_entry_get_start_stop_times (entry, &start, &stop);
|
2012-05-20 23:01:17 +00:00
|
|
|
g_print ("%*s%s: start: %" GST_TIME_FORMAT " stop: %" GST_TIME_FORMAT "\n",
|
2012-07-05 09:03:52 +00:00
|
|
|
depth, " ",
|
|
|
|
gst_toc_entry_type_get_nick (gst_toc_entry_get_entry_type (entry)),
|
2012-05-20 23:01:17 +00:00
|
|
|
GST_TIME_ARGS (start), GST_TIME_ARGS (stop));
|
|
|
|
indent += 2;
|
|
|
|
|
|
|
|
/* print tags */
|
2012-07-05 09:03:52 +00:00
|
|
|
tags = gst_toc_entry_get_tags (entry);
|
|
|
|
if (tags) {
|
2012-05-20 23:01:17 +00:00
|
|
|
g_print ("%*sTags:\n", 2 * depth, " ");
|
2012-07-05 09:03:52 +00:00
|
|
|
gst_tag_list_foreach (tags, print_tag_foreach, GUINT_TO_POINTER (indent));
|
|
|
|
}
|
2012-05-20 23:01:17 +00:00
|
|
|
|
|
|
|
/* loop over sub-toc entries */
|
2012-07-05 09:03:52 +00:00
|
|
|
subentries = gst_toc_entry_get_sub_entries (entry);
|
|
|
|
g_list_foreach (subentries, print_toc_entry, GUINT_TO_POINTER (indent));
|
2012-05-20 23:01:17 +00:00
|
|
|
}
|
|
|
|
|
2010-09-20 09:24:10 +00:00
|
|
|
static void
|
2010-12-13 14:20:23 +00:00
|
|
|
print_properties (GstDiscovererInfo * info, gint tab)
|
2010-09-20 09:24:10 +00:00
|
|
|
{
|
2010-12-19 12:22:23 +00:00
|
|
|
const GstTagList *tags;
|
2012-05-20 23:01:17 +00:00
|
|
|
const GstToc *toc;
|
2010-12-19 12:22:23 +00:00
|
|
|
|
2010-12-13 14:20:23 +00:00
|
|
|
g_print ("%*sDuration: %" GST_TIME_FORMAT "\n", tab + 1, " ",
|
2010-09-20 09:24:10 +00:00
|
|
|
GST_TIME_ARGS (gst_discoverer_info_get_duration (info)));
|
2010-12-13 14:20:23 +00:00
|
|
|
g_print ("%*sSeekable: %s\n", tab + 1, " ",
|
|
|
|
(gst_discoverer_info_get_seekable (info) ? "yes" : "no"));
|
2017-06-13 00:32:09 +00:00
|
|
|
g_print ("%*sLive: %s\n", tab + 1, " ",
|
|
|
|
(gst_discoverer_info_get_live (info) ? "yes" : "no"));
|
2020-04-03 13:36:02 +00:00
|
|
|
if (verbose && (tags = gst_discoverer_info_get_tags (info))) {
|
2010-12-19 12:22:23 +00:00
|
|
|
g_print ("%*sTags: \n", tab + 1, " ");
|
2012-07-07 11:10:45 +00:00
|
|
|
gst_tag_list_foreach (tags, print_tag_foreach, GUINT_TO_POINTER (tab + 2));
|
2010-12-19 12:22:23 +00:00
|
|
|
}
|
2012-05-20 23:01:17 +00:00
|
|
|
if (show_toc && (toc = gst_discoverer_info_get_toc (info))) {
|
2012-07-05 09:03:52 +00:00
|
|
|
GList *entries;
|
|
|
|
|
2012-05-20 23:01:17 +00:00
|
|
|
g_print ("%*sTOC: \n", tab + 1, " ");
|
2012-07-05 09:03:52 +00:00
|
|
|
entries = gst_toc_get_entries (toc);
|
|
|
|
g_list_foreach (entries, print_toc_entry, GUINT_TO_POINTER (tab + 5));
|
2012-05-20 23:01:17 +00:00
|
|
|
}
|
2010-09-20 09:24:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_info (GstDiscovererInfo * info, GError * err)
|
|
|
|
{
|
2015-08-18 23:37:46 +00:00
|
|
|
GstDiscovererResult result;
|
2010-09-22 10:35:59 +00:00
|
|
|
GstDiscovererStreamInfo *sinfo;
|
2010-09-20 09:24:10 +00:00
|
|
|
|
2015-08-18 23:37:46 +00:00
|
|
|
if (!info) {
|
|
|
|
g_print ("Could not discover URI\n");
|
|
|
|
g_print (" %s\n", err->message);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
result = gst_discoverer_info_get_result (info);
|
2010-09-20 09:24:10 +00:00
|
|
|
g_print ("Done discovering %s\n", gst_discoverer_info_get_uri (info));
|
2010-09-22 10:35:59 +00:00
|
|
|
switch (result) {
|
|
|
|
case GST_DISCOVERER_OK:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_DISCOVERER_URI_INVALID:
|
|
|
|
{
|
|
|
|
g_print ("URI is not valid\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_DISCOVERER_ERROR:
|
|
|
|
{
|
|
|
|
g_print ("An error was encountered while discovering the file\n");
|
|
|
|
g_print (" %s\n", err->message);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_DISCOVERER_TIMEOUT:
|
|
|
|
{
|
|
|
|
g_print ("Analyzing URI timed out\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_DISCOVERER_BUSY:
|
|
|
|
{
|
|
|
|
g_print ("Discoverer was busy\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_DISCOVERER_MISSING_PLUGINS:
|
|
|
|
{
|
2020-04-03 13:36:02 +00:00
|
|
|
gint i = 0;
|
|
|
|
const gchar **installer_details =
|
|
|
|
gst_discoverer_info_get_missing_elements_installer_details (info);
|
|
|
|
|
2010-09-22 10:35:59 +00:00
|
|
|
g_print ("Missing plugins\n");
|
2014-01-14 14:39:55 +00:00
|
|
|
|
2020-04-03 13:36:02 +00:00
|
|
|
while (installer_details[i]) {
|
|
|
|
g_print (" (%s)\n", installer_details[i]);
|
2014-01-14 14:39:55 +00:00
|
|
|
|
2020-04-03 13:36:02 +00:00
|
|
|
i++;
|
2010-09-22 10:35:59 +00:00
|
|
|
}
|
|
|
|
break;
|
2010-09-20 09:24:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-29 16:57:50 +00:00
|
|
|
if ((sinfo = gst_discoverer_info_get_stream_info (info))) {
|
2010-12-13 14:20:23 +00:00
|
|
|
g_print ("\nProperties:\n");
|
|
|
|
print_properties (info, 1);
|
2020-04-03 13:36:02 +00:00
|
|
|
print_topology (sinfo, 1);
|
2010-09-29 16:57:50 +00:00
|
|
|
gst_discoverer_stream_info_unref (sinfo);
|
|
|
|
}
|
|
|
|
|
2010-09-20 09:24:10 +00:00
|
|
|
g_print ("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
process_file (GstDiscoverer * dc, const gchar * filename)
|
|
|
|
{
|
|
|
|
GError *err = NULL;
|
|
|
|
GDir *dir;
|
|
|
|
gchar *uri, *path;
|
|
|
|
GstDiscovererInfo *info;
|
|
|
|
|
|
|
|
if (!gst_uri_is_valid (filename)) {
|
|
|
|
/* Recurse into directories */
|
|
|
|
if ((dir = g_dir_open (filename, 0, NULL))) {
|
|
|
|
const gchar *entry;
|
|
|
|
|
|
|
|
while ((entry = g_dir_read_name (dir))) {
|
|
|
|
gchar *path;
|
|
|
|
path = g_strconcat (filename, G_DIR_SEPARATOR_S, entry, NULL);
|
|
|
|
process_file (dc, path);
|
|
|
|
g_free (path);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_dir_close (dir);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!g_path_is_absolute (filename)) {
|
|
|
|
gchar *cur_dir;
|
|
|
|
|
|
|
|
cur_dir = g_get_current_dir ();
|
|
|
|
path = g_build_filename (cur_dir, filename, NULL);
|
|
|
|
g_free (cur_dir);
|
|
|
|
} else {
|
|
|
|
path = g_strdup (filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
uri = g_filename_to_uri (path, NULL, &err);
|
|
|
|
g_free (path);
|
|
|
|
path = NULL;
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
g_warning ("Couldn't convert filename to URI: %s\n", err->message);
|
2015-08-20 06:59:15 +00:00
|
|
|
g_clear_error (&err);
|
2010-09-20 09:24:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
uri = g_strdup (filename);
|
|
|
|
}
|
|
|
|
|
2014-11-28 13:28:06 +00:00
|
|
|
if (!async) {
|
2010-09-20 09:24:10 +00:00
|
|
|
g_print ("Analyzing %s\n", uri);
|
|
|
|
info = gst_discoverer_discover_uri (dc, uri, &err);
|
|
|
|
print_info (info, err);
|
2015-08-20 06:59:15 +00:00
|
|
|
g_clear_error (&err);
|
|
|
|
if (info)
|
|
|
|
gst_discoverer_info_unref (info);
|
2010-09-20 09:24:10 +00:00
|
|
|
} else {
|
|
|
|
gst_discoverer_discover_uri_async (dc, uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_new_discovered_uri (GstDiscoverer * dc, GstDiscovererInfo * info, GError * err)
|
|
|
|
{
|
|
|
|
print_info (info, err);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
_run_async (PrivStruct * ps)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 1; i < ps->argc; i++)
|
|
|
|
process_file (ps->dc, ps->argv[i]);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-10-04 10:18:51 +00:00
|
|
|
_discoverer_finished (GstDiscoverer * dc, GMainLoop * ml)
|
2010-09-20 09:24:10 +00:00
|
|
|
{
|
|
|
|
g_main_loop_quit (ml);
|
|
|
|
}
|
|
|
|
|
2023-01-11 10:17:13 +00:00
|
|
|
static int
|
|
|
|
real_main (int argc, char **argv)
|
2010-09-20 09:24:10 +00:00
|
|
|
{
|
|
|
|
GError *err = NULL;
|
|
|
|
GstDiscoverer *dc;
|
|
|
|
gint timeout = 10;
|
2019-02-20 17:58:36 +00:00
|
|
|
gboolean use_cache = FALSE, print_cache_dir = FALSE;
|
2010-09-20 09:24:10 +00:00
|
|
|
GOptionEntry options[] = {
|
|
|
|
{"async", 'a', 0, G_OPTION_ARG_NONE, &async,
|
|
|
|
"Run asynchronously", NULL},
|
2020-06-22 03:19:28 +00:00
|
|
|
{"use-cache", 0, 0, G_OPTION_ARG_NONE, &use_cache,
|
2017-11-08 13:38:57 +00:00
|
|
|
"Use GstDiscovererInfo from our cache.", NULL},
|
2019-02-20 17:58:36 +00:00
|
|
|
{"print-cache-dir", 0, 0, G_OPTION_ARG_NONE, &print_cache_dir,
|
|
|
|
"Print the directory of the discoverer cache.", NULL},
|
2010-09-20 09:24:10 +00:00
|
|
|
{"timeout", 't', 0, G_OPTION_ARG_INT, &timeout,
|
|
|
|
"Specify timeout (in seconds, default 10)", "T"},
|
|
|
|
/* {"elem", 'e', 0, G_OPTION_ARG_NONE, &elem_seek, */
|
|
|
|
/* "Seek on elements instead of pads", NULL}, */
|
2012-05-20 23:01:17 +00:00
|
|
|
{"toc", 'c', 0, G_OPTION_ARG_NONE, &show_toc,
|
|
|
|
"Output TOC (chapters and editions)", NULL},
|
2010-09-20 09:24:10 +00:00
|
|
|
{"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
|
|
|
|
"Verbose properties", NULL},
|
|
|
|
{NULL}
|
|
|
|
};
|
|
|
|
GOptionContext *ctx;
|
|
|
|
|
2014-01-28 13:28:27 +00:00
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
|
2010-09-20 09:24:10 +00:00
|
|
|
ctx =
|
|
|
|
g_option_context_new
|
|
|
|
("- discover files synchronously with GstDiscoverer");
|
|
|
|
g_option_context_add_main_entries (ctx, options, NULL);
|
|
|
|
g_option_context_add_group (ctx, gst_init_get_option_group ());
|
|
|
|
|
2023-01-27 17:32:13 +00:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
if (!g_option_context_parse_strv (ctx, &argv, &err))
|
|
|
|
#else
|
|
|
|
if (!g_option_context_parse (ctx, &argc, &argv, &err))
|
|
|
|
#endif
|
|
|
|
{
|
2010-09-20 09:24:10 +00:00
|
|
|
g_print ("Error initializing: %s\n", err->message);
|
2015-08-17 02:18:25 +00:00
|
|
|
g_option_context_free (ctx);
|
|
|
|
g_clear_error (&err);
|
2010-09-20 09:24:10 +00:00
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_option_context_free (ctx);
|
|
|
|
|
2023-03-30 19:40:58 +00:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
argc = g_strv_length (argv);
|
|
|
|
#endif
|
|
|
|
|
2010-09-20 09:24:10 +00:00
|
|
|
if (argc < 2) {
|
|
|
|
g_print ("usage: %s <uris>\n", argv[0]);
|
|
|
|
exit (-1);
|
|
|
|
}
|
|
|
|
|
2019-02-20 17:58:36 +00:00
|
|
|
if (print_cache_dir) {
|
|
|
|
gchar *cache_dir =
|
|
|
|
g_build_filename (g_get_user_cache_dir (), "gstreamer-" GST_API_VERSION,
|
|
|
|
"discoverer", NULL);
|
|
|
|
g_print ("\nGstDiscoverer cache directory:\n\n %s\n\n", cache_dir);
|
|
|
|
g_free (cache_dir);
|
|
|
|
exit (0);
|
|
|
|
}
|
|
|
|
|
2010-09-20 09:24:10 +00:00
|
|
|
dc = gst_discoverer_new (timeout * GST_SECOND, &err);
|
|
|
|
if (G_UNLIKELY (dc == NULL)) {
|
|
|
|
g_print ("Error initializing: %s\n", err->message);
|
2015-08-17 02:18:25 +00:00
|
|
|
g_clear_error (&err);
|
2010-09-20 09:24:10 +00:00
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
2017-11-08 13:38:57 +00:00
|
|
|
g_object_set (dc, "use-cache", use_cache, NULL);
|
|
|
|
|
2014-11-28 13:28:06 +00:00
|
|
|
if (!async) {
|
2010-09-20 09:24:10 +00:00
|
|
|
gint i;
|
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
process_file (dc, argv[i]);
|
|
|
|
} else {
|
|
|
|
PrivStruct *ps = g_new0 (PrivStruct, 1);
|
|
|
|
GMainLoop *ml = g_main_loop_new (NULL, FALSE);
|
|
|
|
|
|
|
|
ps->dc = dc;
|
|
|
|
ps->argc = argc;
|
|
|
|
ps->argv = argv;
|
|
|
|
|
|
|
|
/* adding uris will be started when the mainloop runs */
|
|
|
|
g_idle_add ((GSourceFunc) _run_async, ps);
|
|
|
|
|
|
|
|
/* connect signals */
|
|
|
|
g_signal_connect (dc, "discovered", G_CALLBACK (_new_discovered_uri), NULL);
|
2010-10-04 10:18:51 +00:00
|
|
|
g_signal_connect (dc, "finished", G_CALLBACK (_discoverer_finished), ml);
|
2010-09-20 09:24:10 +00:00
|
|
|
|
|
|
|
gst_discoverer_start (dc);
|
|
|
|
/* run mainloop */
|
|
|
|
g_main_loop_run (ml);
|
|
|
|
|
|
|
|
gst_discoverer_stop (dc);
|
|
|
|
g_free (ps);
|
2011-01-06 07:46:42 +00:00
|
|
|
g_main_loop_unref (ml);
|
2010-09-20 09:24:10 +00:00
|
|
|
}
|
|
|
|
g_object_unref (dc);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2023-01-11 10:17:13 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
2023-01-27 17:32:13 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
argv = g_win32_get_command_line ();
|
|
|
|
#endif
|
|
|
|
|
2023-01-11 10:17:13 +00:00
|
|
|
#if defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE
|
2023-01-27 17:32:13 +00:00
|
|
|
ret = gst_macos_main ((GstMainFunc) real_main, argc, argv, NULL);
|
2023-01-11 10:17:13 +00:00
|
|
|
#else
|
2023-01-27 17:32:13 +00:00
|
|
|
ret = real_main (argc, argv);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
g_strfreev (argv);
|
2023-01-11 10:17:13 +00:00
|
|
|
#endif
|
2023-01-27 17:32:13 +00:00
|
|
|
|
|
|
|
return ret;
|
2023-01-11 10:17:13 +00:00
|
|
|
}
|