static void gst_ffmpegmux_base_init (gpointer g_class) { GstFFMpegMuxClass *klass = (GstFFMpegMuxClass *) g_class; GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); GstElementDetails details; GstPadTemplate *videosinktempl, *audiosinktempl, *srctempl; AVOutputFormat *in_plugin; GstCaps *srccaps, *audiosinkcaps, *videosinkcaps; enum CodecID *video_ids = NULL, *audio_ids = NULL; in_plugin = (AVOutputFormat *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass), GST_FFMUX_PARAMS_QDATA); g_assert (in_plugin != NULL); /* construct the element details struct */ details.longname = g_strdup_printf ("FFmpeg %s muxer", in_plugin->long_name); details.klass = g_strdup ("Codec/Muxer"); details.description = g_strdup_printf ("FFmpeg %s muxer", in_plugin->long_name); details.author = "Wim Taymans <*****@*****.**>, " "Ronald Bultje <*****@*****.**>"; gst_element_class_set_details (element_class, &details); g_free (details.longname); g_free (details.klass); g_free (details.description); /* Try to find the caps that belongs here */ srccaps = gst_ffmpeg_formatid_to_caps (in_plugin->name); if (!srccaps) { GST_DEBUG ("Couldn't get source caps for muxer '%s', skipping format", in_plugin->name); goto beach; } if (!gst_ffmpeg_formatid_get_codecids (in_plugin->name, &video_ids, &audio_ids, in_plugin)) { gst_caps_unref (srccaps); GST_DEBUG ("Couldn't get sink caps for muxer '%s'. Most likely because no input format mapping exists.", in_plugin->name); goto beach; } videosinkcaps = video_ids ? gst_ffmpegmux_get_id_caps (video_ids) : NULL; audiosinkcaps = audio_ids ? gst_ffmpegmux_get_id_caps (audio_ids) : NULL; /* fix up allowed caps for some muxers */ /* FIXME : This should be in gstffmpegcodecmap.c ! */ if (strcmp (in_plugin->name, "flv") == 0) { const gint rates[] = { 44100, 22050, 11025 }; gst_ffmpeg_mux_simple_caps_set_int_list (audiosinkcaps, "rate", 3, rates); } else if (strcmp (in_plugin->name, "gif") == 0) { if (videosinkcaps) gst_caps_unref (videosinkcaps); videosinkcaps = gst_caps_from_string ("video/x-raw-rgb, bpp=(int)24, depth=(int)24"); } /* pad templates */ srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps); gst_element_class_add_pad_template (element_class, srctempl); if (audiosinkcaps) { audiosinktempl = gst_pad_template_new ("audio_%d", GST_PAD_SINK, GST_PAD_REQUEST, audiosinkcaps); gst_element_class_add_pad_template (element_class, audiosinktempl); } if (videosinkcaps) { videosinktempl = gst_pad_template_new ("video_%d", GST_PAD_SINK, GST_PAD_REQUEST, videosinkcaps); gst_element_class_add_pad_template (element_class, videosinktempl); } beach: klass->in_plugin = in_plugin; }
static void gst_ffmpegmux_base_init (gpointer g_class) { GstFFMpegMuxClass *klass = (GstFFMpegMuxClass *) g_class; GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); GstPadTemplate *videosinktempl, *audiosinktempl, *srctempl; AVOutputFormat *in_plugin; GstCaps *srccaps, *audiosinkcaps, *videosinkcaps; enum AVCodecID *video_ids = NULL, *audio_ids = NULL; gchar *longname, *description, *name; const char *replacement; gboolean is_formatter; in_plugin = (AVOutputFormat *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass), GST_FFMUX_PARAMS_QDATA); g_assert (in_plugin != NULL); name = g_strdup (in_plugin->name); g_strdelimit (name, ".,|-<> ", '_'); /* construct the element details struct */ replacement = gst_ffmpegmux_get_replacement (in_plugin->name); is_formatter = gst_ffmpegmux_is_formatter (in_plugin->name); if (replacement != NULL) { longname = g_strdup_printf ("libav %s %s (not recommended, use %s instead)", in_plugin->long_name, is_formatter ? "formatter" : "muxer", replacement); description = g_strdup_printf ("libav %s %s (not recommended, use %s instead)", in_plugin->long_name, is_formatter ? "formatter" : "muxer", replacement); } else { longname = g_strdup_printf ("libav %s %s", in_plugin->long_name, is_formatter ? "formatter" : "muxer"); description = g_strdup_printf ("libav %s %s", in_plugin->long_name, is_formatter ? "formatter" : "muxer"); } gst_element_class_set_metadata (element_class, longname, is_formatter ? "Formatter/Metadata" : "Codec/Muxer", description, "Wim Taymans <*****@*****.**>, " "Ronald Bultje <*****@*****.**>"); g_free (longname); g_free (description); /* Try to find the caps that belongs here */ srccaps = gst_ffmpeg_formatid_to_caps (name); if (!srccaps) { GST_DEBUG ("Couldn't get source caps for muxer '%s', skipping", name); goto beach; } if (!gst_ffmpeg_formatid_get_codecids (in_plugin->name, &video_ids, &audio_ids, in_plugin)) { gst_caps_unref (srccaps); GST_DEBUG ("Couldn't get sink caps for muxer '%s'. Most likely because " "no input format mapping exists.", name); goto beach; } videosinkcaps = video_ids ? gst_ffmpegmux_get_id_caps (video_ids) : NULL; audiosinkcaps = audio_ids ? gst_ffmpegmux_get_id_caps (audio_ids) : NULL; /* fix up allowed caps for some muxers */ /* FIXME : This should be in gstffmpegcodecmap.c ! */ if (strcmp (in_plugin->name, "flv") == 0) { const gint rates[] = { 44100, 22050, 11025 }; gst_ffmpeg_mux_simple_caps_set_int_list (audiosinkcaps, "rate", 3, rates); } else if (strcmp (in_plugin->name, "dv") == 0) { gst_caps_set_simple (audiosinkcaps, "rate", G_TYPE_INT, 48000, "channels", G_TYPE_INT, 2, NULL); } else if (strcmp (in_plugin->name, "gif") == 0) { if (videosinkcaps) gst_caps_unref (videosinkcaps); videosinkcaps = gst_caps_from_string ("video/x-raw, format=(string)RGB"); } /* pad templates */ srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps); gst_element_class_add_pad_template (element_class, srctempl); gst_caps_unref (srccaps); if (audiosinkcaps) { audiosinktempl = gst_pad_template_new ("audio_%u", GST_PAD_SINK, GST_PAD_REQUEST, audiosinkcaps); gst_element_class_add_pad_template (element_class, audiosinktempl); gst_caps_unref (audiosinkcaps); } if (videosinkcaps) { videosinktempl = gst_pad_template_new ("video_%u", GST_PAD_SINK, GST_PAD_REQUEST, videosinkcaps); gst_element_class_add_pad_template (element_class, videosinktempl); gst_caps_unref (videosinkcaps); } beach: klass->in_plugin = in_plugin; g_free (name); }