565caa295eabb12c253512f3a045a708906129b2
[platform/upstream/gstreamer.git] / plugins / elements / gstfakesrc.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 <gstfakesrc.h>
22
23
24 GstElementDetails gst_fakesrc_details = {
25   "Fake Source",
26   "Source",
27   "Push empty (no data) buffers around",
28   VERSION,
29   "Erik Walthinsen <omega@cse.ogi.edu>",
30   "(C) 1999",
31 };
32
33
34 /* FakeSrc 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_fakesrc_class_init(GstFakeSrcClass *klass);
47 static void gst_fakesrc_init(GstFakeSrc *fakesrc);
48
49 void gst_fakesrc_push(GstSrc *src);
50
51 static GstSrcClass *parent_class = NULL;
52 //static guint gst_fakesrc_signals[LAST_SIGNAL] = { 0 };
53
54 GtkType
55 gst_fakesrc_get_type(void) {
56   static GtkType fakesrc_type = 0;
57
58   if (!fakesrc_type) {
59     static const GtkTypeInfo fakesrc_info = {
60       "GstFakeSrc",
61       sizeof(GstFakeSrc),
62       sizeof(GstFakeSrcClass),
63       (GtkClassInitFunc)gst_fakesrc_class_init,
64       (GtkObjectInitFunc)gst_fakesrc_init,
65       (GtkArgSetFunc)NULL,
66       (GtkArgGetFunc)NULL,
67       (GtkClassInitFunc)NULL,
68     };
69     fakesrc_type = gtk_type_unique(GST_TYPE_SRC,&fakesrc_info);
70   }
71   return fakesrc_type;
72 }
73
74 static void
75 gst_fakesrc_class_init(GstFakeSrcClass *klass) {
76   GstSrcClass *gstsrc_class;
77
78   gstsrc_class = (GstSrcClass*)klass;
79
80   parent_class = gtk_type_class(GST_TYPE_SRC);
81
82   gstsrc_class->push = gst_fakesrc_push;
83   gstsrc_class->push_region = NULL;
84 }
85
86 static void gst_fakesrc_init(GstFakeSrc *fakesrc) {
87   fakesrc->srcpad = gst_pad_new("src",GST_PAD_SRC);
88   gst_element_add_pad(GST_ELEMENT(fakesrc),fakesrc->srcpad);
89
90   // we're already complete, since we don't have any args...
91   gst_element_set_state(GST_ELEMENT(fakesrc),GST_STATE_COMPLETE);
92 }
93
94 /**
95  * gst_fakesrc_new:
96  * @name: then name of the fakse source
97  * 
98  * create a new fakesrc
99  *
100  * Returns: The new element.
101  */
102 GstElement *gst_fakesrc_new(gchar *name) {
103   GstElement *fakesrc = GST_ELEMENT(gtk_type_new(GST_TYPE_FAKESRC));
104   gst_element_set_name(GST_ELEMENT(fakesrc),name);
105   return fakesrc;
106 }
107
108 /**
109  * gst_fakesrc_push:
110  * @src: the faksesrc to push
111  * 
112  * generate an empty buffer and push it to the next element.
113  */
114 void gst_fakesrc_push(GstSrc *src) {
115   GstFakeSrc *fakesrc;
116   GstBuffer *buf;
117
118   g_return_if_fail(src != NULL);
119   g_return_if_fail(GST_IS_FAKESRC(src));
120   fakesrc = GST_FAKESRC(src);
121
122 //  g_print("gst_fakesrc_push(): pushing fake buffer from '%s'\n",
123 //          gst_element_get_name(GST_ELEMENT(fakesrc)));
124   g_print(">");
125   buf = gst_buffer_new();
126   gst_pad_push(fakesrc->srcpad,buf);
127 }