diff --git a/linphone/coreapi/linphonecore.c b/linphone/coreapi/linphonecore.c index 8f0c3c56f..23b07c2c2 100644 --- a/linphone/coreapi/linphonecore.c +++ b/linphone/coreapi/linphonecore.c @@ -2034,6 +2034,14 @@ const char *linphone_core_get_video_device(const LinphoneCore *lc){ return NULL; } +unsigned long linphone_core_get_native_video_window_id(const LinphoneCore *lc){ + if (lc->videostream) + return video_stream_get_native_window_id(lc->videostream); + if (lc->previewstream) + return video_stream_get_native_window_id(lc->previewstream); + return 0; +} + static MSVideoSizeDef supported_resolutions[]={ { MS_VIDEO_SIZE_SVGA , "svga" }, { MS_VIDEO_SIZE_4CIF , "4cif" }, diff --git a/linphone/coreapi/linphonecore.h b/linphone/coreapi/linphonecore.h index ef9db16fc..7b9416b77 100644 --- a/linphone/coreapi/linphonecore.h +++ b/linphone/coreapi/linphonecore.h @@ -702,7 +702,8 @@ const char** linphone_core_get_video_devices(const LinphoneCore *lc); int linphone_core_set_video_device(LinphoneCore *lc, const char *id); const char *linphone_core_get_video_device(const LinphoneCore *lc); - +/*function to be used for eventually setting window decorations (icons, title...)*/ +unsigned long linphone_core_get_native_video_window_id(const LinphoneCore *lc); /*play/record support: use files instead of soundcard*/ diff --git a/linphone/gtk-glade/main.c b/linphone/gtk-glade/main.c index 84a8721a2..5a06944c0 100644 --- a/linphone/gtk-glade/main.c +++ b/linphone/gtk-glade/main.c @@ -246,8 +246,39 @@ void linphone_gtk_show_about(){ gtk_widget_show(about); } +static void set_video_window_decorations(GdkWindow *w){ + const char *title=linphone_gtk_get_ui_config("title","Linphone"); + 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); + gdk_window_set_title(w,video_title); + if (pbuf){ + GList *l=NULL; + l=g_list_append(l,pbuf); + gdk_window_set_icon_list(w,l); + g_list_free(l); + g_object_unref(G_OBJECT(pbuf)); + } +} + static gboolean linphone_gtk_iterate(LinphoneCore *lc){ + unsigned long id; + static unsigned long previd=0; linphone_core_iterate(lc); + id=linphone_core_get_native_video_window_id(lc); + if (id!=previd){ + GdkWindow *w; + previd=id; + if (id!=0){ + w=gdk_window_foreign_new(id); + if (w) { + set_video_window_decorations(w); + g_object_unref(G_OBJECT(w)); + } + else ms_error("gdk_window_foreign_new() failed"); + } + } return TRUE; } @@ -693,18 +724,21 @@ static void linphone_gtk_check_menu_items(void){ static void linphone_gtk_configure_main_window(){ static gboolean config_loaded=FALSE; static gboolean show_digits=1; + static gboolean show_identities=1; static const char *title; static const char *home; static const char *icon_path; GtkWidget *w=linphone_gtk_get_main_window(); if (!config_loaded){ show_digits=linphone_gtk_get_ui_config_int("show_digits",1); + show_identities=linphone_gtk_get_ui_config_int("identity_frame",1); title=linphone_gtk_get_ui_config("title",NULL); home=linphone_gtk_get_ui_config("home","http://www.linphone.org"); icon_path=linphone_gtk_get_ui_config("icon",NULL); config_loaded=TRUE; } - if (show_digits==0) gtk_widget_hide(linphone_gtk_get_widget(w,"dialpad")); + if (show_digits==FALSE) gtk_widget_hide(linphone_gtk_get_widget(w,"dialpad")); + if (show_identities==FALSE) gtk_widget_hide(linphone_gtk_get_widget(w,"identity_frame")); if (title) gtk_window_set_title(GTK_WINDOW(w),title); if (icon_path) { GdkPixbuf *pbuf=create_pixbuf(icon_path); diff --git a/linphone/gtk-glade/main.glade b/linphone/gtk-glade/main.glade index a02bfbe50..743605db1 100644 --- a/linphone/gtk-glade/main.glade +++ b/linphone/gtk-glade/main.glade @@ -1,6 +1,6 @@ - + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -426,235 +426,17 @@ Online users 4 True - + True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 1 - 0 - - - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 2 - 0 - - - 1 - 2 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 3 - 0 - - - 2 - 3 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - A + D 0 3 4 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 4 - 0 - - - 1 - 2 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - 0 - - - 1 - 2 - 1 - 2 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 6 - 0 - - - 2 - 3 - 1 - 2 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - B - 0 - - - 3 - 4 - 1 - 2 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 7 - 0 - - - 2 - 3 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 8 - 0 - - - 1 - 2 - 2 - 3 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 9 - 0 - - - 2 - 3 - 2 - 3 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - C - 0 - - - 3 - 4 - 2 - 3 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - * - 0 - - - 3 - 4 - - - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - 0 - - - 1 - 2 3 4 @@ -680,19 +462,237 @@ Online users - + True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - D + 0 + 0 + + + 1 + 2 + 3 + 4 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + * + 0 + + + 3 + 4 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + C 0 3 4 - 3 - 4 + 2 + 3 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 9 + 0 + + + 2 + 3 + 2 + 3 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 8 + 0 + + + 1 + 2 + 2 + 3 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 7 + 0 + + + 2 + 3 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + B + 0 + + + 3 + 4 + 1 + 2 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 6 + 0 + + + 2 + 3 + 1 + 2 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + 0 + + + 1 + 2 + 1 + 2 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 4 + 0 + + + 1 + 2 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + A + 0 + + + 3 + 4 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 3 + 0 + + + 2 + 3 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 2 + 0 + + + 1 + 2 + + + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 1 + 0 + + @@ -729,7 +729,7 @@ Online users - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 diff --git a/linphone/mediastreamer2/include/mediastreamer2/mediastream.h b/linphone/mediastreamer2/include/mediastreamer2/mediastream.h index f4a81c619..46507d4d5 100644 --- a/linphone/mediastreamer2/include/mediastreamer2/mediastream.h +++ b/linphone/mediastreamer2/include/mediastreamer2/mediastream.h @@ -142,6 +142,8 @@ void video_stream_send_vfu(VideoStream *stream); void video_stream_stop(VideoStream * stream); void video_stream_set_sent_video_size(VideoStream *stream, MSVideoSize vsize); void video_stream_enable_self_view(VideoStream *stream, bool_t val); +unsigned long video_stream_get_native_window_id(VideoStream *stream); + VideoStream * video_preview_start(MSWebCam *device, MSVideoSize vsize); void video_preview_stop(VideoStream *stream); diff --git a/linphone/mediastreamer2/include/mediastreamer2/msvideoout.h b/linphone/mediastreamer2/include/mediastreamer2/msvideoout.h index 6081b7845..0384f6d39 100644 --- a/linphone/mediastreamer2/include/mediastreamer2/msvideoout.h +++ b/linphone/mediastreamer2/include/mediastreamer2/msvideoout.h @@ -52,6 +52,7 @@ typedef struct _MSDisplay{ MSDisplayDesc *desc; long window_id; /*window id if the display should use an existing window*/ void *data; + bool_t use_external_window; } MSDisplay; @@ -94,6 +95,7 @@ void ms_display_destroy(MSDisplay *d); #define MS_VIDEO_OUT_SET_CORNER MS_FILTER_METHOD(MS_VIDEO_OUT_ID,2,int) #define MS_VIDEO_OUT_AUTO_FIT MS_FILTER_METHOD(MS_VIDEO_OUT_ID,3,int) #define MS_VIDEO_OUT_ENABLE_MIRRORING MS_FILTER_METHOD(MS_VIDEO_OUT_ID,4,int) +#define MS_VIDEO_OUT_GET_NATIVE_WINDOW_ID MS_FILTER_METHOD(MS_VIDEO_OUT_ID,5,unsigned long) #ifdef __cplusplus } diff --git a/linphone/mediastreamer2/src/videoout.c b/linphone/mediastreamer2/src/videoout.c index 7d3055584..dc92f4f3d 100644 --- a/linphone/mediastreamer2/src/videoout.c +++ b/linphone/mediastreamer2/src/videoout.c @@ -53,6 +53,17 @@ static SDL_Surface *sdl_screen=0; #include +static long sdl_get_native_window_id(){ + SDL_SysWMinfo info; + SDL_VERSION(&info.version); + if ( SDL_GetWMInfo(&info) ) { + if ( info.subsystem == SDL_SYSWM_X11 ) { + return (long) info.info.x11.wmwindow; + } + } + return 0; +} + static void sdl_show_window(bool_t show){ SDL_SysWMinfo info; SDL_VERSION(&info.version); @@ -79,6 +90,11 @@ static void sdl_show_window(bool_t show){ ms_warning("SDL window show/hide not implemented"); } +static long sdl_get_native_window_id(){ + ms_warning("sdl_get_native_window_id not implemented"); + return 0; +} + #endif static void sdl_display_uninit(MSDisplay *obj); @@ -92,7 +108,7 @@ 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("Linphone Video", NULL); + SDL_WM_SetCaption("Video window", NULL); ms_message("Using yuv overlay."); lay=SDL_CreateYUVOverlay(w , h ,SDL_YV12_OVERLAY,sdl_screen); if (lay==NULL){ @@ -137,6 +153,7 @@ static bool_t sdl_display_init(MSDisplay *obj, MSPicture *fbuf){ fbuf->h=lay->h; obj->data=lay; sdl_show_window(TRUE); + obj->window_id=sdl_get_native_window_id(); return TRUE; } return FALSE; @@ -207,7 +224,7 @@ MSDisplayDesc ms_sdl_display_desc={ .unlock=sdl_display_unlock, .update=sdl_display_update, .uninit=sdl_display_uninit, - .pollevent=sdl_poll_event + .pollevent=sdl_poll_event, }; #elif defined(WIN32) @@ -325,7 +342,7 @@ static bool_t win_display_init(MSDisplay *obj, MSPicture *fbuf){ wd->fb.h=fbuf->h; if (wd->window==NULL){ - if (obj->window_id!=0){ + if (obj->use_external_window && obj->window_id!=0){ void *p; wd->window=(HWND)obj->window_id; p=(void*)GetWindowLongPtr(wd->window,GWLP_USERDATA); @@ -335,10 +352,11 @@ static bool_t win_display_init(MSDisplay *obj, MSPicture *fbuf){ }else SetWindowLongPtr(wd->window,GWLP_USERDATA,(LONG_PTR)obj); }else{ wd->window=create_window(wd->fb.w,wd->fb.h); + obj->window_id=wd->window; if (wd->window!=NULL) SetWindowLongPtr(wd->window,GWLP_USERDATA,(LONG_PTR)obj); else return FALSE; } - }else if (obj->window_id==0){ + }else if (!obj->use_external_window){ /* the window might need to be resized*/ RECT cur; GetWindowRect(wd->window,&cur); @@ -488,6 +506,7 @@ MSDisplay *ms_display_new(MSDisplayDesc *desc){ void ms_display_set_window_id(MSDisplay *d, long id){ d->window_id=id; + d->use_external_window=TRUE; } void ms_display_destroy(MSDisplay *obj){ @@ -827,6 +846,17 @@ static int video_out_enable_mirroring(MSFilter *f,void *arg){ return 0; } +static int video_out_get_native_window_id(MSFilter *f, void*arg){ + VideoOut *s=(VideoOut*)f->data; + unsigned long *id=(unsigned long*)arg; + *id=0; + if (s->display){ + *id=s->display->window_id; + return 0; + } + return -1; +} + static MSFilterMethod methods[]={ { MS_FILTER_SET_VIDEO_SIZE , video_out_set_vsize }, { MS_VIDEO_OUT_SET_DISPLAY , video_out_set_display}, @@ -834,6 +864,7 @@ static MSFilterMethod methods[]={ { MS_VIDEO_OUT_AUTO_FIT , video_out_auto_fit}, { MS_VIDEO_OUT_HANDLE_RESIZING , video_out_handle_resizing}, { MS_VIDEO_OUT_ENABLE_MIRRORING , video_out_enable_mirroring}, + { MS_VIDEO_OUT_GET_NATIVE_WINDOW_ID, video_out_get_native_window_id}, { 0 ,NULL} }; diff --git a/linphone/mediastreamer2/src/videostream.c b/linphone/mediastreamer2/src/videostream.c index 2bd79ab68..82d7a4b7c 100644 --- a/linphone/mediastreamer2/src/videostream.c +++ b/linphone/mediastreamer2/src/videostream.c @@ -345,6 +345,14 @@ void video_stream_set_rtcp_information(VideoStream *st, const char *cname, const } } +unsigned long video_stream_get_native_window_id(VideoStream *stream){ + unsigned long id; + if (stream->output){ + if (ms_filter_call_method(stream->output,MS_VIDEO_OUT_GET_NATIVE_WINDOW_ID,&id)==0) + return id; + } + return 0; +} VideoStream * video_preview_start(MSWebCam *device, MSVideoSize disp_size){