[gst-plugins-farsight/master] Remove mimic plugin, moved to -bad
Olivier Crête
olivier.crete at collabora.co.uk
Tue Mar 3 14:23:56 PST 2009
---
configure.ac | 13 --
ext/Makefile.am | 8 +-
ext/mimic/Makefile.am | 9 -
ext/mimic/gstmimdec.c | 412 -------------------------------------------------
ext/mimic/gstmimdec.h | 75 ---------
ext/mimic/gstmimenc.c | 332 ---------------------------------------
ext/mimic/gstmimenc.h | 70 ---------
ext/mimic/gstmimic.c | 53 -------
8 files changed, 1 insertions(+), 971 deletions(-)
delete mode 100644 ext/mimic/Makefile.am
delete mode 100644 ext/mimic/gstmimdec.c
delete mode 100644 ext/mimic/gstmimdec.h
delete mode 100644 ext/mimic/gstmimenc.c
delete mode 100644 ext/mimic/gstmimenc.h
delete mode 100644 ext/mimic/gstmimic.c
diff --git a/configure.ac b/configure.ac
index daaecfb..5e32b58 100644
--- a/configure.ac
+++ b/configure.ac
@@ -190,18 +190,6 @@ GST_CHECK_FEATURE(GCONF, [gconf library], gconf, [
])
AC_MSG_RESULT(Found libgconf... $HAVE_GCONF)
-dnl check for libmimic
-translit(dnm, m, l) AM_CONDITIONAL(USE_MIMIC, true)
-GST_CHECK_FEATURE(MIMIC, [libmimic library], mimic, [
- MIMDEC_REQUIRED=1.0
- PKG_CHECK_MODULES(MIMIC, \
- libmimic >= $MIMDEC_REQUIRED,
- HAVE_MIMIC=yes,HAVE_MIMIC=no)
- AC_SUBST(MIMIC_CFLAGS)
- AC_SUBST(MIMIC_LIBS)
- ])
-AC_MSG_RESULT(Found libmimic... $HAVE_MIMIC)
-
dnl Check for GSM
HAVE_GSM="no"
translit(dnm, m, l) AM_CONDITIONAL(USE_GSM, true)
@@ -330,7 +318,6 @@ AM_CONDITIONAL(USE_JINGLEP2P, test x$USE_JINGLEP2P = xyes)
AC_OUTPUT(Makefile \
ext/Makefile \
ext/jrtp/Makefile \
-ext/mimic/Makefile \
ext/gsm/Makefile \
ext/jpeg2000/Makefile \
ext/jasper/Makefile \
diff --git a/ext/Makefile.am b/ext/Makefile.am
index 4da8953..bbd239b 100644
--- a/ext/Makefile.am
+++ b/ext/Makefile.am
@@ -1,11 +1,5 @@
JRTP_DIR=jrtp
-if USE_MIMIC
-MIMIC_DIR=mimic
-else
-MIMIC_DIR=
-endif
-
if USE_GSM
GSM_DIR=gsm
else
@@ -45,4 +39,4 @@ $(JASPER_DIR) \
$(ICE_DIR) \
$(GSM_DIR)
-DIST_SUBDIRS = gsm ice jasper jpeg2000 jrtp gconf mimic
+DIST_SUBDIRS = gsm ice jasper jpeg2000 jrtp gconf
diff --git a/ext/mimic/Makefile.am b/ext/mimic/Makefile.am
deleted file mode 100644
index 30c557e..0000000
--- a/ext/mimic/Makefile.am
+++ /dev/null
@@ -1,9 +0,0 @@
-plugin_LTLIBRARIES = libgstmimic.la
-
-libgstmimic_la_SOURCES = gstmimic.c gstmimdec.c gstmimenc.c
-
-libgstmimic_la_CFLAGS = $(GST_CFLAGS) $(MIMIC_CFLAGS) $(GST_BASE_CFLAGS) $(ERROR_CFLAGS)
-libgstmimic_la_LIBADD = $(GST_LIBS) $(MIMIC_LIBS)
-libgstmimic_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) $(GST_BASE_LIBS)
-
-noinst_HEADERS = gstmimdec.h gstmimenc.h
diff --git a/ext/mimic/gstmimdec.c b/ext/mimic/gstmimdec.c
deleted file mode 100644
index cd1e78b..0000000
--- a/ext/mimic/gstmimdec.c
+++ /dev/null
@@ -1,412 +0,0 @@
-/*
- * GStreamer
- * Copyright (c) 2005 INdT.
- * @author Andre Moreira Magalhaes <andre.magalhaes at indt.org.br>
- * @author Rob Taylor <robtaylor at fastmail.fm>
- * @author Philippe Khalaf <burger at speedy.org>
- * @author Ole André Vadla Ravnås <oleavr at gmail.com>
- *
- * 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
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gst/gst.h>
-
-#include "gstmimdec.h"
-
-GST_DEBUG_CATEGORY (mimdec_debug);
-#define GST_CAT_DEFAULT (mimdec_debug)
-
-static GstStaticPadTemplate sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-mimic")
-);
-
-static GstStaticPadTemplate src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb, "
- "bpp = (int) 24, "
- "depth = (int) 24, "
- "endianness = (int) 4321, "
- "framerate = (fraction) [ 0/1, 30/1 ], "
- "red_mask = (int) 16711680, "
- "green_mask = (int) 65280, "
- "blue_mask = (int) 255, "
- "height = (int) [16, 4096], "
- "width = (int) [16, 4096]"
- )
-);
-
-static void gst_mimdec_finalize (GObject *object);
-
-static GstFlowReturn gst_mimdec_chain (GstPad *pad,
- GstBuffer *in);
-static GstStateChangeReturn
- gst_mimdec_change_state (GstElement *element,
- GstStateChange transition);
-
-static gboolean gst_mimdec_sink_event (GstPad *pad, GstEvent *event);
-
-
-GST_BOILERPLATE (GstMimDec, gst_mimdec, GstElement, GST_TYPE_ELEMENT);
-
-static void
-gst_mimdec_base_init (gpointer klass)
-{
- static GstElementDetails plugin_details = {
- "MimDec",
- "Codec/Decoder/Video",
- "Mimic decoder",
- "Andre Moreira Magalhaes <andre.magalhaes at indt.org.br>, "
- "Rob Taylor <robtaylor at fastmail.fm>, "
- "Philippe Khalaf <burger at speedy.org>, "
- "Ole André Vadla Ravnås <oleavr at gmail.com>"
- };
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&src_factory));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_factory));
-
- gst_element_class_set_details (element_class, &plugin_details);
-}
-
-static void
-gst_mimdec_class_init (GstMimDecClass *klass)
-{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
-
- gobject_class = (GObjectClass*) klass;
- gstelement_class = (GstElementClass*) klass;
- gstelement_class->change_state = gst_mimdec_change_state;
-
- gobject_class->finalize = gst_mimdec_finalize;
-
- GST_DEBUG_CATEGORY_INIT (mimdec_debug, "mimdec", 0, "Mimic decoder plugin");
-}
-
-static void
-gst_mimdec_init (GstMimDec *mimdec, GstMimDecClass *klass)
-{
- mimdec->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&sink_factory), "sink");
- gst_element_add_pad (GST_ELEMENT (mimdec), mimdec->sinkpad);
- gst_pad_set_chain_function (mimdec->sinkpad, gst_mimdec_chain);
- gst_pad_set_event_function (mimdec->sinkpad, gst_mimdec_sink_event);
-
- mimdec->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&src_factory), "src");
- gst_element_add_pad (GST_ELEMENT (mimdec), mimdec->srcpad);
-
- mimdec->adapter = gst_adapter_new ();
-
- mimdec->dec = NULL;
- mimdec->buffer_size = -1;
- mimdec->have_header = FALSE;
- mimdec->payload_size = -1;
- mimdec->current_ts = -1;
-}
-
-static void
-gst_mimdec_finalize (GObject *object)
-{
- GstMimDec *mimdec = GST_MIMDEC (object);
-
- gst_adapter_clear (mimdec->adapter);
- g_object_unref (mimdec->adapter);
-}
-
-static GstFlowReturn
-gst_mimdec_chain (GstPad *pad, GstBuffer *in)
-{
- GstMimDec *mimdec;
- GstBuffer *out_buf, *buf;
- guchar *header, *frame_body;
- guint32 fourcc;
- guint16 header_size;
- gint width, height;
- GstCaps * caps;
- GstFlowReturn res = GST_FLOW_OK;
-
- GST_DEBUG ("in gst_mimdec_chain");
-
- g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_ERROR);
-
- mimdec = GST_MIMDEC (gst_pad_get_parent (pad));
- g_return_val_if_fail (GST_IS_MIMDEC (mimdec), GST_FLOW_ERROR);
-
- buf = GST_BUFFER (in);
- gst_adapter_push (mimdec->adapter, buf);
-
- GST_OBJECT_LOCK (mimdec);
-
- // do we have enough bytes to read a header
- while (gst_adapter_available (mimdec->adapter) >= (mimdec->have_header ? mimdec->payload_size : 24)) {
- if (!mimdec->have_header) {
- header = (guchar *) gst_adapter_peek (mimdec->adapter, 24);
- header_size = GUINT16_FROM_LE (*(guint16 *) (header + 0));
- if (header_size != 24) {
- GST_WARNING_OBJECT (mimdec,
- "invalid frame: header size %d incorrect", header_size);
- gst_adapter_flush (mimdec->adapter, 24);
- res = GST_FLOW_ERROR;
- goto out;
- }
-
- fourcc = GST_MAKE_FOURCC ('M', 'L', '2', '0');
- if (GUINT32_FROM_LE (*((guint32 *) (header + 12))) != fourcc) {
- GST_WARNING_OBJECT (mimdec, "invalid frame: unknown FOURCC code %d", fourcc);
- gst_adapter_flush (mimdec->adapter, 24);
- res = GST_FLOW_ERROR;
- goto out;
- }
-
- mimdec->payload_size = GUINT32_FROM_LE (*((guint32 *) (header + 8)));
-
- mimdec->current_ts = GUINT32_FROM_LE (*((guint32 *) (header + 20)));
-
- GST_DEBUG ("Got packet, payload size %d", mimdec->payload_size);
-
- gst_adapter_flush (mimdec->adapter, 24);
-
- mimdec->have_header = TRUE;
- }
-
- if (gst_adapter_available (mimdec->adapter) < mimdec->payload_size)
- {
- goto out;
- }
-
- frame_body = (guchar *) gst_adapter_peek (mimdec->adapter, mimdec->payload_size);
-
- if (mimdec->dec == NULL) {
- GstEvent * event = NULL;
- gboolean result = TRUE;
-
- /* Check if its a keyframe, otherwise skip it */
- if (GUINT32_FROM_LE(*((guint32 *) (frame_body + 12))) != 0) {
- gst_adapter_flush (mimdec->adapter, mimdec->payload_size);
- mimdec->have_header = FALSE;
- res = GST_FLOW_OK;
- goto out;
- }
-
- mimdec->dec = mimic_open ();
- if (mimdec->dec == NULL) {
- GST_WARNING_OBJECT (mimdec, "mimic_open error\n");
-
- gst_adapter_flush (mimdec->adapter, mimdec->payload_size);
- mimdec->have_header = FALSE;
- res = GST_FLOW_ERROR;
- goto out;
- }
-
- if (!mimic_decoder_init (mimdec->dec, frame_body)) {
- GST_WARNING_OBJECT (mimdec, "mimic_decoder_init error\n");
- mimic_close (mimdec->dec);
- mimdec->dec = NULL;
-
- gst_adapter_flush (mimdec->adapter, mimdec->payload_size);
- mimdec->have_header = FALSE;
- res = GST_FLOW_ERROR;
- goto out;
- }
-
- if (!mimic_get_property (mimdec->dec, "buffer_size", &mimdec->buffer_size)) {
- GST_WARNING_OBJECT (mimdec,
- "mimic_get_property('buffer_size') error\n");
- mimic_close (mimdec->dec);
- mimdec->dec = NULL;
-
- gst_adapter_flush (mimdec->adapter, mimdec->payload_size);
- mimdec->have_header = FALSE;
- res = GST_FLOW_ERROR;
- goto out;
- }
-
- if (mimdec->need_newsegment)
- event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME,
- mimdec->current_ts * GST_MSECOND, -1, 0);
- mimdec->need_newsegment = FALSE;
- GST_OBJECT_UNLOCK (mimdec);
- if (event)
- result = gst_pad_push_event (mimdec->srcpad, event);
- GST_OBJECT_LOCK (mimdec);
- if (!result)
- {
- GST_WARNING_OBJECT (mimdec, "gst_pad_push_event failed");
- res = GST_FLOW_ERROR;
- goto out;
- }
- }
-
- out_buf = gst_buffer_new_and_alloc (mimdec->buffer_size);
-
- if (!mimic_decode_frame (mimdec->dec, frame_body, GST_BUFFER_DATA (out_buf))) {
- GST_WARNING_OBJECT (mimdec, "mimic_decode_frame error\n");
-
- gst_adapter_flush (mimdec->adapter, mimdec->payload_size);
- mimdec->have_header = FALSE;
-
- gst_buffer_unref (out_buf);
- res = GST_FLOW_ERROR;
- goto out;
- }
-
- GST_BUFFER_TIMESTAMP(out_buf) = mimdec->current_ts * GST_MSECOND;
-
- mimic_get_property(mimdec->dec, "width", &width);
- mimic_get_property(mimdec->dec, "height", &height);
- GST_DEBUG_OBJECT (mimdec,
- "got WxH %d x %d payload size %d buffer_size %d",
- width, height, mimdec->payload_size, mimdec->buffer_size);
- caps = gst_caps_new_simple ("video/x-raw-rgb",
- "bpp", G_TYPE_INT, 24,
- "depth", G_TYPE_INT, 24,
- "endianness", G_TYPE_INT, 4321,
- "framerate", GST_TYPE_FRACTION, 7, 1,
- "red_mask", G_TYPE_INT, 16711680,
- "green_mask", G_TYPE_INT, 65280,
- "blue_mask", G_TYPE_INT, 255,
- "width", G_TYPE_INT, width,
- "height", G_TYPE_INT, height, NULL);
- gst_buffer_set_caps (out_buf, caps);
- gst_caps_unref (caps);
- GST_OBJECT_UNLOCK (mimdec);
- res = gst_pad_push (mimdec->srcpad, out_buf);
- GST_OBJECT_LOCK (mimdec);
-
- gst_adapter_flush (mimdec->adapter, mimdec->payload_size);
- mimdec->have_header = FALSE;
- }
-
- out:
- GST_OBJECT_UNLOCK (mimdec);
- gst_object_unref (mimdec);
-
- return res;
-}
-
-static GstStateChangeReturn
-gst_mimdec_change_state (GstElement *element, GstStateChange transition)
-{
- GstMimDec *mimdec;
-
- mimdec = GST_MIMDEC (element);
-
- switch (transition) {
- case GST_STATE_CHANGE_READY_TO_NULL:
- if (mimdec->dec != NULL) {
- mimic_close (mimdec->dec);
- mimdec->dec = NULL;
- mimdec->buffer_size = -1;
- mimdec->have_header = FALSE;
- mimdec->payload_size = -1;
- mimdec->current_ts = -1;
- GST_OBJECT_UNLOCK (element);
- }
- break;
- case GST_STATE_CHANGE_READY_TO_PAUSED:
- GST_OBJECT_LOCK (element);
- mimdec->need_newsegment = TRUE;
- GST_OBJECT_UNLOCK (element);
- break;
- default:
- break;
- }
-
- return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
-}
-
-static gboolean
-gst_mimdec_sink_event (GstPad *pad, GstEvent *event)
-{
- gboolean res = TRUE;
- GstMimDec *mimdec = GST_MIMDEC (gst_pad_get_parent (pad));
-
- /*
- * Ignore upstream newsegment event, its EVIL, we should implement
- * proper seeking instead
- */
- switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_NEWSEGMENT:
- {
- gboolean update;
- GstFormat format;
- gdouble rate, arate;
- gint64 start, stop, time;
-
- gst_event_parse_new_segment_full (event, &update, &rate, &arate,
- &format, &start, &stop, &time);
-
- /* we need TIME and a positive rate */
- if (format != GST_FORMAT_TIME)
- goto newseg_wrong_format;
-
- if (rate <= 0.0)
- goto newseg_wrong_rate;
-
- GST_OBJECT_LOCK (mimdec);
- mimdec->need_newsegment = FALSE;
- GST_OBJECT_UNLOCK (mimdec);
-
- res = gst_pad_push_event (mimdec->srcpad, event);
- }
- break;
- case GST_EVENT_FLUSH_STOP:
- GST_OBJECT_LOCK (mimdec);
- mimdec->need_newsegment = TRUE;
- GST_OBJECT_UNLOCK (mimdec);
-
- res = gst_pad_push_event (mimdec->srcpad, event);
- break;
- default:
- res = gst_pad_push_event (mimdec->srcpad, event);
- break;
- }
-
- done:
-
- gst_object_unref (mimdec);
-
- return res;
-
- newseg_wrong_format:
- {
- GST_DEBUG_OBJECT (mimdec, "received non TIME newsegment");
- gst_event_unref (event);
- goto done;
- }
- newseg_wrong_rate:
- {
- GST_DEBUG_OBJECT (mimdec, "negative rates not supported yet");
- gst_event_unref (event);
- goto done;
- }
-
-
-}
diff --git a/ext/mimic/gstmimdec.h b/ext/mimic/gstmimdec.h
deleted file mode 100644
index dbcd69f..0000000
--- a/ext/mimic/gstmimdec.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * GStreamer
- * Copyright (c) 2005 INdT.
- * @author Andre Moreira Magalhaes <andre.magalhaes at indt.org.br>
- * @author Philippe Khalaf <burger at speedy.org>
- *
- * 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
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GST_MIMDEC_H__
-#define __GST_MIMDEC_H__
-
-#include <gst/gst.h>
-#include <gst/base/gstadapter.h>
-#include <mimic.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_MIMDEC \
- (gst_mimdec_get_type())
-#define GST_MIMDEC(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MIMDEC,GstMimDec))
-#define GST_MIMDEC_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MIMDEC,GstMimDec))
-#define GST_IS_MIMDEC(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MIMDEC))
-#define GST_IS_MIMDEC_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MIMDEC))
-
-typedef struct _GstMimDec GstMimDec;
-typedef struct _GstMimDecClass GstMimDecClass;
-
-struct _GstMimDec
-{
- GstElement element;
-
- GstPad *sinkpad, *srcpad;
-
- /* Protected by stream lock */
- GstAdapter *adapter;
-
- /* Protected by object lock */
- MimCtx *dec;
-
- gint buffer_size;
- gboolean have_header;
- guint32 payload_size;
- guint32 current_ts;
-
- gboolean need_newsegment;
-};
-
-struct _GstMimDecClass
-{
- GstElementClass parent_class;
-};
-
-GType gst_mimdec_get_type (void);
-
-G_END_DECLS
-
-#endif /* __GST_MIMDEC_H__ */
diff --git a/ext/mimic/gstmimenc.c b/ext/mimic/gstmimenc.c
deleted file mode 100644
index 91f4939..0000000
--- a/ext/mimic/gstmimenc.c
+++ /dev/null
@@ -1,332 +0,0 @@
- /*
- * GStreamer
- * Copyright (c) 2005 INdT.
- * @author Andre Moreira Magalhaes <andre.magalhaes at indt.org.br>
- * @author Philippe Khalaf <burger at speedy.org>
- *
- * 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
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gst/gst.h>
-
-#include "gstmimenc.h"
-
-GST_DEBUG_CATEGORY (mimenc_debug);
-#define GST_CAT_DEFAULT (mimenc_debug)
-
-#define MAX_INTERFRAMES 15
-
-static GstStaticPadTemplate sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "video/x-raw-rgb, "
- "bpp = (int) 24, "
- "depth = (int) 24, "
- "endianness = (int) 4321, "
- "framerate = (fraction) [1/1, 30/1], "
- "red_mask = (int) 16711680, "
- "green_mask = (int) 65280, "
- "blue_mask = (int) 255, "
- "width = (int) 320, "
- "height = (int) 240"
- ";video/x-raw-rgb, "
- "bpp = (int) 24, "
- "depth = (int) 24, "
- "endianness = (int) 4321, "
- "framerate = (fraction) [1/1, 30/1], "
- "red_mask = (int) 16711680, "
- "green_mask = (int) 65280, "
- "blue_mask = (int) 255, "
- "width = (int) 160, "
- "height = (int) 120"
- )
-);
-
-static GstStaticPadTemplate src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-mimic")
-);
-
-
-static gboolean gst_mimenc_setcaps (GstPad *pad,
- GstCaps *caps);
-static GstFlowReturn gst_mimenc_chain (GstPad *pad,
- GstBuffer *in);
-static GstBuffer* gst_mimenc_create_tcp_header (GstMimEnc *mimenc,
- guint32 payload_size,
- guint32 timestamp);
-
-static GstStateChangeReturn
- gst_mimenc_change_state (GstElement *element,
- GstStateChange transition);
-
-
-GST_BOILERPLATE (GstMimEnc, gst_mimenc, GstElement, GST_TYPE_ELEMENT);
-
-static void
-gst_mimenc_base_init (gpointer klass)
-{
- static GstElementDetails plugin_details = {
- "MimEnc",
- "Codec/Encoder/Video",
- "Mimic encoder",
- "Andre Moreira Magalhaes <andre.magalhaes at indt.org.br>"
- };
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&src_factory));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_factory));
- gst_element_class_set_details (element_class, &plugin_details);
-}
-
-static void
-gst_mimenc_class_init (GstMimEncClass *klass)
-{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
-
- gobject_class = (GObjectClass*) klass;
- gstelement_class = (GstElementClass*) klass;
- gstelement_class->change_state = gst_mimenc_change_state;
-
- GST_DEBUG_CATEGORY_INIT (mimenc_debug, "mimenc", 0, "Mimic encoder plugin");
-}
-
-static void
-gst_mimenc_init (GstMimEnc *mimenc, GstMimEncClass *klass)
-{
- mimenc->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&sink_factory), "sink");
- gst_element_add_pad (GST_ELEMENT (mimenc), mimenc->sinkpad);
- gst_pad_set_setcaps_function (mimenc->sinkpad, gst_mimenc_setcaps);
- gst_pad_set_chain_function (mimenc->sinkpad, gst_mimenc_chain);
-
- mimenc->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&src_factory), "src");
- gst_element_add_pad (GST_ELEMENT (mimenc), mimenc->srcpad);
-
- mimenc->enc = NULL;
-
- // TODO property to set resolution
- mimenc->res = MIMIC_RES_HIGH;
- mimenc->buffer_size = -1;
- mimenc->width = 0;
- mimenc->height = 0;
- mimenc->frames = 0;
-}
-
-static gboolean
-gst_mimenc_setcaps (GstPad *pad, GstCaps *caps)
-{
- GstMimEnc *filter;
- GstStructure *structure;
- int ret = TRUE, height, width;
-
- filter = GST_MIMENC (gst_pad_get_parent (pad));
- g_return_val_if_fail (filter != NULL, FALSE);
- g_return_val_if_fail (GST_IS_MIMENC (filter), FALSE);
-
- structure = gst_caps_get_structure( caps, 0 );
- ret = gst_structure_get_int( structure, "width", &width );
- if (!ret) {
- GST_DEBUG_OBJECT (filter, "No width set");
- goto out;
- }
- ret = gst_structure_get_int( structure, "height", &height );
- if (!ret) {
- GST_DEBUG_OBJECT (filter, "No height set");
- goto out;
- }
-
- GST_OBJECT_LOCK (filter);
-
- if (width == 320 && height == 240)
- filter->res = MIMIC_RES_HIGH;
- else if (width == 160 && height == 120)
- filter->res = MIMIC_RES_LOW;
- else {
- GST_WARNING_OBJECT (filter, "Invalid resolution %dx%d", width, height);
- ret = FALSE;
- GST_OBJECT_UNLOCK (filter);
- goto out;
- }
-
- filter->width = (guint16)width;
- filter->height = (guint16)height;
-
- GST_DEBUG_OBJECT (filter,"Got info from caps w : %d, h : %d",
- filter->width, filter->height);
-
- GST_OBJECT_UNLOCK (filter);
- out:
- gst_object_unref(filter);
- return ret;
-}
-
-static GstFlowReturn
-gst_mimenc_chain (GstPad *pad, GstBuffer *in)
-{
- GstMimEnc *mimenc;
- GstBuffer *out_buf = NULL, *buf = NULL;
- guchar *data;
- gint buffer_size;
- GstBuffer * header = NULL;
- GstFlowReturn res = GST_FLOW_OK;
-
- g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_ERROR);
- mimenc = GST_MIMENC (gst_pad_get_parent (pad));
-
- g_return_val_if_fail (GST_IS_MIMENC (mimenc), GST_FLOW_ERROR);
-
- GST_OBJECT_LOCK (mimenc);
-
- if (mimenc->enc == NULL) {
- mimenc->enc = mimic_open ();
- if (mimenc->enc == NULL) {
- GST_WARNING_OBJECT (mimenc, "mimic_open error\n");
- res = GST_FLOW_ERROR;
- goto out_unlock;
- }
-
- if (!mimic_encoder_init (mimenc->enc, mimenc->res)) {
- GST_WARNING_OBJECT (mimenc, "mimic_encoder_init error\n");
- mimic_close (mimenc->enc);
- mimenc->enc = NULL;
- res = GST_FLOW_ERROR;
- goto out_unlock;
- }
-
- if (!mimic_get_property (mimenc->enc, "buffer_size", &mimenc->buffer_size)) {
- GST_WARNING_OBJECT (mimenc, "mimic_get_property('buffer_size') error\n");
- mimic_close (mimenc->enc);
- mimenc->enc = NULL;
- res = GST_FLOW_ERROR;
- goto out_unlock;
- }
- }
-
- buf = in;
- data = GST_BUFFER_DATA (buf);
-
- out_buf = gst_buffer_new_and_alloc (mimenc->buffer_size);
- GST_BUFFER_TIMESTAMP(out_buf) = GST_BUFFER_TIMESTAMP(buf);
- buffer_size = mimenc->buffer_size;
- if (!mimic_encode_frame (mimenc->enc, data, GST_BUFFER_DATA (out_buf),
- &buffer_size, ((mimenc->frames % MAX_INTERFRAMES) == 0 ? TRUE : FALSE))) {
- GST_WARNING_OBJECT (mimenc, "mimic_encode_frame error\n");
- gst_buffer_unref (out_buf);
- gst_buffer_unref (buf);
- res = GST_FLOW_ERROR;
- goto out_unlock;
- }
- GST_BUFFER_SIZE (out_buf) = buffer_size;
-
- GST_DEBUG_OBJECT (mimenc, "incoming buf size %d, encoded size %d",
- GST_BUFFER_SIZE(buf), GST_BUFFER_SIZE(out_buf));
- ++mimenc->frames;
-
- // now let's create that tcp header
- header = gst_mimenc_create_tcp_header (mimenc, buffer_size,
- GST_BUFFER_TIMESTAMP (buf) / GST_MSECOND);
-
- GST_OBJECT_UNLOCK (mimenc);
-
- if (header)
- {
- res = gst_pad_push (mimenc->srcpad, header);
- if (res != GST_FLOW_OK) {
- gst_buffer_unref (out_buf);
- goto out;
- }
-
- res = gst_pad_push (mimenc->srcpad, out_buf);
- }
- else
- {
- GST_DEBUG_OBJECT(mimenc, "header not created succesfully");
- res = GST_FLOW_ERROR;
- }
-
- out:
- if (buf)
- gst_buffer_unref (buf);
- gst_object_unref (mimenc);
-
- return res;
-
- out_unlock:
- GST_OBJECT_UNLOCK (mimenc);
- goto out;
-
-}
-
-static GstBuffer*
-gst_mimenc_create_tcp_header (GstMimEnc *mimenc, guint32 payload_size,
- guint32 timestamp)
-{
- // 24 bytes
- GstBuffer *buf_header = gst_buffer_new_and_alloc (24);
- guchar *p = (guchar *) GST_BUFFER_DATA(buf_header);
-
- p[0] = 24;
- *((guchar *) (p + 1)) = 0;
- *((guint16 *) (p + 2)) = GUINT16_TO_LE(mimenc->width);
- *((guint16 *) (p + 4)) = GUINT16_TO_LE(mimenc->height);
- *((guint16 *) (p + 6)) = 0;
- *((guint32 *) (p + 8)) = GUINT32_TO_LE(payload_size);
- *((guint32 *) (p + 12)) = GUINT32_TO_LE(GST_MAKE_FOURCC ('M', 'L', '2', '0'));
- *((guint32 *) (p + 16)) = 0;
- *((guint32 *) (p + 20)) = timestamp;
-
- return buf_header;
-}
-
-static GstStateChangeReturn
-gst_mimenc_change_state (GstElement * element, GstStateChange transition)
-{
- GstMimEnc *mimenc;
-
- switch (transition) {
- case GST_STATE_CHANGE_READY_TO_NULL:
- mimenc = GST_MIMENC (element);
- GST_OBJECT_LOCK (element);
- if (mimenc->enc != NULL) {
- mimic_close (mimenc->enc);
- mimenc->enc = NULL;
- mimenc->buffer_size = -1;
- mimenc->frames = 0;
- }
- GST_OBJECT_UNLOCK (element);
- break;
-
- default:
- break;
- }
-
- return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
-}
diff --git a/ext/mimic/gstmimenc.h b/ext/mimic/gstmimenc.h
deleted file mode 100644
index 77b0a78..0000000
--- a/ext/mimic/gstmimenc.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * GStreamer
- * Copyright (c) 2005 INdT.
- * @author Andre Moreira Magalhaes <andre.magalhaes at indt.org.br>
- * @author Philippe Khalaf <burger at speedy.org>
- *
- * 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
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GST_MIMENC_H__
-#define __GST_MIMENC_H__
-
-#include <glib.h>
-#include <gst/gst.h>
-#include <mimic.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_MIMENC \
- (gst_mimenc_get_type())
-#define GST_MIMENC(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MIMENC,GstMimEnc))
-#define GST_MIMENC_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MIMENC,GstMimEnc))
-#define GST_IS_MIMENC(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MIMENC))
-#define GST_IS_MIMENC_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MIMENC))
-
-typedef struct _GstMimEnc GstMimEnc;
-typedef struct _GstMimEncClass GstMimEncClass;
-
-struct _GstMimEnc
-{
- GstElement element;
-
- GstPad *sinkpad, *srcpad;
-
- /* Protected by the object lock */
- MimCtx *enc;
-
- MimicResEnum res;
- gint buffer_size;
- guint32 frames;
- guint16 height, width;
-};
-
-struct _GstMimEncClass
-{
- GstElementClass parent_class;
-};
-
-GType gst_mimenc_get_type (void);
-
-G_END_DECLS
-
-#endif /* __GST_MIMENC_H__ */
diff --git a/ext/mimic/gstmimic.c b/ext/mimic/gstmimic.c
deleted file mode 100644
index 2208371..0000000
--- a/ext/mimic/gstmimic.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * GStreamer
- * Copyright (c) 2005 INdT.
- * @author Andre Moreira Magalhaes <andre.magalhaes at indt.org.br>
- * @author Philippe Khalaf <burger at speedy.org>
- *
- * 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
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gstmimenc.h"
-#include "gstmimdec.h"
-
-static gboolean
-plugin_init (GstPlugin * plugin)
-{
- if (
- !gst_element_register (plugin, "mimenc",
- GST_RANK_NONE, GST_TYPE_MIMENC) ||
- !gst_element_register (plugin, "mimdec",
- GST_RANK_NONE, GST_TYPE_MIMDEC)
- )
- return FALSE;
-
- return TRUE;
-}
-
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "mimic",
- "Mimic codec",
- plugin_init,
- VERSION,
- "GPL",
- "Farsight",
- "http://farsight.sf.net/")
--
1.5.6.5
More information about the farsight-commits
mailing list