Logo Search packages:      
Sourcecode: betaradio version File versions  Download package

gst_player.c

/* gst_player.c generated by valac, the Vala compiler
 * generated from gst_player.vala, do not modify */

/* -*- coding: utf-8; indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- */
/* vim:set fileencodings=utf-8 tabstop=4 expandtab shiftwidth=4 softtabstop=4: */

#include <glib.h>
#include <glib-object.h>
#include <gst/gst.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>


#define TYPE_GST_PLAYER (gst_player_get_type ())
#define GST_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GST_PLAYER, GstPlayer))
#define GST_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GST_PLAYER, GstPlayerClass))
#define IS_GST_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GST_PLAYER))
#define IS_GST_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GST_PLAYER))
#define GST_PLAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GST_PLAYER, GstPlayerClass))

typedef struct _GstPlayer GstPlayer;
typedef struct _GstPlayerClass GstPlayerClass;
typedef struct _GstPlayerPrivate GstPlayerPrivate;
#define _gst_object_unref0(var) ((var == NULL) ? NULL : (var = (gst_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

00029 struct _GstPlayer {
      GObject parent_instance;
      GstPlayerPrivate * priv;
};

00034 struct _GstPlayerClass {
      GObjectClass parent_class;
};

00038 struct _GstPlayerPrivate {
      GstElement* player;
};


static gpointer gst_player_parent_class = NULL;

GType gst_player_get_type (void);
#define GST_PLAYER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_GST_PLAYER, GstPlayerPrivate))
enum  {
      GST_PLAYER_DUMMY_PROPERTY
};
static inline void _dynamic_set_uri0 (GstElement* obj, const char* value);
GstPlayer* gst_player_new (const char* name, const char* url);
GstPlayer* gst_player_construct (GType object_type, const char* name, const char* url);
void gst_player_play (GstPlayer* self);
void gst_player_stop (GstPlayer* self);
static gboolean gst_player_bus_callback (GstPlayer* self, GstBus* bus, GstMessage* message);
static void gst_player_finalize (GObject* obj);



static inline void _dynamic_set_uri0 (GstElement* obj, const char* value) {
      g_object_set (obj, "uri", value, NULL);
}


GstPlayer* gst_player_construct (GType object_type, const char* name, const char* url) {
      GstPlayer * self;
      GstElement* _tmp0_;
      g_return_val_if_fail (name != NULL, NULL);
      g_return_val_if_fail (url != NULL, NULL);
      self = (GstPlayer*) g_object_new (object_type, NULL);
      self->priv->player = (_tmp0_ = gst_element_factory_make ("playbin2", name), _gst_object_unref0 (self->priv->player), _tmp0_);
      _dynamic_set_uri0 (self->priv->player, url);
      return self;
}


GstPlayer* gst_player_new (const char* name, const char* url) {
      return gst_player_construct (TYPE_GST_PLAYER, name, url);
}


void gst_player_play (GstPlayer* self) {
      g_return_if_fail (self != NULL);
      gst_element_set_state (self->priv->player, GST_STATE_PLAYING);
}


void gst_player_stop (GstPlayer* self) {
      g_return_if_fail (self != NULL);
      gst_element_set_state (self->priv->player, GST_STATE_NULL);
}


static gboolean gst_player_bus_callback (GstPlayer* self, GstBus* bus, GstMessage* message) {
      gboolean result = FALSE;
      g_return_val_if_fail (self != NULL, FALSE);
      g_return_val_if_fail (bus != NULL, FALSE);
      g_return_val_if_fail (message != NULL, FALSE);
      switch (message->type) {
            case GST_MESSAGE_ERROR:
            {
                  GError* err;
                  char* debug;
                  char* _tmp3_;
                  char* _tmp2_ = NULL;
                  GError* _tmp1_;
                  GError* _tmp0_ = NULL;
                  err = NULL;
                  debug = NULL;
                  (gst_message_parse_error (message, &_tmp0_, &_tmp2_), err = (_tmp1_ = _tmp0_, _g_error_free0 (err), _tmp1_));
                  debug = (_tmp3_ = _tmp2_, _g_free0 (debug), _tmp3_);
                  g_error ("gst_player.vala:44: Error: %s\n", err->message);
                  _g_error_free0 (err);
                  _g_free0 (debug);
                  break;
            }
            case GST_MESSAGE_EOS:
            {
                  g_warning ("gst_player.vala:47: end of stream\n");
                  break;
            }
            case GST_MESSAGE_STATE_CHANGED:
            {
                  GstState oldstate = 0;
                  GstState newstate = 0;
                  GstState pending = 0;
                  gst_message_parse_state_changed (message, &oldstate, &newstate, &pending);
                  fprintf (stdout, "state changed: %s->%s:%s\n", gst_element_state_get_name (oldstate), gst_element_state_get_name (newstate), gst_element_state_get_name (pending));
                  break;
            }
            default:
            {
                  break;
            }
      }
      result = TRUE;
      return result;
}


static void gst_player_class_init (GstPlayerClass * klass) {
      gst_player_parent_class = g_type_class_peek_parent (klass);
      g_type_class_add_private (klass, sizeof (GstPlayerPrivate));
      G_OBJECT_CLASS (klass)->finalize = gst_player_finalize;
}


static void gst_player_instance_init (GstPlayer * self) {
      self->priv = GST_PLAYER_GET_PRIVATE (self);
      self->priv->player = NULL;
}


static void gst_player_finalize (GObject* obj) {
      GstPlayer * self;
      self = GST_PLAYER (obj);
      {
            GstElement* _tmp0_;
            self->priv->player = (_tmp0_ = NULL, _gst_object_unref0 (self->priv->player), _tmp0_);
      }
      _gst_object_unref0 (self->priv->player);
      G_OBJECT_CLASS (gst_player_parent_class)->finalize (obj);
}


GType gst_player_get_type (void) {
      static volatile gsize gst_player_type_id__volatile = 0;
      if (g_once_init_enter (&gst_player_type_id__volatile)) {
            static const GTypeInfo g_define_type_info = { sizeof (GstPlayerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gst_player_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GstPlayer), 0, (GInstanceInitFunc) gst_player_instance_init, NULL };
            GType gst_player_type_id;
            gst_player_type_id = g_type_register_static (G_TYPE_OBJECT, "GstPlayer", &g_define_type_info, 0);
            g_once_init_leave (&gst_player_type_id__volatile, gst_player_type_id);
      }
      return gst_player_type_id__volatile;
}





Generated by  Doxygen 1.6.0   Back to index