diff --git a/ext/jpeg/Makefile.am b/ext/jpeg/Makefile.am index fbc947f2de..eb813e4b65 100644 --- a/ext/jpeg/Makefile.am +++ b/ext/jpeg/Makefile.am @@ -3,12 +3,12 @@ plugin_LTLIBRARIES = libgstjpeg.la libgstjpeg_la_SOURCES = \ gstjpeg.c \ - gstjpegdec.c + gstjpegenc.c \ + gstjpegdec.c \ + gstsmokeenc.c \ + smokecodec.c -# gstjpegenc.c -# gstsmokeenc.c # gstsmokedec.c -# smokecodec.c libgstjpeg_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) libgstjpeg_la_LIBADD = $(JPEG_LIBS) diff --git a/ext/jpeg/gstjpeg.c b/ext/jpeg/gstjpeg.c index c6fa7a185a..d1ea276381 100644 --- a/ext/jpeg/gstjpeg.c +++ b/ext/jpeg/gstjpeg.c @@ -25,14 +25,13 @@ #include #include "gstjpegdec.h" - -#if 0 #include "gstjpegenc.h" #include "gstsmokeenc.h" +/* #include "gstsmokedec.h" -static GstStaticCaps smoke_caps = GST_STATIC_CAPS ("video/x-smoke"); +static GstStaticCaps smoke_caps = GST_STATIC_CAPS ("video/x-smoke"); #define SMOKE_CAPS (gst_static_caps_get(&smoke_caps)) static void smoke_type_find (GstTypeFind * tf, gpointer private) @@ -47,34 +46,32 @@ smoke_type_find (GstTypeFind * tf, gpointer private) gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, SMOKE_CAPS); } } -#endif +*/ static gboolean plugin_init (GstPlugin * plugin) { -#if 0 + if (!gst_element_register (plugin, "jpegenc", GST_RANK_NONE, GST_TYPE_JPEGENC)) return FALSE; -#endif if (!gst_element_register (plugin, "jpegdec", GST_RANK_PRIMARY, GST_TYPE_JPEG_DEC)) return FALSE; -#if 0 if (!gst_element_register (plugin, "smokeenc", GST_RANK_PRIMARY, GST_TYPE_SMOKEENC)) return FALSE; - +/* if (!gst_element_register (plugin, "smokedec", GST_RANK_PRIMARY, GST_TYPE_SMOKEDEC)) - return FALSE; + return FALSE; if (!gst_type_find_register (plugin, "video/x-smoke", GST_RANK_PRIMARY, smoke_type_find, NULL, SMOKE_CAPS, NULL)) return FALSE; -#endif +*/ return TRUE; } diff --git a/ext/jpeg/gstjpegenc.c b/ext/jpeg/gstjpegenc.c index a94ef627ce..9605349b1f 100644 --- a/ext/jpeg/gstjpegenc.c +++ b/ext/jpeg/gstjpegenc.c @@ -77,8 +77,8 @@ static void gst_jpegenc_class_init (GstJpegEnc * klass); static void gst_jpegenc_init (GstJpegEnc * jpegenc); static void gst_jpegenc_finalize (GObject * object); -static void gst_jpegenc_chain (GstPad * pad, GstData * _data); -static GstPadLinkReturn gst_jpegenc_link (GstPad * pad, const GstCaps * caps); +static GstFlowReturn gst_jpegenc_chain (GstPad * pad, GstBuffer * buf); +static gboolean gst_jpegenc_setcaps (GstPad * pad, GstCaps * caps); static GstCaps *gst_jpegenc_getcaps (GstPad * pad); static void gst_jpegenc_resync (GstJpegEnc * jpegenc); @@ -101,7 +101,7 @@ gst_jpegenc_get_type (void) if (!jpegenc_type) { static const GTypeInfo jpegenc_info = { sizeof (GstJpegEnc), - gst_jpegenc_base_init, + (GBaseInitFunc) gst_jpegenc_base_init, NULL, (GClassInitFunc) gst_jpegenc_class_init, NULL, @@ -162,6 +162,10 @@ gst_jpegenc_class_init (GstJpegEnc * klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstJpegEncClass, frame_encoded), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + gobject_class->set_property = gst_jpegenc_set_property; + gobject_class->get_property = gst_jpegenc_get_property; + + g_object_class_install_property (gobject_class, ARG_QUALITY, g_param_spec_int ("quality", "Quality", "Quality of encoding", 0, 100, JPEG_DEFAULT_QUALITY, G_PARAM_READWRITE)); @@ -172,8 +176,6 @@ gst_jpegenc_class_init (GstJpegEnc * klass) 0, 100, 0, G_PARAM_READWRITE)); #endif - gobject_class->set_property = gst_jpegenc_set_property; - gobject_class->get_property = gst_jpegenc_get_property; gstelement_class->change_state = gst_jpegenc_change_state; gobject_class->finalize = gst_jpegenc_finalize; @@ -210,14 +212,15 @@ gst_jpegenc_init (GstJpegEnc * jpegenc) (&gst_jpegenc_sink_pad_template), "sink"); gst_pad_set_chain_function (jpegenc->sinkpad, gst_jpegenc_chain); gst_pad_set_getcaps_function (jpegenc->sinkpad, gst_jpegenc_getcaps); - gst_pad_set_link_function (jpegenc->sinkpad, gst_jpegenc_link); + gst_pad_set_setcaps_function (jpegenc->sinkpad, gst_jpegenc_setcaps); gst_element_add_pad (GST_ELEMENT (jpegenc), jpegenc->sinkpad); jpegenc->srcpad = gst_pad_new_from_template (gst_static_pad_template_get (&gst_jpegenc_src_pad_template), "src"); gst_pad_set_getcaps_function (jpegenc->sinkpad, gst_jpegenc_getcaps); - gst_pad_set_link_function (jpegenc->sinkpad, gst_jpegenc_link); + /*gst_pad_set_setcaps_function (jpegenc->sinkpad, gst_jpegenc_setcaps); */ + gst_pad_use_fixed_caps (jpegenc->sinkpad); gst_element_add_pad (GST_ELEMENT (jpegenc), jpegenc->srcpad); /* reset the initial video state */ @@ -284,14 +287,14 @@ gst_jpegenc_getcaps (GstPad * pad) return caps; } -static GstPadLinkReturn -gst_jpegenc_link (GstPad * pad, const GstCaps * caps) +static gboolean +gst_jpegenc_setcaps (GstPad * pad, GstCaps * caps) { GstJpegEnc *jpegenc = GST_JPEGENC (gst_pad_get_parent (pad)); GstStructure *structure; - GstPadLinkReturn ret; GstCaps *othercaps; GstPad *otherpad; + gboolean ret; otherpad = (pad == jpegenc->srcpad) ? jpegenc->sinkpad : jpegenc->srcpad; @@ -306,8 +309,8 @@ gst_jpegenc_link (GstPad * pad, const GstCaps * caps) "height", G_TYPE_INT, jpegenc->height, "framerate", G_TYPE_DOUBLE, jpegenc->fps, NULL); - ret = gst_pad_try_set_caps (jpegenc->srcpad, othercaps); - gst_caps_free (othercaps); + ret = gst_pad_set_caps (jpegenc->srcpad, othercaps); + gst_caps_unref (othercaps); if (GST_PAD_LINK_SUCCESSFUL (ret)) { gst_jpegenc_resync (jpegenc); @@ -383,10 +386,9 @@ gst_jpegenc_resync (GstJpegEnc * jpegenc) GST_DEBUG ("gst_jpegenc_resync: resync done"); } -static void -gst_jpegenc_chain (GstPad * pad, GstData * _data) +static GstFlowReturn +gst_jpegenc_chain (GstPad * pad, GstBuffer * buf) { - GstBuffer *buf = GST_BUFFER (_data); GstJpegEnc *jpegenc; guchar *data, *outdata; gulong size, outsize; @@ -397,11 +399,6 @@ gst_jpegenc_chain (GstPad * pad, GstData * _data) guchar *base[3]; gint i, j, k; - g_return_if_fail (pad != NULL); - g_return_if_fail (GST_IS_PAD (pad)); - g_return_if_fail (buf != NULL); - /*g_return_if_fail(GST_IS_BUFFER(buf)); */ - /*usleep(10000); */ jpegenc = GST_JPEGENC (GST_OBJECT_PARENT (pad)); @@ -454,11 +451,13 @@ gst_jpegenc_chain (GstPad * pad, GstData * _data) GST_BUFFER_SIZE (outbuf) = (((outsize - jpegenc->jdest.free_in_buffer) + 3) & ~3); - gst_pad_push (jpegenc->srcpad, GST_DATA (outbuf)); + gst_pad_push (jpegenc->srcpad, outbuf); g_signal_emit (G_OBJECT (jpegenc), gst_jpegenc_signals[FRAME_ENCODED], 0); - gst_buffer_unref (buf); + /*gst_buffer_unref (buf); */ + + return GST_FLOW_OK; } static void diff --git a/ext/jpeg/gstsmokeenc.c b/ext/jpeg/gstsmokeenc.c index d56037b995..7ec7501020 100644 --- a/ext/jpeg/gstsmokeenc.c +++ b/ext/jpeg/gstsmokeenc.c @@ -64,8 +64,8 @@ static void gst_smokeenc_base_init (gpointer g_class); static void gst_smokeenc_class_init (GstSmokeEnc * klass); static void gst_smokeenc_init (GstSmokeEnc * smokeenc); -static void gst_smokeenc_chain (GstPad * pad, GstData * _data); -static GstPadLinkReturn gst_smokeenc_link (GstPad * pad, const GstCaps * caps); +static GstFlowReturn gst_smokeenc_chain (GstPad * pad, GstBuffer * buf); +static gboolean gst_smokeenc_setcaps (GstPad * pad, GstCaps * caps); static GstCaps *gst_smokeenc_getcaps (GstPad * pad); static void gst_smokeenc_resync (GstSmokeEnc * smokeenc); @@ -86,7 +86,7 @@ gst_smokeenc_get_type (void) if (!smokeenc_type) { static const GTypeInfo smokeenc_info = { sizeof (GstSmokeEncClass), - gst_smokeenc_base_init, + (GBaseInitFunc) gst_smokeenc_base_init, NULL, (GClassInitFunc) gst_smokeenc_class_init, NULL, @@ -142,6 +142,9 @@ gst_smokeenc_class_init (GstSmokeEnc * klass) parent_class = g_type_class_ref (GST_TYPE_ELEMENT); + gobject_class->set_property = gst_smokeenc_set_property; + gobject_class->get_property = gst_smokeenc_get_property; + g_object_class_install_property (gobject_class, ARG_MIN_QUALITY, g_param_spec_int ("qmin", "Qmin", "Minimum quality", 0, 100, SMOKEENC_DEFAULT_MIN_QUALITY, G_PARAM_READWRITE)); @@ -156,9 +159,6 @@ gst_smokeenc_class_init (GstSmokeEnc * klass) "Insert keyframe every N frames", 1, 100000, SMOKEENC_DEFAULT_KEYFRAME, G_PARAM_READWRITE)); - gobject_class->set_property = gst_smokeenc_set_property; - gobject_class->get_property = gst_smokeenc_get_property; - GST_DEBUG_CATEGORY_INIT (smokeenc_debug, "smokeenc", 0, "Smoke encoding element"); } @@ -172,14 +172,15 @@ gst_smokeenc_init (GstSmokeEnc * smokeenc) (&gst_smokeenc_sink_pad_template), "sink"); gst_pad_set_chain_function (smokeenc->sinkpad, gst_smokeenc_chain); gst_pad_set_getcaps_function (smokeenc->sinkpad, gst_smokeenc_getcaps); - gst_pad_set_link_function (smokeenc->sinkpad, gst_smokeenc_link); + gst_pad_set_setcaps_function (smokeenc->sinkpad, gst_smokeenc_setcaps); gst_element_add_pad (GST_ELEMENT (smokeenc), smokeenc->sinkpad); smokeenc->srcpad = gst_pad_new_from_template (gst_static_pad_template_get (&gst_smokeenc_src_pad_template), "src"); gst_pad_set_getcaps_function (smokeenc->sinkpad, gst_smokeenc_getcaps); - gst_pad_set_link_function (smokeenc->sinkpad, gst_smokeenc_link); + gst_pad_use_fixed_caps (smokeenc->sinkpad); + /*gst_pad_set_link_function (smokeenc->sinkpad, gst_smokeenc_link); */ gst_element_add_pad (GST_ELEMENT (smokeenc), smokeenc->srcpad); /* reset the initial video state */ @@ -230,12 +231,12 @@ gst_smokeenc_getcaps (GstPad * pad) return caps; } -static GstPadLinkReturn -gst_smokeenc_link (GstPad * pad, const GstCaps * caps) +static gboolean +gst_smokeenc_setcaps (GstPad * pad, GstCaps * caps) { GstSmokeEnc *smokeenc = GST_SMOKEENC (gst_pad_get_parent (pad)); GstStructure *structure; - GstPadLinkReturn ret; + gboolean ret = TRUE; GstCaps *othercaps; GstPad *otherpad; @@ -252,8 +253,8 @@ gst_smokeenc_link (GstPad * pad, const GstCaps * caps) "height", G_TYPE_INT, smokeenc->height, "framerate", G_TYPE_DOUBLE, smokeenc->fps, NULL); - ret = gst_pad_try_set_caps (smokeenc->srcpad, othercaps); - gst_caps_free (othercaps); + ret = gst_pad_set_caps (smokeenc->srcpad, othercaps); + gst_caps_unref (othercaps); if (GST_PAD_LINK_SUCCESSFUL (ret)) { gst_smokeenc_resync (smokeenc); @@ -286,10 +287,9 @@ gst_smokeenc_resync (GstSmokeEnc * smokeenc) GST_DEBUG ("gst_smokeenc_resync: resync done"); } -static void -gst_smokeenc_chain (GstPad * pad, GstData * _data) +static GstFlowReturn +gst_smokeenc_chain (GstPad * pad, GstBuffer * buf) { - GstBuffer *buf = GST_BUFFER (_data); GstSmokeEnc *smokeenc; guchar *data, *outdata; gulong size; @@ -316,7 +316,7 @@ gst_smokeenc_chain (GstPad * pad, GstData * _data) GST_BUFFER_SIZE (outbuf) = encsize; - gst_pad_push (smokeenc->srcpad, GST_DATA (outbuf)); + gst_pad_push (smokeenc->srcpad, outbuf); smokeenc->need_header = FALSE; } @@ -336,15 +336,17 @@ gst_smokeenc_chain (GstPad * pad, GstData * _data) smokeenc->max_quality); smokecodec_set_threshold (smokeenc->info, smokeenc->threshold); smokecodec_encode (smokeenc->info, data, flags, outdata, &encsize); - gst_buffer_unref (buf); + /*gst_buffer_unref (buf); */ GST_BUFFER_SIZE (outbuf) = encsize; GST_BUFFER_OFFSET (outbuf) = smokeenc->frame; GST_BUFFER_OFFSET_END (outbuf) = smokeenc->frame + 1; - gst_pad_push (smokeenc->srcpad, GST_DATA (outbuf)); + gst_pad_push (smokeenc->srcpad, outbuf); smokeenc->frame++; + + return GST_FLOW_OK; } static void