ext/libmng/: Somewhat port mngenc and mngdec to 0.10. Does not work yet and has many bits ifdeffed out still.

Original commit message from CVS:
* ext/libmng/Makefile.am:
* ext/libmng/gstmng.c: (plugin_init):
* ext/libmng/gstmngdec.c: (gst_mng_dec_base_init),
(gst_mng_dec_class_init), (gst_mng_dec_sink_setcaps),
(gst_mng_dec_init), (gst_mng_dec_src_getcaps), (gst_mng_dec_loop),
(gst_mng_dec_get_property), (gst_mng_dec_set_property),
(mngdec_error), (mngdec_openstream), (mngdec_closestream),
(gst_mng_dec_sink_event), (mngdec_readdata), (mngdec_settimer),
(mngdec_processheader), (mngdec_getcanvasline), (mngdec_refresh),
(gst_mng_dec_change_state):
* ext/libmng/gstmngdec.h:
* ext/libmng/gstmngenc.c: (gst_mng_enc_base_init),
(gst_mng_enc_class_init), (gst_mng_enc_sink_setcaps),
(gst_mng_enc_init), (gst_mng_enc_chain),
(gst_mng_enc_get_property), (gst_mng_enc_set_property):
* ext/libmng/gstmngenc.h:
Somewhat port mngenc and mngdec to 0.10. Does not work yet and has many
bits ifdeffed out still.
This commit is contained in:
Wim Taymans 2008-06-17 10:05:55 +00:00
parent a5f813b90a
commit 51eb9bea8f
7 changed files with 164 additions and 251 deletions

View file

@ -1,3 +1,24 @@
2008-06-17 Wim Taymans <wim.taymans@collabora.co.uk>
* ext/libmng/Makefile.am:
* ext/libmng/gstmng.c: (plugin_init):
* ext/libmng/gstmngdec.c: (gst_mng_dec_base_init),
(gst_mng_dec_class_init), (gst_mng_dec_sink_setcaps),
(gst_mng_dec_init), (gst_mng_dec_src_getcaps), (gst_mng_dec_loop),
(gst_mng_dec_get_property), (gst_mng_dec_set_property),
(mngdec_error), (mngdec_openstream), (mngdec_closestream),
(gst_mng_dec_sink_event), (mngdec_readdata), (mngdec_settimer),
(mngdec_processheader), (mngdec_getcanvasline), (mngdec_refresh),
(gst_mng_dec_change_state):
* ext/libmng/gstmngdec.h:
* ext/libmng/gstmngenc.c: (gst_mng_enc_base_init),
(gst_mng_enc_class_init), (gst_mng_enc_sink_setcaps),
(gst_mng_enc_init), (gst_mng_enc_chain),
(gst_mng_enc_get_property), (gst_mng_enc_set_property):
* ext/libmng/gstmngenc.h:
Somewhat port mngenc and mngdec to 0.10. Does not work yet and has many
bits ifdeffed out still.
2008-06-16 Sebastian Dröge <slomo@circular-chaos.org>
* gst/matroska/matroska-demux.c: (gst_matroska_index_compare):

View file

@ -1,7 +1,7 @@
plugin_LTLIBRARIES = libgstmng.la
libgstmng_la_SOURCES = gstmng.c gstmngdec.c gstmngenc.c
libgstmng_la_CFLAGS = $(GST_CFLAGS)
libgstmng_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
libgstmng_la_LIBADD = $(GST_LIBS) $(LIBMNG_LIBS)
libgstmng_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)

View file

@ -26,14 +26,11 @@
static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_library_load ("gstbytestream"))
return FALSE;
if (!gst_element_register (plugin, "mngdec", GST_RANK_PRIMARY,
GST_TYPE_MNGDEC))
GST_TYPE_MNG_DEC))
return FALSE;
if (!gst_element_register (plugin, "mngenc", GST_RANK_NONE, GST_TYPE_MNGENC))
if (!gst_element_register (plugin, "mngenc", GST_RANK_NONE, GST_TYPE_MNG_ENC))
return FALSE;
return TRUE;

View file

