|
From: <sb...@us...> - 2007-11-05 15:29:10
|
Revision: 1266
http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1266&view=rev
Author: sbalea
Date: 2007-11-05 07:29:12 -0800 (Mon, 05 Nov 2007)
Log Message:
-----------
Synchronize with trunk rev 1265
Revision Links:
--------------
http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1265&view=rev
Modified Paths:
--------------
branches/team/mihai/echocan/lib/iaxclient.h
branches/team/mihai/echocan/lib/iaxclient_lib.c
branches/team/mihai/echocan/lib/video.c
Modified: branches/team/mihai/echocan/lib/iaxclient.h
===================================================================
--- branches/team/mihai/echocan/lib/iaxclient.h 2007-11-05 15:09:32 UTC (rev 1265)
+++ branches/team/mihai/echocan/lib/iaxclient.h 2007-11-05 15:29:12 UTC (rev 1266)
@@ -819,6 +819,11 @@
EXPORT void iaxc_send_text(const char * text);
/*!
+ Sends \a text to call \a callNo
+*/
+EXPORT void iaxc_send_text_call(int callNo, const char * text);
+
+/*!
Sends a URL across the currently selected call
\param url The URL to send across.
\param link If non-zero the URL is a link
@@ -1135,9 +1140,14 @@
EXPORT int iaxc_set_audio_prefs(unsigned int prefs);
/*!
- Get video capture device information:
+ Get video capture device information.
+ WARNING: the array pointed to by parameter 'devs' below is owned
+ by iaxclient, and may be freed on subsequent calls to
+ this function.
\param devs Returns an array of iaxc_video_device structures.
- The array will will be valid as long as iaxc is initialized.
+ The array will only be valid until this function is
+ called again (if the device list changes), or until
+ iaxc is shutdown.
\param nDevs Returns the number of devices in the devs array
\param devId Returns the id of the currently selected video capture device
Modified: branches/team/mihai/echocan/lib/iaxclient_lib.c
===================================================================
--- branches/team/mihai/echocan/lib/iaxclient_lib.c 2007-11-05 15:09:32 UTC (rev 1265)
+++ branches/team/mihai/echocan/lib/iaxclient_lib.c 2007-11-05 15:29:12 UTC (rev 1266)
@@ -1512,6 +1512,17 @@
}
}
+EXPORT void iaxc_send_text_call(int callNo, const char * text)
+{
+ if ( callNo < 0 || !(calls[callNo].state & IAXC_CALL_STATE_ACTIVE) )
+ return;
+
+ get_iaxc_lock();
+ if ( calls[callNo].state & IAXC_CALL_STATE_ACTIVE )
+ iax_send_text(calls[callNo].session, text);
+ put_iaxc_lock();
+}
+
EXPORT void iaxc_send_url(const char * url, int link)
{
if ( selected_call >= 0 )
Modified: branches/team/mihai/echocan/lib/video.c
===================================================================
--- branches/team/mihai/echocan/lib/video.c 2007-11-05 15:09:32 UTC (rev 1265)
+++ branches/team/mihai/echocan/lib/video.c 2007-11-05 15:29:12 UTC (rev 1266)
@@ -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
@@ -1371,19 +1379,17 @@
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) )
+ /* 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) )
{
- /*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 +1400,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;
}
@@ -1440,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;
}
@@ -1486,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");
@@ -1530,12 +1545,14 @@
memset(&vinfo, 0, sizeof(vinfo));
+ 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);
- vinfo.width = vfinfo.width;
- vinfo.height = vfinfo.height;
-
if ( !(vinfo.vc = vidcap_initialize()) )
{
fprintf(stderr, "ERROR: failed vidcap_initialize\n");
@@ -1558,8 +1575,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 +1619,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);
}
@@ -1649,9 +1663,25 @@
int video_destroy(void)
{
+ int i;
+
if ( !vinfo.vc )
return -1;
+ free(vinfo.vc_src_info);
+ for ( i = 0; i < vinfo.device_count; i++ )
+ {
+ free((void *)vinfo.devices[i].name);
+ free((void *)vinfo.devices[i].id_string);
+ }
+ 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.
|