2001-12-22 23:26:33 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999-2001 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2003-01-17 14:04:39 +00:00
|
|
|
|
2003-06-29 19:46:13 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2001-12-22 23:26:33 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <gst/gst.h>
|
2001-12-23 12:18:18 +00:00
|
|
|
#include <gst/audio/audio.h>
|
2003-01-17 14:04:39 +00:00
|
|
|
|
2001-12-22 23:26:33 +00:00
|
|
|
#include "gstplayondemand.h"
|
|
|
|
|
2003-06-16 22:20:52 +00:00
|
|
|
/* in these files, a 'tick' is a discrete unit of time, usually around the 1ms
|
|
|
|
* range. a tick is not divisible into smaller units of time. 1ms is probably
|
|
|
|
* way beyond what a real computer can actually keep track of, but hey ... */
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2003-01-17 14:04:39 +00:00
|
|
|
/* some default values */
|
2004-03-15 19:32:27 +00:00
|
|
|
#define GST_POD_MAX_PLAYS 100 /* maximum simultaneous plays */
|
|
|
|
#define GST_POD_BUFFER_TIME 5.0 /* buffer length in seconds */
|
|
|
|
#define GST_POD_TICK_RATE 1e-6 /* ticks per second */
|
2003-01-17 14:04:39 +00:00
|
|
|
|
|
|
|
/* buffer pool fallback values ... use if no buffer pool is available */
|
|
|
|
#define GST_POD_BUFPOOL_SIZE 4096
|
|
|
|
#define GST_POD_BUFPOOL_NUM 6
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2003-01-17 14:04:39 +00:00
|
|
|
|
2006-04-25 21:56:38 +00:00
|
|
|
static const GstElementDetails play_on_demand_details =
|
2006-04-06 11:35:26 +00:00
|
|
|
GST_ELEMENT_DETAILS ("Play On Demand",
|
|
|
|
"Filter/Editor/Audio",
|
|
|
|
"Schedule a stream to play at specific times, or when a signal is received",
|
|
|
|
"Leif Morgan Johnson <leif@ambient.2y.net>");
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
static GstStaticPadTemplate play_on_demand_sink_template =
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
2003-12-22 01:47:09 +00:00
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
|
2004-03-14 22:34:33 +00:00
|
|
|
);
|
2003-12-22 01:47:09 +00:00
|
|
|
|
|
|
|
static GstStaticPadTemplate play_on_demand_src_template =
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("src",
|
2003-12-22 01:47:09 +00:00
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
|
2004-03-14 22:34:33 +00:00
|
|
|
);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2003-01-17 14:04:39 +00:00
|
|
|
|
|
|
|
/* GObject functionality */
|
2004-03-14 22:34:33 +00:00
|
|
|
static void play_on_demand_class_init (GstPlayOnDemandClass * klass);
|
|
|
|
static void play_on_demand_base_init (GstPlayOnDemandClass * klass);
|
|
|
|
static void play_on_demand_init (GstPlayOnDemand * filter);
|
|
|
|
static void play_on_demand_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void play_on_demand_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
Fixes a bunch of problems with finalize and dispose functions, either assumptions that dispose is only called once, o...
Original commit message from CVS:
* ext/alsa/gstalsa.c: (gst_alsa_class_init), (gst_alsa_dispose),
(gst_alsa_finalize):
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_class_init),
(gst_cdaudio_finalize):
* ext/cdparanoia/gstcdparanoia.c: (cdparanoia_class_init),
(cdparanoia_finalize):
* ext/divx/gstdivxdec.c: (gst_divxdec_dispose):
* ext/divx/gstdivxenc.c: (gst_divxenc_dispose):
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_finalize):
* ext/flac/gstflacdec.c: (gst_flacdec_class_init),
(gst_flacdec_finalize):
* ext/flac/gstflacenc.c: (gst_flacenc_class_init),
(gst_flacenc_finalize):
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_class_init),
(gst_gnomevfssink_finalize):
* ext/gnomevfs/gstgnomevfssrc.c: (gst_gnomevfssrc_class_init),
(gst_gnomevfssrc_finalize):
* ext/libfame/gstlibfame.c: (gst_fameenc_class_init),
(gst_fameenc_finalize):
* ext/nas/nassink.c: (gst_nassink_class_init),
(gst_nassink_finalize):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_finalize),
(gst_sdlvideosink_class_init):
* ext/sndfile/gstsf.c: (gst_sf_dispose):
* gst-libs/gst/mixer/mixertrack.c: (gst_mixer_track_dispose):
* gst-libs/gst/tuner/tunerchannel.c: (gst_tuner_channel_dispose):
* gst-libs/gst/tuner/tunernorm.c: (gst_tuner_norm_dispose):
* gst-libs/gst/xwindowlistener/xwindowlistener.c:
(gst_x_window_listener_dispose):
* gst/audioscale/gstaudioscale.c:
* gst/playondemand/gstplayondemand.c: (play_on_demand_class_init),
(play_on_demand_finalize):
* gst/videofilter/gstvideobalance.c: (gst_videobalance_dispose):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_chain):
* sys/cdrom/gstcdplayer.c: (cdplayer_class_init),
(cdplayer_finalize):
* sys/glsink/glimagesink.c: (gst_glimagesink_finalize),
(gst_glimagesink_class_init):
* sys/oss/gstosselement.c: (gst_osselement_class_init),
(gst_osselement_finalize):
* sys/oss/gstosssink.c: (gst_osssink_dispose):
* sys/oss/gstosssrc.c: (gst_osssrc_dispose):
* sys/v4l/gstv4lelement.c: (gst_v4lelement_dispose):
Fixes a bunch of problems with finalize and dispose functions,
either assumptions that dispose is only called once, or not calling
the parent class dispose/finalize function
2004-11-01 14:43:38 +00:00
|
|
|
static void play_on_demand_finalize (GObject * object);
|
2002-10-17 20:05:58 +00:00
|
|
|
|
2003-01-17 14:04:39 +00:00
|
|
|
/* GStreamer functionality */
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstPadLinkReturn play_on_demand_pad_link (GstPad * pad,
|
|
|
|
const GstCaps * caps);
|
|
|
|
static void play_on_demand_loop (GstElement * elem);
|
|
|
|
static void play_on_demand_set_clock (GstElement * elem, GstClock * clock);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2003-01-17 14:04:39 +00:00
|
|
|
/* signal handlers */
|
2004-03-14 22:34:33 +00:00
|
|
|
static void play_on_demand_play_handler (GstElement * elem);
|
|
|
|
static void play_on_demand_clear_handler (GstElement * elem);
|
|
|
|
static void play_on_demand_reset_handler (GstElement * elem);
|
2002-10-17 20:05:58 +00:00
|
|
|
|
2003-01-17 14:04:39 +00:00
|
|
|
/* utility functions */
|
2004-03-14 22:34:33 +00:00
|
|
|
static void play_on_demand_add_play_pointer (GstPlayOnDemand * filter,
|
|
|
|
guint pos);
|
|
|
|
static void play_on_demand_resize_buffer (GstPlayOnDemand * filter);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
GType
|
2002-01-22 04:44:21 +00:00
|
|
|
gst_play_on_demand_get_type (void)
|
|
|
|
{
|
2001-12-22 23:26:33 +00:00
|
|
|
static GType play_on_demand_type = 0;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!play_on_demand_type) {
|
2001-12-22 23:26:33 +00:00
|
|
|
static const GTypeInfo play_on_demand_info = {
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstPlayOnDemandClass),
|
2003-11-02 21:40:55 +00:00
|
|
|
(GBaseInitFunc) play_on_demand_base_init,
|
2001-12-22 23:26:33 +00:00
|
|
|
NULL,
|
|
|
|
(GClassInitFunc) play_on_demand_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstPlayOnDemand),
|
2001-12-22 23:26:33 +00:00
|
|
|
0,
|
|
|
|
(GInstanceInitFunc) play_on_demand_init,
|
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
play_on_demand_type = g_type_register_static (GST_TYPE_ELEMENT,
|
2004-03-15 19:32:27 +00:00
|
|
|
"GstPlayOnDemand", &play_on_demand_info, 0);
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
return play_on_demand_type;
|
|
|
|
}
|
|
|
|
|
2003-01-17 14:04:39 +00:00
|
|
|
|
|
|
|
/* signals and properties */
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2003-01-17 14:04:39 +00:00
|
|
|
/* add signals here */
|
|
|
|
PLAYED_SIGNAL,
|
2003-07-19 23:17:57 +00:00
|
|
|
STOPPED_SIGNAL,
|
2003-01-17 14:04:39 +00:00
|
|
|
PLAY_SIGNAL,
|
|
|
|
CLEAR_SIGNAL,
|
|
|
|
RESET_SIGNAL,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2003-01-17 14:04:39 +00:00
|
|
|
PROP_0,
|
|
|
|
PROP_MUTE,
|
|
|
|
PROP_BUFFER_TIME,
|
|
|
|
PROP_MAX_PLAYS,
|
2003-06-16 22:20:52 +00:00
|
|
|
PROP_TICK_RATE,
|
2003-01-17 14:04:39 +00:00
|
|
|
PROP_TOTAL_TICKS,
|
2004-05-21 22:39:30 +00:00
|
|
|
PROP_TICKS
|
2003-01-17 14:04:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static guint gst_pod_filter_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
|
|
|
|
2003-11-02 21:40:55 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
play_on_demand_base_init (GstPlayOnDemandClass * klass)
|
2003-11-02 21:40:55 +00:00
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&play_on_demand_src_template));
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&play_on_demand_sink_template));
|
|
|
|
gst_element_class_set_details (element_class, &play_on_demand_details);
|
2003-11-02 21:40:55 +00:00
|
|
|
}
|
|
|
|
|
2001-12-22 23:26:33 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
play_on_demand_class_init (GstPlayOnDemandClass * klass)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
GObjectClass *gobject_class;
|
2001-12-22 23:26:33 +00:00
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
2001-12-22 23:26:33 +00:00
|
|
|
gstelement_class = (GstElementClass *) klass;
|
|
|
|
|
2003-01-17 14:04:39 +00:00
|
|
|
gst_pod_filter_signals[PLAYED_SIGNAL] =
|
2004-03-14 22:34:33 +00:00
|
|
|
g_signal_new ("played", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GstPlayOnDemandClass, played),
|
|
|
|
NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
2003-01-17 14:04:39 +00:00
|
|
|
|
2003-07-19 23:17:57 +00:00
|
|
|
gst_pod_filter_signals[STOPPED_SIGNAL] =
|
2004-03-14 22:34:33 +00:00
|
|
|
g_signal_new ("stopped", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GstPlayOnDemandClass, stopped),
|
|
|
|
NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
2003-07-19 23:17:57 +00:00
|
|
|
|
2001-12-22 23:26:33 +00:00
|
|
|
gst_pod_filter_signals[PLAY_SIGNAL] =
|
2004-03-14 22:34:33 +00:00
|
|
|
g_signal_new ("play", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GstPlayOnDemandClass, play),
|
|
|
|
NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2003-01-17 14:04:39 +00:00
|
|
|
gst_pod_filter_signals[CLEAR_SIGNAL] =
|
2004-03-14 22:34:33 +00:00
|
|
|
g_signal_new ("clear", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GstPlayOnDemandClass, clear),
|
|
|
|
NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
2003-01-17 14:04:39 +00:00
|
|
|
|
2001-12-22 23:26:33 +00:00
|
|
|
gst_pod_filter_signals[RESET_SIGNAL] =
|
2004-03-14 22:34:33 +00:00
|
|
|
g_signal_new ("reset", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GstPlayOnDemandClass, reset),
|
|
|
|
NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
klass->play = play_on_demand_play_handler;
|
2003-01-17 14:04:39 +00:00
|
|
|
klass->clear = play_on_demand_clear_handler;
|
2001-12-22 23:26:33 +00:00
|
|
|
klass->reset = play_on_demand_reset_handler;
|
|
|
|
|
2006-04-08 21:48:01 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
gobject_class->set_property = play_on_demand_set_property;
|
|
|
|
gobject_class->get_property = play_on_demand_get_property;
|
Fixes a bunch of problems with finalize and dispose functions, either assumptions that dispose is only called once, o...
Original commit message from CVS:
* ext/alsa/gstalsa.c: (gst_alsa_class_init), (gst_alsa_dispose),
(gst_alsa_finalize):
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_class_init),
(gst_cdaudio_finalize):
* ext/cdparanoia/gstcdparanoia.c: (cdparanoia_class_init),
(cdparanoia_finalize):
* ext/divx/gstdivxdec.c: (gst_divxdec_dispose):
* ext/divx/gstdivxenc.c: (gst_divxenc_dispose):
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_finalize):
* ext/flac/gstflacdec.c: (gst_flacdec_class_init),
(gst_flacdec_finalize):
* ext/flac/gstflacenc.c: (gst_flacenc_class_init),
(gst_flacenc_finalize):
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_class_init),
(gst_gnomevfssink_finalize):
* ext/gnomevfs/gstgnomevfssrc.c: (gst_gnomevfssrc_class_init),
(gst_gnomevfssrc_finalize):
* ext/libfame/gstlibfame.c: (gst_fameenc_class_init),
(gst_fameenc_finalize):
* ext/nas/nassink.c: (gst_nassink_class_init),
(gst_nassink_finalize):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_finalize),
(gst_sdlvideosink_class_init):
* ext/sndfile/gstsf.c: (gst_sf_dispose):
* gst-libs/gst/mixer/mixertrack.c: (gst_mixer_track_dispose):
* gst-libs/gst/tuner/tunerchannel.c: (gst_tuner_channel_dispose):
* gst-libs/gst/tuner/tunernorm.c: (gst_tuner_norm_dispose):
* gst-libs/gst/xwindowlistener/xwindowlistener.c:
(gst_x_window_listener_dispose):
* gst/audioscale/gstaudioscale.c:
* gst/playondemand/gstplayondemand.c: (play_on_demand_class_init),
(play_on_demand_finalize):
* gst/videofilter/gstvideobalance.c: (gst_videobalance_dispose):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_chain):
* sys/cdrom/gstcdplayer.c: (cdplayer_class_init),
(cdplayer_finalize):
* sys/glsink/glimagesink.c: (gst_glimagesink_finalize),
(gst_glimagesink_class_init):
* sys/oss/gstosselement.c: (gst_osselement_class_init),
(gst_osselement_finalize):
* sys/oss/gstosssink.c: (gst_osssink_dispose):
* sys/oss/gstosssrc.c: (gst_osssrc_dispose):
* sys/v4l/gstv4lelement.c: (gst_v4lelement_dispose):
Fixes a bunch of problems with finalize and dispose functions,
either assumptions that dispose is only called once, or not calling
the parent class dispose/finalize function
2004-11-01 14:43:38 +00:00
|
|
|
gobject_class->finalize = play_on_demand_finalize;
|
2002-11-27 20:54:42 +00:00
|
|
|
|
|
|
|
gstelement_class->set_clock = play_on_demand_set_clock;
|
2003-01-17 14:04:39 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MUTE,
|
|
|
|
g_param_spec_boolean ("mute", "Silence output", "Do not output any sound",
|
2004-03-15 19:32:27 +00:00
|
|
|
FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BUFFER_TIME,
|
|
|
|
g_param_spec_float ("buffer-time", "Buffer length in seconds",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Number of seconds of audio the buffer holds", 0.0, G_MAXFLOAT,
|
|
|
|
GST_POD_BUFFER_TIME, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MAX_PLAYS,
|
|
|
|
g_param_spec_uint ("max-plays", "Maximum simultaneous playbacks",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Maximum allowed number of simultaneous plays from the buffer", 1,
|
|
|
|
G_MAXUINT, GST_POD_MAX_PLAYS, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_TICK_RATE,
|
|
|
|
g_param_spec_float ("tick-rate", "Tick rate (ticks/second)",
|
2004-03-15 19:32:27 +00:00
|
|
|
"The rate of musical ticks, the smallest time unit in a song", 0,
|
|
|
|
G_MAXFLOAT, GST_POD_TICK_RATE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_TOTAL_TICKS,
|
|
|
|
g_param_spec_uint ("total-ticks", "Total number of ticks",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Total number of ticks in the tick array", 1, G_MAXUINT, 1,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_TICKS,
|
|
|
|
g_param_spec_pointer ("ticks", "Ticks to play sample on",
|
2004-03-15 19:32:27 +00:00
|
|
|
"An array of ticks (musical times) at which to play the sample",
|
|
|
|
G_PARAM_READWRITE));
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
play_on_demand_init (GstPlayOnDemand * filter)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
filter->srcpad =
|
2007-06-22 10:46:33 +00:00
|
|
|
gst_pad_new_from_static_template (&play_on_demand_src_template, "src");
|
2004-03-14 22:34:33 +00:00
|
|
|
filter->sinkpad =
|
2007-06-22 10:46:33 +00:00
|
|
|
gst_pad_new_from_static_template (&play_on_demand_sink_template, "sink");
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_pad_set_link_function (filter->sinkpad, play_on_demand_pad_link);
|
2002-10-17 20:05:58 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
|
|
|
|
gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_element_set_loop_function (GST_ELEMENT (filter), play_on_demand_loop);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2003-01-17 14:04:39 +00:00
|
|
|
filter->clock = NULL;
|
|
|
|
|
2003-06-16 22:20:52 +00:00
|
|
|
filter->rate = 0;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
filter->ticks = g_new (guint32, filter->total_ticks / 32 + 1);
|
|
|
|
filter->plays = g_new (guint, filter->max_plays);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
play_on_demand_resize_buffer (filter);
|
|
|
|
play_on_demand_reset_handler (GST_ELEMENT (filter));
|
2003-01-17 14:04:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
play_on_demand_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
2003-01-17 14:04:39 +00:00
|
|
|
{
|
|
|
|
GstPlayOnDemand *filter;
|
2004-03-14 22:34:33 +00:00
|
|
|
register guint i;
|
|
|
|
guint new_size, min_size, *new_plays;
|
|
|
|
guint *new_ticks;
|
2003-01-17 14:04:39 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (GST_IS_PLAYONDEMAND (object));
|
|
|
|
filter = GST_PLAYONDEMAND (object);
|
2003-01-17 14:04:39 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2004-03-14 22:34:33 +00:00
|
|
|
case PROP_MUTE:
|
|
|
|
filter->mute = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
case PROP_BUFFER_TIME:
|
|
|
|
filter->buffer_time = g_value_get_float (value);
|
|
|
|
play_on_demand_resize_buffer (filter);
|
|
|
|
|
|
|
|
/* clear out now-invalid play pointers */
|
|
|
|
for (i = 0; i < filter->max_plays; i++)
|
2004-03-15 19:32:27 +00:00
|
|
|
filter->plays[i] = G_MAXUINT;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
case PROP_MAX_PLAYS:
|
|
|
|
new_size = g_value_get_uint (value);
|
|
|
|
min_size = (new_size < filter->max_plays) ? new_size : filter->max_plays;
|
|
|
|
|
|
|
|
new_plays = g_new (guint, new_size);
|
|
|
|
for (i = 0; i < min_size; i++)
|
2004-03-15 19:32:27 +00:00
|
|
|
new_plays[i] = filter->plays[i];
|
2004-03-14 22:34:33 +00:00
|
|
|
for (i = min_size; i < new_size; i++)
|
2004-03-15 19:32:27 +00:00
|
|
|
new_plays[i] = G_MAXUINT;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
g_free (filter->plays);
|
|
|
|
filter->plays = new_plays;
|
|
|
|
filter->max_plays = new_size;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case PROP_TICK_RATE:
|
|
|
|
filter->tick_rate = g_value_get_float (value);
|
|
|
|
break;
|
|
|
|
case PROP_TOTAL_TICKS:
|
|
|
|
new_size = g_value_get_uint (value);
|
|
|
|
min_size =
|
2004-03-15 19:32:27 +00:00
|
|
|
(new_size < filter->total_ticks) ? new_size : filter->total_ticks;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
new_ticks = g_new (guint32, new_size / 32 + 1);
|
|
|
|
for (i = 0; i <= min_size / 32; i++)
|
2004-03-15 19:32:27 +00:00
|
|
|
new_ticks[i] = filter->ticks[i];
|
2004-03-14 22:34:33 +00:00
|
|
|
for (i = min_size / 32 + 1; i <= new_size / 32; i++)
|
2004-03-15 19:32:27 +00:00
|
|
|
new_ticks[i] = 0;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
g_free (filter->ticks);
|
2003-06-16 22:20:52 +00:00
|
|
|
filter->ticks = new_ticks;
|
2004-03-14 22:34:33 +00:00
|
|
|
filter->total_ticks = new_size;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case PROP_TICKS:
|
|
|
|
new_ticks = (guint *) g_value_get_pointer (value);
|
|
|
|
if (new_ticks) {
|
2004-03-15 19:32:27 +00:00
|
|
|
g_free (filter->ticks);
|
|
|
|
filter->ticks = new_ticks;
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-17 14:04:39 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
play_on_demand_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
2003-01-17 14:04:39 +00:00
|
|
|
{
|
|
|
|
GstPlayOnDemand *filter;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (GST_IS_PLAYONDEMAND (object));
|
|
|
|
filter = GST_PLAYONDEMAND (object);
|
2003-01-17 14:04:39 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2004-03-14 22:34:33 +00:00
|
|
|
case PROP_MUTE:
|
|
|
|
g_value_set_boolean (value, filter->mute);
|
|
|
|
break;
|
|
|
|
case PROP_BUFFER_TIME:
|
|
|
|
g_value_set_float (value, filter->buffer_time);
|
|
|
|
break;
|
|
|
|
case PROP_MAX_PLAYS:
|
|
|
|
g_value_set_uint (value, filter->max_plays);
|
|
|
|
break;
|
|
|
|
case PROP_TICK_RATE:
|
|
|
|
g_value_set_float (value, filter->tick_rate);
|
|
|
|
break;
|
|
|
|
case PROP_TOTAL_TICKS:
|
|
|
|
g_value_set_uint (value, filter->total_ticks);
|
|
|
|
break;
|
|
|
|
case PROP_TICKS:
|
|
|
|
g_value_set_pointer (value, (gpointer) filter->ticks);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
2003-01-17 14:04:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-16 22:20:52 +00:00
|
|
|
static void
|
Fixes a bunch of problems with finalize and dispose functions, either assumptions that dispose is only called once, o...
Original commit message from CVS:
* ext/alsa/gstalsa.c: (gst_alsa_class_init), (gst_alsa_dispose),
(gst_alsa_finalize):
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_class_init),
(gst_cdaudio_finalize):
* ext/cdparanoia/gstcdparanoia.c: (cdparanoia_class_init),
(cdparanoia_finalize):
* ext/divx/gstdivxdec.c: (gst_divxdec_dispose):
* ext/divx/gstdivxenc.c: (gst_divxenc_dispose):
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_finalize):
* ext/flac/gstflacdec.c: (gst_flacdec_class_init),
(gst_flacdec_finalize):
* ext/flac/gstflacenc.c: (gst_flacenc_class_init),
(gst_flacenc_finalize):
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_class_init),
(gst_gnomevfssink_finalize):
* ext/gnomevfs/gstgnomevfssrc.c: (gst_gnomevfssrc_class_init),
(gst_gnomevfssrc_finalize):
* ext/libfame/gstlibfame.c: (gst_fameenc_class_init),
(gst_fameenc_finalize):
* ext/nas/nassink.c: (gst_nassink_class_init),
(gst_nassink_finalize):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_finalize),
(gst_sdlvideosink_class_init):
* ext/sndfile/gstsf.c: (gst_sf_dispose):
* gst-libs/gst/mixer/mixertrack.c: (gst_mixer_track_dispose):
* gst-libs/gst/tuner/tunerchannel.c: (gst_tuner_channel_dispose):
* gst-libs/gst/tuner/tunernorm.c: (gst_tuner_norm_dispose):
* gst-libs/gst/xwindowlistener/xwindowlistener.c:
(gst_x_window_listener_dispose):
* gst/audioscale/gstaudioscale.c:
* gst/playondemand/gstplayondemand.c: (play_on_demand_class_init),
(play_on_demand_finalize):
* gst/videofilter/gstvideobalance.c: (gst_videobalance_dispose):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_chain):
* sys/cdrom/gstcdplayer.c: (cdplayer_class_init),
(cdplayer_finalize):
* sys/glsink/glimagesink.c: (gst_glimagesink_finalize),
(gst_glimagesink_class_init):
* sys/oss/gstosselement.c: (gst_osselement_class_init),
(gst_osselement_finalize):
* sys/oss/gstosssink.c: (gst_osssink_dispose):
* sys/oss/gstosssrc.c: (gst_osssrc_dispose):
* sys/v4l/gstv4lelement.c: (gst_v4lelement_dispose):
Fixes a bunch of problems with finalize and dispose functions,
either assumptions that dispose is only called once, or not calling
the parent class dispose/finalize function
2004-11-01 14:43:38 +00:00
|
|
|
play_on_demand_finalize (GObject * object)
|
2003-06-16 22:20:52 +00:00
|
|
|
{
|
|
|
|
GstPlayOnDemand *filter = GST_PLAYONDEMAND (object);
|
|
|
|
|
|
|
|
g_free (filter->ticks);
|
|
|
|
g_free (filter->plays);
|
|
|
|
g_free (filter->buffer);
|
Fixes a bunch of problems with finalize and dispose functions, either assumptions that dispose is only called once, o...
Original commit message from CVS:
* ext/alsa/gstalsa.c: (gst_alsa_class_init), (gst_alsa_dispose),
(gst_alsa_finalize):
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_class_init),
(gst_cdaudio_finalize):
* ext/cdparanoia/gstcdparanoia.c: (cdparanoia_class_init),
(cdparanoia_finalize):
* ext/divx/gstdivxdec.c: (gst_divxdec_dispose):
* ext/divx/gstdivxenc.c: (gst_divxenc_dispose):
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_finalize):
* ext/flac/gstflacdec.c: (gst_flacdec_class_init),
(gst_flacdec_finalize):
* ext/flac/gstflacenc.c: (gst_flacenc_class_init),
(gst_flacenc_finalize):
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_class_init),
(gst_gnomevfssink_finalize):
* ext/gnomevfs/gstgnomevfssrc.c: (gst_gnomevfssrc_class_init),
(gst_gnomevfssrc_finalize):
* ext/libfame/gstlibfame.c: (gst_fameenc_class_init),
(gst_fameenc_finalize):
* ext/nas/nassink.c: (gst_nassink_class_init),
(gst_nassink_finalize):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_finalize),
(gst_sdlvideosink_class_init):
* ext/sndfile/gstsf.c: (gst_sf_dispose):
* gst-libs/gst/mixer/mixertrack.c: (gst_mixer_track_dispose):
* gst-libs/gst/tuner/tunerchannel.c: (gst_tuner_channel_dispose):
* gst-libs/gst/tuner/tunernorm.c: (gst_tuner_norm_dispose):
* gst-libs/gst/xwindowlistener/xwindowlistener.c:
(gst_x_window_listener_dispose):
* gst/audioscale/gstaudioscale.c:
* gst/playondemand/gstplayondemand.c: (play_on_demand_class_init),
(play_on_demand_finalize):
* gst/videofilter/gstvideobalance.c: (gst_videobalance_dispose):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_chain):
* sys/cdrom/gstcdplayer.c: (cdplayer_class_init),
(cdplayer_finalize):
* sys/glsink/glimagesink.c: (gst_glimagesink_finalize),
(gst_glimagesink_class_init):
* sys/oss/gstosselement.c: (gst_osselement_class_init),
(gst_osselement_finalize):
* sys/oss/gstosssink.c: (gst_osssink_dispose):
* sys/oss/gstosssrc.c: (gst_osssrc_dispose):
* sys/v4l/gstv4lelement.c: (gst_v4lelement_dispose):
Fixes a bunch of problems with finalize and dispose functions,
either assumptions that dispose is only called once, or not calling
the parent class dispose/finalize function
2004-11-01 14:43:38 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2003-06-16 22:20:52 +00:00
|
|
|
}
|
|
|
|
|
2003-01-17 14:04:39 +00:00
|
|
|
static GstPadLinkReturn
|
2004-03-14 22:34:33 +00:00
|
|
|
play_on_demand_pad_link (GstPad * pad, const GstCaps * caps)
|
2003-01-17 14:04:39 +00:00
|
|
|
{
|
2003-07-06 20:49:52 +00:00
|
|
|
const gchar *mimetype;
|
2003-01-17 14:04:39 +00:00
|
|
|
GstPlayOnDemand *filter;
|
2003-12-22 01:47:09 +00:00
|
|
|
GstStructure *structure;
|
2003-01-17 14:04:39 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_val_if_fail (caps != NULL, GST_PAD_LINK_DELAYED);
|
|
|
|
g_return_val_if_fail (pad != NULL, GST_PAD_LINK_DELAYED);
|
2003-01-17 14:04:39 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
filter = GST_PLAYONDEMAND (GST_PAD_PARENT (pad));
|
2003-01-17 14:04:39 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
|
|
|
|
|
|
|
mimetype = gst_structure_get_name (structure);
|
|
|
|
gst_structure_get_int (structure, "rate", &filter->rate);
|
|
|
|
gst_structure_get_int (structure, "channels", &filter->channels);
|
2003-01-17 14:04:39 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (strcmp (mimetype, "audio/x-raw-int") == 0) {
|
2003-01-17 14:04:39 +00:00
|
|
|
filter->format = GST_PLAYONDEMAND_FORMAT_INT;
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_structure_get_int (structure, "width", &filter->width);
|
|
|
|
} else if (strcmp (mimetype, "audio/x-raw-float") == 0) {
|
2003-01-17 14:04:39 +00:00
|
|
|
filter->format = GST_PLAYONDEMAND_FORMAT_FLOAT;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
play_on_demand_resize_buffer (filter);
|
2003-01-17 14:04:39 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
return gst_pad_try_set_caps (filter->srcpad, caps);
|
2003-01-17 14:04:39 +00:00
|
|
|
}
|
|
|
|
|
2003-06-16 22:20:52 +00:00
|
|
|
inline static void
|
2004-03-14 22:34:33 +00:00
|
|
|
play_on_demand_add_play_pointer (GstPlayOnDemand * filter, guint pos)
|
2003-06-16 22:20:52 +00:00
|
|
|
{
|
|
|
|
register guint i;
|
|
|
|
|
|
|
|
if (filter->rate && ((filter->buffer_time * filter->rate) > pos)) {
|
|
|
|
for (i = 0; i < filter->max_plays; i++) {
|
|
|
|
if (filter->plays[i] == G_MAXUINT) {
|
2004-03-15 19:32:27 +00:00
|
|
|
filter->plays[i] = pos;
|
|
|
|
/* emit a signal to indicate a sample being played */
|
|
|
|
g_signal_emit (filter, gst_pod_filter_signals[PLAYED_SIGNAL], 0);
|
|
|
|
break;
|
2003-06-16 22:20:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-01-17 14:04:39 +00:00
|
|
|
|
2001-12-22 23:26:33 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
play_on_demand_loop (GstElement * elem)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
GstPlayOnDemand *filter = GST_PLAYONDEMAND (elem);
|
|
|
|
guint num_in, num_out, num_filter;
|
|
|
|
GstData *in = NULL;
|
|
|
|
GstBuffer *out = NULL;
|
|
|
|
static guint last_tick = 0;
|
2003-01-17 14:04:39 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (filter != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PLAYONDEMAND (filter));
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
in = (in == NULL && !filter->eos) ? gst_pad_pull (filter->sinkpad) : NULL;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
if (filter->format == GST_PLAYONDEMAND_FORMAT_INT) {
|
|
|
|
if (filter->width == 16) {
|
2003-06-16 22:20:52 +00:00
|
|
|
gint16 min = 0xffff;
|
|
|
|
gint16 max = 0x7fff;
|
2001-12-22 23:26:33 +00:00
|
|
|
gint16 zero = 0;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2001-12-22 23:26:33 +00:00
|
|
|
#define _TYPE_ gint16
|
|
|
|
#include "filter.func"
|
|
|
|
#undef _TYPE_
|
|
|
|
} else if (filter->width == 8) {
|
2003-06-16 22:20:52 +00:00
|
|
|
gint8 min = 0xff;
|
|
|
|
gint8 max = 0x7f;
|
2001-12-22 23:26:33 +00:00
|
|
|
gint8 zero = 0;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2001-12-22 23:26:33 +00:00
|
|
|
#define _TYPE_ gint8
|
|
|
|
#include "filter.func"
|
|
|
|
#undef _TYPE_
|
|
|
|
}
|
|
|
|
} else if (filter->format == GST_PLAYONDEMAND_FORMAT_FLOAT) {
|
|
|
|
gfloat min = -1.0;
|
|
|
|
gfloat max = 1.0;
|
|
|
|
gfloat zero = 0.0;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2001-12-22 23:26:33 +00:00
|
|
|
#define _TYPE_ gfloat
|
|
|
|
#include "filter.func"
|
|
|
|
#undef _TYPE_
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
play_on_demand_set_clock (GstElement * elem, GstClock * clock)
|
2002-10-17 20:05:58 +00:00
|
|
|
{
|
|
|
|
GstPlayOnDemand *filter;
|
2003-01-17 14:04:39 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (elem != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PLAYONDEMAND (elem));
|
|
|
|
filter = GST_PLAYONDEMAND (elem);
|
2002-10-17 20:05:58 +00:00
|
|
|
|
|
|
|
filter->clock = clock;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
play_on_demand_play_handler (GstElement * elem)
|
2002-10-17 20:05:58 +00:00
|
|
|
{
|
|
|
|
GstPlayOnDemand *filter;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (elem != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PLAYONDEMAND (elem));
|
|
|
|
filter = GST_PLAYONDEMAND (elem);
|
2002-10-17 20:05:58 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
play_on_demand_add_play_pointer (filter, 0);
|
2002-10-17 20:05:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
play_on_demand_clear_handler (GstElement * elem)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
2003-01-17 14:04:39 +00:00
|
|
|
GstPlayOnDemand *filter;
|
2003-06-16 22:20:52 +00:00
|
|
|
register guint i;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (elem != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PLAYONDEMAND (elem));
|
|
|
|
filter = GST_PLAYONDEMAND (elem);
|
2003-01-17 14:04:39 +00:00
|
|
|
|
|
|
|
filter->write = 0;
|
|
|
|
filter->eos = FALSE;
|
2003-06-16 22:20:52 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
for (i = 0; i < filter->max_plays; i++)
|
|
|
|
filter->plays[i] = G_MAXUINT;
|
|
|
|
for (i = 0; i < filter->buffer_bytes; i++)
|
|
|
|
filter->buffer[i] = (gchar) 0;
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
play_on_demand_reset_handler (GstElement * elem)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
2002-10-17 20:05:58 +00:00
|
|
|
GstPlayOnDemand *filter;
|
2001-12-22 23:26:33 +00:00
|
|
|
register guint i;
|
2002-10-17 20:05:58 +00:00
|
|
|
|
2003-06-16 22:20:52 +00:00
|
|
|
play_on_demand_clear_handler (elem);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (elem != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PLAYONDEMAND (elem));
|
|
|
|
filter = GST_PLAYONDEMAND (elem);
|
2002-10-17 20:05:58 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
for (i = 0; i <= filter->total_ticks / 32; i++)
|
|
|
|
filter->ticks[i] = 0;
|
2002-10-17 20:05:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
play_on_demand_resize_buffer (GstPlayOnDemand * filter)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
register guint i;
|
|
|
|
guint new_size, min_size;
|
|
|
|
gchar *new_buffer;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2003-01-17 14:04:39 +00:00
|
|
|
/* use a default sample rate of 44100, 1 channel, 1 byte per sample if caps
|
|
|
|
haven't been set yet */
|
2004-03-14 22:34:33 +00:00
|
|
|
new_size = (guint) filter->buffer_time;
|
2003-01-17 14:04:39 +00:00
|
|
|
new_size *= (filter->rate) ? filter->rate : 44100;
|
|
|
|
new_size *= (filter->channels) ? filter->channels : 1;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2003-01-17 14:04:39 +00:00
|
|
|
if (filter->format && filter->format == GST_PLAYONDEMAND_FORMAT_FLOAT)
|
2004-03-14 22:34:33 +00:00
|
|
|
new_size *= sizeof (gfloat);
|
2003-01-17 14:04:39 +00:00
|
|
|
else
|
|
|
|
new_size *= (filter->width) ? filter->width / 8 : 1;
|
2002-10-17 20:05:58 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
min_size =
|
|
|
|
(new_size < filter->buffer_bytes) ? new_size : filter->buffer_bytes;
|
2002-10-17 20:05:58 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
new_buffer = g_new (gchar, new_size);
|
|
|
|
for (i = 0; i < min_size; i++)
|
|
|
|
new_buffer[i] = filter->buffer[i];
|
|
|
|
for (i = min_size; i < new_size; i++)
|
|
|
|
new_buffer[i] = (gchar) 0;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_free (filter->buffer);
|
2003-01-17 14:04:39 +00:00
|
|
|
filter->buffer = new_buffer;
|
|
|
|
filter->buffer_bytes = new_size;
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
return gst_element_register (plugin, "playondemand",
|
|
|
|
GST_RANK_NONE, GST_TYPE_PLAYONDEMAND);
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"playondemand",
|
|
|
|
"Plays a stream at specific times, or when it receives a signal",
|
2006-04-01 10:09:11 +00:00
|
|
|
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
|