mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 08:17:01 +00:00
Code cleanup, make it adhere to the Gnome/Gtk+ code formatting, which is quite clean and more readable.
Original commit message from CVS: Code cleanup, make it adhere to the Gnome/Gtk+ code formatting, which is quite clean and more readable. Renamed parseavi to avidecoder Implemented seeking/time display/pause/play/stop/clean exit to gstmediaplay Added an element flag to indicate that it cannot deal with noncontigous buffers. If such an element is found in the pipeline, seeking is disabled for the complete stream (avidecoder cannot deal with seeking until we convert it to a loop based element with pull_region to fetch the indeces etc...)
This commit is contained in:
parent
c69c6914c9
commit
9500bd2128
17 changed files with 650 additions and 360 deletions
|
@ -37,16 +37,16 @@ extern "C" {
|
|||
|
||||
typedef enum {
|
||||
GST_STATE_NONE_PENDING = -1,
|
||||
GST_STATE_NULL = 0,
|
||||
GST_STATE_READY = 1,
|
||||
GST_STATE_PLAYING = 2,
|
||||
GST_STATE_PAUSED = 3,
|
||||
GST_STATE_NULL = 0,
|
||||
GST_STATE_READY = 1,
|
||||
GST_STATE_PLAYING = 2,
|
||||
GST_STATE_PAUSED = 3,
|
||||
} GstElementState;
|
||||
|
||||
typedef enum {
|
||||
GST_STATE_FAILURE = 0,
|
||||
GST_STATE_SUCCESS = 1,
|
||||
GST_STATE_ASYNC = 2,
|
||||
GST_STATE_FAILURE = 0,
|
||||
GST_STATE_SUCCESS = 1,
|
||||
GST_STATE_ASYNC = 2,
|
||||
} GstElementStateReturn;
|
||||
|
||||
static inline char *_gst_print_statename(int state) {
|
||||
|
@ -78,6 +78,7 @@ static inline char *_gst_print_statename(int state) {
|
|||
typedef enum {
|
||||
GST_ELEMENT_MULTI_IN = (1 << 4),
|
||||
GST_ELEMENT_THREAD_SUGGESTED = (1 << 5),
|
||||
GST_ELEMENT_NO_SEEK = (1 << 6),
|
||||
} GstElementFlags;
|
||||
|
||||
#define GST_ELEMENT_IS_MULTI_IN(obj) (GST_FLAGS(obj) & GST_ELEMENT_MULTI_IN)
|
||||
|
@ -115,10 +116,10 @@ struct _GstElementClass {
|
|||
GstElementFactory *elementfactory;
|
||||
|
||||
/* signal callbacks */
|
||||
void (*state_change) (GstElement *element,GstElementState state);
|
||||
void (*new_pad) (GstElement *element,GstPad *pad);
|
||||
void (*state_change) (GstElement *element,GstElementState state);
|
||||
void (*new_pad) (GstElement *element,GstPad *pad);
|
||||
void (*new_ghost_pad) (GstElement *element,GstPad *pad);
|
||||
void (*error) (GstElement *element,gchar *error);
|
||||
void (*error) (GstElement *element,gchar *error);
|
||||
|
||||
/* events */
|
||||
// gboolean (*start) (GstElement *element,GstElementState state);
|
||||
|
@ -151,59 +152,57 @@ struct _GstElementFactory {
|
|||
GList *sink_types;
|
||||
};
|
||||
|
||||
GtkType gst_element_get_type(void);
|
||||
GstElement *gst_element_new(void);
|
||||
GtkType gst_element_get_type (void);
|
||||
GstElement* gst_element_new (void);
|
||||
#define gst_element_destroy(element) gst_object_destroy (GST_OBJECT (element))
|
||||
|
||||
void gst_element_set_loop_function(GstElement *element,
|
||||
GstElementLoopFunction loop);
|
||||
void gst_element_set_loop_function (GstElement *element,
|
||||
GstElementLoopFunction loop);
|
||||
|
||||
void gst_element_set_name(GstElement *element,gchar *name);
|
||||
gchar *gst_element_get_name(GstElement *element);
|
||||
void gst_element_set_name (GstElement *element, gchar *name);
|
||||
gchar* gst_element_get_name (GstElement *element);
|
||||
|
||||
void gst_element_set_manager(GstElement *element,GstElement *manager);
|
||||
GstElement *gst_element_get_manager(GstElement *element);
|
||||
void gst_element_set_manager (GstElement *element, GstElement *manager);
|
||||
GstElement* gst_element_get_manager (GstElement *element);
|
||||
|
||||
void gst_element_add_pad(GstElement *element,GstPad *pad);
|
||||
void gst_element_add_ghost_pad(GstElement *element,GstPad *pad);
|
||||
GstPad *gst_element_get_pad(GstElement *element,gchar *name);
|
||||
GList *gst_element_get_pad_list(GstElement *element);
|
||||
void gst_element_add_pad (GstElement *element, GstPad *pad);
|
||||
GstPad* gst_element_get_pad (GstElement *element, gchar *name);
|
||||
GList* gst_element_get_pad_list (GstElement *element);
|
||||
void gst_element_add_ghost_pad (GstElement *element, GstPad *pad);
|
||||
|
||||
void gst_element_connect(GstElement *src,gchar *srcpadname,
|
||||
GstElement *dest,gchar *destpadname);
|
||||
void gst_element_connect (GstElement *src, gchar *srcpadname,
|
||||
GstElement *dest, gchar *destpadname);
|
||||
|
||||
/* called by the app to set the state of the element */
|
||||
gint gst_element_set_state(GstElement *element,GstElementState state);
|
||||
gint gst_element_set_state (GstElement *element, GstElementState state);
|
||||
|
||||
void gst_element_error(GstElement *element,gchar *error);
|
||||
void gst_element_error (GstElement *element, gchar *error);
|
||||
|
||||
GstElementFactory *gst_element_get_factory(GstElement *element);
|
||||
|
||||
#define gst_element_destroy(element) gst_object_destroy(GST_OBJECT(element))
|
||||
GstElementFactory* gst_element_get_factory (GstElement *element);
|
||||
int gst_element_loopfunc_wrapper (int argc,char **argv);
|
||||
|
||||
/* XML write and read */
|
||||
xmlNodePtr gst_element_save_thyself(GstElement *element,xmlNodePtr parent);
|
||||
GstElement *gst_element_load_thyself(xmlNodePtr parent, GHashTable *elements);
|
||||
xmlNodePtr gst_element_save_thyself (GstElement *element, xmlNodePtr parent);
|
||||
GstElement* gst_element_load_thyself (xmlNodePtr parent, GHashTable *elements);
|
||||
|
||||
GstElementFactory *gst_elementfactory_new(gchar *name,GtkType type,
|
||||
GstElementDetails *details);
|
||||
void gst_elementfactory_register(GstElementFactory *elementfactory);
|
||||
|
||||
void gst_elementfactory_add_src(GstElementFactory *elementfactory, guint16 id);
|
||||
void gst_elementfactory_add_sink(GstElementFactory *elementfactory, guint16 id);
|
||||
GstElementFactory* gst_elementfactory_new (gchar *name,GtkType type,
|
||||
GstElementDetails *details);
|
||||
void gst_elementfactory_register (GstElementFactory *elementfactory);
|
||||
|
||||
GstElementFactory *gst_elementfactory_find(gchar *name);
|
||||
GList *gst_elementfactory_get_list();
|
||||
void gst_elementfactory_add_src (GstElementFactory *elementfactory, guint16 id);
|
||||
void gst_elementfactory_add_sink (GstElementFactory *elementfactory, guint16 id);
|
||||
|
||||
GstElement *gst_elementfactory_create(GstElementFactory *factory,
|
||||
gchar *name);
|
||||
GstElementFactory* gst_elementfactory_find (gchar *name);
|
||||
GList* gst_elementfactory_get_list (void);
|
||||
|
||||
GstElement* gst_elementfactory_create (GstElementFactory *factory,
|
||||
gchar *name);
|
||||
// FIXME this name is wrong, probably so is the one above it
|
||||
GstElement *gst_elementfactory_make(gchar *factoryname,gchar *name);
|
||||
GstElement* gst_elementfactory_make (gchar *factoryname, gchar *name);
|
||||
|
||||
xmlNodePtr gst_elementfactory_save_thyself(GstElementFactory *factory, xmlNodePtr parent);
|
||||
GstElementFactory *gst_elementfactory_load_thyself(xmlNodePtr parent);
|
||||
|
||||
int gst_element_loopfunc_wrapper(int argc,char **argv);
|
||||
xmlNodePtr gst_elementfactory_save_thyself (GstElementFactory *factory, xmlNodePtr parent);
|
||||
GstElementFactory* gst_elementfactory_load_thyself (xmlNodePtr parent);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
278
gst/gstpad.c
278
gst/gstpad.c
|
@ -66,7 +66,8 @@ gst_pad_get_type(void) {
|
|||
}
|
||||
|
||||
static void
|
||||
gst_pad_class_init(GstPadClass *klass) {
|
||||
gst_pad_class_init (GstPadClass *klass)
|
||||
{
|
||||
GtkObjectClass *gtkobject_class;
|
||||
|
||||
gtkobject_class = (GtkObjectClass*)klass;
|
||||
|
@ -76,7 +77,9 @@ gst_pad_class_init(GstPadClass *klass) {
|
|||
gtkobject_class->destroy = gst_pad_real_destroy;
|
||||
}
|
||||
|
||||
static void gst_pad_init(GstPad *pad) {
|
||||
static void
|
||||
gst_pad_init (GstPad *pad)
|
||||
{
|
||||
pad->type = 0;
|
||||
pad->direction = GST_PAD_UNKNOWN;
|
||||
pad->peer = NULL;
|
||||
|
@ -97,14 +100,17 @@ static void gst_pad_init(GstPad *pad) {
|
|||
*
|
||||
* Returns: new pad
|
||||
*/
|
||||
GstPad *gst_pad_new(gchar *name,GstPadDirection direction) {
|
||||
GstPad*
|
||||
gst_pad_new (gchar *name,
|
||||
GstPadDirection direction)
|
||||
{
|
||||
GstPad *pad;
|
||||
|
||||
g_return_val_if_fail(name != NULL, NULL);
|
||||
g_return_val_if_fail(direction != GST_PAD_UNKNOWN, NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
g_return_val_if_fail (direction != GST_PAD_UNKNOWN, NULL);
|
||||
|
||||
pad = GST_PAD(gtk_type_new(gst_pad_get_type()));
|
||||
pad->name = g_strdup(name);
|
||||
pad = GST_PAD (gtk_type_new (gst_pad_get_type ()));
|
||||
pad->name = g_strdup (name);
|
||||
pad->direction = direction;
|
||||
return pad;
|
||||
}
|
||||
|
@ -117,9 +123,11 @@ GstPad *gst_pad_new(gchar *name,GstPadDirection direction) {
|
|||
*
|
||||
* Returns: the direction of the pad
|
||||
*/
|
||||
GstPadDirection gst_pad_get_direction(GstPad *pad) {
|
||||
g_return_val_if_fail(pad != NULL, GST_PAD_UNKNOWN);
|
||||
g_return_val_if_fail(GST_IS_PAD(pad), GST_PAD_UNKNOWN);
|
||||
GstPadDirection
|
||||
gst_pad_get_direction (GstPad *pad)
|
||||
{
|
||||
g_return_val_if_fail (pad != NULL, GST_PAD_UNKNOWN);
|
||||
g_return_val_if_fail (GST_IS_PAD (pad), GST_PAD_UNKNOWN);
|
||||
|
||||
return pad->direction;
|
||||
}
|
||||
|
@ -131,14 +139,17 @@ GstPadDirection gst_pad_get_direction(GstPad *pad) {
|
|||
*
|
||||
* set the name of a pad
|
||||
*/
|
||||
void gst_pad_set_name(GstPad *pad,gchar *name) {
|
||||
g_return_if_fail(pad != NULL);
|
||||
g_return_if_fail(GST_IS_PAD(pad));
|
||||
void
|
||||
gst_pad_set_name (GstPad *pad,
|
||||
const gchar *name)
|
||||
{
|
||||
g_return_if_fail (pad != NULL);
|
||||
g_return_if_fail (GST_IS_PAD (pad));
|
||||
|
||||
if (pad->name != NULL)
|
||||
g_free(pad->name);
|
||||
g_free (pad->name);
|
||||
|
||||
pad->name = g_strdup(name);
|
||||
pad->name = g_strdup (name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -147,11 +158,13 @@ void gst_pad_set_name(GstPad *pad,gchar *name) {
|
|||
*
|
||||
* get the name of a pad
|
||||
*
|
||||
* Returns: the name of the pad
|
||||
* Returns: the name of the pad, don't free.
|
||||
*/
|
||||
gchar *gst_pad_get_name(GstPad *pad) {
|
||||
g_return_val_if_fail(pad != NULL, NULL);
|
||||
g_return_val_if_fail(GST_IS_PAD(pad), NULL);
|
||||
const gchar*
|
||||
gst_pad_get_name (GstPad *pad)
|
||||
{
|
||||
g_return_val_if_fail (pad != NULL, NULL);
|
||||
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
|
||||
|
||||
return pad->name;
|
||||
}
|
||||
|
@ -163,9 +176,12 @@ gchar *gst_pad_get_name(GstPad *pad) {
|
|||
*
|
||||
* Set the given pull function for the pad
|
||||
*/
|
||||
void gst_pad_set_pull_function(GstPad *pad,GstPadPullFunction pull) {
|
||||
g_return_if_fail(pad != NULL);
|
||||
g_return_if_fail(GST_IS_PAD(pad));
|
||||
void
|
||||
gst_pad_set_pull_function (GstPad *pad,
|
||||
GstPadPullFunction pull)
|
||||
{
|
||||
g_return_if_fail (pad != NULL);
|
||||
g_return_if_fail (GST_IS_PAD (pad));
|
||||
|
||||
g_print("gstpad: pad setting pull function\n");
|
||||
|
||||
|
@ -179,9 +195,11 @@ void gst_pad_set_pull_function(GstPad *pad,GstPadPullFunction pull) {
|
|||
*
|
||||
* Set the given chain function for the pad
|
||||
*/
|
||||
void gst_pad_set_chain_function(GstPad *pad,GstPadChainFunction chain) {
|
||||
g_return_if_fail(pad != NULL);
|
||||
g_return_if_fail(GST_IS_PAD(pad));
|
||||
void gst_pad_set_chain_function (GstPad *pad,
|
||||
GstPadChainFunction chain)
|
||||
{
|
||||
g_return_if_fail (pad != NULL);
|
||||
g_return_if_fail (GST_IS_PAD (pad));
|
||||
|
||||
pad->chainfunc = chain;
|
||||
}
|
||||
|
@ -193,9 +211,12 @@ void gst_pad_set_chain_function(GstPad *pad,GstPadChainFunction chain) {
|
|||
*
|
||||
* Set the given qos function for the pad
|
||||
*/
|
||||
void gst_pad_set_qos_function(GstPad *pad,GstPadQoSFunction qos) {
|
||||
g_return_if_fail(pad != NULL);
|
||||
g_return_if_fail(GST_IS_PAD(pad));
|
||||
void
|
||||
gst_pad_set_qos_function (GstPad *pad,
|
||||
GstPadQoSFunction qos)
|
||||
{
|
||||
g_return_if_fail (pad != NULL);
|
||||
g_return_if_fail (GST_IS_PAD (pad));
|
||||
|
||||
pad->qosfunc = qos;
|
||||
}
|
||||
|
@ -207,7 +228,10 @@ void gst_pad_set_qos_function(GstPad *pad,GstPadQoSFunction qos) {
|
|||
*
|
||||
* pushes a buffer along a src pad
|
||||
*/
|
||||
void gst_pad_push(GstPad *pad,GstBuffer *buffer) {
|
||||
void
|
||||
gst_pad_push (GstPad *pad,
|
||||
GstBuffer *buffer)
|
||||
{
|
||||
g_return_if_fail(pad != NULL);
|
||||
g_return_if_fail(GST_IS_PAD(pad));
|
||||
g_return_if_fail(GST_PAD_CONNECTED(pad));
|
||||
|
@ -241,7 +265,9 @@ void gst_pad_push(GstPad *pad,GstBuffer *buffer) {
|
|||
*
|
||||
* Returns: the buffer that was pulled
|
||||
*/
|
||||
GstBuffer *gst_pad_pull(GstPad *pad) {
|
||||
GstBuffer*
|
||||
gst_pad_pull (GstPad *pad)
|
||||
{
|
||||
GstBuffer *buf;
|
||||
// GstElement *peerparent;
|
||||
// cothread_state *state;
|
||||
|
@ -280,20 +306,41 @@ GstBuffer *gst_pad_pull(GstPad *pad) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_pad_pull_region:
|
||||
* @pad: the pad to pull
|
||||
* @offset: the offset to pull
|
||||
* @size: the size to pull
|
||||
*
|
||||
* pulls a buffer along a sink pad with a given offset and size
|
||||
*
|
||||
* Returns: the buffer that was pulled
|
||||
*/
|
||||
GstBuffer*
|
||||
gst_pad_pull_region (GstPad *pad,
|
||||
gulong offset,
|
||||
gulong size)
|
||||
{
|
||||
// FIXME
|
||||
return gst_pad_pull (pad);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_pad_chain:
|
||||
* @pad: the pad to chain
|
||||
*
|
||||
* call the chain function of the given pad
|
||||
*/
|
||||
void gst_pad_chain(GstPad *pad) {
|
||||
g_return_if_fail(pad != NULL);
|
||||
g_return_if_fail(GST_IS_PAD(pad));
|
||||
g_return_if_fail(pad->peer != NULL);
|
||||
g_return_if_fail(pad->chainfunc != NULL);
|
||||
void
|
||||
gst_pad_chain (GstPad *pad)
|
||||
{
|
||||
g_return_if_fail (pad != NULL);
|
||||
g_return_if_fail (GST_IS_PAD (pad));
|
||||
g_return_if_fail (pad->peer != NULL);
|
||||
g_return_if_fail (pad->chainfunc != NULL);
|
||||
|
||||
if (pad->bufpen && pad->chainfunc)
|
||||
(pad->chainfunc)(pad,pad->bufpen);
|
||||
(pad->chainfunc) (pad,pad->bufpen);
|
||||
}
|
||||
|
||||
|
||||
|
@ -304,8 +351,9 @@ void gst_pad_chain(GstPad *pad) {
|
|||
*
|
||||
* pass the qos message downstream
|
||||
*/
|
||||
void gst_pad_handle_qos(GstPad *pad,
|
||||
glong qos_message)
|
||||
void
|
||||
gst_pad_handle_qos(GstPad *pad,
|
||||
glong qos_message)
|
||||
{
|
||||
GstElement *element;
|
||||
GList *pads;
|
||||
|
@ -314,19 +362,19 @@ void gst_pad_handle_qos(GstPad *pad,
|
|||
DEBUG("gst_pad_handle_qos(\"%s\",%08ld)\n", GST_ELEMENT(pad->parent)->name,qos_message);
|
||||
|
||||
if (pad->qosfunc) {
|
||||
(pad->qosfunc)(pad,qos_message);
|
||||
(pad->qosfunc) (pad,qos_message);
|
||||
}
|
||||
else {
|
||||
element = GST_ELEMENT(pad->peer->parent);
|
||||
element = GST_ELEMENT (pad->peer->parent);
|
||||
|
||||
pads = element->pads;
|
||||
DEBUG("gst_pad_handle_qos recurse(\"%s\",%08ld)\n", element->name,qos_message);
|
||||
while (pads) {
|
||||
target_pad = GST_PAD(pads->data);
|
||||
target_pad = GST_PAD (pads->data);
|
||||
if (target_pad->direction == GST_PAD_SINK) {
|
||||
gst_pad_handle_qos(target_pad, qos_message);
|
||||
gst_pad_handle_qos (target_pad, qos_message);
|
||||
}
|
||||
pads = g_list_next(pads);
|
||||
pads = g_list_next (pads);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -340,18 +388,20 @@ void gst_pad_handle_qos(GstPad *pad,
|
|||
*
|
||||
* disconnects the source pad from the sink pad
|
||||
*/
|
||||
void gst_pad_disconnect(GstPad *srcpad,GstPad *sinkpad) {
|
||||
|
||||
void
|
||||
gst_pad_disconnect (GstPad *srcpad,
|
||||
GstPad *sinkpad)
|
||||
{
|
||||
/* generic checks */
|
||||
g_return_if_fail(srcpad != NULL);
|
||||
g_return_if_fail(GST_IS_PAD(srcpad));
|
||||
g_return_if_fail(srcpad->peer != NULL);
|
||||
g_return_if_fail(sinkpad != NULL);
|
||||
g_return_if_fail(GST_IS_PAD(sinkpad));
|
||||
g_return_if_fail(sinkpad->peer != NULL);
|
||||
g_return_if_fail (srcpad != NULL);
|
||||
g_return_if_fail (GST_IS_PAD (srcpad));
|
||||
g_return_if_fail (srcpad->peer != NULL);
|
||||
g_return_if_fail (sinkpad != NULL);
|
||||
g_return_if_fail (GST_IS_PAD (sinkpad));
|
||||
g_return_if_fail (sinkpad->peer != NULL);
|
||||
|
||||
g_return_if_fail((srcpad->direction == GST_PAD_SRC) &&
|
||||
(sinkpad->direction == GST_PAD_SINK));
|
||||
g_return_if_fail ((srcpad->direction == GST_PAD_SRC) &&
|
||||
(sinkpad->direction == GST_PAD_SINK));
|
||||
|
||||
/* first clear peers */
|
||||
srcpad->peer = NULL;
|
||||
|
@ -368,7 +418,10 @@ void gst_pad_disconnect(GstPad *srcpad,GstPad *sinkpad) {
|
|||
*
|
||||
* connects the source pad to the sink pad
|
||||
*/
|
||||
void gst_pad_connect(GstPad *srcpad,GstPad *sinkpad) {
|
||||
void
|
||||
gst_pad_connect (GstPad *srcpad,
|
||||
GstPad *sinkpad)
|
||||
{
|
||||
GstPad *temppad;
|
||||
|
||||
/* generic checks */
|
||||
|
@ -410,13 +463,16 @@ void gst_pad_connect(GstPad *srcpad,GstPad *sinkpad) {
|
|||
*
|
||||
* sets the parent object of a pad.
|
||||
*/
|
||||
void gst_pad_set_parent(GstPad *pad,GstObject *parent) {
|
||||
g_return_if_fail(pad != NULL);
|
||||
g_return_if_fail(GST_IS_PAD(pad));
|
||||
g_return_if_fail(pad->parent == NULL);
|
||||
g_return_if_fail(parent != NULL);
|
||||
g_return_if_fail(GTK_IS_OBJECT(parent));
|
||||
g_return_if_fail((gpointer)pad != (gpointer)parent);
|
||||
void
|
||||
gst_pad_set_parent (GstPad *pad,
|
||||
GstObject *parent)
|
||||
{
|
||||
g_return_if_fail (pad != NULL);
|
||||
g_return_if_fail (GST_IS_PAD (pad));
|
||||
g_return_if_fail (pad->parent == NULL);
|
||||
g_return_if_fail (parent != NULL);
|
||||
g_return_if_fail (GTK_IS_OBJECT (parent));
|
||||
g_return_if_fail ((gpointer)pad != (gpointer)parent);
|
||||
|
||||
//g_print("set parent %s\n", gst_element_get_name(parent));
|
||||
|
||||
|
@ -430,13 +486,16 @@ void gst_pad_set_parent(GstPad *pad,GstObject *parent) {
|
|||
*
|
||||
* add a ghost parent object to a pad.
|
||||
*/
|
||||
void gst_pad_add_ghost_parent(GstPad *pad,GstObject *parent) {
|
||||
g_return_if_fail(pad != NULL);
|
||||
g_return_if_fail(GST_IS_PAD(pad));
|
||||
g_return_if_fail(parent != NULL);
|
||||
g_return_if_fail(GTK_IS_OBJECT(parent));
|
||||
void
|
||||
gst_pad_add_ghost_parent (GstPad *pad,
|
||||
GstObject *parent)
|
||||
{
|
||||
g_return_if_fail (pad != NULL);
|
||||
g_return_if_fail (GST_IS_PAD (pad));
|
||||
g_return_if_fail (parent != NULL);
|
||||
g_return_if_fail (GTK_IS_OBJECT (parent));
|
||||
|
||||
pad->ghostparents = g_list_prepend(pad->ghostparents,parent);
|
||||
pad->ghostparents = g_list_prepend (pad->ghostparents, parent);
|
||||
}
|
||||
|
||||
|
||||
|
@ -447,13 +506,16 @@ void gst_pad_add_ghost_parent(GstPad *pad,GstObject *parent) {
|
|||
*
|
||||
* remove a ghost parent object from a pad.
|
||||
*/
|
||||
void gst_pad_remove_ghost_parent(GstPad *pad,GstObject *parent) {
|
||||
g_return_if_fail(pad != NULL);
|
||||
g_return_if_fail(GST_IS_PAD(pad));
|
||||
g_return_if_fail(parent != NULL);
|
||||
g_return_if_fail(GTK_IS_OBJECT(parent));
|
||||
void
|
||||
gst_pad_remove_ghost_parent (GstPad *pad,
|
||||
GstObject *parent)
|
||||
{
|
||||
g_return_if_fail (pad != NULL);
|
||||
g_return_if_fail (GST_IS_PAD (pad));
|
||||
g_return_if_fail (parent != NULL);
|
||||
g_return_if_fail (GTK_IS_OBJECT (parent));
|
||||
|
||||
pad->ghostparents = g_list_remove(pad->ghostparents,parent);
|
||||
pad->ghostparents = g_list_remove (pad->ghostparents, parent);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -464,9 +526,11 @@ void gst_pad_remove_ghost_parent(GstPad *pad,GstObject *parent) {
|
|||
*
|
||||
* Returns: the parent object
|
||||
*/
|
||||
GstObject *gst_pad_get_parent(GstPad *pad) {
|
||||
g_return_val_if_fail(pad != NULL, NULL);
|
||||
g_return_val_if_fail(GST_IS_PAD(pad), NULL);
|
||||
GstObject*
|
||||
gst_pad_get_parent (GstPad *pad)
|
||||
{
|
||||
g_return_val_if_fail (pad != NULL, NULL);
|
||||
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
|
||||
|
||||
return pad->parent;
|
||||
}
|
||||
|
@ -479,9 +543,11 @@ GstObject *gst_pad_get_parent(GstPad *pad) {
|
|||
*
|
||||
* Returns: a list of ghost parent objects
|
||||
*/
|
||||
GList *gst_pad_get_ghost_parents(GstPad *pad) {
|
||||
g_return_val_if_fail(pad != NULL, NULL);
|
||||
g_return_val_if_fail(GST_IS_PAD(pad), NULL);
|
||||
GList*
|
||||
gst_pad_get_ghost_parents (GstPad *pad)
|
||||
{
|
||||
g_return_val_if_fail (pad != NULL, NULL);
|
||||
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
|
||||
|
||||
return pad->ghostparents;
|
||||
}
|
||||
|
@ -494,9 +560,11 @@ GList *gst_pad_get_ghost_parents(GstPad *pad) {
|
|||
*
|
||||
* Returns: the type of this pad
|
||||
*/
|
||||
guint16 gst_pad_get_type_id(GstPad *pad) {
|
||||
g_return_val_if_fail(pad != NULL, 0);
|
||||
g_return_val_if_fail(GST_IS_PAD(pad), 0);
|
||||
guint16
|
||||
gst_pad_get_type_id (GstPad *pad)
|
||||
{
|
||||
g_return_val_if_fail (pad != NULL, 0);
|
||||
g_return_val_if_fail (GST_IS_PAD (pad), 0);
|
||||
|
||||
return pad->type;
|
||||
}
|
||||
|
@ -508,10 +576,13 @@ guint16 gst_pad_get_type_id(GstPad *pad) {
|
|||
*
|
||||
* set the type of this pad
|
||||
*/
|
||||
void gst_pad_set_type_id(GstPad *pad,guint16 id) {
|
||||
g_return_if_fail(pad != NULL);
|
||||
g_return_if_fail(GST_IS_PAD(pad));
|
||||
g_return_if_fail(gst_type_find_by_id(id) != NULL);
|
||||
void
|
||||
gst_pad_set_type_id (GstPad *pad,
|
||||
guint16 id)
|
||||
{
|
||||
g_return_if_fail (pad != NULL);
|
||||
g_return_if_fail (GST_IS_PAD (pad));
|
||||
g_return_if_fail (gst_type_find_by_id (id) != NULL);
|
||||
|
||||
pad->type = id;
|
||||
}
|
||||
|
@ -524,21 +595,25 @@ void gst_pad_set_type_id(GstPad *pad,guint16 id) {
|
|||
*
|
||||
* Returns: the peer pad
|
||||
*/
|
||||
GstPad *gst_pad_get_peer(GstPad *pad) {
|
||||
g_return_val_if_fail(pad != NULL, NULL);
|
||||
g_return_val_if_fail(GST_IS_PAD(pad), NULL);
|
||||
GstPad*
|
||||
gst_pad_get_peer (GstPad *pad)
|
||||
{
|
||||
g_return_val_if_fail (pad != NULL, NULL);
|
||||
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
|
||||
|
||||
return pad->peer;
|
||||
}
|
||||
|
||||
static void gst_pad_real_destroy(GtkObject *object) {
|
||||
GstPad *pad = GST_PAD(object);
|
||||
static void
|
||||
gst_pad_real_destroy (GtkObject *object)
|
||||
{
|
||||
GstPad *pad = GST_PAD (object);
|
||||
|
||||
// g_print("in gst_pad_real_destroy()\n");
|
||||
|
||||
if (pad->name)
|
||||
g_free(pad->name);
|
||||
g_list_free(pad->ghostparents);
|
||||
g_free (pad->name);
|
||||
g_list_free (pad->ghostparents);
|
||||
}
|
||||
|
||||
|
||||
|
@ -551,7 +626,11 @@ static void gst_pad_real_destroy(GtkObject *object) {
|
|||
* Read the pad definition from the XML node and connect the given pad
|
||||
* in element to a pad of an element in the hashtable.
|
||||
*/
|
||||
void gst_pad_load_and_connect(xmlNodePtr parent, GstObject *element, GHashTable *elements) {
|
||||
void
|
||||
gst_pad_load_and_connect (xmlNodePtr parent,
|
||||
GstObject *element,
|
||||
GHashTable *elements)
|
||||
{
|
||||
xmlNodePtr field = parent->childs;
|
||||
GstPad *pad = NULL, *targetpad;
|
||||
guchar *peer = NULL;
|
||||
|
@ -599,7 +678,10 @@ cleanup:
|
|||
*
|
||||
* Returns: the xml representation of the pad
|
||||
*/
|
||||
xmlNodePtr gst_pad_save_thyself(GstPad *pad,xmlNodePtr parent) {
|
||||
xmlNodePtr
|
||||
gst_pad_save_thyself (GstPad *pad,
|
||||
xmlNodePtr parent)
|
||||
{
|
||||
GstPad *peer;
|
||||
|
||||
xmlNewChild(parent,NULL,"name",pad->name);
|
||||
|
@ -626,7 +708,11 @@ xmlNodePtr gst_pad_save_thyself(GstPad *pad,xmlNodePtr parent) {
|
|||
*
|
||||
* Returns: the xml representation of the pad
|
||||
*/
|
||||
xmlNodePtr gst_pad_ghost_save_thyself(GstPad *pad,GstElement *bin,xmlNodePtr parent) {
|
||||
xmlNodePtr
|
||||
gst_pad_ghost_save_thyself (GstPad *pad,
|
||||
GstElement *bin,
|
||||
xmlNodePtr parent)
|
||||
{
|
||||
xmlNodePtr self;
|
||||
|
||||
self = xmlNewChild(parent,NULL,"ghostpad",NULL);
|
||||
|
|
69
gst/gstpad.h
69
gst/gstpad.h
|
@ -32,15 +32,15 @@ extern "C" {
|
|||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#define GST_TYPE_PAD (gst_pad_get_type())
|
||||
#define GST_PAD(obj) (GTK_CHECK_CAST((obj),GST_TYPE_PAD,GstPad))
|
||||
#define GST_PAD_CLASS(klass) (GTK_CHECK_CLASS_CAST((klass),GST_TYPE_PAD,GstPadClass))
|
||||
#define GST_IS_PAD(obj) (GTK_CHECK_TYPE((obj),GST_TYPE_PAD))
|
||||
#define GST_IS_PAD_CLASS(obj) (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_PAD))
|
||||
#define GST_TYPE_PAD (gst_pad_get_type ())
|
||||
#define GST_PAD(obj) (GTK_CHECK_CAST ((obj), GST_TYPE_PAD,GstPad))
|
||||
#define GST_PAD_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GST_TYPE_PAD,GstPadClass))
|
||||
#define GST_IS_PAD(obj) (GTK_CHECK_TYPE ((obj), GST_TYPE_PAD))
|
||||
#define GST_IS_PAD_CLASS(obj) (GTK_CHECK_CLASS_TYPE ((klass), GST_TYPE_PAD))
|
||||
|
||||
// quick test to see if the pad is connected
|
||||
#define GST_PAD_CONNECTED(pad) (pad && (pad)->peer != NULL)
|
||||
#define GST_PAD_CAN_PULL(pad) (pad && (pad)->pullfunc != NULL)
|
||||
#define GST_PAD_CONNECTED(pad) (pad && (pad)->peer != NULL)
|
||||
#define GST_PAD_CAN_PULL(pad) (pad && (pad)->pullfunc != NULL)
|
||||
|
||||
typedef struct _GstPad GstPad;
|
||||
typedef struct _GstPadClass GstPadClass;
|
||||
|
@ -59,9 +59,6 @@ typedef enum {
|
|||
GST_PAD_SINK,
|
||||
} GstPadDirection;
|
||||
|
||||
//typedef enum {
|
||||
//} GstPadFlags;
|
||||
|
||||
struct _GstPad {
|
||||
GstObject object;
|
||||
|
||||
|
@ -87,39 +84,41 @@ struct _GstPadClass {
|
|||
GstObjectClass parent_class;
|
||||
};
|
||||
|
||||
GtkType gst_pad_get_type(void);
|
||||
GstPad *gst_pad_new(gchar *name,GstPadDirection direction);
|
||||
void gst_pad_destroy(GstPad *pad);
|
||||
|
||||
GstPadDirection gst_pad_get_direction(GstPad *pad);
|
||||
void gst_pad_set_chain_function(GstPad *pad,GstPadChainFunction chain);
|
||||
void gst_pad_set_pull_function(GstPad *pad, GstPadPullFunction pull);
|
||||
void gst_pad_set_qos_function(GstPad *pad, GstPadQoSFunction qos);
|
||||
GtkType gst_pad_get_type (void);
|
||||
GstPad* gst_pad_new (gchar *name, GstPadDirection direction);
|
||||
#define gst_pad_destroy(pad) gst_object_destroy (GST_OBJECT (pad))
|
||||
|
||||
guint16 gst_pad_get_type_id(GstPad *pad);
|
||||
void gst_pad_set_type_id(GstPad *pad,guint16 id);
|
||||
GstPadDirection gst_pad_get_direction (GstPad *pad);
|
||||
|
||||
void gst_pad_set_name(GstPad *pad,gchar *name);
|
||||
gchar *gst_pad_get_name(GstPad *pad);
|
||||
#define gst_pad_destroy(pad) gst_object_destroy(GST_OBJECT(pad))
|
||||
void gst_pad_set_chain_function (GstPad *pad, GstPadChainFunction chain);
|
||||
void gst_pad_set_pull_function (GstPad *pad, GstPadPullFunction pull);
|
||||
void gst_pad_set_qos_function (GstPad *pad, GstPadQoSFunction qos);
|
||||
|
||||
void gst_pad_set_parent(GstPad *pad,GstObject *parent);
|
||||
void gst_pad_add_ghost_parent(GstPad *pad,GstObject *parent);
|
||||
void gst_pad_remove_ghost_parent(GstPad *pad,GstObject *parent);
|
||||
GstObject *gst_pad_get_parent(GstPad *pad);
|
||||
GList *gst_pad_get_ghost_parents(GstPad *pad);
|
||||
guint16 gst_pad_get_type_id (GstPad *pad);
|
||||
void gst_pad_set_type_id (GstPad *pad, guint16 id);
|
||||
|
||||
GstPad *gst_pad_get_peer(GstPad *pad);
|
||||
void gst_pad_set_name (GstPad *pad, const gchar *name);
|
||||
const gchar* gst_pad_get_name (GstPad *pad);
|
||||
|
||||
void gst_pad_connect(GstPad *srcpad,GstPad *sinkpad);
|
||||
void gst_pad_disconnect(GstPad *srcpad,GstPad *sinkpad);
|
||||
void gst_pad_set_parent (GstPad *pad, GstObject *parent);
|
||||
GstObject* gst_pad_get_parent (GstPad *pad);
|
||||
void gst_pad_add_ghost_parent (GstPad *pad, GstObject *parent);
|
||||
void gst_pad_remove_ghost_parent (GstPad *pad, GstObject *parent);
|
||||
GList* gst_pad_get_ghost_parents (GstPad *pad);
|
||||
|
||||
void gst_pad_push(GstPad *pad,GstBuffer *buffer);
|
||||
GstBuffer *gst_pad_pull(GstPad *pad);
|
||||
void gst_pad_handle_qos(GstPad *pad, glong qos_message);
|
||||
GstPad* gst_pad_get_peer (GstPad *pad);
|
||||
|
||||
xmlNodePtr gst_pad_save_thyself(GstPad *pad,xmlNodePtr parent);
|
||||
void gst_pad_load_and_connect(xmlNodePtr parent, GstObject *element, GHashTable *elements);
|
||||
void gst_pad_connect (GstPad *srcpad, GstPad *sinkpad);
|
||||
void gst_pad_disconnect (GstPad *srcpad, GstPad *sinkpad);
|
||||
|
||||
void gst_pad_push (GstPad *pad, GstBuffer *buffer);
|
||||
GstBuffer* gst_pad_pull (GstPad *pad);
|
||||
GstBuffer* gst_pad_pull_region (GstPad *pad, gulong offset, gulong size);
|
||||
void gst_pad_handle_qos (GstPad *pad, glong qos_message);
|
||||
|
||||
xmlNodePtr gst_pad_save_thyself (GstPad *pad, xmlNodePtr parent);
|
||||
void gst_pad_load_and_connect (xmlNodePtr parent, GstObject *element, GHashTable *elements);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -253,7 +253,7 @@ gboolean gst_plugin_load_absolute(gchar *name) {
|
|||
return TRUE;
|
||||
} else if (_gst_plugin_spew) {
|
||||
// if (strstr(g_module_error(),"No such") == NULL)
|
||||
gst_info("error loading plugin: %s, reasion: %s\n", name, g_module_error());
|
||||
gst_info("error loading plugin: %s, reason: %s\n", name, g_module_error());
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
|
|
@ -191,12 +191,13 @@ static GstElementStateReturn gst_thread_change_state(GstElement *element) {
|
|||
|
||||
if (pending == GST_STATE(element)) return GST_STATE_SUCCESS;
|
||||
|
||||
GST_FLAG_UNSET(thread,GST_THREAD_STATE_SPINNING);
|
||||
|
||||
if (GST_ELEMENT_CLASS(parent_class)->change_state)
|
||||
stateset = GST_ELEMENT_CLASS(parent_class)->change_state(element);
|
||||
|
||||
gst_info("gstthread: stateset %d %d %d\n", GST_STATE(element), stateset, GST_STATE_PENDING(element));
|
||||
|
||||
|
||||
switch (pending) {
|
||||
case GST_STATE_READY:
|
||||
if (!stateset) return FALSE;
|
||||
|
@ -229,7 +230,7 @@ static GstElementStateReturn gst_thread_change_state(GstElement *element) {
|
|||
case GST_STATE_PAUSED:
|
||||
gst_info("gstthread: pausing thread \"%s\"\n",
|
||||
gst_element_get_name(GST_ELEMENT(element)));
|
||||
GST_FLAG_UNSET(thread,GST_THREAD_STATE_SPINNING);
|
||||
//GST_FLAG_UNSET(thread,GST_THREAD_STATE_SPINNING);
|
||||
gst_thread_signal_thread(thread);
|
||||
break;
|
||||
case GST_STATE_NULL:
|
||||
|
|
|
@ -73,7 +73,7 @@ guint16 gst_type_register(GstTypeFactory *factory) {
|
|||
|
||||
g_return_val_if_fail(factory != NULL, 0);
|
||||
|
||||
g_print("gsttype: type register %s\n", factory->mime);
|
||||
//g_print("gsttype: type register %s\n", factory->mime);
|
||||
id = gst_type_find_by_mime(factory->mime);
|
||||
if (!id) {
|
||||
type = g_new0(GstType, 1);
|
||||
|
|
|
@ -15,8 +15,6 @@ gstmediaplay_SOURCES = \
|
|||
gststatusarea.c gststatusarea.h \
|
||||
callbacks.c callbacks.h
|
||||
|
||||
# interface.c interface.h
|
||||
|
||||
CFLAGS += -O2 -Wall -DDATADIR=\""$(gladedir)/"\"
|
||||
|
||||
gstmediaplay_CFLAGS = $(shell gnome-config --cflags gnomeui) $(shell libglade-config --cflags gnome) \
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#include "gstplay.h"
|
||||
#include "callbacks.h"
|
||||
#include "interface.h"
|
||||
|
||||
GtkFileSelection *open_file_selection;
|
||||
|
||||
|
@ -54,19 +53,6 @@ on_open2_activate (GtkMenuItem *menuitem,
|
|||
open_file_selection = GTK_FILE_SELECTION(glade_xml_get_widget(xml, "fileselection1"));
|
||||
}
|
||||
|
||||
void
|
||||
on_hscale1_value_changed (GtkAdjustment *adj,
|
||||
gpointer user_data)
|
||||
{
|
||||
//int size = gst_util_get_int_arg(GTK_OBJECT(src),"size");
|
||||
|
||||
//gtk_object_set(GTK_OBJECT(src),"offset",(int)(adj->value*size/100.0),NULL);
|
||||
|
||||
//if (state != GSTPLAY_PLAYING) {
|
||||
// show_next_picture();
|
||||
//}
|
||||
}
|
||||
|
||||
void on_about_activate(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
GladeXML *xml;
|
||||
|
|
|
@ -9,14 +9,18 @@
|
|||
#include "gstmediaplay.h"
|
||||
#include "callbacks.h"
|
||||
|
||||
static void gst_media_play_class_init (GstMediaPlayClass *klass);
|
||||
static void gst_media_play_init (GstMediaPlay *play);
|
||||
static void gst_media_play_class_init (GstMediaPlayClass *klass);
|
||||
static void gst_media_play_init (GstMediaPlay *play);
|
||||
|
||||
static void gst_media_play_set_arg (GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_media_play_get_arg (GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_media_play_set_arg (GtkObject *object,GtkArg *arg,guint id);
|
||||
static void gst_media_play_get_arg (GtkObject *object,GtkArg *arg,guint id);
|
||||
|
||||
static void update_buttons (GstMediaPlay *mplay, GstPlayState state);
|
||||
static void update_slider (GtkAdjustment *adjustment, gfloat value);
|
||||
static void gst_media_play_frame_displayed (GstPlay *play, GstMediaPlay *mplay);
|
||||
static void gst_media_play_state_changed (GstPlay *play, GstPlayState state, GstMediaPlay *mplay);
|
||||
static void gst_media_play_slider_changed (GtkAdjustment *adj, GstMediaPlay *mplay);
|
||||
|
||||
static void update_buttons (GstMediaPlay *mplay, GstPlayState state);
|
||||
static void update_slider (GstMediaPlay *mplay, GtkAdjustment *adjustment, gfloat value);
|
||||
|
||||
/* signals and args */
|
||||
enum {
|
||||
|
@ -46,7 +50,7 @@ static GtkTargetEntry target_table[] = {
|
|||
};
|
||||
|
||||
static GtkObject *parent_class = NULL;
|
||||
static guint gst_media_play_signals[LAST_SIGNAL] = { 0 };
|
||||
//static guint gst_media_play_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
GtkType
|
||||
gst_media_play_get_type(void)
|
||||
|
@ -125,6 +129,20 @@ gst_media_play_init(GstMediaPlay *mplay)
|
|||
/* load the interface */
|
||||
mplay->xml = glade_xml_new (DATADIR "gstmediaplay.glade", "gstplay");
|
||||
|
||||
mplay->slider = glade_xml_get_widget(mplay->xml, "slider");
|
||||
{
|
||||
GtkArg arg;
|
||||
GtkRange *range;
|
||||
|
||||
arg.name = "adjustment";
|
||||
gtk_object_getv (GTK_OBJECT (mplay->slider), 1, &arg);
|
||||
range = GTK_RANGE (GTK_VALUE_POINTER (arg));
|
||||
mplay->adjustment = gtk_range_get_adjustment (range);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (mplay->adjustment), "value_changed",
|
||||
GTK_SIGNAL_FUNC (gst_media_play_slider_changed), mplay);
|
||||
}
|
||||
|
||||
mplay->play_button = glade_xml_get_widget (mplay->xml, "toggle_play");
|
||||
mplay->pause_button = glade_xml_get_widget (mplay->xml, "toggle_pause");
|
||||
mplay->stop_button = glade_xml_get_widget (mplay->xml, "toggle_stop");
|
||||
|
@ -140,6 +158,18 @@ gst_media_play_init(GstMediaPlay *mplay)
|
|||
|
||||
mplay->play = gst_play_new();
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (mplay->play), "frame_displayed",
|
||||
GTK_SIGNAL_FUNC (gst_media_play_frame_displayed),
|
||||
mplay);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (mplay->play), "audio_played",
|
||||
GTK_SIGNAL_FUNC (gst_media_play_frame_displayed),
|
||||
mplay);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (mplay->play), "playing_state_changed",
|
||||
GTK_SIGNAL_FUNC (gst_media_play_state_changed),
|
||||
mplay);
|
||||
|
||||
gnome_dock_set_client_area (GNOME_DOCK (glade_xml_get_widget(mplay->xml, "dock1")),
|
||||
GTK_WIDGET (mplay->play));
|
||||
|
||||
|
@ -160,6 +190,7 @@ gst_media_play_init(GstMediaPlay *mplay)
|
|||
GTK_WIDGET (mplay->status));
|
||||
gtk_widget_show (GTK_WIDGET (mplay->status));
|
||||
|
||||
mplay->last_time = 0;
|
||||
}
|
||||
|
||||
GstMediaPlay *
|
||||
|
@ -168,6 +199,17 @@ gst_media_play_new ()
|
|||
return GST_MEDIA_PLAY (gtk_type_new (GST_TYPE_MEDIA_PLAY));
|
||||
}
|
||||
|
||||
static void
|
||||
gst_media_play_update_status_area (GstMediaPlay *play,
|
||||
gulong current_time,
|
||||
gulong total_time)
|
||||
{
|
||||
gst_status_area_set_playtime (play->status,
|
||||
g_strdup_printf("%02lu:%02lu / %02lu:%02lu",
|
||||
current_time/60, current_time%60,
|
||||
total_time/60, total_time%60));
|
||||
}
|
||||
|
||||
void
|
||||
gst_media_play_start_uri (GstMediaPlay *play,
|
||||
const guchar *uri)
|
||||
|
@ -179,9 +221,12 @@ gst_media_play_start_uri (GstMediaPlay *play,
|
|||
|
||||
if (uri != NULL) {
|
||||
ret = gst_play_set_uri (play->play, uri);
|
||||
gst_status_area_set_state (play->status, GST_STATUS_AREA_STATE_PLAYING);
|
||||
|
||||
if (!gst_play_media_can_seek (play->play)) {
|
||||
gtk_widget_set_sensitive (play->slider, FALSE);
|
||||
}
|
||||
|
||||
gst_play_play (play->play);
|
||||
update_buttons (play, GST_PLAY_STATE (play->play));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -216,31 +261,110 @@ gst_media_play_get_arg (GtkObject *object,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gst_media_play_state_changed (GstPlay *play,
|
||||
GstPlayState state,
|
||||
GstMediaPlay *mplay)
|
||||
{
|
||||
GstStatusAreaState area_state;
|
||||
|
||||
g_return_if_fail (GST_IS_PLAY (play));
|
||||
g_return_if_fail (GST_IS_MEDIA_PLAY (mplay));
|
||||
|
||||
update_buttons (mplay, state);
|
||||
|
||||
switch (state) {
|
||||
case GST_PLAY_STOPPED:
|
||||
area_state = GST_STATUS_AREA_STATE_STOPPED;
|
||||
break;
|
||||
case GST_PLAY_PLAYING:
|
||||
area_state = GST_STATUS_AREA_STATE_PLAYING;
|
||||
break;
|
||||
case GST_PLAY_PAUSED:
|
||||
area_state = GST_STATUS_AREA_STATE_PAUSED;
|
||||
break;
|
||||
default:
|
||||
area_state = GST_STATUS_AREA_STATE_INIT;
|
||||
}
|
||||
gst_status_area_set_state (mplay->status, area_state);
|
||||
}
|
||||
|
||||
void
|
||||
on_gst_media_play_destroy (GtkWidget *widget,
|
||||
GstMediaPlay *mplay)
|
||||
{
|
||||
gst_main_quit ();
|
||||
}
|
||||
|
||||
gint
|
||||
on_gst_media_play_delete_event (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
GstMediaPlay *mplay)
|
||||
{
|
||||
gdk_threads_leave ();
|
||||
gst_play_stop (mplay->play);
|
||||
gdk_threads_enter ();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_media_play_frame_displayed (GstPlay *play,
|
||||
GstMediaPlay *mplay)
|
||||
{
|
||||
gulong current_time;
|
||||
gulong total_time;
|
||||
gulong size, current_offset;
|
||||
|
||||
g_return_if_fail (GST_IS_PLAY (play));
|
||||
g_return_if_fail (GST_IS_MEDIA_PLAY (mplay));
|
||||
|
||||
current_time = gst_play_get_media_current_time (play);
|
||||
total_time = gst_play_get_media_total_time (play);
|
||||
size = gst_play_get_media_size (play);
|
||||
current_offset = gst_play_get_media_offset (play);
|
||||
|
||||
if (current_time != mplay->last_time) {
|
||||
gst_media_play_update_status_area (mplay, current_time, total_time);
|
||||
update_slider (mplay, mplay->adjustment, current_offset*100.0/size);
|
||||
mplay->last_time = current_time;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gst_media_play_slider_changed (GtkAdjustment *adj,
|
||||
GstMediaPlay *mplay)
|
||||
{
|
||||
gulong size;
|
||||
|
||||
g_return_if_fail (GST_IS_MEDIA_PLAY (mplay));
|
||||
|
||||
size = gst_play_get_media_size (mplay->play);
|
||||
|
||||
gst_play_media_seek(mplay->play, (int)(adj->value*size/100.0));
|
||||
}
|
||||
|
||||
void
|
||||
on_toggle_play_toggled (GtkToggleButton *togglebutton,
|
||||
GstMediaPlay *play)
|
||||
{
|
||||
gst_status_area_set_state (play->status, GST_STATUS_AREA_STATE_PLAYING);
|
||||
gst_play_play (play->play);
|
||||
update_buttons (play, GST_PLAY_STATE (play->play));
|
||||
update_buttons (play, GST_PLAY_STATE(play->play));
|
||||
}
|
||||
|
||||
void
|
||||
on_toggle_pause_toggled (GtkToggleButton *togglebutton,
|
||||
GstMediaPlay *play)
|
||||
{
|
||||
gst_status_area_set_state (play->status, GST_STATUS_AREA_STATE_PAUSED);
|
||||
gst_play_pause (play->play);
|
||||
update_buttons (play, GST_PLAY_STATE (play->play));
|
||||
update_buttons (play, GST_PLAY_STATE(play->play));
|
||||
}
|
||||
|
||||
void
|
||||
on_toggle_stop_toggled (GtkToggleButton *togglebutton,
|
||||
GstMediaPlay *play)
|
||||
{
|
||||
gst_status_area_set_state (play->status, GST_STATUS_AREA_STATE_STOPPED);
|
||||
gst_play_stop (play->play);
|
||||
update_buttons (play, GST_PLAY_STATE (play->play));
|
||||
update_buttons (play, GST_PLAY_STATE(play->play));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -283,15 +407,16 @@ update_buttons (GstMediaPlay *mplay,
|
|||
}
|
||||
|
||||
static void
|
||||
update_slider (GtkAdjustment *adjustment,
|
||||
update_slider (GstMediaPlay *mplay,
|
||||
GtkAdjustment *adjustment,
|
||||
gfloat value)
|
||||
{
|
||||
gtk_signal_handler_block_by_func (GTK_OBJECT (adjustment),
|
||||
GTK_SIGNAL_FUNC (on_hscale1_value_changed),
|
||||
NULL);
|
||||
GTK_SIGNAL_FUNC (gst_media_play_slider_changed),
|
||||
mplay);
|
||||
gtk_adjustment_set_value (adjustment, value);
|
||||
gtk_signal_handler_unblock_by_func (GTK_OBJECT (adjustment),
|
||||
GTK_SIGNAL_FUNC (on_hscale1_value_changed),
|
||||
NULL);
|
||||
GTK_SIGNAL_FUNC (gst_media_play_slider_changed),
|
||||
mplay);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
<name>gstplay</name>
|
||||
<signal>
|
||||
<name>delete_event</name>
|
||||
<handler>on_gstplay_delete_event</handler>
|
||||
<last_modification_time>Sun, 06 Aug 2000 11:30:22 GMT</last_modification_time>
|
||||
<handler>on_gst_media_play_delete_event</handler>
|
||||
<last_modification_time>Wed, 01 Nov 2000 00:38:57 GMT</last_modification_time>
|
||||
</signal>
|
||||
<signal>
|
||||
<name>destroy</name>
|
||||
<handler>on_gstplay_destroy</handler>
|
||||
<last_modification_time>Sun, 06 Aug 2000 11:34:58 GMT</last_modification_time>
|
||||
<handler>on_gst_media_play_destroy</handler>
|
||||
<last_modification_time>Wed, 01 Nov 2000 00:39:03 GMT</last_modification_time>
|
||||
</signal>
|
||||
<title>Gstplay</title>
|
||||
<type>GTK_WINDOW_TOPLEVEL</type>
|
||||
|
|
|
@ -37,6 +37,12 @@ struct _GstMediaPlay {
|
|||
GtkWidget *stop_button;
|
||||
|
||||
GstStatusArea *status;
|
||||
|
||||
// the slider
|
||||
GtkAdjustment *adjustment;
|
||||
GtkWidget *slider;
|
||||
|
||||
gulong last_time;
|
||||
};
|
||||
|
||||
struct _GstMediaPlayClass {
|
||||
|
|
|
@ -82,12 +82,12 @@ gst_play_class_init (GstPlayClass *klass)
|
|||
gst_play_signals[SIGNAL_FRAME_DISPLAYED] =
|
||||
gtk_signal_new ("frame_displayed",GTK_RUN_FIRST,object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GstPlayClass,frame_displayed),
|
||||
gtk_marshal_NONE__INT,GTK_TYPE_NONE,0);
|
||||
gtk_marshal_NONE__NONE,GTK_TYPE_NONE,0);
|
||||
|
||||
gst_play_signals[SIGNAL_AUDIO_PLAYED] =
|
||||
gtk_signal_new ("audio_played",GTK_RUN_FIRST,object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GstPlayClass,audio_played),
|
||||
gtk_marshal_NONE__INT,GTK_TYPE_NONE,0);
|
||||
gtk_marshal_NONE__NONE,GTK_TYPE_NONE,0);
|
||||
|
||||
gtk_object_class_add_signals (object_class,gst_play_signals,LAST_SIGNAL);
|
||||
gtk_object_add_arg_type ("GstPlay::uri",GTK_TYPE_STRING,
|
||||
|
@ -116,39 +116,43 @@ static void
|
|||
gst_play_init (GstPlay *play)
|
||||
{
|
||||
|
||||
GstPlayPrivate *private = g_new0 (GstPlayPrivate, 1);
|
||||
GstPlayPrivate *priv = g_new0 (GstPlayPrivate, 1);
|
||||
|
||||
play->private = private;
|
||||
play->priv = priv;
|
||||
|
||||
/* create a new bin to hold the elements */
|
||||
private->thread = gst_thread_new ("main_thread");
|
||||
g_assert (private->thread != NULL);
|
||||
private->pipeline = gst_pipeline_new ("main_pipeline");
|
||||
g_assert (private->pipeline != NULL);
|
||||
priv->thread = gst_thread_new ("main_thread");
|
||||
g_assert (priv->thread != NULL);
|
||||
priv->pipeline = gst_pipeline_new ("main_pipeline");
|
||||
g_assert (priv->pipeline != NULL);
|
||||
|
||||
/* and an audio sink */
|
||||
private->audio_play = gst_elementfactory_make ("audiosink","play_audio");
|
||||
g_return_if_fail (private->audio_play != NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (private->audio_play), "handoff",
|
||||
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",
|
||||
GTK_SIGNAL_FUNC (gst_play_audio_handoff), play);
|
||||
|
||||
/* and a video sink */
|
||||
private->video_show = gst_elementfactory_make ("videosink","show");
|
||||
g_return_if_fail (private->video_show != NULL);
|
||||
gtk_object_set (GTK_OBJECT (private->video_show),"xv_enabled",FALSE,NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (private->video_show), "frame_displayed",
|
||||
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",
|
||||
GTK_SIGNAL_FUNC (gst_play_frame_displayed), play);
|
||||
|
||||
gst_pipeline_add_sink (GST_PIPELINE (private->pipeline), private->audio_play);
|
||||
gst_pipeline_add_sink (GST_PIPELINE (private->pipeline), private->video_show);
|
||||
gst_pipeline_add_sink (GST_PIPELINE (priv->pipeline), priv->audio_play);
|
||||
gst_pipeline_add_sink (GST_PIPELINE (priv->pipeline), priv->video_show);
|
||||
|
||||
gst_bin_add (GST_BIN (private->thread), private->pipeline);
|
||||
gst_bin_add (GST_BIN (priv->thread), priv->pipeline);
|
||||
|
||||
play->state = GST_PLAY_STOPPED;
|
||||
private->src = NULL;
|
||||
play->flags = 0;
|
||||
private->muted = FALSE;
|
||||
private->uri = NULL;
|
||||
|
||||
priv->src = NULL;
|
||||
priv->muted = FALSE;
|
||||
priv->can_seek = TRUE;
|
||||
priv->uri = NULL;
|
||||
priv->offset_element = NULL;
|
||||
priv->bit_rate_element = NULL;
|
||||
}
|
||||
|
||||
GstPlay *
|
||||
|
@ -180,40 +184,90 @@ gst_play_audio_handoff (GstElement *element,
|
|||
NULL);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
GstPlayReturn
|
||||
gst_play_set_uri (GstPlay *play,
|
||||
const guchar *uri)
|
||||
{
|
||||
GstPlayPrivate *private;
|
||||
GstPlayPrivate *priv;
|
||||
|
||||
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);
|
||||
|
||||
private = (GstPlayPrivate *)play->private;
|
||||
priv = (GstPlayPrivate *)play->priv;
|
||||
|
||||
if (private->src) {
|
||||
if (priv->src) {
|
||||
}
|
||||
|
||||
if (private->uri) g_free (private->uri);
|
||||
if (priv->uri) g_free (priv->uri);
|
||||
|
||||
private->uri = g_strdup (uri);
|
||||
priv->uri = g_strdup (uri);
|
||||
|
||||
private->src = gst_elementfactory_make ("disksrc", "disk_src");
|
||||
g_return_val_if_fail (private->src != NULL, -1);
|
||||
gtk_object_set (GTK_OBJECT (private->src),"location",uri,NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (private->src), "eos", GTK_SIGNAL_FUNC (gst_play_eos), play);
|
||||
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);
|
||||
|
||||
gst_pipeline_add_src (GST_PIPELINE (private->pipeline),GST_ELEMENT (private->src));
|
||||
gtk_signal_connect (GTK_OBJECT (priv->pipeline), "object_added", gst_play_object_added, play);
|
||||
|
||||
if (!gst_pipeline_autoplug (GST_PIPELINE (private->pipeline))) {
|
||||
gst_pipeline_add_src (GST_PIPELINE (priv->pipeline),GST_ELEMENT (priv->src));
|
||||
|
||||
if (!gst_pipeline_autoplug (GST_PIPELINE (priv->pipeline))) {
|
||||
return GST_PLAY_UNKNOWN_MEDIA;
|
||||
}
|
||||
|
||||
if (GST_PAD_CONNECTED (gst_element_get_pad (private->video_show, "sink"))) {
|
||||
if (GST_PAD_CONNECTED (gst_element_get_pad (priv->video_show, "sink"))) {
|
||||
play->flags |= GST_PLAY_TYPE_VIDEO;
|
||||
}
|
||||
if (GST_PAD_CONNECTED (gst_element_get_pad (private->audio_play, "sink"))) {
|
||||
if (GST_PAD_CONNECTED (gst_element_get_pad (priv->audio_play, "sink"))) {
|
||||
play->flags |= GST_PLAY_TYPE_AUDIO;
|
||||
}
|
||||
|
||||
|
@ -225,14 +279,14 @@ gst_play_realize (GtkWidget *widget)
|
|||
{
|
||||
GstPlay *play;
|
||||
GtkWidget *video_widget;
|
||||
GstPlayPrivate *private;
|
||||
GstPlayPrivate *priv;
|
||||
|
||||
g_return_if_fail (GST_IS_PLAY (widget));
|
||||
|
||||
play = GST_PLAY (widget);
|
||||
private = (GstPlayPrivate *)play->private;
|
||||
priv = (GstPlayPrivate *)play->priv;
|
||||
|
||||
video_widget = gst_util_get_widget_arg (GTK_OBJECT (private->video_show),"widget");
|
||||
video_widget = gst_util_get_widget_arg (GTK_OBJECT (priv->video_show),"widget");
|
||||
|
||||
if (video_widget) {
|
||||
gtk_container_add (GTK_CONTAINER (widget), video_widget);
|
||||
|
@ -247,18 +301,18 @@ gst_play_realize (GtkWidget *widget)
|
|||
void
|
||||
gst_play_play (GstPlay *play)
|
||||
{
|
||||
GstPlayPrivate *private;
|
||||
GstPlayPrivate *priv;
|
||||
|
||||
g_return_if_fail (play != NULL);
|
||||
g_return_if_fail (GST_IS_PLAY (play));
|
||||
|
||||
private = (GstPlayPrivate *)play->private;
|
||||
priv = (GstPlayPrivate *)play->priv;
|
||||
|
||||
if (play->state == GST_PLAY_PLAYING) return;
|
||||
|
||||
if (play->state == GST_PLAY_STOPPED)
|
||||
gst_element_set_state (GST_ELEMENT (private->thread),GST_STATE_READY);
|
||||
gst_element_set_state (GST_ELEMENT (private->thread),GST_STATE_PLAYING);
|
||||
gst_element_set_state (GST_ELEMENT (priv->thread),GST_STATE_READY);
|
||||
gst_element_set_state (GST_ELEMENT (priv->thread),GST_STATE_PLAYING);
|
||||
|
||||
play->state = GST_PLAY_PLAYING;
|
||||
|
||||
|
@ -269,16 +323,16 @@ gst_play_play (GstPlay *play)
|
|||
void
|
||||
gst_play_pause (GstPlay *play)
|
||||
{
|
||||
GstPlayPrivate *private;
|
||||
GstPlayPrivate *priv;
|
||||
|
||||
g_return_if_fail (play != NULL);
|
||||
g_return_if_fail (GST_IS_PLAY (play));
|
||||
|
||||
private = (GstPlayPrivate *)play->private;
|
||||
priv = (GstPlayPrivate *)play->priv;
|
||||
|
||||
if (play->state == GST_PLAY_PAUSED) return;
|
||||
if (play->state != GST_PLAY_PLAYING) return;
|
||||
|
||||
gst_element_set_state (GST_ELEMENT (private->thread),GST_STATE_PAUSED);
|
||||
gst_element_set_state (GST_ELEMENT (priv->thread),GST_STATE_PAUSED);
|
||||
|
||||
play->state = GST_PLAY_PAUSED;
|
||||
|
||||
|
@ -289,17 +343,17 @@ gst_play_pause (GstPlay *play)
|
|||
void
|
||||
gst_play_stop (GstPlay *play)
|
||||
{
|
||||
GstPlayPrivate *private;
|
||||
GstPlayPrivate *priv;
|
||||
|
||||
g_return_if_fail (play != NULL);
|
||||
g_return_if_fail (GST_IS_PLAY (play));
|
||||
|
||||
if (play->state == GST_PLAY_STOPPED) return;
|
||||
|
||||
private = (GstPlayPrivate *)play->private;
|
||||
priv = (GstPlayPrivate *)play->priv;
|
||||
|
||||
gst_element_set_state (GST_ELEMENT (private->thread),GST_STATE_NULL);
|
||||
gtk_object_set (GTK_OBJECT (private->src),"offset",0,NULL);
|
||||
gst_element_set_state (GST_ELEMENT (priv->thread),GST_STATE_NULL);
|
||||
gtk_object_set (GTK_OBJECT (priv->src),"offset",0,NULL);
|
||||
|
||||
play->state = GST_PLAY_STOPPED;
|
||||
|
||||
|
@ -307,12 +361,116 @@ gst_play_stop (GstPlay *play)
|
|||
play->state);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gst_play_set_arg (GtkObject *object,
|
||||
GtkArg *arg,
|
||||
guint id)
|
||||
{
|
||||
GstPlay *play;
|
||||
|
||||
g_return_if_fail (object != NULL);
|
||||
g_return_if_fail (arg != NULL);
|
||||
|
||||
play = GST_PLAY (object);
|
||||
|
||||
switch (id) {
|
||||
|
@ -330,26 +488,29 @@ gst_play_get_arg (GtkObject *object,
|
|||
guint id)
|
||||
{
|
||||
GstPlay *play;
|
||||
GstPlayPrivate *private;
|
||||
GstPlayPrivate *priv;
|
||||
|
||||
g_return_if_fail (object != NULL);
|
||||
g_return_if_fail (arg != NULL);
|
||||
|
||||
play = GST_PLAY (object);
|
||||
private = (GstPlayPrivate *)play->private;
|
||||
priv = (GstPlayPrivate *)play->priv;
|
||||
|
||||
switch (id) {
|
||||
case ARG_URI:
|
||||
GTK_VALUE_STRING (*arg) = private->uri;
|
||||
GTK_VALUE_STRING (*arg) = priv->uri;
|
||||
break;
|
||||
case ARG_MUTE:
|
||||
GTK_VALUE_BOOL (*arg) = private->muted;
|
||||
GTK_VALUE_BOOL (*arg) = priv->muted;
|
||||
break;
|
||||
case ARG_STATE:
|
||||
GTK_VALUE_INT (*arg) = play->state;
|
||||
break;
|
||||
case ARG_MEDIA_SIZE:
|
||||
GTK_VALUE_LONG (*arg) = gst_util_get_long_arg (GTK_OBJECT (private->src), "size");
|
||||
GTK_VALUE_LONG (*arg) = gst_play_get_media_size(play);
|
||||
break;
|
||||
case ARG_MEDIA_OFFSET:
|
||||
GTK_VALUE_LONG (*arg) = gst_util_get_long_arg (GTK_OBJECT (private->src), "offset");
|
||||
GTK_VALUE_LONG (*arg) = gst_play_get_media_offset(play);
|
||||
break;
|
||||
case ARG_MEDIA_TOTAL_TIME:
|
||||
break;
|
||||
|
|
|
@ -45,7 +45,7 @@ struct _GstPlay {
|
|||
GstPlayState state;
|
||||
GstPlayMediaTypeFlags flags;
|
||||
|
||||
gpointer private;
|
||||
gpointer priv;
|
||||
};
|
||||
|
||||
#define GST_PLAY_STATE(play) ((play)->state)
|
||||
|
@ -78,6 +78,7 @@ void gst_play_mute (GstPlay *play, gboolean mute);
|
|||
/* information about the media stream */
|
||||
gulong gst_play_get_media_size (GstPlay *play);
|
||||
gulong gst_play_get_media_offset (GstPlay *play);
|
||||
gboolean gst_play_media_can_seek (GstPlay *play);
|
||||
void gst_play_media_seek (GstPlay *play, gulong offset);
|
||||
|
||||
gulong gst_play_get_media_total_time (GstPlay *play);
|
||||
|
|
|
@ -19,6 +19,10 @@ struct _GstPlayPrivate {
|
|||
|
||||
guchar *uri;
|
||||
gboolean muted;
|
||||
gboolean can_seek;
|
||||
|
||||
GstElement *offset_element;
|
||||
GstElement *bit_rate_element;
|
||||
};
|
||||
|
||||
#endif /* __GSTPLAY_PRIVATE_H__ */
|
||||
|
|
|
@ -28,7 +28,7 @@ enum {
|
|||
};
|
||||
|
||||
static GtkDrawingArea *parent_class = NULL;
|
||||
static guint gst_status_area_signals[LAST_SIGNAL] = { 0 };
|
||||
//static guint gst_status_area_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
GtkType
|
||||
gst_status_area_get_type (void)
|
||||
|
@ -159,10 +159,12 @@ gst_status_area_expose(GtkWidget *widget,
|
|||
8, 15, statustext);
|
||||
|
||||
if (status_area->playtime) {
|
||||
gint width = gdk_string_width (widget->style->font, status_area->playtime);
|
||||
|
||||
gdk_draw_string (widget->window,
|
||||
widget->style->font,
|
||||
widget->style->white_gc,
|
||||
widget->allocation.width-100, 15, status_area->playtime);
|
||||
widget->allocation.width-width-20, 15, status_area->playtime);
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
|
@ -192,6 +194,9 @@ gst_status_area_set_playtime (GstStatusArea *area,
|
|||
if (area->playtime) g_free (area->playtime);
|
||||
|
||||
area->playtime = g_strdup (time);
|
||||
|
||||
if (GTK_WIDGET_VISIBLE(area))
|
||||
gtk_widget_queue_draw(GTK_WIDGET(area));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
* DO NOT EDIT THIS FILE - it is generated by Glade.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gnome.h>
|
||||
|
||||
#include "callbacks.h"
|
||||
#include "interface.h"
|
||||
|
||||
extern GtkWidget *play_button;
|
||||
extern GtkWidget *pause_button;
|
||||
extern GtkWidget *stop_button;
|
||||
extern guchar statusline[];
|
||||
extern guchar *statustext;
|
||||
|
||||
void update_buttons(GstPlayState state)
|
||||
{
|
||||
gtk_signal_handler_block_by_func(GTK_OBJECT(play_button),
|
||||
GTK_SIGNAL_FUNC (on_toggle_play_toggled),
|
||||
NULL);
|
||||
gtk_signal_handler_block_by_func(GTK_OBJECT(pause_button),
|
||||
GTK_SIGNAL_FUNC (on_toggle_pause_toggled),
|
||||
NULL);
|
||||
gtk_signal_handler_block_by_func(GTK_OBJECT(stop_button),
|
||||
GTK_SIGNAL_FUNC (on_toggle_stop_toggled),
|
||||
NULL);
|
||||
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(play_button), FALSE);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pause_button), FALSE);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stop_button), FALSE);
|
||||
|
||||
if (state == GST_PLAY_PLAYING) {
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(play_button), TRUE);
|
||||
}
|
||||
else if (state == GST_PLAY_PAUSED) {
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pause_button), TRUE);
|
||||
}
|
||||
else if (state == GST_PLAY_STOPPED) {
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stop_button), TRUE);
|
||||
}
|
||||
|
||||
gtk_signal_handler_unblock_by_func(GTK_OBJECT(play_button),
|
||||
GTK_SIGNAL_FUNC (on_toggle_play_toggled),
|
||||
NULL);
|
||||
gtk_signal_handler_unblock_by_func(GTK_OBJECT(pause_button),
|
||||
GTK_SIGNAL_FUNC (on_toggle_pause_toggled),
|
||||
NULL);
|
||||
gtk_signal_handler_unblock_by_func(GTK_OBJECT(stop_button),
|
||||
GTK_SIGNAL_FUNC (on_toggle_stop_toggled),
|
||||
NULL);
|
||||
}
|
||||
|
||||
void update_slider(GtkAdjustment *adjustment, gfloat value)
|
||||
{
|
||||
gtk_signal_handler_block_by_func(GTK_OBJECT(adjustment),
|
||||
GTK_SIGNAL_FUNC (on_hscale1_value_changed),
|
||||
NULL);
|
||||
gtk_adjustment_set_value(adjustment, value);
|
||||
gtk_signal_handler_unblock_by_func(GTK_OBJECT(adjustment),
|
||||
GTK_SIGNAL_FUNC (on_hscale1_value_changed),
|
||||
NULL);
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
/*
|
||||
* DO NOT EDIT THIS FILE - it is generated by Glade.
|
||||
*/
|
||||
|
||||
#include "gstplay.h"
|
||||
|
||||
void update_status_area(GtkWidget *area);
|
||||
void update_slider(GtkAdjustment *adjustment, gfloat value);
|
||||
void update_buttons(GstPlayState state);
|
Loading…
Reference in a new issue