From: <do...@us...> - 2007-11-02 17:07:22
|
Revision: 1262 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1262&view=rev Author: dohpaz Date: 2007-11-02 10:07:22 -0700 (Fri, 02 Nov 2007) Log Message: ----------- Add ability to send text to a particular call. Modified Paths: -------------- branches/team/elbunce/iaxclient/lib/iaxclient.h branches/team/elbunce/iaxclient/lib/iaxclient_lib.c Modified: branches/team/elbunce/iaxclient/lib/iaxclient.h =================================================================== --- branches/team/elbunce/iaxclient/lib/iaxclient.h 2007-11-02 16:41:54 UTC (rev 1261) +++ branches/team/elbunce/iaxclient/lib/iaxclient.h 2007-11-02 17:07:22 UTC (rev 1262) @@ -861,6 +861,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 Modified: branches/team/elbunce/iaxclient/lib/iaxclient_lib.c =================================================================== --- branches/team/elbunce/iaxclient/lib/iaxclient_lib.c 2007-11-02 16:41:54 UTC (rev 1261) +++ branches/team/elbunce/iaxclient/lib/iaxclient_lib.c 2007-11-02 17:07:22 UTC (rev 1262) @@ -1501,6 +1501,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 ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <do...@us...> - 2007-11-04 19:17:54
|
Revision: 1264 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1264&view=rev Author: dohpaz Date: 2007-11-04 11:17:58 -0800 (Sun, 04 Nov 2007) Log Message: ----------- Merge up to trunk r1263. Modified Paths: -------------- branches/team/elbunce/iaxclient/lib/iaxclient_lib.c branches/team/elbunce/iaxclient/lib/video.c Modified: branches/team/elbunce/iaxclient/lib/iaxclient_lib.c =================================================================== --- branches/team/elbunce/iaxclient/lib/iaxclient_lib.c 2007-11-02 21:05:49 UTC (rev 1263) +++ branches/team/elbunce/iaxclient/lib/iaxclient_lib.c 2007-11-04 19:17:58 UTC (rev 1264) @@ -679,7 +679,25 @@ video_destroy(); #endif } - + + /* destroy enocders and decoders for all existing calls */ + if ( calls ) + { + int i; + for ( i=0 ; i<max_calls ; i++ ) + { + if ( calls[i].encoder ) + calls[i].encoder->destroy(calls[i].encoder); + if ( calls[i].decoder ) + calls[i].decoder->destroy(calls[i].decoder); + if ( calls[i].vencoder ) + calls[i].vdecoder->destroy(calls[i].vencoder); + if ( calls[i].vdecoder ) + calls[i].vencoder->destroy(calls[i].vdecoder); + } + free(calls); + calls = NULL; + } put_iaxc_lock(); #ifdef WIN32 closesocket(iax_get_fd()); //fd: Modified: branches/team/elbunce/iaxclient/lib/video.c =================================================================== --- branches/team/elbunce/iaxclient/lib/video.c 2007-11-02 21:05:49 UTC (rev 1263) +++ branches/team/elbunce/iaxclient/lib/video.c 2007-11-04 19:17:58 UTC (rev 1264) @@ -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; @@ -969,20 +978,19 @@ fprintf(stderr, "We SHOULD be STOPPING capture here! vinfo.capturing=%d\n", vinfo.capturing); 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 @@ -1379,7 +1387,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; @@ -1433,9 +1444,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; } @@ -1479,6 +1497,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"); @@ -1654,6 +1678,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: <do...@us...> - 2007-12-06 06:05:29
|
Revision: 1302 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1302&view=rev Author: dohpaz Date: 2007-12-05 22:05:28 -0800 (Wed, 05 Dec 2007) Log Message: ----------- Add iaxc_register_ex() API to support passing a registration refresh time. Tweak transfer diagnostics. Modified Paths: -------------- branches/team/elbunce/iaxclient/lib/iaxclient.h branches/team/elbunce/iaxclient/lib/iaxclient_lib.c branches/team/elbunce/iaxclient/lib/libiax2/src/iax.c Modified: branches/team/elbunce/iaxclient/lib/iaxclient.h =================================================================== --- branches/team/elbunce/iaxclient/lib/iaxclient.h 2007-12-05 23:36:59 UTC (rev 1301) +++ branches/team/elbunce/iaxclient/lib/iaxclient.h 2007-12-06 06:05:28 UTC (rev 1302) @@ -793,6 +793,17 @@ EXPORT int iaxc_register(const char * user, const char * pass, const char * host); /*! + Registers the IAXClient instance with an IAX server + \param user The username to register as + \param pass The password to register with + \param host The address of the host/peer to register with + \param refresh The registration refresh period + + \return The registration id number upon success; -1 otherwise. +*/ +EXPORT int iaxc_register_ex(const char * user, const char * pass, const char * host, int refresh); + +/*! Respond to incoming call \a callNo as busy. */ EXPORT void iaxc_send_busy_on_incoming_call(int callNo); Modified: branches/team/elbunce/iaxclient/lib/iaxclient_lib.c =================================================================== --- branches/team/elbunce/iaxclient/lib/iaxclient_lib.c 2007-12-05 23:36:59 UTC (rev 1301) +++ branches/team/elbunce/iaxclient/lib/iaxclient_lib.c 2007-12-06 06:05:28 UTC (rev 1302) @@ -80,8 +80,6 @@ struct iaxc_registration *next; }; -static int registration_timeout = 60; - static int next_registration_id = 0; static struct iaxc_registration *registrations = NULL; @@ -753,7 +751,7 @@ { // If there is less than one second before the registration is about // to expire, renew it. - if ( iaxci_usecdiff(&now, &cur->last) > cur->refresh - 1 * 1000 *1000 ) + if ( iaxci_usecdiff(&now, &cur->last) > (cur->refresh - 1) * 1000 *1000 ) { if ( cur->session != NULL ) { @@ -765,7 +763,7 @@ iaxci_usermsg(IAXC_ERROR, "Can't make new registration session"); return; } - iax_register(cur->session, cur->host, cur->user, cur->pass, registration_timeout); + iax_register(cur->session, cur->host, cur->user, cur->pass, cur->refresh); cur->last = now; } } @@ -1247,6 +1245,11 @@ EXPORT int iaxc_register(const char * user, const char * pass, const char * host) { + iaxc_register_ex(user, pass, host, 60); +} + +EXPORT int iaxc_register_ex(const char * user, const char * pass, const char * host, int refresh) +{ struct iaxc_registration *newreg; newreg = (struct iaxc_registration *)malloc(sizeof (struct iaxc_registration)); @@ -1266,14 +1269,14 @@ } gettimeofday(&newreg->last,NULL); - newreg->refresh = (registration_timeout - 2) *1000*1000; /* 2 seconds before registration timeout, in usecs */ + newreg->refresh = refresh; strncpy(newreg->host, host, 256); strncpy(newreg->user, user, 256); strncpy(newreg->pass, pass, 256); - /* send out the initial registration with registration_timeout seconds */ - iax_register(newreg->session, host, user, pass, registration_timeout); + /* send out the initial registration with refresh seconds */ + iax_register(newreg->session, host, user, pass, refresh); /* add it to the list; */ newreg->id = ++next_registration_id; Modified: branches/team/elbunce/iaxclient/lib/libiax2/src/iax.c =================================================================== --- branches/team/elbunce/iaxclient/lib/libiax2/src/iax.c 2007-12-05 23:36:59 UTC (rev 1301) +++ branches/team/elbunce/iaxclient/lib/libiax2/src/iax.c 2007-12-06 06:05:28 UTC (rev 1302) @@ -1429,8 +1429,8 @@ s1->transferpeer = s0->callno; DEBU(G "iax_setup_transfer(%d, %d) transfer_id=%d\n", s0->callno, s1->callno, transfer_id); - DEBU(G "\torg: callno=%d peercallno=%d peeraddr=%s\n", s0->callno, s0->peercallno, inet_ntoa(s0->peeraddr.sin_addr)); - DEBU(G "\tnew: callno=%d peercallno=%d peeraddr=%s\n", s1->callno, s1->peercallno, inet_ntoa(s1->peeraddr.sin_addr)); + DEBU(G "\torg: callno=%d peercallno=%d peeraddr=%s peerport=%d\n", s0->callno, s0->peercallno, inet_ntoa(s0->peeraddr.sin_addr), ntohs(s0->peeraddr.sin_port)); + DEBU(G "\tnew: callno=%d peercallno=%d peeraddr=%s peerport=%d\n", s1->callno, s1->peercallno, inet_ntoa(s1->peeraddr.sin_addr), ntohs(s1->peeraddr.sin_port)); res = send_command(s0, AST_FRAME_IAX, IAX_COMMAND_TXREQ, 0, ied0.buf, ied0.pos, -1); if (res < 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <do...@us...> - 2007-12-14 04:49:01
|
Revision: 1308 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1308&view=rev Author: dohpaz Date: 2007-12-13 20:49:05 -0800 (Thu, 13 Dec 2007) Log Message: ----------- Merge up to trunk r1307. Modified Paths: -------------- branches/team/elbunce/iaxclient/lib/iaxclient_lib.c branches/team/elbunce/iaxclient/lib/libiax2/src/iax-client.h branches/team/elbunce/iaxclient/lib/libiax2/src/iax.c branches/team/elbunce/iaxclient/lib/video.c Modified: branches/team/elbunce/iaxclient/lib/iaxclient_lib.c =================================================================== --- branches/team/elbunce/iaxclient/lib/iaxclient_lib.c 2007-12-12 22:19:44 UTC (rev 1307) +++ branches/team/elbunce/iaxclient/lib/iaxclient_lib.c 2007-12-14 04:49:05 UTC (rev 1308) @@ -139,8 +139,13 @@ MUTEXLOCK(&iaxc_lock); } +int try_iaxc_lock() +{ + return MUTEXTRYLOCK(&iaxc_lock); +} + // Unlock the library and post any events that were queued in the meantime -static void put_iaxc_lock() +void put_iaxc_lock() { iaxc_event *prev, *event; Modified: branches/team/elbunce/iaxclient/lib/libiax2/src/iax-client.h =================================================================== --- branches/team/elbunce/iaxclient/lib/libiax2/src/iax-client.h 2007-12-12 22:19:44 UTC (rev 1307) +++ branches/team/elbunce/iaxclient/lib/libiax2/src/iax-client.h 2007-12-14 04:49:05 UTC (rev 1308) @@ -17,6 +17,9 @@ #if defined(_MSC_VER) /* disable zero-sized array in struct/union warning */ #pragma warning(disable:4200) +#endif + +#ifdef WIN32 #define socklen_t int #endif Modified: branches/team/elbunce/iaxclient/lib/libiax2/src/iax.c =================================================================== --- branches/team/elbunce/iaxclient/lib/libiax2/src/iax.c 2007-12-12 22:19:44 UTC (rev 1307) +++ branches/team/elbunce/iaxclient/lib/libiax2/src/iax.c 2007-12-14 04:49:05 UTC (rev 1308) @@ -908,7 +908,7 @@ struct sockaddr_in sin; socklen_t sinlen; int flags; - int bufsize = 256 * 1024; + int bufsize = 128 * 1024; if (netfd > -1) { @@ -998,10 +998,18 @@ if (setsockopt(netfd, SOL_SOCKET, SO_RCVBUF, (char *)&bufsize, sizeof(bufsize)) < 0) { - DEBU(G "Unable to set buffer size."); - IAXERROR "Unable to set buffer size."); + DEBU(G "Unable to set receive buffer size."); + IAXERROR "Unable to set receive buffer size."); } + /* set send buffer size too */ + if (setsockopt(netfd, SOL_SOCKET, SO_SNDBUF, (char *)&bufsize, + sizeof(bufsize)) < 0) + { + DEBU(G "Unable to set send buffer size."); + IAXERROR "Unable to set send buffer size."); + } + portno = ntohs(sin.sin_port); DEBU(G "Started on port %d\n", portno); } Modified: branches/team/elbunce/iaxclient/lib/video.c =================================================================== --- branches/team/elbunce/iaxclient/lib/video.c 2007-12-12 22:19:44 UTC (rev 1307) +++ branches/team/elbunce/iaxclient/lib/video.c 2007-12-14 04:49:05 UTC (rev 1308) @@ -124,6 +124,10 @@ extern int test_mode; extern struct iaxc_call * calls; +/* to prevent clearing a call while in capture callback */ +extern __inline int try_iaxc_lock(); +extern __inline void put_iaxc_lock(); + EXPORT unsigned int iaxc_get_video_prefs(void) { return vinfo.prefs; @@ -644,20 +648,35 @@ 0); /* timestamp (ms) */ } + /* Don't block waiting for this lock. If the main thread has the lock + * for the purpose of dumping the call, it may request that video + * capture stop - which would block until this callback returned. + */ + if ( try_iaxc_lock() ) + { + /* give it a second try */ + iaxc_millisleep(5); + if ( try_iaxc_lock() ) + { + fprintf(stderr, "skipping processing of a video frame\n"); + return 0; + } + } + if ( selected_call < 0 ) - return 0; + goto callback_done; call = &calls[selected_call]; if ( !call || !(call->state & (IAXC_CALL_STATE_COMPLETE | IAXC_CALL_STATE_OUTGOING)) ) { - return 0; + goto callback_done; } if ( call->vformat == 0 ) { - return -1; + goto callback_failed; } if ( !need_encode ) @@ -674,7 +693,7 @@ call->vencoder = 0; } - return 0; + goto callback_done; } else { @@ -693,7 +712,8 @@ fprintf(stderr, "ERROR: failed to create codec " "for format 0x%08x\n", call->vformat); - return -1; + + goto callback_failed; } fprintf(stderr, "created encoder codec %s\n", @@ -705,7 +725,7 @@ &slice_set) ) { fprintf(stderr, "failed to encode captured video\n"); - return -1; + goto callback_failed; } } @@ -724,7 +744,7 @@ if ( !call->session ) { fprintf(stderr, "not sending video to sessionless call\n"); - return -1; + goto callback_failed; } for ( i = 0; i < slice_set.num_slices; ++i ) @@ -752,7 +772,7 @@ fprintf(stderr, "failed sending slice call %d " "size %d\n", selected_call, slice_set.size[i]); - return -1; + goto callback_failed; } /* More statistics */ @@ -768,7 +788,13 @@ maybe_send_stats(call); +callback_done: + put_iaxc_lock(); return 0; + +callback_failed: + put_iaxc_lock(); + return -1; } static int prepare_for_capture() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |