2000-06-25 21:38:00 +00:00
|
|
|
/*
|
|
|
|
* Initial main.c file generated by Glade. Edit as required.
|
|
|
|
* Glade will not overwrite this file.
|
|
|
|
*/
|
|
|
|
|
2000-08-18 20:35:48 +00:00
|
|
|
#include <config.h>
|
2000-06-25 21:38:00 +00:00
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
#include "gstplay.h"
|
|
|
|
#include "gstplayprivate.h"
|
2000-07-12 22:52:42 +00:00
|
|
|
|
2000-10-30 21:02:08 +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
|
|
|
|
2000-10-30 21:02:08 +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
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
static void gst_play_realize (GtkWidget *play);
|
2000-07-05 10:21:08 +00:00
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
static void gst_play_frame_displayed (GstElement *element, 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 {
|
|
|
|
SIGNAL_STATE_CHANGED,
|
|
|
|
SIGNAL_FRAME_DISPLAYED,
|
|
|
|
SIGNAL_AUDIO_PLAYED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
2000-07-05 10:21:08 +00:00
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
enum {
|
|
|
|
ARG_0,
|
|
|
|
ARG_URI,
|
|
|
|
ARG_MUTE,
|
|
|
|
ARG_STATE,
|
|
|
|
ARG_MEDIA_SIZE,
|
|
|
|
ARG_MEDIA_OFFSET,
|
|
|
|
ARG_MEDIA_TOTAL_TIME,
|
|
|
|
ARG_MEDIA_CURRENT_TIME,
|
|
|
|
};
|
2000-07-05 10:21:08 +00:00
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
static GtkObject *parent_class = NULL;
|
|
|
|
static guint gst_play_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
|
|
GtkType
|
|
|
|
gst_play_get_type (void)
|
|
|
|
{
|
|
|
|
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);
|
2000-07-05 10:21:08 +00:00
|
|
|
}
|
2000-10-30 21:02:08 +00:00
|
|
|
return play_type;
|
2000-06-25 21:38:00 +00:00
|
|
|
}
|
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
static void
|
|
|
|
gst_play_class_init (GstPlayClass *klass)
|
|
|
|
{
|
|
|
|
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] =
|
|
|
|
gtk_signal_new ("playing_state_changed",GTK_RUN_FIRST,object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GstPlayClass,state_changed),
|
|
|
|
gtk_marshal_NONE__INT,GTK_TYPE_NONE,1,
|
|
|
|
GTK_TYPE_INT);
|
|
|
|
|
|
|
|
gst_play_signals[SIGNAL_FRAME_DISPLAYED] =
|
|
|
|
gtk_signal_new ("frame_displayed",GTK_RUN_FIRST,object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GstPlayClass,frame_displayed),
|
2000-11-01 13:49:41 +00:00
|
|
|
gtk_marshal_NONE__NONE,GTK_TYPE_NONE,0);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
|
|
|
gst_play_signals[SIGNAL_AUDIO_PLAYED] =
|
|
|
|
gtk_signal_new ("audio_played",GTK_RUN_FIRST,object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GstPlayClass,audio_played),
|
2000-11-01 13:49:41 +00:00
|
|
|
gtk_marshal_NONE__NONE,GTK_TYPE_NONE,0);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
|
|
|
gtk_object_class_add_signals (object_class,gst_play_signals,LAST_SIGNAL);
|
|
|
|
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);
|
|
|
|
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);
|
|
|
|
|
|
|
|
object_class->set_arg = gst_play_set_arg;
|
|
|
|
object_class->get_arg = gst_play_get_arg;
|
|
|
|
|
|
|
|
widget_class->realize = gst_play_realize;
|
|
|
|
|
2000-07-05 10:21:08 +00:00
|
|
|
}
|
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
static void
|
|
|
|
gst_play_init (GstPlay *play)
|
2000-08-14 10:16:23 +00:00
|
|
|
{
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2000-11-01 13:49:41 +00:00
|
|
|
GstPlayPrivate *priv = g_new0 (GstPlayPrivate, 1);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2000-11-01 13:49:41 +00:00
|
|
|
play->priv = priv;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
|
|
|
/* create a new bin to hold the elements */
|
2000-11-01 13:49:41 +00:00
|
|
|
priv->thread = gst_thread_new ("main_thread");
|
|
|
|
g_assert (priv->thread != NULL);
|
|
|
|
priv->pipeline = gst_pipeline_new ("main_pipeline");
|
|
|
|
g_assert (priv->pipeline != NULL);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
|
|
|
/* and an audio sink */
|
2000-11-01 13:49:41 +00:00
|
|
|
priv->audio_play = gst_elementfactory_make ("audiosink","play_audio");
|
|
|
|
g_return_if_fail (priv->audio_play != NULL);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (priv->audio_play), "handoff",
|
2000-10-30 21:02:08 +00:00
|
|
|
GTK_SIGNAL_FUNC (gst_play_audio_handoff), play);
|
|
|
|
|
|
|
|
/* and a video sink */
|
2000-11-01 13:49:41 +00:00
|
|
|
priv->video_show = gst_elementfactory_make ("videosink","show");
|
|
|
|
g_return_if_fail (priv->video_show != NULL);
|
|
|
|
gtk_object_set (GTK_OBJECT (priv->video_show),"xv_enabled",FALSE,NULL);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (priv->video_show), "frame_displayed",
|
2000-10-30 21:02:08 +00:00
|
|
|
GTK_SIGNAL_FUNC (gst_play_frame_displayed), play);
|
|
|
|
|
2000-11-01 13:49:41 +00:00
|
|
|
gst_pipeline_add_sink (GST_PIPELINE (priv->pipeline), priv->audio_play);
|
|
|
|
gst_pipeline_add_sink (GST_PIPELINE (priv->pipeline), priv->video_show);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2000-11-01 13:49:41 +00:00
|
|
|
gst_bin_add (GST_BIN (priv->thread), priv->pipeline);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
|
|
|
play->state = GST_PLAY_STOPPED;
|
|
|
|
play->flags = 0;
|
2000-11-01 13:49:41 +00:00
|
|
|
|
|
|
|
priv->src = NULL;
|
|
|
|
priv->muted = FALSE;
|
|
|
|
priv->can_seek = TRUE;
|
|
|
|
priv->uri = NULL;
|
|
|
|
priv->offset_element = NULL;
|
|
|
|
priv->bit_rate_element = NULL;
|
2000-08-14 10:16:23 +00:00
|
|
|
}
|
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
GstPlay *
|
|
|
|
gst_play_new ()
|
2000-08-14 10:16:23 +00:00
|
|
|
{
|
2000-10-30 21:02:08 +00:00
|
|
|
return GST_PLAY (gtk_type_new (GST_TYPE_PLAY));
|
2000-08-14 10:16:23 +00:00
|
|
|
}
|
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
static void
|
|
|
|
gst_play_eos (GstElement *element,
|
|
|
|
GstPlay *play)
|
2000-07-13 19:49:50 +00:00
|
|
|
{
|
2000-10-30 21:02:08 +00:00
|
|
|
gst_play_stop(play);
|
2000-07-13 19:49:50 +00:00
|
|
|
}
|
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
static void
|
|
|
|
gst_play_frame_displayed (GstElement *element,
|
|
|
|
GstPlay *play)
|
2000-07-13 19:49:50 +00:00
|
|
|
{
|
2000-10-30 21:02:08 +00:00
|
|
|
gtk_signal_emit (GTK_OBJECT (play), gst_play_signals[SIGNAL_FRAME_DISPLAYED],
|
|
|
|
NULL);
|
2000-07-13 19:49:50 +00:00
|
|
|
}
|
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
static void
|
|
|
|
gst_play_audio_handoff (GstElement *element,
|
|
|
|
GstPlay *play)
|
2000-07-12 22:52:42 +00:00
|
|
|
{
|
2000-10-30 21:02:08 +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
|
|
|
|
2000-11-01 13:49:41 +00:00
|
|
|
static void
|
|
|
|
gst_play_object_introspect (GstElement *element,
|
|
|
|
const gchar *property,
|
|
|
|
GstElement **target)
|
|
|
|
{
|
|
|
|
gchar *info;
|
|
|
|
GtkArgInfo *arg;
|
|
|
|
|
|
|
|
info = gtk_object_arg_get_info( GTK_OBJECT_TYPE(element), property, &arg);
|
|
|
|
|
|
|
|
if (info) {
|
|
|
|
g_free(info);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*target = element;
|
|
|
|
g_print("gstplay: using element \"%s\" for %s property\n",
|
|
|
|
gst_element_get_name(element), property);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Dumb introspection of the interface...
|
|
|
|
* this will change with glib 1.4
|
|
|
|
* */
|
|
|
|
static void
|
|
|
|
gst_play_object_added (GstElement *pipeline,
|
|
|
|
GstElement *element,
|
|
|
|
GstPlay *play)
|
|
|
|
{
|
|
|
|
GstPlayPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (play != NULL);
|
|
|
|
|
|
|
|
priv = (GstPlayPrivate *)play->priv;
|
|
|
|
|
|
|
|
if (GST_FLAGS (element) & GST_ELEMENT_NO_SEEK) {
|
|
|
|
priv->can_seek = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GST_IS_BIN (element)) {
|
|
|
|
gtk_signal_connect (GTK_OBJECT (element), "object_added", gst_play_object_added, play);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// first come first serve here...
|
|
|
|
if (!priv->offset_element) gst_play_object_introspect(element, "offset", &priv->offset_element);
|
|
|
|
if (!priv->bit_rate_element) gst_play_object_introspect(element, "bit_rate", &priv->bit_rate_element);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
GstPlayReturn
|
|
|
|
gst_play_set_uri (GstPlay *play,
|
|
|
|
const guchar *uri)
|
|
|
|
{
|
2000-11-01 13:49:41 +00:00
|
|
|
GstPlayPrivate *priv;
|
2000-10-30 21:02:08 +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);
|
|
|
|
|
2000-11-01 13:49:41 +00:00
|
|
|
priv = (GstPlayPrivate *)play->priv;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2000-11-01 13:49:41 +00:00
|
|
|
if (priv->src) {
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
2000-11-01 13:49:41 +00:00
|
|
|
if (priv->uri) g_free (priv->uri);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2000-11-01 13:49:41 +00:00
|
|
|
priv->uri = g_strdup (uri);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2000-11-01 13:49:41 +00:00
|
|
|
priv->src = gst_elementfactory_make ("disksrc", "disk_src");
|
|
|
|
g_return_val_if_fail (priv->src != NULL, -1);
|
|
|
|
gtk_object_set (GTK_OBJECT (priv->src),"location",uri,NULL);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (priv->src), "eos", GTK_SIGNAL_FUNC (gst_play_eos), play);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2000-11-01 13:49:41 +00:00
|
|
|
gtk_signal_connect (GTK_OBJECT (priv->pipeline), "object_added", gst_play_object_added, play);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2000-11-01 13:49:41 +00:00
|
|
|
gst_pipeline_add_src (GST_PIPELINE (priv->pipeline),GST_ELEMENT (priv->src));
|
|
|
|
|
|
|
|
if (!gst_pipeline_autoplug (GST_PIPELINE (priv->pipeline))) {
|
2000-10-30 21:02:08 +00:00
|
|
|
return GST_PLAY_UNKNOWN_MEDIA;
|
|
|
|
}
|
|
|
|
|
2000-11-01 13:49:41 +00:00
|
|
|
if (GST_PAD_CONNECTED (gst_element_get_pad (priv->video_show, "sink"))) {
|
2000-10-30 21:02:08 +00:00
|
|
|
play->flags |= GST_PLAY_TYPE_VIDEO;
|
|
|
|
}
|
2000-11-01 13:49:41 +00:00
|
|
|
if (GST_PAD_CONNECTED (gst_element_get_pad (priv->audio_play, "sink"))) {
|
2000-10-30 21:02:08 +00:00
|
|
|
play->flags |= GST_PLAY_TYPE_AUDIO;
|
2000-07-05 10:21:08 +00:00
|
|
|
}
|
2000-10-30 21:02:08 +00:00
|
|
|
|
|
|
|
return GST_PLAY_OK;
|
2000-07-05 10:21:08 +00:00
|
|
|
}
|
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
static void
|
|
|
|
gst_play_realize (GtkWidget *widget)
|
2000-08-14 10:16:23 +00:00
|
|
|
{
|
2000-10-30 21:02:08 +00:00
|
|
|
GstPlay *play;
|
|
|
|
GtkWidget *video_widget;
|
2000-11-01 13:49:41 +00:00
|
|
|
GstPlayPrivate *priv;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_PLAY (widget));
|
|
|
|
|
|
|
|
play = GST_PLAY (widget);
|
2000-11-01 13:49:41 +00:00
|
|
|
priv = (GstPlayPrivate *)play->priv;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2000-11-01 13:49:41 +00:00
|
|
|
video_widget = gst_util_get_widget_arg (GTK_OBJECT (priv->video_show),"widget");
|
2000-10-30 21:02:08 +00:00
|
|
|
|
|
|
|
if (video_widget) {
|
|
|
|
gtk_container_add (GTK_CONTAINER (widget), video_widget);
|
|
|
|
gtk_widget_show (video_widget);
|
2000-10-12 19:41:30 +00:00
|
|
|
}
|
2000-08-14 10:16:23 +00:00
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
if (GTK_WIDGET_CLASS (parent_class)->realize) {
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->realize (widget);
|
2000-10-12 19:41:30 +00:00
|
|
|
}
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gst_play_play (GstPlay *play)
|
|
|
|
{
|
2000-11-01 13:49:41 +00:00
|
|
|
GstPlayPrivate *priv;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
|
|
|
g_return_if_fail (play != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PLAY (play));
|
2000-08-14 10:16:23 +00:00
|
|
|
|
2000-11-01 13:49:41 +00:00
|
|
|
priv = (GstPlayPrivate *)play->priv;
|
2000-08-14 10:16:23 +00:00
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
if (play->state == GST_PLAY_PLAYING) return;
|
2000-08-14 10:16:23 +00:00
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
if (play->state == GST_PLAY_STOPPED)
|
2000-11-01 13:49:41 +00:00
|
|
|
gst_element_set_state (GST_ELEMENT (priv->thread),GST_STATE_READY);
|
|
|
|
gst_element_set_state (GST_ELEMENT (priv->thread),GST_STATE_PLAYING);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
|
|
|
play->state = GST_PLAY_PLAYING;
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (play), gst_play_signals[SIGNAL_STATE_CHANGED],
|
|
|
|
play->state);
|
2000-08-14 10:16:23 +00:00
|
|
|
}
|
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
void
|
|
|
|
gst_play_pause (GstPlay *play)
|
|
|
|
{
|
2000-11-01 13:49:41 +00:00
|
|
|
GstPlayPrivate *priv;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
|
|
|
g_return_if_fail (play != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PLAY (play));
|
2000-08-14 10:16:23 +00:00
|
|
|
|
2000-11-01 13:49:41 +00:00
|
|
|
priv = (GstPlayPrivate *)play->priv;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2000-11-01 13:49:41 +00:00
|
|
|
if (play->state != GST_PLAY_PLAYING) return;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2000-11-01 13:49:41 +00:00
|
|
|
gst_element_set_state (GST_ELEMENT (priv->thread),GST_STATE_PAUSED);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
|
|
|
play->state = GST_PLAY_PAUSED;
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (play), gst_play_signals[SIGNAL_STATE_CHANGED],
|
|
|
|
play->state);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gst_play_stop (GstPlay *play)
|
2000-06-25 21:38:00 +00:00
|
|
|
{
|
2000-11-01 13:49:41 +00:00
|
|
|
GstPlayPrivate *priv;
|
2000-08-14 10:16:23 +00:00
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
g_return_if_fail (play != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PLAY (play));
|
2000-08-14 10:16:23 +00:00
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
if (play->state == GST_PLAY_STOPPED) return;
|
2000-07-05 10:21:08 +00:00
|
|
|
|
2000-11-01 13:49:41 +00:00
|
|
|
priv = (GstPlayPrivate *)play->priv;
|
2000-07-12 22:52:42 +00:00
|
|
|
|
2000-11-01 13:49:41 +00:00
|
|
|
gst_element_set_state (GST_ELEMENT (priv->thread),GST_STATE_NULL);
|
|
|
|
gtk_object_set (GTK_OBJECT (priv->src),"offset",0,NULL);
|
2000-10-12 19:41:30 +00:00
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
play->state = GST_PLAY_STOPPED;
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (play), gst_play_signals[SIGNAL_STATE_CHANGED],
|
|
|
|
play->state);
|
|
|
|
}
|
|
|
|
|
2000-11-01 13:49:41 +00:00
|
|
|
gulong
|
|
|
|
gst_play_get_media_size (GstPlay *play)
|
|
|
|
{
|
|
|
|
GstPlayPrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (play != NULL, 0);
|
|
|
|
g_return_val_if_fail (GST_IS_PLAY (play), 0);
|
|
|
|
|
|
|
|
priv = (GstPlayPrivate *)play->priv;
|
|
|
|
|
|
|
|
return gst_util_get_long_arg (GTK_OBJECT (priv->src), "size");
|
|
|
|
}
|
|
|
|
|
|
|
|
gulong
|
|
|
|
gst_play_get_media_offset (GstPlay *play)
|
|
|
|
{
|
|
|
|
GstPlayPrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (play != NULL, 0);
|
|
|
|
g_return_val_if_fail (GST_IS_PLAY (play), 0);
|
|
|
|
|
|
|
|
priv = (GstPlayPrivate *)play->priv;
|
|
|
|
|
|
|
|
return gst_util_get_long_arg (GTK_OBJECT (priv->offset_element), "offset");
|
|
|
|
}
|
|
|
|
|
|
|
|
gulong
|
|
|
|
gst_play_get_media_total_time (GstPlay *play)
|
|
|
|
{
|
|
|
|
gulong total_time, bit_rate;
|
|
|
|
GstPlayPrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (play != NULL, 0);
|
|
|
|
g_return_val_if_fail (GST_IS_PLAY (play), 0);
|
|
|
|
|
|
|
|
priv = (GstPlayPrivate *)play->priv;
|
|
|
|
|
|
|
|
if (priv->bit_rate_element == NULL) return 0;
|
|
|
|
|
|
|
|
bit_rate = gst_util_get_long_arg (GTK_OBJECT (priv->bit_rate_element), "bit_rate");
|
|
|
|
|
|
|
|
if (bit_rate)
|
|
|
|
total_time = (gst_play_get_media_size (play) * 8) / bit_rate;
|
|
|
|
else
|
|
|
|
total_time = 0;
|
|
|
|
|
|
|
|
return total_time;
|
|
|
|
}
|
|
|
|
|
|
|
|
gulong
|
|
|
|
gst_play_get_media_current_time (GstPlay *play)
|
|
|
|
{
|
|
|
|
gulong current_time, bit_rate;
|
|
|
|
GstPlayPrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (play != NULL, 0);
|
|
|
|
g_return_val_if_fail (GST_IS_PLAY (play), 0);
|
|
|
|
|
|
|
|
priv = (GstPlayPrivate *)play->priv;
|
|
|
|
|
|
|
|
if (priv->bit_rate_element == NULL) return 0;
|
|
|
|
|
|
|
|
bit_rate = gst_util_get_long_arg (GTK_OBJECT (priv->bit_rate_element), "bit_rate");
|
|
|
|
|
|
|
|
if (bit_rate)
|
|
|
|
current_time = (gst_play_get_media_offset (play) * 8) / bit_rate;
|
|
|
|
else
|
|
|
|
current_time = 0;
|
|
|
|
|
|
|
|
return current_time;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gst_play_media_can_seek (GstPlay *play)
|
|
|
|
{
|
|
|
|
GstPlayPrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (play != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
|
|
|
|
|
|
|
|
priv = (GstPlayPrivate *)play->priv;
|
|
|
|
|
|
|
|
return priv->can_seek;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gst_play_media_seek (GstPlay *play,
|
|
|
|
gulong offset)
|
|
|
|
{
|
|
|
|
GstPlayPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (play != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PLAY (play));
|
|
|
|
|
|
|
|
priv = (GstPlayPrivate *)play->priv;
|
|
|
|
|
|
|
|
gtk_object_set (GTK_OBJECT (priv->src), "offset", offset, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
static void
|
|
|
|
gst_play_set_arg (GtkObject *object,
|
|
|
|
GtkArg *arg,
|
|
|
|
guint id)
|
|
|
|
{
|
|
|
|
GstPlay *play;
|
2000-11-01 13:49:41 +00:00
|
|
|
|
|
|
|
g_return_if_fail (object != NULL);
|
|
|
|
g_return_if_fail (arg != NULL);
|
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
play = GST_PLAY (object);
|
|
|
|
|
|
|
|
switch (id) {
|
|
|
|
case ARG_MUTE:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_warning ("GstPlay: unknown arg!");
|
|
|
|
break;
|
2000-08-14 10:16:23 +00:00
|
|
|
}
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_play_get_arg (GtkObject *object,
|
|
|
|
GtkArg *arg,
|
|
|
|
guint id)
|
|
|
|
{
|
|
|
|
GstPlay *play;
|
2000-11-01 13:49:41 +00:00
|
|
|
GstPlayPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (object != NULL);
|
|
|
|
g_return_if_fail (arg != NULL);
|
2000-06-25 21:38:00 +00:00
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
play = GST_PLAY (object);
|
2000-11-01 13:49:41 +00:00
|
|
|
priv = (GstPlayPrivate *)play->priv;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
|
|
|
switch (id) {
|
|
|
|
case ARG_URI:
|
2000-11-01 13:49:41 +00:00
|
|
|
GTK_VALUE_STRING (*arg) = priv->uri;
|
2000-10-30 21:02:08 +00:00
|
|
|
break;
|
|
|
|
case ARG_MUTE:
|
2000-11-01 13:49:41 +00:00
|
|
|
GTK_VALUE_BOOL (*arg) = priv->muted;
|
2000-10-30 21:02:08 +00:00
|
|
|
break;
|
|
|
|
case ARG_STATE:
|
|
|
|
GTK_VALUE_INT (*arg) = play->state;
|
|
|
|
break;
|
|
|
|
case ARG_MEDIA_SIZE:
|
2000-11-01 13:49:41 +00:00
|
|
|
GTK_VALUE_LONG (*arg) = gst_play_get_media_size(play);
|
2000-10-30 21:02:08 +00:00
|
|
|
break;
|
|
|
|
case ARG_MEDIA_OFFSET:
|
2000-11-01 13:49:41 +00:00
|
|
|
GTK_VALUE_LONG (*arg) = gst_play_get_media_offset(play);
|
2000-10-30 21:02:08 +00:00
|
|
|
break;
|
|
|
|
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
|
|
|
}
|
|
|
|
|