@ -21,13 +21,12 @@
#include "gstmngdec.h"
#include <gst/video/video.h>
static const GstElementDetails gst_mngdec_details =
static const GstElementDetails gst_mng_dec_details =
GST_ELEMENT_DETAILS ("MNG video decoder",
"Codec/Decoder/Video",
"Decode a mng video to raw images",
"Wim Taymans <wim@fluendo.com>");
/* Filter signals and args */
enum
{
@ -37,60 +36,17 @@ enum
enum
{
ARG_0
PROP_0
};
static void gst_mngdec_base_init (gpointer g_class);
static void gst_mngdec_class_init (GstMngDecClass * klass);
static void gst_mngdec_init (GstMngDec * mngdec);
static void gst_mngdec_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec);
static void gst_mngdec_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec);
static GstStateChangeReturn gst_mngdec_change_state (GstElement * element,
GstStateChange transition);
static void gst_mngdec_loop (GstElement * element);
static GstCaps *gst_mngdec_src_getcaps (GstPad * pad);
static GstElementClass *parent_class = NULL;
GType
gst_mngdec_get_type (void)
{
static GType mngdec_type = 0;
if (!mngdec_type) {
static const GTypeInfo mngdec_info = {
sizeof (GstMngDecClass),
gst_mngdec_base_init,
NULL,
(GClassInitFunc) gst_mngdec_class_init,
NULL,
NULL,
sizeof (GstMngDec),
0,
(GInstanceInitFunc) gst_mngdec_init,
};
mngdec_type = g_type_register_static (GST_TYPE_ELEMENT, "GstMngDec",
&mngdec_info, 0);
}
return mngdec_type;
}
static GstStaticPadTemplate gst_mngdec_src_pad_template =
static GstStaticPadTemplate gst_mng_dec_src_pad_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBA ";" GST_VIDEO_CAPS_RGB)
);
static GstStaticPadTemplate gst_mngdec_sink_pad_template =
static GstStaticPadTemplate gst_mng_dec_sink_pad_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
@ -99,20 +55,32 @@ GST_STATIC_PAD_TEMPLATE ("sink",
"height = (int) [ 16, 4096 ], " "framerate = (double) [ 0.0, MAX ]")
);
static void gst_mng_dec_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec);
static void gst_mng_dec_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec);
static GstStateChangeReturn gst_mng_dec_change_state (GstElement * element,
GstStateChange transition);
static gboolean gst_mng_dec_sink_event (GstPad * pad, GstEvent * event);
GST_BOILERPLATE (GstMngDec, gst_mng_dec, GstElement, GST_TYPE_ELEMENT);
static void
gst_mngdec_base_init (gpointer g_class)
gst_mng_dec_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_mngdec_src_pad_template));
gst_static_pad_template_get (&gst_mng_dec_src_pad_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_mngdec_sink_pad_template));
gst_element_class_set_details (element_class, &gst_mngdec_details);
gst_static_pad_template_get (&gst_mng_dec_sink_pad_template));
gst_element_class_set_details (element_class, &gst_mng_dec_details);
}
static void
gst_mngdec_class_init (GstMngDecClass * klass)
gst_mng_dec_class_init (GstMngDecClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
@ -120,45 +88,42 @@ gst_mngdec_class_init (GstMngDecClass * klass)
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_peek_parent (klass);
gstelement_class->change_state = gst_mngdec_change_state;
gstelement_class->get_property = gst_mngdec_get_property;
gstelement_class->set_property = gst_mngdec_set_property;
gobject_class->get_property = gst_mng_dec_get_property;
gobject_class->set_property = gst_mng_dec_set_property;
gstelement_class->change_state = gst_mng_dec_change_state;
}
static GstPadLinkReturn
gst_mngdec_sinklink (GstPad * pad, const GstCaps * caps)
static gboolean
gst_mng_dec_sink_setcaps (GstPad * pad, GstCaps * caps)
{
GstMngDec *mngdec;
GstStructure *structure;
mngdec = GST_MNGDEC (gst_pad_get_parent (pad));
mngdec = GST_MNG_DEC (gst_pad_get_parent (pad));
structure = gst_caps_get_structure (caps, 0);
gst_structure_get_double (structure, "framerate", &mngdec->fps);
gst_object_unref (mngdec);
return TRUE;
}
static void
gst_mngdec_init (GstMngDec * mngdec)
gst_mng_dec_init (GstMngDec * mngdec, GstMngDecClass * gclass)
{
mngdec->sinkpad =
gst_pad_new_from_static_template (&gst_mngdec_sink_pad_template, "sink");
gst_pad_new_from_static_template (&gst_mng_dec_sink_pad_template, "sink");
gst_element_add_pad (GST_ELEMENT (mngdec), mngdec->sinkpad);
mngdec->srcpad =
gst_pad_new_from_static_template (&gst_mngdec_src_pad_template, "src");
gst_pad_new_from_static_template (&gst_mng_dec_src_pad_template, "src");
gst_element_add_pad (GST_ELEMENT (mngdec), mngdec->srcpad);
gst_pad_set_link_function (mngdec->sinkpad, gst_mngdec_sinklink);
gst_pad_set_getcaps_function (mngdec->srcpad, gst_mngdec_src_getcaps);
gst_pad_set_setcaps_function (mngdec->sinkpad, gst_mng_dec_sink_setcaps);
gst_pad_set_event_function (mngdec->sinkpad, gst_mng_dec_sink_event);
//gst_pad_set_getcaps_function (mngdec->srcpad, gst_mng_dec_src_getcaps);
mngdec->mng = NULL;
mngdec->buffer_out = NULL;
@ -167,12 +132,11 @@ gst_mngdec_init (GstMngDec * mngdec)
mngdec->width = -1;
mngdec->height = -1;
mngdec->fps = -1;
gst_element_set_loop_function (GST_ELEMENT (mngdec), gst_mngdec_loop);
}
#if 0
static GstCaps *
gst_mngdec_src_getcaps (GstPad * pad)
gst_mng_dec_src_getcaps (GstPad * pad)
{
GstMngDec *mngdec;
GstCaps *caps;
@ -180,8 +144,8 @@ gst_mngdec_src_getcaps (GstPad * pad)
GstPadTemplate *templ;
GstCaps *inter;
mngdec = GST_MNGDEC (gst_pad_get_parent (pad));
templ = gst_static_pad_template_get (&gst_mngdec_src_pad_template);
mngdec = GST_MNG_DEC (gst_pad_get_parent (pad));
templ = gst_static_pad_template_get (&gst_mng_dec_src_pad_template);
caps = gst_caps_copy (gst_pad_template_get_caps (templ));
if (mngdec->color_type != -1) {
@ -232,15 +196,16 @@ gst_mngdec_src_getcaps (GstPad * pad)
return caps;
}
#endif
#if 0
static void
gst_mngdec_loop (GstElement * element)
gst_mng_dec_loop (GstElement * element)
{
GstMngDec *mngdec;
mng_retcode ret;
mngdec = GST_MNGDEC (element);
mngdec = GST_MNG_DEC (element);
if (mngdec->first) {
GST_DEBUG ("display");
@ -254,18 +219,18 @@ gst_mngdec_loop (GstElement * element)
/* libmng needs more data later on */
} else {
/* assume EOS here */
gst_pad_push (mngdec->srcpad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
gst_element_set_eos (element);
gst_pad_push_event (mngdec->srcpad, (gst_event_new_eos ()));
}
}
#endif
static void
gst_mngdec_get_property (GObject * object,
gst_mng_dec_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec)
{
GstMngDec *mngdec;
mngdec = GST_MNGDEC (object);
mngdec = GST_MNG_DEC (object);
switch (prop_id) {
default:
@ -276,12 +241,12 @@ gst_mngdec_get_property (GObject * object,
static void
gst_mngdec_set_property (GObject * object,
gst_mng_dec_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstMngDec *mngdec;
mngdec = GST_MNGDEC (object);
mngdec = GST_MNG_DEC (object);
switch (prop_id) {
default:
@ -297,7 +262,7 @@ mngdec_error (mng_handle mng, mng_int32 code, mng_int8 severity,
{
GstMngDec *mngdec;
mngdec = GST_MNGDEC (mng_get_userdata (mng));
mngdec = GST_MNG_DEC (mng_get_userdata (mng));
GST_ERROR_OBJECT (mngdec, "error in chunk %4.4s (%d): %s",
(gchar *) & chunktype, chunkseq, text);
@ -310,9 +275,7 @@ mngdec_openstream (mng_handle mng)
{
GstMngDec *mngdec;
mngdec = GST_MNGDEC (mng_get_userdata (mng));
mngdec->bs = gst_bytestream_new (mngdec->sinkpad);
mngdec = GST_MNG_DEC (mng_get_userdata (mng));
return MNG_TRUE;
}
@ -322,41 +285,37 @@ mngdec_closestream (mng_handle mng)
{
GstMngDec *mngdec;
mngdec = GST_MNGDEC (mng_get_userdata (mng));
gst_bytestream_destroy (mngdec->bs);
mngdec = GST_MNG_DEC (mng_get_userdata (mng));
return MNG_TRUE;
}
static gboolean
mngdec_handle_sink_event (GstMngDec * mngdec)
gst_mng_dec_sink_event (GstPad * pad, GstEvent * event)
{
guint32 remaining;
GstEvent *event;
GstEventType type;
GstMngDec *mngdec;
gst_bytestream_get_status (mngdec->bs, &remaining, &event);
mngdec = GST_MNG_DEC_CAST (gst_pad_get_parent (pad));
type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN;
GST_DEBUG ("mngdec: event %p %d", event, type);
type = GST_EVENT_TYPE (event);
GST_DEBUG_OBJECT (mngdec, "mngdec: event %p %d", event, type);
switch (type) {
case GST_EVENT_EOS:
gst_bytestream_flush (mngdec->bs, remaining);
gst_pad_event_default (mngdec->sinkpad, event);
return FALSE;
case GST_EVENT_FLUSH:
break;
case GST_EVENT_DISCONTINUOUS:
GST_DEBUG ("discontinuous event");
case GST_EVENT_FLUSH_START:
break;
case GST_EVENT_FLUSH_STOP:
break;
case GST_EVENT_NEWSEGMENT:
break;
default:
g_warning ("unhandled event %d", type);
break;
}
gst_event_unref (event);
return TRUE;
}
@ -365,13 +324,16 @@ mngdec_readdata (mng_handle mng, mng_ptr buffer,
mng_uint32 size, mng_uint32 * bytesread)
{
GstMngDec *mngdec;
#if 0
guint8 *bytes;
guint32 read;
#endif
mngdec = GST_MNGDEC (mng_get_userdata (mng));
mngdec = GST_MNG_DEC (mng_get_userdata (mng));
GST_DEBUG ("read data %d", size);
#if 0
do {
read = gst_bytestream_peek_bytes (mngdec->bs, &bytes, size);
if (read != size) {
@ -388,6 +350,7 @@ mngdec_readdata (mng_handle mng, mng_ptr buffer,
memcpy (buffer, bytes, size);
gst_bytestream_flush_fast (mngdec->bs, read);
*bytesread = size;
#endif
return MNG_TRUE;
}
@ -411,7 +374,7 @@ mngdec_settimer (mng_handle mng, mng_uint32 msecs)
{
GstMngDec *mngdec;
mngdec = GST_MNGDEC (mng_get_userdata (mng));
mngdec = GST_MNG_DEC (mng_get_userdata (mng));
//mymng->delay = msecs;
GST_DEBUG ("set timer %d", msecs);
@ -426,7 +389,7 @@ mngdec_processheader (mng_handle mng, mng_uint32 width, mng_uint32 height)
guint32 framecount;
guint32 ticks;
mngdec = GST_MNGDEC (mng_get_userdata (mng));
mngdec = GST_MNG_DEC (mng_get_userdata (mng));
GST_DEBUG ("process header %d %d", width, height);
@ -445,10 +408,12 @@ mngdec_processheader (mng_handle mng, mng_uint32 width, mng_uint32 height)
mngdec->stride = ((width + 3) & ~3) * 4;
mngdec->height = height;
#if 0
if (GST_PAD_LINK_FAILED (gst_pad_renegotiate (mngdec->srcpad))) {
GST_ELEMENT_ERROR (mngdec, CORE, NEGOTIATION, (NULL), (NULL));
return MNG_FALSE;
}
#endif
mngdec->buffer_out =
gst_buffer_new_and_alloc (mngdec->height * mngdec->stride);
@ -461,7 +426,7 @@ mngdec_getcanvasline (mng_handle mng, mng_uint32 line)
{
GstMngDec *mngdec;
mngdec = GST_MNGDEC (mng_get_userdata (mng));
mngdec = GST_MNG_DEC (mng_get_userdata (mng));
GST_DEBUG ("get canvas line %d", line);
@ -476,7 +441,7 @@ mngdec_refresh (mng_handle mng, mng_uint32 x, mng_uint32 y,
GstMngDec *mngdec;
guint32 current;
mngdec = GST_MNGDEC (mng_get_userdata (mng));
mngdec = GST_MNG_DEC (mng_get_userdata (mng));
current = mng_get_currentplaytime (mng);
@ -484,16 +449,17 @@ mngdec_refresh (mng_handle mng, mng_uint32 x, mng_uint32 y,
if (h == mngdec->height) {
GstBuffer *out = gst_buffer_copy (mngdec->buffer_out);
gst_pad_push (mngdec->srcpad, GST_DATA (out));
gst_pad_push (mngdec->srcpad, out);
}
return MNG_TRUE;
}
static GstStateChangeReturn
gst_mngdec_change_state (GstElement * element, GstStateChange transition)
gst_mng_dec_change_state (GstElement * element, GstStateChange transition)
{
GstMngDec *mngdec = GST_MNGDEC (element);
GstStateChangeReturn ret;
GstMngDec *mngdec = GST_MNG_DEC (element);
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
@ -523,6 +489,13 @@ gst_mngdec_change_state (GstElement * element, GstStateChange transition)
break;
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
break;
default:
break;
}
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
switch (transition) {
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
@ -533,9 +506,5 @@ gst_mngdec_change_state (GstElement * element, GstStateChange transition)
default:
break;
}
if (GST_ELEMENT_CLASS (parent_class)->change_state)
return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
return GST_STATE_CHANGE_SUCCESS;
return ret;
}

View file

@ -18,23 +18,20 @@
*/
#ifndef __GST_MNGDEC_H__
#define __GST_MNGDEC_H__
#ifndef __GST_MNG_DEC_H__
#define __GST_MNG_DEC_H__
#include <gst/gst.h>
#include <gst/bytestream/bytestream.h>
#include <libmng.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
G_BEGIN_DECLS
#define GST_TYPE_MNGDEC (gst_mngdec_get_type())
#define GST_MNGDEC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MNGDEC,GstMngDec))
#define GST_MNGDEC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MNGDEC,GstMngDecClass))
#define GST_IS_MNGDEC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MNGDEC))
#define GST_IS_MNGDEC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MNGDEC))
#define GST_TYPE_MNG_DEC (gst_mng_dec_get_type())
#define GST_MNG_DEC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MNG_DEC,GstMngDec))
#define GST_MNG_DEC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MNG_DEC,GstMngDecClass))
#define GST_IS_MNG_DEC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MNG_DEC))
#define GST_IS_MNG_DEC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MNG_DEC))
#define GST_MNG_DEC_CAST(obj) ((GstMngDec *) (obj))
typedef struct _GstMngDec GstMngDec;
typedef struct _GstMngDecClass GstMngDecClass;
@ -46,7 +43,6 @@ struct _GstMngDec
GstPad *sinkpad, *srcpad;
GstBuffer *buffer_out;
GstByteStream *bs;
mng_handle mng;
gboolean first;
@ -64,12 +60,8 @@ struct _GstMngDecClass
GstElementClass parent_class;
};
GType gst_mngdec_get_type(void);
GType gst_mng_dec_get_type(void);
G_END_DECLS
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GST_MNGDEC_H__ */
#endif /* __GST_MNG_DEC_H__ */

View file

@ -26,8 +26,7 @@
#define MAX_HEIGHT 4096
static const GstElementDetails gst_mngenc_details =
static const GstElementDetails gst_mng_enc_details =
GST_ELEMENT_DETAILS ("MNG video encoder",
"Codec/Encoder/Video",
"Encode a video frame to an .mng video",
@ -45,49 +44,19 @@ enum
enum
{
ARG_0,
ARG_SNAPSHOT,
ARG_NEWMEDIA
ARG_0
};
static void gst_mngenc_base_init (gpointer g_class);
static void gst_mngenc_class_init (GstMngEncClass * klass);
static void gst_mngenc_init (GstMngEnc * mngenc);
static void gst_mngenc_set_property (GObject * object,
static void gst_mng_enc_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec);
static void gst_mngenc_get_property (GObject * object,
static void gst_mng_enc_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec);
static void gst_mngenc_chain (GstPad * pad, GstData * _data);
static GstFlowReturn gst_mng_enc_chain (GstPad * pad, GstBuffer * buf);
GstPadTemplate *mngenc_src_template, *mngenc_sink_template;
static GstElementClass *parent_class = NULL;
GType
gst_mngenc_get_type (void)
{
static GType mngenc_type = 0;
if (!mngenc_type) {
static const GTypeInfo mngenc_info = {
sizeof (GstMngEncClass),
gst_mngenc_base_init,
NULL,
(GClassInitFunc) gst_mngenc_class_init,
NULL,
NULL,
sizeof (GstMngEnc),
0,
(GInstanceInitFunc) gst_mngenc_init,
};
mngenc_type = g_type_register_static (GST_TYPE_ELEMENT, "GstMngEnc",
&mngenc_info, 0);
}
return mngenc_type;
}
GST_BOILERPLATE (GstMngEnc, gst_mng_enc, GstElement, GST_TYPE_ELEMENT);
static GstCaps *
mng_caps_factory (void)
@ -106,7 +75,7 @@ raw_caps_factory (void)
}
static void
gst_mngenc_base_init (gpointer g_class)
gst_mng_enc_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
GstCaps *raw_caps, *mng_caps;
@ -122,11 +91,11 @@ gst_mngenc_base_init (gpointer g_class)
gst_element_class_add_pad_template (element_class, mngenc_sink_template);
gst_element_class_add_pad_template (element_class, mngenc_src_template);
gst_element_class_set_details (element_class, &gst_mngenc_details);
gst_element_class_set_details (element_class, &gst_mng_enc_details);
}
static void
gst_mngenc_class_init (GstMngEncClass * klass)
gst_mng_enc_class_init (GstMngEncClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
@ -134,32 +103,18 @@ gst_mngenc_class_init (GstMngEncClass * klass)
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_peek_parent (klass);
g_object_class_install_property (gobject_class, ARG_SNAPSHOT,
g_param_spec_boolean ("snapshot", "Snapshot",
"Send EOS after encoding a frame, useful for snapshots",
DEFAULT_SNAPSHOT, (GParamFlags) G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_NEWMEDIA,
g_param_spec_boolean ("newmedia", "newmedia",
"Send new media discontinuity after encoding each frame",
FALSE, (GParamFlags) G_PARAM_READWRITE));
gstelement_class->get_property = gst_mngenc_get_property;
gstelement_class->set_property = gst_mngenc_set_property;
gobject_class->get_property = gst_mng_enc_get_property;
gobject_class->set_property = gst_mng_enc_set_property;
}
static GstPadLinkReturn
gst_mngenc_sinklink (GstPad * pad, const GstCaps * caps)
static gboolean
gst_mng_enc_sink_setcaps (GstPad * pad, GstCaps * caps)
{
GstMngEnc *mngenc;
gdouble fps;
GstStructure *structure;
GstPadLinkReturn result;
mngenc = GST_MNGENC (gst_pad_get_parent (pad));
mngenc = GST_MNG_ENC (gst_pad_get_parent (pad));
structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "width", &mngenc->width);
@ -172,14 +127,16 @@ gst_mngenc_sinklink (GstPad * pad, const GstCaps * caps)
"width", G_TYPE_INT, mngenc->width,
"height", G_TYPE_INT, mngenc->height, NULL);
result = gst_pad_try_set_caps (mngenc->srcpad, caps);
gst_pad_set_caps (mngenc->srcpad, caps);
gst_caps_unref (caps);
gst_object_unref (mngenc);
return result;
return TRUE;
}
static void
gst_mngenc_init (GstMngEnc * mngenc)
gst_mng_enc_init (GstMngEnc * mngenc, GstMngEncClass * gclass)
{
mngenc->sinkpad = gst_pad_new_from_template (mngenc_sink_template, "sink");
gst_element_add_pad (GST_ELEMENT (mngenc), mngenc->sinkpad);
@ -187,43 +144,35 @@ gst_mngenc_init (GstMngEnc * mngenc)
mngenc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_element_add_pad (GST_ELEMENT (mngenc), mngenc->srcpad);
gst_pad_set_chain_function (mngenc->sinkpad, gst_mngenc_chain);
gst_pad_set_link_function (mngenc->sinkpad, gst_mngenc_sinklink);
mngenc->snapshot = DEFAULT_SNAPSHOT;
mngenc->newmedia = FALSE;
gst_pad_set_chain_function (mngenc->sinkpad, gst_mng_enc_chain);
gst_pad_set_setcaps_function (mngenc->sinkpad, gst_mng_enc_sink_setcaps);
}
static void
gst_mngenc_chain (GstPad * pad, GstData * _data)
static GstFlowReturn
gst_mng_enc_chain (GstPad * pad, GstBuffer * buf)
{
GstBuffer *buf = GST_BUFFER (_data);
GstMngEnc *mngenc;
mngenc = GST_MNGENC (gst_pad_get_parent (pad));
mngenc = GST_MNG_ENC (gst_pad_get_parent (pad));
/* FIXME, do something here */
gst_buffer_unref (buf);
gst_object_unref (mngenc);
return GST_FLOW_NOT_SUPPORTED;
}
static void
gst_mngenc_get_property (GObject * object,
gst_mng_enc_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec)
{
GstMngEnc *mngenc;
mngenc = GST_MNGENC (object);
mngenc = GST_MNG_ENC (object);
switch (prop_id) {
case ARG_SNAPSHOT:
g_value_set_boolean (value, mngenc->snapshot);
break;
case ARG_NEWMEDIA:
g_value_set_boolean (value, mngenc->newmedia);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -232,20 +181,14 @@ gst_mngenc_get_property (GObject * object,
static void
gst_mngenc_set_property (GObject * object,
gst_mng_enc_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstMngEnc *mngenc;
mngenc = GST_MNGENC (object);
mngenc = GST_MNG_ENC (object);
switch (prop_id) {
case ARG_SNAPSHOT:
mngenc->snapshot = g_value_get_boolean (value);
break;
case ARG_NEWMEDIA:
mngenc->newmedia = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;

View file

@ -18,22 +18,20 @@
*/
#ifndef __GST_MNGENC_H__
#define __GST_MNGENC_H__
#ifndef __GST_MNG_ENC_H__
#define __GST_MNG_ENC_H__
#include <gst/gst.h>
#include <libmng.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
G_BEGIN_DECLS
#define GST_TYPE_MNGENC (gst_mngenc_get_type())
#define GST_MNGENC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MNGENC,GstMngEnc))
#define GST_MNGENC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MNGENC,GstMngEncClass))
#define GST_IS_MNGENC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MNGENC))
#define GST_IS_MNGENC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MNGENC))
#define GST_TYPE_MNG_ENC (gst_mng_enc_get_type())
#define GST_MNG_ENC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MNG_ENC,GstMngEnc))
#define GST_MNG_ENC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MNG_ENC,GstMngEncClass))
#define GST_IS_MNG_ENC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MNG_ENC))
#define GST_IS_MNG_ENC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MNG_ENC))
#define GST_MNG_ENC_CAST(obj) (GstMngEnc *)(obj)
typedef struct _GstMngEnc GstMngEnc;
typedef struct _GstMngEncClass GstMngEncClass;
@ -52,9 +50,6 @@ struct _GstMngEnc
gint width;
gint height;
gint bpp;
gboolean snapshot;
gboolean newmedia;
};
struct _GstMngEncClass
@ -62,12 +57,8 @@ struct _GstMngEncClass
GstElementClass parent_class;
};
GType gst_mngenc_get_type(void);
GType gst_mng_enc_get_type(void);
G_END_DECLS
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GST_MNGENC_H__ */
#endif /* __GST_MNG_ENC_H__ */