2000-08-18 20:35:48 +00:00
|
|
|
#include <config.h>
|
2000-06-25 21:38:00 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
#include <string.h>
|
2001-12-13 23:14:39 +00:00
|
|
|
#include <gtk/gtkobject.h>
|
|
|
|
#include <gtk/gtksignal.h>
|
|
|
|
#include <gtk/gtksocket.h>
|
|
|
|
#include <gtk/gtkmain.h>
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
#include "gstplay.h"
|
2000-07-12 22:52:42 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
static void gst_play_class_init (GstPlayClass *klass);
|
|
|
|
static void gst_play_init (GstPlay *play);
|
2000-07-12 22:52:42 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
static void gst_play_set_arg (GtkObject *object, GtkArg *arg, guint id);
|
|
|
|
static void gst_play_get_arg (GtkObject *object, GtkArg *arg, guint id);
|
2000-06-25 21:38:00 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
static void gst_play_realize (GtkWidget *play);
|
2000-07-05 10:21:08 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
static void gst_play_frame_displayed (GstElement *element, GstPlay *play);
|
|
|
|
static void gst_play_have_size (GstElement *element, guint width, guint height, GstPlay *play);
|
|
|
|
static void gst_play_audio_handoff (GstElement *element, GstPlay *play);
|
2000-07-05 10:21:08 +00:00
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
/* signals and args */
|
|
|
|
enum {
|
2001-05-21 01:19:06 +00:00
|
|
|
SIGNAL_STATE_CHANGED,
|
|
|
|
SIGNAL_FRAME_DISPLAYED,
|
|
|
|
SIGNAL_AUDIO_PLAYED,
|
|
|
|
LAST_SIGNAL
|
2000-10-30 21:02:08 +00:00
|
|
|
};
|
2000-07-05 10:21:08 +00:00
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
enum {
|
2001-05-21 01:19:06 +00:00
|
|
|
ARG_0,
|
|
|
|
ARG_URI,
|
|
|
|
ARG_MUTE,
|
|
|
|
ARG_STATE,
|
|
|
|
ARG_MEDIA_SIZE,
|
|
|
|
ARG_MEDIA_OFFSET,
|
|
|
|
ARG_MEDIA_TOTAL_TIME,
|
|
|
|
ARG_MEDIA_CURRENT_TIME,
|
2000-10-30 21:02:08 +00:00
|
|
|
};
|
2000-07-05 10:21:08 +00:00
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
static GtkObject *parent_class = NULL;
|
2001-05-21 01:19:06 +00:00
|
|
|
static guint gst_play_signals[LAST_SIGNAL] = {0};
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
struct _GstPlayPrivate {
|
|
|
|
GstElement *pipeline;
|
|
|
|
GstElement *video_element, *audio_element;
|
|
|
|
GstElement *video_show;
|
|
|
|
GtkWidget *video_widget;
|
|
|
|
GstElement *src;
|
|
|
|
GstElement *cache;
|
|
|
|
GstElement *typefind;
|
|
|
|
|
|
|
|
guchar *uri;
|
|
|
|
gboolean muted;
|
|
|
|
gboolean can_seek;
|
|
|
|
|
|
|
|
GstElement *offset_element;
|
|
|
|
GstElement *bit_rate_element;
|
|
|
|
GstElement *media_time_element;
|
|
|
|
GstElement *current_time_element;
|
|
|
|
|
|
|
|
guint source_width;
|
|
|
|
guint source_height;
|
|
|
|
};
|
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
GtkType
|
|
|
|
gst_play_get_type (void)
|
2000-10-30 21:02:08 +00:00
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
static GtkType play_type = 0;
|
|
|
|
|
|
|
|
if (!play_type) {
|
|
|
|
static const GtkTypeInfo play_info = {
|
|
|
|
"GstPlay",
|
|
|
|
sizeof (GstPlay),
|
|
|
|
sizeof (GstPlayClass),
|
|
|
|
(GtkClassInitFunc) gst_play_class_init,
|
|
|
|
(GtkObjectInitFunc) gst_play_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(GtkClassInitFunc)NULL,
|
|
|
|
};
|
|
|
|
play_type = gtk_type_unique (gtk_hbox_get_type (), &play_info);
|
|
|
|
}
|
|
|
|
return play_type;
|
2000-06-25 21:38:00 +00:00
|
|
|
}
|
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
static void
|
|
|
|
gst_play_class_init (GstPlayClass *klass)
|
2000-10-30 21:02:08 +00:00
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
GtkObjectClass *object_class;
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
|
|
|
|
parent_class = gtk_type_class (gtk_hbox_get_type ());
|
|
|
|
|
|
|
|
object_class = (GtkObjectClass*)klass;
|
|
|
|
widget_class = (GtkWidgetClass*)klass;
|
|
|
|
|
|
|
|
gst_play_signals[SIGNAL_STATE_CHANGED] =
|
2001-12-13 23:14:39 +00:00
|
|
|
gtk_signal_new ("playing_state_changed", GTK_RUN_FIRST,
|
|
|
|
G_TYPE_FROM_CLASS (object_class),
|
2001-05-21 01:19:06 +00:00
|
|
|
GTK_SIGNAL_OFFSET (GstPlayClass, state_changed),
|
|
|
|
gtk_marshal_NONE__INT, GTK_TYPE_NONE, 1,
|
|
|
|
GTK_TYPE_INT);
|
|
|
|
|
|
|
|
gst_play_signals[SIGNAL_FRAME_DISPLAYED] =
|
2001-12-13 23:14:39 +00:00
|
|
|
gtk_signal_new ("frame_displayed",GTK_RUN_FIRST, G_TYPE_FROM_CLASS (object_class),
|
2001-05-21 01:19:06 +00:00
|
|
|
GTK_SIGNAL_OFFSET (GstPlayClass, frame_displayed),
|
|
|
|
gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0);
|
|
|
|
|
|
|
|
gst_play_signals[SIGNAL_AUDIO_PLAYED] =
|
2001-12-13 23:14:39 +00:00
|
|
|
gtk_signal_new ("audio_played",GTK_RUN_FIRST, G_TYPE_FROM_CLASS (object_class),
|
2001-05-21 01:19:06 +00:00
|
|
|
GTK_SIGNAL_OFFSET (GstPlayClass, audio_played),
|
|
|
|
gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0);
|
|
|
|
|
2001-12-13 23:14:39 +00:00
|
|
|
#ifndef USE_GLIB2
|
2001-05-21 01:19:06 +00:00
|
|
|
gtk_object_class_add_signals (object_class, gst_play_signals, LAST_SIGNAL);
|
2001-12-13 23:14:39 +00:00
|
|
|
#endif
|
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
gtk_object_add_arg_type ("GstPlay::uri", GTK_TYPE_STRING,
|
|
|
|
GTK_ARG_READABLE, ARG_URI);
|
|
|
|
gtk_object_add_arg_type ("GstPlay::mute", GTK_TYPE_BOOL,
|
|
|
|
GTK_ARG_READWRITE, ARG_MUTE);
|
|
|
|
gtk_object_add_arg_type ("GstPlay::state", GTK_TYPE_INT,
|
|
|
|
GTK_ARG_READABLE, ARG_STATE);
|
2001-12-13 23:14:39 +00:00
|
|
|
#ifdef USE_GLIB2
|
|
|
|
gtk_object_add_arg_type ("GstPlay::media_size", GTK_TYPE_UINT,
|
|
|
|
GTK_ARG_READABLE, ARG_MEDIA_SIZE);
|
|
|
|
gtk_object_add_arg_type ("GstPlay::media_offset", GTK_TYPE_UINT,
|
|
|
|
GTK_ARG_READABLE, ARG_MEDIA_OFFSET);
|
|
|
|
gtk_object_add_arg_type ("GstPlay::media_total_time", GTK_TYPE_UINT,
|
|
|
|
GTK_ARG_READABLE, ARG_MEDIA_TOTAL_TIME);
|
|
|
|
gtk_object_add_arg_type ("GstPlay::media_current_time", GTK_TYPE_UINT,
|
|
|
|
GTK_ARG_READABLE, ARG_MEDIA_CURRENT_TIME);
|
|
|
|
#else
|
2001-05-21 01:19:06 +00:00
|
|
|
gtk_object_add_arg_type ("GstPlay::media_size", GTK_TYPE_ULONG,
|
|
|
|
GTK_ARG_READABLE, ARG_MEDIA_SIZE);
|
|
|
|
gtk_object_add_arg_type ("GstPlay::media_offset", GTK_TYPE_ULONG,
|
|
|
|
GTK_ARG_READABLE, ARG_MEDIA_OFFSET);
|
|
|
|
gtk_object_add_arg_type ("GstPlay::media_total_time", GTK_TYPE_ULONG,
|
|
|
|
GTK_ARG_READABLE, ARG_MEDIA_TOTAL_TIME);
|
|
|
|
gtk_object_add_arg_type ("GstPlay::media_current_time", GTK_TYPE_ULONG,
|
|
|
|
GTK_ARG_READABLE, ARG_MEDIA_CURRENT_TIME);
|
2001-12-13 23:14:39 +00:00
|
|
|
#endif
|
2001-05-21 01:19:06 +00:00
|
|
|
|
|
|
|
object_class->set_arg = gst_play_set_arg;
|
|
|
|
object_class->get_arg = gst_play_get_arg;
|
|
|
|
|
|
|
|
widget_class->realize = gst_play_realize;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2000-07-05 10:21:08 +00:00
|
|
|
}
|
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
static void
|
|
|
|
gst_play_init (GstPlay *play)
|
2000-08-14 10:16:23 +00:00
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
GstPlayPrivate *priv = g_new0 (GstPlayPrivate, 1);
|
|
|
|
GstElement *colorspace;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
play->priv = priv;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
/* create a new bin to hold the elements */
|
2001-05-25 21:00:07 +00:00
|
|
|
priv->pipeline = gst_pipeline_new ("main_pipeline");
|
|
|
|
g_assert (priv->pipeline != NULL);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
priv->audio_element = gst_elementfactory_make ("osssink", "play_audio");
|
|
|
|
g_return_if_fail (priv->audio_element != NULL);
|
2001-12-13 23:14:39 +00:00
|
|
|
g_signal_connect (G_OBJECT (priv->audio_element), "handoff",
|
|
|
|
G_CALLBACK (gst_play_audio_handoff), play);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
priv->video_element = gst_elementfactory_make ("bin", "video_bin");
|
2001-04-12 18:11:19 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
priv->video_show = gst_elementfactory_make ("xvideosink", "show");
|
2001-12-31 02:40:03 +00:00
|
|
|
g_object_set (G_OBJECT (priv->video_show), "toplevel", FALSE, NULL);
|
2001-05-21 01:19:06 +00:00
|
|
|
g_return_if_fail (priv->video_show != NULL);
|
2001-12-14 21:09:18 +00:00
|
|
|
/* gtk_object_set (GTK_OBJECT (priv->video_element), "xv_enabled", FALSE, NULL); */
|
2001-12-13 23:14:39 +00:00
|
|
|
g_signal_connect (G_OBJECT (priv->video_show), "frame_displayed",
|
|
|
|
G_CALLBACK (gst_play_frame_displayed), play);
|
|
|
|
g_signal_connect (G_OBJECT (priv->video_show), "have_size",
|
|
|
|
G_CALLBACK (gst_play_have_size), play);
|
2001-05-21 01:19:06 +00:00
|
|
|
|
|
|
|
gst_bin_add (GST_BIN (priv->video_element), priv->video_show);
|
|
|
|
|
2001-06-01 17:42:15 +00:00
|
|
|
colorspace = gst_elementfactory_make ("colorspace", "colorspace");
|
|
|
|
if (colorspace == NULL) {
|
2001-06-03 12:08:05 +00:00
|
|
|
g_warning ("could not create the 'colorspace' element, doing without");
|
2001-06-01 17:42:15 +00:00
|
|
|
gst_element_add_ghost_pad (priv->video_element,
|
|
|
|
gst_element_get_pad (priv->video_show, "sink"),
|
|
|
|
"sink");
|
|
|
|
}
|
|
|
|
else {
|
2001-12-24 01:04:08 +00:00
|
|
|
//GST_FLAG_SET (priv->video_element, GST_ELEMENT_THREAD_SUGGESTED);
|
2001-06-01 17:42:15 +00:00
|
|
|
gst_bin_add (GST_BIN (priv->video_element), colorspace);
|
|
|
|
gst_element_connect (colorspace, "src", priv->video_show, "sink");
|
|
|
|
gst_element_add_ghost_pad (priv->video_element,
|
2001-05-21 01:19:06 +00:00
|
|
|
gst_element_get_pad (colorspace, "sink"),
|
|
|
|
"sink");
|
2001-06-01 17:42:15 +00:00
|
|
|
}
|
2001-05-21 01:19:06 +00:00
|
|
|
|
|
|
|
play->state = GST_PLAY_STOPPED;
|
|
|
|
play->flags = 0;
|
|
|
|
|
|
|
|
priv->src = NULL;
|
|
|
|
priv->muted = FALSE;
|
|
|
|
priv->can_seek = TRUE;
|
|
|
|
priv->uri = NULL;
|
|
|
|
priv->offset_element = NULL;
|
|
|
|
priv->bit_rate_element = NULL;
|
|
|
|
priv->media_time_element = NULL;
|
2001-12-14 15:07:24 +00:00
|
|
|
priv->current_time_element = NULL;
|
2001-06-13 01:18:12 +00:00
|
|
|
|
2001-08-15 22:43:09 +00:00
|
|
|
priv->source_width = 0;
|
|
|
|
priv->source_height = 0;
|
2000-08-14 10:16:23 +00:00
|
|
|
}
|
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
GstPlay *
|
2001-03-07 21:52:56 +00:00
|
|
|
gst_play_new ()
|
2000-08-14 10:16:23 +00:00
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
return GST_PLAY (gtk_type_new (GST_TYPE_PLAY));
|
2000-08-14 10:16:23 +00:00
|
|
|
}
|
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
static gboolean
|
|
|
|
gst_play_idle_func (gpointer data)
|
|
|
|
{
|
2001-12-04 22:12:50 +00:00
|
|
|
gboolean busy;
|
|
|
|
|
|
|
|
busy = gst_bin_iterate (GST_BIN (data));
|
|
|
|
|
|
|
|
return busy;
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
static void
|
|
|
|
gst_play_eos (GstElement *element,
|
|
|
|
GstPlay *play)
|
2000-07-13 19:49:50 +00:00
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
GST_DEBUG(0, "gstplay: eos reached\n");
|
|
|
|
gst_play_stop (play);
|
2000-07-13 19:49:50 +00:00
|
|
|
}
|
|
|
|
|
2001-04-12 18:11:19 +00:00
|
|
|
static void
|
|
|
|
gst_play_have_size (GstElement *element, guint width, guint height,
|
|
|
|
GstPlay *play)
|
|
|
|
{
|
2001-12-14 18:11:52 +00:00
|
|
|
play->priv->source_width = width;
|
|
|
|
play->priv->source_height = height;
|
2001-05-21 01:19:06 +00:00
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
gtk_widget_set_usize (play->priv->video_widget, width, height);
|
2001-04-12 18:11:19 +00:00
|
|
|
}
|
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
static void
|
2001-05-21 01:19:06 +00:00
|
|
|
gst_play_frame_displayed (GstElement *element, GstPlay *play)
|
2000-07-13 19:49:50 +00:00
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
static int stolen = FALSE;
|
|
|
|
|
|
|
|
gdk_threads_enter ();
|
|
|
|
if (!stolen) {
|
2001-12-14 18:11:52 +00:00
|
|
|
gtk_widget_realize (play->priv->video_widget);
|
|
|
|
gtk_socket_steal (GTK_SOCKET (play->priv->video_widget),
|
|
|
|
gst_util_get_int_arg (
|
|
|
|
G_OBJECT (play->priv->video_show), "xid"));
|
|
|
|
gtk_widget_show (play->priv->video_widget);
|
2001-05-21 01:19:06 +00:00
|
|
|
stolen = TRUE;
|
|
|
|
}
|
|
|
|
gdk_threads_leave ();
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (play), gst_play_signals[SIGNAL_FRAME_DISPLAYED],
|
|
|
|
NULL);
|
2000-07-13 19:49:50 +00:00
|
|
|
}
|
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
static void
|
2001-05-21 01:19:06 +00:00
|
|
|
gst_play_audio_handoff (GstElement *element, GstPlay *play)
|
2000-07-12 22:52:42 +00:00
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
gtk_signal_emit (GTK_OBJECT (play), gst_play_signals[SIGNAL_AUDIO_PLAYED],
|
|
|
|
NULL);
|
2000-08-14 10:16:23 +00:00
|
|
|
}
|
2000-07-12 22:52:42 +00:00
|
|
|
|
2001-12-13 23:14:39 +00:00
|
|
|
#ifdef USE_GLIB2
|
|
|
|
static void
|
|
|
|
gst_play_object_introspect (GstObject *object, const gchar *property, GstElement **target)
|
|
|
|
{
|
|
|
|
GParamSpec *pspec;
|
|
|
|
GstElement *element;
|
|
|
|
|
|
|
|
if (!GST_IS_ELEMENT (object) && !GST_IS_BIN (object))
|
|
|
|
return;
|
|
|
|
|
|
|
|
element = GST_ELEMENT (object);
|
|
|
|
|
|
|
|
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (element), property);
|
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
if (pspec) {
|
2001-12-13 23:14:39 +00:00
|
|
|
*target = element;
|
|
|
|
GST_DEBUG(0, "gstplay: using element \"%s\" for %s property\n",
|
|
|
|
gst_element_get_name(element), property);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2001-03-07 21:52:56 +00:00
|
|
|
static void
|
2001-05-21 01:19:06 +00:00
|
|
|
gst_play_object_introspect (GstObject *object, const gchar *property, GstElement **target)
|
2000-11-01 13:49:41 +00:00
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
gchar *info;
|
|
|
|
GtkArgInfo *arg;
|
|
|
|
GstElement *element;
|
2000-11-01 13:49:41 +00:00
|
|
|
|
2001-06-03 12:08:05 +00:00
|
|
|
if (!GST_IS_ELEMENT (object) && !GST_IS_BIN (object))
|
2001-05-21 01:19:06 +00:00
|
|
|
return;
|
2001-03-07 21:52:56 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
element = GST_ELEMENT (object);
|
2001-03-07 21:52:56 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
info = gtk_object_arg_get_info (GTK_OBJECT_TYPE (element), property, &arg);
|
2000-11-01 13:49:41 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
if (info) {
|
|
|
|
g_free(info);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*target = element;
|
2001-08-15 22:32:30 +00:00
|
|
|
GST_DEBUG(0, "gstplay: using element \"%s\" for %s property\n",
|
2001-05-21 01:19:06 +00:00
|
|
|
gst_element_get_name(element), property);
|
|
|
|
}
|
2000-11-01 13:49:41 +00:00
|
|
|
}
|
2001-12-13 23:14:39 +00:00
|
|
|
#endif
|
2000-11-01 13:49:41 +00:00
|
|
|
|
|
|
|
/* Dumb introspection of the interface...
|
2001-03-07 21:52:56 +00:00
|
|
|
* this will change with glib 1.4
|
2000-11-01 13:49:41 +00:00
|
|
|
* */
|
2001-03-07 21:52:56 +00:00
|
|
|
static void
|
2001-05-21 01:19:06 +00:00
|
|
|
gst_play_object_added (GstAutoplug* autoplug, GstObject *object, GstPlay *play)
|
2000-11-01 13:49:41 +00:00
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
g_return_if_fail (play != NULL);
|
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
if (GST_FLAG_IS_SET (object, GST_ELEMENT_NO_SEEK))
|
|
|
|
play->priv->can_seek = FALSE;
|
2001-05-21 01:19:06 +00:00
|
|
|
|
2001-12-14 21:09:18 +00:00
|
|
|
/* first come first serve here... */
|
2001-12-14 18:11:52 +00:00
|
|
|
if (!play->priv->offset_element)
|
|
|
|
gst_play_object_introspect (object, "offset",
|
|
|
|
&play->priv->offset_element);
|
|
|
|
if (!play->priv->bit_rate_element)
|
|
|
|
gst_play_object_introspect (object, "bit_rate",
|
|
|
|
&play->priv->bit_rate_element);
|
|
|
|
if (!play->priv->media_time_element)
|
|
|
|
gst_play_object_introspect (object, "media_time",
|
|
|
|
&play->priv->media_time_element);
|
|
|
|
if (!play->priv->current_time_element)
|
|
|
|
gst_play_object_introspect (object, "current_time",
|
|
|
|
&play->priv->current_time_element);
|
2001-06-03 12:08:05 +00:00
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_play_cache_empty (GstElement *element, GstPlay *play)
|
2001-03-07 21:52:56 +00:00
|
|
|
{
|
2001-12-14 18:11:52 +00:00
|
|
|
GstPlayPrivate *priv = play->priv;
|
2001-05-25 21:00:07 +00:00
|
|
|
GstElement *new_element;
|
|
|
|
|
|
|
|
gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
|
|
|
|
|
|
|
|
new_element = gst_bin_get_by_name (GST_BIN (priv->pipeline), "new_element");
|
|
|
|
|
|
|
|
gst_element_disconnect (priv->src, "src", priv->cache, "sink");
|
|
|
|
gst_element_disconnect (priv->cache, "src", new_element, "sink");
|
|
|
|
gst_bin_remove (GST_BIN (priv->pipeline), priv->cache);
|
|
|
|
gst_element_connect (priv->src, "src", new_element, "sink");
|
2001-03-07 21:52:56 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
|
2001-03-07 21:52:56 +00:00
|
|
|
}
|
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
static void
|
|
|
|
gst_play_have_type (GstElement *sink, GstCaps *caps, GstPlay *play)
|
2001-03-07 21:52:56 +00:00
|
|
|
{
|
2001-05-25 21:00:07 +00:00
|
|
|
GstElement *new_element;
|
|
|
|
GstAutoplug *autoplug;
|
2001-12-14 18:11:52 +00:00
|
|
|
GstPlayPrivate *priv = play->priv;
|
2001-03-07 21:52:56 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
GST_DEBUG (0,"GstPipeline: play have type\n");
|
2001-03-07 21:52:56 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
|
2001-03-07 21:52:56 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_element_disconnect (priv->cache, "src", priv->typefind, "sink");
|
|
|
|
gst_bin_remove (GST_BIN (priv->pipeline), priv->typefind);
|
2001-03-07 21:52:56 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
autoplug = gst_autoplugfactory_make ("staticrender");
|
|
|
|
g_assert (autoplug != NULL);
|
|
|
|
|
2001-12-13 23:14:39 +00:00
|
|
|
g_signal_connect (G_OBJECT (autoplug), "new_object",
|
|
|
|
G_CALLBACK (gst_play_object_added), play);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
|
|
|
new_element = gst_autoplug_to_renderers (autoplug,
|
|
|
|
caps,
|
|
|
|
priv->video_element,
|
|
|
|
priv->audio_element,
|
|
|
|
NULL);
|
2001-03-07 21:52:56 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
if (!new_element) {
|
2001-12-14 21:09:18 +00:00
|
|
|
/* FIXME, signal a suitable error */
|
2001-05-25 21:00:07 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-03-07 21:52:56 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_element_set_name (new_element, "new_element");
|
2001-03-07 21:52:56 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_bin_add (GST_BIN (priv->pipeline), new_element);
|
2001-03-07 21:52:56 +00:00
|
|
|
|
2001-12-13 23:14:39 +00:00
|
|
|
g_object_set (G_OBJECT (priv->cache), "reset", TRUE, NULL);
|
2001-03-07 21:52:56 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_element_connect (priv->cache, "src", new_element, "sink");
|
2001-03-07 21:52:56 +00:00
|
|
|
|
2001-12-13 23:14:39 +00:00
|
|
|
g_signal_connect (G_OBJECT (priv->pipeline), "eos", G_CALLBACK (gst_play_eos), play);
|
2001-03-07 21:52:56 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
|
2000-11-01 13:49:41 +00:00
|
|
|
}
|
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
#if 0
|
2001-03-07 21:52:56 +00:00
|
|
|
static gboolean
|
|
|
|
connect_pads (GstElement *new_element, GstElement *target, gboolean add)
|
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
GList *pads = gst_element_get_pad_list (new_element);
|
|
|
|
GstPad *targetpad = gst_element_get_pad (target, "sink");
|
|
|
|
|
|
|
|
while (pads) {
|
|
|
|
GstPad *pad = GST_PAD (pads->data);
|
|
|
|
|
|
|
|
if (gst_pad_check_compatibility (pad, targetpad)) {
|
|
|
|
if (add) {
|
|
|
|
gst_bin_add (GST_BIN (gst_element_get_parent (
|
|
|
|
GST_ELEMENT (gst_pad_get_real_parent (pad)))),
|
|
|
|
target);
|
|
|
|
}
|
|
|
|
gst_pad_connect (pad, targetpad);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
pads = g_list_next (pads);
|
|
|
|
}
|
|
|
|
return FALSE;
|
2001-03-07 21:52:56 +00:00
|
|
|
}
|
2001-12-14 18:11:52 +00:00
|
|
|
#endif
|
2001-03-07 21:52:56 +00:00
|
|
|
|
|
|
|
GstPlayReturn
|
2001-05-21 01:19:06 +00:00
|
|
|
gst_play_set_uri (GstPlay *play, const guchar *uri)
|
2000-10-30 21:02:08 +00:00
|
|
|
{
|
2001-12-13 23:14:39 +00:00
|
|
|
gchar *uriloc;
|
2001-05-21 01:19:06 +00:00
|
|
|
GstPlayPrivate *priv;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
g_return_val_if_fail (play != NULL, GST_PLAY_ERROR);
|
|
|
|
g_return_val_if_fail (GST_IS_PLAY (play), GST_PLAY_ERROR);
|
|
|
|
g_return_val_if_fail (uri != NULL, GST_PLAY_ERROR);
|
2001-08-15 22:32:30 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
priv = (GstPlayPrivate *)play->priv;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
if (priv->uri)
|
|
|
|
g_free (priv->uri);
|
2001-08-15 22:43:09 +00:00
|
|
|
|
2001-06-03 12:08:05 +00:00
|
|
|
/* see if it looks like an URI */
|
2001-05-25 21:00:07 +00:00
|
|
|
if ((uriloc = strstr (uri, ":/"))) {
|
2001-08-15 22:43:09 +00:00
|
|
|
priv->src = gst_elementfactory_make ("gnomevfssrc", "srcelement");
|
|
|
|
|
|
|
|
if (!priv->src) {
|
2001-12-14 18:11:52 +00:00
|
|
|
if (strstr (uri, "file:/"))
|
|
|
|
uri += strlen ("file:/");
|
2001-08-15 22:43:09 +00:00
|
|
|
else
|
|
|
|
return GST_PLAY_CANNOT_PLAY;
|
|
|
|
}
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
2001-08-15 22:43:09 +00:00
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
if (!priv->src)
|
2001-12-14 11:11:54 +00:00
|
|
|
priv->src = gst_elementfactory_make ("filesrc", "srcelement");
|
2001-08-15 22:43:09 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
priv->uri = g_strdup (uri);
|
2001-08-15 22:43:09 +00:00
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
/* priv->src = gst_elementfactory_make ("dvdsrc", "disk_src"); */
|
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
g_return_val_if_fail (priv->src != NULL, GST_PLAY_CANNOT_PLAY);
|
2001-08-15 22:43:09 +00:00
|
|
|
|
2001-12-13 23:14:39 +00:00
|
|
|
g_object_set (G_OBJECT (priv->src), "location", priv->uri, NULL);
|
2001-08-15 22:43:09 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
priv->cache = gst_elementfactory_make ("autoplugcache", "cache");
|
|
|
|
g_return_val_if_fail (priv->cache != NULL, GST_PLAY_CANNOT_PLAY);
|
2001-08-15 22:43:09 +00:00
|
|
|
|
2001-12-13 23:14:39 +00:00
|
|
|
g_signal_connect (G_OBJECT (priv->cache), "cache_empty",
|
|
|
|
G_CALLBACK (gst_play_cache_empty), play);
|
2001-08-15 22:43:09 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
priv->typefind = gst_elementfactory_make ("typefind", "typefind");
|
|
|
|
g_return_val_if_fail (priv->typefind != NULL, GST_PLAY_CANNOT_PLAY);
|
2001-12-13 23:14:39 +00:00
|
|
|
g_signal_connect (G_OBJECT (priv->typefind), "have_type",
|
|
|
|
G_CALLBACK (gst_play_have_type), play);
|
2001-08-15 22:43:09 +00:00
|
|
|
|
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_bin_add (GST_BIN (priv->pipeline), priv->src);
|
|
|
|
gst_bin_add (GST_BIN (priv->pipeline), priv->cache);
|
|
|
|
gst_bin_add (GST_BIN (priv->pipeline), priv->typefind);
|
2001-08-15 22:43:09 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_element_connect (priv->src, "src", priv->cache, "sink");
|
|
|
|
gst_element_connect (priv->cache, "src", priv->typefind, "sink");
|
2001-08-15 22:43:09 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
return GST_PLAY_OK;
|
2000-07-05 10:21:08 +00:00
|
|
|
}
|
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
static void
|
|
|
|
gst_play_realize (GtkWidget *widget)
|
2000-08-14 10:16:23 +00:00
|
|
|
{
|
2001-12-14 18:11:52 +00:00
|
|
|
GstPlay *play = GST_PLAY (widget);
|
2001-03-07 21:52:56 +00:00
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
g_return_if_fail (play != NULL);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-12-14 21:09:18 +00:00
|
|
|
/* g_print ("realize\n"); */
|
2001-04-14 18:56:37 +00:00
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
play->priv->video_widget = gtk_socket_new ();
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (widget), play->priv->video_widget);
|
2001-08-15 22:43:09 +00:00
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
if (GTK_WIDGET_CLASS (parent_class)->realize)
|
2001-05-21 01:19:06 +00:00
|
|
|
GTK_WIDGET_CLASS (parent_class)->realize (widget);
|
2001-04-02 14:21:08 +00:00
|
|
|
|
2001-12-14 21:09:18 +00:00
|
|
|
/* gtk_socket_steal (GTK_SOCKET (priv->video_widget), */
|
|
|
|
/* gst_util_get_int_arg (GTK_OBJECT(priv->video_element), "xid")); */
|
2001-04-02 14:21:08 +00:00
|
|
|
|
2001-12-14 21:09:18 +00:00
|
|
|
/* gtk_widget_realize (priv->video_widget); */
|
|
|
|
/* gtk_socket_steal (GTK_SOCKET (priv->video_widget), */
|
|
|
|
/* gst_util_get_int_arg (GTK_OBJECT(priv->video_element), "xid")); */
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
void
|
|
|
|
gst_play_play (GstPlay *play)
|
2000-10-30 21:02:08 +00:00
|
|
|
{
|
2001-12-14 18:11:52 +00:00
|
|
|
GstPlayPrivate *priv = play->priv;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
g_return_if_fail (play != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PLAY (play));
|
2000-08-14 10:16:23 +00:00
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
if (play->state == GST_PLAY_PLAYING)
|
|
|
|
return;
|
2000-08-14 10:16:23 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
if (play->state == GST_PLAY_STOPPED)
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_element_set_state (GST_ELEMENT (priv->pipeline),GST_STATE_READY);
|
|
|
|
gst_element_set_state (GST_ELEMENT (priv->pipeline),GST_STATE_PLAYING);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
play->state = GST_PLAY_PLAYING;
|
2001-05-25 21:00:07 +00:00
|
|
|
gtk_idle_add (gst_play_idle_func, priv->pipeline);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
gtk_signal_emit (GTK_OBJECT (play), gst_play_signals[SIGNAL_STATE_CHANGED],
|
|
|
|
play->state);
|
2000-08-14 10:16:23 +00:00
|
|
|
}
|
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
void
|
|
|
|
gst_play_pause (GstPlay *play)
|
2000-10-30 21:02:08 +00:00
|
|
|
{
|
2001-12-14 18:11:52 +00:00
|
|
|
GstPlayPrivate *priv = play->priv;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
g_return_if_fail (play != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PLAY (play));
|
2000-08-14 10:16:23 +00:00
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
if (play->state != GST_PLAY_PLAYING)
|
|
|
|
return;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-06-13 01:18:12 +00:00
|
|
|
gst_element_set_state (GST_ELEMENT (priv->pipeline), GST_STATE_PAUSED);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
play->state = GST_PLAY_PAUSED;
|
2001-05-25 21:00:07 +00:00
|
|
|
g_idle_remove_by_data (priv->pipeline);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
gtk_signal_emit (GTK_OBJECT (play), gst_play_signals[SIGNAL_STATE_CHANGED],
|
|
|
|
play->state);
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
void
|
|
|
|
gst_play_stop (GstPlay *play)
|
2000-06-25 21:38:00 +00:00
|
|
|
{
|
2001-12-14 18:11:52 +00:00
|
|
|
GstPlayPrivate *priv = play->priv;
|
2001-05-21 01:19:06 +00:00
|
|
|
|
|
|
|
g_return_if_fail (play != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PLAY (play));
|
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
if (play->state == GST_PLAY_STOPPED)
|
|
|
|
return;
|
2001-06-13 01:18:12 +00:00
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
/* FIXME until state changes are handled properly */
|
2001-06-13 01:18:12 +00:00
|
|
|
gst_element_set_state (GST_ELEMENT (priv->pipeline), GST_STATE_READY);
|
2001-12-14 18:11:52 +00:00
|
|
|
g_object_set (G_OBJECT (priv->src), "offset", 0, NULL);
|
|
|
|
/* gst_element_set_state (GST_ELEMENT (priv->pipeline),GST_STATE_NULL); */
|
2000-08-14 10:16:23 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
play->state = GST_PLAY_STOPPED;
|
2001-05-25 21:00:07 +00:00
|
|
|
g_idle_remove_by_data (priv->pipeline);
|
2000-07-05 10:21:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
gtk_signal_emit (GTK_OBJECT (play), gst_play_signals[SIGNAL_STATE_CHANGED],
|
|
|
|
play->state);
|
|
|
|
}
|
2000-07-12 22:52:42 +00:00
|
|
|
|
2001-06-13 01:18:12 +00:00
|
|
|
GtkWidget *
|
|
|
|
gst_play_get_video_widget (GstPlay *play)
|
2001-05-21 01:19:06 +00:00
|
|
|
{
|
2001-06-13 01:18:12 +00:00
|
|
|
g_return_val_if_fail (GST_IS_PLAY (play), 0);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
return play->priv->video_widget;
|
2001-06-13 01:18:12 +00:00
|
|
|
}
|
2001-05-21 01:19:06 +00:00
|
|
|
|
2001-06-13 01:18:12 +00:00
|
|
|
gint
|
|
|
|
gst_play_get_source_width (GstPlay *play)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_PLAY (play), 0);
|
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
return play->priv->source_width;
|
2001-06-13 01:18:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gst_play_get_source_height (GstPlay *play)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_PLAY (play), 0);
|
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
return play->priv->source_height;
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
gulong
|
|
|
|
gst_play_get_media_size (GstPlay *play)
|
2000-11-01 13:49:41 +00:00
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
g_return_val_if_fail (GST_IS_PLAY (play), 0);
|
2000-11-01 13:49:41 +00:00
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
if (gst_util_has_arg (G_OBJECT (play->priv->src),
|
|
|
|
"filesize", G_TYPE_INT64))
|
|
|
|
return gst_util_get_int64_arg (
|
|
|
|
G_OBJECT (play->priv->src), "filesize");
|
|
|
|
else
|
|
|
|
return 0;
|
2000-11-01 13:49:41 +00:00
|
|
|
}
|
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
gulong
|
2000-11-01 13:49:41 +00:00
|
|
|
gst_play_get_media_offset (GstPlay *play)
|
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
g_return_val_if_fail (GST_IS_PLAY (play), 0);
|
2000-11-01 13:49:41 +00:00
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
if (play->priv->offset_element)
|
|
|
|
return gst_util_get_long_arg (
|
|
|
|
G_OBJECT (play->priv->offset_element), "offset");
|
2001-05-21 01:19:06 +00:00
|
|
|
else
|
|
|
|
return 0;
|
2000-11-01 13:49:41 +00:00
|
|
|
}
|
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
gulong
|
2000-11-01 13:49:41 +00:00
|
|
|
gst_play_get_media_total_time (GstPlay *play)
|
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
gulong total_time, bit_rate;
|
2001-03-07 21:52:56 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
g_return_val_if_fail (play != NULL, 0);
|
|
|
|
g_return_val_if_fail (GST_IS_PLAY (play), 0);
|
2000-11-01 13:49:41 +00:00
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
if (play->priv->media_time_element)
|
|
|
|
return gst_util_get_long_arg (
|
|
|
|
G_OBJECT (play->priv->media_time_element), "media_time");
|
2000-11-06 00:15:51 +00:00
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
if (!play->priv->bit_rate_element)
|
|
|
|
return 0;
|
2000-11-01 13:49:41 +00:00
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
bit_rate = gst_util_get_long_arg (
|
|
|
|
G_OBJECT (play->priv->bit_rate_element), "bit_rate");
|
2000-11-01 13:49:41 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
if (bit_rate)
|
|
|
|
total_time = (gst_play_get_media_size (play) * 8) / bit_rate;
|
|
|
|
else
|
|
|
|
total_time = 0;
|
2000-11-01 13:49:41 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
return total_time;
|
2000-11-01 13:49:41 +00:00
|
|
|
}
|
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
gulong
|
2000-11-01 13:49:41 +00:00
|
|
|
gst_play_get_media_current_time (GstPlay *play)
|
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
gulong current_time, bit_rate;
|
2001-03-07 21:52:56 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
g_return_val_if_fail (GST_IS_PLAY (play), 0);
|
2000-11-01 13:49:41 +00:00
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
if (play->priv->current_time_element) {
|
|
|
|
return gst_util_get_long_arg (
|
|
|
|
G_OBJECT (play->priv->current_time_element),
|
|
|
|
"current_time");
|
2001-05-21 01:19:06 +00:00
|
|
|
}
|
2000-11-06 00:15:51 +00:00
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
if (!play->priv->bit_rate_element)
|
|
|
|
return 0;
|
2000-11-01 13:49:41 +00:00
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
bit_rate = gst_util_get_long_arg (
|
|
|
|
G_OBJECT (play->priv->bit_rate_element), "bit_rate");
|
2000-11-01 13:49:41 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
if (bit_rate)
|
|
|
|
current_time = (gst_play_get_media_offset (play) * 8) / bit_rate;
|
|
|
|
else
|
|
|
|
current_time = 0;
|
2000-11-01 13:49:41 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
return current_time;
|
2000-11-01 13:49:41 +00:00
|
|
|
}
|
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
gboolean
|
2000-11-01 13:49:41 +00:00
|
|
|
gst_play_media_can_seek (GstPlay *play)
|
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
|
2000-11-01 13:49:41 +00:00
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
return play->priv->can_seek;
|
2000-11-01 13:49:41 +00:00
|
|
|
}
|
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
void
|
2001-05-21 01:19:06 +00:00
|
|
|
gst_play_media_seek (GstPlay *play, gulong offset)
|
2000-11-01 13:49:41 +00:00
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
g_return_if_fail (GST_IS_PLAY (play));
|
2000-11-01 13:49:41 +00:00
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
if (play->priv->offset_element)
|
|
|
|
g_object_set (G_OBJECT (play->priv->src),
|
|
|
|
"offset", offset, NULL);
|
2000-11-01 13:49:41 +00:00
|
|
|
}
|
|
|
|
|
2001-05-15 09:04:41 +00:00
|
|
|
GstElement*
|
2001-05-21 01:19:06 +00:00
|
|
|
gst_play_get_pipeline (GstPlay *play)
|
2001-05-15 09:04:41 +00:00
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
g_return_val_if_fail (GST_IS_PLAY (play), NULL);
|
2001-05-15 09:04:41 +00:00
|
|
|
|
2001-12-14 18:11:52 +00:00
|
|
|
return GST_ELEMENT (play->priv->pipeline);
|
2001-05-15 09:04:41 +00:00
|
|
|
}
|
2000-11-01 13:49:41 +00:00
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
static void
|
2001-05-21 01:19:06 +00:00
|
|
|
gst_play_set_arg (GtkObject *object, GtkArg *arg, guint id)
|
2000-10-30 21:02:08 +00:00
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
GstPlay *play;
|
2000-11-01 13:49:41 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
g_return_if_fail (object != NULL);
|
|
|
|
g_return_if_fail (arg != NULL);
|
2000-11-01 13:49:41 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
play = GST_PLAY (object);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
switch (id) {
|
|
|
|
case ARG_MUTE:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_warning ("GstPlay: unknown arg!");
|
|
|
|
break;
|
|
|
|
}
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
static void
|
2001-05-21 01:19:06 +00:00
|
|
|
gst_play_get_arg (GtkObject *object, GtkArg *arg, guint id)
|
2000-10-30 21:02:08 +00:00
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
GstPlay *play;
|
|
|
|
GstPlayPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (object != NULL);
|
|
|
|
g_return_if_fail (arg != NULL);
|
|
|
|
|
|
|
|
play = GST_PLAY (object);
|
2001-12-14 18:11:52 +00:00
|
|
|
priv = play->priv;
|
2001-05-21 01:19:06 +00:00
|
|
|
|
|
|
|
switch (id) {
|
|
|
|
case ARG_URI:
|
|
|
|
GTK_VALUE_STRING (*arg) = priv->uri;
|
|
|
|
break;
|
|
|
|
case ARG_MUTE:
|
|
|
|
GTK_VALUE_BOOL (*arg) = priv->muted;
|
|
|
|
break;
|
|
|
|
case ARG_STATE:
|
|
|
|
GTK_VALUE_INT (*arg) = play->state;
|
|
|
|
break;
|
2001-12-13 23:14:39 +00:00
|
|
|
#ifdef USE_GLIB2
|
|
|
|
case ARG_MEDIA_SIZE:
|
|
|
|
GTK_VALUE_UINT (*arg) = gst_play_get_media_size(play);
|
|
|
|
break;
|
|
|
|
case ARG_MEDIA_OFFSET:
|
|
|
|
GTK_VALUE_UINT (*arg) = gst_play_get_media_offset(play);
|
|
|
|
break;
|
|
|
|
#else
|
2001-05-21 01:19:06 +00:00
|
|
|
case ARG_MEDIA_SIZE:
|
|
|
|
GTK_VALUE_LONG (*arg) = gst_play_get_media_size(play);
|
|
|
|
break;
|
|
|
|
case ARG_MEDIA_OFFSET:
|
|
|
|
GTK_VALUE_LONG (*arg) = gst_play_get_media_offset(play);
|
|
|
|
break;
|
2001-12-13 23:14:39 +00:00
|
|
|
#endif
|
2001-05-21 01:19:06 +00:00
|
|
|
case ARG_MEDIA_TOTAL_TIME:
|
|
|
|
break;
|
|
|
|
case ARG_MEDIA_CURRENT_TIME:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
arg->type = GTK_TYPE_INVALID;
|
|
|
|
break;
|
|
|
|
}
|
2000-06-25 21:38:00 +00:00
|
|
|
}
|