From: <jpg...@us...> - 2007-10-03 17:17:07
|
Revision: 1166 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1166&view=rev Author: jpgrayson Date: 2007-10-03 10:17:10 -0700 (Wed, 03 Oct 2007) Log Message: ----------- Use more portable rand() instead of random(). We do not really need the extra randomness of random() anyway. Modified Paths: -------------- trunk/lib/video.c Modified: trunk/lib/video.c =================================================================== --- trunk/lib/video.c 2007-10-03 17:15:52 UTC (rev 1165) +++ trunk/lib/video.c 2007-10-03 17:17:10 UTC (rev 1166) @@ -15,6 +15,7 @@ */ #include <assert.h> +#include <stdlib.h> #include "video.h" #include "slice.h" @@ -893,8 +894,9 @@ { int i; - if ( sc == NULL ) - sc = create_slicer_context(random(), iaxc_video_fragsize); + if ( !sc ) + sc = create_slicer_context((unsigned short)rand(), + iaxc_video_fragsize); slice(data, size, &slice_set, sc); for ( i = 0 ; i < slice_set.num_slices ; i++ ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bc...@us...> - 2007-11-01 13:49:38
|
Revision: 1252 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1252&view=rev Author: bcholew Date: 2007-11-01 06:49:42 -0700 (Thu, 01 Nov 2007) Log Message: ----------- Ensure video capture device ids start at a fixed number - even if they weren't present at initialization. Modified Paths: -------------- trunk/lib/video.c Modified: trunk/lib/video.c =================================================================== --- trunk/lib/video.c 2007-10-31 19:01:27 UTC (rev 1251) +++ trunk/lib/video.c 2007-11-01 13:49:42 UTC (rev 1252) @@ -1371,19 +1371,14 @@ new_iaxc_dev_list[n].name = strdup(new_src_list[n].description); new_iaxc_dev_list[n].id_string = strdup(new_src_list[n].identifier); - /* this device may have been here all along - * Check if it has, and re-assign that device id + /* This device may have been here all along. + * If it has, re-assign that device id * else assign a new id */ for ( i = 0; i < vinfo.device_count; i++ ) { if ( !strcmp(new_iaxc_dev_list[n].name, vinfo.devices[i].name) ) { - /*fprintf(stderr, "EXISTING DEVICE: %s - (id=%d) '%s'\n", - new_iaxc_dev_list[n].name, - vinfo.devices[i].id, - new_iaxc_dev_list[n].id_string); - */ new_iaxc_dev_list[n].id = vinfo.devices[i].id; if ( vinfo.selected_device_id == new_iaxc_dev_list[n].id ) @@ -1394,10 +1389,6 @@ if ( i == vinfo.device_count ) { new_iaxc_dev_list[n].id = vinfo.next_id++; - fprintf(stderr, "NEW DEVICE: %s - (id=%d) '%s'\n", - new_iaxc_dev_list[n].name, - new_iaxc_dev_list[n].id, - new_iaxc_dev_list[n].id_string); list_changed = 1; } @@ -1530,12 +1521,14 @@ memset(&vinfo, 0, sizeof(vinfo)); - MUTEXINIT(&vinfo.camera_lock); - MUTEXINIT(&vinfo.dev_list_lock); - vinfo.width = vfinfo.width; vinfo.height = vfinfo.height; + vinfo.selected_device_id = -1; + vinfo.next_id = starting_id; + MUTEXINIT(&vinfo.camera_lock); + MUTEXINIT(&vinfo.dev_list_lock); + if ( !(vinfo.vc = vidcap_initialize()) ) { fprintf(stderr, "ERROR: failed vidcap_initialize\n"); @@ -1558,8 +1551,6 @@ vinfo.sapi_info.description, vinfo.sapi_info.identifier); - vinfo.selected_device_id = -1; - vinfo.device_count = vidcap_src_list_update(vinfo.sapi); if ( vinfo.device_count < 0 ) { @@ -1604,13 +1595,12 @@ * these ids may diverge as devices are added * and removed. */ - vinfo.devices[i].id = i + starting_id; + vinfo.devices[i].id = vinfo.next_id++; } - vinfo.next_id = vinfo.devices[vinfo.device_count - 1].id + 1; - /* set default source - the first device */ if ( vinfo.device_count ) { + /* set default source - the first device */ iaxc_video_device_set(vinfo.devices[0].id); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bc...@us...> - 2007-11-01 21:15:26
|
Revision: 1256 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1256&view=rev Author: bcholew Date: 2007-11-01 14:15:30 -0700 (Thu, 01 Nov 2007) Log Message: ----------- When checking for changes to the vidcap device list, look at the device's unique id_string. Otherwise two identical webcams would confuse us. Modified Paths: -------------- trunk/lib/video.c Modified: trunk/lib/video.c =================================================================== --- trunk/lib/video.c 2007-11-01 17:37:41 UTC (rev 1255) +++ trunk/lib/video.c 2007-11-01 21:15:30 UTC (rev 1256) @@ -1377,7 +1377,10 @@ */ for ( i = 0; i < vinfo.device_count; i++ ) { - if ( !strcmp(new_iaxc_dev_list[n].name, vinfo.devices[i].name) ) + /* check both the device name and its unique identifier */ + if ( !strcmp(new_iaxc_dev_list[n].name, vinfo.devices[i].name) && + !strcmp(new_iaxc_dev_list[n].id_string, + vinfo.devices[i].id_string) ) { new_iaxc_dev_list[n].id = vinfo.devices[i].id; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bc...@us...> - 2007-11-02 21:05:45
|
Revision: 1263 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1263&view=rev Author: bcholew Date: 2007-11-02 14:05:49 -0700 (Fri, 02 Nov 2007) Log Message: ----------- Be careful not to use vinfo.src if it's not valid. If the selected vidcap device is removed, set the selected device id to -1. Before releasing a source be sure that capture has been stopped. Cleanup before calling vidcap_destroy(). Modified Paths: -------------- trunk/lib/video.c Modified: trunk/lib/video.c =================================================================== --- trunk/lib/video.c 2007-11-02 17:07:22 UTC (rev 1262) +++ trunk/lib/video.c 2007-11-02 21:05:49 UTC (rev 1263) @@ -557,6 +557,15 @@ cap_info->error_status); vinfo.capturing = 0; + /* NOTE: + * We want to release now, but we're in the capture callback thread. + * vidcap_src_release() fails during capture. + * + * We'll defer the release until the end-application's main thread + * requires the release - if either iaxc_set_video_prefs(), + * iaxc_video_device_set() or video_destroy() are called. + */ + evt.type = IAXC_EVENT_VIDCAP_ERROR; iaxci_post_event(evt); return -1; @@ -967,20 +976,19 @@ !(prefs & IAXC_VIDEO_PREF_RECV_LOCAL_ENCODED)) ) { MUTEXLOCK(&vinfo.camera_lock); - if ( vinfo.capturing ) + if ( vinfo.capturing && vinfo.src && + vidcap_src_capture_stop(vinfo.src) ) { - if ( vidcap_src_capture_stop(vinfo.src) ) - fprintf(stderr, "failed vidcap_src_capture_stop\n"); + fprintf(stderr, "failed vidcap_src_capture_stop\n"); + } - vinfo.capturing = 0; + if ( vinfo.src && vidcap_src_release(vinfo.src) ) + { + fprintf(stderr, "failed to release a video source\n"); + } - if ( vinfo.src && vidcap_src_release(vinfo.src) ) - { - fprintf(stderr, "failed to release a video source\n"); - } - - vinfo.src = 0; - } + vinfo.src = 0; + vinfo.capturing = 0; MUTEXUNLOCK(&vinfo.camera_lock); } else @@ -1434,9 +1442,16 @@ free(old_iaxc_dev_list); } + /* If we can't find the selected device, defer releasing it. + * It'll happen when we set a new device, or shutdown + */ + + if ( !found_selected_device ) + vinfo.selected_device_id = -1; + *devs = vinfo.devices; *num_devs = vinfo.device_count; - *id_selected = found_selected_device ? vinfo.selected_device_id : -1; + *id_selected = vinfo.selected_device_id; return list_changed; } @@ -1480,6 +1495,12 @@ vinfo.selected_device_id = capture_dev_id; + if ( vinfo.capturing && vinfo.src && + vidcap_src_capture_stop(vinfo.src) ) + { + fprintf(stderr, "failed to stop video capture\n"); + } + if ( vinfo.src && vidcap_src_release(vinfo.src) ) { fprintf(stderr, "failed to release video source\n"); @@ -1655,6 +1676,12 @@ } free(vinfo.devices); + if ( vinfo.capturing && vinfo.src ) + vidcap_src_capture_stop(vinfo.src); + + if ( vinfo.src ) + vidcap_src_release(vinfo.src); + vidcap_destroy(vinfo.vc); vinfo.vc = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bc...@us...> - 2007-12-03 15:55:38
|
Revision: 1295 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1295&view=rev Author: bcholew Date: 2007-12-03 07:55:43 -0800 (Mon, 03 Dec 2007) Log Message: ----------- Screen-out video capture callbacks with no data. Protect against case of no sapi when getting the video device list. Use calloc instead of malloc. Remove some C99-isms. Whitespace. Modified Paths: -------------- trunk/lib/video.c Modified: trunk/lib/video.c =================================================================== --- trunk/lib/video.c 2007-11-30 13:07:16 UTC (rev 1294) +++ trunk/lib/video.c 2007-12-03 15:55:43 UTC (rev 1295) @@ -562,7 +562,7 @@ * vidcap_src_release() fails during capture. * * We'll defer the release until the end-application's main thread - * requires the release - if either iaxc_set_video_prefs(), + * requires the release - if either iaxc_set_video_prefs(), * iaxc_video_device_set() or video_destroy() are called. */ @@ -571,6 +571,12 @@ return -1; } + if ( cap_info->video_data_size < 1 ) + { + fprintf(stderr, "FYI: callback with no data\n"); + return 0; + } + if ( vinfo.prefs & IAXC_VIDEO_PREF_CAPTURE_DISABLE ) return 0; @@ -1018,7 +1024,7 @@ capture_callback, 0)) ) { MUTEXUNLOCK(&vinfo.camera_lock); - fprintf(stderr, "failed to start video capture: %d\n", + fprintf(stderr, "failed to start video capture: %d\n", ret); return -1; } @@ -1321,8 +1327,8 @@ } EXPORT int iaxc_video_devices_get(struct iaxc_video_device **devs, - int *num_devs, int *id_selected) -{ + int *num_devs, int *id_selected) +{ int new_device_count; int old_device_count; struct vidcap_src_info *new_src_list; @@ -1330,13 +1336,15 @@ struct iaxc_video_device *new_iaxc_dev_list; struct iaxc_video_device *old_iaxc_dev_list; int found_selected_device = 0; - int list_changed = 0; + int list_changed; int i, n; + if ( !vinfo.sapi ) + return -1; + /* update libvidcap's device list */ new_device_count = vidcap_src_list_update(vinfo.sapi); - if ( new_device_count != vinfo.device_count ) - list_changed = 1; + list_changed = new_device_count != vinfo.device_count; if ( new_device_count < 0 ) { @@ -1345,16 +1353,17 @@ return -1; } - new_src_list = (struct vidcap_src_info *)malloc(new_device_count * - sizeof(struct vidcap_src_info)); + new_src_list = calloc(new_device_count, sizeof(struct vidcap_src_info)); + if ( !new_src_list ) { fprintf(stderr, "ERROR: failed updated source allocation\n"); return -1; } - new_iaxc_dev_list = (struct iaxc_video_device *)malloc( - new_device_count * sizeof(struct iaxc_video_device)); + new_iaxc_dev_list = calloc(new_device_count, + sizeof(struct iaxc_video_device)); + if ( !new_iaxc_dev_list ) { free(new_src_list); @@ -1365,7 +1374,7 @@ /* get an updated libvidcap device list */ if ( vidcap_src_list_get(vinfo.sapi, new_device_count, new_src_list) ) { - fprintf(stderr, "ERROR: failed vidcap_srcList_get()\n"); + fprintf(stderr, "ERROR: failed vidcap_srcList_get().\n"); free(new_src_list); free(new_iaxc_dev_list); @@ -1373,7 +1382,6 @@ } /* build a new iaxclient video source list */ - found_selected_device = 0; for ( n = 0; n < new_device_count; n++ ) { new_iaxc_dev_list[n].name = strdup(new_src_list[n].description); @@ -1453,11 +1461,11 @@ *num_devs = vinfo.device_count; *id_selected = vinfo.selected_device_id; - return list_changed; -} + return list_changed; +} -EXPORT int iaxc_video_device_set(int capture_dev_id) -{ +EXPORT int iaxc_video_device_set(int capture_dev_id) +{ int ret = 0; int dev_num = 0; @@ -1583,16 +1591,18 @@ goto bail; } - vinfo.vc_src_info = (struct vidcap_src_info *)malloc(vinfo.device_count * + vinfo.vc_src_info = calloc(vinfo.device_count, sizeof(struct vidcap_src_info)); + if ( !vinfo.vc_src_info ) { fprintf(stderr, "ERROR: failed vinfo field allocations\n"); goto bail; } - vinfo.devices = (struct iaxc_video_device *)malloc(vinfo.device_count * + vinfo.devices = calloc(vinfo.device_count, sizeof(struct iaxc_video_device)); + if ( !vinfo.devices ) { fprintf(stderr, "ERROR: failed vinfo field allocation\n"); @@ -1636,7 +1646,7 @@ fprintf(stderr, "ERROR: failed vidcap_srcs_notify()\n"); goto late_bail; } - + vinfo.prefs = IAXC_VIDEO_PREF_RECV_LOCAL_RAW | IAXC_VIDEO_PREF_RECV_REMOTE_RAW | @@ -1656,6 +1666,11 @@ free(vinfo.devices); bail: + if ( vinfo.sapi ) + { + vidcap_sapi_release(vinfo.sapi); + vinfo.sapi = 0; + } vidcap_destroy(vinfo.vc); vinfo.vc = 0; return -1; @@ -1681,7 +1696,7 @@ if ( vinfo.src ) vidcap_src_release(vinfo.src); - + vidcap_destroy(vinfo.vc); vinfo.vc = 0; @@ -1722,7 +1737,7 @@ * we are saying that the "camera is working" if there exists * more than zero cameras. */ - return vidcap_src_list_update(vinfo.sapi) > 0; + return vinfo.sapi && vidcap_src_list_update(vinfo.sapi) > 0; } int video_send_stats(struct iaxc_call * call) @@ -1756,27 +1771,27 @@ EXPORT int iaxc_push_video(void *data, unsigned int size, int fragment) { struct iaxc_call *call; - + if (selected_call < 0) return -1; - + call = &calls[selected_call]; if ( vinfo.prefs & IAXC_VIDEO_PREF_SEND_DISABLE ) return 0; - + //fprintf(stderr, "iaxc_push_video: sending video size %d\n", size); - + // Fragment if needed if ( fragment ) { static struct slice_set_t slice_set; int i; - + if ( !vinfo.sc ) vinfo.sc = create_slicer_context((unsigned short)rand(), vfinfo.fragsize); - + slice(data, size, &slice_set, vinfo.sc); for ( i = 0 ; i < slice_set.num_slices ; i++ ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpg...@us...> - 2008-04-15 22:19:30
|
Revision: 1407 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1407&view=rev Author: jpgrayson Date: 2008-04-15 15:19:33 -0700 (Tue, 15 Apr 2008) Log Message: ----------- Print a message when video is captured without a video format been established for the call. Modified Paths: -------------- trunk/lib/video.c Modified: trunk/lib/video.c =================================================================== --- trunk/lib/video.c 2008-04-15 22:18:13 UTC (rev 1406) +++ trunk/lib/video.c 2008-04-15 22:19:33 UTC (rev 1407) @@ -676,6 +676,8 @@ if ( call->vformat == 0 ) { + fprintf(stderr, "video format not set for call %d\n", + selected_call); goto callback_failed; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |