Ejemplo n.º 1
0
static void
bus_message_cb (GstBus     *bus,
                GstMessage *message,
                gpointer    user_data)
{
	GthMediaViewerPage *self = user_data;

	switch (GST_MESSAGE_TYPE (message)) {
	case GST_MESSAGE_STATE_CHANGED: {
		GstState old_state;
		GstState new_state;
		GstState pending_state;

		old_state = new_state = GST_STATE_NULL;
		gst_message_parse_state_changed (message, &old_state, &new_state, &pending_state);

		self->priv->paused = (new_state == GST_STATE_PAUSED);

		if (old_state == new_state)
			break;
		if (GST_MESSAGE_SRC (message) != GST_OBJECT (self->priv->playbin))
			break;

		update_current_position_bar (self, TRUE);

		if ((old_state == GST_STATE_READY) && (new_state == GST_STATE_PAUSED)) {
			update_stream_info (self);
			gth_viewer_page_update_sensitivity (GTH_VIEWER_PAGE (self));
		}
		if ((old_state == GST_STATE_READY) || (new_state == GST_STATE_PAUSED))
			update_volume_from_playbin (self);
		if ((old_state == GST_STATE_PLAYING) || (new_state == GST_STATE_PLAYING))
			update_play_button (self, new_state);
		break;
	}

	case GST_MESSAGE_DURATION: {
		GstFormat format;

		format = GST_FORMAT_TIME;
		gst_message_parse_duration (message, &format, &self->priv->duration);
		update_current_position_bar (self, TRUE);
		break;
	}

	case GST_MESSAGE_EOS:
		reset_player_state (self);
		break;

	case GST_MESSAGE_BUFFERING: {
		int percent = 0;
		gst_message_parse_buffering (message, &percent);
		g_print ("Buffering (%%%u percent done)", percent);
		break;
	}

	default:
		break;
	}
}
Ejemplo n.º 2
0
static VALUE
duration_parse(VALUE self)
{
    GstFormat format;
    gint64 duration;

    gst_message_parse_duration(SELF(self), &format, &duration);
    return rb_ary_new3(2, GST_FORMAT2RVAL(format), LL2NUM(duration));
}
Ejemplo n.º 3
0
qint64 DurationMessage::duration() const
{
    gint64 d;
    gst_message_parse_duration(object<GstMessage>(), NULL, &d);
    return d;
}
Ejemplo n.º 4
0
Format DurationMessage::format() const
{
    GstFormat f;
    gst_message_parse_duration(object<GstMessage>(), &f, NULL);
    return static_cast<Format>(f);
}