Commit e0c55e8f authored by Wim Taymans's avatar Wim Taymans
Browse files

Added change_state to fakesrc

Original commit message from CVS:
Added change_state to fakesrc
parent fe49cb9c
......@@ -45,6 +45,7 @@ enum {
ARG_0,
ARG_NUM_SINKS,
ARG_SILENT,
ARG_DUMP,
};
GST_PADTEMPLATE_FACTORY (fakesink_sink_factory,
......@@ -109,6 +110,9 @@ gst_fakesink_class_init (GstFakeSinkClass *klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean ("silent", "silent", "silent",
FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
g_param_spec_boolean ("dump", "dump", "dump",
FALSE, G_PARAM_READWRITE));
gst_fakesink_signals[SIGNAL_HANDOFF] =
g_signal_new ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
......@@ -133,6 +137,7 @@ gst_fakesink_init (GstFakeSink *fakesink)
fakesink->sinkpads = g_slist_prepend (NULL, pad);
fakesink->numsinkpads = 1;
fakesink->silent = FALSE;
fakesink->dump = FALSE;
}
static GstPad*
......@@ -174,6 +179,9 @@ gst_fakesink_set_property (GObject *object, guint prop_id, const GValue *value,
case ARG_SILENT:
sink->silent = g_value_get_boolean (value);
break;
case ARG_DUMP:
sink->dump = g_value_get_boolean (value);
break;
default:
break;
}
......@@ -196,6 +204,9 @@ gst_fakesink_get_property (GObject *object, guint prop_id, GValue *value, GParam
case ARG_SILENT:
g_value_set_boolean (value, sink->silent);
break;
case ARG_DUMP:
g_value_set_boolean (value, sink->dump);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -238,10 +249,15 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
}
if (!fakesink->silent)
g_print("fakesink: chain ******* (%s:%s)< (%d bytes, %lld) \n",
GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_print("fakesink: chain ******* (%s:%s)< (%d bytes, %lld) %p\n",
GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf);
g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0, buf);
g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0, buf, pad);
if (fakesink->dump)
{
gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
}
gst_buffer_unref (buf);
}
......
......@@ -57,6 +57,7 @@ struct _GstFakeSink {
GSList *sinkpads;
gint numsinkpads;
gboolean silent;
gboolean dump;
};
struct _GstFakeSinkClass {
......
......@@ -22,6 +22,8 @@
#include <stdlib.h>
#include <string.h>
#include <gstfakesrc.h>
......@@ -147,8 +149,12 @@ static void gst_fakesrc_init (GstFakeSrc *fakesrc);
static GstPad* gst_fakesrc_request_new_pad (GstElement *element, GstPadTemplate *templ);
static void gst_fakesrc_update_functions (GstFakeSrc *src);
static void gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void gst_fakesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
static void gst_fakesrc_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec);
static void gst_fakesrc_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec);
static GstElementStateReturn gst_fakesrc_change_state (GstElement *element);
static GstBuffer* gst_fakesrc_get (GstPad *pad);
static void gst_fakesrc_loop (GstElement *element);
......@@ -241,7 +247,8 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass)
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_fakesrc_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_fakesrc_get_property);
gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_fakesrc_request_new_pad);
gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_fakesrc_request_new_pad);
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_fakesrc_change_state);
}
static void
......@@ -390,8 +397,10 @@ gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, G
src->data = g_value_get_int (value);
switch (src->data) {
case FAKESRC_DATA_ALLOCATE:
gst_buffer_unref (src->parent);
src->parent = NULL;
if (src->parent) {
gst_buffer_unref (src->parent);
src->parent = NULL;
}
break;
case FAKESRC_DATA_SUBBUFFER:
if (!src->parent)
......@@ -671,7 +680,7 @@ gst_fakesrc_get(GstPad *pad)
GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_signal_emit (G_OBJECT (src), gst_fakesrc_signals[SIGNAL_HANDOFF], 0,
buf);
buf, pad);
return buf;
}
......@@ -723,7 +732,7 @@ gst_fakesrc_loop(GstElement *element)
GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_signal_emit (G_OBJECT (src), gst_fakesrc_signals[SIGNAL_HANDOFF], 0,
buf);
buf, pad);
gst_pad_push (pad, buf);
pads = g_slist_next (pads);
......@@ -731,6 +740,34 @@ gst_fakesrc_loop(GstElement *element)
} while (!GST_ELEMENT_IS_COTHREAD_STOPPING (element));
}
static GstElementStateReturn
gst_fakesrc_change_state (GstElement *element)
{
GstFakeSrc *fakesrc;
g_return_val_if_fail (GST_IS_FAKESRC (element), GST_STATE_FAILURE);
fakesrc = GST_FAKESRC (element);
if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
if (fakesrc->parent) {
gst_buffer_unref (fakesrc->parent);
fakesrc->parent = NULL;
}
}
else if (GST_STATE_PENDING (element) == GST_STATE_READY) {
fakesrc->buffer_count = 0;
fakesrc->pattern_byte = 0x00;
fakesrc->need_flush = FALSE;
fakesrc->parent = NULL;
}
if (GST_ELEMENT_CLASS (parent_class)->change_state)
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
return GST_STATE_SUCCESS;
}
gboolean
gst_fakesrc_factory_init (GstElementFactory *factory)
{
......
......@@ -45,6 +45,7 @@ enum {
ARG_0,
ARG_NUM_SINKS,
ARG_SILENT,
ARG_DUMP,
};
GST_PADTEMPLATE_FACTORY (fakesink_sink_factory,
......@@ -109,6 +110,9 @@ gst_fakesink_class_init (GstFakeSinkClass *klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean ("silent", "silent", "silent",
FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
g_param_spec_boolean ("dump", "dump", "dump",
FALSE, G_PARAM_READWRITE));
gst_fakesink_signals[SIGNAL_HANDOFF] =
g_signal_new ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
......@@ -133,6 +137,7 @@ gst_fakesink_init (GstFakeSink *fakesink)
fakesink->sinkpads = g_slist_prepend (NULL, pad);
fakesink->numsinkpads = 1;
fakesink->silent = FALSE;
fakesink->dump = FALSE;
}
static GstPad*
......@@ -174,6 +179,9 @@ gst_fakesink_set_property (GObject *object, guint prop_id, const GValue *value,
case ARG_SILENT:
sink->silent = g_value_get_boolean (value);
break;
case ARG_DUMP:
sink->dump = g_value_get_boolean (value);
break;
default:
break;
}
......@@ -196,6 +204,9 @@ gst_fakesink_get_property (GObject *object, guint prop_id, GValue *value, GParam
case ARG_SILENT:
g_value_set_boolean (value, sink->silent);
break;
case ARG_DUMP:
g_value_set_boolean (value, sink->dump);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -238,10 +249,15 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
}
if (!fakesink->silent)
g_print("fakesink: chain ******* (%s:%s)< (%d bytes, %lld) \n",
GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_print("fakesink: chain ******* (%s:%s)< (%d bytes, %lld) %p\n",
GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf);
g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0, buf);
g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0, buf, pad);
if (fakesink->dump)
{
gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
}
gst_buffer_unref (buf);
}
......
......@@ -57,6 +57,7 @@ struct _GstFakeSink {
GSList *sinkpads;
gint numsinkpads;
gboolean silent;
gboolean dump;
};
struct _GstFakeSinkClass {
......
......@@ -22,6 +22,8 @@
#include <stdlib.h>
#include <string.h>
#include <gstfakesrc.h>
......@@ -147,8 +149,12 @@ static void gst_fakesrc_init (GstFakeSrc *fakesrc);
static GstPad* gst_fakesrc_request_new_pad (GstElement *element, GstPadTemplate *templ);
static void gst_fakesrc_update_functions (GstFakeSrc *src);
static void gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void gst_fakesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
static void gst_fakesrc_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec);
static void gst_fakesrc_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec);
static GstElementStateReturn gst_fakesrc_change_state (GstElement *element);
static GstBuffer* gst_fakesrc_get (GstPad *pad);
static void gst_fakesrc_loop (GstElement *element);
......@@ -241,7 +247,8 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass)
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_fakesrc_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_fakesrc_get_property);
gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_fakesrc_request_new_pad);
gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_fakesrc_request_new_pad);
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_fakesrc_change_state);
}
static void
......@@ -390,8 +397,10 @@ gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, G
src->data = g_value_get_int (value);
switch (src->data) {
case FAKESRC_DATA_ALLOCATE:
gst_buffer_unref (src->parent);
src->parent = NULL;
if (src->parent) {
gst_buffer_unref (src->parent);
src->parent = NULL;
}
break;
case FAKESRC_DATA_SUBBUFFER:
if (!src->parent)
......@@ -671,7 +680,7 @@ gst_fakesrc_get(GstPad *pad)
GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_signal_emit (G_OBJECT (src), gst_fakesrc_signals[SIGNAL_HANDOFF], 0,
buf);
buf, pad);
return buf;
}
......@@ -723,7 +732,7 @@ gst_fakesrc_loop(GstElement *element)
GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_signal_emit (G_OBJECT (src), gst_fakesrc_signals[SIGNAL_HANDOFF], 0,
buf);
buf, pad);
gst_pad_push (pad, buf);
pads = g_slist_next (pads);
......@@ -731,6 +740,34 @@ gst_fakesrc_loop(GstElement *element)
} while (!GST_ELEMENT_IS_COTHREAD_STOPPING (element));
}
static GstElementStateReturn
gst_fakesrc_change_state (GstElement *element)
{
GstFakeSrc *fakesrc;
g_return_val_if_fail (GST_IS_FAKESRC (element), GST_STATE_FAILURE);
fakesrc = GST_FAKESRC (element);
if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
if (fakesrc->parent) {
gst_buffer_unref (fakesrc->parent);
fakesrc->parent = NULL;
}
}
else if (GST_STATE_PENDING (element) == GST_STATE_READY) {
fakesrc->buffer_count = 0;
fakesrc->pattern_byte = 0x00;
fakesrc->need_flush = FALSE;
fakesrc->parent = NULL;
}
if (GST_ELEMENT_CLASS (parent_class)->change_state)
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
return GST_STATE_SUCCESS;
}
gboolean
gst_fakesrc_factory_init (GstElementFactory *factory)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment