2000-12-28 22:12:02 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
*
|
|
|
|
* gsttee.c: Tee element, one in N out
|
2000-01-30 09:03:00 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2000-12-28 22:12:02 +00:00
|
|
|
#include "gst_private.h"
|
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
#include "gsttee.h"
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-12-28 22:12:02 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
GstElementDetails gst_tee_details = {
|
|
|
|
"Tee pipe fitting",
|
|
|
|
"Tee",
|
2000-03-27 19:53:43 +00:00
|
|
|
"1-to-N pipe fitting",
|
2000-01-30 09:03:00 +00:00
|
|
|
VERSION,
|
|
|
|
"Erik Walthinsen <omega@cse.ogi.edu>",
|
|
|
|
"(C) 1999",
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Tee signals and args */
|
|
|
|
enum {
|
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ARG_0,
|
|
|
|
/* FILL ME */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void gst_tee_class_init(GstTeeClass *klass);
|
|
|
|
static void gst_tee_init(GstTee *tee);
|
|
|
|
|
2000-02-27 23:18:38 +00:00
|
|
|
//static xmlNodePtr gst_tee_save_thyself(GstElement *element,xmlNodePtr parent);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-12-29 02:28:04 +00:00
|
|
|
static GstElementClass *parent_class = NULL;
|
2000-02-27 23:18:38 +00:00
|
|
|
//static guint gst_tee_signals[LAST_SIGNAL] = { 0 };
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
GtkType
|
|
|
|
gst_tee_get_type(void) {
|
|
|
|
static GtkType tee_type = 0;
|
|
|
|
|
|
|
|
if (!tee_type) {
|
|
|
|
static const GtkTypeInfo tee_info = {
|
|
|
|
"GstTee",
|
|
|
|
sizeof(GstTee),
|
|
|
|
sizeof(GstTeeClass),
|
|
|
|
(GtkClassInitFunc)gst_tee_class_init,
|
|
|
|
(GtkObjectInitFunc)gst_tee_init,
|
|
|
|
(GtkArgSetFunc)NULL,
|
|
|
|
(GtkArgGetFunc)NULL,
|
|
|
|
(GtkClassInitFunc)NULL,
|
|
|
|
};
|
2000-12-29 02:28:04 +00:00
|
|
|
tee_type = gtk_type_unique(GST_TYPE_ELEMENT,&tee_info);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
return tee_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_tee_class_init(GstTeeClass *klass) {
|
2000-12-29 02:28:04 +00:00
|
|
|
GstElementClass *gstelement_class;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-12-29 02:28:04 +00:00
|
|
|
gstelement_class = (GstElementClass*)klass;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-12-29 02:28:04 +00:00
|
|
|
parent_class = gtk_type_class(GST_TYPE_ELEMENT);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gst_tee_init(GstTee *tee) {
|
|
|
|
tee->sinkpad = gst_pad_new("sink",GST_PAD_SINK);
|
|
|
|
gst_element_add_pad(GST_ELEMENT(tee),tee->sinkpad);
|
|
|
|
gst_pad_set_chain_function(tee->sinkpad,gst_tee_chain);
|
|
|
|
|
|
|
|
tee->numsrcpads = 0;
|
|
|
|
tee->srcpads = NULL;
|
|
|
|
}
|
|
|
|
|
2000-03-27 19:53:43 +00:00
|
|
|
/**
|
|
|
|
* gst_tee_new:
|
|
|
|
* @name: the name of the new tee
|
|
|
|
*
|
|
|
|
* create a new tee element
|
|
|
|
*
|
|
|
|
* Returns: the new tee element
|
|
|
|
*/
|
2000-01-30 09:03:00 +00:00
|
|
|
GstElement *gst_tee_new(gchar *name) {
|
|
|
|
GstElement *tee = GST_ELEMENT(gtk_type_new(GST_TYPE_TEE));
|
|
|
|
gst_element_set_name(GST_ELEMENT(tee),name);
|
|
|
|
return tee;
|
|
|
|
}
|
|
|
|
|
2000-03-27 19:53:43 +00:00
|
|
|
/**
|
|
|
|
* gst_tee_new_pad:
|
|
|
|
* @tee: the tee to create the new pad on
|
|
|
|
*
|
|
|
|
* create a new pad on a given tee
|
|
|
|
*
|
|
|
|
* Returns: the name of the new pad
|
|
|
|
*/
|
2000-01-30 09:03:00 +00:00
|
|
|
gchar *gst_tee_new_pad(GstTee *tee) {
|
|
|
|
gchar *name;
|
|
|
|
GstPad *srcpad;
|
|
|
|
|
2000-02-27 23:18:38 +00:00
|
|
|
g_return_val_if_fail(tee != NULL, NULL);
|
|
|
|
g_return_val_if_fail(GST_IS_TEE(tee), NULL);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
name = g_strdup_printf("src%d",tee->numsrcpads);
|
|
|
|
srcpad = gst_pad_new(name,GST_PAD_SRC);
|
|
|
|
gst_element_add_pad(GST_ELEMENT(tee),srcpad);
|
|
|
|
tee->srcpads = g_slist_prepend(tee->srcpads,srcpad);
|
|
|
|
tee->numsrcpads++;
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2000-03-27 19:53:43 +00:00
|
|
|
/**
|
|
|
|
* gst_tee_chain:
|
|
|
|
* @pad: the pad to follow
|
|
|
|
* @buf: the buffer to pass
|
|
|
|
*
|
|
|
|
* chain a buffer on a pad
|
|
|
|
*/
|
2000-01-30 09:03:00 +00:00
|
|
|
void gst_tee_chain(GstPad *pad,GstBuffer *buf) {
|
|
|
|
GstTee *tee;
|
|
|
|
GSList *srcpads;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
g_return_if_fail(pad != NULL);
|
|
|
|
g_return_if_fail(GST_IS_PAD(pad));
|
|
|
|
g_return_if_fail(buf != NULL);
|
|
|
|
|
|
|
|
tee = GST_TEE(pad->parent);
|
|
|
|
gst_trace_add_entry(NULL,0,buf,"tee buffer");
|
|
|
|
for (i=0;i<tee->numsrcpads-1;i++)
|
|
|
|
gst_buffer_ref(buf);
|
|
|
|
srcpads = tee->srcpads;
|
|
|
|
while (srcpads) {
|
|
|
|
gst_pad_push(GST_PAD(srcpads->data),buf);
|
|
|
|
srcpads = g_slist_next(srcpads);
|
|
|
|
}
|
|
|
|
}
|