forked from mirrors/linphone-iphone
Add audio assistant
Fix wizard bug
This commit is contained in:
parent
4d6894901e
commit
9073389641
10 changed files with 629 additions and 84 deletions
|
|
@ -14,7 +14,8 @@ UI_FILES= about.ui \
|
|||
call_statistics.ui \
|
||||
ldap.ui \
|
||||
config-uri.ui \
|
||||
provisioning-fetch.ui
|
||||
provisioning-fetch.ui \
|
||||
audio_assistant.ui
|
||||
|
||||
PIXMAPS= \
|
||||
stock_people.png
|
||||
|
|
@ -52,6 +53,7 @@ linphone_SOURCES= \
|
|||
singleinstance.c \
|
||||
conference.c \
|
||||
config-fetching.c \
|
||||
audio_assistant.c \
|
||||
linphone.h
|
||||
if BUILD_WIZARD
|
||||
linphone_SOURCES+= \
|
||||
|
|
|
|||
461
gtk/audio_assistant.c
Normal file
461
gtk/audio_assistant.c
Normal file
|
|
@ -0,0 +1,461 @@
|
|||
/*
|
||||
linphone, gtk-glade interface.
|
||||
Copyright (C) 2008 Simon MORLAT (simon.morlat@linphone.org)
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#include "linphone.h"
|
||||
#include "linphonecore_utils.h"
|
||||
#include "mediastreamer2/mediastream.h"
|
||||
#include "mediastreamer2/msvolume.h"
|
||||
|
||||
static GtkWidget *audio_assistant=NULL;
|
||||
|
||||
GtkWidget *get_widget_from_assistant(const char *name){
|
||||
return (GtkWidget *)g_object_get_data(G_OBJECT(audio_assistant),name);
|
||||
}
|
||||
void set_widget_to_assistant(const char *name,GtkWidget *w){
|
||||
g_object_set_data(G_OBJECT(audio_assistant),name,w);
|
||||
}
|
||||
|
||||
void update_record_button(gboolean is_visible){
|
||||
GtkWidget *rec_button = get_widget_from_assistant("rec_button");
|
||||
gtk_widget_set_sensitive(rec_button,is_visible);
|
||||
}
|
||||
|
||||
void activate_record_button(gboolean is_active){
|
||||
GtkWidget *rec_button = get_widget_from_assistant("rec_button");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rec_button),is_active);
|
||||
}
|
||||
|
||||
void update_play_button(gboolean is_visible){
|
||||
GtkWidget *play_button = get_widget_from_assistant("play_button");
|
||||
gtk_widget_set_sensitive(play_button,is_visible);
|
||||
}
|
||||
|
||||
void activate_play_button(gboolean is_active){
|
||||
GtkWidget *play_button = get_widget_from_assistant("play_button");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(play_button),is_active);
|
||||
}
|
||||
|
||||
|
||||
|
||||
gchar *get_record_file(){
|
||||
char filename[256]={0};
|
||||
char date[64]={0};
|
||||
time_t curtime=time(NULL);
|
||||
struct tm loctime;
|
||||
|
||||
#ifdef WIN32
|
||||
loctime=*localtime(&curtime);
|
||||
#else
|
||||
localtime_r(&curtime,&loctime);
|
||||
#endif
|
||||
snprintf(date,sizeof(date)-1,"%i%02i%02i-%02i%02i%2i",loctime.tm_year+1900,loctime.tm_mon+1,loctime.tm_mday, loctime.tm_hour, loctime.tm_min, loctime.tm_sec);
|
||||
|
||||
snprintf(filename,sizeof(filename)-1,"record-%s.wav",date);
|
||||
return g_build_path(G_DIR_SEPARATOR_S,g_get_tmp_dir(),filename,NULL);;
|
||||
}
|
||||
|
||||
float audio_stream_get_record_volume(AudioStream *st){
|
||||
if (st && st->volsend){
|
||||
float vol=0;
|
||||
ms_filter_call_method(st->volsend,MS_VOLUME_GET,&vol);
|
||||
return vol;
|
||||
}
|
||||
return LINPHONE_VOLUME_DB_LOWEST;
|
||||
}
|
||||
|
||||
float audio_stream_get_max_volume(AudioStream *st){
|
||||
if (st && st->volsend){
|
||||
float vol=0;
|
||||
ms_filter_call_method(st->volsend,MS_VOLUME_GET_MAX,&vol);
|
||||
return vol;
|
||||
}
|
||||
return LINPHONE_VOLUME_DB_LOWEST;
|
||||
}
|
||||
|
||||
static gboolean update_audio_label(volume_ctx_t *ctx){
|
||||
float volume_db=ctx->get_volume(ctx->data);
|
||||
gchar *result;
|
||||
if (volume_db < -30) result = "No Voice";
|
||||
if (volume_db > -30 && volume_db < -15) result = "Low";
|
||||
if (volume_db > -15 && volume_db < 0) result = "Good";
|
||||
if (volume_db > 0) result = "Too loud";
|
||||
//g_message("volume_db=%f, frac=%f",volume_db,frac);
|
||||
gtk_label_set_text(GTK_LABEL(ctx->widget),result);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void on_audio_label_destroy(guint task_id){
|
||||
g_source_remove(task_id);
|
||||
}
|
||||
|
||||
void linphone_gtk_init_audio_label(GtkWidget *w, get_volume_t get_volume, void *data){
|
||||
guint task_id=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w),"task_id_t"));
|
||||
if (task_id==0){
|
||||
volume_ctx_t *ctx=g_new(volume_ctx_t,1);
|
||||
ctx->widget=w;
|
||||
ctx->get_volume=get_volume;
|
||||
ctx->data=data;
|
||||
ctx->last_value=0;
|
||||
g_object_set_data_full(G_OBJECT(w),"ctx_t",ctx,g_free);
|
||||
task_id=g_timeout_add(200,(GSourceFunc)update_audio_label,ctx);
|
||||
g_object_set_data_full(G_OBJECT(w),"task_id_t",GINT_TO_POINTER(task_id),(GDestroyNotify)on_audio_label_destroy);
|
||||
}
|
||||
}
|
||||
|
||||
void linphone_gtk_uninit_audio_label(GtkWidget *w){
|
||||
guint task_id=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w),"task_id_t"));
|
||||
if (task_id!=0){
|
||||
g_object_set_data(G_OBJECT(w),"ctx_t",NULL);
|
||||
g_object_set_data(G_OBJECT(w),"task_id_t",NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void playback_device_changed(GtkWidget *w){
|
||||
gchar *sel=gtk_combo_box_get_active_text(GTK_COMBO_BOX(w));
|
||||
linphone_core_set_playback_device(linphone_gtk_get_core(),sel);
|
||||
g_free(sel);
|
||||
}
|
||||
|
||||
void capture_device_changed(GtkWidget *capture_device){
|
||||
gchar *sel;
|
||||
GtkWidget *mic_audiolevel;
|
||||
AudioStream *audio_stream;
|
||||
|
||||
mic_audiolevel = get_widget_from_assistant("mic_audiolevel");
|
||||
audio_stream = (AudioStream *) g_object_get_data(G_OBJECT(capture_device),"audio_stream");
|
||||
sel = gtk_combo_box_get_active_text(GTK_COMBO_BOX(capture_device));
|
||||
linphone_core_set_capture_device(linphone_gtk_get_core(),sel);
|
||||
linphone_gtk_uninit_audio_meter(mic_audiolevel);
|
||||
audio_stream_stop(audio_stream);
|
||||
linphone_gtk_init_audio_meter(mic_audiolevel,(get_volume_t)audio_stream_get_record_volume,audio_stream);
|
||||
|
||||
g_free(sel);
|
||||
}
|
||||
|
||||
static void dialog_click(GtkWidget *dialog, guint response_id, GtkWidget *page){
|
||||
switch(response_id){
|
||||
case GTK_RESPONSE_YES:
|
||||
gtk_assistant_set_page_complete(GTK_ASSISTANT(audio_assistant),page,TRUE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
gtk_widget_destroy(dialog);
|
||||
}
|
||||
|
||||
static void calibration_finished(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay, void *data){
|
||||
ms_message("echo calibration finished %s.",status==LinphoneEcCalibratorDone ? "successfully" : "with faillure");
|
||||
if (status==LinphoneEcCalibratorDone) ms_message("Measured delay is %i",delay);
|
||||
|
||||
GtkWidget * dialog;
|
||||
GtkWidget *speaker_page = get_widget_from_assistant("speaker_page");
|
||||
|
||||
dialog = gtk_message_dialog_new (
|
||||
GTK_WINDOW(audio_assistant),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_QUESTION,
|
||||
GTK_BUTTONS_YES_NO,
|
||||
"%s","Did you hear three beeps ?");
|
||||
|
||||
g_signal_connect(G_OBJECT (dialog), "response",
|
||||
G_CALLBACK (dialog_click),speaker_page);
|
||||
gtk_widget_show(dialog);
|
||||
}
|
||||
|
||||
void linphone_gtk_start_sound(GtkWidget *w){
|
||||
LinphoneCore *lc = linphone_gtk_get_core();
|
||||
linphone_core_start_echo_calibration(lc,calibration_finished,NULL,NULL,NULL);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
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 void endoffile_cb(void *ud, MSFilter *f, unsigned int ev,void * arg){
|
||||
switch (ev) {
|
||||
case MS_PLAYER_EOF: {
|
||||
ms_message("EndOfFile received");
|
||||
activate_play_button(FALSE);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void linphone_gtk_start_play_record_sound(GtkWidget *w,gpointer data){
|
||||
LinphoneCore *lc = linphone_gtk_get_core();
|
||||
gboolean active=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
|
||||
AudioStream *stream = NULL;
|
||||
MSSndCardManager *manager = ms_snd_card_manager_get();
|
||||
|
||||
if(active){
|
||||
gchar *path = g_object_get_data(G_OBJECT(audio_assistant),"path");
|
||||
stream=audio_stream_new(8888, 8889, FALSE);
|
||||
if(path != NULL){
|
||||
audio_stream_start_full(stream,&av_profile,"127.0.0.1",8888,"127.0.0.1",8889,0,0,path,
|
||||
NULL,ms_snd_card_manager_get_card(manager,linphone_core_get_playback_device(lc)),NULL,FALSE);
|
||||
ms_filter_add_notify_callback(stream->soundread,endoffile_cb,stream,FALSE);
|
||||
g_object_set_data(G_OBJECT(audio_assistant),"play_stream",stream);
|
||||
}
|
||||
} else {
|
||||
stream = (AudioStream *)g_object_get_data(G_OBJECT(audio_assistant),"play_stream");
|
||||
if(stream != NULL){
|
||||
audio_stream_stop(stream);
|
||||
g_object_set_data(G_OBJECT(audio_assistant),"play_stream",NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static GtkWidget *create_intro(){
|
||||
GtkWidget *vbox=gtk_vbox_new(FALSE,2);
|
||||
GtkWidget *label=gtk_label_new(_("Welcome !\nThis assistant will help you to configure audio settings for Linphone"));
|
||||
gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 2);
|
||||
gtk_widget_show_all(vbox);
|
||||
return vbox;
|
||||
}
|
||||
|
||||
static GtkWidget *create_mic_page(){
|
||||
GtkWidget *vbox=gtk_table_new(3,2,FALSE);
|
||||
LinphoneCore *lc=linphone_gtk_get_core();
|
||||
|
||||
GtkWidget *labelMicChoice=gtk_label_new(_("Capture device"));
|
||||
GtkWidget *labelMicLevel=gtk_label_new(_("Recorded volume"));
|
||||
GtkWidget *mic_audiolevel=gtk_progress_bar_new();
|
||||
GtkWidget *capture_device=gtk_combo_box_new();
|
||||
GtkWidget *box = gtk_vbox_new(FALSE,0);
|
||||
GtkWidget *label_audiolevel=gtk_label_new(_("No voice"));
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(box),mic_audiolevel,TRUE,TRUE,1);
|
||||
gtk_box_pack_start(GTK_BOX(box),label_audiolevel,FALSE,FALSE,1);
|
||||
|
||||
gtk_table_attach_defaults(GTK_TABLE(vbox), labelMicChoice, 0, 1, 0, 1);
|
||||
gtk_table_attach_defaults(GTK_TABLE(vbox), capture_device, 1, 2, 0, 1);
|
||||
gtk_table_attach_defaults(GTK_TABLE(vbox), labelMicLevel, 0, 1, 1, 2);
|
||||
gtk_table_attach_defaults(GTK_TABLE(vbox), box, 1, 2, 1, 2);
|
||||
|
||||
gtk_table_set_row_spacings(GTK_TABLE(vbox),10);
|
||||
|
||||
set_widget_to_assistant("mic_audiolevel",mic_audiolevel);
|
||||
set_widget_to_assistant("label_audiolevel",label_audiolevel);
|
||||
|
||||
const char **sound_devices=linphone_core_get_sound_devices(lc);
|
||||
linphone_gtk_fill_combo_box(capture_device, sound_devices,
|
||||
linphone_core_get_capture_device(lc), CAP_CAPTURE);
|
||||
gtk_widget_show_all(vbox);
|
||||
|
||||
g_signal_connect(G_OBJECT(capture_device),"changed",(GCallback)capture_device_changed,capture_device);
|
||||
|
||||
return vbox;
|
||||
}
|
||||
|
||||
static GtkWidget *create_speaker_page(){
|
||||
GtkWidget *vbox=gtk_table_new(2,2,FALSE);
|
||||
LinphoneCore *lc=linphone_gtk_get_core();
|
||||
|
||||
GtkWidget *labelSpeakerChoice=gtk_label_new(_("Playback device"));
|
||||
GtkWidget *labelSpeakerLevel=gtk_label_new(_("Play three beeps"));
|
||||
GtkWidget *spk_button=gtk_button_new_from_stock(GTK_STOCK_MEDIA_PLAY);
|
||||
GtkWidget *playback_device=gtk_combo_box_new();
|
||||
|
||||
gtk_table_attach_defaults(GTK_TABLE(vbox), labelSpeakerChoice, 0, 1, 0, 1);
|
||||
gtk_table_attach_defaults(GTK_TABLE(vbox), playback_device, 1, 2, 0, 1);
|
||||
gtk_table_attach_defaults(GTK_TABLE(vbox), labelSpeakerLevel, 0, 1, 1, 2);
|
||||
gtk_table_attach(GTK_TABLE(vbox), spk_button, 1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0,0);
|
||||
|
||||
gtk_table_set_row_spacings(GTK_TABLE(vbox),10);
|
||||
|
||||
const char **sound_devices=linphone_core_get_sound_devices(lc);
|
||||
linphone_gtk_fill_combo_box(playback_device, sound_devices,
|
||||
linphone_core_get_playback_device(lc),CAP_PLAYBACK);
|
||||
gtk_widget_show_all(vbox);
|
||||
|
||||
set_widget_to_assistant("speaker_page",vbox);
|
||||
g_signal_connect(G_OBJECT(playback_device),"changed",(GCallback)playback_device_changed,playback_device);
|
||||
g_signal_connect(G_OBJECT(spk_button),"clicked",(GCallback)linphone_gtk_start_sound,vbox);
|
||||
|
||||
return vbox;
|
||||
}
|
||||
|
||||
static GtkWidget *create_play_record_page(){
|
||||
GtkWidget *vbox=gtk_table_new(2,2,FALSE);
|
||||
GtkWidget *labelRecord=gtk_label_new(_("Press the record button and say some words"));
|
||||
GtkWidget *labelPlay=gtk_label_new(_("Listen to your record voice"));
|
||||
GtkWidget *rec_button=gtk_toggle_button_new_with_label("Record");
|
||||
GtkWidget *play_button=gtk_toggle_button_new_with_label("Play");
|
||||
GtkWidget *image;
|
||||
|
||||
image=gtk_image_new_from_stock(GTK_STOCK_MEDIA_RECORD,GTK_ICON_SIZE_MENU);
|
||||
gtk_button_set_image(GTK_BUTTON(rec_button),image);
|
||||
|
||||
image=gtk_image_new_from_stock(GTK_STOCK_MEDIA_PLAY,GTK_ICON_SIZE_MENU);
|
||||
gtk_button_set_image(GTK_BUTTON(play_button),image);
|
||||
gtk_widget_set_sensitive(play_button,FALSE);
|
||||
|
||||
gtk_table_attach_defaults(GTK_TABLE(vbox), labelRecord, 0, 1, 0, 1);
|
||||
gtk_table_attach(GTK_TABLE(vbox), rec_button, 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0,0);
|
||||
gtk_table_attach_defaults(GTK_TABLE(vbox), labelPlay, 0, 1, 1, 2);
|
||||
gtk_table_attach(GTK_TABLE(vbox), play_button, 1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0,0);
|
||||
|
||||
gtk_widget_show_all(vbox);
|
||||
|
||||
set_widget_to_assistant("rec_button",rec_button);
|
||||
set_widget_to_assistant("play_button",play_button);
|
||||
g_signal_connect(G_OBJECT(rec_button),"toggled",(GCallback)linphone_gtk_start_record_sound,vbox);
|
||||
g_signal_connect(G_OBJECT(play_button),"toggled",(GCallback)linphone_gtk_start_play_record_sound,vbox);
|
||||
|
||||
return vbox;
|
||||
}
|
||||
|
||||
static GtkWidget *create_end_page(){
|
||||
GtkWidget *vbox=gtk_vbox_new(FALSE,2);
|
||||
GtkWidget *label=gtk_label_new(_("Let's start Linphone now"));
|
||||
gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 2);
|
||||
gtk_widget_show_all(vbox);
|
||||
return vbox;
|
||||
}
|
||||
|
||||
static void prepare(GtkAssistant *w, GtkWidget *p, void * data){
|
||||
AudioStream *audio_stream = NULL;
|
||||
LinphoneCore *lc=linphone_gtk_get_core();
|
||||
int page = gtk_assistant_get_current_page(w);
|
||||
GtkWidget *mic_audiolevel = get_widget_from_assistant("mic_audiolevel");
|
||||
GtkWidget *label_audiolevel = get_widget_from_assistant("label_audiolevel");
|
||||
|
||||
//Speaker page
|
||||
if(page == 1){
|
||||
MSSndCardManager *manager = ms_snd_card_manager_get();
|
||||
audio_stream = audio_stream_start_with_sndcards(&av_profile,9897,"127.0.0.1",9898,0,0,ms_snd_card_manager_get_card(manager,linphone_core_get_playback_device(lc)),ms_snd_card_manager_get_card(manager,linphone_core_get_capture_device(lc)),FALSE);
|
||||
if(mic_audiolevel != NULL && audio_stream != NULL){
|
||||
g_object_set_data(G_OBJECT(audio_assistant),"stream",audio_stream);
|
||||
linphone_gtk_init_audio_meter(mic_audiolevel,(get_volume_t)audio_stream_get_record_volume,audio_stream);
|
||||
linphone_gtk_init_audio_label(label_audiolevel,(get_volume_t)audio_stream_get_max_volume,audio_stream);
|
||||
}
|
||||
|
||||
|
||||
} else if(page == 2 || page == 0){
|
||||
if(mic_audiolevel != NULL && label_audiolevel != NULL){
|
||||
audio_stream = (AudioStream *)g_object_get_data(G_OBJECT(audio_assistant),"stream");
|
||||
if(audio_stream != NULL){
|
||||
linphone_gtk_uninit_audio_meter(mic_audiolevel);
|
||||
linphone_gtk_uninit_audio_label(label_audiolevel);
|
||||
audio_stream_stop(audio_stream);
|
||||
g_object_set_data(G_OBJECT(audio_assistant),"stream",NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void linphone_gtk_close_audio_assistant(GtkWidget *w){
|
||||
gchar *path = g_object_get_data(G_OBJECT(audio_assistant),"path");
|
||||
g_unlink(path);
|
||||
gtk_widget_destroy(w);
|
||||
audio_assistant = NULL;
|
||||
linphone_gtk_show_main_window();
|
||||
}
|
||||
|
||||
void linphone_gtk_audio_assistant_apply(GtkWidget *w){
|
||||
linphone_gtk_close_audio_assistant(w);
|
||||
}
|
||||
|
||||
void linphone_gtk_show_audio_assistant(void){
|
||||
GtkWidget *w;
|
||||
if(audio_assistant!=NULL)
|
||||
return;
|
||||
w=audio_assistant=linphone_gtk_create_window("audio_assistant");
|
||||
|
||||
gtk_window_set_resizable (GTK_WINDOW(w), FALSE);
|
||||
gtk_window_set_title(GTK_WINDOW(w),_("Audio Assistant"));
|
||||
|
||||
GtkWidget *welcome=create_intro();
|
||||
GtkWidget *mic_page=create_mic_page();
|
||||
GtkWidget *speaker_page=create_speaker_page();
|
||||
GtkWidget *play_record_page=create_play_record_page();
|
||||
GtkWidget *end_page=create_end_page();
|
||||
|
||||
gtk_assistant_append_page(GTK_ASSISTANT(w),welcome);
|
||||
gtk_assistant_set_page_type(GTK_ASSISTANT(w),welcome,GTK_ASSISTANT_PAGE_INTRO);
|
||||
gtk_assistant_set_page_title(GTK_ASSISTANT(w),welcome,_("Audio assistant"));
|
||||
gtk_assistant_set_page_complete(GTK_ASSISTANT(w),welcome,TRUE);
|
||||
|
||||
gtk_assistant_append_page(GTK_ASSISTANT(w),mic_page);
|
||||
gtk_assistant_set_page_type(GTK_ASSISTANT(w),mic_page,GTK_ASSISTANT_PAGE_CONTENT);
|
||||
gtk_assistant_set_page_title(GTK_ASSISTANT(w),mic_page,_("Mic Gain calibration"));
|
||||
gtk_assistant_set_page_complete(GTK_ASSISTANT(w),mic_page,TRUE);
|
||||
|
||||
gtk_assistant_append_page(GTK_ASSISTANT(w),speaker_page);
|
||||
gtk_assistant_set_page_type(GTK_ASSISTANT(w),speaker_page,GTK_ASSISTANT_PAGE_CONTENT);
|
||||
gtk_assistant_set_page_complete(GTK_ASSISTANT(w),speaker_page,FALSE);
|
||||
gtk_assistant_set_page_title(GTK_ASSISTANT(w),speaker_page,_("Speaker volume calibration"));
|
||||
|
||||
gtk_assistant_append_page(GTK_ASSISTANT(w),play_record_page);
|
||||
gtk_assistant_set_page_type(GTK_ASSISTANT(w),play_record_page,GTK_ASSISTANT_PAGE_CONTENT);
|
||||
gtk_assistant_set_page_complete(GTK_ASSISTANT(w),play_record_page,TRUE);
|
||||
gtk_assistant_set_page_title(GTK_ASSISTANT(w),play_record_page,_("Record and Play"));
|
||||
|
||||
gtk_assistant_append_page(GTK_ASSISTANT(w),end_page);
|
||||
gtk_assistant_set_page_type(GTK_ASSISTANT(w),end_page,GTK_ASSISTANT_PAGE_SUMMARY);
|
||||
gtk_assistant_set_page_complete(GTK_ASSISTANT(w),end_page,TRUE);
|
||||
gtk_assistant_set_page_title(GTK_ASSISTANT(w),end_page,_("Terminating"));
|
||||
|
||||
g_signal_connect(G_OBJECT(w),"close",(GCallback)linphone_gtk_close_audio_assistant,w);
|
||||
g_signal_connect(G_OBJECT(w),"cancel",(GCallback)linphone_gtk_close_audio_assistant,w);
|
||||
g_signal_connect(G_OBJECT(w),"prepare",(GCallback)prepare,NULL);
|
||||
|
||||
gtk_widget_show(w);
|
||||
}
|
||||
21
gtk/audio_assistant.ui
Normal file
21
gtk/audio_assistant.ui
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk+" version="2.24"/>
|
||||
<!-- interface-naming-policy project-wide -->
|
||||
<object class="GtkAssistant" id="audio_assistant">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">12</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
|
@ -567,13 +567,6 @@ static gboolean linphone_gtk_in_call_view_refresh(LinphoneCall *call){
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
typedef struct _volume_ctx{
|
||||
GtkWidget *widget;
|
||||
get_volume_t get_volume;
|
||||
void *data;
|
||||
float last_value;
|
||||
}volume_ctx_t;
|
||||
|
||||
#define UNSIGNIFICANT_VOLUME (-26)
|
||||
#define SMOOTH 0.15
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,27 @@ enum {
|
|||
COMPLETION_LDAP
|
||||
};
|
||||
|
||||
typedef float (*get_volume_t)(void *data);
|
||||
|
||||
typedef struct _volume_ctx{
|
||||
GtkWidget *widget;
|
||||
get_volume_t get_volume;
|
||||
void *data;
|
||||
float last_value;
|
||||
}volume_ctx_t;
|
||||
|
||||
typedef enum {
|
||||
CAP_IGNORE,
|
||||
CAP_PLAYBACK,
|
||||
CAP_CAPTURE
|
||||
}DeviceCap;
|
||||
|
||||
enum {
|
||||
START_LINPHONE,
|
||||
START_AUDIO_ASSISTANT,
|
||||
START_LINPHONE_WITH_CALL
|
||||
};
|
||||
|
||||
GdkPixbuf * create_pixbuf(const gchar *filename);
|
||||
GdkPixbufAnimation *create_pixbuf_animation(const gchar *filename);
|
||||
void add_pixmap_directory(const gchar *directory);
|
||||
|
|
@ -96,7 +117,6 @@ LinphoneLDAPContactProvider* linphone_gtk_get_ldap(void);
|
|||
void linphone_gtk_set_ldap(LinphoneLDAPContactProvider* ldap);
|
||||
int linphone_gtk_is_ldap_supported(void);
|
||||
|
||||
|
||||
void linphone_gtk_open_browser(const char *url);
|
||||
void linphone_gtk_check_for_new_version(void);
|
||||
const char *linphone_gtk_get_lang(const char *config_file);
|
||||
|
|
@ -150,8 +170,8 @@ void linphone_gtk_unset_from_conference(LinphoneCall *call);
|
|||
void linphone_gtk_terminate_conference_participant(LinphoneCall *call);
|
||||
void linphone_gtk_in_call_view_show_encryption(LinphoneCall *call);
|
||||
void linphone_gtk_update_video_button(LinphoneCall *call);
|
||||
typedef float (*get_volume_t)(void *data);
|
||||
void linphone_gtk_init_audio_meter(GtkWidget *w, get_volume_t get_volume, void *data);
|
||||
void linphone_gtk_uninit_audio_meter(GtkWidget *w);
|
||||
|
||||
void linphone_gtk_show_login_frame(LinphoneProxyConfig *cfg, gboolean disable_auto_login);
|
||||
void linphone_gtk_exit_login_frame(void);
|
||||
|
|
@ -159,14 +179,17 @@ void linphone_gtk_set_ui_config(const char *key, const char *value);
|
|||
|
||||
void linphone_gtk_log_uninit();
|
||||
|
||||
bool_t linphone_gtk_init_instance(const char *app_name, const char *addr_to_call);
|
||||
bool_t linphone_gtk_init_instance(const char *app_name, int option, const char *addr_to_call);
|
||||
void linphone_gtk_uninit_instance(void);
|
||||
void linphone_gtk_monitor_usb(void);
|
||||
void linphone_gtk_unmonitor_usb(void);
|
||||
|
||||
void linphone_gtk_fill_combo_box(GtkWidget *combo, const char **devices, const char *selected, DeviceCap cap);
|
||||
gchar *linphone_gtk_get_record_path(const LinphoneAddress *address, gboolean is_conference);
|
||||
void linphone_gtk_schedule_restart(void);
|
||||
|
||||
void linphone_gtk_show_audio_assistant(void);
|
||||
|
||||
void linphone_gtk_set_configuration_uri(void);
|
||||
GtkWidget * linphone_gtk_show_config_fetching(void);
|
||||
void linphone_gtk_close_config_fetching(GtkWidget *w, LinphoneConfiguringState state);
|
||||
|
|
|
|||
20
gtk/main.c
20
gtk/main.c
|
|
@ -86,8 +86,10 @@ static gboolean verbose=0;
|
|||
static gboolean quit_done=FALSE;
|
||||
static gboolean auto_answer = 0;
|
||||
static gchar * addr_to_call = NULL;
|
||||
static int start_option = START_LINPHONE;
|
||||
static gboolean no_video=FALSE;
|
||||
static gboolean iconified=FALSE;
|
||||
static gboolean run_audio_assistant=FALSE;
|
||||
static gchar *workingdir=NULL;
|
||||
static char *progpath=NULL;
|
||||
gchar *linphone_logfile=NULL;
|
||||
|
|
@ -153,6 +155,13 @@ static GOptionEntry linphone_options[]={
|
|||
.arg_data = (gpointer) &custom_config_file,
|
||||
.description = N_("Configuration file")
|
||||
},
|
||||
{
|
||||
.long_name = "run-audio-assistant",
|
||||
.short_name = '\0',
|
||||
.arg = G_OPTION_ARG_NONE,
|
||||
.arg_data = (gpointer) &run_audio_assistant,
|
||||
.description = N_("Run the audio assistant")
|
||||
},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
|
@ -2136,6 +2145,11 @@ static void linphone_gtk_init_ui(void){
|
|||
}
|
||||
#endif
|
||||
|
||||
if(run_audio_assistant){
|
||||
linphone_gtk_show_audio_assistant();
|
||||
start_option=START_AUDIO_ASSISTANT;
|
||||
iconified = TRUE;
|
||||
}
|
||||
#ifndef HAVE_GTK_OSX
|
||||
linphone_gtk_init_status_icon();
|
||||
#endif
|
||||
|
|
@ -2168,7 +2182,6 @@ int main(int argc, char *argv[]){
|
|||
|
||||
config_file=linphone_gtk_get_config_file(NULL);
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
/*workaround for windows: sometimes LANG is defined to an integer value, not understood by gtk */
|
||||
if ((lang=getenv("LANG"))!=NULL){
|
||||
|
|
@ -2226,6 +2239,9 @@ int main(int argc, char *argv[]){
|
|||
}
|
||||
config_file=linphone_gtk_get_config_file(custom_config_file);
|
||||
|
||||
if(run_audio_assistant) start_option=START_AUDIO_ASSISTANT;
|
||||
if(addr_to_call != NULL) start_option=START_LINPHONE_WITH_CALL;
|
||||
|
||||
settings=gtk_settings_get_default();
|
||||
g_type_class_unref (g_type_class_ref (GTK_TYPE_IMAGE_MENU_ITEM));
|
||||
g_type_class_unref (g_type_class_ref (GTK_TYPE_BUTTON));
|
||||
|
|
@ -2275,7 +2291,7 @@ int main(int argc, char *argv[]){
|
|||
#endif
|
||||
|
||||
core_start:
|
||||
if (linphone_gtk_init_instance(app_name, addr_to_call) == FALSE){
|
||||
if (linphone_gtk_init_instance(app_name, start_option, addr_to_call) == FALSE){
|
||||
g_warning("Another running instance of linphone has been detected. It has been woken-up.");
|
||||
g_warning("This instance is going to exit now.");
|
||||
gdk_threads_leave();
|
||||
|
|
|
|||
129
gtk/main.ui
129
gtk/main.ui
|
|
@ -786,6 +786,12 @@
|
|||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-add</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image21">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="yalign">0.49000000953674316</property>
|
||||
<property name="stock">gtk-properties</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
|
|
@ -821,6 +827,59 @@
|
|||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-add</property>
|
||||
</object>
|
||||
<object class="GtkListStore" id="model1">
|
||||
<columns>
|
||||
<!-- column-name gchararray -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
<data>
|
||||
<row>
|
||||
<col id="0" translatable="yes">All users</col>
|
||||
</row>
|
||||
<row>
|
||||
<col id="0" translatable="yes">Online users</col>
|
||||
</row>
|
||||
</data>
|
||||
</object>
|
||||
<object class="GtkListStore" id="model2">
|
||||
<columns>
|
||||
<!-- column-name gchararray -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
<data>
|
||||
<row>
|
||||
<col id="0" translatable="yes">ADSL</col>
|
||||
</row>
|
||||
<row>
|
||||
<col id="0" translatable="yes">Fiber Channel</col>
|
||||
</row>
|
||||
</data>
|
||||
</object>
|
||||
<object class="GtkListStore" id="model3">
|
||||
<columns>
|
||||
<!-- column-name gchararray -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
<data>
|
||||
<row>
|
||||
<col id="0" translatable="yes">Default</col>
|
||||
</row>
|
||||
</data>
|
||||
</object>
|
||||
<object class="GtkListStore" id="model4">
|
||||
<columns>
|
||||
<!-- column-name gchararray -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
<data>
|
||||
<row>
|
||||
<col id="0" translatable="yes">ADSL</col>
|
||||
</row>
|
||||
<row>
|
||||
<col id="0" translatable="yes">Fiber Channel</col>
|
||||
</row>
|
||||
</data>
|
||||
</object>
|
||||
<object class="GtkWindow" id="main">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||
|
|
@ -991,6 +1050,17 @@
|
|||
<signal name="activate" handler="linphone_gtk_show_assistant" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="audio_assistant_item">
|
||||
<property name="label" translatable="yes">Audio assistant</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="image">image21</property>
|
||||
<property name="use_stock">False</property>
|
||||
<signal name="activate" handler="linphone_gtk_show_audio_assistant" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
@ -1733,9 +1803,6 @@
|
|||
<property name="bottom_attach">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="userid">
|
||||
<property name="can_focus">False</property>
|
||||
|
|
@ -1762,6 +1829,9 @@
|
|||
<property name="bottom_attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
@ -1881,59 +1951,6 @@
|
|||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkListStore" id="model1">
|
||||
<columns>
|
||||
<!-- column-name gchararray -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
<data>
|
||||
<row>
|
||||
<col id="0" translatable="yes">All users</col>
|
||||
</row>
|
||||
<row>
|
||||
<col id="0" translatable="yes">Online users</col>
|
||||
</row>
|
||||
</data>
|
||||
</object>
|
||||
<object class="GtkListStore" id="model2">
|
||||
<columns>
|
||||
<!-- column-name gchararray -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
<data>
|
||||
<row>
|
||||
<col id="0" translatable="yes">ADSL</col>
|
||||
</row>
|
||||
<row>
|
||||
<col id="0" translatable="yes">Fiber Channel</col>
|
||||
</row>
|
||||
</data>
|
||||
</object>
|
||||
<object class="GtkListStore" id="model3">
|
||||
<columns>
|
||||
<!-- column-name gchararray -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
<data>
|
||||
<row>
|
||||
<col id="0" translatable="yes">Default</col>
|
||||
</row>
|
||||
</data>
|
||||
</object>
|
||||
<object class="GtkListStore" id="model4">
|
||||
<columns>
|
||||
<!-- column-name gchararray -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
<data>
|
||||
<row>
|
||||
<col id="0" translatable="yes">ADSL</col>
|
||||
</row>
|
||||
<row>
|
||||
<col id="0" translatable="yes">Fiber Channel</col>
|
||||
</row>
|
||||
</data>
|
||||
</object>
|
||||
<object class="GtkImage" id="remove_image">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
|
|
|
|||
|
|
@ -21,13 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "linphone_tunnel.h"
|
||||
#include "lpconfig.h"
|
||||
|
||||
typedef enum {
|
||||
CAP_IGNORE,
|
||||
CAP_PLAYBACK,
|
||||
CAP_CAPTURE
|
||||
}DeviceCap;
|
||||
|
||||
static void linphone_gtk_fill_combo_box(GtkWidget *combo, const char **devices, const char *selected, DeviceCap cap){
|
||||
void linphone_gtk_fill_combo_box(GtkWidget *combo, const char **devices, const char *selected, DeviceCap cap){
|
||||
const char **p=devices;
|
||||
int i=0,active=-1;
|
||||
GtkTreeModel *model;
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ static void linphone_account_informations_changed(GtkEntry *entry, GtkWidget *w)
|
|||
GtkEntry* username = GTK_ENTRY(g_object_get_data(G_OBJECT(w),"username"));
|
||||
|
||||
gtk_assistant_set_page_complete(GTK_ASSISTANT(assistant),w,
|
||||
gtk_entry_get_text_length(username) >= LOGIN_MIN_SIZE);
|
||||
gtk_entry_get_text_length(username) > 0);
|
||||
}
|
||||
|
||||
static GtkWidget *create_linphone_account_informations_page() {
|
||||
|
|
@ -453,6 +453,7 @@ static void linphone_gtk_assistant_prepare(GtkWidget *assistant, GtkWidget *page
|
|||
|
||||
static gint destroy_assistant(GtkWidget* w){
|
||||
gtk_widget_destroy(w);
|
||||
the_assistant = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,11 +33,26 @@ gchar *make_name(const char *appname){
|
|||
return g_strdup(appname);
|
||||
}
|
||||
|
||||
static gboolean execute_wakeup(char *uri){
|
||||
linphone_gtk_show_main_window();
|
||||
if (strlen(uri)>0)
|
||||
linphone_gtk_refer_received(linphone_gtk_get_core(),uri);
|
||||
g_free(uri);
|
||||
static gboolean execute_wakeup(char *buf){
|
||||
char uri[255]={0};
|
||||
int option;
|
||||
|
||||
if (strlen(buf)>1) sscanf(buf,"%i%s",&option,uri);
|
||||
else sscanf(buf,"%i",&option);
|
||||
|
||||
switch(option){
|
||||
case START_LINPHONE:
|
||||
linphone_gtk_show_main_window();
|
||||
break;
|
||||
case START_AUDIO_ASSISTANT:
|
||||
linphone_gtk_show_audio_assistant();
|
||||
break;
|
||||
case START_LINPHONE_WITH_CALL:
|
||||
linphone_gtk_refer_received(linphone_gtk_get_core(),uri);
|
||||
break;
|
||||
};
|
||||
|
||||
g_free(buf);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -71,14 +86,16 @@ static void linphone_gtk_init_pipe(const char *name){
|
|||
ms_thread_create(&pipe_thread,NULL,server_pipe_thread,NULL);
|
||||
}
|
||||
|
||||
bool_t linphone_gtk_init_instance(const char *app_name, const char *addr_to_call){
|
||||
bool_t linphone_gtk_init_instance(const char *app_name, int option, const char *addr_to_call){
|
||||
pipe_name=make_name(app_name);
|
||||
ortp_pipe_t p=ortp_client_pipe_connect(pipe_name);
|
||||
if (p!=(ortp_pipe_t)-1){
|
||||
uint8_t buf[256]={0};
|
||||
g_message("There is already a running instance.");
|
||||
if (addr_to_call!=NULL){
|
||||
strncpy((char*)buf,addr_to_call,sizeof(buf)-1);
|
||||
sprintf((char *)buf,"%i%s",option,addr_to_call);
|
||||
} else {
|
||||
sprintf((char *)buf,"%i",option);
|
||||
}
|
||||
if (ortp_pipe_write(p,buf,sizeof(buf))==-1){
|
||||
g_error("Fail to send wakeup command to running instance: %s",strerror(errno));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue