Megapatch, changes which states are available, how they're used, and how they're...
[platform/upstream/gstreamer.git] / plugins / elements / gstfakesink.c
1 /* Gnome-Streamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20
21 #include <gstfakesink.h>
22
23
24 GstElementDetails gst_fakesink_details = {
25   "Fake Sink",
26   "Sink",
27   "Black hole for data",
28   VERSION,
29   "Erik Walthinsen <omega@cse.ogi.edu>",
30   "(C) 1999",
31 };
32
33
34 /* FakeSink signals and args */
35 enum {
36   /* FILL ME */
37   LAST_SIGNAL
38 };
39
40 enum {
41   ARG_0,
42   /* FILL ME */
43 };
44
45
46 static void gst_fakesink_class_init(GstFakeSinkClass *klass);
47 static void gst_fakesink_init(GstFakeSink *fakesink);
48
49 GstElement *gst_fakesink_new(gchar *name);
50 void gst_fakesink_chain(GstPad *pad,GstBuffer *buf);
51
52 static GstSinkClass *parent_class = NULL;
53 //static guint gst_fakesink_signals[LAST_SIGNAL] = { 0 };
54
55 GtkType
56 gst_fakesink_get_type(void) {
57   static GtkType fakesink_type = 0;
58
59   if (!fakesink_type) {
60     static const GtkTypeInfo fakesink_info = {
61       "GstFakeSink",
62       sizeof(GstFakeSink),
63       sizeof(GstFakeSinkClass),
64       (GtkClassInitFunc)gst_fakesink_class_init,
65       (GtkObjectInitFunc)gst_fakesink_init,
66       (GtkArgSetFunc)NULL,
67       (GtkArgGetFunc)NULL,
68       (GtkClassInitFunc)NULL,
69     };
70     fakesink_type = gtk_type_unique(GST_TYPE_SINK,&fakesink_info);
71   }
72   return fakesink_type;
73 }
74
75 static void
76 gst_fakesink_class_init(GstFakeSinkClass *klass) {
77   GstSinkClass *gstsink_class;
78
79   gstsink_class = (GstSinkClass*)klass;
80
81   parent_class = gtk_type_class(GST_TYPE_SINK);
82 }
83
84 static void gst_fakesink_init(GstFakeSink *fakesink) {
85   fakesink->sinkpad = gst_pad_new("sink",GST_PAD_SINK);
86   gst_element_add_pad(GST_ELEMENT(fakesink),fakesink->sinkpad);
87   gst_pad_set_chain_function(fakesink->sinkpad,gst_fakesink_chain);
88
89   // we're ready right away, since we don't have any args...
90 //  gst_element_set_state(GST_ELEMENT(fakesink),GST_STATE_READY);
91 }
92
93 /**
94  * gst_fakesink_new:
95  * @name: the name of the new fakesrc
96  *
97  * create a new fakesink
98  *
99  * Returns: the new fakesink
100  */
101 GstElement *gst_fakesink_new(gchar *name) {
102   GstElement *fakesink = GST_ELEMENT(gtk_type_new(GST_TYPE_FAKESINK));
103   gst_element_set_name(GST_ELEMENT(fakesink),name);
104   return fakesink;
105 }
106
107 /**
108  * gst_fakesink_chain:
109  * @pad: the pad this faksink is connected to
110  * @buf: the buffer that has to be absorbed
111  *
112  * take the buffer from the pad and unref it without doing
113  * anything with it.
114  */
115 void gst_fakesink_chain(GstPad *pad,GstBuffer *buf) {
116   GstFakeSink *fakesink;
117
118   g_return_if_fail(pad != NULL);
119   g_return_if_fail(GST_IS_PAD(pad));
120   g_return_if_fail(buf != NULL);
121
122   fakesink = GST_FAKESINK(pad->parent);
123 //  g_print("gst_fakesink_chain: got buffer in '%s'\n",
124 //          gst_element_get_name(GST_ELEMENT(fakesink)));
125   g_print("<");
126   gst_buffer_unref(buf);
127 }