mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-29 15:22:11 +02:00
API: make "state" into a property
This commit is contained in:
31
lib/gst/clapper/gstclapper.c
vendored
31
lib/gst/clapper/gstclapper.c
vendored
@@ -50,6 +50,7 @@
|
||||
GST_DEBUG_CATEGORY_STATIC (gst_clapper_debug);
|
||||
#define GST_CAT_DEFAULT gst_clapper_debug
|
||||
|
||||
#define DEFAULT_STATE GST_CLAPPER_STATE_STOPPED
|
||||
#define DEFAULT_URI NULL
|
||||
#define DEFAULT_POSITION GST_CLOCK_TIME_NONE
|
||||
#define DEFAULT_DURATION GST_CLOCK_TIME_NONE
|
||||
@@ -75,6 +76,7 @@ enum
|
||||
PROP_0,
|
||||
PROP_VIDEO_RENDERER,
|
||||
PROP_SIGNAL_DISPATCHER,
|
||||
PROP_STATE,
|
||||
PROP_URI,
|
||||
PROP_SUBURI,
|
||||
PROP_POSITION,
|
||||
@@ -268,6 +270,7 @@ gst_clapper_init (GstClapper * self)
|
||||
self->last_seek_time = GST_CLOCK_TIME_NONE;
|
||||
self->inhibit_sigs = FALSE;
|
||||
self->needs_info_update = FALSE;
|
||||
self->app_state = GST_CLAPPER_STATE_STOPPED;
|
||||
|
||||
GST_TRACE_OBJECT (self, "Initialized");
|
||||
}
|
||||
@@ -297,6 +300,11 @@ gst_clapper_class_init (GstClapperClass * klass)
|
||||
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
param_specs[PROP_STATE] =
|
||||
g_param_spec_enum ("state", "Clapper State", "Current player state",
|
||||
GST_TYPE_CLAPPER_STATE, DEFAULT_STATE, G_PARAM_READABLE |
|
||||
G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
param_specs[PROP_URI] = g_param_spec_string ("uri", "URI", "Current URI",
|
||||
DEFAULT_URI, G_PARAM_READWRITE |
|
||||
G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
@@ -730,6 +738,11 @@ gst_clapper_get_property (GObject * object, guint prop_id,
|
||||
GstClapper *self = GST_CLAPPER (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_STATE:
|
||||
g_mutex_lock (&self->lock);
|
||||
g_value_set_enum (value, self->app_state);
|
||||
g_mutex_unlock (&self->lock);
|
||||
break;
|
||||
case PROP_URI:
|
||||
g_mutex_lock (&self->lock);
|
||||
g_value_set_string (value, self->uri);
|
||||
@@ -3442,6 +3455,24 @@ remove_seek_source (GstClapper * self)
|
||||
self->seek_source = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_clapper_get_state:
|
||||
* @clapper: #GstClapper instance
|
||||
*
|
||||
* Returns: Current player state
|
||||
*/
|
||||
GstClapperState
|
||||
gst_clapper_get_state (GstClapper * self)
|
||||
{
|
||||
GstClapperState state;
|
||||
|
||||
g_return_val_if_fail (GST_IS_CLAPPER (self), DEFAULT_STATE);
|
||||
|
||||
g_object_get (self, "state", &state, NULL);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_clapper_get_uri:
|
||||
* @clapper: #GstClapper instance
|
||||
|
4
lib/gst/clapper/gstclapper.h
vendored
4
lib/gst/clapper/gstclapper.h
vendored
@@ -170,6 +170,10 @@ void gst_clapper_stop (GstClapper *clapper
|
||||
GST_CLAPPER_API
|
||||
void gst_clapper_seek (GstClapper *clapper, GstClockTime position);
|
||||
|
||||
GST_CLAPPER_API
|
||||
GstClapperState
|
||||
gst_clapper_get_state (GstClapper *clapper);
|
||||
|
||||
GST_CLAPPER_API
|
||||
GstClapperSeekMode
|
||||
gst_clapper_get_seek_mode (GstClapper *clapper);
|
||||
|
@@ -33,7 +33,6 @@ class ClapperPlayer extends GstClapper.Clapper
|
||||
this.widget = gtk4plugin.video_sink.widget;
|
||||
this.widget.add_css_class('videowidget');
|
||||
|
||||
this.state = GstClapper.ClapperState.STOPPED;
|
||||
this.visualization_enabled = false;
|
||||
|
||||
this.webserver = null;
|
||||
@@ -518,7 +517,6 @@ class ClapperPlayer extends GstClapper.Clapper
|
||||
|
||||
_onStateChanged(player, state)
|
||||
{
|
||||
this.state = state;
|
||||
this.emitWs('state_changed', state);
|
||||
|
||||
if(state !== GstClapper.ClapperState.BUFFERING) {
|
||||
|
Reference in New Issue
Block a user