Commit b9ffc926 authored by smorlat's avatar smorlat
Browse files

- new in-call view

- set name of remote people as title of the video window.

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@562 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent d6106f82
linphone-3.1.2 --
linphone-3.2.0 --
* new in-call layout
* new idle view with two buttons
* ability to dial the number from dialpad
linphone-3.1.2 -- May 5, 2009
* make it work with lastest ffmpeg swscale
* improve theora packer
* update theora default settings to match performance of 1.0 release.
......
......@@ -79,6 +79,7 @@ int lc_callback_obj_invoke(LCCallbackObj *obj, LinphoneCore *lc){
static void linphone_call_init_common(LinphoneCall *call, char *from, char *to){
call->state=LCStateInit;
call->start_time=time(NULL);
call->media_start_time=0;
call->log=linphone_call_log_new(call, from, to);
linphone_core_notify_all_friends(call->core,LINPHONE_STATUS_ONTHEPHONE);
if (linphone_core_get_firewall_policy(call->core)==LINPHONE_POLICY_USE_STUN)
......@@ -251,7 +252,14 @@ void linphone_call_log_destroy(LinphoneCallLog *cl){
int linphone_core_get_current_call_duration(const LinphoneCore *lc){
LinphoneCall *call=lc->call;
if (call==NULL) return 0;
return time(NULL)-call->start_time;
if (call->media_start_time==0) return 0;
return time(NULL)-call->media_start_time;
}
const char *linphone_core_get_remote_uri(LinphoneCore *lc){
LinphoneCall *call=lc->call;
if (call==NULL) return 0;
return call->dir==LinphoneCallIncoming ? call->log->from : call->log->to;
}
void _osip_trace_func(char *fi, int li, osip_trace_level_t level, char *chfr, va_list ap){
......@@ -1541,6 +1549,9 @@ void linphone_core_start_media_streams(LinphoneCore *lc, LinphoneCall *call){
const char *tool="linphone-" LINPHONE_VERSION;
/* adjust rtp jitter compensation. It must be at least the latency of the sound card */
int jitt_comp=MAX(lc->sound_conf.latency,lc->rtp_conf.audio_jitt_comp);
if (call->media_start_time==0) call->media_start_time=time(NULL);
char *cname=ortp_strdup_printf("%s@%s",me->url->username,me->url->host);
{
StreamParams *audio_params=&call->audio_params;
......
......@@ -186,7 +186,8 @@ typedef struct _LinphoneCall
int did; /*dialog id */
int tid; /*last transaction id*/
struct _sdp_context *sdpctx;
time_t start_time;
time_t start_time; /*time at which the call was initiated*/
time_t media_start_time; /*time at which it was accepted, media streams established*/
LCState state;
bool_t auth_pending;
} LinphoneCall;
......@@ -771,6 +772,7 @@ void linphone_core_set_record_file(LinphoneCore *lc, const char *file);
gstate_t linphone_core_get_state(const LinphoneCore *lc, gstate_group_t group);
int linphone_core_get_current_call_duration(const LinphoneCore *lc);
const char *linphone_core_get_remote_uri(LinphoneCore *lc);
int linphone_core_get_mtu(const LinphoneCore *lc);
void linphone_core_set_mtu(LinphoneCore *lc, int mtu);
......
......@@ -35,6 +35,7 @@ linphone_3_SOURCES= main.c \
buddylookup.c \
utils.c \
setupwizard.c\
incall_view.c \
linphone.h
linphone_3_LDADD=$(top_builddir)/oRTP/src/libortp.la \
......
/*
* C Implementation: incall_frame
*
* Description:
*
*
* Author: Simon Morlat <simon.morlat@linphone.org>, (C) 2009
*
* Copyright: See COPYING file that comes with this distribution
*
*/
#include "linphone.h"
void linphone_gtk_show_in_call_view(void){
GtkWidget *main_window=linphone_gtk_get_main_window();
GtkWidget *idle_frame=linphone_gtk_get_widget(main_window,"idle_frame");
GtkWidget *in_call_frame=linphone_gtk_get_widget(main_window,"in_call_frame");
gtk_widget_hide(idle_frame);
gtk_widget_show(in_call_frame);
}
void linphone_gtk_show_idle_view(void){
GtkWidget *main_window=linphone_gtk_get_main_window();
GtkWidget *idle_frame=linphone_gtk_get_widget(main_window,"idle_frame");
GtkWidget *in_call_frame=linphone_gtk_get_widget(main_window,"in_call_frame");
gtk_widget_show(idle_frame);
gtk_widget_hide(in_call_frame);
}
void linphone_gtk_in_call_view_set_calling(const char *uri){
GtkWidget *main_window=linphone_gtk_get_main_window();
GtkWidget *status=linphone_gtk_get_widget(main_window,"in_call_status");
GtkWidget *callee=linphone_gtk_get_widget(main_window,"in_call_uri");
GtkWidget *duration=linphone_gtk_get_widget(main_window,"in_call_duration");
GtkWidget *animation=linphone_gtk_get_widget(main_window,"in_call_animation");
GdkPixbufAnimation *pbuf=create_pixbuf_animation("calling_anim.gif");
GtkWidget *terminate_button=linphone_gtk_get_widget(main_window,"in_call_terminate");
char *uri_label;
gtk_widget_set_sensitive(terminate_button,TRUE);
gtk_label_set_markup(GTK_LABEL(status),_("<b>Calling...</b>"));
uri_label=g_markup_printf_escaped("<span size=\"large\"><i>%s</i></span>", uri);
gtk_label_set_markup(GTK_LABEL(callee),uri_label);
g_free(uri_label);
gtk_label_set_text(GTK_LABEL(duration),"00:00:00");
if (pbuf!=NULL){
gtk_image_set_from_animation(GTK_IMAGE(animation),pbuf);
g_object_unref(G_OBJECT(pbuf));
}else gtk_image_set_from_stock(GTK_IMAGE(animation),GTK_STOCK_INFO,GTK_ICON_SIZE_DIALOG);
}
void linphone_gtk_in_call_view_set_in_call(const char *uri){
GtkWidget *main_window=linphone_gtk_get_main_window();
GtkWidget *status=linphone_gtk_get_widget(main_window,"in_call_status");
GtkWidget *callee=linphone_gtk_get_widget(main_window,"in_call_uri");
GtkWidget *duration=linphone_gtk_get_widget(main_window,"in_call_duration");
char *uri_label;
GtkWidget *animation=linphone_gtk_get_widget(main_window,"in_call_animation");
GdkPixbufAnimation *pbuf=create_pixbuf_animation("incall_anim.gif");
GtkWidget *terminate_button=linphone_gtk_get_widget(main_window,"in_call_terminate");
gtk_widget_set_sensitive(terminate_button,TRUE);
gtk_label_set_markup(GTK_LABEL(status),_("<b>In call with</b>"));
uri_label=g_markup_printf_escaped("<span size=\"large\"><i>%s</i></span>", uri);
gtk_label_set_markup(GTK_LABEL(callee),uri_label);
g_free(uri_label);
gtk_label_set_text(GTK_LABEL(duration),_("00::00::00"));
if (pbuf!=NULL){
gtk_image_set_from_animation(GTK_IMAGE(animation),pbuf);
g_object_unref(G_OBJECT(pbuf));
}else gtk_image_set_from_stock(GTK_IMAGE(animation),GTK_STOCK_INFO,GTK_ICON_SIZE_DIALOG);
}
void linphone_gtk_in_call_view_update_duration(int duration){
GtkWidget *main_window=linphone_gtk_get_main_window();
GtkWidget *duration_label=linphone_gtk_get_widget(main_window,"in_call_duration");
char tmp[256]={0};
int seconds=duration%60;
int minutes=(duration/60)%60;
int hours=duration/3600;
snprintf(tmp,sizeof(tmp)-1,_("%02i::%02i::%02i"),hours,minutes,seconds);
gtk_label_set_text(GTK_LABEL(duration_label),tmp);
}
static gboolean in_call_view_terminated(){
linphone_gtk_show_idle_view();
return FALSE;
}
void linphone_gtk_in_call_view_terminate(const char *error_msg){
GtkWidget *main_window=linphone_gtk_get_main_window();
GtkWidget *status=linphone_gtk_get_widget(main_window,"in_call_status");
GtkWidget *animation=linphone_gtk_get_widget(main_window,"in_call_animation");
GtkWidget *terminate_button=linphone_gtk_get_widget(main_window,"in_call_terminate");
GdkPixbuf *pbuf=create_pixbuf(linphone_gtk_get_ui_config("stop_call_icon","red.png"));
gtk_widget_set_sensitive(terminate_button,FALSE);
if (error_msg==NULL)
gtk_label_set_markup(GTK_LABEL(status),_("<b>Call ended.</b>"));
else{
char *msg=g_markup_printf_escaped("<span color=\"red\"><b>%s</b></span>",error_msg);
gtk_label_set_markup(GTK_LABEL(status),msg);
g_free(msg);
}
if (pbuf!=NULL){
gtk_image_set_from_pixbuf(GTK_IMAGE(animation),pbuf);
g_object_unref(G_OBJECT(pbuf));
}
g_timeout_add_seconds(2,(GSourceFunc)in_call_view_terminated,NULL);
}
......@@ -34,6 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#endif
GdkPixbuf * create_pixbuf(const gchar *filename);
GdkPixbufAnimation *create_pixbuf_animation(const gchar *filename);
void add_pixmap_directory(const gchar *directory);
GtkWidget *linphone_gtk_create_window(const char *window_name);
GtkWidget *linphone_gtk_get_widget(GtkWidget *window, const char *name);
......@@ -41,6 +42,7 @@ LinphoneCore *linphone_gtk_get_core(void);
GtkWidget *linphone_gtk_get_main_window();
void linphone_gtk_display_something(GtkMessageType type,const gchar *message);
void linphone_gtk_start_call(GtkWidget *button);
void linphone_gtk_call_terminated();
void linphone_gtk_show_friends(void);
void linphone_gtk_show_contact(LinphoneFriend *lf);
void linphone_gtk_set_my_presence(LinphoneOnlineStatus ss);
......@@ -63,3 +65,12 @@ void linphone_gtk_set_lang(const char *code);
SipSetupContext* linphone_gtk_get_default_sip_setup_context(void);
void linphone_gtk_show_buddy_lookup_window(SipSetupContext *ctx);
void * linphone_gtk_wait(LinphoneCore *lc, void *ctx, LinphoneWaitingState ws, const char *purpose, float progress);
gchar *linphone_gtk_get_display_name(const char *sip_uri);
/*functions controlling the in-call view*/
void linphone_gtk_show_in_call_view(void);
void linphone_gtk_show_idle_view(void);
void linphone_gtk_in_call_view_set_calling(const char *uri);
void linphone_gtk_in_call_view_set_in_call(const char *uri);
void linphone_gtk_in_call_view_update_duration(int duration);
void linphone_gtk_in_call_view_terminate(const char *error_msg);
......@@ -304,8 +304,17 @@ static void set_video_window_decorations(GdkWindow *w){
const char *icon_path=linphone_gtk_get_ui_config("icon","linphone2.png");
char video_title[256];
GdkPixbuf *pbuf=create_pixbuf(icon_path);
snprintf(video_title,sizeof(video_title),"%s video",title);
if (!linphone_core_in_call(linphone_gtk_get_core())){
snprintf(video_title,sizeof(video_title),"%s video",title);
}else{
const char *uri=linphone_core_get_remote_uri(linphone_gtk_get_core());
gchar *display_name=linphone_gtk_get_display_name(uri);
snprintf(video_title,sizeof(video_title),"Call with %s",display_name);
g_free(display_name);
}
gdk_window_set_title(w,video_title);
/*gdk_window_set_urgency_hint(w,TRUE);*/
gdk_window_raise(w);
if (pbuf){
GList *l=NULL;
l=g_list_append(l,pbuf);
......@@ -315,6 +324,11 @@ static void set_video_window_decorations(GdkWindow *w){
}
}
static gboolean video_needs_update=FALSE;
static void update_video_title(){
video_needs_update=TRUE;
}
static gboolean linphone_gtk_iterate(LinphoneCore *lc){
unsigned long id;
......@@ -326,11 +340,11 @@ static gboolean linphone_gtk_iterate(LinphoneCore *lc){
in_iterate=TRUE;
linphone_core_iterate(lc);
id=linphone_core_get_native_video_window_id(lc);
if (id!=previd){
ms_message("Updating window decorations");
if (id!=previd || video_needs_update){
GdkWindow *w;
previd=id;
if (id!=0){
ms_message("Updating window decorations");
#ifndef WIN32
w=gdk_window_foreign_new(id);
#else
......@@ -341,6 +355,7 @@ static gboolean linphone_gtk_iterate(LinphoneCore *lc){
g_object_unref(G_OBJECT(w));
}
else ms_error("gdk_window_foreign_new() failed");
if (video_needs_update) video_needs_update=FALSE;
}
}
in_iterate=FALSE;
......@@ -419,37 +434,56 @@ static void completion_add_text(GtkEntry *entry, const char *text){
save_uri_history();
}
static void linphone_gtk_call_terminated(GtkWidget *mw){
void linphone_gtk_call_terminated(const char *error){
GtkWidget *mw=linphone_gtk_get_main_window();
gtk_widget_set_sensitive(linphone_gtk_get_widget(mw,"terminate_call"),FALSE);
gtk_widget_set_sensitive(linphone_gtk_get_widget(mw,"start_call"),TRUE);
gtk_widget_hide(linphone_gtk_get_widget(mw,"go_to_call_view"));
linphone_gtk_in_call_view_terminate(error);
update_video_title();
g_object_set_data(G_OBJECT(mw),"incoming_call",NULL);
}
gboolean check_call_active(){
if (!linphone_core_in_call(linphone_gtk_get_core())){
linphone_gtk_call_terminated(linphone_gtk_get_main_window());
return FALSE;
static gboolean in_call_timer(){
if (linphone_core_in_call(linphone_gtk_get_core())){
linphone_gtk_in_call_view_update_duration(
linphone_core_get_current_call_duration(linphone_gtk_get_core()));
return TRUE;
}
return TRUE;
return FALSE;
}
static void linphone_gtk_call_started(GtkWidget *mw){
gtk_widget_set_sensitive(linphone_gtk_get_widget(mw,"start_call"),FALSE);
gtk_widget_set_sensitive(linphone_gtk_get_widget(mw,"terminate_call"),TRUE);
g_timeout_add(250,(GSourceFunc)check_call_active,NULL);
gtk_widget_show(linphone_gtk_get_widget(mw,"go_to_call_view"));
update_video_title();
g_timeout_add(250,(GSourceFunc)in_call_timer,NULL);
}
static gboolean linphone_gtk_start_call_do(GtkWidget *uri_bar){
const char *entered=gtk_entry_get_text(GTK_ENTRY(uri_bar));
if (linphone_core_invite(linphone_gtk_get_core(),entered)==0) {
completion_add_text(GTK_ENTRY(uri_bar),entered);
}else{
}
return FALSE;
}
void linphone_gtk_start_call(GtkWidget *w){
LinphoneCore *lc=linphone_gtk_get_core();
if (linphone_core_inc_invite_pending(lc)){
if (linphone_core_inc_invite_pending(lc) || linphone_core_in_call(lc)) {
/*already in call */
}else{
GtkWidget *uri_bar=linphone_gtk_get_widget(gtk_widget_get_toplevel(w),"uribar");
/*change into in-call mode, then do the work later as it might block a bit */
GtkWidget *mw=gtk_widget_get_toplevel(w);
GtkWidget *uri_bar=linphone_gtk_get_widget(mw,"uribar");
const char *entered=gtk_entry_get_text(GTK_ENTRY(uri_bar));
if (linphone_core_invite(lc,entered)==0) {
linphone_gtk_call_started(linphone_gtk_get_main_window());
completion_add_text(GTK_ENTRY(uri_bar),entered);
}
linphone_gtk_call_started(mw);
linphone_gtk_in_call_view_set_calling(entered);
linphone_gtk_show_in_call_view();
g_timeout_add(100,(GSourceFunc)linphone_gtk_start_call_do,uri_bar);
}
}
......@@ -460,20 +494,21 @@ void linphone_gtk_uri_bar_activate(GtkWidget *w){
void linphone_gtk_terminate_call(GtkWidget *button){
linphone_core_terminate_call(linphone_gtk_get_core(),NULL);
linphone_gtk_call_terminated(gtk_widget_get_toplevel(button));
}
void linphone_gtk_decline_call(GtkWidget *button){
linphone_core_terminate_call(linphone_gtk_get_core(),NULL);
linphone_gtk_call_terminated(linphone_gtk_get_main_window());
gtk_widget_destroy(gtk_widget_get_toplevel(button));
}
void linphone_gtk_accept_call(GtkWidget *button){
linphone_core_accept_call(linphone_gtk_get_core(),NULL);
LinphoneCore *lc=linphone_gtk_get_core();
linphone_core_accept_call(lc,NULL);
g_object_set_data(G_OBJECT(linphone_gtk_get_main_window()),"incoming_call",NULL);
gtk_widget_destroy(gtk_widget_get_toplevel(button));
linphone_gtk_call_started(linphone_gtk_get_main_window());
linphone_gtk_in_call_view_set_in_call(linphone_core_get_remote_uri(lc));
linphone_gtk_show_in_call_view();
}
void linphone_gtk_set_audio_video(){
......@@ -535,7 +570,6 @@ static void linphone_gtk_bye_recv(LinphoneCore *lc, const char *from){
if (icw!=NULL){
gtk_widget_destroy(icw);
}
linphone_gtk_call_terminated(linphone_gtk_get_main_window());
}
static void linphone_gtk_notify_recv(LinphoneCore *lc, LinphoneFriend * fid, const char *url, const char *status, const char *img){
......@@ -667,6 +701,20 @@ static void linphone_gtk_call_log_updated(LinphoneCore *lc, LinphoneCallLog *cl)
}
static void linphone_gtk_general_state(LinphoneCore *lc, LinphoneGeneralState *gstate){
switch(gstate->new_state){
case GSTATE_CALL_OUT_CONNECTED:
case GSTATE_CALL_IN_CONNECTED:
linphone_gtk_in_call_view_set_in_call(linphone_core_get_remote_uri(lc));
break;
case GSTATE_CALL_ERROR:
linphone_gtk_call_terminated(gstate->message);
break;
case GSTATE_CALL_END:
linphone_gtk_call_terminated(NULL);
break;
default:
break;
}
}
static void icon_popup_menu(GtkStatusIcon *status_icon, guint button, guint activate_time, gpointer user_data){
......@@ -769,7 +817,13 @@ void linphone_gtk_load_identities(void){
static void linphone_gtk_dtmf_clicked(GtkButton *button){
const char *label=gtk_button_get_label(button);
linphone_core_send_dtmf(linphone_gtk_get_core(),label[0]);
if (linphone_core_in_call(linphone_gtk_get_core())){
linphone_core_send_dtmf(linphone_gtk_get_core(),label[0]);
}else{
GtkWidget *uri_bar=linphone_gtk_get_widget(gtk_widget_get_toplevel(GTK_WIDGET(button)),"uribar");
int pos=-1;
gtk_editable_insert_text(GTK_EDITABLE(uri_bar),label,1,&pos);
}
}
static void linphone_gtk_connect_digits(void){
......@@ -863,7 +917,7 @@ void linphone_gtk_close(){
/*shutdown call if any*/
if (linphone_core_in_call(lc)){
linphone_core_terminate_call(lc,NULL);
linphone_gtk_call_terminated(the_ui);
linphone_gtk_call_terminated(NULL);
}
linphone_core_enable_video_preview(lc,FALSE);
}
......
This diff is collapsed.
......@@ -86,6 +86,36 @@ create_pixbuf (const gchar *filename)
return pixbuf;
}
/* This is an internally used function to create animations */
GdkPixbufAnimation *
create_pixbuf_animation(const gchar *filename)
{
gchar *pathname = NULL;
GdkPixbufAnimation *pixbuf;
GError *error = NULL;
if (!filename || !filename[0])
return NULL;
pathname = find_pixmap_file (filename);
if (!pathname){
g_warning (_("Couldn't find pixmap file: %s"), filename);
return NULL;
}
pixbuf = gdk_pixbuf_animation_new_from_file (pathname, &error);
if (!pixbuf){
fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
pathname, error->message);
g_error_free (error);
}
g_free (pathname);
return pixbuf;
}
/* This is used to set ATK action descriptions. */
void
glade_set_atk_action_description (AtkAction *action,
......@@ -126,6 +156,12 @@ const char *linphone_gtk_get_lang(const char *config_file){
void linphone_gtk_set_lang(const char *code){
LpConfig *cfg=linphone_core_get_config(linphone_gtk_get_core());
const char *curlang;
curlang=getenv("LANG");
if (curlang!=NULL && strncmp(curlang,code,2)==0) {
/* do not loose the _territory@encoding part*/
return;
}
lp_config_set_string(cfg,"GtkUi","lang",code);
#ifdef WIN32
char tmp[128];
......
......@@ -75,3 +75,20 @@ void *linphone_gtk_wait(LinphoneCore *lc, void *ctx, LinphoneWaitingState ws, co
}
return NULL;
}
gchar *linphone_gtk_get_display_name(const char *sip_uri){
osip_from_t *from;
gchar *ret=NULL;
if (strchr(sip_uri,'@')){
osip_from_init(&from);
if (osip_from_parse(from,sip_uri)==0){
if (from->displayname!=NULL && strlen(from->displayname)>0){
ret=g_strdup(from->displayname);
}
}
osip_from_free(from);
}
if (ret==NULL) ret=g_strdup(sip_uri);
return ret;
}
......@@ -100,6 +100,7 @@ static long sdl_get_native_window_id(){
static void sdl_display_uninit(MSDisplay *obj);
static SDL_Overlay * sdl_create_window(int w, int h){
static bool_t once=TRUE;
SDL_Overlay *lay;
sdl_screen = SDL_SetVideoMode(w,h, 0,SDL_SWSURFACE|SDL_RESIZABLE);
if (sdl_screen == NULL ) {
......@@ -108,7 +109,10 @@ static SDL_Overlay * sdl_create_window(int w, int h){
return NULL;
}
if (sdl_screen->flags & SDL_HWSURFACE) ms_message("SDL surface created in hardware");
SDL_WM_SetCaption("Video window", NULL);
if (once) {
SDL_WM_SetCaption("Video window", NULL);
once=FALSE;
}
ms_message("Using yuv overlay.");
lay=SDL_CreateYUVOverlay(w , h ,SDL_YV12_OVERLAY,sdl_screen);
if (lay==NULL){
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment