+2007-02-16 Tim-Philipp Müller <tim at centricular dot net>
+
+ * ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_base_init),
+ (gst_ffmpegdec_register):
+ * ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
+ (gst_ffmpegdemux_register):
+ * ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_base_init),
+ (gst_ffmpegenc_register):
+ * ext/ffmpeg/gstffmpegmux.c: (gst_ffmpegmux_base_init),
+ (gst_ffmpegmux_register):
+ Don't use GINT_TO_POINTER and GPOINTER_TO_INT with GTypes, this
+ can break horribly if sizeof(GType) happens to be bigger than
+ sizeof(int), because GPOINTER_TO_INT might then chop off some bits
+ of our GType (the reason this seems to works nevertheless is the
+ put-current-type-also-as-value-0-into-the-hash-table-as-fallback
+ hack used in the current code).
+ In any case, instead of just fixing this, let's not use a hash table
+ with GTypes here at all. g_type_{set|get}_qdata() seems to do the
+ job just as well.
+
2007-02-14 Edward Hervey <edward@fluendo.com>
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_flags_get_type):
ARG_SKIPFRAME
};
-static GHashTable *global_plugins;
-
-/* A number of functon prototypes are given so we can refer to them later. */
+/* A number of function prototypes are given so we can refer to them later. */
static void gst_ffmpegdec_base_init (GstFFMpegDecClass * klass);
static void gst_ffmpegdec_class_init (GstFFMpegDecClass * klass);
static void gst_ffmpegdec_init (GstFFMpegDec * ffmpegdec);
static void gst_ffmpegdec_release_buffer (AVCodecContext * context,
AVFrame * picture);
+#define GST_FFDEC_PARAMS_QDATA g_quark_from_static_string("ffdec-params")
+
static GstElementClass *parent_class = NULL;
#define GST_FFMPEGDEC_TYPE_LOWRES (gst_ffmpegdec_lowres_get_type())
static void
gst_ffmpegdec_base_init (GstFFMpegDecClass * klass)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstFFMpegDecClassParams *params;
GstElementDetails details;
GstPadTemplate *sinktempl, *srctempl;
- params = g_hash_table_lookup (global_plugins,
- GINT_TO_POINTER (G_OBJECT_CLASS_TYPE (gobject_class)));
- if (!params)
- params = g_hash_table_lookup (global_plugins, GINT_TO_POINTER (0));
- g_assert (params);
+ params =
+ (GstFFMpegDecClassParams *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
+ GST_FFDEC_PARAMS_QDATA);
+ g_assert (params != NULL);
/* construct the element details struct */
details.longname = g_strdup_printf ("FFMPEG %s decoder",
in_plugin = first_avcodec;
- global_plugins = g_hash_table_new (NULL, NULL);
-
while (in_plugin) {
GstFFMpegDecClassParams *params;
GstCaps *srccaps = NULL, *sinkcaps = NULL;
params->in_plugin = in_plugin;
params->srccaps = gst_caps_ref (srccaps);
params->sinkcaps = gst_caps_ref (sinkcaps);
- g_hash_table_insert (global_plugins,
- GINT_TO_POINTER (0), (gpointer) params);
/* create the gtype now */
type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
+ g_type_set_qdata (type, GST_FFDEC_PARAMS_QDATA, (gpointer) params);
/* (Ronald) MPEG-4 gets a higher priority because it has been well-
* tested and by far outperforms divxdec/xviddec - so we prefer it.
g_free (type_name);
- g_hash_table_insert (global_plugins,
- GINT_TO_POINTER (type), (gpointer) params);
-
next:
if (sinkcaps)
gst_caps_unref (sinkcaps);
gst_caps_unref (srccaps);
in_plugin = in_plugin->next;
}
- g_hash_table_remove (global_plugins, GINT_TO_POINTER (0));
return TRUE;
}
#include <ffmpeg/avformat.h>
#include <ffmpeg/avi.h>
#endif
-
#include <gst/gst.h>
#include "gstffmpeg.h"
GstPadTemplate *audiosrctempl;
};
-static GHashTable *global_plugins;
-
-/* A number of functon prototypes are given so we can refer to them later. */
+/* A number of function prototypes are given so we can refer to them later. */
static void gst_ffmpegdemux_class_init (GstFFMpegDemuxClass * klass);
static void gst_ffmpegdemux_base_init (GstFFMpegDemuxClass * klass);
static void gst_ffmpegdemux_init (GstFFMpegDemux * demux);
static GstStateChangeReturn
gst_ffmpegdemux_change_state (GstElement * element, GstStateChange transition);
+#define GST_FFDEMUX_PARAMS_QDATA g_quark_from_static_string("ffdemux-params")
+
static GstElementClass *parent_class = NULL;
static const gchar *
static void
gst_ffmpegdemux_base_init (GstFFMpegDemuxClass * klass)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstFFMpegDemuxClassParams *params;
GstElementDetails details;
GstPadTemplate *sinktempl, *audiosrctempl, *videosrctempl;
- params = g_hash_table_lookup (global_plugins,
- GINT_TO_POINTER (G_OBJECT_CLASS_TYPE (gobject_class)));
- if (!params)
- params = g_hash_table_lookup (global_plugins, GINT_TO_POINTER (0));
- g_assert (params);
+ params =
+ (GstFFMpegDemuxClassParams *)
+ g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass), GST_FFDEMUX_PARAMS_QDATA);
+ g_assert (params != NULL);
/* construct the element details struct */
details.longname = g_strdup_printf ("FFMPEG %s demuxer",
/* and prepare to continue streaming */
if (flush) {
gint n;
+
/* send flush stop, peer will accept data and events again. We
* are not yet providing data as we still have the STREAM_LOCK. */
gst_ffmpegdemux_push_event (demux, gst_event_new_flush_stop ());
/* if a pad is in e.g. WRONG_STATE, we want to pause to unlock the STREAM_LOCK */
if ((ret != GST_FLOW_OK)
- && ((ret = gst_ffmpegdemux_aggregated_flow (demux)) != GST_FLOW_OK)) {
+ && ((ret = gst_ffmpegdemux_aggregated_flow (demux)) != GST_FLOW_OK)) {
GST_WARNING_OBJECT (demux, "stream_movi flow: %s / %s",
gst_flow_get_name (stream->last_flow), gst_flow_get_name (ret));
goto pause;
in_plugin = first_iformat;
- global_plugins = g_hash_table_new (NULL, NULL);
-
while (in_plugin) {
gchar *type_name, *typefind_name;
gchar *p, *name = NULL;
!strcmp (in_plugin->name, "ea") ||
!strcmp (in_plugin->name, "daud") ||
!strcmp (in_plugin->name, "avs") ||
- !strcmp (in_plugin->name, "aiff") ||
- !strcmp (in_plugin->name, "4xm") ||
- !strcmp(in_plugin->name, "yuv4mpegpipe"))
+ !strcmp (in_plugin->name, "aiff") ||
+ !strcmp (in_plugin->name, "4xm") ||
+ !strcmp (in_plugin->name, "yuv4mpegpipe"))
rank = GST_RANK_MARGINAL;
else
rank = GST_RANK_NONE;
params->videosrccaps = videosrccaps;
params->audiosrccaps = audiosrccaps;
- g_hash_table_insert (global_plugins,
- GINT_TO_POINTER (0), (gpointer) params);
-
/* create the type now */
type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
-
- g_hash_table_insert (global_plugins,
- GINT_TO_POINTER (type), (gpointer) params);
+ g_type_set_qdata (type, GST_FFDEMUX_PARAMS_QDATA, (gpointer) params);
if (in_plugin->extensions)
extensions = g_strsplit (in_plugin->extensions, " ", 0);
g_free (name);
in_plugin = in_plugin->next;
}
- g_hash_table_remove (global_plugins, GINT_TO_POINTER (0));
return TRUE;
}
return ffmpegenc_me_method_type;
}
-static GHashTable *enc_global_plugins;
-
-/* A number of functon prototypes are given so we can refer to them later. */
+/* A number of function prototypes are given so we can refer to them later. */
static void gst_ffmpegenc_class_init (GstFFMpegEncClass * klass);
static void gst_ffmpegenc_base_init (GstFFMpegEncClass * klass);
static void gst_ffmpegenc_init (GstFFMpegEnc * ffmpegenc);
static GstStateChangeReturn gst_ffmpegenc_change_state (GstElement * element,
GstStateChange transition);
+#define GST_FFENC_PARAMS_QDATA g_quark_from_static_string("ffenc-params")
+
static GstElementClass *parent_class = NULL;
/*static guint gst_ffmpegenc_signals[LAST_SIGNAL] = { 0 }; */
static void
gst_ffmpegenc_base_init (GstFFMpegEncClass * klass)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstFFMpegEncClassParams *params;
GstElementDetails details;
GstPadTemplate *srctempl, *sinktempl;
- params = g_hash_table_lookup (enc_global_plugins,
- GINT_TO_POINTER (G_OBJECT_CLASS_TYPE (gobject_class)));
- /* HACK: if we don't have a GType yet, our params are stored at position 0 */
- if (!params) {
- params = g_hash_table_lookup (enc_global_plugins, GINT_TO_POINTER (0));
- }
- g_assert (params);
+ params =
+ (GstFFMpegEncClassParams *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
+ GST_FFENC_PARAMS_QDATA);
+ g_assert (params != NULL);
/* construct the element details struct */
details.longname = g_strdup_printf ("FFMPEG %s encoder",
in_plugin = first_avcodec;
- enc_global_plugins = g_hash_table_new (NULL, NULL);
-
/* build global ffmpeg param/property info */
gst_ffmpeg_cfg_init ();
params->srccaps = gst_caps_ref (srccaps);
params->sinkcaps = gst_caps_ref (sinkcaps);
- g_hash_table_insert (enc_global_plugins,
- GINT_TO_POINTER (0), (gpointer) params);
-
/* create the glib type now */
type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
+ g_type_set_qdata (type, GST_FFENC_PARAMS_QDATA, (gpointer) params);
+
if (!gst_element_register (plugin, type_name, GST_RANK_NONE, type)) {
g_free (type_name);
return FALSE;
g_free (type_name);
- g_hash_table_insert (enc_global_plugins,
- GINT_TO_POINTER (type), (gpointer) params);
-
next:
if (sinkcaps)
gst_caps_unref (sinkcaps);
gst_caps_unref (srccaps);
in_plugin = in_plugin->next;
}
- g_hash_table_remove (enc_global_plugins, GINT_TO_POINTER (0));
return TRUE;
}
/* FILL ME */
};
-static GHashTable *global_plugins;
-
-/* A number of functon prototypes are given so we can refer to them later. */
+/* A number of function prototypes are given so we can refer to them later. */
static void gst_ffmpegmux_class_init (GstFFMpegMuxClass * klass);
static void gst_ffmpegmux_base_init (gpointer g_class);
static void gst_ffmpegmux_init (GstFFMpegMux * ffmpegmux,
static GstStateChangeReturn gst_ffmpegmux_change_state (GstElement * element,
GstStateChange transition);
+#define GST_FFMUX_PARAMS_QDATA g_quark_from_static_string("ffmux-params")
+
static GstElementClass *parent_class = NULL;
/*static guint gst_ffmpegmux_signals[LAST_SIGNAL] = { 0 }; */
static void
gst_ffmpegmux_base_init (gpointer g_class)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
GstFFMpegMuxClass *klass = (GstFFMpegMuxClass *) g_class;
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
GstElementDetails details;
GstFFMpegMuxClassParams *params;
GstPadTemplate *videosinktempl, *audiosinktempl, *srctempl;
- params = g_hash_table_lookup (global_plugins,
- GINT_TO_POINTER (G_OBJECT_CLASS_TYPE (gobject_class)));
- if (!params)
- params = g_hash_table_lookup (global_plugins, GINT_TO_POINTER (0));
- g_assert (params);
+ params =
+ (GstFFMpegMuxClassParams *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
+ GST_FFMUX_PARAMS_QDATA);
+ g_assert (params != NULL);
/* construct the element details struct */
details.longname = g_strdup_printf ("FFMPEG %s Muxer",
in_plugin = first_oformat;
- global_plugins = g_hash_table_new (NULL, NULL);
-
while (in_plugin) {
gchar *type_name;
gchar *p;
params->videosinkcaps = videosinkcaps;
params->audiosinkcaps = audiosinkcaps;
- g_hash_table_insert (global_plugins,
- GINT_TO_POINTER (0), (gpointer) params);
-
/* create the type now */
type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
+ g_type_set_qdata (type, GST_FFMUX_PARAMS_QDATA, (gpointer) params);
g_type_add_interface_static (type, GST_TYPE_TAG_SETTER, &tag_setter_info);
+
if (!gst_element_register (plugin, type_name, GST_RANK_NONE, type)) {
g_free (type_name);
gst_caps_unref (srccaps);
g_free (type_name);
- g_hash_table_insert (global_plugins,
- GINT_TO_POINTER (type), (gpointer) params);
-
next:
in_plugin = in_plugin->next;
}
- g_hash_table_remove (global_plugins, GINT_TO_POINTER (0));
return TRUE;
}