Пример #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;
	}
}
void linphone_gtk_start_record_sound(GtkWidget *w, gpointer data){
	LinphoneCore *lc = linphone_gtk_get_core();
	AudioStream *stream = NULL;
	MSSndCardManager *manager = ms_snd_card_manager_get();
	gboolean active=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));

	if(active){
		gchar *path = get_record_file();
		stream=audio_stream_new(8888, 8889, FALSE);
		if(stream != NULL){
			audio_stream_start_full(stream,&av_profile,"127.0.0.1",8888,"127.0.0.1",8889,0,0,NULL,
				path,NULL,ms_snd_card_manager_get_card(manager,linphone_core_get_capture_device(lc)),FALSE);
			g_object_set_data(G_OBJECT(audio_assistant),"record_stream",stream);
		}
		gint timeout_id = gtk_timeout_add(6000,(GtkFunction)linphone_gtk_stop_record,NULL);
		g_object_set_data(G_OBJECT(audio_assistant),"timeout_id",GINT_TO_POINTER(timeout_id));
		g_object_set_data(G_OBJECT(audio_assistant),"path",path);
	} else {
		stream = (AudioStream *)g_object_get_data(G_OBJECT(audio_assistant),"record_stream");
		gint timeout_id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(audio_assistant),"timeout_id"));
		gtk_timeout_remove(timeout_id);
		if(stream != NULL){
			audio_stream_stop(stream);
			g_object_set_data(G_OBJECT(audio_assistant),"record_stream",NULL);
		}
		update_record_button(FALSE);
		update_play_button(TRUE);
	}
}
static gboolean linphone_gtk_stop_record(gpointer data){
	AudioStream *stream = (AudioStream *)g_object_get_data(G_OBJECT(audio_assistant),"record_stream");
	if(stream != NULL){
		audio_stream_stop(stream);
		g_object_set_data(G_OBJECT(audio_assistant),"record_stream",NULL);
	}
	update_record_button(FALSE);
	update_play_button(TRUE);
	return FALSE;
}
Пример #4
0
static void
reset_player_state (GthMediaViewerPage *self)
{
        if (self->priv->update_progress_id != 0) {
                g_source_remove (self->priv->update_progress_id);
                self->priv->update_progress_id = 0;
        }

	update_play_button (self, GST_STATE_NULL);
	self->priv->playing = FALSE;
	self->priv->rate = 1.0;
}
Пример #5
0
static void
bus_message_cb (GstBus     *bus,
                GstMessage *message,
                gpointer    user_data)
{
	GthMediaViewerPage *self = user_data;

	if (GST_MESSAGE_SRC (message) != GST_OBJECT (self->priv->playbin))
		return;

	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);
		if (old_state == new_state)
			break;

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

		if ((old_state == GST_STATE_NULL) && (new_state == GST_STATE_READY) && (pending_state != GST_STATE_PAUSED)) {
			update_stream_info (self);
			gth_viewer_page_update_sensitivity (GTH_VIEWER_PAGE (self));
			gth_viewer_page_file_loaded (GTH_VIEWER_PAGE (self), self->priv->file_data, 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));
			gth_viewer_page_file_loaded (GTH_VIEWER_PAGE (self), self->priv->file_data, TRUE);
		}
		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_CHANGED:
		self->priv->duration = 0;
		update_current_position_bar (self);
		break;

	case GST_MESSAGE_EOS:
		reset_player_state (self);
		break;

	case GST_MESSAGE_BUFFERING: {
		int percent = 0;
		gst_message_parse_buffering (message, &percent);
		gst_element_set_state (self->priv->playbin, (percent == 100) ? GST_STATE_PLAYING : GST_STATE_PAUSED);
		break;
	}

	case GST_MESSAGE_ERROR:
		gth_viewer_page_file_loaded (GTH_VIEWER_PAGE (self), self->priv->file_data, FALSE);
		break;

	default:
		break;
	}
}