mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-16 11:15:31 +00:00
Code Cleanups
Original commit message from CVS: Code Cleanups Added use cases for the source elements.
This commit is contained in:
parent
a075cbda18
commit
26a69ef7f8
44 changed files with 1490 additions and 1201 deletions
66
docs/random/sources
Normal file
66
docs/random/sources
Normal file
|
@ -0,0 +1,66 @@
|
|||
There are a number of different ways of coding a GstSrc. I'll try to
|
||||
outline them and how the function here:
|
||||
|
||||
1a) Simple push-function based with single output
|
||||
|
||||
This is the style that all the existing sources use. There is a single
|
||||
output pad, and a _push function that's global to the whole element. The
|
||||
_push function simple constructs buffer and pushes them out the pad.
|
||||
|
||||
Chained:
|
||||
|
||||
Typically this will be the/an entry into the Bin. The Bin's iterate
|
||||
function simply calls the Src's _push function. When the _push function
|
||||
pushes a buffer out it's pad, the chain function of the peer pad is
|
||||
called, presumably causing a push out the other side of that element, and
|
||||
eventually data gets to the other end. The stack unrolls, and the
|
||||
iteration ends for that Src.
|
||||
|
||||
Cothreaded:
|
||||
|
||||
Again, the source would generally be an entry into the Bin. A loopfunc
|
||||
will be constructed around it, which will simply loop calling the Src's
|
||||
_push function as in the non-cothreaded case. When the _push function
|
||||
pushes a buffer, it finds a pushfunc attached to the pad, drops the buffer
|
||||
in the pen, and calls the pushfunc provided by the Bin. This causes a
|
||||
switch to the next element, then the next, to the end, at which point a
|
||||
buffer pull will travel back down the chain. The _push function gets
|
||||
context and finishes, at which point the loopfunc wrapper simply calls it
|
||||
again in the next iteration.
|
||||
|
||||
|
||||
1b) Simple push-function based with multiple output
|
||||
|
||||
Chained:
|
||||
|
||||
Similar to the single output variant, except several chains are spawned
|
||||
off, one per push, hanging off whichever pad the buffer is pushed off of.
|
||||
The stack will grow and unwind as many times as buffers are pushed out.
|
||||
|
||||
Cothreaded:
|
||||
|
||||
Also similar to the single output variant. When the pull winds its way
|
||||
back from the first push, execution returns to the Src's _push function,
|
||||
which simply goes off and pushes out another buffer, causing another
|
||||
series of context switches. Eventually the loopfunc wrapper starts over,
|
||||
round and round we go.
|
||||
|
||||
|
||||
|
||||
2) Pull-function based with single output
|
||||
|
||||
Similar to a regular filter with a chain function associated with each
|
||||
pad, this kind of source doesn't provide a src-wide push function, but
|
||||
does provide pullfuncs for its pad. A pullfunc puts a buffer in the pen
|
||||
and exits.
|
||||
|
||||
Chained:
|
||||
|
||||
As usual, is likely to be an entry into a Bin. The Bin iterate code must
|
||||
explicitely pull a buffer and pass it on to the peer.
|
||||
|
||||
Cothreaded:
|
||||
|
||||
|
||||
---- ok, I'll finish this tomorrow when my brain's working again.... ----
|
||||
|
|
@ -33,7 +33,6 @@ extern "C" {
|
|||
|
||||
GstElementDetails gst_asyncdisksrc_details;
|
||||
|
||||
|
||||
#define GST_TYPE_ASYNCDISKSRC \
|
||||
(gst_asyncdisksrc_get_type())
|
||||
#define GST_ASYNCDISKSRC(obj) \
|
||||
|
|
|
@ -40,15 +40,17 @@ GstElementDetails gst_audiosink_details = {
|
|||
"(C) 1999",
|
||||
};
|
||||
|
||||
static void gst_audiosink_class_init (GstAudioSinkClass *klass);
|
||||
static void gst_audiosink_init (GstAudioSink *audiosink);
|
||||
|
||||
static gboolean gst_audiosink_open_audio(GstAudioSink *sink);
|
||||
static void gst_audiosink_close_audio(GstAudioSink *sink);
|
||||
static GstElementStateReturn gst_audiosink_change_state(GstElement *element);
|
||||
static gboolean gst_audiosink_open_audio (GstAudioSink *sink);
|
||||
static void gst_audiosink_close_audio (GstAudioSink *sink);
|
||||
static GstElementStateReturn gst_audiosink_change_state (GstElement *element);
|
||||
|
||||
static void gst_audiosink_set_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_audiosink_get_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_audiosink_set_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
static void gst_audiosink_get_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
|
||||
void gst_audiosink_chain(GstPad *pad,GstBuffer *buf);
|
||||
static void gst_audiosink_chain (GstPad *pad,GstBuffer *buf);
|
||||
|
||||
/* AudioSink signals and args */
|
||||
enum {
|
||||
|
@ -67,7 +69,7 @@ enum {
|
|||
|
||||
#define GST_TYPE_AUDIOSINK_FORMATS (gst_audiosink_formats_get_type())
|
||||
|
||||
GtkType
|
||||
static GtkType
|
||||
gst_audiosink_formats_get_type(void) {
|
||||
static GtkType audiosink_formats_type = 0;
|
||||
static GtkEnumValue audiosink_formats[] = {
|
||||
|
@ -83,7 +85,7 @@ gst_audiosink_formats_get_type(void) {
|
|||
|
||||
#define GST_TYPE_AUDIOSINK_CHANNELS (gst_audiosink_channels_get_type())
|
||||
|
||||
GtkType
|
||||
static GtkType
|
||||
gst_audiosink_channels_get_type(void) {
|
||||
static GtkType audiosink_channels_type = 0;
|
||||
static GtkEnumValue audiosink_channels[] = {
|
||||
|
@ -97,9 +99,6 @@ gst_audiosink_channels_get_type(void) {
|
|||
return audiosink_channels_type;
|
||||
}
|
||||
|
||||
static void gst_audiosink_class_init(GstAudioSinkClass *klass);
|
||||
static void gst_audiosink_init(GstAudioSink *audiosink);
|
||||
|
||||
|
||||
static GstSinkClass *parent_class = NULL;
|
||||
static guint gst_audiosink_signals[LAST_SIGNAL] = { 0 };
|
||||
|
@ -107,7 +106,8 @@ static guint gst_audiosink_signals[LAST_SIGNAL] = { 0 };
|
|||
static guint16 gst_audiosink_type_audio = 0;
|
||||
|
||||
GtkType
|
||||
gst_audiosink_get_type(void) {
|
||||
gst_audiosink_get_type (void)
|
||||
{
|
||||
static GtkType audiosink_type = 0;
|
||||
|
||||
if (!audiosink_type) {
|
||||
|
@ -121,17 +121,18 @@ gst_audiosink_get_type(void) {
|
|||
(GtkArgGetFunc)NULL,
|
||||
(GtkClassInitFunc)NULL,
|
||||
};
|
||||
audiosink_type = gtk_type_unique(GST_TYPE_SINK,&audiosink_info);
|
||||
audiosink_type = gtk_type_unique (GST_TYPE_SINK, &audiosink_info);
|
||||
}
|
||||
|
||||
if (!gst_audiosink_type_audio)
|
||||
gst_audiosink_type_audio = gst_type_find_by_mime("audio/raw");
|
||||
gst_audiosink_type_audio = gst_type_find_by_mime ("audio/raw");
|
||||
|
||||
return audiosink_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_audiosink_class_init(GstAudioSinkClass *klass) {
|
||||
gst_audiosink_class_init (GstAudioSinkClass *klass)
|
||||
{
|
||||
GtkObjectClass *gtkobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
|
||||
|
@ -140,13 +141,13 @@ gst_audiosink_class_init(GstAudioSinkClass *klass) {
|
|||
|
||||
parent_class = gtk_type_class(GST_TYPE_FILTER);
|
||||
|
||||
gtk_object_add_arg_type("GstAudioSink::mute", GTK_TYPE_BOOL,
|
||||
gtk_object_add_arg_type ("GstAudioSink::mute", GTK_TYPE_BOOL,
|
||||
GTK_ARG_READWRITE, ARG_MUTE);
|
||||
gtk_object_add_arg_type("GstAudioSink::format", GST_TYPE_AUDIOSINK_FORMATS,
|
||||
gtk_object_add_arg_type ("GstAudioSink::format", GST_TYPE_AUDIOSINK_FORMATS,
|
||||
GTK_ARG_READWRITE, ARG_FORMAT);
|
||||
gtk_object_add_arg_type("GstAudioSink::channels", GST_TYPE_AUDIOSINK_CHANNELS,
|
||||
gtk_object_add_arg_type ("GstAudioSink::channels", GST_TYPE_AUDIOSINK_CHANNELS,
|
||||
GTK_ARG_READWRITE, ARG_CHANNELS);
|
||||
gtk_object_add_arg_type("GstAudioSink::frequency", GTK_TYPE_INT,
|
||||
gtk_object_add_arg_type ("GstAudioSink::frequency", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_FREQUENCY);
|
||||
|
||||
gtkobject_class->set_arg = gst_audiosink_set_arg;
|
||||
|
@ -156,174 +157,184 @@ gst_audiosink_class_init(GstAudioSinkClass *klass) {
|
|||
gtk_signal_new("handoff",GTK_RUN_LAST,gtkobject_class->type,
|
||||
GTK_SIGNAL_OFFSET(GstAudioSinkClass,handoff),
|
||||
gtk_marshal_NONE__NONE,GTK_TYPE_NONE,0);
|
||||
|
||||
gtk_object_class_add_signals(gtkobject_class,gst_audiosink_signals,
|
||||
LAST_SIGNAL);
|
||||
|
||||
gstelement_class->change_state = gst_audiosink_change_state;
|
||||
}
|
||||
|
||||
static void gst_audiosink_init(GstAudioSink *audiosink) {
|
||||
audiosink->sinkpad = gst_pad_new("sink",GST_PAD_SINK);
|
||||
gst_element_add_pad(GST_ELEMENT(audiosink),audiosink->sinkpad);
|
||||
static void
|
||||
gst_audiosink_init (GstAudioSink *audiosink)
|
||||
{
|
||||
audiosink->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
|
||||
gst_element_add_pad (GST_ELEMENT (audiosink), audiosink->sinkpad);
|
||||
gst_pad_set_type_id (audiosink->sinkpad, gst_audiosink_type_audio);
|
||||
|
||||
gst_pad_set_type_id(audiosink->sinkpad,gst_audiosink_type_audio);
|
||||
|
||||
gst_pad_set_chain_function(audiosink->sinkpad,gst_audiosink_chain);
|
||||
gst_pad_set_chain_function (audiosink->sinkpad, gst_audiosink_chain);
|
||||
|
||||
audiosink->fd = -1;
|
||||
audiosink->clock = gst_clock_get_system();
|
||||
gst_clock_register(audiosink->clock, GST_OBJECT(audiosink));
|
||||
//audiosink->clocktime = 0LL;
|
||||
|
||||
gst_clock_register (audiosink->clock, GST_OBJECT (audiosink));
|
||||
|
||||
GST_FLAG_SET(audiosink, GST_ELEMENT_THREAD_SUGGESTED);
|
||||
GST_FLAG_SET (audiosink, GST_ELEMENT_THREAD_SUGGESTED);
|
||||
}
|
||||
|
||||
void gst_audiosink_sync_parms(GstAudioSink *audiosink) {
|
||||
static void
|
||||
gst_audiosink_sync_parms (GstAudioSink *audiosink)
|
||||
{
|
||||
audio_buf_info ospace;
|
||||
int frag;
|
||||
|
||||
g_return_if_fail(audiosink != NULL);
|
||||
g_return_if_fail(GST_IS_AUDIOSINK(audiosink));
|
||||
g_return_if_fail (audiosink != NULL);
|
||||
g_return_if_fail (GST_IS_AUDIOSINK (audiosink));
|
||||
|
||||
if (audiosink->fd == -1) return;
|
||||
|
||||
ioctl(audiosink->fd,SNDCTL_DSP_RESET,0);
|
||||
ioctl (audiosink->fd,SNDCTL_DSP_RESET, 0);
|
||||
|
||||
ioctl(audiosink->fd,SNDCTL_DSP_SETFMT,&audiosink->format);
|
||||
ioctl(audiosink->fd,SNDCTL_DSP_CHANNELS,&audiosink->channels);
|
||||
ioctl(audiosink->fd,SNDCTL_DSP_SPEED,&audiosink->frequency);
|
||||
ioctl(audiosink->fd,SNDCTL_DSP_GETBLKSIZE, &frag);
|
||||
ioctl (audiosink->fd, SNDCTL_DSP_SETFMT, &audiosink->format);
|
||||
ioctl (audiosink->fd, SNDCTL_DSP_CHANNELS, &audiosink->channels);
|
||||
ioctl (audiosink->fd, SNDCTL_DSP_SPEED, &audiosink->frequency);
|
||||
ioctl (audiosink->fd, SNDCTL_DSP_GETBLKSIZE, &frag);
|
||||
|
||||
ioctl(audiosink->fd,SNDCTL_DSP_GETOSPACE,&ospace);
|
||||
ioctl (audiosink->fd, SNDCTL_DSP_GETOSPACE, &ospace);
|
||||
|
||||
g_print("audiosink: setting sound card to %dKHz %d bit %s (%d bytes buffer, %d fragment)\n",
|
||||
audiosink->frequency,audiosink->format,
|
||||
(audiosink->channels == 2) ? "stereo" : "mono",ospace.bytes, frag);
|
||||
audiosink->frequency, audiosink->format,
|
||||
(audiosink->channels == 2) ? "stereo" : "mono", ospace.bytes, frag);
|
||||
|
||||
}
|
||||
|
||||
GstElement *gst_audiosink_new(gchar *name) {
|
||||
GstElement *audiosink = GST_ELEMENT(gtk_type_new(GST_TYPE_AUDIOSINK));
|
||||
gst_element_set_name(GST_ELEMENT(audiosink),name);
|
||||
return audiosink;
|
||||
}
|
||||
|
||||
void gst_audiosink_chain(GstPad *pad,GstBuffer *buf) {
|
||||
static void
|
||||
gst_audiosink_chain (GstPad *pad, GstBuffer *buf)
|
||||
{
|
||||
GstAudioSink *audiosink;
|
||||
MetaAudioRaw *meta;
|
||||
gboolean in_flush;
|
||||
audio_buf_info ospace;
|
||||
|
||||
g_return_if_fail(pad != NULL);
|
||||
g_return_if_fail(GST_IS_PAD(pad));
|
||||
g_return_if_fail(buf != NULL);
|
||||
g_return_if_fail (pad != NULL);
|
||||
g_return_if_fail (GST_IS_PAD (pad));
|
||||
g_return_if_fail (buf != NULL);
|
||||
|
||||
|
||||
/* this has to be an audio buffer */
|
||||
// g_return_if_fail(((GstMeta *)buf->meta)->type !=
|
||||
//gst_audiosink_type_audio);
|
||||
audiosink = GST_AUDIOSINK(pad->parent);
|
||||
audiosink = GST_AUDIOSINK (pad->parent);
|
||||
// g_return_if_fail(GST_FLAG_IS_SET(audiosink,GST_STATE_RUNNING));
|
||||
|
||||
if ((in_flush = GST_BUFFER_FLAG_IS_SET(buf, GST_BUFFER_FLUSH))) {
|
||||
DEBUG("audiosink: flush\n");
|
||||
ioctl(audiosink->fd,SNDCTL_DSP_RESET,0);
|
||||
if ((in_flush = GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLUSH))) {
|
||||
DEBUG ("audiosink: flush\n");
|
||||
ioctl (audiosink->fd, SNDCTL_DSP_RESET, 0);
|
||||
}
|
||||
|
||||
|
||||
meta = (MetaAudioRaw *)gst_buffer_get_first_meta(buf);
|
||||
meta = (MetaAudioRaw *)gst_buffer_get_first_meta (buf);
|
||||
if (meta != NULL) {
|
||||
if ((meta->format != audiosink->format) ||
|
||||
(meta->channels != audiosink->channels) ||
|
||||
(meta->frequency != audiosink->frequency)) {
|
||||
audiosink->format = meta->format;
|
||||
audiosink->channels = meta->channels;
|
||||
(meta->frequency != audiosink->frequency))
|
||||
{
|
||||
audiosink->format = meta->format;
|
||||
audiosink->channels = meta->channels;
|
||||
audiosink->frequency = meta->frequency;
|
||||
gst_audiosink_sync_parms(audiosink);
|
||||
gst_audiosink_sync_parms (audiosink);
|
||||
g_print("audiosink: sound device set to format %d, %d channels, %dHz\n",
|
||||
audiosink->format,audiosink->channels,audiosink->frequency);
|
||||
audiosink->format, audiosink->channels, audiosink->frequency);
|
||||
}
|
||||
}
|
||||
|
||||
gtk_signal_emit(GTK_OBJECT(audiosink),gst_audiosink_signals[SIGNAL_HANDOFF],
|
||||
gtk_signal_emit (GTK_OBJECT (audiosink), gst_audiosink_signals[SIGNAL_HANDOFF],
|
||||
audiosink);
|
||||
|
||||
if (GST_BUFFER_DATA(buf) != NULL) {
|
||||
gst_trace_add_entry(NULL,0,buf,"audiosink: writing to soundcard");
|
||||
if (GST_BUFFER_DATA (buf) != NULL) {
|
||||
gst_trace_add_entry(NULL, 0, buf, "audiosink: writing to soundcard");
|
||||
//g_print("audiosink: writing to soundcard\n");
|
||||
if (audiosink->fd > 2) {
|
||||
if (!audiosink->mute) {
|
||||
gst_clock_wait(audiosink->clock, GST_BUFFER_TIMESTAMP(buf), GST_OBJECT(audiosink));
|
||||
ioctl(audiosink->fd,SNDCTL_DSP_GETOSPACE,&ospace);
|
||||
DEBUG("audiosink: (%d bytes buffer) %d %p %d\n", ospace.bytes, audiosink->fd, GST_BUFFER_DATA(buf), GST_BUFFER_SIZE(buf));
|
||||
write(audiosink->fd,GST_BUFFER_DATA(buf),GST_BUFFER_SIZE(buf));
|
||||
gst_clock_wait (audiosink->clock, GST_BUFFER_TIMESTAMP (buf), GST_OBJECT (audiosink));
|
||||
ioctl (audiosink->fd, SNDCTL_DSP_GETOSPACE, &ospace);
|
||||
DEBUG ("audiosink: (%d bytes buffer) %d %p %d\n", ospace.bytes,
|
||||
audiosink->fd, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
|
||||
write (audiosink->fd, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
|
||||
//write(STDOUT_FILENO,GST_BUFFER_DATA(buf),GST_BUFFER_SIZE(buf));
|
||||
}
|
||||
}
|
||||
}
|
||||
gst_buffer_unref(buf);
|
||||
gst_buffer_unref (buf);
|
||||
}
|
||||
|
||||
static void gst_audiosink_set_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_audiosink_set_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstAudioSink *audiosink;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_AUDIOSINK(object));
|
||||
audiosink = GST_AUDIOSINK(object);
|
||||
g_return_if_fail (GST_IS_AUDIOSINK (object));
|
||||
|
||||
audiosink = GST_AUDIOSINK (object);
|
||||
|
||||
switch(id) {
|
||||
case ARG_MUTE:
|
||||
audiosink->mute = GTK_VALUE_BOOL(*arg);
|
||||
audiosink->mute = GTK_VALUE_BOOL (*arg);
|
||||
break;
|
||||
case ARG_FORMAT:
|
||||
audiosink->format = GTK_VALUE_ENUM(*arg);
|
||||
gst_audiosink_sync_parms(audiosink);
|
||||
audiosink->format = GTK_VALUE_ENUM (*arg);
|
||||
gst_audiosink_sync_parms (audiosink);
|
||||
break;
|
||||
case ARG_CHANNELS:
|
||||
audiosink->channels = GTK_VALUE_ENUM(*arg);
|
||||
gst_audiosink_sync_parms(audiosink);
|
||||
audiosink->channels = GTK_VALUE_ENUM (*arg);
|
||||
gst_audiosink_sync_parms (audiosink);
|
||||
break;
|
||||
case ARG_FREQUENCY:
|
||||
audiosink->frequency = GTK_VALUE_INT(*arg);
|
||||
gst_audiosink_sync_parms(audiosink);
|
||||
audiosink->frequency = GTK_VALUE_INT (*arg);
|
||||
gst_audiosink_sync_parms (audiosink);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void gst_audiosink_get_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_audiosink_get_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstAudioSink *audiosink;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_AUDIOSINK(object));
|
||||
audiosink = GST_AUDIOSINK(object);
|
||||
g_return_if_fail (GST_IS_AUDIOSINK (object));
|
||||
|
||||
audiosink = GST_AUDIOSINK (object);
|
||||
|
||||
switch(id) {
|
||||
case ARG_MUTE:
|
||||
GTK_VALUE_BOOL(*arg) = audiosink->mute;
|
||||
GTK_VALUE_BOOL (*arg) = audiosink->mute;
|
||||
break;
|
||||
case ARG_FORMAT:
|
||||
GTK_VALUE_ENUM(*arg) = audiosink->format;
|
||||
GTK_VALUE_ENUM (*arg) = audiosink->format;
|
||||
break;
|
||||
case ARG_CHANNELS:
|
||||
GTK_VALUE_ENUM(*arg) = audiosink->channels;
|
||||
GTK_VALUE_ENUM (*arg) = audiosink->channels;
|
||||
break;
|
||||
case ARG_FREQUENCY:
|
||||
GTK_VALUE_INT(*arg) = audiosink->frequency;
|
||||
GTK_VALUE_INT (*arg) = audiosink->frequency;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean gst_audiosink_open_audio(GstAudioSink *sink) {
|
||||
g_return_val_if_fail(sink->fd == -1, FALSE);
|
||||
static gboolean
|
||||
gst_audiosink_open_audio (GstAudioSink *sink)
|
||||
{
|
||||
g_return_val_if_fail (sink->fd == -1, FALSE);
|
||||
|
||||
g_print("audiosink: attempting to open sound device\n");
|
||||
g_print ("audiosink: attempting to open sound device\n");
|
||||
|
||||
/* first try to open the sound card */
|
||||
sink->fd = open("/dev/dsp",O_WRONLY);
|
||||
sink->fd = open("/dev/dsp", O_WRONLY);
|
||||
|
||||
/* if we have it, set the default parameters and go have fun */
|
||||
if (sink->fd > 0) {
|
||||
|
@ -331,59 +342,69 @@ static gboolean gst_audiosink_open_audio(GstAudioSink *sink) {
|
|||
sink->format = AFMT_S16_LE;
|
||||
sink->channels = 2; /* stereo */
|
||||
sink->frequency = 44100;
|
||||
gst_audiosink_sync_parms(sink);
|
||||
ioctl(sink->fd,SNDCTL_DSP_GETCAPS,&sink->caps);
|
||||
gst_audiosink_sync_parms (sink);
|
||||
ioctl(sink->fd, SNDCTL_DSP_GETCAPS, &sink->caps);
|
||||
|
||||
g_print("audiosink: Capabilities\n");
|
||||
|
||||
if (sink->caps & DSP_CAP_DUPLEX) g_print("audiosink: Full duplex\n");
|
||||
if (sink->caps & DSP_CAP_REALTIME) g_print("audiosink: Realtime\n");
|
||||
if (sink->caps & DSP_CAP_BATCH) g_print("audiosink: Batch\n");
|
||||
if (sink->caps & DSP_CAP_COPROC) g_print("audiosink: Has coprocessor\n");
|
||||
if (sink->caps & DSP_CAP_TRIGGER) g_print("audiosink: Trigger\n");
|
||||
if (sink->caps & DSP_CAP_MMAP) g_print("audiosink: Direct access\n");
|
||||
|
||||
g_print("audiosink: opened audio with fd=%d\n", sink->fd);
|
||||
GST_FLAG_SET(sink,GST_AUDIOSINK_OPEN);
|
||||
GST_FLAG_SET (sink, GST_AUDIOSINK_OPEN);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void gst_audiosink_close_audio(GstAudioSink *sink) {
|
||||
static void
|
||||
gst_audiosink_close_audio (GstAudioSink *sink)
|
||||
{
|
||||
if (sink->fd < 0) return;
|
||||
|
||||
close(sink->fd);
|
||||
sink->fd = -1;
|
||||
GST_FLAG_UNSET(sink,GST_AUDIOSINK_OPEN);
|
||||
|
||||
GST_FLAG_UNSET (sink, GST_AUDIOSINK_OPEN);
|
||||
|
||||
g_print("audiosink: closed sound device\n");
|
||||
}
|
||||
|
||||
static GstElementStateReturn gst_audiosink_change_state(GstElement *element) {
|
||||
g_return_val_if_fail(GST_IS_AUDIOSINK(element), FALSE);
|
||||
static GstElementStateReturn
|
||||
gst_audiosink_change_state (GstElement *element)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_AUDIOSINK (element), FALSE);
|
||||
|
||||
/* if going down into NULL state, close the file if it's open */
|
||||
if (GST_STATE_PENDING(element) == GST_STATE_NULL) {
|
||||
if (GST_FLAG_IS_SET(element,GST_AUDIOSINK_OPEN))
|
||||
gst_audiosink_close_audio(GST_AUDIOSINK(element));
|
||||
if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
|
||||
if (GST_FLAG_IS_SET (element, GST_AUDIOSINK_OPEN))
|
||||
gst_audiosink_close_audio (GST_AUDIOSINK (element));
|
||||
/* otherwise (READY or higher) we need to open the sound card */
|
||||
} else {
|
||||
if (!GST_FLAG_IS_SET(element,GST_AUDIOSINK_OPEN)) {
|
||||
if (!gst_audiosink_open_audio(GST_AUDIOSINK(element)))
|
||||
if (!GST_FLAG_IS_SET (element, GST_AUDIOSINK_OPEN)) {
|
||||
if (!gst_audiosink_open_audio (GST_AUDIOSINK (element)))
|
||||
return GST_STATE_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (GST_ELEMENT_CLASS(parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS(parent_class)->change_state(element);
|
||||
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
||||
return GST_STATE_SUCCESS;
|
||||
}
|
||||
|
||||
gboolean gst_audiosink_factory_init(GstElementFactory *factory) {
|
||||
|
||||
gboolean
|
||||
gst_audiosink_factory_init (GstElementFactory *factory)
|
||||
{
|
||||
if (!gst_audiosink_type_audio)
|
||||
gst_audiosink_type_audio = gst_type_find_by_mime("audio/raw");
|
||||
gst_audiosink_type_audio = gst_type_find_by_mime ("audio/raw");
|
||||
|
||||
gst_type_add_sink(gst_audiosink_type_audio, factory);
|
||||
gst_type_add_sink (gst_audiosink_type_audio, factory);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -53,23 +53,25 @@ enum {
|
|||
};
|
||||
|
||||
|
||||
static void gst_audiosrc_class_init(GstAudioSrcClass *klass);
|
||||
static void gst_audiosrc_init(GstAudioSrc *audiosrc);
|
||||
static void gst_audiosrc_set_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_audiosrc_get_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static GstElementStateReturn gst_audiosrc_change_state(GstElement *element);
|
||||
static void gst_audiosrc_class_init (GstAudioSrcClass *klass);
|
||||
static void gst_audiosrc_init (GstAudioSrc *audiosrc);
|
||||
|
||||
static void gst_audiosrc_close_audio(GstAudioSrc *src);
|
||||
static gboolean gst_audiosrc_open_audio(GstAudioSrc *src);
|
||||
void gst_audiosrc_sync_parms(GstAudioSrc *audiosrc);
|
||||
static void gst_audiosrc_set_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
static void gst_audiosrc_get_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
static GstElementStateReturn gst_audiosrc_change_state (GstElement *element);
|
||||
|
||||
void gst_audiosrc_push(GstSrc *src);
|
||||
static void gst_audiosrc_close_audio (GstAudioSrc *src);
|
||||
static gboolean gst_audiosrc_open_audio (GstAudioSrc *src);
|
||||
static void gst_audiosrc_sync_parms (GstAudioSrc *audiosrc);
|
||||
|
||||
static void gst_audiosrc_push (GstSrc *src);
|
||||
|
||||
static GstSrcClass *parent_class = NULL;
|
||||
//static guint gst_audiosrc_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
GtkType
|
||||
gst_audiosrc_get_type(void) {
|
||||
gst_audiosrc_get_type (void)
|
||||
{
|
||||
static GtkType audiosrc_type = 0;
|
||||
|
||||
if (!audiosrc_type) {
|
||||
|
@ -83,13 +85,14 @@ gst_audiosrc_get_type(void) {
|
|||
(GtkArgGetFunc)gst_audiosrc_get_arg,
|
||||
(GtkClassInitFunc)NULL,
|
||||
};
|
||||
audiosrc_type = gtk_type_unique(GST_TYPE_SRC,&audiosrc_info);
|
||||
audiosrc_type = gtk_type_unique (GST_TYPE_SRC, &audiosrc_info);
|
||||
}
|
||||
return audiosrc_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_audiosrc_class_init(GstAudioSrcClass *klass) {
|
||||
gst_audiosrc_class_init (GstAudioSrcClass *klass)
|
||||
{
|
||||
GtkObjectClass *gtkobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
GstSrcClass *gstsrc_class;
|
||||
|
@ -98,18 +101,18 @@ gst_audiosrc_class_init(GstAudioSrcClass *klass) {
|
|||
gstelement_class = (GstElementClass*)klass;
|
||||
gstsrc_class = (GstSrcClass*)klass;
|
||||
|
||||
parent_class = gtk_type_class(GST_TYPE_SRC);
|
||||
parent_class = gtk_type_class (GST_TYPE_SRC);
|
||||
|
||||
gtk_object_add_arg_type("GstAudioSrc::bytes_per_read", GTK_TYPE_ULONG,
|
||||
GTK_ARG_READWRITE, ARG_BYTESPERREAD);
|
||||
gtk_object_add_arg_type("GstAudioSrc::curoffset", GTK_TYPE_ULONG,
|
||||
GTK_ARG_READABLE, ARG_CUROFFSET);
|
||||
gtk_object_add_arg_type("GstAudioSrc::format", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_FORMAT);
|
||||
gtk_object_add_arg_type("GstAudioSrc::channels", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_CHANNELS);
|
||||
gtk_object_add_arg_type("GstAudioSrc::frequency", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_FREQUENCY);
|
||||
gtk_object_add_arg_type ("GstAudioSrc::bytes_per_read", GTK_TYPE_ULONG,
|
||||
GTK_ARG_READWRITE, ARG_BYTESPERREAD);
|
||||
gtk_object_add_arg_type ("GstAudioSrc::curoffset", GTK_TYPE_ULONG,
|
||||
GTK_ARG_READABLE, ARG_CUROFFSET);
|
||||
gtk_object_add_arg_type ("GstAudioSrc::format", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_FORMAT);
|
||||
gtk_object_add_arg_type ("GstAudioSrc::channels", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_CHANNELS);
|
||||
gtk_object_add_arg_type ("GstAudioSrc::frequency", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_FREQUENCY);
|
||||
|
||||
gtkobject_class->set_arg = gst_audiosrc_set_arg;
|
||||
gtkobject_class->get_arg = gst_audiosrc_get_arg;
|
||||
|
@ -119,9 +122,11 @@ gst_audiosrc_class_init(GstAudioSrcClass *klass) {
|
|||
gstsrc_class->push = gst_audiosrc_push;
|
||||
}
|
||||
|
||||
static void gst_audiosrc_init(GstAudioSrc *audiosrc) {
|
||||
audiosrc->srcpad = gst_pad_new("src",GST_PAD_SRC);
|
||||
gst_element_add_pad(GST_ELEMENT(audiosrc),audiosrc->srcpad);
|
||||
static void
|
||||
gst_audiosrc_init (GstAudioSrc *audiosrc)
|
||||
{
|
||||
audiosrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||
gst_element_add_pad (GST_ELEMENT (audiosrc), audiosrc->srcpad);
|
||||
|
||||
audiosrc->fd = -1;
|
||||
|
||||
|
@ -136,87 +141,93 @@ static void gst_audiosrc_init(GstAudioSrc *audiosrc) {
|
|||
audiosrc->seq = 0;
|
||||
}
|
||||
|
||||
GstElement *gst_audiosrc_new(gchar *name) {
|
||||
GstElement *audiosrc = GST_ELEMENT(gtk_type_new(GST_TYPE_AUDIOSRC));
|
||||
gst_element_set_name(GST_ELEMENT(audiosrc),name);
|
||||
return audiosrc;
|
||||
}
|
||||
|
||||
void gst_audiosrc_push(GstSrc *src) {
|
||||
static void
|
||||
gst_audiosrc_push (GstSrc *src)
|
||||
{
|
||||
GstAudioSrc *audiosrc;
|
||||
GstBuffer *buf;
|
||||
glong readbytes;
|
||||
|
||||
g_return_if_fail(src != NULL);
|
||||
g_return_if_fail(GST_IS_AUDIOSRC(src));
|
||||
audiosrc = GST_AUDIOSRC(src);
|
||||
g_return_if_fail (src != NULL);
|
||||
g_return_if_fail (GST_IS_AUDIOSRC (src));
|
||||
audiosrc = GST_AUDIOSRC (src);
|
||||
|
||||
// g_print("attempting to read something from soundcard\n");
|
||||
|
||||
buf = gst_buffer_new();
|
||||
g_return_if_fail(buf);
|
||||
GST_BUFFER_DATA(buf) = (gpointer)g_malloc(audiosrc->bytes_per_read);
|
||||
readbytes = read(audiosrc->fd,GST_BUFFER_DATA(buf),
|
||||
audiosrc->bytes_per_read);
|
||||
buf = gst_buffer_new ();
|
||||
g_return_if_fail (buf);
|
||||
|
||||
GST_BUFFER_DATA (buf) = (gpointer)g_malloc (audiosrc->bytes_per_read);
|
||||
|
||||
readbytes = read (audiosrc->fd,GST_BUFFER_DATA (buf),
|
||||
audiosrc->bytes_per_read);
|
||||
|
||||
if (readbytes == 0) {
|
||||
gst_src_signal_eos(GST_SRC(audiosrc));
|
||||
gst_src_signal_eos (GST_SRC (audiosrc));
|
||||
return;
|
||||
}
|
||||
|
||||
GST_BUFFER_SIZE(buf) = readbytes;
|
||||
GST_BUFFER_OFFSET(buf) = audiosrc->curoffset;
|
||||
GST_BUFFER_SIZE (buf) = readbytes;
|
||||
GST_BUFFER_OFFSET (buf) = audiosrc->curoffset;
|
||||
|
||||
audiosrc->curoffset += readbytes;
|
||||
|
||||
// gst_buffer_add_meta(buf,GST_META(newmeta));
|
||||
|
||||
gst_pad_push(audiosrc->srcpad,buf);
|
||||
gst_pad_push (audiosrc->srcpad,buf);
|
||||
// g_print("pushed buffer from soundcard of %d bytes\n",readbytes);
|
||||
}
|
||||
|
||||
static void gst_audiosrc_set_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_audiosrc_set_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstAudioSrc *src;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_AUDIOSRC(object));
|
||||
src = GST_AUDIOSRC(object);
|
||||
g_return_if_fail (GST_IS_AUDIOSRC (object));
|
||||
|
||||
src = GST_AUDIOSRC (object);
|
||||
|
||||
switch (id) {
|
||||
case ARG_BYTESPERREAD:
|
||||
src->bytes_per_read = GTK_VALUE_INT(*arg);
|
||||
src->bytes_per_read = GTK_VALUE_INT (*arg);
|
||||
break;
|
||||
case ARG_FORMAT:
|
||||
src->format = GTK_VALUE_INT(*arg);
|
||||
src->format = GTK_VALUE_INT (*arg);
|
||||
break;
|
||||
case ARG_CHANNELS:
|
||||
src->channels = GTK_VALUE_INT(*arg);
|
||||
src->channels = GTK_VALUE_INT (*arg);
|
||||
break;
|
||||
case ARG_FREQUENCY:
|
||||
src->frequency = GTK_VALUE_INT(*arg);
|
||||
src->frequency = GTK_VALUE_INT (*arg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void gst_audiosrc_get_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_audiosrc_get_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstAudioSrc *src;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_AUDIOSRC(object));
|
||||
src = GST_AUDIOSRC(object);
|
||||
g_return_if_fail (GST_IS_AUDIOSRC (object));
|
||||
|
||||
src = GST_AUDIOSRC (object);
|
||||
|
||||
switch (id) {
|
||||
case ARG_BYTESPERREAD:
|
||||
GTK_VALUE_INT(*arg) = src->bytes_per_read;
|
||||
GTK_VALUE_INT (*arg) = src->bytes_per_read;
|
||||
break;
|
||||
case ARG_FORMAT:
|
||||
GTK_VALUE_INT(*arg) = src->format;
|
||||
GTK_VALUE_INT (*arg) = src->format;
|
||||
break;
|
||||
case ARG_CHANNELS:
|
||||
GTK_VALUE_INT(*arg) = src->channels;
|
||||
GTK_VALUE_INT (*arg) = src->channels;
|
||||
break;
|
||||
case ARG_FREQUENCY:
|
||||
GTK_VALUE_INT(*arg) = src->frequency;
|
||||
GTK_VALUE_INT (*arg) = src->frequency;
|
||||
break;
|
||||
default:
|
||||
arg->type = GTK_TYPE_INVALID;
|
||||
|
@ -224,71 +235,81 @@ static void gst_audiosrc_get_arg(GtkObject *object,GtkArg *arg,guint id) {
|
|||
}
|
||||
}
|
||||
|
||||
static GstElementStateReturn gst_audiosrc_change_state(GstElement *element) {
|
||||
g_return_val_if_fail(GST_IS_AUDIOSRC(element), FALSE);
|
||||
static GstElementStateReturn
|
||||
gst_audiosrc_change_state (GstElement *element)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_AUDIOSRC (element), FALSE);
|
||||
|
||||
/* if going down into NULL state, close the file if it's open */
|
||||
if (GST_STATE_PENDING(element) == GST_STATE_NULL) {
|
||||
if (GST_FLAG_IS_SET(element,GST_AUDIOSRC_OPEN))
|
||||
gst_audiosrc_close_audio(GST_AUDIOSRC(element));
|
||||
if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
|
||||
if (GST_FLAG_IS_SET (element, GST_AUDIOSRC_OPEN))
|
||||
gst_audiosrc_close_audio (GST_AUDIOSRC (element));
|
||||
/* otherwise (READY or higher) we need to open the sound card */
|
||||
} else {
|
||||
if (!GST_FLAG_IS_SET(element,GST_AUDIOSRC_OPEN)) {
|
||||
if (!gst_audiosrc_open_audio(GST_AUDIOSRC(element)))
|
||||
if (!GST_FLAG_IS_SET (element, GST_AUDIOSRC_OPEN)) {
|
||||
if (!gst_audiosrc_open_audio (GST_AUDIOSRC (element)))
|
||||
return GST_STATE_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (GST_ELEMENT_CLASS(parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS(parent_class)->change_state(element);
|
||||
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
||||
|
||||
return GST_STATE_SUCCESS;
|
||||
}
|
||||
|
||||
static gboolean gst_audiosrc_open_audio(GstAudioSrc *src) {
|
||||
g_return_val_if_fail(!GST_FLAG_IS_SET(src,GST_AUDIOSRC_OPEN), FALSE);
|
||||
static gboolean
|
||||
gst_audiosrc_open_audio (GstAudioSrc *src)
|
||||
{
|
||||
g_return_val_if_fail (!GST_FLAG_IS_SET (src, GST_AUDIOSRC_OPEN), FALSE);
|
||||
|
||||
/* first try to open the sound card */
|
||||
src->fd = open("/dev/dsp",O_RDONLY);
|
||||
src->fd = open("/dev/dsp", O_RDONLY);
|
||||
|
||||
/* if we have it, set the default parameters and go have fun */
|
||||
if (src->fd > 0) {
|
||||
int arg = 0x7fff0006;
|
||||
|
||||
if (ioctl(src->fd, SNDCTL_DSP_SETFRAGMENT, &arg)) perror("uh");
|
||||
if (ioctl (src->fd, SNDCTL_DSP_SETFRAGMENT, &arg)) perror("uh");
|
||||
|
||||
/* set card state */
|
||||
gst_audiosrc_sync_parms(src);
|
||||
gst_audiosrc_sync_parms (src);
|
||||
DEBUG("opened audio\n");
|
||||
GST_FLAG_SET(src,GST_AUDIOSRC_OPEN);
|
||||
|
||||
GST_FLAG_SET (src, GST_AUDIOSRC_OPEN);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void gst_audiosrc_close_audio(GstAudioSrc *src) {
|
||||
g_return_if_fail(GST_FLAG_IS_SET(src,GST_AUDIOSRC_OPEN));
|
||||
static void
|
||||
gst_audiosrc_close_audio (GstAudioSrc *src)
|
||||
{
|
||||
g_return_if_fail (GST_FLAG_IS_SET (src, GST_AUDIOSRC_OPEN));
|
||||
|
||||
close(src->fd);
|
||||
src->fd = -1;
|
||||
|
||||
GST_FLAG_UNSET(src,GST_AUDIOSRC_OPEN);
|
||||
GST_FLAG_UNSET (src, GST_AUDIOSRC_OPEN);
|
||||
}
|
||||
|
||||
void gst_audiosrc_sync_parms(GstAudioSrc *audiosrc) {
|
||||
static void
|
||||
gst_audiosrc_sync_parms (GstAudioSrc *audiosrc)
|
||||
{
|
||||
audio_buf_info ospace;
|
||||
|
||||
g_return_if_fail(audiosrc != NULL);
|
||||
g_return_if_fail(GST_IS_AUDIOSRC(audiosrc));
|
||||
g_return_if_fail(audiosrc->fd > 0);
|
||||
g_return_if_fail (audiosrc != NULL);
|
||||
g_return_if_fail (GST_IS_AUDIOSRC (audiosrc));
|
||||
g_return_if_fail (audiosrc->fd > 0);
|
||||
|
||||
ioctl(audiosrc->fd,SNDCTL_DSP_RESET,0);
|
||||
ioctl(audiosrc->fd, SNDCTL_DSP_RESET, 0);
|
||||
|
||||
ioctl(audiosrc->fd,SNDCTL_DSP_SETFMT,&audiosrc->format);
|
||||
ioctl(audiosrc->fd,SNDCTL_DSP_CHANNELS,&audiosrc->channels);
|
||||
ioctl(audiosrc->fd,SNDCTL_DSP_SPEED,&audiosrc->frequency);
|
||||
ioctl(audiosrc->fd, SNDCTL_DSP_SETFMT, &audiosrc->format);
|
||||
ioctl(audiosrc->fd, SNDCTL_DSP_CHANNELS, &audiosrc->channels);
|
||||
ioctl(audiosrc->fd, SNDCTL_DSP_SPEED, &audiosrc->frequency);
|
||||
|
||||
ioctl(audiosrc->fd,SNDCTL_DSP_GETOSPACE,&ospace);
|
||||
ioctl(audiosrc->fd, SNDCTL_DSP_GETOSPACE, &ospace);
|
||||
|
||||
g_print("setting sound card to %dKHz %d bit %s (%d bytes buffer)\n",
|
||||
audiosrc->frequency,audiosrc->format,
|
||||
|
|
|
@ -44,7 +44,7 @@ GstElementDetails gst_audiosrc_details;
|
|||
#define GST_IS_AUDIOSRC(obj) \
|
||||
(GTK_CHECK_TYPE((obj),GST_TYPE_AUDIOSRC))
|
||||
#define GST_IS_AUDIOSRC_CLASS(obj) \
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIOSRC)))
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIOSRC))
|
||||
|
||||
// NOTE: per-element flags start with 16 for now
|
||||
typedef enum {
|
||||
|
|
|
@ -45,30 +45,32 @@ struct _elements_entry {
|
|||
gboolean (*factoryinit) (GstElementFactory *factory);
|
||||
};
|
||||
|
||||
struct _elements_entry _elements[] = {
|
||||
{ "fakesrc", gst_fakesrc_get_type, &gst_fakesrc_details, NULL },
|
||||
{ "fakesink", gst_fakesink_get_type, &gst_fakesink_details, NULL },
|
||||
{ "asyncdisksrc", gst_asyncdisksrc_get_type, &gst_asyncdisksrc_details, NULL },
|
||||
{ "audiosink", gst_audiosink_get_type, &gst_audiosink_details, gst_audiosink_factory_init },
|
||||
{ "audiosrc", gst_audiosrc_get_type, &gst_audiosrc_details, NULL },
|
||||
{ "disksrc", gst_disksrc_get_type, &gst_disksrc_details, NULL },
|
||||
{ "identity", gst_identity_get_type, &gst_identity_details, NULL },
|
||||
{ "fdsink", gst_fdsink_get_type, &gst_fdsink_details, NULL },
|
||||
{ "fdsrc", gst_fdsrc_get_type, &gst_fdsrc_details, NULL },
|
||||
static struct _elements_entry _elements[] = {
|
||||
{ "fakesrc", gst_fakesrc_get_type, &gst_fakesrc_details, NULL },
|
||||
{ "fakesink", gst_fakesink_get_type, &gst_fakesink_details, NULL },
|
||||
{ "asyncdisksrc", gst_asyncdisksrc_get_type, &gst_asyncdisksrc_details, NULL },
|
||||
{ "audiosink", gst_audiosink_get_type, &gst_audiosink_details, gst_audiosink_factory_init },
|
||||
{ "audiosrc", gst_audiosrc_get_type, &gst_audiosrc_details, NULL },
|
||||
{ "disksrc", gst_disksrc_get_type, &gst_disksrc_details, NULL },
|
||||
{ "identity", gst_identity_get_type, &gst_identity_details, NULL },
|
||||
{ "fdsink", gst_fdsink_get_type, &gst_fdsink_details, NULL },
|
||||
{ "fdsrc", gst_fdsrc_get_type, &gst_fdsrc_details, NULL },
|
||||
#if HAVE_LIBGHTTP
|
||||
{ "httpsrc", gst_httpsrc_get_type, &gst_httpsrc_details, NULL },
|
||||
{ "httpsrc", gst_httpsrc_get_type, &gst_httpsrc_details, NULL },
|
||||
#endif /* HAVE_LIBGHTTP */
|
||||
{ "pipefilter", gst_pipefilter_get_type, &gst_pipefilter_details, NULL },
|
||||
{ "queue", gst_queue_get_type, &gst_queue_details, NULL },
|
||||
{ "sinesrc", gst_sinesrc_get_type, &gst_sinesrc_details, NULL },
|
||||
{ "typefind", gst_typefind_get_type, &gst_typefind_details, NULL },
|
||||
{ "pipefilter", gst_pipefilter_get_type, &gst_pipefilter_details, NULL },
|
||||
{ "queue", gst_queue_get_type, &gst_queue_details, NULL },
|
||||
{ "sinesrc", gst_sinesrc_get_type, &gst_sinesrc_details, NULL },
|
||||
{ "typefind", gst_typefind_get_type, &gst_typefind_details, NULL },
|
||||
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
||||
GstPlugin *plugin_init(GModule *module) {
|
||||
GstPlugin *plugin_init (GModule *module)
|
||||
{
|
||||
GstPlugin *plugin;
|
||||
GstElementFactory *factory;
|
||||
int i = 0;
|
||||
gint i = 0;
|
||||
|
||||
/* we depend on having the usual types loaded first */
|
||||
gst_plugin_load("gsttypes");
|
||||
|
@ -76,23 +78,23 @@ GstPlugin *plugin_init(GModule *module) {
|
|||
plugin = gst_plugin_new("gstelements");
|
||||
g_return_val_if_fail(plugin != NULL,NULL);
|
||||
|
||||
gst_plugin_set_longname(plugin,"Standard GST Elements");
|
||||
gst_plugin_set_longname (plugin, "Standard GST Elements");
|
||||
|
||||
while (_elements[i].name) {
|
||||
factory = gst_elementfactory_new(_elements[i].name,
|
||||
(_elements[i].type)(),
|
||||
_elements[i].details);
|
||||
factory = gst_elementfactory_new (_elements[i].name,
|
||||
(_elements[i].type) (),
|
||||
_elements[i].details);
|
||||
if (factory != NULL) {
|
||||
gst_plugin_add_factory(plugin,factory);
|
||||
gst_plugin_add_factory (plugin, factory);
|
||||
if (_elements[i].factoryinit) {
|
||||
_elements[i].factoryinit(factory);
|
||||
_elements[i].factoryinit (factory);
|
||||
}
|
||||
// g_print("added factory '%s'\n",_elements[i].name);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
gst_info("gstelements: loaded %d standard elements\n",i);
|
||||
gst_info ("gstelements: loaded %d standard elements\n", i);
|
||||
|
||||
return plugin;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ extern "C" {
|
|||
#define GST_IS_ESDSINK(obj) \
|
||||
(GTK_CHECK_TYPE((obj),GST_TYPE_ESDSINK))
|
||||
#define GST_IS_ESDSINK_CLASS(obj) \
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_ESDSINK)))
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_ESDSINK))
|
||||
|
||||
typedef struct _GstEsdSink GstEsdSink;
|
||||
typedef struct _GstEsdSinkClass GstEsdSinkClass;
|
||||
|
|
|
@ -46,14 +46,14 @@ enum {
|
|||
static void gst_fakesink_class_init(GstFakeSinkClass *klass);
|
||||
static void gst_fakesink_init(GstFakeSink *fakesink);
|
||||
|
||||
GstElement *gst_fakesink_new(gchar *name);
|
||||
void gst_fakesink_chain(GstPad *pad,GstBuffer *buf);
|
||||
static void gst_fakesink_chain(GstPad *pad,GstBuffer *buf);
|
||||
|
||||
static GstSinkClass *parent_class = NULL;
|
||||
//static guint gst_fakesink_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
GtkType
|
||||
gst_fakesink_get_type(void) {
|
||||
gst_fakesink_get_type (void)
|
||||
{
|
||||
static GtkType fakesink_type = 0;
|
||||
|
||||
if (!fakesink_type) {
|
||||
|
@ -67,43 +67,32 @@ gst_fakesink_get_type(void) {
|
|||
(GtkArgGetFunc)NULL,
|
||||
(GtkClassInitFunc)NULL,
|
||||
};
|
||||
fakesink_type = gtk_type_unique(GST_TYPE_SINK,&fakesink_info);
|
||||
fakesink_type = gtk_type_unique (GST_TYPE_SINK, &fakesink_info);
|
||||
}
|
||||
return fakesink_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_fakesink_class_init(GstFakeSinkClass *klass) {
|
||||
gst_fakesink_class_init (GstFakeSinkClass *klass)
|
||||
{
|
||||
GstSinkClass *gstsink_class;
|
||||
|
||||
gstsink_class = (GstSinkClass*)klass;
|
||||
|
||||
parent_class = gtk_type_class(GST_TYPE_SINK);
|
||||
parent_class = gtk_type_class (GST_TYPE_SINK);
|
||||
}
|
||||
|
||||
static void gst_fakesink_init(GstFakeSink *fakesink) {
|
||||
fakesink->sinkpad = gst_pad_new("sink",GST_PAD_SINK);
|
||||
gst_element_add_pad(GST_ELEMENT(fakesink),fakesink->sinkpad);
|
||||
gst_pad_set_chain_function(fakesink->sinkpad,gst_fakesink_chain);
|
||||
static void
|
||||
gst_fakesink_init (GstFakeSink *fakesink)
|
||||
{
|
||||
fakesink->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
|
||||
gst_element_add_pad (GST_ELEMENT (fakesink), fakesink->sinkpad);
|
||||
gst_pad_set_chain_function (fakesink->sinkpad, gst_fakesink_chain);
|
||||
|
||||
// we're ready right away, since we don't have any args...
|
||||
// gst_element_set_state(GST_ELEMENT(fakesink),GST_STATE_READY);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_fakesink_new:
|
||||
* @name: the name of the new fakesrc
|
||||
*
|
||||
* create a new fakesink
|
||||
*
|
||||
* Returns: the new fakesink
|
||||
*/
|
||||
GstElement *gst_fakesink_new(gchar *name) {
|
||||
GstElement *fakesink = GST_ELEMENT(gtk_type_new(GST_TYPE_FAKESINK));
|
||||
gst_element_set_name(GST_ELEMENT(fakesink),name);
|
||||
return fakesink;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_fakesink_chain:
|
||||
* @pad: the pad this faksink is connected to
|
||||
|
@ -112,16 +101,19 @@ GstElement *gst_fakesink_new(gchar *name) {
|
|||
* take the buffer from the pad and unref it without doing
|
||||
* anything with it.
|
||||
*/
|
||||
void gst_fakesink_chain(GstPad *pad,GstBuffer *buf) {
|
||||
static void
|
||||
gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
|
||||
{
|
||||
GstFakeSink *fakesink;
|
||||
|
||||
g_return_if_fail(pad != NULL);
|
||||
g_return_if_fail(GST_IS_PAD(pad));
|
||||
g_return_if_fail(buf != NULL);
|
||||
g_return_if_fail (pad != NULL);
|
||||
g_return_if_fail (GST_IS_PAD (pad));
|
||||
g_return_if_fail (buf != NULL);
|
||||
|
||||
fakesink = GST_FAKESINK(pad->parent);
|
||||
fakesink = GST_FAKESINK (pad->parent);
|
||||
// g_print("gst_fakesink_chain: got buffer in '%s'\n",
|
||||
// gst_element_get_name(GST_ELEMENT(fakesink)));
|
||||
g_print("<");
|
||||
gst_buffer_unref(buf);
|
||||
|
||||
gst_buffer_unref (buf);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ GstElementDetails gst_fakesink_details;
|
|||
#define GST_IS_FAKESINK(obj) \
|
||||
(GTK_CHECK_TYPE((obj),GST_TYPE_FAKESINK))
|
||||
#define GST_IS_FAKESINK_CLASS(obj) \
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FAKESINK)))
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FAKESINK))
|
||||
|
||||
typedef struct _GstFakeSink GstFakeSink;
|
||||
typedef struct _GstFakeSinkClass GstFakeSinkClass;
|
||||
|
|
|
@ -43,16 +43,17 @@ enum {
|
|||
};
|
||||
|
||||
|
||||
static void gst_fakesrc_class_init(GstFakeSrcClass *klass);
|
||||
static void gst_fakesrc_init(GstFakeSrc *fakesrc);
|
||||
static void gst_fakesrc_class_init (GstFakeSrcClass *klass);
|
||||
static void gst_fakesrc_init (GstFakeSrc *fakesrc);
|
||||
|
||||
void gst_fakesrc_push(GstSrc *src);
|
||||
static void gst_fakesrc_push (GstSrc *src);
|
||||
|
||||
static GstSrcClass *parent_class = NULL;
|
||||
//static guint gst_fakesrc_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
GtkType
|
||||
gst_fakesrc_get_type(void) {
|
||||
gst_fakesrc_get_type (void)
|
||||
{
|
||||
static GtkType fakesrc_type = 0;
|
||||
|
||||
if (!fakesrc_type) {
|
||||
|
@ -66,62 +67,55 @@ gst_fakesrc_get_type(void) {
|
|||
(GtkArgGetFunc)NULL,
|
||||
(GtkClassInitFunc)NULL,
|
||||
};
|
||||
fakesrc_type = gtk_type_unique(GST_TYPE_SRC,&fakesrc_info);
|
||||
fakesrc_type = gtk_type_unique (GST_TYPE_SRC, &fakesrc_info);
|
||||
}
|
||||
return fakesrc_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_fakesrc_class_init(GstFakeSrcClass *klass) {
|
||||
gst_fakesrc_class_init (GstFakeSrcClass *klass)
|
||||
{
|
||||
GstSrcClass *gstsrc_class;
|
||||
|
||||
gstsrc_class = (GstSrcClass*)klass;
|
||||
|
||||
parent_class = gtk_type_class(GST_TYPE_SRC);
|
||||
parent_class = gtk_type_class (GST_TYPE_SRC);
|
||||
|
||||
gstsrc_class->push = gst_fakesrc_push;
|
||||
gstsrc_class->push_region = NULL;
|
||||
}
|
||||
|
||||
static void gst_fakesrc_init(GstFakeSrc *fakesrc) {
|
||||
fakesrc->srcpad = gst_pad_new("src",GST_PAD_SRC);
|
||||
gst_element_add_pad(GST_ELEMENT(fakesrc),fakesrc->srcpad);
|
||||
static void
|
||||
gst_fakesrc_init (GstFakeSrc *fakesrc)
|
||||
{
|
||||
fakesrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||
gst_element_add_pad (GST_ELEMENT (fakesrc), fakesrc->srcpad);
|
||||
|
||||
// we're ready right away, since we don't have any args...
|
||||
// gst_element_set_state(GST_ELEMENT(fakesrc),GST_STATE_READY);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_fakesrc_new:
|
||||
* @name: then name of the fakse source
|
||||
*
|
||||
* create a new fakesrc
|
||||
*
|
||||
* Returns: The new element.
|
||||
*/
|
||||
GstElement *gst_fakesrc_new(gchar *name) {
|
||||
GstElement *fakesrc = GST_ELEMENT(gtk_type_new(GST_TYPE_FAKESRC));
|
||||
gst_element_set_name(GST_ELEMENT(fakesrc),name);
|
||||
return fakesrc;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_fakesrc_push:
|
||||
* @src: the faksesrc to push
|
||||
*
|
||||
* generate an empty buffer and push it to the next element.
|
||||
*/
|
||||
void gst_fakesrc_push(GstSrc *src) {
|
||||
static void
|
||||
gst_fakesrc_push (GstSrc *src)
|
||||
{
|
||||
GstFakeSrc *fakesrc;
|
||||
GstBuffer *buf;
|
||||
|
||||
g_return_if_fail(src != NULL);
|
||||
g_return_if_fail(GST_IS_FAKESRC(src));
|
||||
fakesrc = GST_FAKESRC(src);
|
||||
g_return_if_fail (src != NULL);
|
||||
g_return_if_fail (GST_IS_FAKESRC (src));
|
||||
|
||||
fakesrc = GST_FAKESRC (src);
|
||||
|
||||
// g_print("gst_fakesrc_push(): pushing fake buffer from '%s'\n",
|
||||
// gst_element_get_name(GST_ELEMENT(fakesrc)));
|
||||
g_print(">");
|
||||
buf = gst_buffer_new();
|
||||
gst_pad_push(fakesrc->srcpad,buf);
|
||||
buf = gst_buffer_new ();
|
||||
|
||||
gst_pad_push (fakesrc->srcpad, buf);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ GstElementDetails gst_fakesrc_details;
|
|||
#define GST_IS_FAKESRC(obj) \
|
||||
(GTK_CHECK_TYPE((obj),GST_TYPE_FAKESRC))
|
||||
#define GST_IS_FAKESRC_CLASS(obj) \
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FAKESRC)))
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FAKESRC))
|
||||
|
||||
typedef struct _GstFakeSrc GstFakeSrc;
|
||||
typedef struct _GstFakeSrcClass GstFakeSrcClass;
|
||||
|
|
|
@ -43,18 +43,20 @@ enum {
|
|||
};
|
||||
|
||||
|
||||
static void gst_fdsink_class_init(GstFdSinkClass *klass);
|
||||
static void gst_fdsink_init(GstFdSink *fdsink);
|
||||
static void gst_fdsink_set_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_fdsink_get_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_fdsink_class_init (GstFdSinkClass *klass);
|
||||
static void gst_fdsink_init (GstFdSink *fdsink);
|
||||
|
||||
void gst_fdsink_chain(GstPad *pad,GstBuffer *buf);
|
||||
static void gst_fdsink_set_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
static void gst_fdsink_get_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
|
||||
static void gst_fdsink_chain (GstPad *pad,GstBuffer *buf);
|
||||
|
||||
static GstSinkClass *parent_class = NULL;
|
||||
//static guint gst_fdsink_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
GtkType
|
||||
gst_fdsink_get_type(void) {
|
||||
gst_fdsink_get_type (void)
|
||||
{
|
||||
static GtkType fdsink_type = 0;
|
||||
|
||||
if (!fdsink_type) {
|
||||
|
@ -68,88 +70,90 @@ gst_fdsink_get_type(void) {
|
|||
(GtkArgGetFunc)gst_fdsink_get_arg,
|
||||
(GtkClassInitFunc)NULL,
|
||||
};
|
||||
fdsink_type = gtk_type_unique(GST_TYPE_SINK,&fdsink_info);
|
||||
fdsink_type = gtk_type_unique (GST_TYPE_SINK, &fdsink_info);
|
||||
}
|
||||
return fdsink_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_fdsink_class_init(GstFdSinkClass *klass) {
|
||||
gst_fdsink_class_init (GstFdSinkClass *klass)
|
||||
{
|
||||
GtkObjectClass *gtkobject_class;
|
||||
GstSinkClass *gstsink_class;
|
||||
|
||||
gtkobject_class = (GtkObjectClass*)klass;
|
||||
gstsink_class = (GstSinkClass*)klass;
|
||||
|
||||
parent_class = gtk_type_class(GST_TYPE_SINK);
|
||||
parent_class = gtk_type_class (GST_TYPE_SINK);
|
||||
|
||||
gtk_object_add_arg_type("GstFdSink::fd", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_FD);
|
||||
gtk_object_add_arg_type ("GstFdSink::fd", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_FD);
|
||||
|
||||
gtkobject_class->set_arg = gst_fdsink_set_arg;
|
||||
gtkobject_class->get_arg = gst_fdsink_get_arg;
|
||||
}
|
||||
|
||||
static void gst_fdsink_init(GstFdSink *fdsink) {
|
||||
fdsink->sinkpad = gst_pad_new("sink",GST_PAD_SINK);
|
||||
gst_element_add_pad(GST_ELEMENT(fdsink),fdsink->sinkpad);
|
||||
gst_pad_set_chain_function(fdsink->sinkpad,gst_fdsink_chain);
|
||||
static void
|
||||
gst_fdsink_init (GstFdSink *fdsink)
|
||||
{
|
||||
fdsink->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
|
||||
gst_element_add_pad (GST_ELEMENT (fdsink), fdsink->sinkpad);
|
||||
gst_pad_set_chain_function (fdsink->sinkpad, gst_fdsink_chain);
|
||||
|
||||
fdsink->fd = 1;
|
||||
}
|
||||
|
||||
GstElement *gst_fdsink_new(gchar *name) {
|
||||
GstElement *fdsink = GST_ELEMENT(gtk_type_new(GST_TYPE_FDSINK));
|
||||
gst_element_set_name(GST_ELEMENT(fdsink),name);
|
||||
return fdsink;
|
||||
}
|
||||
|
||||
GstElement *gst_fdsink_new_with_fd(gchar *name,gint fd) {
|
||||
GstElement *fdsink = gst_fdsink_new(name);
|
||||
gtk_object_set(GTK_OBJECT(fdsink),"fd",fd,NULL);
|
||||
return fdsink;
|
||||
}
|
||||
|
||||
void gst_fdsink_chain(GstPad *pad,GstBuffer *buf) {
|
||||
static void
|
||||
gst_fdsink_chain (GstPad *pad, GstBuffer *buf)
|
||||
{
|
||||
GstFdSink *fdsink;
|
||||
|
||||
g_return_if_fail(pad != NULL);
|
||||
g_return_if_fail(GST_IS_PAD(pad));
|
||||
g_return_if_fail(buf != NULL);
|
||||
g_return_if_fail (pad != NULL);
|
||||
g_return_if_fail (GST_IS_PAD (pad));
|
||||
g_return_if_fail (buf != NULL);
|
||||
|
||||
fdsink = GST_FDSINK(pad->parent);
|
||||
g_return_if_fail(fdsink->fd >= 0);
|
||||
if (GST_BUFFER_DATA(buf))
|
||||
write(fdsink->fd,GST_BUFFER_DATA(buf),GST_BUFFER_SIZE(buf));
|
||||
gst_buffer_unref(buf);
|
||||
fdsink = GST_FDSINK (pad->parent);
|
||||
|
||||
g_return_if_fail (fdsink->fd >= 0);
|
||||
|
||||
if (GST_BUFFER_DATA (buf))
|
||||
write (fdsink->fd, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
|
||||
|
||||
gst_buffer_unref (buf);
|
||||
}
|
||||
|
||||
static void gst_fdsink_set_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_fdsink_set_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstFdSink *fdsink;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_FDSINK(object));
|
||||
fdsink = GST_FDSINK(object);
|
||||
g_return_if_fail (GST_IS_FDSINK (object));
|
||||
|
||||
fdsink = GST_FDSINK (object);
|
||||
|
||||
switch(id) {
|
||||
case ARG_FD:
|
||||
fdsink->fd = GTK_VALUE_INT(*arg);
|
||||
fdsink->fd = GTK_VALUE_INT (*arg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void gst_fdsink_get_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_fdsink_get_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstFdSink *fdsink;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_FDSINK(object));
|
||||
fdsink = GST_FDSINK(object);
|
||||
g_return_if_fail (GST_IS_FDSINK (object));
|
||||
|
||||
fdsink = GST_FDSINK (object);
|
||||
|
||||
switch(id) {
|
||||
case ARG_FD:
|
||||
GTK_VALUE_INT(*arg) = fdsink->fd;
|
||||
GTK_VALUE_INT (*arg) = fdsink->fd;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -43,7 +43,7 @@ GstElementDetails gst_fdsink_details;
|
|||
#define GST_IS_FDSINK(obj) \
|
||||
(GTK_CHECK_TYPE((obj),GST_TYPE_FDSINK))
|
||||
#define GST_IS_FDSINK_CLASS(obj) \
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FDSINK)))
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FDSINK))
|
||||
|
||||
typedef struct _GstFdSink GstFdSink;
|
||||
typedef struct _GstFdSinkClass GstFdSinkClass;
|
||||
|
|
|
@ -51,12 +51,13 @@ enum {
|
|||
};
|
||||
|
||||
|
||||
static void gst_fdsrc_class_init(GstFdSrcClass *klass);
|
||||
static void gst_fdsrc_init(GstFdSrc *fdsrc);
|
||||
static void gst_fdsrc_set_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_fdsrc_get_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_fdsrc_class_init (GstFdSrcClass *klass);
|
||||
static void gst_fdsrc_init (GstFdSrc *fdsrc);
|
||||
|
||||
static void gst_fdsrc_push(GstSrc *src);
|
||||
static void gst_fdsrc_set_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
static void gst_fdsrc_get_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
|
||||
static void gst_fdsrc_push (GstSrc *src);
|
||||
//static void gst_fdsrc_push_region(GstSrc *src,gulong offset,gulong size);
|
||||
|
||||
|
||||
|
@ -64,7 +65,8 @@ static GstSrcClass *parent_class = NULL;
|
|||
//static guint gst_fdsrc_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
GtkType
|
||||
gst_fdsrc_get_type(void) {
|
||||
gst_fdsrc_get_type (void)
|
||||
{
|
||||
static GtkType fdsrc_type = 0;
|
||||
|
||||
if (!fdsrc_type) {
|
||||
|
@ -78,13 +80,14 @@ gst_fdsrc_get_type(void) {
|
|||
(GtkArgGetFunc)gst_fdsrc_get_arg,
|
||||
(GtkClassInitFunc)NULL,
|
||||
};
|
||||
fdsrc_type = gtk_type_unique(GST_TYPE_SRC,&fdsrc_info);
|
||||
fdsrc_type = gtk_type_unique (GST_TYPE_SRC, &fdsrc_info);
|
||||
}
|
||||
return fdsrc_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_fdsrc_class_init(GstFdSrcClass *klass) {
|
||||
gst_fdsrc_class_init (GstFdSrcClass *klass)
|
||||
{
|
||||
GtkObjectClass *gtkobject_class;
|
||||
GstSrcClass *gstsrc_class;
|
||||
|
||||
|
@ -93,24 +96,27 @@ gst_fdsrc_class_init(GstFdSrcClass *klass) {
|
|||
|
||||
parent_class = gtk_type_class(GST_TYPE_SRC);
|
||||
|
||||
gtk_object_add_arg_type("GstFdSrc::location", GST_TYPE_FILENAME,
|
||||
GTK_ARG_WRITABLE, ARG_LOCATION);
|
||||
gtk_object_add_arg_type("GstFdSrc::bytesperread", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_BYTESPERREAD);
|
||||
gtk_object_add_arg_type("GstFdSrc::offset", GTK_TYPE_INT,
|
||||
GTK_ARG_READABLE, ARG_OFFSET);
|
||||
gtk_object_add_arg_type ("GstFdSrc::location", GST_TYPE_FILENAME,
|
||||
GTK_ARG_WRITABLE, ARG_LOCATION);
|
||||
gtk_object_add_arg_type ("GstFdSrc::bytesperread", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_BYTESPERREAD);
|
||||
gtk_object_add_arg_type ("GstFdSrc::offset", GTK_TYPE_INT,
|
||||
GTK_ARG_READABLE, ARG_OFFSET);
|
||||
|
||||
gtkobject_class->set_arg = gst_fdsrc_set_arg;
|
||||
gtkobject_class->get_arg = gst_fdsrc_get_arg;
|
||||
|
||||
gstsrc_class->push = gst_fdsrc_push;
|
||||
|
||||
/* we nominally can't (won't) do async */
|
||||
gstsrc_class->push_region = NULL;
|
||||
}
|
||||
|
||||
static void gst_fdsrc_init(GstFdSrc *fdsrc) {
|
||||
fdsrc->srcpad = gst_pad_new("src",GST_PAD_SRC);
|
||||
gst_element_add_pad(GST_ELEMENT(fdsrc),fdsrc->srcpad);
|
||||
static void
|
||||
gst_fdsrc_init (GstFdSrc *fdsrc)
|
||||
{
|
||||
fdsrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||
gst_element_add_pad (GST_ELEMENT (fdsrc), fdsrc->srcpad);
|
||||
|
||||
fdsrc->fd = 0;
|
||||
fdsrc->curoffset = 0;
|
||||
|
@ -119,50 +125,56 @@ static void gst_fdsrc_init(GstFdSrc *fdsrc) {
|
|||
}
|
||||
|
||||
|
||||
static void gst_fdsrc_set_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_fdsrc_set_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstFdSrc *src;
|
||||
int fd;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_FDSRC(object));
|
||||
src = GST_FDSRC(object);
|
||||
g_return_if_fail (GST_IS_FDSRC (object));
|
||||
|
||||
src = GST_FDSRC (object);
|
||||
|
||||
switch(id) {
|
||||
case ARG_LOCATION:
|
||||
/* the element must not be playing in order to do this */
|
||||
g_return_if_fail(GST_STATE(src) < GST_STATE_PLAYING);
|
||||
g_return_if_fail (GST_STATE (src) < GST_STATE_PLAYING);
|
||||
|
||||
/* if we get a NULL, consider it to be a fd of 0 */
|
||||
if (GTK_VALUE_STRING(*arg) == NULL) {
|
||||
gst_element_set_state(GST_ELEMENT(object),GST_STATE_NULL);
|
||||
if (GTK_VALUE_STRING (*arg) == NULL) {
|
||||
gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL);
|
||||
src->fd = 0;
|
||||
/* otherwise set the new filename */
|
||||
} else {
|
||||
if (sscanf(GTK_VALUE_STRING(*arg),"%d",&fd))
|
||||
if (sscanf (GTK_VALUE_STRING (*arg), "%d", &fd))
|
||||
src->fd = fd;
|
||||
}
|
||||
break;
|
||||
case ARG_BYTESPERREAD:
|
||||
src->bytes_per_read = GTK_VALUE_INT(*arg);
|
||||
src->bytes_per_read = GTK_VALUE_INT (*arg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void gst_fdsrc_get_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_fdsrc_get_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstFdSrc *src;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_FDSRC(object));
|
||||
src = GST_FDSRC(object);
|
||||
g_return_if_fail (GST_IS_FDSRC (object));
|
||||
|
||||
src = GST_FDSRC (object);
|
||||
|
||||
switch (id) {
|
||||
case ARG_BYTESPERREAD:
|
||||
GTK_VALUE_INT(*arg) = src->bytes_per_read;
|
||||
GTK_VALUE_INT (*arg) = src->bytes_per_read;
|
||||
break;
|
||||
case ARG_OFFSET:
|
||||
GTK_VALUE_INT(*arg) = src->curoffset;
|
||||
GTK_VALUE_INT (*arg) = src->curoffset;
|
||||
break;
|
||||
default:
|
||||
arg->type = GTK_TYPE_INVALID;
|
||||
|
@ -170,40 +182,44 @@ static void gst_fdsrc_get_arg(GtkObject *object,GtkArg *arg,guint id) {
|
|||
}
|
||||
}
|
||||
|
||||
void gst_fdsrc_push(GstSrc *src) {
|
||||
static void
|
||||
gst_fdsrc_push (GstSrc *src)
|
||||
{
|
||||
GstFdSrc *fdsrc;
|
||||
GstBuffer *buf;
|
||||
glong readbytes;
|
||||
|
||||
g_return_if_fail(src != NULL);
|
||||
g_return_if_fail(GST_IS_FDSRC(src));
|
||||
fdsrc = GST_FDSRC(src);
|
||||
g_return_if_fail (src != NULL);
|
||||
g_return_if_fail (GST_IS_FDSRC (src));
|
||||
|
||||
fdsrc = GST_FDSRC (src);
|
||||
|
||||
/* create the buffer */
|
||||
// FIXME: should eventually use a bufferpool for this
|
||||
buf = gst_buffer_new();
|
||||
g_return_if_fail(buf);
|
||||
buf = gst_buffer_new ();
|
||||
g_return_if_fail (buf);
|
||||
|
||||
/* allocate the space for the buffer data */
|
||||
GST_BUFFER_DATA(buf) = g_malloc(fdsrc->bytes_per_read);
|
||||
g_return_if_fail(GST_BUFFER_DATA(buf) != NULL);
|
||||
GST_BUFFER_DATA (buf) = g_malloc (fdsrc->bytes_per_read);
|
||||
g_return_if_fail (GST_BUFFER_DATA (buf) != NULL);
|
||||
|
||||
/* read it in from the file */
|
||||
readbytes = read(fdsrc->fd,GST_BUFFER_DATA(buf),fdsrc->bytes_per_read);
|
||||
readbytes = read (fdsrc->fd, GST_BUFFER_DATA (buf), fdsrc->bytes_per_read);
|
||||
if (readbytes == 0) {
|
||||
gst_src_signal_eos(GST_SRC(fdsrc));
|
||||
gst_src_signal_eos (GST_SRC (fdsrc));
|
||||
return;
|
||||
}
|
||||
|
||||
/* if we didn't get as many bytes as we asked for, we're at EOF */
|
||||
if (readbytes < fdsrc->bytes_per_read) {
|
||||
// set the buffer's EOF bit here
|
||||
GST_BUFFER_FLAG_SET(buf,GST_BUFFER_EOS);
|
||||
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_EOS);
|
||||
}
|
||||
GST_BUFFER_OFFSET(buf) = fdsrc->curoffset;
|
||||
GST_BUFFER_SIZE(buf) = readbytes;
|
||||
GST_BUFFER_OFFSET (buf) = fdsrc->curoffset;
|
||||
GST_BUFFER_SIZE (buf) = readbytes;
|
||||
|
||||
fdsrc->curoffset += readbytes;
|
||||
|
||||
/* we're done, push the buffer off now */
|
||||
gst_pad_push(fdsrc->srcpad,buf);
|
||||
gst_pad_push (fdsrc->srcpad, buf);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ GstElementDetails gst_fdsrc_details;
|
|||
#define GST_IS_FDSRC(obj) \
|
||||
(GTK_CHECK_TYPE((obj),GST_TYPE_FDSRC))
|
||||
#define GST_IS_FDSRC_CLASS(obj) \
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FDSRC)))
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FDSRC))
|
||||
|
||||
|
||||
typedef struct _GstFdSrc GstFdSrc;
|
||||
|
|
|
@ -35,13 +35,6 @@ GstElementDetails gst_httpsrc_details = {
|
|||
"(C) 1999",
|
||||
};
|
||||
|
||||
|
||||
static void gst_httpsrc_push(GstSrc *src);
|
||||
static gboolean gst_httpsrc_open_url(GstHttpSrc *src);
|
||||
static void gst_httpsrc_close_url(GstHttpSrc *src);
|
||||
static GstElementStateReturn gst_httpsrc_change_state(GstElement *element);
|
||||
|
||||
|
||||
/* HttpSrc signals and args */
|
||||
enum {
|
||||
/* FILL ME */
|
||||
|
@ -56,17 +49,25 @@ enum {
|
|||
};
|
||||
|
||||
|
||||
static void gst_httpsrc_class_init(GstHttpSrcClass *klass);
|
||||
static void gst_httpsrc_init(GstHttpSrc *httpsrc);
|
||||
static void gst_httpsrc_set_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_httpsrc_get_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_httpsrc_class_init (GstHttpSrcClass *klass);
|
||||
static void gst_httpsrc_init (GstHttpSrc *httpsrc);
|
||||
|
||||
static void gst_httpsrc_set_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
static void gst_httpsrc_get_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
|
||||
static void gst_httpsrc_push (GstSrc *src);
|
||||
|
||||
static gboolean gst_httpsrc_open_url (GstHttpSrc *src);
|
||||
static void gst_httpsrc_close_url (GstHttpSrc *src);
|
||||
|
||||
static GstElementStateReturn gst_httpsrc_change_state(GstElement *element);
|
||||
|
||||
static GstSrcClass *parent_class = NULL;
|
||||
//static guint gst_httpsrc_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
GtkType
|
||||
gst_httpsrc_get_type(void) {
|
||||
gst_httpsrc_get_type (void)
|
||||
{
|
||||
static GtkType httpsrc_type = 0;
|
||||
|
||||
if (!httpsrc_type) {
|
||||
|
@ -80,13 +81,14 @@ gst_httpsrc_get_type(void) {
|
|||
(GtkArgGetFunc)gst_httpsrc_get_arg,
|
||||
(GtkClassInitFunc)NULL,
|
||||
};
|
||||
httpsrc_type = gtk_type_unique(GST_TYPE_SRC,&httpsrc_info);
|
||||
httpsrc_type = gtk_type_unique (GST_TYPE_SRC, &httpsrc_info);
|
||||
}
|
||||
return httpsrc_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_httpsrc_class_init(GstHttpSrcClass *klass) {
|
||||
gst_httpsrc_class_init (GstHttpSrcClass *klass)
|
||||
{
|
||||
GtkObjectClass *gtkobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
GstSrcClass *gstsrc_class;
|
||||
|
@ -95,13 +97,13 @@ gst_httpsrc_class_init(GstHttpSrcClass *klass) {
|
|||
gstelement_class = (GstElementClass*)klass;
|
||||
gstsrc_class = (GstSrcClass*)klass;
|
||||
|
||||
parent_class = gtk_type_class(GST_TYPE_SRC);
|
||||
parent_class = gtk_type_class (GST_TYPE_SRC);
|
||||
|
||||
|
||||
gtk_object_add_arg_type("GstHttpSrc::location", GTK_TYPE_STRING,
|
||||
GTK_ARG_READWRITE, ARG_LOCATION);
|
||||
gtk_object_add_arg_type("GstHttpSrc::bytesperread", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_BYTESPERREAD);
|
||||
gtk_object_add_arg_type ("GstHttpSrc::location", GTK_TYPE_STRING,
|
||||
GTK_ARG_READWRITE, ARG_LOCATION);
|
||||
gtk_object_add_arg_type ("GstHttpSrc::bytesperread", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_BYTESPERREAD);
|
||||
|
||||
gtkobject_class->set_arg = gst_httpsrc_set_arg;
|
||||
gtkobject_class->get_arg = gst_httpsrc_get_arg;
|
||||
|
@ -112,9 +114,11 @@ gst_httpsrc_class_init(GstHttpSrcClass *klass) {
|
|||
gstsrc_class->push_region = NULL;
|
||||
}
|
||||
|
||||
static void gst_httpsrc_init(GstHttpSrc *httpsrc) {
|
||||
httpsrc->srcpad = gst_pad_new("src",GST_PAD_SRC);
|
||||
gst_element_add_pad(GST_ELEMENT(httpsrc),httpsrc->srcpad);
|
||||
static void
|
||||
gst_httpsrc_init (GstHttpSrc *httpsrc)
|
||||
{
|
||||
httpsrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||
gst_element_add_pad (GST_ELEMENT (httpsrc), httpsrc->srcpad);
|
||||
|
||||
httpsrc->url = NULL;
|
||||
httpsrc->request = NULL;
|
||||
|
@ -123,115 +127,132 @@ static void gst_httpsrc_init(GstHttpSrc *httpsrc) {
|
|||
httpsrc->bytes_per_read = 4096;
|
||||
}
|
||||
|
||||
static void gst_httpsrc_push(GstSrc *src) {
|
||||
static void
|
||||
gst_httpsrc_push (GstSrc *src)
|
||||
{
|
||||
GstHttpSrc *httpsrc;
|
||||
GstBuffer *buf;
|
||||
glong readbytes;
|
||||
|
||||
g_return_if_fail(src != NULL);
|
||||
g_return_if_fail(GST_IS_HTTPSRC(src));
|
||||
g_return_if_fail (src != NULL);
|
||||
g_return_if_fail (GST_IS_HTTPSRC (src));
|
||||
// g_return_if_fail(GST_FLAG_IS_SET(src,GST_));
|
||||
httpsrc = GST_HTTPSRC(src);
|
||||
httpsrc = GST_HTTPSRC (src);
|
||||
|
||||
buf = gst_buffer_new();
|
||||
GST_BUFFER_DATA(buf) = (gpointer)malloc(httpsrc->bytes_per_read);
|
||||
readbytes = read(httpsrc->fd,GST_BUFFER_DATA(buf),httpsrc->bytes_per_read);
|
||||
buf = gst_buffer_new ();
|
||||
GST_BUFFER_DATA (buf) = (gpointer)malloc (httpsrc->bytes_per_read);
|
||||
|
||||
readbytes = read (httpsrc->fd, GST_BUFFER_DATA (buf), httpsrc->bytes_per_read);
|
||||
|
||||
if (readbytes == 0) {
|
||||
gst_src_signal_eos(GST_SRC(httpsrc));
|
||||
gst_src_signal_eos (GST_SRC (httpsrc));
|
||||
return;
|
||||
}
|
||||
|
||||
if (readbytes < httpsrc->bytes_per_read) {
|
||||
// FIXME: set the buffer's EOF bit here
|
||||
}
|
||||
GST_BUFFER_OFFSET(buf) = httpsrc->curoffset;
|
||||
GST_BUFFER_SIZE(buf) = readbytes;
|
||||
GST_BUFFER_OFFSET (buf) = httpsrc->curoffset;
|
||||
GST_BUFFER_SIZE (buf) = readbytes;
|
||||
|
||||
httpsrc->curoffset += readbytes;
|
||||
|
||||
gst_pad_push(httpsrc->srcpad,buf);
|
||||
gst_pad_push (httpsrc->srcpad, buf);
|
||||
}
|
||||
|
||||
static gboolean gst_httpsrc_open_url(GstHttpSrc *httpsrc) {
|
||||
static gboolean
|
||||
gst_httpsrc_open_url (GstHttpSrc *httpsrc)
|
||||
{
|
||||
gint status;
|
||||
|
||||
g_return_val_if_fail(!GST_FLAG_IS_SET(httpsrc,GST_HTTPSRC_OPEN), FALSE);
|
||||
g_return_val_if_fail(httpsrc->url != NULL, FALSE);
|
||||
g_return_val_if_fail (!GST_FLAG_IS_SET (httpsrc, GST_HTTPSRC_OPEN), FALSE);
|
||||
g_return_val_if_fail (httpsrc->url != NULL, FALSE);
|
||||
|
||||
httpsrc->request = ghttp_request_new();
|
||||
ghttp_set_uri(httpsrc->request,httpsrc->url);
|
||||
ghttp_set_sync(httpsrc->request,ghttp_async);
|
||||
ghttp_set_header(httpsrc->request,"User-Agent","GstHttpSrc");
|
||||
ghttp_prepare(httpsrc->request);
|
||||
httpsrc->request = ghttp_request_new ();
|
||||
|
||||
ghttp_set_uri (httpsrc->request, httpsrc->url);
|
||||
ghttp_set_sync (httpsrc->request, ghttp_async);
|
||||
ghttp_set_header (httpsrc->request, "User-Agent", "GstHttpSrc");
|
||||
ghttp_prepare (httpsrc->request);
|
||||
|
||||
/* process everything up to the actual data stream */
|
||||
/* FIXME: should be in preroll, but hey */
|
||||
status = 0;
|
||||
while ((ghttp_get_status(httpsrc->request).proc != ghttp_proc_response)
|
||||
while ((ghttp_get_status (httpsrc->request).proc != ghttp_proc_response)
|
||||
&& (status >= 0)) {
|
||||
status = ghttp_process(httpsrc->request);
|
||||
status = ghttp_process (httpsrc->request);
|
||||
}
|
||||
|
||||
/* get the fd so we can read data ourselves */
|
||||
httpsrc->fd = ghttp_get_socket(httpsrc->request);
|
||||
GST_FLAG_SET(httpsrc,GST_HTTPSRC_OPEN);
|
||||
httpsrc->fd = ghttp_get_socket (httpsrc->request);
|
||||
|
||||
GST_FLAG_SET (httpsrc, GST_HTTPSRC_OPEN);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* unmap and close the file */
|
||||
static void gst_httpsrc_close_url(GstHttpSrc *src) {
|
||||
g_return_if_fail(GST_FLAG_IS_SET(src,GST_HTTPSRC_OPEN));
|
||||
|
||||
g_return_if_fail(src->fd > 0);
|
||||
static void
|
||||
gst_httpsrc_close_url (GstHttpSrc *src)
|
||||
{
|
||||
g_return_if_fail (GST_FLAG_IS_SET (src, GST_HTTPSRC_OPEN));
|
||||
g_return_if_fail (src->fd > 0);
|
||||
|
||||
close(src->fd);
|
||||
src->fd = 0;
|
||||
|
||||
GST_FLAG_UNSET(src,GST_HTTPSRC_OPEN);
|
||||
GST_FLAG_UNSET (src, GST_HTTPSRC_OPEN);
|
||||
}
|
||||
|
||||
static void gst_httpsrc_set_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_httpsrc_set_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstHttpSrc *src;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_HTTPSRC(object));
|
||||
src = GST_HTTPSRC(object);
|
||||
g_return_if_fail (GST_IS_HTTPSRC (object));
|
||||
|
||||
src = GST_HTTPSRC (object);
|
||||
|
||||
switch(id) {
|
||||
case ARG_LOCATION:
|
||||
/* the element must not be playing in order to do this */
|
||||
g_return_if_fail(GST_STATE(src) < GST_STATE_PLAYING);
|
||||
g_return_if_fail (GST_STATE (src) < GST_STATE_PLAYING);
|
||||
|
||||
if (src->url) g_free(src->url);
|
||||
if (src->url) g_free (src->url);
|
||||
/* clear the url if we get a NULL (is that possible?) */
|
||||
if (GTK_VALUE_STRING(*arg) == NULL) {
|
||||
gst_element_set_state(GST_ELEMENT(object),GST_STATE_NULL);
|
||||
if (GTK_VALUE_STRING (*arg) == NULL) {
|
||||
gst_element_set_state (GST_ELEMENT (object),GST_STATE_NULL);
|
||||
src->url = NULL;
|
||||
/* otherwise set the new url */
|
||||
} else {
|
||||
src->url = g_strdup(GTK_VALUE_STRING(*arg));
|
||||
src->url = g_strdup (GTK_VALUE_STRING (*arg));
|
||||
}
|
||||
break;
|
||||
case ARG_BYTESPERREAD:
|
||||
src->bytes_per_read = GTK_VALUE_INT(*arg);
|
||||
src->bytes_per_read = GTK_VALUE_INT (*arg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void gst_httpsrc_get_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_httpsrc_get_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstHttpSrc *httpsrc;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_HTTPSRC(object));
|
||||
httpsrc = GST_HTTPSRC(object);
|
||||
g_return_if_fail (GST_IS_HTTPSRC (object));
|
||||
|
||||
httpsrc = GST_HTTPSRC (object);
|
||||
|
||||
switch (id) {
|
||||
case ARG_LOCATION:
|
||||
GTK_VALUE_STRING(*arg) = httpsrc->url;
|
||||
GTK_VALUE_STRING (*arg) = httpsrc->url;
|
||||
break;
|
||||
case ARG_BYTESPERREAD:
|
||||
GTK_VALUE_INT(*arg) = httpsrc->bytes_per_read;
|
||||
GTK_VALUE_INT (*arg) = httpsrc->bytes_per_read;
|
||||
break;
|
||||
default:
|
||||
arg->type = GTK_TYPE_INVALID;
|
||||
|
@ -239,20 +260,23 @@ static void gst_httpsrc_get_arg(GtkObject *object,GtkArg *arg,guint id) {
|
|||
}
|
||||
}
|
||||
|
||||
static GstElementStateReturn gst_httpsrc_change_state(GstElement *element) {
|
||||
g_return_val_if_fail(GST_IS_HTTPSRC(element),GST_STATE_FAILURE);
|
||||
static GstElementStateReturn
|
||||
gst_httpsrc_change_state (GstElement *element)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_HTTPSRC (element), GST_STATE_FAILURE);
|
||||
|
||||
if (GST_STATE_PENDING(element) == GST_STATE_NULL) {
|
||||
if (GST_FLAG_IS_SET(element,GST_HTTPSRC_OPEN))
|
||||
gst_httpsrc_close_url(GST_HTTPSRC(element));
|
||||
if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
|
||||
if (GST_FLAG_IS_SET (element, GST_HTTPSRC_OPEN))
|
||||
gst_httpsrc_close_url (GST_HTTPSRC (element));
|
||||
} else {
|
||||
if (!GST_FLAG_IS_SET(element,GST_HTTPSRC_OPEN)) {
|
||||
if (!gst_httpsrc_open_url(GST_HTTPSRC(element)))
|
||||
if (!GST_FLAG_IS_SET (element, GST_HTTPSRC_OPEN)) {
|
||||
if (!gst_httpsrc_open_url (GST_HTTPSRC (element)))
|
||||
return GST_STATE_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (GST_ELEMENT_CLASS(parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS(parent_class)->change_state(element);
|
||||
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
||||
|
||||
return GST_STATE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ GstElementDetails gst_httpsrc_details;
|
|||
#define GST_IS_HTTPSRC(obj) \
|
||||
(GTK_CHECK_TYPE((obj),GST_TYPE_HTTPSRC))
|
||||
#define GST_IS_HTTPSRC_CLASS(obj) \
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_HTTPSRC)))
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_HTTPSRC))
|
||||
|
||||
// NOTE: per-element flags start with 16 for now
|
||||
typedef enum {
|
||||
|
|
|
@ -43,18 +43,20 @@ enum {
|
|||
};
|
||||
|
||||
|
||||
static void gst_identity_class_init(GstIdentityClass *klass);
|
||||
static void gst_identity_init(GstIdentity *identity);
|
||||
static void gst_identity_set_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_identity_get_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_identity_class_init (GstIdentityClass *klass);
|
||||
static void gst_identity_init (GstIdentity *identity);
|
||||
|
||||
void gst_identity_chain(GstPad *pad,GstBuffer *buf);
|
||||
static void gst_identity_set_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
static void gst_identity_get_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
|
||||
static void gst_identity_chain (GstPad *pad, GstBuffer *buf);
|
||||
|
||||
static GstFilterClass *parent_class = NULL;
|
||||
//static guint gst_identity_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
GtkType
|
||||
gst_identity_get_type(void) {
|
||||
gst_identity_get_type (void)
|
||||
{
|
||||
static GtkType identity_type = 0;
|
||||
|
||||
if (!identity_type) {
|
||||
|
@ -68,19 +70,21 @@ gst_identity_get_type(void) {
|
|||
(GtkArgGetFunc)gst_identity_get_arg,
|
||||
(GtkClassInitFunc)NULL,
|
||||
};
|
||||
identity_type = gtk_type_unique(GST_TYPE_FILTER,&identity_info);
|
||||
identity_type = gtk_type_unique (GST_TYPE_FILTER, &identity_info);
|
||||
}
|
||||
return identity_type;
|
||||
}
|
||||
|
||||
static void gst_identity_class_init(GstIdentityClass *klass) {
|
||||
static void
|
||||
gst_identity_class_init (GstIdentityClass *klass)
|
||||
{
|
||||
GtkObjectClass *gtkobject_class;
|
||||
GstFilterClass *gstfilter_class;
|
||||
|
||||
gtkobject_class = (GtkObjectClass*)klass;
|
||||
gstfilter_class = (GstFilterClass*)klass;
|
||||
|
||||
parent_class = gtk_type_class(GST_TYPE_FILTER);
|
||||
parent_class = gtk_type_class (GST_TYPE_FILTER);
|
||||
|
||||
//gtk_object_add_arg_type("GstIdentity::control", GTK_TYPE_INT,
|
||||
// GTK_ARG_READWRITE, ARG_CONTROL);
|
||||
|
@ -89,46 +93,49 @@ static void gst_identity_class_init(GstIdentityClass *klass) {
|
|||
//gtkobject_class->get_arg = gst_identity_get_arg;
|
||||
}
|
||||
|
||||
static void gst_identity_init(GstIdentity *identity) {
|
||||
identity->sinkpad = gst_pad_new("sink",GST_PAD_SINK);
|
||||
gst_element_add_pad(GST_ELEMENT(identity),identity->sinkpad);
|
||||
gst_pad_set_chain_function(identity->sinkpad,gst_identity_chain);
|
||||
identity->srcpad = gst_pad_new("src",GST_PAD_SRC);
|
||||
gst_element_add_pad(GST_ELEMENT(identity),identity->srcpad);
|
||||
static void
|
||||
gst_identity_init (GstIdentity *identity)
|
||||
{
|
||||
identity->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
|
||||
gst_element_add_pad (GST_ELEMENT (identity), identity->sinkpad);
|
||||
gst_pad_set_chain_function (identity->sinkpad, gst_identity_chain);
|
||||
|
||||
identity->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||
gst_element_add_pad (GST_ELEMENT (identity), identity->srcpad);
|
||||
|
||||
identity->control = 0;
|
||||
}
|
||||
|
||||
GstElement *gst_identity_new(gchar *name) {
|
||||
GstElement *identity = GST_ELEMENT(gtk_type_new(GST_TYPE_IDENTITY));
|
||||
gst_element_set_name(GST_ELEMENT(identity),name);
|
||||
return identity;
|
||||
}
|
||||
|
||||
void gst_identity_chain(GstPad *pad,GstBuffer *buf) {
|
||||
static void
|
||||
gst_identity_chain (GstPad *pad, GstBuffer *buf)
|
||||
{
|
||||
GstIdentity *identity;
|
||||
|
||||
g_return_if_fail(pad != NULL);
|
||||
g_return_if_fail(GST_IS_PAD(pad));
|
||||
g_return_if_fail(buf != NULL);
|
||||
g_return_if_fail (pad != NULL);
|
||||
g_return_if_fail (GST_IS_PAD (pad));
|
||||
g_return_if_fail (buf != NULL);
|
||||
|
||||
identity = GST_IDENTITY(pad->parent);
|
||||
identity = GST_IDENTITY (pad->parent);
|
||||
// g_print("gst_identity_chain: got buffer in '%s'\n",
|
||||
// gst_element_get_name(GST_ELEMENT(identity)));
|
||||
g_print("i");
|
||||
gst_pad_push(identity->srcpad,buf);
|
||||
|
||||
gst_pad_push (identity->srcpad, buf);
|
||||
}
|
||||
|
||||
static void gst_identity_set_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_identity_set_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstIdentity *identity;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_IDENTITY(object));
|
||||
identity = GST_IDENTITY(object);
|
||||
g_return_if_fail (GST_IS_IDENTITY (object));
|
||||
|
||||
identity = GST_IDENTITY (object);
|
||||
|
||||
switch(id) {
|
||||
case ARG_CONTROL:
|
||||
identity->control = GTK_VALUE_INT(*arg);
|
||||
identity->control = GTK_VALUE_INT (*arg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -139,12 +146,13 @@ static void gst_identity_get_arg(GtkObject *object,GtkArg *arg,guint id) {
|
|||
GstIdentity *identity;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_IDENTITY(object));
|
||||
identity = GST_IDENTITY(object);
|
||||
g_return_if_fail (GST_IS_IDENTITY (object));
|
||||
|
||||
identity = GST_IDENTITY (object);
|
||||
|
||||
switch (id) {
|
||||
case ARG_CONTROL:
|
||||
GTK_VALUE_INT(*arg) = identity->control;
|
||||
GTK_VALUE_INT (*arg) = identity->control;
|
||||
break;
|
||||
default:
|
||||
arg->type = GTK_TYPE_INVALID;
|
||||
|
|
|
@ -43,7 +43,7 @@ GstElementDetails gst_identity_details;
|
|||
#define GST_IS_IDENTITY(obj) \
|
||||
(GTK_CHECK_TYPE((obj),GST_TYPE_IDENTITY))
|
||||
#define GST_IS_IDENTITY_CLASS(obj) \
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_IDENTITY)))
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_IDENTITY))
|
||||
|
||||
typedef struct _GstIdentity GstIdentity;
|
||||
typedef struct _GstIdentityClass GstIdentityClass;
|
||||
|
|
|
@ -52,17 +52,19 @@ enum {
|
|||
};
|
||||
|
||||
|
||||
static void gst_queue_class_init(GstQueueClass *klass);
|
||||
static void gst_queue_init(GstQueue *queue);
|
||||
static void gst_queue_set_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_queue_get_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_queue_class_init (GstQueueClass *klass);
|
||||
static void gst_queue_init (GstQueue *queue);
|
||||
|
||||
static void gst_queue_push(GstConnection *connection);
|
||||
static void gst_queue_chain(GstPad *pad,GstBuffer *buf);
|
||||
static void gst_queue_set_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
static void gst_queue_get_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
|
||||
static void gst_queue_flush(GstQueue *queue);
|
||||
static void gst_queue_push (GstConnection *connection);
|
||||
static void gst_queue_chain (GstPad *pad, GstBuffer *buf);
|
||||
|
||||
static void gst_queue_flush (GstQueue *queue);
|
||||
|
||||
static GstElementStateReturn gst_queue_change_state (GstElement *element);
|
||||
|
||||
static GstElementStateReturn gst_queue_change_state(GstElement *element);
|
||||
|
||||
static GstConnectionClass *parent_class = NULL;
|
||||
//static guint gst_queue_signals[LAST_SIGNAL] = { 0 };
|
||||
|
@ -82,12 +84,14 @@ gst_queue_get_type(void) {
|
|||
(GtkArgGetFunc)gst_queue_get_arg,
|
||||
(GtkClassInitFunc)NULL,
|
||||
};
|
||||
queue_type = gtk_type_unique(GST_TYPE_CONNECTION,&queue_info);
|
||||
queue_type = gtk_type_unique (GST_TYPE_CONNECTION, &queue_info);
|
||||
}
|
||||
return queue_type;
|
||||
}
|
||||
|
||||
static void gst_queue_class_init(GstQueueClass *klass) {
|
||||
static void
|
||||
gst_queue_class_init (GstQueueClass *klass)
|
||||
{
|
||||
GtkObjectClass *gtkobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
GstConnectionClass *gstconnection_class;
|
||||
|
@ -96,12 +100,12 @@ static void gst_queue_class_init(GstQueueClass *klass) {
|
|||
gstelement_class = (GstElementClass*)klass;
|
||||
gstconnection_class = (GstConnectionClass*)klass;
|
||||
|
||||
parent_class = gtk_type_class(GST_TYPE_CONNECTION);
|
||||
parent_class = gtk_type_class (GST_TYPE_CONNECTION);
|
||||
|
||||
gtk_object_add_arg_type("GstQueue::level", GTK_TYPE_INT,
|
||||
GTK_ARG_READABLE, ARG_LEVEL);
|
||||
gtk_object_add_arg_type("GstQueue::max_level", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_MAX_LEVEL);
|
||||
gtk_object_add_arg_type ("GstQueue::level", GTK_TYPE_INT,
|
||||
GTK_ARG_READABLE, ARG_LEVEL);
|
||||
gtk_object_add_arg_type ("GstQueue::max_level", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_MAX_LEVEL);
|
||||
|
||||
gstconnection_class->push = gst_queue_push;
|
||||
|
||||
|
@ -111,13 +115,15 @@ static void gst_queue_class_init(GstQueueClass *klass) {
|
|||
gstelement_class->change_state = gst_queue_change_state;
|
||||
}
|
||||
|
||||
static void gst_queue_init(GstQueue *queue) {
|
||||
queue->sinkpad = gst_pad_new("sink",GST_PAD_SINK);
|
||||
gst_element_add_pad(GST_ELEMENT(queue),queue->sinkpad);
|
||||
gst_pad_set_chain_function(queue->sinkpad,gst_queue_chain);
|
||||
static void
|
||||
gst_queue_init (GstQueue *queue)
|
||||
{
|
||||
queue->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
|
||||
gst_element_add_pad (GST_ELEMENT (queue), queue->sinkpad);
|
||||
gst_pad_set_chain_function (queue->sinkpad, gst_queue_chain);
|
||||
|
||||
queue->srcpad = gst_pad_new("src",GST_PAD_SRC);
|
||||
gst_element_add_pad(GST_ELEMENT(queue),queue->srcpad);
|
||||
queue->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||
gst_element_add_pad (GST_ELEMENT (queue), queue->srcpad);
|
||||
|
||||
queue->queue = NULL;
|
||||
queue->level_buffers = 0;
|
||||
|
@ -126,54 +132,55 @@ static void gst_queue_init(GstQueue *queue) {
|
|||
queue->size_buffers = 0;
|
||||
queue->size_bytes = 0;
|
||||
|
||||
queue->emptylock = g_mutex_new();
|
||||
queue->emptycond = g_cond_new();
|
||||
queue->emptylock = g_mutex_new ();
|
||||
queue->emptycond = g_cond_new ();
|
||||
|
||||
queue->fulllock = g_mutex_new();
|
||||
queue->fullcond = g_cond_new();
|
||||
queue->fulllock = g_mutex_new ();
|
||||
queue->fullcond = g_cond_new ();
|
||||
}
|
||||
|
||||
GstElement *gst_queue_new(gchar *name) {
|
||||
GstElement *queue = GST_ELEMENT(gtk_type_new(GST_TYPE_QUEUE));
|
||||
gst_element_set_name(GST_ELEMENT(queue),name);
|
||||
return queue;
|
||||
}
|
||||
|
||||
static void gst_queue_cleanup_buffers(gpointer data, const gpointer user_data)
|
||||
static void
|
||||
gst_queue_cleanup_buffers (gpointer data, const gpointer user_data)
|
||||
{
|
||||
DEBUG("queue: %s cleaning buffer %p\n", (gchar *)user_data, data);
|
||||
|
||||
gst_buffer_unref (GST_BUFFER (data));
|
||||
}
|
||||
|
||||
static void gst_queue_flush(GstQueue *queue) {
|
||||
g_slist_foreach(queue->queue, gst_queue_cleanup_buffers, (char *)gst_element_get_name(GST_ELEMENT(queue)));
|
||||
g_slist_free(queue->queue);
|
||||
static void
|
||||
gst_queue_flush (GstQueue *queue)
|
||||
{
|
||||
g_slist_foreach (queue->queue, gst_queue_cleanup_buffers,
|
||||
(char *)gst_element_get_name (GST_ELEMENT (queue)));
|
||||
g_slist_free (queue->queue);
|
||||
|
||||
queue->queue = NULL;
|
||||
queue->level_buffers = 0;
|
||||
}
|
||||
|
||||
static void gst_queue_chain(GstPad *pad,GstBuffer *buf) {
|
||||
static void
|
||||
gst_queue_chain (GstPad *pad, GstBuffer *buf)
|
||||
{
|
||||
GstQueue *queue;
|
||||
gboolean tosignal = FALSE;
|
||||
const guchar *name;
|
||||
|
||||
g_return_if_fail(pad != NULL);
|
||||
g_return_if_fail(GST_IS_PAD(pad));
|
||||
g_return_if_fail(buf != NULL);
|
||||
g_return_if_fail (pad != NULL);
|
||||
g_return_if_fail (GST_IS_PAD (pad));
|
||||
g_return_if_fail (buf != NULL);
|
||||
|
||||
queue = GST_QUEUE(pad->parent);
|
||||
name = gst_element_get_name(GST_ELEMENT(queue));
|
||||
queue = GST_QUEUE (pad->parent);
|
||||
name = gst_element_get_name (GST_ELEMENT (queue));
|
||||
|
||||
/* we have to lock the queue since we span threads */
|
||||
|
||||
DEBUG("queue: try have queue lock\n");
|
||||
GST_LOCK(queue);
|
||||
DEBUG("queue: %s adding buffer %p %ld\n", name, buf, pthread_self());
|
||||
GST_LOCK (queue);
|
||||
DEBUG("queue: %s adding buffer %p %ld\n", name, buf, pthread_self ());
|
||||
DEBUG("queue: have queue lock\n");
|
||||
|
||||
if (GST_BUFFER_FLAG_IS_SET(buf, GST_BUFFER_FLUSH)) {
|
||||
gst_queue_flush(queue);
|
||||
if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLUSH)) {
|
||||
gst_queue_flush (queue);
|
||||
}
|
||||
|
||||
DEBUG("queue: %s: chain %d %p\n", name, queue->level_buffers, buf);
|
||||
|
@ -181,17 +188,17 @@ static void gst_queue_chain(GstPad *pad,GstBuffer *buf) {
|
|||
while (queue->level_buffers >= queue->max_buffers) {
|
||||
DEBUG("queue: %s waiting %d\n", name, queue->level_buffers);
|
||||
STATUS("%s: O\n");
|
||||
GST_UNLOCK(queue);
|
||||
g_mutex_lock(queue->fulllock);
|
||||
g_cond_wait(queue->fullcond,queue->fulllock);
|
||||
g_mutex_unlock(queue->fulllock);
|
||||
GST_LOCK(queue);
|
||||
GST_UNLOCK (queue);
|
||||
g_mutex_lock (queue->fulllock);
|
||||
g_cond_wait (queue->fullcond, queue->fulllock);
|
||||
g_mutex_unlock (queue->fulllock);
|
||||
GST_LOCK (queue);
|
||||
STATUS("%s: O+\n");
|
||||
DEBUG("queue: %s waiting done %d\n", name, queue->level_buffers);
|
||||
}
|
||||
|
||||
/* put the buffer on the tail of the list */
|
||||
queue->queue = g_slist_append(queue->queue,buf);
|
||||
queue->queue = g_slist_append (queue->queue, buf);
|
||||
STATUS("%s: +\n");
|
||||
|
||||
/* if we were empty, but aren't any more, signal a condition */
|
||||
|
@ -200,116 +207,127 @@ static void gst_queue_chain(GstPad *pad,GstBuffer *buf) {
|
|||
|
||||
/* we can unlock now */
|
||||
DEBUG("queue: %s chain %d end signal(%d,%p)\n", name, queue->level_buffers, tosignal, queue->emptycond);
|
||||
GST_UNLOCK(queue);
|
||||
GST_UNLOCK (queue);
|
||||
|
||||
if (tosignal) {
|
||||
g_mutex_lock(queue->emptylock);
|
||||
g_mutex_lock (queue->emptylock);
|
||||
STATUS("%s: >\n");
|
||||
g_cond_signal(queue->emptycond);
|
||||
g_cond_signal (queue->emptycond);
|
||||
STATUS("%s: >>\n");
|
||||
g_mutex_unlock(queue->emptylock);
|
||||
g_mutex_unlock (queue->emptylock);
|
||||
}
|
||||
}
|
||||
|
||||
static void gst_queue_push(GstConnection *connection) {
|
||||
GstQueue *queue = GST_QUEUE(connection);
|
||||
static void
|
||||
gst_queue_push (GstConnection *connection)
|
||||
{
|
||||
GstQueue *queue = GST_QUEUE (connection);
|
||||
GstBuffer *buf = NULL;
|
||||
GSList *front;
|
||||
gboolean tosignal = FALSE;
|
||||
const guchar *name;
|
||||
|
||||
name = gst_element_get_name(GST_ELEMENT(queue));
|
||||
name = gst_element_get_name (GST_ELEMENT (queue));
|
||||
|
||||
/* have to lock for thread-safety */
|
||||
DEBUG("queue: %s try have queue lock\n", name);
|
||||
GST_LOCK(queue);
|
||||
DEBUG("queue: %s push %d %ld %p\n", name, queue->level_buffers, pthread_self(), queue->emptycond);
|
||||
GST_LOCK (queue);
|
||||
DEBUG("queue: %s push %d %ld %p\n", name, queue->level_buffers, pthread_self (), queue->emptycond);
|
||||
DEBUG("queue: %s have queue lock\n", name);
|
||||
|
||||
while (!queue->level_buffers) {
|
||||
STATUS("queue: %s U released lock\n");
|
||||
GST_UNLOCK(queue);
|
||||
g_mutex_lock(queue->emptylock);
|
||||
g_cond_wait(queue->emptycond,queue->emptylock);
|
||||
g_mutex_unlock(queue->emptylock);
|
||||
GST_LOCK(queue);
|
||||
GST_UNLOCK (queue);
|
||||
g_mutex_lock (queue->emptylock);
|
||||
g_cond_wait (queue->emptycond, queue->emptylock);
|
||||
g_mutex_unlock (queue->emptylock);
|
||||
GST_LOCK (queue);
|
||||
STATUS("queue: %s U- getting lock\n");
|
||||
}
|
||||
|
||||
front = queue->queue;
|
||||
buf = (GstBuffer *)(front->data);
|
||||
queue->queue = g_slist_remove_link(queue->queue,front);
|
||||
g_slist_free(front);
|
||||
queue->queue = g_slist_remove_link (queue->queue, front);
|
||||
g_slist_free (front);
|
||||
|
||||
queue->level_buffers--;
|
||||
STATUS("%s: -\n");
|
||||
tosignal = queue->level_buffers < queue->max_buffers;
|
||||
GST_UNLOCK(queue);
|
||||
|
||||
if (tosignal) {
|
||||
g_mutex_lock(queue->fulllock);
|
||||
g_mutex_lock (queue->fulllock);
|
||||
STATUS("%s: < \n");
|
||||
g_cond_signal(queue->fullcond);
|
||||
g_cond_signal (queue->fullcond);
|
||||
STATUS("%s: << \n");
|
||||
g_mutex_unlock(queue->fulllock);
|
||||
g_mutex_unlock (queue->fulllock);
|
||||
}
|
||||
|
||||
DEBUG("queue: %s pushing %d %p \n", name, queue->level_buffers, buf);
|
||||
gst_pad_push(queue->srcpad,buf);
|
||||
gst_pad_push (queue->srcpad, buf);
|
||||
DEBUG("queue: %s pushing %d done \n", name, queue->level_buffers);
|
||||
|
||||
/* unlock now */
|
||||
}
|
||||
|
||||
static GstElementStateReturn gst_queue_change_state(GstElement *element) {
|
||||
static GstElementStateReturn
|
||||
gst_queue_change_state (GstElement *element)
|
||||
{
|
||||
GstQueue *queue;
|
||||
g_return_val_if_fail(GST_IS_QUEUE(element),GST_STATE_FAILURE);
|
||||
g_return_val_if_fail (GST_IS_QUEUE (element), GST_STATE_FAILURE);
|
||||
|
||||
queue = GST_QUEUE(element);
|
||||
DEBUG("gstqueue: state pending %d\n", GST_STATE_PENDING(element));
|
||||
queue = GST_QUEUE (element);
|
||||
DEBUG("gstqueue: state pending %d\n", GST_STATE_PENDING (element));
|
||||
|
||||
/* if going down into NULL state, clear out buffers*/
|
||||
if (GST_STATE_PENDING(element) == GST_STATE_READY) {
|
||||
if (GST_STATE_PENDING (element) == GST_STATE_READY) {
|
||||
/* otherwise (READY or higher) we need to open the file */
|
||||
gst_queue_flush(queue);
|
||||
gst_queue_flush (queue);
|
||||
}
|
||||
|
||||
/* if we haven't failed already, give the parent class a chance to ;-) */
|
||||
if (GST_ELEMENT_CLASS(parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS(parent_class)->change_state(element);
|
||||
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
||||
|
||||
return GST_STATE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static void gst_queue_set_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_queue_set_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstQueue *queue;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_QUEUE(object));
|
||||
queue = GST_QUEUE(object);
|
||||
g_return_if_fail (GST_IS_QUEUE (object));
|
||||
|
||||
queue = GST_QUEUE (object);
|
||||
|
||||
switch(id) {
|
||||
case ARG_MAX_LEVEL:
|
||||
queue->max_buffers = GTK_VALUE_INT(*arg);
|
||||
queue->max_buffers = GTK_VALUE_INT (*arg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void gst_queue_get_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_queue_get_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstQueue *queue;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_QUEUE(object));
|
||||
queue = GST_QUEUE(object);
|
||||
g_return_if_fail (GST_IS_QUEUE (object));
|
||||
|
||||
queue = GST_QUEUE (object);
|
||||
|
||||
switch (id) {
|
||||
case ARG_LEVEL:
|
||||
GTK_VALUE_INT(*arg) = queue->level_buffers;
|
||||
GTK_VALUE_INT (*arg) = queue->level_buffers;
|
||||
break;
|
||||
case ARG_MAX_LEVEL:
|
||||
GTK_VALUE_INT(*arg) = queue->max_buffers;
|
||||
GTK_VALUE_INT (*arg) = queue->max_buffers;
|
||||
break;
|
||||
default:
|
||||
arg->type = GTK_TYPE_INVALID;
|
||||
|
|
|
@ -73,7 +73,7 @@ struct _GstQueueClass {
|
|||
GstConnectionClass parent_class;
|
||||
};
|
||||
|
||||
GtkType gst_queue_get_type(void);
|
||||
GtkType gst_queue_get_type (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ GstElementDetails gst_sinesrc_details;
|
|||
#define GST_IS_SINESRC(obj) \
|
||||
(GTK_CHECK_TYPE((obj),GST_TYPE_SINESRC))
|
||||
#define GST_IS_SINESRC_CLASS(obj) \
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_SINESRC)))
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_SINESRC))
|
||||
|
||||
typedef struct _GstSineSrc GstSineSrc;
|
||||
typedef struct _GstSineSrcClass GstSineSrcClass;
|
||||
|
|
|
@ -47,21 +47,21 @@ enum {
|
|||
};
|
||||
|
||||
|
||||
static void gst_pipeline_class_init(GstPipelineClass *klass);
|
||||
static void gst_pipeline_init(GstPipeline *pipeline);
|
||||
static void gst_pipeline_class_init (GstPipelineClass *klass);
|
||||
static void gst_pipeline_init (GstPipeline *pipeline);
|
||||
|
||||
static GstElementStateReturn gst_pipeline_change_state(GstElement *element);
|
||||
static GstElementStateReturn gst_pipeline_change_state (GstElement *element);
|
||||
|
||||
static void gst_pipeline_prepare(GstPipeline *pipeline);
|
||||
static void gst_pipeline_prepare (GstPipeline *pipeline);
|
||||
|
||||
static void gst_pipeline_have_type(GstSink *sink, GstSink *sink2, gpointer data);
|
||||
static void gst_pipeline_pads_autoplug(GstElement *src, GstElement *sink);
|
||||
static void gst_pipeline_have_type (GstSink *sink, GstSink *sink2, gpointer data);
|
||||
static void gst_pipeline_pads_autoplug (GstElement *src, GstElement *sink);
|
||||
|
||||
static GstBin *parent_class = NULL;
|
||||
//static guint gst_pipeline_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
GtkType
|
||||
gst_pipeline_get_type(void) {
|
||||
gst_pipeline_get_type (void) {
|
||||
static GtkType pipeline_type = 0;
|
||||
|
||||
if (!pipeline_type) {
|
||||
|
@ -75,13 +75,14 @@ gst_pipeline_get_type(void) {
|
|||
(GtkArgGetFunc)NULL,
|
||||
(GtkClassInitFunc)NULL,
|
||||
};
|
||||
pipeline_type = gtk_type_unique(gst_bin_get_type(),&pipeline_info);
|
||||
pipeline_type = gtk_type_unique (gst_bin_get_type (), &pipeline_info);
|
||||
}
|
||||
return pipeline_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_pipeline_class_init(GstPipelineClass *klass) {
|
||||
gst_pipeline_class_init (GstPipelineClass *klass)
|
||||
{
|
||||
GstElementClass *gstelement_class;
|
||||
|
||||
gstelement_class = (GstElementClass*)klass;
|
||||
|
@ -89,10 +90,12 @@ gst_pipeline_class_init(GstPipelineClass *klass) {
|
|||
parent_class = gtk_type_class(gst_bin_get_type());
|
||||
|
||||
gstelement_class->change_state = gst_pipeline_change_state;
|
||||
gstelement_class->elementfactory = gst_elementfactory_find("pipeline");
|
||||
gstelement_class->elementfactory = gst_elementfactory_find ("pipeline");
|
||||
}
|
||||
|
||||
static void gst_pipeline_init(GstPipeline *pipeline) {
|
||||
static void
|
||||
gst_pipeline_init (GstPipeline *pipeline)
|
||||
{
|
||||
pipeline->src = NULL;
|
||||
pipeline->sinks = NULL;
|
||||
}
|
||||
|
@ -106,26 +109,35 @@ static void gst_pipeline_init(GstPipeline *pipeline) {
|
|||
*
|
||||
* Returns: newly created GstPipeline
|
||||
*/
|
||||
GstElement *gst_pipeline_new(guchar *name) {
|
||||
GstElement*
|
||||
gst_pipeline_new (guchar *name)
|
||||
{
|
||||
GstPipeline *pipeline;
|
||||
|
||||
pipeline = gtk_type_new(gst_pipeline_get_type());
|
||||
gst_element_set_name(GST_ELEMENT(pipeline),name);
|
||||
return GST_ELEMENT(pipeline);
|
||||
pipeline = gtk_type_new (gst_pipeline_get_type ());
|
||||
gst_element_set_name (GST_ELEMENT (pipeline), name);
|
||||
|
||||
return GST_ELEMENT (pipeline);
|
||||
}
|
||||
|
||||
static void gst_pipeline_prepare(GstPipeline *pipeline) {
|
||||
static void
|
||||
gst_pipeline_prepare (GstPipeline *pipeline)
|
||||
{
|
||||
g_print("GstPipeline: preparing pipeline \"%s\" for playing\n",
|
||||
gst_element_get_name(GST_ELEMENT(pipeline)));
|
||||
}
|
||||
|
||||
static void gst_pipeline_have_type(GstSink *sink, GstSink *sink2, gpointer data) {
|
||||
static void
|
||||
gst_pipeline_have_type (GstSink *sink, GstSink *sink2, gpointer data)
|
||||
{
|
||||
g_print("GstPipeline: pipeline have type %p\n", (gboolean *)data);
|
||||
|
||||
*(gboolean *)data = TRUE;
|
||||
}
|
||||
|
||||
static guint16 gst_pipeline_typefind(GstPipeline *pipeline, GstElement *element) {
|
||||
static guint16
|
||||
gst_pipeline_typefind (GstPipeline *pipeline, GstElement *element)
|
||||
{
|
||||
gboolean found = FALSE;
|
||||
GstElement *typefind;
|
||||
guint16 type_id = 0;
|
||||
|
@ -133,42 +145,44 @@ static guint16 gst_pipeline_typefind(GstPipeline *pipeline, GstElement *element)
|
|||
g_print("GstPipeline: typefind for element \"%s\" %p\n",
|
||||
gst_element_get_name(element), &found);
|
||||
|
||||
typefind = gst_elementfactory_make("typefind","typefind");
|
||||
g_return_val_if_fail(typefind != NULL, FALSE);
|
||||
typefind = gst_elementfactory_make ("typefind", "typefind");
|
||||
g_return_val_if_fail (typefind != NULL, FALSE);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(typefind),"have_type",
|
||||
GTK_SIGNAL_FUNC(gst_pipeline_have_type), &found);
|
||||
gtk_signal_connect (GTK_OBJECT (typefind), "have_type",
|
||||
GTK_SIGNAL_FUNC (gst_pipeline_have_type), &found);
|
||||
|
||||
gst_pad_connect(gst_element_get_pad(element,"src"),
|
||||
gst_element_get_pad(typefind,"sink"));
|
||||
gst_pad_connect (gst_element_get_pad (element, "src"),
|
||||
gst_element_get_pad (typefind, "sink"));
|
||||
|
||||
gst_bin_add(GST_BIN(pipeline), typefind);
|
||||
gst_bin_add (GST_BIN (pipeline), typefind);
|
||||
|
||||
gst_bin_create_plan(GST_BIN(pipeline));
|
||||
gst_element_set_state(GST_ELEMENT(element),GST_STATE_READY);
|
||||
gst_element_set_state(GST_ELEMENT(element),GST_STATE_PLAYING);
|
||||
gst_bin_create_plan (GST_BIN (pipeline));
|
||||
gst_element_set_state (GST_ELEMENT (element), GST_STATE_READY);
|
||||
gst_element_set_state (GST_ELEMENT (element), GST_STATE_PLAYING);
|
||||
|
||||
// keep pushing buffers... the have_type signal handler will set the found flag
|
||||
while (!found) {
|
||||
gst_src_push(GST_SRC(element));
|
||||
gst_src_push (GST_SRC (element));
|
||||
}
|
||||
|
||||
gst_element_set_state(GST_ELEMENT(element),GST_STATE_NULL);
|
||||
gst_element_set_state (GST_ELEMENT (element), GST_STATE_NULL);
|
||||
|
||||
if (found) {
|
||||
type_id = gst_util_get_int_arg(GTK_OBJECT(typefind),"type");
|
||||
gst_pad_set_type_id(gst_element_get_pad(element, "src"), type_id);
|
||||
type_id = gst_util_get_int_arg (GTK_OBJECT (typefind), "type");
|
||||
gst_pad_set_type_id (gst_element_get_pad (element, "src"), type_id);
|
||||
}
|
||||
|
||||
gst_pad_disconnect(gst_element_get_pad(element,"src"),
|
||||
gst_element_get_pad(typefind,"sink"));
|
||||
gst_bin_remove(GST_BIN(pipeline), typefind);
|
||||
gst_object_unref(GST_OBJECT(typefind));
|
||||
gst_pad_disconnect (gst_element_get_pad (element, "src"),
|
||||
gst_element_get_pad (typefind, "sink"));
|
||||
gst_bin_remove (GST_BIN (pipeline), typefind);
|
||||
gst_object_unref (GST_OBJECT (typefind));
|
||||
|
||||
return type_id;
|
||||
}
|
||||
|
||||
static void gst_pipeline_pads_autoplug_func(GstElement *src, GstPad *pad, GstElement *sink) {
|
||||
static void
|
||||
gst_pipeline_pads_autoplug_func (GstElement *src, GstPad *pad, GstElement *sink)
|
||||
{
|
||||
GList *sinkpads;
|
||||
GstPad *sinkpad;
|
||||
gboolean connected = FALSE;
|
||||
|
@ -201,7 +215,9 @@ static void gst_pipeline_pads_autoplug_func(GstElement *src, GstPad *pad, GstEle
|
|||
}
|
||||
}
|
||||
|
||||
static void gst_pipeline_pads_autoplug(GstElement *src, GstElement *sink) {
|
||||
static void
|
||||
gst_pipeline_pads_autoplug (GstElement *src, GstElement *sink)
|
||||
{
|
||||
GList *srcpads, *sinkpads;
|
||||
gboolean connected = FALSE;
|
||||
|
||||
|
@ -255,12 +271,13 @@ end:
|
|||
* than one src element, the previously added element will
|
||||
* be removed.
|
||||
*/
|
||||
void gst_pipeline_add_src(GstPipeline *pipeline, GstElement *src)
|
||||
void
|
||||
gst_pipeline_add_src (GstPipeline *pipeline, GstElement *src)
|
||||
{
|
||||
g_return_if_fail(pipeline != NULL);
|
||||
g_return_if_fail(GST_IS_PIPELINE(pipeline));
|
||||
g_return_if_fail(src != NULL);
|
||||
g_return_if_fail(GST_IS_ELEMENT(src));
|
||||
g_return_if_fail (pipeline != NULL);
|
||||
g_return_if_fail (GST_IS_PIPELINE (pipeline));
|
||||
g_return_if_fail (src != NULL);
|
||||
g_return_if_fail (GST_IS_ELEMENT (src));
|
||||
|
||||
if (pipeline->src) {
|
||||
printf("gstpipeline: *WARNING* removing previously added element \"%s\"\n",
|
||||
|
@ -279,14 +296,15 @@ void gst_pipeline_add_src(GstPipeline *pipeline, GstElement *src)
|
|||
* Adds a sink element to the pipeline. This element
|
||||
* will be used as a sink for autoplugging
|
||||
*/
|
||||
void gst_pipeline_add_sink(GstPipeline *pipeline, GstElement *sink)
|
||||
void
|
||||
gst_pipeline_add_sink (GstPipeline *pipeline, GstElement *sink)
|
||||
{
|
||||
g_return_if_fail(pipeline != NULL);
|
||||
g_return_if_fail(GST_IS_PIPELINE(pipeline));
|
||||
g_return_if_fail(sink != NULL);
|
||||
g_return_if_fail(GST_IS_ELEMENT(sink));
|
||||
g_return_if_fail (pipeline != NULL);
|
||||
g_return_if_fail (GST_IS_PIPELINE (pipeline));
|
||||
g_return_if_fail (sink != NULL);
|
||||
g_return_if_fail (GST_IS_ELEMENT (sink));
|
||||
|
||||
pipeline->sinks = g_list_prepend(pipeline->sinks, sink);
|
||||
pipeline->sinks = g_list_prepend (pipeline->sinks, sink);
|
||||
//gst_bin_add(GST_BIN(pipeline), sink);
|
||||
}
|
||||
|
||||
|
@ -299,7 +317,9 @@ void gst_pipeline_add_sink(GstPipeline *pipeline, GstElement *sink)
|
|||
*
|
||||
* Returns: a gboolean indicating success or failure.
|
||||
*/
|
||||
gboolean gst_pipeline_autoplug(GstPipeline *pipeline) {
|
||||
gboolean
|
||||
gst_pipeline_autoplug (GstPipeline *pipeline)
|
||||
{
|
||||
GList *elements;
|
||||
GstElement *element, *srcelement = NULL, *sinkelement= NULL;
|
||||
GList **factories;
|
||||
|
@ -500,24 +520,27 @@ next:
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static GstElementStateReturn gst_pipeline_change_state(GstElement *element) {
|
||||
static GstElementStateReturn
|
||||
gst_pipeline_change_state (GstElement *element)
|
||||
{
|
||||
GstPipeline *pipeline;
|
||||
|
||||
g_return_val_if_fail(GST_IS_PIPELINE(element), FALSE);
|
||||
pipeline = GST_PIPELINE(element);
|
||||
g_return_val_if_fail (GST_IS_PIPELINE (element), FALSE);
|
||||
|
||||
pipeline = GST_PIPELINE (element);
|
||||
|
||||
|
||||
switch (GST_STATE_PENDING(pipeline)) {
|
||||
switch (GST_STATE_PENDING (pipeline)) {
|
||||
case GST_STATE_READY:
|
||||
// we need to set up internal state
|
||||
gst_pipeline_prepare(pipeline);
|
||||
gst_pipeline_prepare (pipeline);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (GST_ELEMENT_CLASS(parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS(parent_class)->change_state(element);
|
||||
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
||||
|
||||
return GST_STATE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -528,7 +551,9 @@ static GstElementStateReturn gst_pipeline_change_state(GstElement *element) {
|
|||
*
|
||||
* Cause the pipeline's contents to be run through one full 'iteration'.
|
||||
*/
|
||||
void gst_pipeline_iterate(GstPipeline *pipeline) {
|
||||
g_return_if_fail(pipeline != NULL);
|
||||
g_return_if_fail(GST_IS_PIPELINE(pipeline));
|
||||
void
|
||||
gst_pipeline_iterate (GstPipeline *pipeline)
|
||||
{
|
||||
g_return_if_fail (pipeline != NULL);
|
||||
g_return_if_fail (GST_IS_PIPELINE(pipeline));
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ extern "C" {
|
|||
|
||||
GstElementDetails gst_asyncdisksrc_details;
|
||||
|
||||
|
||||
#define GST_TYPE_ASYNCDISKSRC \
|
||||
(gst_asyncdisksrc_get_type())
|
||||
#define GST_ASYNCDISKSRC(obj) \
|
||||
|
|
|
@ -40,15 +40,17 @@ GstElementDetails gst_audiosink_details = {
|
|||
"(C) 1999",
|
||||
};
|
||||
|
||||
static void gst_audiosink_class_init (GstAudioSinkClass *klass);
|
||||
static void gst_audiosink_init (GstAudioSink *audiosink);
|
||||
|
||||
static gboolean gst_audiosink_open_audio(GstAudioSink *sink);
|
||||
static void gst_audiosink_close_audio(GstAudioSink *sink);
|
||||
static GstElementStateReturn gst_audiosink_change_state(GstElement *element);
|
||||
static gboolean gst_audiosink_open_audio (GstAudioSink *sink);
|
||||
static void gst_audiosink_close_audio (GstAudioSink *sink);
|
||||
static GstElementStateReturn gst_audiosink_change_state (GstElement *element);
|
||||
|
||||
static void gst_audiosink_set_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_audiosink_get_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_audiosink_set_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
static void gst_audiosink_get_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
|
||||
void gst_audiosink_chain(GstPad *pad,GstBuffer *buf);
|
||||
static void gst_audiosink_chain (GstPad *pad,GstBuffer *buf);
|
||||
|
||||
/* AudioSink signals and args */
|
||||
enum {
|
||||
|
@ -67,7 +69,7 @@ enum {
|
|||
|
||||
#define GST_TYPE_AUDIOSINK_FORMATS (gst_audiosink_formats_get_type())
|
||||
|
||||
GtkType
|
||||
static GtkType
|
||||
gst_audiosink_formats_get_type(void) {
|
||||
static GtkType audiosink_formats_type = 0;
|
||||
static GtkEnumValue audiosink_formats[] = {
|
||||
|
@ -83,7 +85,7 @@ gst_audiosink_formats_get_type(void) {
|
|||
|
||||
#define GST_TYPE_AUDIOSINK_CHANNELS (gst_audiosink_channels_get_type())
|
||||
|
||||
GtkType
|
||||
static GtkType
|
||||
gst_audiosink_channels_get_type(void) {
|
||||
static GtkType audiosink_channels_type = 0;
|
||||
static GtkEnumValue audiosink_channels[] = {
|
||||
|
@ -97,9 +99,6 @@ gst_audiosink_channels_get_type(void) {
|
|||
return audiosink_channels_type;
|
||||
}
|
||||
|
||||
static void gst_audiosink_class_init(GstAudioSinkClass *klass);
|
||||
static void gst_audiosink_init(GstAudioSink *audiosink);
|
||||
|
||||
|
||||
static GstSinkClass *parent_class = NULL;
|
||||
static guint gst_audiosink_signals[LAST_SIGNAL] = { 0 };
|
||||
|
@ -107,7 +106,8 @@ static guint gst_audiosink_signals[LAST_SIGNAL] = { 0 };
|
|||
static guint16 gst_audiosink_type_audio = 0;
|
||||
|
||||
GtkType
|
||||
gst_audiosink_get_type(void) {
|
||||
gst_audiosink_get_type (void)
|
||||
{
|
||||
static GtkType audiosink_type = 0;
|
||||
|
||||
if (!audiosink_type) {
|
||||
|
@ -121,17 +121,18 @@ gst_audiosink_get_type(void) {
|
|||
(GtkArgGetFunc)NULL,
|
||||
(GtkClassInitFunc)NULL,
|
||||
};
|
||||
audiosink_type = gtk_type_unique(GST_TYPE_SINK,&audiosink_info);
|
||||
audiosink_type = gtk_type_unique (GST_TYPE_SINK, &audiosink_info);
|
||||
}
|
||||
|
||||
if (!gst_audiosink_type_audio)
|
||||
gst_audiosink_type_audio = gst_type_find_by_mime("audio/raw");
|
||||
gst_audiosink_type_audio = gst_type_find_by_mime ("audio/raw");
|
||||
|
||||
return audiosink_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_audiosink_class_init(GstAudioSinkClass *klass) {
|
||||
gst_audiosink_class_init (GstAudioSinkClass *klass)
|
||||
{
|
||||
GtkObjectClass *gtkobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
|
||||
|
@ -140,13 +141,13 @@ gst_audiosink_class_init(GstAudioSinkClass *klass) {
|
|||
|
||||
parent_class = gtk_type_class(GST_TYPE_FILTER);
|
||||
|
||||
gtk_object_add_arg_type("GstAudioSink::mute", GTK_TYPE_BOOL,
|
||||
gtk_object_add_arg_type ("GstAudioSink::mute", GTK_TYPE_BOOL,
|
||||
GTK_ARG_READWRITE, ARG_MUTE);
|
||||
gtk_object_add_arg_type("GstAudioSink::format", GST_TYPE_AUDIOSINK_FORMATS,
|
||||
gtk_object_add_arg_type ("GstAudioSink::format", GST_TYPE_AUDIOSINK_FORMATS,
|
||||
GTK_ARG_READWRITE, ARG_FORMAT);
|
||||
gtk_object_add_arg_type("GstAudioSink::channels", GST_TYPE_AUDIOSINK_CHANNELS,
|
||||
gtk_object_add_arg_type ("GstAudioSink::channels", GST_TYPE_AUDIOSINK_CHANNELS,
|
||||
GTK_ARG_READWRITE, ARG_CHANNELS);
|
||||
gtk_object_add_arg_type("GstAudioSink::frequency", GTK_TYPE_INT,
|
||||
gtk_object_add_arg_type ("GstAudioSink::frequency", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_FREQUENCY);
|
||||
|
||||
gtkobject_class->set_arg = gst_audiosink_set_arg;
|
||||
|
@ -156,174 +157,184 @@ gst_audiosink_class_init(GstAudioSinkClass *klass) {
|
|||
gtk_signal_new("handoff",GTK_RUN_LAST,gtkobject_class->type,
|
||||
GTK_SIGNAL_OFFSET(GstAudioSinkClass,handoff),
|
||||
gtk_marshal_NONE__NONE,GTK_TYPE_NONE,0);
|
||||
|
||||
gtk_object_class_add_signals(gtkobject_class,gst_audiosink_signals,
|
||||
LAST_SIGNAL);
|
||||
|
||||
gstelement_class->change_state = gst_audiosink_change_state;
|
||||
}
|
||||
|
||||
static void gst_audiosink_init(GstAudioSink *audiosink) {
|
||||
audiosink->sinkpad = gst_pad_new("sink",GST_PAD_SINK);
|
||||
gst_element_add_pad(GST_ELEMENT(audiosink),audiosink->sinkpad);
|
||||
static void
|
||||
gst_audiosink_init (GstAudioSink *audiosink)
|
||||
{
|
||||
audiosink->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
|
||||
gst_element_add_pad (GST_ELEMENT (audiosink), audiosink->sinkpad);
|
||||
gst_pad_set_type_id (audiosink->sinkpad, gst_audiosink_type_audio);
|
||||
|
||||
gst_pad_set_type_id(audiosink->sinkpad,gst_audiosink_type_audio);
|
||||
|
||||
gst_pad_set_chain_function(audiosink->sinkpad,gst_audiosink_chain);
|
||||
gst_pad_set_chain_function (audiosink->sinkpad, gst_audiosink_chain);
|
||||
|
||||
audiosink->fd = -1;
|
||||
audiosink->clock = gst_clock_get_system();
|
||||
gst_clock_register(audiosink->clock, GST_OBJECT(audiosink));
|
||||
//audiosink->clocktime = 0LL;
|
||||
|
||||
gst_clock_register (audiosink->clock, GST_OBJECT (audiosink));
|
||||
|
||||
GST_FLAG_SET(audiosink, GST_ELEMENT_THREAD_SUGGESTED);
|
||||
GST_FLAG_SET (audiosink, GST_ELEMENT_THREAD_SUGGESTED);
|
||||
}
|
||||
|
||||
void gst_audiosink_sync_parms(GstAudioSink *audiosink) {
|
||||
static void
|
||||
gst_audiosink_sync_parms (GstAudioSink *audiosink)
|
||||
{
|
||||
audio_buf_info ospace;
|
||||
int frag;
|
||||
|
||||
g_return_if_fail(audiosink != NULL);
|
||||
g_return_if_fail(GST_IS_AUDIOSINK(audiosink));
|
||||
g_return_if_fail (audiosink != NULL);
|
||||
g_return_if_fail (GST_IS_AUDIOSINK (audiosink));
|
||||
|
||||
if (audiosink->fd == -1) return;
|
||||
|
||||
ioctl(audiosink->fd,SNDCTL_DSP_RESET,0);
|
||||
ioctl (audiosink->fd,SNDCTL_DSP_RESET, 0);
|
||||
|
||||
ioctl(audiosink->fd,SNDCTL_DSP_SETFMT,&audiosink->format);
|
||||
ioctl(audiosink->fd,SNDCTL_DSP_CHANNELS,&audiosink->channels);
|
||||
ioctl(audiosink->fd,SNDCTL_DSP_SPEED,&audiosink->frequency);
|
||||
ioctl(audiosink->fd,SNDCTL_DSP_GETBLKSIZE, &frag);
|
||||
ioctl (audiosink->fd, SNDCTL_DSP_SETFMT, &audiosink->format);
|
||||
ioctl (audiosink->fd, SNDCTL_DSP_CHANNELS, &audiosink->channels);
|
||||
ioctl (audiosink->fd, SNDCTL_DSP_SPEED, &audiosink->frequency);
|
||||
ioctl (audiosink->fd, SNDCTL_DSP_GETBLKSIZE, &frag);
|
||||
|
||||
ioctl(audiosink->fd,SNDCTL_DSP_GETOSPACE,&ospace);
|
||||
ioctl (audiosink->fd, SNDCTL_DSP_GETOSPACE, &ospace);
|
||||
|
||||
g_print("audiosink: setting sound card to %dKHz %d bit %s (%d bytes buffer, %d fragment)\n",
|
||||
audiosink->frequency,audiosink->format,
|
||||
(audiosink->channels == 2) ? "stereo" : "mono",ospace.bytes, frag);
|
||||
audiosink->frequency, audiosink->format,
|
||||
(audiosink->channels == 2) ? "stereo" : "mono", ospace.bytes, frag);
|
||||
|
||||
}
|
||||
|
||||
GstElement *gst_audiosink_new(gchar *name) {
|
||||
GstElement *audiosink = GST_ELEMENT(gtk_type_new(GST_TYPE_AUDIOSINK));
|
||||
gst_element_set_name(GST_ELEMENT(audiosink),name);
|
||||
return audiosink;
|
||||
}
|
||||
|
||||
void gst_audiosink_chain(GstPad *pad,GstBuffer *buf) {
|
||||
static void
|
||||
gst_audiosink_chain (GstPad *pad, GstBuffer *buf)
|
||||
{
|
||||
GstAudioSink *audiosink;
|
||||
MetaAudioRaw *meta;
|
||||
gboolean in_flush;
|
||||
audio_buf_info ospace;
|
||||
|
||||
g_return_if_fail(pad != NULL);
|
||||
g_return_if_fail(GST_IS_PAD(pad));
|
||||
g_return_if_fail(buf != NULL);
|
||||
g_return_if_fail (pad != NULL);
|
||||
g_return_if_fail (GST_IS_PAD (pad));
|
||||
g_return_if_fail (buf != NULL);
|
||||
|
||||
|
||||
/* this has to be an audio buffer */
|
||||
// g_return_if_fail(((GstMeta *)buf->meta)->type !=
|
||||
//gst_audiosink_type_audio);
|
||||
audiosink = GST_AUDIOSINK(pad->parent);
|
||||
audiosink = GST_AUDIOSINK (pad->parent);
|
||||
// g_return_if_fail(GST_FLAG_IS_SET(audiosink,GST_STATE_RUNNING));
|
||||
|
||||
if ((in_flush = GST_BUFFER_FLAG_IS_SET(buf, GST_BUFFER_FLUSH))) {
|
||||
DEBUG("audiosink: flush\n");
|
||||
ioctl(audiosink->fd,SNDCTL_DSP_RESET,0);
|
||||
if ((in_flush = GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLUSH))) {
|
||||
DEBUG ("audiosink: flush\n");
|
||||
ioctl (audiosink->fd, SNDCTL_DSP_RESET, 0);
|
||||
}
|
||||
|
||||
|
||||
meta = (MetaAudioRaw *)gst_buffer_get_first_meta(buf);
|
||||
meta = (MetaAudioRaw *)gst_buffer_get_first_meta (buf);
|
||||
if (meta != NULL) {
|
||||
if ((meta->format != audiosink->format) ||
|
||||
(meta->channels != audiosink->channels) ||
|
||||
(meta->frequency != audiosink->frequency)) {
|
||||
audiosink->format = meta->format;
|
||||
audiosink->channels = meta->channels;
|
||||
(meta->frequency != audiosink->frequency))
|
||||
{
|
||||
audiosink->format = meta->format;
|
||||
audiosink->channels = meta->channels;
|
||||
audiosink->frequency = meta->frequency;
|
||||
gst_audiosink_sync_parms(audiosink);
|
||||
gst_audiosink_sync_parms (audiosink);
|
||||
g_print("audiosink: sound device set to format %d, %d channels, %dHz\n",
|
||||
audiosink->format,audiosink->channels,audiosink->frequency);
|
||||
audiosink->format, audiosink->channels, audiosink->frequency);
|
||||
}
|
||||
}
|
||||
|
||||
gtk_signal_emit(GTK_OBJECT(audiosink),gst_audiosink_signals[SIGNAL_HANDOFF],
|
||||
gtk_signal_emit (GTK_OBJECT (audiosink), gst_audiosink_signals[SIGNAL_HANDOFF],
|
||||
audiosink);
|
||||
|
||||
if (GST_BUFFER_DATA(buf) != NULL) {
|
||||
gst_trace_add_entry(NULL,0,buf,"audiosink: writing to soundcard");
|
||||
if (GST_BUFFER_DATA (buf) != NULL) {
|
||||
gst_trace_add_entry(NULL, 0, buf, "audiosink: writing to soundcard");
|
||||
//g_print("audiosink: writing to soundcard\n");
|
||||
if (audiosink->fd > 2) {
|
||||
if (!audiosink->mute) {
|
||||
gst_clock_wait(audiosink->clock, GST_BUFFER_TIMESTAMP(buf), GST_OBJECT(audiosink));
|
||||
ioctl(audiosink->fd,SNDCTL_DSP_GETOSPACE,&ospace);
|
||||
DEBUG("audiosink: (%d bytes buffer) %d %p %d\n", ospace.bytes, audiosink->fd, GST_BUFFER_DATA(buf), GST_BUFFER_SIZE(buf));
|
||||
write(audiosink->fd,GST_BUFFER_DATA(buf),GST_BUFFER_SIZE(buf));
|
||||
gst_clock_wait (audiosink->clock, GST_BUFFER_TIMESTAMP (buf), GST_OBJECT (audiosink));
|
||||
ioctl (audiosink->fd, SNDCTL_DSP_GETOSPACE, &ospace);
|
||||
DEBUG ("audiosink: (%d bytes buffer) %d %p %d\n", ospace.bytes,
|
||||
audiosink->fd, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
|
||||
write (audiosink->fd, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
|
||||
//write(STDOUT_FILENO,GST_BUFFER_DATA(buf),GST_BUFFER_SIZE(buf));
|
||||
}
|
||||
}
|
||||
}
|
||||
gst_buffer_unref(buf);
|
||||
gst_buffer_unref (buf);
|
||||
}
|
||||
|
||||
static void gst_audiosink_set_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_audiosink_set_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstAudioSink *audiosink;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_AUDIOSINK(object));
|
||||
audiosink = GST_AUDIOSINK(object);
|
||||
g_return_if_fail (GST_IS_AUDIOSINK (object));
|
||||
|
||||
audiosink = GST_AUDIOSINK (object);
|
||||
|
||||
switch(id) {
|
||||
case ARG_MUTE:
|
||||
audiosink->mute = GTK_VALUE_BOOL(*arg);
|
||||
audiosink->mute = GTK_VALUE_BOOL (*arg);
|
||||
break;
|
||||
case ARG_FORMAT:
|
||||
audiosink->format = GTK_VALUE_ENUM(*arg);
|
||||
gst_audiosink_sync_parms(audiosink);
|
||||
audiosink->format = GTK_VALUE_ENUM (*arg);
|
||||
gst_audiosink_sync_parms (audiosink);
|
||||
break;
|
||||
case ARG_CHANNELS:
|
||||
audiosink->channels = GTK_VALUE_ENUM(*arg);
|
||||
gst_audiosink_sync_parms(audiosink);
|
||||
audiosink->channels = GTK_VALUE_ENUM (*arg);
|
||||
gst_audiosink_sync_parms (audiosink);
|
||||
break;
|
||||
case ARG_FREQUENCY:
|
||||
audiosink->frequency = GTK_VALUE_INT(*arg);
|
||||
gst_audiosink_sync_parms(audiosink);
|
||||
audiosink->frequency = GTK_VALUE_INT (*arg);
|
||||
gst_audiosink_sync_parms (audiosink);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void gst_audiosink_get_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_audiosink_get_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstAudioSink *audiosink;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_AUDIOSINK(object));
|
||||
audiosink = GST_AUDIOSINK(object);
|
||||
g_return_if_fail (GST_IS_AUDIOSINK (object));
|
||||
|
||||
audiosink = GST_AUDIOSINK (object);
|
||||
|
||||
switch(id) {
|
||||
case ARG_MUTE:
|
||||
GTK_VALUE_BOOL(*arg) = audiosink->mute;
|
||||
GTK_VALUE_BOOL (*arg) = audiosink->mute;
|
||||
break;
|
||||
case ARG_FORMAT:
|
||||
GTK_VALUE_ENUM(*arg) = audiosink->format;
|
||||
GTK_VALUE_ENUM (*arg) = audiosink->format;
|
||||
break;
|
||||
case ARG_CHANNELS:
|
||||
GTK_VALUE_ENUM(*arg) = audiosink->channels;
|
||||
GTK_VALUE_ENUM (*arg) = audiosink->channels;
|
||||
break;
|
||||
case ARG_FREQUENCY:
|
||||
GTK_VALUE_INT(*arg) = audiosink->frequency;
|
||||
GTK_VALUE_INT (*arg) = audiosink->frequency;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean gst_audiosink_open_audio(GstAudioSink *sink) {
|
||||
g_return_val_if_fail(sink->fd == -1, FALSE);
|
||||
static gboolean
|
||||
gst_audiosink_open_audio (GstAudioSink *sink)
|
||||
{
|
||||
g_return_val_if_fail (sink->fd == -1, FALSE);
|
||||
|
||||
g_print("audiosink: attempting to open sound device\n");
|
||||
g_print ("audiosink: attempting to open sound device\n");
|
||||
|
||||
/* first try to open the sound card */
|
||||
sink->fd = open("/dev/dsp",O_WRONLY);
|
||||
sink->fd = open("/dev/dsp", O_WRONLY);
|
||||
|
||||
/* if we have it, set the default parameters and go have fun */
|
||||
if (sink->fd > 0) {
|
||||
|
@ -331,59 +342,69 @@ static gboolean gst_audiosink_open_audio(GstAudioSink *sink) {
|
|||
sink->format = AFMT_S16_LE;
|
||||
sink->channels = 2; /* stereo */
|
||||
sink->frequency = 44100;
|
||||
gst_audiosink_sync_parms(sink);
|
||||
ioctl(sink->fd,SNDCTL_DSP_GETCAPS,&sink->caps);
|
||||
gst_audiosink_sync_parms (sink);
|
||||
ioctl(sink->fd, SNDCTL_DSP_GETCAPS, &sink->caps);
|
||||
|
||||
g_print("audiosink: Capabilities\n");
|
||||
|
||||
if (sink->caps & DSP_CAP_DUPLEX) g_print("audiosink: Full duplex\n");
|
||||
if (sink->caps & DSP_CAP_REALTIME) g_print("audiosink: Realtime\n");
|
||||
if (sink->caps & DSP_CAP_BATCH) g_print("audiosink: Batch\n");
|
||||
if (sink->caps & DSP_CAP_COPROC) g_print("audiosink: Has coprocessor\n");
|
||||
if (sink->caps & DSP_CAP_TRIGGER) g_print("audiosink: Trigger\n");
|
||||
if (sink->caps & DSP_CAP_MMAP) g_print("audiosink: Direct access\n");
|
||||
|
||||
g_print("audiosink: opened audio with fd=%d\n", sink->fd);
|
||||
GST_FLAG_SET(sink,GST_AUDIOSINK_OPEN);
|
||||
GST_FLAG_SET (sink, GST_AUDIOSINK_OPEN);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void gst_audiosink_close_audio(GstAudioSink *sink) {
|
||||
static void
|
||||
gst_audiosink_close_audio (GstAudioSink *sink)
|
||||
{
|
||||
if (sink->fd < 0) return;
|
||||
|
||||
close(sink->fd);
|
||||
sink->fd = -1;
|
||||
GST_FLAG_UNSET(sink,GST_AUDIOSINK_OPEN);
|
||||
|
||||
GST_FLAG_UNSET (sink, GST_AUDIOSINK_OPEN);
|
||||
|
||||
g_print("audiosink: closed sound device\n");
|
||||
}
|
||||
|
||||
static GstElementStateReturn gst_audiosink_change_state(GstElement *element) {
|
||||
g_return_val_if_fail(GST_IS_AUDIOSINK(element), FALSE);
|
||||
static GstElementStateReturn
|
||||
gst_audiosink_change_state (GstElement *element)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_AUDIOSINK (element), FALSE);
|
||||
|
||||
/* if going down into NULL state, close the file if it's open */
|
||||
if (GST_STATE_PENDING(element) == GST_STATE_NULL) {
|
||||
if (GST_FLAG_IS_SET(element,GST_AUDIOSINK_OPEN))
|
||||
gst_audiosink_close_audio(GST_AUDIOSINK(element));
|
||||
if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
|
||||
if (GST_FLAG_IS_SET (element, GST_AUDIOSINK_OPEN))
|
||||
gst_audiosink_close_audio (GST_AUDIOSINK (element));
|
||||
/* otherwise (READY or higher) we need to open the sound card */
|
||||
} else {
|
||||
if (!GST_FLAG_IS_SET(element,GST_AUDIOSINK_OPEN)) {
|
||||
if (!gst_audiosink_open_audio(GST_AUDIOSINK(element)))
|
||||
if (!GST_FLAG_IS_SET (element, GST_AUDIOSINK_OPEN)) {
|
||||
if (!gst_audiosink_open_audio (GST_AUDIOSINK (element)))
|
||||
return GST_STATE_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (GST_ELEMENT_CLASS(parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS(parent_class)->change_state(element);
|
||||
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
||||
return GST_STATE_SUCCESS;
|
||||
}
|
||||
|
||||
gboolean gst_audiosink_factory_init(GstElementFactory *factory) {
|
||||
|
||||
gboolean
|
||||
gst_audiosink_factory_init (GstElementFactory *factory)
|
||||
{
|
||||
if (!gst_audiosink_type_audio)
|
||||
gst_audiosink_type_audio = gst_type_find_by_mime("audio/raw");
|
||||
gst_audiosink_type_audio = gst_type_find_by_mime ("audio/raw");
|
||||
|
||||
gst_type_add_sink(gst_audiosink_type_audio, factory);
|
||||
gst_type_add_sink (gst_audiosink_type_audio, factory);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -53,23 +53,25 @@ enum {
|
|||
};
|
||||
|
||||
|
||||
static void gst_audiosrc_class_init(GstAudioSrcClass *klass);
|
||||
static void gst_audiosrc_init(GstAudioSrc *audiosrc);
|
||||
static void gst_audiosrc_set_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_audiosrc_get_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static GstElementStateReturn gst_audiosrc_change_state(GstElement *element);
|
||||
static void gst_audiosrc_class_init (GstAudioSrcClass *klass);
|
||||
static void gst_audiosrc_init (GstAudioSrc *audiosrc);
|
||||
|
||||
static void gst_audiosrc_close_audio(GstAudioSrc *src);
|
||||
static gboolean gst_audiosrc_open_audio(GstAudioSrc *src);
|
||||
void gst_audiosrc_sync_parms(GstAudioSrc *audiosrc);
|
||||
static void gst_audiosrc_set_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
static void gst_audiosrc_get_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
static GstElementStateReturn gst_audiosrc_change_state (GstElement *element);
|
||||
|
||||
void gst_audiosrc_push(GstSrc *src);
|
||||
static void gst_audiosrc_close_audio (GstAudioSrc *src);
|
||||
static gboolean gst_audiosrc_open_audio (GstAudioSrc *src);
|
||||
static void gst_audiosrc_sync_parms (GstAudioSrc *audiosrc);
|
||||
|
||||
static void gst_audiosrc_push (GstSrc *src);
|
||||
|
||||
static GstSrcClass *parent_class = NULL;
|
||||
//static guint gst_audiosrc_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
GtkType
|
||||
gst_audiosrc_get_type(void) {
|
||||
gst_audiosrc_get_type (void)
|
||||
{
|
||||
static GtkType audiosrc_type = 0;
|
||||
|
||||
if (!audiosrc_type) {
|
||||
|
@ -83,13 +85,14 @@ gst_audiosrc_get_type(void) {
|
|||
(GtkArgGetFunc)gst_audiosrc_get_arg,
|
||||
(GtkClassInitFunc)NULL,
|
||||
};
|
||||
audiosrc_type = gtk_type_unique(GST_TYPE_SRC,&audiosrc_info);
|
||||
audiosrc_type = gtk_type_unique (GST_TYPE_SRC, &audiosrc_info);
|
||||
}
|
||||
return audiosrc_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_audiosrc_class_init(GstAudioSrcClass *klass) {
|
||||
gst_audiosrc_class_init (GstAudioSrcClass *klass)
|
||||
{
|
||||
GtkObjectClass *gtkobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
GstSrcClass *gstsrc_class;
|
||||
|
@ -98,18 +101,18 @@ gst_audiosrc_class_init(GstAudioSrcClass *klass) {
|
|||
gstelement_class = (GstElementClass*)klass;
|
||||
gstsrc_class = (GstSrcClass*)klass;
|
||||
|
||||
parent_class = gtk_type_class(GST_TYPE_SRC);
|
||||
parent_class = gtk_type_class (GST_TYPE_SRC);
|
||||
|
||||
gtk_object_add_arg_type("GstAudioSrc::bytes_per_read", GTK_TYPE_ULONG,
|
||||
GTK_ARG_READWRITE, ARG_BYTESPERREAD);
|
||||
gtk_object_add_arg_type("GstAudioSrc::curoffset", GTK_TYPE_ULONG,
|
||||
GTK_ARG_READABLE, ARG_CUROFFSET);
|
||||
gtk_object_add_arg_type("GstAudioSrc::format", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_FORMAT);
|
||||
gtk_object_add_arg_type("GstAudioSrc::channels", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_CHANNELS);
|
||||
gtk_object_add_arg_type("GstAudioSrc::frequency", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_FREQUENCY);
|
||||
gtk_object_add_arg_type ("GstAudioSrc::bytes_per_read", GTK_TYPE_ULONG,
|
||||
GTK_ARG_READWRITE, ARG_BYTESPERREAD);
|
||||
gtk_object_add_arg_type ("GstAudioSrc::curoffset", GTK_TYPE_ULONG,
|
||||
GTK_ARG_READABLE, ARG_CUROFFSET);
|
||||
gtk_object_add_arg_type ("GstAudioSrc::format", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_FORMAT);
|
||||
gtk_object_add_arg_type ("GstAudioSrc::channels", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_CHANNELS);
|
||||
gtk_object_add_arg_type ("GstAudioSrc::frequency", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_FREQUENCY);
|
||||
|
||||
gtkobject_class->set_arg = gst_audiosrc_set_arg;
|
||||
gtkobject_class->get_arg = gst_audiosrc_get_arg;
|
||||
|
@ -119,9 +122,11 @@ gst_audiosrc_class_init(GstAudioSrcClass *klass) {
|
|||
gstsrc_class->push = gst_audiosrc_push;
|
||||
}
|
||||
|
||||
static void gst_audiosrc_init(GstAudioSrc *audiosrc) {
|
||||
audiosrc->srcpad = gst_pad_new("src",GST_PAD_SRC);
|
||||
gst_element_add_pad(GST_ELEMENT(audiosrc),audiosrc->srcpad);
|
||||
static void
|
||||
gst_audiosrc_init (GstAudioSrc *audiosrc)
|
||||
{
|
||||
audiosrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||
gst_element_add_pad (GST_ELEMENT (audiosrc), audiosrc->srcpad);
|
||||
|
||||
audiosrc->fd = -1;
|
||||
|
||||
|
@ -136,87 +141,93 @@ static void gst_audiosrc_init(GstAudioSrc *audiosrc) {
|
|||
audiosrc->seq = 0;
|
||||
}
|
||||
|
||||
GstElement *gst_audiosrc_new(gchar *name) {
|
||||
GstElement *audiosrc = GST_ELEMENT(gtk_type_new(GST_TYPE_AUDIOSRC));
|
||||
gst_element_set_name(GST_ELEMENT(audiosrc),name);
|
||||
return audiosrc;
|
||||
}
|
||||
|
||||
void gst_audiosrc_push(GstSrc *src) {
|
||||
static void
|
||||
gst_audiosrc_push (GstSrc *src)
|
||||
{
|
||||
GstAudioSrc *audiosrc;
|
||||
GstBuffer *buf;
|
||||
glong readbytes;
|
||||
|
||||
g_return_if_fail(src != NULL);
|
||||
g_return_if_fail(GST_IS_AUDIOSRC(src));
|
||||
audiosrc = GST_AUDIOSRC(src);
|
||||
g_return_if_fail (src != NULL);
|
||||
g_return_if_fail (GST_IS_AUDIOSRC (src));
|
||||
audiosrc = GST_AUDIOSRC (src);
|
||||
|
||||
// g_print("attempting to read something from soundcard\n");
|
||||
|
||||
buf = gst_buffer_new();
|
||||
g_return_if_fail(buf);
|
||||
GST_BUFFER_DATA(buf) = (gpointer)g_malloc(audiosrc->bytes_per_read);
|
||||
readbytes = read(audiosrc->fd,GST_BUFFER_DATA(buf),
|
||||
audiosrc->bytes_per_read);
|
||||
buf = gst_buffer_new ();
|
||||
g_return_if_fail (buf);
|
||||
|
||||
GST_BUFFER_DATA (buf) = (gpointer)g_malloc (audiosrc->bytes_per_read);
|
||||
|
||||
readbytes = read (audiosrc->fd,GST_BUFFER_DATA (buf),
|
||||
audiosrc->bytes_per_read);
|
||||
|
||||
if (readbytes == 0) {
|
||||
gst_src_signal_eos(GST_SRC(audiosrc));
|
||||
gst_src_signal_eos (GST_SRC (audiosrc));
|
||||
return;
|
||||
}
|
||||
|
||||
GST_BUFFER_SIZE(buf) = readbytes;
|
||||
GST_BUFFER_OFFSET(buf) = audiosrc->curoffset;
|
||||
GST_BUFFER_SIZE (buf) = readbytes;
|
||||
GST_BUFFER_OFFSET (buf) = audiosrc->curoffset;
|
||||
|
||||
audiosrc->curoffset += readbytes;
|
||||
|
||||
// gst_buffer_add_meta(buf,GST_META(newmeta));
|
||||
|
||||
gst_pad_push(audiosrc->srcpad,buf);
|
||||
gst_pad_push (audiosrc->srcpad,buf);
|
||||
// g_print("pushed buffer from soundcard of %d bytes\n",readbytes);
|
||||
}
|
||||
|
||||
static void gst_audiosrc_set_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_audiosrc_set_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstAudioSrc *src;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_AUDIOSRC(object));
|
||||
src = GST_AUDIOSRC(object);
|
||||
g_return_if_fail (GST_IS_AUDIOSRC (object));
|
||||
|
||||
src = GST_AUDIOSRC (object);
|
||||
|
||||
switch (id) {
|
||||
case ARG_BYTESPERREAD:
|
||||
src->bytes_per_read = GTK_VALUE_INT(*arg);
|
||||
src->bytes_per_read = GTK_VALUE_INT (*arg);
|
||||
break;
|
||||
case ARG_FORMAT:
|
||||
src->format = GTK_VALUE_INT(*arg);
|
||||
src->format = GTK_VALUE_INT (*arg);
|
||||
break;
|
||||
case ARG_CHANNELS:
|
||||
src->channels = GTK_VALUE_INT(*arg);
|
||||
src->channels = GTK_VALUE_INT (*arg);
|
||||
break;
|
||||
case ARG_FREQUENCY:
|
||||
src->frequency = GTK_VALUE_INT(*arg);
|
||||
src->frequency = GTK_VALUE_INT (*arg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void gst_audiosrc_get_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_audiosrc_get_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstAudioSrc *src;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_AUDIOSRC(object));
|
||||
src = GST_AUDIOSRC(object);
|
||||
g_return_if_fail (GST_IS_AUDIOSRC (object));
|
||||
|
||||
src = GST_AUDIOSRC (object);
|
||||
|
||||
switch (id) {
|
||||
case ARG_BYTESPERREAD:
|
||||
GTK_VALUE_INT(*arg) = src->bytes_per_read;
|
||||
GTK_VALUE_INT (*arg) = src->bytes_per_read;
|
||||
break;
|
||||
case ARG_FORMAT:
|
||||
GTK_VALUE_INT(*arg) = src->format;
|
||||
GTK_VALUE_INT (*arg) = src->format;
|
||||
break;
|
||||
case ARG_CHANNELS:
|
||||
GTK_VALUE_INT(*arg) = src->channels;
|
||||
GTK_VALUE_INT (*arg) = src->channels;
|
||||
break;
|
||||
case ARG_FREQUENCY:
|
||||
GTK_VALUE_INT(*arg) = src->frequency;
|
||||
GTK_VALUE_INT (*arg) = src->frequency;
|
||||
break;
|
||||
default:
|
||||
arg->type = GTK_TYPE_INVALID;
|
||||
|
@ -224,71 +235,81 @@ static void gst_audiosrc_get_arg(GtkObject *object,GtkArg *arg,guint id) {
|
|||
}
|
||||
}
|
||||
|
||||
static GstElementStateReturn gst_audiosrc_change_state(GstElement *element) {
|
||||
g_return_val_if_fail(GST_IS_AUDIOSRC(element), FALSE);
|
||||
static GstElementStateReturn
|
||||
gst_audiosrc_change_state (GstElement *element)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_AUDIOSRC (element), FALSE);
|
||||
|
||||
/* if going down into NULL state, close the file if it's open */
|
||||
if (GST_STATE_PENDING(element) == GST_STATE_NULL) {
|
||||
if (GST_FLAG_IS_SET(element,GST_AUDIOSRC_OPEN))
|
||||
gst_audiosrc_close_audio(GST_AUDIOSRC(element));
|
||||
if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
|
||||
if (GST_FLAG_IS_SET (element, GST_AUDIOSRC_OPEN))
|
||||
gst_audiosrc_close_audio (GST_AUDIOSRC (element));
|
||||
/* otherwise (READY or higher) we need to open the sound card */
|
||||
} else {
|
||||
if (!GST_FLAG_IS_SET(element,GST_AUDIOSRC_OPEN)) {
|
||||
if (!gst_audiosrc_open_audio(GST_AUDIOSRC(element)))
|
||||
if (!GST_FLAG_IS_SET (element, GST_AUDIOSRC_OPEN)) {
|
||||
if (!gst_audiosrc_open_audio (GST_AUDIOSRC (element)))
|
||||
return GST_STATE_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (GST_ELEMENT_CLASS(parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS(parent_class)->change_state(element);
|
||||
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
||||
|
||||
return GST_STATE_SUCCESS;
|
||||
}
|
||||
|
||||
static gboolean gst_audiosrc_open_audio(GstAudioSrc *src) {
|
||||
g_return_val_if_fail(!GST_FLAG_IS_SET(src,GST_AUDIOSRC_OPEN), FALSE);
|
||||
static gboolean
|
||||
gst_audiosrc_open_audio (GstAudioSrc *src)
|
||||
{
|
||||
g_return_val_if_fail (!GST_FLAG_IS_SET (src, GST_AUDIOSRC_OPEN), FALSE);
|
||||
|
||||
/* first try to open the sound card */
|
||||
src->fd = open("/dev/dsp",O_RDONLY);
|
||||
src->fd = open("/dev/dsp", O_RDONLY);
|
||||
|
||||
/* if we have it, set the default parameters and go have fun */
|
||||
if (src->fd > 0) {
|
||||
int arg = 0x7fff0006;
|
||||
|
||||
if (ioctl(src->fd, SNDCTL_DSP_SETFRAGMENT, &arg)) perror("uh");
|
||||
if (ioctl (src->fd, SNDCTL_DSP_SETFRAGMENT, &arg)) perror("uh");
|
||||
|
||||
/* set card state */
|
||||
gst_audiosrc_sync_parms(src);
|
||||
gst_audiosrc_sync_parms (src);
|
||||
DEBUG("opened audio\n");
|
||||
GST_FLAG_SET(src,GST_AUDIOSRC_OPEN);
|
||||
|
||||
GST_FLAG_SET (src, GST_AUDIOSRC_OPEN);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void gst_audiosrc_close_audio(GstAudioSrc *src) {
|
||||
g_return_if_fail(GST_FLAG_IS_SET(src,GST_AUDIOSRC_OPEN));
|
||||
static void
|
||||
gst_audiosrc_close_audio (GstAudioSrc *src)
|
||||
{
|
||||
g_return_if_fail (GST_FLAG_IS_SET (src, GST_AUDIOSRC_OPEN));
|
||||
|
||||
close(src->fd);
|
||||
src->fd = -1;
|
||||
|
||||
GST_FLAG_UNSET(src,GST_AUDIOSRC_OPEN);
|
||||
GST_FLAG_UNSET (src, GST_AUDIOSRC_OPEN);
|
||||
}
|
||||
|
||||
void gst_audiosrc_sync_parms(GstAudioSrc *audiosrc) {
|
||||
static void
|
||||
gst_audiosrc_sync_parms (GstAudioSrc *audiosrc)
|
||||
{
|
||||
audio_buf_info ospace;
|
||||
|
||||
g_return_if_fail(audiosrc != NULL);
|
||||
g_return_if_fail(GST_IS_AUDIOSRC(audiosrc));
|
||||
g_return_if_fail(audiosrc->fd > 0);
|
||||
g_return_if_fail (audiosrc != NULL);
|
||||
g_return_if_fail (GST_IS_AUDIOSRC (audiosrc));
|
||||
g_return_if_fail (audiosrc->fd > 0);
|
||||
|
||||
ioctl(audiosrc->fd,SNDCTL_DSP_RESET,0);
|
||||
ioctl(audiosrc->fd, SNDCTL_DSP_RESET, 0);
|
||||
|
||||
ioctl(audiosrc->fd,SNDCTL_DSP_SETFMT,&audiosrc->format);
|
||||
ioctl(audiosrc->fd,SNDCTL_DSP_CHANNELS,&audiosrc->channels);
|
||||
ioctl(audiosrc->fd,SNDCTL_DSP_SPEED,&audiosrc->frequency);
|
||||
ioctl(audiosrc->fd, SNDCTL_DSP_SETFMT, &audiosrc->format);
|
||||
ioctl(audiosrc->fd, SNDCTL_DSP_CHANNELS, &audiosrc->channels);
|
||||
ioctl(audiosrc->fd, SNDCTL_DSP_SPEED, &audiosrc->frequency);
|
||||
|
||||
ioctl(audiosrc->fd,SNDCTL_DSP_GETOSPACE,&ospace);
|
||||
ioctl(audiosrc->fd, SNDCTL_DSP_GETOSPACE, &ospace);
|
||||
|
||||
g_print("setting sound card to %dKHz %d bit %s (%d bytes buffer)\n",
|
||||
audiosrc->frequency,audiosrc->format,
|
||||
|
|
|
@ -44,7 +44,7 @@ GstElementDetails gst_audiosrc_details;
|
|||
#define GST_IS_AUDIOSRC(obj) \
|
||||
(GTK_CHECK_TYPE((obj),GST_TYPE_AUDIOSRC))
|
||||
#define GST_IS_AUDIOSRC_CLASS(obj) \
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIOSRC)))
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIOSRC))
|
||||
|
||||
// NOTE: per-element flags start with 16 for now
|
||||
typedef enum {
|
||||
|
|
|
@ -45,30 +45,32 @@ struct _elements_entry {
|
|||
gboolean (*factoryinit) (GstElementFactory *factory);
|
||||
};
|
||||
|
||||
struct _elements_entry _elements[] = {
|
||||
{ "fakesrc", gst_fakesrc_get_type, &gst_fakesrc_details, NULL },
|
||||
{ "fakesink", gst_fakesink_get_type, &gst_fakesink_details, NULL },
|
||||
{ "asyncdisksrc", gst_asyncdisksrc_get_type, &gst_asyncdisksrc_details, NULL },
|
||||
{ "audiosink", gst_audiosink_get_type, &gst_audiosink_details, gst_audiosink_factory_init },
|
||||
{ "audiosrc", gst_audiosrc_get_type, &gst_audiosrc_details, NULL },
|
||||
{ "disksrc", gst_disksrc_get_type, &gst_disksrc_details, NULL },
|
||||
{ "identity", gst_identity_get_type, &gst_identity_details, NULL },
|
||||
{ "fdsink", gst_fdsink_get_type, &gst_fdsink_details, NULL },
|
||||
{ "fdsrc", gst_fdsrc_get_type, &gst_fdsrc_details, NULL },
|
||||
static struct _elements_entry _elements[] = {
|
||||
{ "fakesrc", gst_fakesrc_get_type, &gst_fakesrc_details, NULL },
|
||||
{ "fakesink", gst_fakesink_get_type, &gst_fakesink_details, NULL },
|
||||
{ "asyncdisksrc", gst_asyncdisksrc_get_type, &gst_asyncdisksrc_details, NULL },
|
||||
{ "audiosink", gst_audiosink_get_type, &gst_audiosink_details, gst_audiosink_factory_init },
|
||||
{ "audiosrc", gst_audiosrc_get_type, &gst_audiosrc_details, NULL },
|
||||
{ "disksrc", gst_disksrc_get_type, &gst_disksrc_details, NULL },
|
||||
{ "identity", gst_identity_get_type, &gst_identity_details, NULL },
|
||||
{ "fdsink", gst_fdsink_get_type, &gst_fdsink_details, NULL },
|
||||
{ "fdsrc", gst_fdsrc_get_type, &gst_fdsrc_details, NULL },
|
||||
#if HAVE_LIBGHTTP
|
||||
{ "httpsrc", gst_httpsrc_get_type, &gst_httpsrc_details, NULL },
|
||||
{ "httpsrc", gst_httpsrc_get_type, &gst_httpsrc_details, NULL },
|
||||
#endif /* HAVE_LIBGHTTP */
|
||||
{ "pipefilter", gst_pipefilter_get_type, &gst_pipefilter_details, NULL },
|
||||
{ "queue", gst_queue_get_type, &gst_queue_details, NULL },
|
||||
{ "sinesrc", gst_sinesrc_get_type, &gst_sinesrc_details, NULL },
|
||||
{ "typefind", gst_typefind_get_type, &gst_typefind_details, NULL },
|
||||
{ "pipefilter", gst_pipefilter_get_type, &gst_pipefilter_details, NULL },
|
||||
{ "queue", gst_queue_get_type, &gst_queue_details, NULL },
|
||||
{ "sinesrc", gst_sinesrc_get_type, &gst_sinesrc_details, NULL },
|
||||
{ "typefind", gst_typefind_get_type, &gst_typefind_details, NULL },
|
||||
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
||||
GstPlugin *plugin_init(GModule *module) {
|
||||
GstPlugin *plugin_init (GModule *module)
|
||||
{
|
||||
GstPlugin *plugin;
|
||||
GstElementFactory *factory;
|
||||
int i = 0;
|
||||
gint i = 0;
|
||||
|
||||
/* we depend on having the usual types loaded first */
|
||||
gst_plugin_load("gsttypes");
|
||||
|
@ -76,23 +78,23 @@ GstPlugin *plugin_init(GModule *module) {
|
|||
plugin = gst_plugin_new("gstelements");
|
||||
g_return_val_if_fail(plugin != NULL,NULL);
|
||||
|
||||
gst_plugin_set_longname(plugin,"Standard GST Elements");
|
||||
gst_plugin_set_longname (plugin, "Standard GST Elements");
|
||||
|
||||
while (_elements[i].name) {
|
||||
factory = gst_elementfactory_new(_elements[i].name,
|
||||
(_elements[i].type)(),
|
||||
_elements[i].details);
|
||||
factory = gst_elementfactory_new (_elements[i].name,
|
||||
(_elements[i].type) (),
|
||||
_elements[i].details);
|
||||
if (factory != NULL) {
|
||||
gst_plugin_add_factory(plugin,factory);
|
||||
gst_plugin_add_factory (plugin, factory);
|
||||
if (_elements[i].factoryinit) {
|
||||
_elements[i].factoryinit(factory);
|
||||
_elements[i].factoryinit (factory);
|
||||
}
|
||||
// g_print("added factory '%s'\n",_elements[i].name);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
gst_info("gstelements: loaded %d standard elements\n",i);
|
||||
gst_info ("gstelements: loaded %d standard elements\n", i);
|
||||
|
||||
return plugin;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ extern "C" {
|
|||
#define GST_IS_ESDSINK(obj) \
|
||||
(GTK_CHECK_TYPE((obj),GST_TYPE_ESDSINK))
|
||||
#define GST_IS_ESDSINK_CLASS(obj) \
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_ESDSINK)))
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_ESDSINK))
|
||||
|
||||
typedef struct _GstEsdSink GstEsdSink;
|
||||
typedef struct _GstEsdSinkClass GstEsdSinkClass;
|
||||
|
|
|
@ -46,14 +46,14 @@ enum {
|
|||
static void gst_fakesink_class_init(GstFakeSinkClass *klass);
|
||||
static void gst_fakesink_init(GstFakeSink *fakesink);
|
||||
|
||||
GstElement *gst_fakesink_new(gchar *name);
|
||||
void gst_fakesink_chain(GstPad *pad,GstBuffer *buf);
|
||||
static void gst_fakesink_chain(GstPad *pad,GstBuffer *buf);
|
||||
|
||||
static GstSinkClass *parent_class = NULL;
|
||||
//static guint gst_fakesink_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
GtkType
|
||||
gst_fakesink_get_type(void) {
|
||||
gst_fakesink_get_type (void)
|
||||
{
|
||||
static GtkType fakesink_type = 0;
|
||||
|
||||
if (!fakesink_type) {
|
||||
|
@ -67,43 +67,32 @@ gst_fakesink_get_type(void) {
|
|||
(GtkArgGetFunc)NULL,
|
||||
(GtkClassInitFunc)NULL,
|
||||
};
|
||||
fakesink_type = gtk_type_unique(GST_TYPE_SINK,&fakesink_info);
|
||||
fakesink_type = gtk_type_unique (GST_TYPE_SINK, &fakesink_info);
|
||||
}
|
||||
return fakesink_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_fakesink_class_init(GstFakeSinkClass *klass) {
|
||||
gst_fakesink_class_init (GstFakeSinkClass *klass)
|
||||
{
|
||||
GstSinkClass *gstsink_class;
|
||||
|
||||
gstsink_class = (GstSinkClass*)klass;
|
||||
|
||||
parent_class = gtk_type_class(GST_TYPE_SINK);
|
||||
parent_class = gtk_type_class (GST_TYPE_SINK);
|
||||
}
|
||||
|
||||
static void gst_fakesink_init(GstFakeSink *fakesink) {
|
||||
fakesink->sinkpad = gst_pad_new("sink",GST_PAD_SINK);
|
||||
gst_element_add_pad(GST_ELEMENT(fakesink),fakesink->sinkpad);
|
||||
gst_pad_set_chain_function(fakesink->sinkpad,gst_fakesink_chain);
|
||||
static void
|
||||
gst_fakesink_init (GstFakeSink *fakesink)
|
||||
{
|
||||
fakesink->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
|
||||
gst_element_add_pad (GST_ELEMENT (fakesink), fakesink->sinkpad);
|
||||
gst_pad_set_chain_function (fakesink->sinkpad, gst_fakesink_chain);
|
||||
|
||||
// we're ready right away, since we don't have any args...
|
||||
// gst_element_set_state(GST_ELEMENT(fakesink),GST_STATE_READY);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_fakesink_new:
|
||||
* @name: the name of the new fakesrc
|
||||
*
|
||||
* create a new fakesink
|
||||
*
|
||||
* Returns: the new fakesink
|
||||
*/
|
||||
GstElement *gst_fakesink_new(gchar *name) {
|
||||
GstElement *fakesink = GST_ELEMENT(gtk_type_new(GST_TYPE_FAKESINK));
|
||||
gst_element_set_name(GST_ELEMENT(fakesink),name);
|
||||
return fakesink;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_fakesink_chain:
|
||||
* @pad: the pad this faksink is connected to
|
||||
|
@ -112,16 +101,19 @@ GstElement *gst_fakesink_new(gchar *name) {
|
|||
* take the buffer from the pad and unref it without doing
|
||||
* anything with it.
|
||||
*/
|
||||
void gst_fakesink_chain(GstPad *pad,GstBuffer *buf) {
|
||||
static void
|
||||
gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
|
||||
{
|
||||
GstFakeSink *fakesink;
|
||||
|
||||
g_return_if_fail(pad != NULL);
|
||||
g_return_if_fail(GST_IS_PAD(pad));
|
||||
g_return_if_fail(buf != NULL);
|
||||
g_return_if_fail (pad != NULL);
|
||||
g_return_if_fail (GST_IS_PAD (pad));
|
||||
g_return_if_fail (buf != NULL);
|
||||
|
||||
fakesink = GST_FAKESINK(pad->parent);
|
||||
fakesink = GST_FAKESINK (pad->parent);
|
||||
// g_print("gst_fakesink_chain: got buffer in '%s'\n",
|
||||
// gst_element_get_name(GST_ELEMENT(fakesink)));
|
||||
g_print("<");
|
||||
gst_buffer_unref(buf);
|
||||
|
||||
gst_buffer_unref (buf);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ GstElementDetails gst_fakesink_details;
|
|||
#define GST_IS_FAKESINK(obj) \
|
||||
(GTK_CHECK_TYPE((obj),GST_TYPE_FAKESINK))
|
||||
#define GST_IS_FAKESINK_CLASS(obj) \
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FAKESINK)))
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FAKESINK))
|
||||
|
||||
typedef struct _GstFakeSink GstFakeSink;
|
||||
typedef struct _GstFakeSinkClass GstFakeSinkClass;
|
||||
|
|
|
@ -43,16 +43,17 @@ enum {
|
|||
};
|
||||
|
||||
|
||||
static void gst_fakesrc_class_init(GstFakeSrcClass *klass);
|
||||
static void gst_fakesrc_init(GstFakeSrc *fakesrc);
|
||||
static void gst_fakesrc_class_init (GstFakeSrcClass *klass);
|
||||
static void gst_fakesrc_init (GstFakeSrc *fakesrc);
|
||||
|
||||
void gst_fakesrc_push(GstSrc *src);
|
||||
static void gst_fakesrc_push (GstSrc *src);
|
||||
|
||||
static GstSrcClass *parent_class = NULL;
|
||||
//static guint gst_fakesrc_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
GtkType
|
||||
gst_fakesrc_get_type(void) {
|
||||
gst_fakesrc_get_type (void)
|
||||
{
|
||||
static GtkType fakesrc_type = 0;
|
||||
|
||||
if (!fakesrc_type) {
|
||||
|
@ -66,62 +67,55 @@ gst_fakesrc_get_type(void) {
|
|||
(GtkArgGetFunc)NULL,
|
||||
(GtkClassInitFunc)NULL,
|
||||
};
|
||||
fakesrc_type = gtk_type_unique(GST_TYPE_SRC,&fakesrc_info);
|
||||
fakesrc_type = gtk_type_unique (GST_TYPE_SRC, &fakesrc_info);
|
||||
}
|
||||
return fakesrc_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_fakesrc_class_init(GstFakeSrcClass *klass) {
|
||||
gst_fakesrc_class_init (GstFakeSrcClass *klass)
|
||||
{
|
||||
GstSrcClass *gstsrc_class;
|
||||
|
||||
gstsrc_class = (GstSrcClass*)klass;
|
||||
|
||||
parent_class = gtk_type_class(GST_TYPE_SRC);
|
||||
parent_class = gtk_type_class (GST_TYPE_SRC);
|
||||
|
||||
gstsrc_class->push = gst_fakesrc_push;
|
||||
gstsrc_class->push_region = NULL;
|
||||
}
|
||||
|
||||
static void gst_fakesrc_init(GstFakeSrc *fakesrc) {
|
||||
fakesrc->srcpad = gst_pad_new("src",GST_PAD_SRC);
|
||||
gst_element_add_pad(GST_ELEMENT(fakesrc),fakesrc->srcpad);
|
||||
static void
|
||||
gst_fakesrc_init (GstFakeSrc *fakesrc)
|
||||
{
|
||||
fakesrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||
gst_element_add_pad (GST_ELEMENT (fakesrc), fakesrc->srcpad);
|
||||
|
||||
// we're ready right away, since we don't have any args...
|
||||
// gst_element_set_state(GST_ELEMENT(fakesrc),GST_STATE_READY);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_fakesrc_new:
|
||||
* @name: then name of the fakse source
|
||||
*
|
||||
* create a new fakesrc
|
||||
*
|
||||
* Returns: The new element.
|
||||
*/
|
||||
GstElement *gst_fakesrc_new(gchar *name) {
|
||||
GstElement *fakesrc = GST_ELEMENT(gtk_type_new(GST_TYPE_FAKESRC));
|
||||
gst_element_set_name(GST_ELEMENT(fakesrc),name);
|
||||
return fakesrc;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_fakesrc_push:
|
||||
* @src: the faksesrc to push
|
||||
*
|
||||
* generate an empty buffer and push it to the next element.
|
||||
*/
|
||||
void gst_fakesrc_push(GstSrc *src) {
|
||||
static void
|
||||
gst_fakesrc_push (GstSrc *src)
|
||||
{
|
||||
GstFakeSrc *fakesrc;
|
||||
GstBuffer *buf;
|
||||
|
||||
g_return_if_fail(src != NULL);
|
||||
g_return_if_fail(GST_IS_FAKESRC(src));
|
||||
fakesrc = GST_FAKESRC(src);
|
||||
g_return_if_fail (src != NULL);
|
||||
g_return_if_fail (GST_IS_FAKESRC (src));
|
||||
|
||||
fakesrc = GST_FAKESRC (src);
|
||||
|
||||
// g_print("gst_fakesrc_push(): pushing fake buffer from '%s'\n",
|
||||
// gst_element_get_name(GST_ELEMENT(fakesrc)));
|
||||
g_print(">");
|
||||
buf = gst_buffer_new();
|
||||
gst_pad_push(fakesrc->srcpad,buf);
|
||||
buf = gst_buffer_new ();
|
||||
|
||||
gst_pad_push (fakesrc->srcpad, buf);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ GstElementDetails gst_fakesrc_details;
|
|||
#define GST_IS_FAKESRC(obj) \
|
||||
(GTK_CHECK_TYPE((obj),GST_TYPE_FAKESRC))
|
||||
#define GST_IS_FAKESRC_CLASS(obj) \
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FAKESRC)))
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FAKESRC))
|
||||
|
||||
typedef struct _GstFakeSrc GstFakeSrc;
|
||||
typedef struct _GstFakeSrcClass GstFakeSrcClass;
|
||||
|
|
|
@ -43,18 +43,20 @@ enum {
|
|||
};
|
||||
|
||||
|
||||
static void gst_fdsink_class_init(GstFdSinkClass *klass);
|
||||
static void gst_fdsink_init(GstFdSink *fdsink);
|
||||
static void gst_fdsink_set_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_fdsink_get_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_fdsink_class_init (GstFdSinkClass *klass);
|
||||
static void gst_fdsink_init (GstFdSink *fdsink);
|
||||
|
||||
void gst_fdsink_chain(GstPad *pad,GstBuffer *buf);
|
||||
static void gst_fdsink_set_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
static void gst_fdsink_get_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
|
||||
static void gst_fdsink_chain (GstPad *pad,GstBuffer *buf);
|
||||
|
||||
static GstSinkClass *parent_class = NULL;
|
||||
//static guint gst_fdsink_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
GtkType
|
||||
gst_fdsink_get_type(void) {
|
||||
gst_fdsink_get_type (void)
|
||||
{
|
||||
static GtkType fdsink_type = 0;
|
||||
|
||||
if (!fdsink_type) {
|
||||
|
@ -68,88 +70,90 @@ gst_fdsink_get_type(void) {
|
|||
(GtkArgGetFunc)gst_fdsink_get_arg,
|
||||
(GtkClassInitFunc)NULL,
|
||||
};
|
||||
fdsink_type = gtk_type_unique(GST_TYPE_SINK,&fdsink_info);
|
||||
fdsink_type = gtk_type_unique (GST_TYPE_SINK, &fdsink_info);
|
||||
}
|
||||
return fdsink_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_fdsink_class_init(GstFdSinkClass *klass) {
|
||||
gst_fdsink_class_init (GstFdSinkClass *klass)
|
||||
{
|
||||
GtkObjectClass *gtkobject_class;
|
||||
GstSinkClass *gstsink_class;
|
||||
|
||||
gtkobject_class = (GtkObjectClass*)klass;
|
||||
gstsink_class = (GstSinkClass*)klass;
|
||||
|
||||
parent_class = gtk_type_class(GST_TYPE_SINK);
|
||||
parent_class = gtk_type_class (GST_TYPE_SINK);
|
||||
|
||||
gtk_object_add_arg_type("GstFdSink::fd", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_FD);
|
||||
gtk_object_add_arg_type ("GstFdSink::fd", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_FD);
|
||||
|
||||
gtkobject_class->set_arg = gst_fdsink_set_arg;
|
||||
gtkobject_class->get_arg = gst_fdsink_get_arg;
|
||||
}
|
||||
|
||||
static void gst_fdsink_init(GstFdSink *fdsink) {
|
||||
fdsink->sinkpad = gst_pad_new("sink",GST_PAD_SINK);
|
||||
gst_element_add_pad(GST_ELEMENT(fdsink),fdsink->sinkpad);
|
||||
gst_pad_set_chain_function(fdsink->sinkpad,gst_fdsink_chain);
|
||||
static void
|
||||
gst_fdsink_init (GstFdSink *fdsink)
|
||||
{
|
||||
fdsink->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
|
||||
gst_element_add_pad (GST_ELEMENT (fdsink), fdsink->sinkpad);
|
||||
gst_pad_set_chain_function (fdsink->sinkpad, gst_fdsink_chain);
|
||||
|
||||
fdsink->fd = 1;
|
||||
}
|
||||
|
||||
GstElement *gst_fdsink_new(gchar *name) {
|
||||
GstElement *fdsink = GST_ELEMENT(gtk_type_new(GST_TYPE_FDSINK));
|
||||
gst_element_set_name(GST_ELEMENT(fdsink),name);
|
||||
return fdsink;
|
||||
}
|
||||
|
||||
GstElement *gst_fdsink_new_with_fd(gchar *name,gint fd) {
|
||||
GstElement *fdsink = gst_fdsink_new(name);
|
||||
gtk_object_set(GTK_OBJECT(fdsink),"fd",fd,NULL);
|
||||
return fdsink;
|
||||
}
|
||||
|
||||
void gst_fdsink_chain(GstPad *pad,GstBuffer *buf) {
|
||||
static void
|
||||
gst_fdsink_chain (GstPad *pad, GstBuffer *buf)
|
||||
{
|
||||
GstFdSink *fdsink;
|
||||
|
||||
g_return_if_fail(pad != NULL);
|
||||
g_return_if_fail(GST_IS_PAD(pad));
|
||||
g_return_if_fail(buf != NULL);
|
||||
g_return_if_fail (pad != NULL);
|
||||
g_return_if_fail (GST_IS_PAD (pad));
|
||||
g_return_if_fail (buf != NULL);
|
||||
|
||||
fdsink = GST_FDSINK(pad->parent);
|
||||
g_return_if_fail(fdsink->fd >= 0);
|
||||
if (GST_BUFFER_DATA(buf))
|
||||
write(fdsink->fd,GST_BUFFER_DATA(buf),GST_BUFFER_SIZE(buf));
|
||||
gst_buffer_unref(buf);
|
||||
fdsink = GST_FDSINK (pad->parent);
|
||||
|
||||
g_return_if_fail (fdsink->fd >= 0);
|
||||
|
||||
if (GST_BUFFER_DATA (buf))
|
||||
write (fdsink->fd, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
|
||||
|
||||
gst_buffer_unref (buf);
|
||||
}
|
||||
|
||||
static void gst_fdsink_set_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_fdsink_set_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstFdSink *fdsink;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_FDSINK(object));
|
||||
fdsink = GST_FDSINK(object);
|
||||
g_return_if_fail (GST_IS_FDSINK (object));
|
||||
|
||||
fdsink = GST_FDSINK (object);
|
||||
|
||||
switch(id) {
|
||||
case ARG_FD:
|
||||
fdsink->fd = GTK_VALUE_INT(*arg);
|
||||
fdsink->fd = GTK_VALUE_INT (*arg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void gst_fdsink_get_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_fdsink_get_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstFdSink *fdsink;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_FDSINK(object));
|
||||
fdsink = GST_FDSINK(object);
|
||||
g_return_if_fail (GST_IS_FDSINK (object));
|
||||
|
||||
fdsink = GST_FDSINK (object);
|
||||
|
||||
switch(id) {
|
||||
case ARG_FD:
|
||||
GTK_VALUE_INT(*arg) = fdsink->fd;
|
||||
GTK_VALUE_INT (*arg) = fdsink->fd;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -43,7 +43,7 @@ GstElementDetails gst_fdsink_details;
|
|||
#define GST_IS_FDSINK(obj) \
|
||||
(GTK_CHECK_TYPE((obj),GST_TYPE_FDSINK))
|
||||
#define GST_IS_FDSINK_CLASS(obj) \
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FDSINK)))
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FDSINK))
|
||||
|
||||
typedef struct _GstFdSink GstFdSink;
|
||||
typedef struct _GstFdSinkClass GstFdSinkClass;
|
||||
|
|
|
@ -51,12 +51,13 @@ enum {
|
|||
};
|
||||
|
||||
|
||||
static void gst_fdsrc_class_init(GstFdSrcClass *klass);
|
||||
static void gst_fdsrc_init(GstFdSrc *fdsrc);
|
||||
static void gst_fdsrc_set_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_fdsrc_get_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_fdsrc_class_init (GstFdSrcClass *klass);
|
||||
static void gst_fdsrc_init (GstFdSrc *fdsrc);
|
||||
|
||||
static void gst_fdsrc_push(GstSrc *src);
|
||||
static void gst_fdsrc_set_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
static void gst_fdsrc_get_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
|
||||
static void gst_fdsrc_push (GstSrc *src);
|
||||
//static void gst_fdsrc_push_region(GstSrc *src,gulong offset,gulong size);
|
||||
|
||||
|
||||
|
@ -64,7 +65,8 @@ static GstSrcClass *parent_class = NULL;
|
|||
//static guint gst_fdsrc_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
GtkType
|
||||
gst_fdsrc_get_type(void) {
|
||||
gst_fdsrc_get_type (void)
|
||||
{
|
||||
static GtkType fdsrc_type = 0;
|
||||
|
||||
if (!fdsrc_type) {
|
||||
|
@ -78,13 +80,14 @@ gst_fdsrc_get_type(void) {
|
|||
(GtkArgGetFunc)gst_fdsrc_get_arg,
|
||||
(GtkClassInitFunc)NULL,
|
||||
};
|
||||
fdsrc_type = gtk_type_unique(GST_TYPE_SRC,&fdsrc_info);
|
||||
fdsrc_type = gtk_type_unique (GST_TYPE_SRC, &fdsrc_info);
|
||||
}
|
||||
return fdsrc_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_fdsrc_class_init(GstFdSrcClass *klass) {
|
||||
gst_fdsrc_class_init (GstFdSrcClass *klass)
|
||||
{
|
||||
GtkObjectClass *gtkobject_class;
|
||||
GstSrcClass *gstsrc_class;
|
||||
|
||||
|
@ -93,24 +96,27 @@ gst_fdsrc_class_init(GstFdSrcClass *klass) {
|
|||
|
||||
parent_class = gtk_type_class(GST_TYPE_SRC);
|
||||
|
||||
gtk_object_add_arg_type("GstFdSrc::location", GST_TYPE_FILENAME,
|
||||
GTK_ARG_WRITABLE, ARG_LOCATION);
|
||||
gtk_object_add_arg_type("GstFdSrc::bytesperread", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_BYTESPERREAD);
|
||||
gtk_object_add_arg_type("GstFdSrc::offset", GTK_TYPE_INT,
|
||||
GTK_ARG_READABLE, ARG_OFFSET);
|
||||
gtk_object_add_arg_type ("GstFdSrc::location", GST_TYPE_FILENAME,
|
||||
GTK_ARG_WRITABLE, ARG_LOCATION);
|
||||
gtk_object_add_arg_type ("GstFdSrc::bytesperread", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_BYTESPERREAD);
|
||||
gtk_object_add_arg_type ("GstFdSrc::offset", GTK_TYPE_INT,
|
||||
GTK_ARG_READABLE, ARG_OFFSET);
|
||||
|
||||
gtkobject_class->set_arg = gst_fdsrc_set_arg;
|
||||
gtkobject_class->get_arg = gst_fdsrc_get_arg;
|
||||
|
||||
gstsrc_class->push = gst_fdsrc_push;
|
||||
|
||||
/* we nominally can't (won't) do async */
|
||||
gstsrc_class->push_region = NULL;
|
||||
}
|
||||
|
||||
static void gst_fdsrc_init(GstFdSrc *fdsrc) {
|
||||
fdsrc->srcpad = gst_pad_new("src",GST_PAD_SRC);
|
||||
gst_element_add_pad(GST_ELEMENT(fdsrc),fdsrc->srcpad);
|
||||
static void
|
||||
gst_fdsrc_init (GstFdSrc *fdsrc)
|
||||
{
|
||||
fdsrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||
gst_element_add_pad (GST_ELEMENT (fdsrc), fdsrc->srcpad);
|
||||
|
||||
fdsrc->fd = 0;
|
||||
fdsrc->curoffset = 0;
|
||||
|
@ -119,50 +125,56 @@ static void gst_fdsrc_init(GstFdSrc *fdsrc) {
|
|||
}
|
||||
|
||||
|
||||
static void gst_fdsrc_set_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_fdsrc_set_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstFdSrc *src;
|
||||
int fd;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_FDSRC(object));
|
||||
src = GST_FDSRC(object);
|
||||
g_return_if_fail (GST_IS_FDSRC (object));
|
||||
|
||||
src = GST_FDSRC (object);
|
||||
|
||||
switch(id) {
|
||||
case ARG_LOCATION:
|
||||
/* the element must not be playing in order to do this */
|
||||
g_return_if_fail(GST_STATE(src) < GST_STATE_PLAYING);
|
||||
g_return_if_fail (GST_STATE (src) < GST_STATE_PLAYING);
|
||||
|
||||
/* if we get a NULL, consider it to be a fd of 0 */
|
||||
if (GTK_VALUE_STRING(*arg) == NULL) {
|
||||
gst_element_set_state(GST_ELEMENT(object),GST_STATE_NULL);
|
||||
if (GTK_VALUE_STRING (*arg) == NULL) {
|
||||
gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL);
|
||||
src->fd = 0;
|
||||
/* otherwise set the new filename */
|
||||
} else {
|
||||
if (sscanf(GTK_VALUE_STRING(*arg),"%d",&fd))
|
||||
if (sscanf (GTK_VALUE_STRING (*arg), "%d", &fd))
|
||||
src->fd = fd;
|
||||
}
|
||||
break;
|
||||
case ARG_BYTESPERREAD:
|
||||
src->bytes_per_read = GTK_VALUE_INT(*arg);
|
||||
src->bytes_per_read = GTK_VALUE_INT (*arg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void gst_fdsrc_get_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_fdsrc_get_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstFdSrc *src;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_FDSRC(object));
|
||||
src = GST_FDSRC(object);
|
||||
g_return_if_fail (GST_IS_FDSRC (object));
|
||||
|
||||
src = GST_FDSRC (object);
|
||||
|
||||
switch (id) {
|
||||
case ARG_BYTESPERREAD:
|
||||
GTK_VALUE_INT(*arg) = src->bytes_per_read;
|
||||
GTK_VALUE_INT (*arg) = src->bytes_per_read;
|
||||
break;
|
||||
case ARG_OFFSET:
|
||||
GTK_VALUE_INT(*arg) = src->curoffset;
|
||||
GTK_VALUE_INT (*arg) = src->curoffset;
|
||||
break;
|
||||
default:
|
||||
arg->type = GTK_TYPE_INVALID;
|
||||
|
@ -170,40 +182,44 @@ static void gst_fdsrc_get_arg(GtkObject *object,GtkArg *arg,guint id) {
|
|||
}
|
||||
}
|
||||
|
||||
void gst_fdsrc_push(GstSrc *src) {
|
||||
static void
|
||||
gst_fdsrc_push (GstSrc *src)
|
||||
{
|
||||
GstFdSrc *fdsrc;
|
||||
GstBuffer *buf;
|
||||
glong readbytes;
|
||||
|
||||
g_return_if_fail(src != NULL);
|
||||
g_return_if_fail(GST_IS_FDSRC(src));
|
||||
fdsrc = GST_FDSRC(src);
|
||||
g_return_if_fail (src != NULL);
|
||||
g_return_if_fail (GST_IS_FDSRC (src));
|
||||
|
||||
fdsrc = GST_FDSRC (src);
|
||||
|
||||
/* create the buffer */
|
||||
// FIXME: should eventually use a bufferpool for this
|
||||
buf = gst_buffer_new();
|
||||
g_return_if_fail(buf);
|
||||
buf = gst_buffer_new ();
|
||||
g_return_if_fail (buf);
|
||||
|
||||
/* allocate the space for the buffer data */
|
||||
GST_BUFFER_DATA(buf) = g_malloc(fdsrc->bytes_per_read);
|
||||
g_return_if_fail(GST_BUFFER_DATA(buf) != NULL);
|
||||
GST_BUFFER_DATA (buf) = g_malloc (fdsrc->bytes_per_read);
|
||||
g_return_if_fail (GST_BUFFER_DATA (buf) != NULL);
|
||||
|
||||
/* read it in from the file */
|
||||
readbytes = read(fdsrc->fd,GST_BUFFER_DATA(buf),fdsrc->bytes_per_read);
|
||||
readbytes = read (fdsrc->fd, GST_BUFFER_DATA (buf), fdsrc->bytes_per_read);
|
||||
if (readbytes == 0) {
|
||||
gst_src_signal_eos(GST_SRC(fdsrc));
|
||||
gst_src_signal_eos (GST_SRC (fdsrc));
|
||||
return;
|
||||
}
|
||||
|
||||
/* if we didn't get as many bytes as we asked for, we're at EOF */
|
||||
if (readbytes < fdsrc->bytes_per_read) {
|
||||
// set the buffer's EOF bit here
|
||||
GST_BUFFER_FLAG_SET(buf,GST_BUFFER_EOS);
|
||||
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_EOS);
|
||||
}
|
||||
GST_BUFFER_OFFSET(buf) = fdsrc->curoffset;
|
||||
GST_BUFFER_SIZE(buf) = readbytes;
|
||||
GST_BUFFER_OFFSET (buf) = fdsrc->curoffset;
|
||||
GST_BUFFER_SIZE (buf) = readbytes;
|
||||
|
||||
fdsrc->curoffset += readbytes;
|
||||
|
||||
/* we're done, push the buffer off now */
|
||||
gst_pad_push(fdsrc->srcpad,buf);
|
||||
gst_pad_push (fdsrc->srcpad, buf);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ GstElementDetails gst_fdsrc_details;
|
|||
#define GST_IS_FDSRC(obj) \
|
||||
(GTK_CHECK_TYPE((obj),GST_TYPE_FDSRC))
|
||||
#define GST_IS_FDSRC_CLASS(obj) \
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FDSRC)))
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_FDSRC))
|
||||
|
||||
|
||||
typedef struct _GstFdSrc GstFdSrc;
|
||||
|
|
|
@ -35,13 +35,6 @@ GstElementDetails gst_httpsrc_details = {
|
|||
"(C) 1999",
|
||||
};
|
||||
|
||||
|
||||
static void gst_httpsrc_push(GstSrc *src);
|
||||
static gboolean gst_httpsrc_open_url(GstHttpSrc *src);
|
||||
static void gst_httpsrc_close_url(GstHttpSrc *src);
|
||||
static GstElementStateReturn gst_httpsrc_change_state(GstElement *element);
|
||||
|
||||
|
||||
/* HttpSrc signals and args */
|
||||
enum {
|
||||
/* FILL ME */
|
||||
|
@ -56,17 +49,25 @@ enum {
|
|||
};
|
||||
|
||||
|
||||
static void gst_httpsrc_class_init(GstHttpSrcClass *klass);
|
||||
static void gst_httpsrc_init(GstHttpSrc *httpsrc);
|
||||
static void gst_httpsrc_set_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_httpsrc_get_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_httpsrc_class_init (GstHttpSrcClass *klass);
|
||||
static void gst_httpsrc_init (GstHttpSrc *httpsrc);
|
||||
|
||||
static void gst_httpsrc_set_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
static void gst_httpsrc_get_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
|
||||
static void gst_httpsrc_push (GstSrc *src);
|
||||
|
||||
static gboolean gst_httpsrc_open_url (GstHttpSrc *src);
|
||||
static void gst_httpsrc_close_url (GstHttpSrc *src);
|
||||
|
||||
static GstElementStateReturn gst_httpsrc_change_state(GstElement *element);
|
||||
|
||||
static GstSrcClass *parent_class = NULL;
|
||||
//static guint gst_httpsrc_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
GtkType
|
||||
gst_httpsrc_get_type(void) {
|
||||
gst_httpsrc_get_type (void)
|
||||
{
|
||||
static GtkType httpsrc_type = 0;
|
||||
|
||||
if (!httpsrc_type) {
|
||||
|
@ -80,13 +81,14 @@ gst_httpsrc_get_type(void) {
|
|||
(GtkArgGetFunc)gst_httpsrc_get_arg,
|
||||
(GtkClassInitFunc)NULL,
|
||||
};
|
||||
httpsrc_type = gtk_type_unique(GST_TYPE_SRC,&httpsrc_info);
|
||||
httpsrc_type = gtk_type_unique (GST_TYPE_SRC, &httpsrc_info);
|
||||
}
|
||||
return httpsrc_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_httpsrc_class_init(GstHttpSrcClass *klass) {
|
||||
gst_httpsrc_class_init (GstHttpSrcClass *klass)
|
||||
{
|
||||
GtkObjectClass *gtkobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
GstSrcClass *gstsrc_class;
|
||||
|
@ -95,13 +97,13 @@ gst_httpsrc_class_init(GstHttpSrcClass *klass) {
|
|||
gstelement_class = (GstElementClass*)klass;
|
||||
gstsrc_class = (GstSrcClass*)klass;
|
||||
|
||||
parent_class = gtk_type_class(GST_TYPE_SRC);
|
||||
parent_class = gtk_type_class (GST_TYPE_SRC);
|
||||
|
||||
|
||||
gtk_object_add_arg_type("GstHttpSrc::location", GTK_TYPE_STRING,
|
||||
GTK_ARG_READWRITE, ARG_LOCATION);
|
||||
gtk_object_add_arg_type("GstHttpSrc::bytesperread", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_BYTESPERREAD);
|
||||
gtk_object_add_arg_type ("GstHttpSrc::location", GTK_TYPE_STRING,
|
||||
GTK_ARG_READWRITE, ARG_LOCATION);
|
||||
gtk_object_add_arg_type ("GstHttpSrc::bytesperread", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_BYTESPERREAD);
|
||||
|
||||
gtkobject_class->set_arg = gst_httpsrc_set_arg;
|
||||
gtkobject_class->get_arg = gst_httpsrc_get_arg;
|
||||
|
@ -112,9 +114,11 @@ gst_httpsrc_class_init(GstHttpSrcClass *klass) {
|
|||
gstsrc_class->push_region = NULL;
|
||||
}
|
||||
|
||||
static void gst_httpsrc_init(GstHttpSrc *httpsrc) {
|
||||
httpsrc->srcpad = gst_pad_new("src",GST_PAD_SRC);
|
||||
gst_element_add_pad(GST_ELEMENT(httpsrc),httpsrc->srcpad);
|
||||
static void
|
||||
gst_httpsrc_init (GstHttpSrc *httpsrc)
|
||||
{
|
||||
httpsrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||
gst_element_add_pad (GST_ELEMENT (httpsrc), httpsrc->srcpad);
|
||||
|
||||
httpsrc->url = NULL;
|
||||
httpsrc->request = NULL;
|
||||
|
@ -123,115 +127,132 @@ static void gst_httpsrc_init(GstHttpSrc *httpsrc) {
|
|||
httpsrc->bytes_per_read = 4096;
|
||||
}
|
||||
|
||||
static void gst_httpsrc_push(GstSrc *src) {
|
||||
static void
|
||||
gst_httpsrc_push (GstSrc *src)
|
||||
{
|
||||
GstHttpSrc *httpsrc;
|
||||
GstBuffer *buf;
|
||||
glong readbytes;
|
||||
|
||||
g_return_if_fail(src != NULL);
|
||||
g_return_if_fail(GST_IS_HTTPSRC(src));
|
||||
g_return_if_fail (src != NULL);
|
||||
g_return_if_fail (GST_IS_HTTPSRC (src));
|
||||
// g_return_if_fail(GST_FLAG_IS_SET(src,GST_));
|
||||
httpsrc = GST_HTTPSRC(src);
|
||||
httpsrc = GST_HTTPSRC (src);
|
||||
|
||||
buf = gst_buffer_new();
|
||||
GST_BUFFER_DATA(buf) = (gpointer)malloc(httpsrc->bytes_per_read);
|
||||
readbytes = read(httpsrc->fd,GST_BUFFER_DATA(buf),httpsrc->bytes_per_read);
|
||||
buf = gst_buffer_new ();
|
||||
GST_BUFFER_DATA (buf) = (gpointer)malloc (httpsrc->bytes_per_read);
|
||||
|
||||
readbytes = read (httpsrc->fd, GST_BUFFER_DATA (buf), httpsrc->bytes_per_read);
|
||||
|
||||
if (readbytes == 0) {
|
||||
gst_src_signal_eos(GST_SRC(httpsrc));
|
||||
gst_src_signal_eos (GST_SRC (httpsrc));
|
||||
return;
|
||||
}
|
||||
|
||||
if (readbytes < httpsrc->bytes_per_read) {
|
||||
// FIXME: set the buffer's EOF bit here
|
||||
}
|
||||
GST_BUFFER_OFFSET(buf) = httpsrc->curoffset;
|
||||
GST_BUFFER_SIZE(buf) = readbytes;
|
||||
GST_BUFFER_OFFSET (buf) = httpsrc->curoffset;
|
||||
GST_BUFFER_SIZE (buf) = readbytes;
|
||||
|
||||
httpsrc->curoffset += readbytes;
|
||||
|
||||
gst_pad_push(httpsrc->srcpad,buf);
|
||||
gst_pad_push (httpsrc->srcpad, buf);
|
||||
}
|
||||
|
||||
static gboolean gst_httpsrc_open_url(GstHttpSrc *httpsrc) {
|
||||
static gboolean
|
||||
gst_httpsrc_open_url (GstHttpSrc *httpsrc)
|
||||
{
|
||||
gint status;
|
||||
|
||||
g_return_val_if_fail(!GST_FLAG_IS_SET(httpsrc,GST_HTTPSRC_OPEN), FALSE);
|
||||
g_return_val_if_fail(httpsrc->url != NULL, FALSE);
|
||||
g_return_val_if_fail (!GST_FLAG_IS_SET (httpsrc, GST_HTTPSRC_OPEN), FALSE);
|
||||
g_return_val_if_fail (httpsrc->url != NULL, FALSE);
|
||||
|
||||
httpsrc->request = ghttp_request_new();
|
||||
ghttp_set_uri(httpsrc->request,httpsrc->url);
|
||||
ghttp_set_sync(httpsrc->request,ghttp_async);
|
||||
ghttp_set_header(httpsrc->request,"User-Agent","GstHttpSrc");
|
||||
ghttp_prepare(httpsrc->request);
|
||||
httpsrc->request = ghttp_request_new ();
|
||||
|
||||
ghttp_set_uri (httpsrc->request, httpsrc->url);
|
||||
ghttp_set_sync (httpsrc->request, ghttp_async);
|
||||
ghttp_set_header (httpsrc->request, "User-Agent", "GstHttpSrc");
|
||||
ghttp_prepare (httpsrc->request);
|
||||
|
||||
/* process everything up to the actual data stream */
|
||||
/* FIXME: should be in preroll, but hey */
|
||||
status = 0;
|
||||
while ((ghttp_get_status(httpsrc->request).proc != ghttp_proc_response)
|
||||
while ((ghttp_get_status (httpsrc->request).proc != ghttp_proc_response)
|
||||
&& (status >= 0)) {
|
||||
status = ghttp_process(httpsrc->request);
|
||||
status = ghttp_process (httpsrc->request);
|
||||
}
|
||||
|
||||
/* get the fd so we can read data ourselves */
|
||||
httpsrc->fd = ghttp_get_socket(httpsrc->request);
|
||||
GST_FLAG_SET(httpsrc,GST_HTTPSRC_OPEN);
|
||||
httpsrc->fd = ghttp_get_socket (httpsrc->request);
|
||||
|
||||
GST_FLAG_SET (httpsrc, GST_HTTPSRC_OPEN);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* unmap and close the file */
|
||||
static void gst_httpsrc_close_url(GstHttpSrc *src) {
|
||||
g_return_if_fail(GST_FLAG_IS_SET(src,GST_HTTPSRC_OPEN));
|
||||
|
||||
g_return_if_fail(src->fd > 0);
|
||||
static void
|
||||
gst_httpsrc_close_url (GstHttpSrc *src)
|
||||
{
|
||||
g_return_if_fail (GST_FLAG_IS_SET (src, GST_HTTPSRC_OPEN));
|
||||
g_return_if_fail (src->fd > 0);
|
||||
|
||||
close(src->fd);
|
||||
src->fd = 0;
|
||||
|
||||
GST_FLAG_UNSET(src,GST_HTTPSRC_OPEN);
|
||||
GST_FLAG_UNSET (src, GST_HTTPSRC_OPEN);
|
||||
}
|
||||
|
||||
static void gst_httpsrc_set_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_httpsrc_set_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstHttpSrc *src;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_HTTPSRC(object));
|
||||
src = GST_HTTPSRC(object);
|
||||
g_return_if_fail (GST_IS_HTTPSRC (object));
|
||||
|
||||
src = GST_HTTPSRC (object);
|
||||
|
||||
switch(id) {
|
||||
case ARG_LOCATION:
|
||||
/* the element must not be playing in order to do this */
|
||||
g_return_if_fail(GST_STATE(src) < GST_STATE_PLAYING);
|
||||
g_return_if_fail (GST_STATE (src) < GST_STATE_PLAYING);
|
||||
|
||||
if (src->url) g_free(src->url);
|
||||
if (src->url) g_free (src->url);
|
||||
/* clear the url if we get a NULL (is that possible?) */
|
||||
if (GTK_VALUE_STRING(*arg) == NULL) {
|
||||
gst_element_set_state(GST_ELEMENT(object),GST_STATE_NULL);
|
||||
if (GTK_VALUE_STRING (*arg) == NULL) {
|
||||
gst_element_set_state (GST_ELEMENT (object),GST_STATE_NULL);
|
||||
src->url = NULL;
|
||||
/* otherwise set the new url */
|
||||
} else {
|
||||
src->url = g_strdup(GTK_VALUE_STRING(*arg));
|
||||
src->url = g_strdup (GTK_VALUE_STRING (*arg));
|
||||
}
|
||||
break;
|
||||
case ARG_BYTESPERREAD:
|
||||
src->bytes_per_read = GTK_VALUE_INT(*arg);
|
||||
src->bytes_per_read = GTK_VALUE_INT (*arg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void gst_httpsrc_get_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_httpsrc_get_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstHttpSrc *httpsrc;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_HTTPSRC(object));
|
||||
httpsrc = GST_HTTPSRC(object);
|
||||
g_return_if_fail (GST_IS_HTTPSRC (object));
|
||||
|
||||
httpsrc = GST_HTTPSRC (object);
|
||||
|
||||
switch (id) {
|
||||
case ARG_LOCATION:
|
||||
GTK_VALUE_STRING(*arg) = httpsrc->url;
|
||||
GTK_VALUE_STRING (*arg) = httpsrc->url;
|
||||
break;
|
||||
case ARG_BYTESPERREAD:
|
||||
GTK_VALUE_INT(*arg) = httpsrc->bytes_per_read;
|
||||
GTK_VALUE_INT (*arg) = httpsrc->bytes_per_read;
|
||||
break;
|
||||
default:
|
||||
arg->type = GTK_TYPE_INVALID;
|
||||
|
@ -239,20 +260,23 @@ static void gst_httpsrc_get_arg(GtkObject *object,GtkArg *arg,guint id) {
|
|||
}
|
||||
}
|
||||
|
||||
static GstElementStateReturn gst_httpsrc_change_state(GstElement *element) {
|
||||
g_return_val_if_fail(GST_IS_HTTPSRC(element),GST_STATE_FAILURE);
|
||||
static GstElementStateReturn
|
||||
gst_httpsrc_change_state (GstElement *element)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_HTTPSRC (element), GST_STATE_FAILURE);
|
||||
|
||||
if (GST_STATE_PENDING(element) == GST_STATE_NULL) {
|
||||
if (GST_FLAG_IS_SET(element,GST_HTTPSRC_OPEN))
|
||||
gst_httpsrc_close_url(GST_HTTPSRC(element));
|
||||
if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
|
||||
if (GST_FLAG_IS_SET (element, GST_HTTPSRC_OPEN))
|
||||
gst_httpsrc_close_url (GST_HTTPSRC (element));
|
||||
} else {
|
||||
if (!GST_FLAG_IS_SET(element,GST_HTTPSRC_OPEN)) {
|
||||
if (!gst_httpsrc_open_url(GST_HTTPSRC(element)))
|
||||
if (!GST_FLAG_IS_SET (element, GST_HTTPSRC_OPEN)) {
|
||||
if (!gst_httpsrc_open_url (GST_HTTPSRC (element)))
|
||||
return GST_STATE_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (GST_ELEMENT_CLASS(parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS(parent_class)->change_state(element);
|
||||
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
||||
|
||||
return GST_STATE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ GstElementDetails gst_httpsrc_details;
|
|||
#define GST_IS_HTTPSRC(obj) \
|
||||
(GTK_CHECK_TYPE((obj),GST_TYPE_HTTPSRC))
|
||||
#define GST_IS_HTTPSRC_CLASS(obj) \
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_HTTPSRC)))
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_HTTPSRC))
|
||||
|
||||
// NOTE: per-element flags start with 16 for now
|
||||
typedef enum {
|
||||
|
|
|
@ -43,18 +43,20 @@ enum {
|
|||
};
|
||||
|
||||
|
||||
static void gst_identity_class_init(GstIdentityClass *klass);
|
||||
static void gst_identity_init(GstIdentity *identity);
|
||||
static void gst_identity_set_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_identity_get_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_identity_class_init (GstIdentityClass *klass);
|
||||
static void gst_identity_init (GstIdentity *identity);
|
||||
|
||||
void gst_identity_chain(GstPad *pad,GstBuffer *buf);
|
||||
static void gst_identity_set_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
static void gst_identity_get_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
|
||||
static void gst_identity_chain (GstPad *pad, GstBuffer *buf);
|
||||
|
||||
static GstFilterClass *parent_class = NULL;
|
||||
//static guint gst_identity_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
GtkType
|
||||
gst_identity_get_type(void) {
|
||||
gst_identity_get_type (void)
|
||||
{
|
||||
static GtkType identity_type = 0;
|
||||
|
||||
if (!identity_type) {
|
||||
|
@ -68,19 +70,21 @@ gst_identity_get_type(void) {
|
|||
(GtkArgGetFunc)gst_identity_get_arg,
|
||||
(GtkClassInitFunc)NULL,
|
||||
};
|
||||
identity_type = gtk_type_unique(GST_TYPE_FILTER,&identity_info);
|
||||
identity_type = gtk_type_unique (GST_TYPE_FILTER, &identity_info);
|
||||
}
|
||||
return identity_type;
|
||||
}
|
||||
|
||||
static void gst_identity_class_init(GstIdentityClass *klass) {
|
||||
static void
|
||||
gst_identity_class_init (GstIdentityClass *klass)
|
||||
{
|
||||
GtkObjectClass *gtkobject_class;
|
||||
GstFilterClass *gstfilter_class;
|
||||
|
||||
gtkobject_class = (GtkObjectClass*)klass;
|
||||
gstfilter_class = (GstFilterClass*)klass;
|
||||
|
||||
parent_class = gtk_type_class(GST_TYPE_FILTER);
|
||||
parent_class = gtk_type_class (GST_TYPE_FILTER);
|
||||
|
||||
//gtk_object_add_arg_type("GstIdentity::control", GTK_TYPE_INT,
|
||||
// GTK_ARG_READWRITE, ARG_CONTROL);
|
||||
|
@ -89,46 +93,49 @@ static void gst_identity_class_init(GstIdentityClass *klass) {
|
|||
//gtkobject_class->get_arg = gst_identity_get_arg;
|
||||
}
|
||||
|
||||
static void gst_identity_init(GstIdentity *identity) {
|
||||
identity->sinkpad = gst_pad_new("sink",GST_PAD_SINK);
|
||||
gst_element_add_pad(GST_ELEMENT(identity),identity->sinkpad);
|
||||
gst_pad_set_chain_function(identity->sinkpad,gst_identity_chain);
|
||||
identity->srcpad = gst_pad_new("src",GST_PAD_SRC);
|
||||
gst_element_add_pad(GST_ELEMENT(identity),identity->srcpad);
|
||||
static void
|
||||
gst_identity_init (GstIdentity *identity)
|
||||
{
|
||||
identity->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
|
||||
gst_element_add_pad (GST_ELEMENT (identity), identity->sinkpad);
|
||||
gst_pad_set_chain_function (identity->sinkpad, gst_identity_chain);
|
||||
|
||||
identity->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||
gst_element_add_pad (GST_ELEMENT (identity), identity->srcpad);
|
||||
|
||||
identity->control = 0;
|
||||
}
|
||||
|
||||
GstElement *gst_identity_new(gchar *name) {
|
||||
GstElement *identity = GST_ELEMENT(gtk_type_new(GST_TYPE_IDENTITY));
|
||||
gst_element_set_name(GST_ELEMENT(identity),name);
|
||||
return identity;
|
||||
}
|
||||
|
||||
void gst_identity_chain(GstPad *pad,GstBuffer *buf) {
|
||||
static void
|
||||
gst_identity_chain (GstPad *pad, GstBuffer *buf)
|
||||
{
|
||||
GstIdentity *identity;
|
||||
|
||||
g_return_if_fail(pad != NULL);
|
||||
g_return_if_fail(GST_IS_PAD(pad));
|
||||
g_return_if_fail(buf != NULL);
|
||||
g_return_if_fail (pad != NULL);
|
||||
g_return_if_fail (GST_IS_PAD (pad));
|
||||
g_return_if_fail (buf != NULL);
|
||||
|
||||
identity = GST_IDENTITY(pad->parent);
|
||||
identity = GST_IDENTITY (pad->parent);
|
||||
// g_print("gst_identity_chain: got buffer in '%s'\n",
|
||||
// gst_element_get_name(GST_ELEMENT(identity)));
|
||||
g_print("i");
|
||||
gst_pad_push(identity->srcpad,buf);
|
||||
|
||||
gst_pad_push (identity->srcpad, buf);
|
||||
}
|
||||
|
||||
static void gst_identity_set_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_identity_set_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstIdentity *identity;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_IDENTITY(object));
|
||||
identity = GST_IDENTITY(object);
|
||||
g_return_if_fail (GST_IS_IDENTITY (object));
|
||||
|
||||
identity = GST_IDENTITY (object);
|
||||
|
||||
switch(id) {
|
||||
case ARG_CONTROL:
|
||||
identity->control = GTK_VALUE_INT(*arg);
|
||||
identity->control = GTK_VALUE_INT (*arg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -139,12 +146,13 @@ static void gst_identity_get_arg(GtkObject *object,GtkArg *arg,guint id) {
|
|||
GstIdentity *identity;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_IDENTITY(object));
|
||||
identity = GST_IDENTITY(object);
|
||||
g_return_if_fail (GST_IS_IDENTITY (object));
|
||||
|
||||
identity = GST_IDENTITY (object);
|
||||
|
||||
switch (id) {
|
||||
case ARG_CONTROL:
|
||||
GTK_VALUE_INT(*arg) = identity->control;
|
||||
GTK_VALUE_INT (*arg) = identity->control;
|
||||
break;
|
||||
default:
|
||||
arg->type = GTK_TYPE_INVALID;
|
||||
|
|
|
@ -43,7 +43,7 @@ GstElementDetails gst_identity_details;
|
|||
#define GST_IS_IDENTITY(obj) \
|
||||
(GTK_CHECK_TYPE((obj),GST_TYPE_IDENTITY))
|
||||
#define GST_IS_IDENTITY_CLASS(obj) \
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_IDENTITY)))
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_IDENTITY))
|
||||
|
||||
typedef struct _GstIdentity GstIdentity;
|
||||
typedef struct _GstIdentityClass GstIdentityClass;
|
||||
|
|
|
@ -52,17 +52,19 @@ enum {
|
|||
};
|
||||
|
||||
|
||||
static void gst_queue_class_init(GstQueueClass *klass);
|
||||
static void gst_queue_init(GstQueue *queue);
|
||||
static void gst_queue_set_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_queue_get_arg(GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_queue_class_init (GstQueueClass *klass);
|
||||
static void gst_queue_init (GstQueue *queue);
|
||||
|
||||
static void gst_queue_push(GstConnection *connection);
|
||||
static void gst_queue_chain(GstPad *pad,GstBuffer *buf);
|
||||
static void gst_queue_set_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
static void gst_queue_get_arg (GtkObject *object, GtkArg *arg, guint id);
|
||||
|
||||
static void gst_queue_flush(GstQueue *queue);
|
||||
static void gst_queue_push (GstConnection *connection);
|
||||
static void gst_queue_chain (GstPad *pad, GstBuffer *buf);
|
||||
|
||||
static void gst_queue_flush (GstQueue *queue);
|
||||
|
||||
static GstElementStateReturn gst_queue_change_state (GstElement *element);
|
||||
|
||||
static GstElementStateReturn gst_queue_change_state(GstElement *element);
|
||||
|
||||
static GstConnectionClass *parent_class = NULL;
|
||||
//static guint gst_queue_signals[LAST_SIGNAL] = { 0 };
|
||||
|
@ -82,12 +84,14 @@ gst_queue_get_type(void) {
|
|||
(GtkArgGetFunc)gst_queue_get_arg,
|
||||
(GtkClassInitFunc)NULL,
|
||||
};
|
||||
queue_type = gtk_type_unique(GST_TYPE_CONNECTION,&queue_info);
|
||||
queue_type = gtk_type_unique (GST_TYPE_CONNECTION, &queue_info);
|
||||
}
|
||||
return queue_type;
|
||||
}
|
||||
|
||||
static void gst_queue_class_init(GstQueueClass *klass) {
|
||||
static void
|
||||
gst_queue_class_init (GstQueueClass *klass)
|
||||
{
|
||||
GtkObjectClass *gtkobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
GstConnectionClass *gstconnection_class;
|
||||
|
@ -96,12 +100,12 @@ static void gst_queue_class_init(GstQueueClass *klass) {
|
|||
gstelement_class = (GstElementClass*)klass;
|
||||
gstconnection_class = (GstConnectionClass*)klass;
|
||||
|
||||
parent_class = gtk_type_class(GST_TYPE_CONNECTION);
|
||||
parent_class = gtk_type_class (GST_TYPE_CONNECTION);
|
||||
|
||||
gtk_object_add_arg_type("GstQueue::level", GTK_TYPE_INT,
|
||||
GTK_ARG_READABLE, ARG_LEVEL);
|
||||
gtk_object_add_arg_type("GstQueue::max_level", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_MAX_LEVEL);
|
||||
gtk_object_add_arg_type ("GstQueue::level", GTK_TYPE_INT,
|
||||
GTK_ARG_READABLE, ARG_LEVEL);
|
||||
gtk_object_add_arg_type ("GstQueue::max_level", GTK_TYPE_INT,
|
||||
GTK_ARG_READWRITE, ARG_MAX_LEVEL);
|
||||
|
||||
gstconnection_class->push = gst_queue_push;
|
||||
|
||||
|
@ -111,13 +115,15 @@ static void gst_queue_class_init(GstQueueClass *klass) {
|
|||
gstelement_class->change_state = gst_queue_change_state;
|
||||
}
|
||||
|
||||
static void gst_queue_init(GstQueue *queue) {
|
||||
queue->sinkpad = gst_pad_new("sink",GST_PAD_SINK);
|
||||
gst_element_add_pad(GST_ELEMENT(queue),queue->sinkpad);
|
||||
gst_pad_set_chain_function(queue->sinkpad,gst_queue_chain);
|
||||
static void
|
||||
gst_queue_init (GstQueue *queue)
|
||||
{
|
||||
queue->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
|
||||
gst_element_add_pad (GST_ELEMENT (queue), queue->sinkpad);
|
||||
gst_pad_set_chain_function (queue->sinkpad, gst_queue_chain);
|
||||
|
||||
queue->srcpad = gst_pad_new("src",GST_PAD_SRC);
|
||||
gst_element_add_pad(GST_ELEMENT(queue),queue->srcpad);
|
||||
queue->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||
gst_element_add_pad (GST_ELEMENT (queue), queue->srcpad);
|
||||
|
||||
queue->queue = NULL;
|
||||
queue->level_buffers = 0;
|
||||
|
@ -126,54 +132,55 @@ static void gst_queue_init(GstQueue *queue) {
|
|||
queue->size_buffers = 0;
|
||||
queue->size_bytes = 0;
|
||||
|
||||
queue->emptylock = g_mutex_new();
|
||||
queue->emptycond = g_cond_new();
|
||||
queue->emptylock = g_mutex_new ();
|
||||
queue->emptycond = g_cond_new ();
|
||||
|
||||
queue->fulllock = g_mutex_new();
|
||||
queue->fullcond = g_cond_new();
|
||||
queue->fulllock = g_mutex_new ();
|
||||
queue->fullcond = g_cond_new ();
|
||||
}
|
||||
|
||||
GstElement *gst_queue_new(gchar *name) {
|
||||
GstElement *queue = GST_ELEMENT(gtk_type_new(GST_TYPE_QUEUE));
|
||||
gst_element_set_name(GST_ELEMENT(queue),name);
|
||||
return queue;
|
||||
}
|
||||
|
||||
static void gst_queue_cleanup_buffers(gpointer data, const gpointer user_data)
|
||||
static void
|
||||
gst_queue_cleanup_buffers (gpointer data, const gpointer user_data)
|
||||
{
|
||||
DEBUG("queue: %s cleaning buffer %p\n", (gchar *)user_data, data);
|
||||
|
||||
gst_buffer_unref (GST_BUFFER (data));
|
||||
}
|
||||
|
||||
static void gst_queue_flush(GstQueue *queue) {
|
||||
g_slist_foreach(queue->queue, gst_queue_cleanup_buffers, (char *)gst_element_get_name(GST_ELEMENT(queue)));
|
||||
g_slist_free(queue->queue);
|
||||
static void
|
||||
gst_queue_flush (GstQueue *queue)
|
||||
{
|
||||
g_slist_foreach (queue->queue, gst_queue_cleanup_buffers,
|
||||
(char *)gst_element_get_name (GST_ELEMENT (queue)));
|
||||
g_slist_free (queue->queue);
|
||||
|
||||
queue->queue = NULL;
|
||||
queue->level_buffers = 0;
|
||||
}
|
||||
|
||||
static void gst_queue_chain(GstPad *pad,GstBuffer *buf) {
|
||||
static void
|
||||
gst_queue_chain (GstPad *pad, GstBuffer *buf)
|
||||
{
|
||||
GstQueue *queue;
|
||||
gboolean tosignal = FALSE;
|
||||
const guchar *name;
|
||||
|
||||
g_return_if_fail(pad != NULL);
|
||||
g_return_if_fail(GST_IS_PAD(pad));
|
||||
g_return_if_fail(buf != NULL);
|
||||
g_return_if_fail (pad != NULL);
|
||||
g_return_if_fail (GST_IS_PAD (pad));
|
||||
g_return_if_fail (buf != NULL);
|
||||
|
||||
queue = GST_QUEUE(pad->parent);
|
||||
name = gst_element_get_name(GST_ELEMENT(queue));
|
||||
queue = GST_QUEUE (pad->parent);
|
||||
name = gst_element_get_name (GST_ELEMENT (queue));
|
||||
|
||||
/* we have to lock the queue since we span threads */
|
||||
|
||||
DEBUG("queue: try have queue lock\n");
|
||||
GST_LOCK(queue);
|
||||
DEBUG("queue: %s adding buffer %p %ld\n", name, buf, pthread_self());
|
||||
GST_LOCK (queue);
|
||||
DEBUG("queue: %s adding buffer %p %ld\n", name, buf, pthread_self ());
|
||||
DEBUG("queue: have queue lock\n");
|
||||
|
||||
if (GST_BUFFER_FLAG_IS_SET(buf, GST_BUFFER_FLUSH)) {
|
||||
gst_queue_flush(queue);
|
||||
if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLUSH)) {
|
||||
gst_queue_flush (queue);
|
||||
}
|
||||
|
||||
DEBUG("queue: %s: chain %d %p\n", name, queue->level_buffers, buf);
|
||||
|
@ -181,17 +188,17 @@ static void gst_queue_chain(GstPad *pad,GstBuffer *buf) {
|
|||
while (queue->level_buffers >= queue->max_buffers) {
|
||||
DEBUG("queue: %s waiting %d\n", name, queue->level_buffers);
|
||||
STATUS("%s: O\n");
|
||||
GST_UNLOCK(queue);
|
||||
g_mutex_lock(queue->fulllock);
|
||||
g_cond_wait(queue->fullcond,queue->fulllock);
|
||||
g_mutex_unlock(queue->fulllock);
|
||||
GST_LOCK(queue);
|
||||
GST_UNLOCK (queue);
|
||||
g_mutex_lock (queue->fulllock);
|
||||
g_cond_wait (queue->fullcond, queue->fulllock);
|
||||
g_mutex_unlock (queue->fulllock);
|
||||
GST_LOCK (queue);
|
||||
STATUS("%s: O+\n");
|
||||
DEBUG("queue: %s waiting done %d\n", name, queue->level_buffers);
|
||||
}
|
||||
|
||||
/* put the buffer on the tail of the list */
|
||||
queue->queue = g_slist_append(queue->queue,buf);
|
||||
queue->queue = g_slist_append (queue->queue, buf);
|
||||
STATUS("%s: +\n");
|
||||
|
||||
/* if we were empty, but aren't any more, signal a condition */
|
||||
|
@ -200,116 +207,127 @@ static void gst_queue_chain(GstPad *pad,GstBuffer *buf) {
|
|||
|
||||
/* we can unlock now */
|
||||
DEBUG("queue: %s chain %d end signal(%d,%p)\n", name, queue->level_buffers, tosignal, queue->emptycond);
|
||||
GST_UNLOCK(queue);
|
||||
GST_UNLOCK (queue);
|
||||
|
||||
if (tosignal) {
|
||||
g_mutex_lock(queue->emptylock);
|
||||
g_mutex_lock (queue->emptylock);
|
||||
STATUS("%s: >\n");
|
||||
g_cond_signal(queue->emptycond);
|
||||
g_cond_signal (queue->emptycond);
|
||||
STATUS("%s: >>\n");
|
||||
g_mutex_unlock(queue->emptylock);
|
||||
g_mutex_unlock (queue->emptylock);
|
||||
}
|
||||
}
|
||||
|
||||
static void gst_queue_push(GstConnection *connection) {
|
||||
GstQueue *queue = GST_QUEUE(connection);
|
||||
static void
|
||||
gst_queue_push (GstConnection *connection)
|
||||
{
|
||||
GstQueue *queue = GST_QUEUE (connection);
|
||||
GstBuffer *buf = NULL;
|
||||
GSList *front;
|
||||
gboolean tosignal = FALSE;
|
||||
const guchar *name;
|
||||
|
||||
name = gst_element_get_name(GST_ELEMENT(queue));
|
||||
name = gst_element_get_name (GST_ELEMENT (queue));
|
||||
|
||||
/* have to lock for thread-safety */
|
||||
DEBUG("queue: %s try have queue lock\n", name);
|
||||
GST_LOCK(queue);
|
||||
DEBUG("queue: %s push %d %ld %p\n", name, queue->level_buffers, pthread_self(), queue->emptycond);
|
||||
GST_LOCK (queue);
|
||||
DEBUG("queue: %s push %d %ld %p\n", name, queue->level_buffers, pthread_self (), queue->emptycond);
|
||||
DEBUG("queue: %s have queue lock\n", name);
|
||||
|
||||
while (!queue->level_buffers) {
|
||||
STATUS("queue: %s U released lock\n");
|
||||
GST_UNLOCK(queue);
|
||||
g_mutex_lock(queue->emptylock);
|
||||
g_cond_wait(queue->emptycond,queue->emptylock);
|
||||
g_mutex_unlock(queue->emptylock);
|
||||
GST_LOCK(queue);
|
||||
GST_UNLOCK (queue);
|
||||
g_mutex_lock (queue->emptylock);
|
||||
g_cond_wait (queue->emptycond, queue->emptylock);
|
||||
g_mutex_unlock (queue->emptylock);
|
||||
GST_LOCK (queue);
|
||||
STATUS("queue: %s U- getting lock\n");
|
||||
}
|
||||
|
||||
front = queue->queue;
|
||||
buf = (GstBuffer *)(front->data);
|
||||
queue->queue = g_slist_remove_link(queue->queue,front);
|
||||
g_slist_free(front);
|
||||
queue->queue = g_slist_remove_link (queue->queue, front);
|
||||
g_slist_free (front);
|
||||
|
||||
queue->level_buffers--;
|
||||
STATUS("%s: -\n");
|
||||
tosignal = queue->level_buffers < queue->max_buffers;
|
||||
GST_UNLOCK(queue);
|
||||
|
||||
if (tosignal) {
|
||||
g_mutex_lock(queue->fulllock);
|
||||
g_mutex_lock (queue->fulllock);
|
||||
STATUS("%s: < \n");
|
||||
g_cond_signal(queue->fullcond);
|
||||
g_cond_signal (queue->fullcond);
|
||||
STATUS("%s: << \n");
|
||||
g_mutex_unlock(queue->fulllock);
|
||||
g_mutex_unlock (queue->fulllock);
|
||||
}
|
||||
|
||||
DEBUG("queue: %s pushing %d %p \n", name, queue->level_buffers, buf);
|
||||
gst_pad_push(queue->srcpad,buf);
|
||||
gst_pad_push (queue->srcpad, buf);
|
||||
DEBUG("queue: %s pushing %d done \n", name, queue->level_buffers);
|
||||
|
||||
/* unlock now */
|
||||
}
|
||||
|
||||
static GstElementStateReturn gst_queue_change_state(GstElement *element) {
|
||||
static GstElementStateReturn
|
||||
gst_queue_change_state (GstElement *element)
|
||||
{
|
||||
GstQueue *queue;
|
||||
g_return_val_if_fail(GST_IS_QUEUE(element),GST_STATE_FAILURE);
|
||||
g_return_val_if_fail (GST_IS_QUEUE (element), GST_STATE_FAILURE);
|
||||
|
||||
queue = GST_QUEUE(element);
|
||||
DEBUG("gstqueue: state pending %d\n", GST_STATE_PENDING(element));
|
||||
queue = GST_QUEUE (element);
|
||||
DEBUG("gstqueue: state pending %d\n", GST_STATE_PENDING (element));
|
||||
|
||||
/* if going down into NULL state, clear out buffers*/
|
||||
if (GST_STATE_PENDING(element) == GST_STATE_READY) {
|
||||
if (GST_STATE_PENDING (element) == GST_STATE_READY) {
|
||||
/* otherwise (READY or higher) we need to open the file */
|
||||
gst_queue_flush(queue);
|
||||
gst_queue_flush (queue);
|
||||
}
|
||||
|
||||
/* if we haven't failed already, give the parent class a chance to ;-) */
|
||||
if (GST_ELEMENT_CLASS(parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS(parent_class)->change_state(element);
|
||||
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
||||
|
||||
return GST_STATE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static void gst_queue_set_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_queue_set_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstQueue *queue;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_QUEUE(object));
|
||||
queue = GST_QUEUE(object);
|
||||
g_return_if_fail (GST_IS_QUEUE (object));
|
||||
|
||||
queue = GST_QUEUE (object);
|
||||
|
||||
switch(id) {
|
||||
case ARG_MAX_LEVEL:
|
||||
queue->max_buffers = GTK_VALUE_INT(*arg);
|
||||
queue->max_buffers = GTK_VALUE_INT (*arg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void gst_queue_get_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||
static void
|
||||
gst_queue_get_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||
{
|
||||
GstQueue *queue;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail(GST_IS_QUEUE(object));
|
||||
queue = GST_QUEUE(object);
|
||||
g_return_if_fail (GST_IS_QUEUE (object));
|
||||
|
||||
queue = GST_QUEUE (object);
|
||||
|
||||
switch (id) {
|
||||
case ARG_LEVEL:
|
||||
GTK_VALUE_INT(*arg) = queue->level_buffers;
|
||||
GTK_VALUE_INT (*arg) = queue->level_buffers;
|
||||
break;
|
||||
case ARG_MAX_LEVEL:
|
||||
GTK_VALUE_INT(*arg) = queue->max_buffers;
|
||||
GTK_VALUE_INT (*arg) = queue->max_buffers;
|
||||
break;
|
||||
default:
|
||||
arg->type = GTK_TYPE_INVALID;
|
||||
|
|
|
@ -73,7 +73,7 @@ struct _GstQueueClass {
|
|||
GstConnectionClass parent_class;
|
||||
};
|
||||
|
||||
GtkType gst_queue_get_type(void);
|
||||
GtkType gst_queue_get_type (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ GstElementDetails gst_sinesrc_details;
|
|||
#define GST_IS_SINESRC(obj) \
|
||||
(GTK_CHECK_TYPE((obj),GST_TYPE_SINESRC))
|
||||
#define GST_IS_SINESRC_CLASS(obj) \
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_SINESRC)))
|
||||
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_SINESRC))
|
||||
|
||||
typedef struct _GstSineSrc GstSineSrc;
|
||||
typedef struct _GstSineSrcClass GstSineSrcClass;
|
||||
|
|
Loading…
Reference in a new issue