]> sjero.net Git - linphone/commitdiff
merge patch that add new "webcam" command to linphonec + setting of the static picture.
authorSimon Morlat <simon.morlat@linphone.org>
Thu, 25 Mar 2010 12:54:59 +0000 (13:54 +0100)
committerSimon Morlat <simon.morlat@linphone.org>
Thu, 25 Mar 2010 12:54:59 +0000 (13:54 +0100)
console/commands.c
console/linphonec.c
coreapi/linphonecore.c
coreapi/linphonecore.h
mediastreamer2

index d32e62667909e6939035f0b56a673e060a966e6d..1b65a9cdd93f533b1a32b449765864fb66655b5a 100644 (file)
@@ -65,6 +65,8 @@ static int lpc_cmd_stun(LinphoneCore *, char *);
 static int lpc_cmd_firewall(LinphoneCore *, char *);
 static int lpc_cmd_friend(LinphoneCore *, char*);
 static int lpc_cmd_soundcard(LinphoneCore *, char *);
+static int lpc_cmd_webcam(LinphoneCore *, char *);
+static int lpc_cmd_staticpic(LinphoneCore *, char *);
 static int lpc_cmd_play(LinphoneCore *, char *);
 static int lpc_cmd_record(LinphoneCore *, char *);
 static int lpc_cmd_register(LinphoneCore *, char *);
@@ -144,6 +146,13 @@ LPC_COMMAND commands[] = {
                "'soundcard use <index>' : select a sound device.\n"
                "'soundcard use files' : use .wav files instead of soundcard\n"
        },
+       { "webcam", lpc_cmd_webcam, "Manage webcams",
+               "'webcam list' : list all known devices.\n"
+               "'webcam use <index>' : select a video device.\n"
+       },
+       { "staticpic", lpc_cmd_staticpic, "Manage static pictures when nowebcam",
+               "'staticpic set' : Set path to picture that should be used.\n"
+       },
        { "ipv6", lpc_cmd_ipv6, "Use IPV6",
                "'ipv6 status' : show ipv6 usage status.\n"
                "'ipv6 enable' : enable the use of the ipv6 network.\n"
@@ -948,6 +957,79 @@ static int lpc_cmd_soundcard(LinphoneCore *lc, char *args)
        return 0; /* syntax error */
 }
 
+static int lpc_cmd_webcam(LinphoneCore *lc, char *args)
+{
+       int i, index;
+       const char **dev;
+       char *arg1 = args;
+       char *arg2 = NULL;
+       char *ptr = args;
+
+       if (!args) return 0; /* syntax error */
+
+       /* Isolate first and second arg */
+       while(*ptr && !isspace(*ptr)) ++ptr;
+       if ( *ptr )
+       {
+               *ptr='\0';
+               arg2=ptr+1;
+               while(*arg2 && isspace(*arg2)) ++arg2;
+       }
+
+       if (strcmp(arg1, "list")==0)
+       {
+               dev=linphone_core_get_video_devices(lc);
+               for(i=0; dev[i]!=NULL; ++i){
+                       linphonec_out("%i: %s\n",i,dev[i]);
+               }
+               return 1;
+       }
+
+       if (strcmp(arg1, "use")==0 && arg2)
+       {
+               dev=linphone_core_get_video_devices(lc);
+               index=atoi(arg2); /* FIXME: handle not-a-number */
+               for(i=0;dev[i]!=NULL;i++)
+               {
+                       if (i!=index) continue;
+
+                       linphone_core_set_video_device(lc, dev[i]);
+                       linphonec_out("Using video device %s\n",dev[i]);
+                       return 1;
+               }
+               linphonec_out("No such video device\n");
+               return 1;
+       }
+       return 0; /* syntax error */
+}
+
+static int
+lpc_cmd_staticpic(LinphoneCore *lc, char *args)
+{
+       char *arg1 = args;
+       char *arg2 = NULL;
+       char *ptr = args;
+
+       if (!args) return 0;  /* Syntax error */
+
+       /* Isolate first and second arg */
+       while(*ptr && !isspace(*ptr)) ++ptr;
+       if ( *ptr )
+       {
+               *ptr='\0';
+               arg2=ptr+1;
+               while(*arg2 && isspace(*arg2)) ++arg2;
+       }
+
+       if (strcmp(arg1, "set")==0 && arg2) {
+               return linphone_core_set_static_picture(lc, arg2);
+       }
+
+       return 0; /* Syntax error */
+}
+
+
+
 /***************************************************************************
  *
  *  Commands helper functions
index 2e0ca83426d504c0843b1dddfc314938d2c3258a..93b5da744b774f53a39c18334b92d76a4a542600 100644 (file)
@@ -513,6 +513,15 @@ char *linphonec_readline(char *prompt){
                        linphonec_idle_call();
 #ifdef WIN32
                        Sleep(20);
+                       /* Following is to get the video window going as it
+                                should. Maybe should we only have this on when the option -V
+                                or -D is on? */
+                       MSG msg;
+       
+                       if (PeekMessage(&msg, NULL, 0, 0,1)) {
+                               TranslateMessage(&msg);
+                               DispatchMessage(&msg);
+                       }
 #else
                        usleep(20000);
 #endif
index 62adf68fc1f35fdccde6e73e3aabaf249e195161..3a442f6604b4f58babf9280a818ce9140320f271 100644 (file)
@@ -3128,6 +3128,35 @@ const char *linphone_core_get_video_device(const LinphoneCore *lc){
        return NULL;
 }
 
+int linphone_core_set_static_picture(LinphoneCore *lc, const char *path) {
+       struct _VideoStream *vs = NULL;
+
+       /* Select the video stream from the call in the first place */
+       if (lc && lc->videostream) {
+               vs = lc->videostream;
+       }
+       /* If not in call, select the video stream from the preview */
+       if (vs == NULL && lc && lc->previewstream) {
+               vs = lc->previewstream;
+       }
+       
+       /* If we have a video stream (either preview, either from call), we
+                have a source and it is using the static picture filter, then
+                force the filter to use that picture. */
+       if (vs && vs->source) {
+               if (ms_filter_get_id(vs->source) == MS_STATIC_IMAGE_ID) {
+                       ms_filter_call_method(vs->source, MS_FILTER_SET_IMAGE,
+                                                                                                               (void *)path);
+               }
+       }
+
+       /* Tell the static image filter to use that image from now on so
+                that the image will be used next time it has to be read */
+       ms_static_image_set_default_image(path);
+
+       return 1;
+}
+
 /**
  * Returns the native window handle of the video window, casted as an unsigned long.
  *
index 6c8f0e208eb8caed1a2c97c4a63daf8cb4c7ca38..aa9d044848a83c8fc2620302830c5359dd393056 100644 (file)
@@ -898,6 +898,9 @@ 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);
 
+/* Set static picture to be used when "Static picture" is the video device */
+int linphone_core_set_static_picture(LinphoneCore *lc, const char *path);
+
 /*function to be used for eventually setting window decorations (icons, title...)*/
 unsigned long linphone_core_get_native_video_window_id(const LinphoneCore *lc);
 
index 5bcbcae29d9cf6d22b4f6880489eafa98e100008..705c57139cd2e3a7e2268dbdbe6a1c4e34392663 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 5bcbcae29d9cf6d22b4f6880489eafa98e100008
+Subproject commit 705c57139cd2e3a7e2268dbdbe6a1c4e34392663