From: <jpg...@us...> - 2007-05-07 22:27:10
|
Revision: 967 http://svn.sourceforge.net/iaxclient/?rev=967&view=rev Author: jpgrayson Date: 2007-05-07 15:26:39 -0700 (Mon, 07 May 2007) Log Message: ----------- Remove various visual studio project files. This stuff is moving into the contrib directory. Removed Paths: ------------- trunk/lib/gsm/gsm.vcproj trunk/lib/iaxclient_lib.dsp trunk/lib/iaxclient_lib.dsw trunk/lib/iaxclient_lib.vco trunk/lib/iaxclient_lib.vcp trunk/lib/iaxclient_lib.vcproj trunk/lib/iaxclient_lib.vcw trunk/lib/libiax2/libiax2.vcproj trunk/lib/videoLib/videoLib.vcproj trunk/lib/videoLib/win32/BaseClasses/baseclasses.dsp trunk/lib/videoLib/win32/BaseClasses/baseclasses.dsw trunk/lib/videoLib/win32/BaseClasses/baseclasses.sln trunk/lib/videoLib/win32/BaseClasses/baseclasses.vcproj Deleted: trunk/lib/gsm/gsm.vcproj =================================================================== --- trunk/lib/gsm/gsm.vcproj 2007-05-07 20:20:18 UTC (rev 966) +++ trunk/lib/gsm/gsm.vcproj 2007-05-07 22:26:39 UTC (rev 967) @@ -1,243 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="8.00" - Name="gsm" - ProjectGUID="{82C9BD79-9796-405F-8A28-3F538514AC3A}" - RootNamespace="gsm" - Keyword="Win32Proj" - > - <Platforms> - <Platform - Name="Win32" - /> - </Platforms> - <ToolFiles> - </ToolFiles> - <Configurations> - <Configuration - Name="Debug|Win32" - OutputDirectory="$(SolutionDir)$(ConfigurationName)" - IntermediateDirectory="$(ConfigurationName)" - ConfigurationType="4" - CharacterSet="1" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories=".\inc" - PreprocessorDefinitions="WIN32;_DEBUG;_LIB" - MinimalRebuild="true" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - UsePrecompiledHeader="0" - WarningLevel="3" - Detect64BitPortabilityProblems="true" - DebugInformationFormat="4" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLibrarianTool" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Release|Win32" - OutputDirectory="$(SolutionDir)$(ConfigurationName)" - IntermediateDirectory="$(ConfigurationName)" - ConfigurationType="4" - CharacterSet="1" - WholeProgramOptimization="1" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - AdditionalIncludeDirectories=".\inc" - PreprocessorDefinitions="WIN32;NDEBUG;_LIB" - RuntimeLibrary="2" - UsePrecompiledHeader="0" - WarningLevel="3" - Detect64BitPortabilityProblems="true" - DebugInformationFormat="3" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLibrarianTool" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <Filter - Name="Source Files" - Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" - UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" - > - <File - RelativePath=".\src\add.c" - > - </File> - <File - RelativePath=".\src\code.c" - > - </File> - <File - RelativePath=".\src\debug.c" - > - </File> - <File - RelativePath=".\src\decode.c" - > - </File> - <File - RelativePath=".\src\gsm_create.c" - > - </File> - <File - RelativePath=".\src\gsm_decode.c" - > - </File> - <File - RelativePath=".\src\gsm_destroy.c" - > - </File> - <File - RelativePath=".\src\gsm_encode.c" - > - </File> - <File - RelativePath=".\src\gsm_explode.c" - > - </File> - <File - RelativePath=".\src\gsm_implode.c" - > - </File> - <File - RelativePath=".\src\gsm_option.c" - > - </File> - <File - RelativePath=".\src\gsm_print.c" - > - </File> - <File - RelativePath=".\src\long_term.c" - > - </File> - <File - RelativePath=".\src\lpc.c" - > - </File> - <File - RelativePath=".\src\preprocess.c" - > - </File> - <File - RelativePath=".\src\rpe.c" - > - </File> - <File - RelativePath=".\src\short_term.c" - > - </File> - <File - RelativePath=".\src\table.c" - > - </File> - </Filter> - <Filter - Name="Header Files" - Filter="h;hpp;hxx;hm;inl;inc;xsd" - UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" - > - </Filter> - <Filter - Name="Resource Files" - Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" - UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" - > - </Filter> - <File - RelativePath=".\ReadMe.txt" - > - </File> - </Files> - <Globals> - </Globals> -</VisualStudioProject> Deleted: trunk/lib/iaxclient_lib.dsp =================================================================== --- trunk/lib/iaxclient_lib.dsp 2007-05-07 20:20:18 UTC (rev 966) +++ trunk/lib/iaxclient_lib.dsp 2007-05-07 22:26:39 UTC (rev 967) @@ -1,303 +0,0 @@ -# Microsoft Developer Studio Project File - Name="iaxclient_lib" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=iaxclient_lib - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "iax1lib.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "iax1lib.mak" CFG="iaxclient_lib - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "iaxclient_lib - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "iaxclient_lib - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "iaxclient_lib - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /MT /w /W0 /GX /I ".\libiax\src" /I ".\gsm\inc" /I ".\portaudio\pa_common" /I ".\portaudio\pablio" /D "WIN32" /D SPEEX_PREPROCESS=1 /D SPEEX_EC=1 /D "NDEBUG" /D "_LIB" /FR /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"Release\iaxclient1.lib" - -!ELSEIF "$(CFG)" == "iaxclient_lib - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /w /W0 /Gm /GX /ZI /Od /I ".\libiax\src" /I ".\gsm\inc" /I ".\portaudio\pa_common" /I ".\portaudio\pablio" /I ".\libspeex" /D "WIN32" /D SPEEX_PREPROCESS=1 /D SPEEX_EC=1 /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /YX /FD /GZ /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"Debug\iaxclient1.lib" - -!ENDIF - -# Begin Target - -# Name "iaxclient_lib - Win32 Release" -# Name "iaxclient_lib - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\gsm\src\add.c -# End Source File -# Begin Source File - -SOURCE=.\audio_encode.c -# End Source File -# Begin Source File - -SOURCE=.\audio_file.c -# End Source File -# Begin Source File - -SOURCE=.\audio_portaudio.c -# End Source File -# Begin Source File - -SOURCE=.\audio_win32.c -# End Source File -# Begin Source File - -SOURCE=.\gsm\src\code.c -# End Source File -# Begin Source File - -SOURCE=.\sox\compand.c -# End Source File -# Begin Source File - -SOURCE=.\gsm\src\debug.c -# End Source File -# Begin Source File - -SOURCE=.\gsm\src\decode.c -# End Source File -# Begin Source File - -SOURCE=.\gsm\src\gsm_create.c -# End Source File -# Begin Source File - -SOURCE=.\gsm\src\gsm_decode.c -# End Source File -# Begin Source File - -SOURCE=.\gsm\src\gsm_destroy.c -# End Source File -# Begin Source File - -SOURCE=.\gsm\src\gsm_encode.c -# End Source File -# Begin Source File - -SOURCE=.\gsm\src\gsm_explode.c -# End Source File -# Begin Source File - -SOURCE=.\gsm\src\gsm_implode.c -# End Source File -# Begin Source File - -SOURCE=.\gsm\src\gsm_option.c -# End Source File -# Begin Source File - -SOURCE=.\gsm\src\gsm_print.c -# End Source File -# Begin Source File - -SOURCE=.\libiax\src\iax.c -# End Source File -# Begin Source File - -SOURCE=.\iaxclient_lib.c -# End Source File -# Begin Source File - -SOURCE=.\gsm\src\long_term.c -# End Source File -# Begin Source File - -SOURCE=.\gsm\src\lpc.c -# End Source File -# Begin Source File - -SOURCE=.\libiax\src\md5.c -# End Source File -# Begin Source File - -SOURCE=.\libspeex\misc.c -# End Source File -# Begin Source File - -SOURCE=.\portaudio\pa_common\pa_lib.c -# End Source File -# Begin Source File - -SOURCE=.\portaudio\pa_win_wmme\pa_win_wmme.c -# End Source File -# Begin Source File - -SOURCE=.\portaudio\pablio\pablio.c -# End Source File -# Begin Source File - -SOURCE=.\gsm\src\preprocess.c - -!IF "$(CFG)" == "iaxclient_lib - Win32 Release" - -# PROP Intermediate_Dir "Release\gsm" - -!ELSEIF "$(CFG)" == "iaxclient_lib - Win32 Debug" - -# PROP Intermediate_Dir "Debug\gsm" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\libspeex\preprocess.c -# End Source File -# Begin Source File - -SOURCE=.\portaudio\pablio\ringbuffer.c -# End Source File -# Begin Source File - -SOURCE=.\gsm\src\rpe.c -# End Source File -# Begin Source File - -SOURCE=.\gsm\src\short_term.c -# End Source File -# Begin Source File - -SOURCE=.\libspeex\smallft.c -# End Source File -# Begin Source File - -SOURCE=.\sox\soxcompat.c -# End Source File -# Begin Source File - -SOURCE=.\gsm\src\table.c -# End Source File -# Begin Source File - -SOURCE=.\winfuncs.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\libiax\src\answer.h -# End Source File -# Begin Source File - -SOURCE=.\audio_encode.h -# End Source File -# Begin Source File - -SOURCE=.\audio_portaudio.h -# End Source File -# Begin Source File - -SOURCE=.\audio_win32.h -# End Source File -# Begin Source File - -SOURCE=.\libiax\src\frame.h -# End Source File -# Begin Source File - -SOURCE=".\libiax\src\iax-client.h" -# End Source File -# Begin Source File - -SOURCE=.\libiax\src\iax.h -# End Source File -# Begin Source File - -SOURCE=.\iaxclient_lib.h -# End Source File -# Begin Source File - -SOURCE=.\gsm\src\k6opt.h -# End Source File -# Begin Source File - -SOURCE=.\libiax\src\md5.h -# End Source File -# Begin Source File - -SOURCE=.\libspeex\misc.h -# End Source File -# Begin Source File - -SOURCE=.\libspeex\smallft.h -# End Source File -# Begin Source File - -SOURCE=.\sox\sox.h -# End Source File -# Begin Source File - -SOURCE=.\libspeex\speex_preprocess.h -# End Source File -# Begin Source File - -SOURCE=.\libiax\src\winpoop.h -# End Source File -# End Group -# End Target -# End Project Deleted: trunk/lib/iaxclient_lib.dsw =================================================================== --- trunk/lib/iaxclient_lib.dsw 2007-05-07 20:20:18 UTC (rev 966) +++ trunk/lib/iaxclient_lib.dsw 2007-05-07 22:26:39 UTC (rev 967) @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "iaxclient_lib"=.\iaxclient_lib.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - Deleted: trunk/lib/iaxclient_lib.vco =================================================================== --- trunk/lib/iaxclient_lib.vco 2007-05-07 20:20:18 UTC (rev 966) +++ trunk/lib/iaxclient_lib.vco 2007-05-07 22:26:39 UTC (rev 967) @@ -1,522 +0,0 @@ -\xD0\xCFࡱ\xE1 |
From: <jpg...@us...> - 2007-05-09 16:01:24
|
Revision: 976 http://svn.sourceforge.net/iaxclient/?rev=976&view=rev Author: jpgrayson Date: 2007-05-09 09:01:26 -0700 (Wed, 09 May 2007) Log Message: ----------- Modify iaxclient to pass iax timestamp information for audio and video events (iaxc_ev_video and iaxc_ev_audio). These are the timestamps coming from the headers of incoming iax frames. Modified Paths: -------------- trunk/lib/audio_encode.c trunk/lib/iaxclient.h trunk/lib/iaxclient_lib.c trunk/lib/iaxclient_lib.h trunk/lib/video.c Modified: trunk/lib/audio_encode.c =================================================================== --- trunk/lib/audio_encode.c 2007-05-09 15:53:14 UTC (rev 975) +++ trunk/lib/audio_encode.c 2007-05-09 16:01:26 UTC (rev 976) @@ -319,7 +319,7 @@ // Send the encoded audio data back to the app if required // TODO: fix the stupid way in which the encoded audio size is returned if ( iaxc_get_audio_prefs() & IAXC_AUDIO_PREF_RECV_LOCAL_ENCODED ) - iaxc_do_audio_callback(callNo, IAXC_SOURCE_LOCAL, 1, + iaxc_do_audio_callback(callNo, 0, IAXC_SOURCE_LOCAL, 1, call->encoder->format & IAXC_AUDIO_FORMAT_MASK, sizeof(outbuf) - outsize, outbuf); Modified: trunk/lib/iaxclient.h =================================================================== --- trunk/lib/iaxclient.h 2007-05-09 15:53:14 UTC (rev 975) +++ trunk/lib/iaxclient.h 2007-05-09 16:01:26 UTC (rev 976) @@ -216,6 +216,7 @@ struct iaxc_ev_video { int callNo; + unsigned int ts; int format; int width; int height; @@ -227,12 +228,13 @@ struct iaxc_ev_audio { - int callNo; - int format; - int encoded; - int source; - int size; - unsigned char *data; + int callNo; + unsigned int ts; + int format; + int encoded; + int source; + int size; + unsigned char *data; }; struct iaxc_ev_registration { Modified: trunk/lib/iaxclient_lib.c =================================================================== --- trunk/lib/iaxclient_lib.c 2007-05-09 15:53:14 UTC (rev 975) +++ trunk/lib/iaxclient_lib.c 2007-05-09 16:01:26 UTC (rev 976) @@ -342,12 +342,13 @@ iaxc_post_event(e); } -void iaxc_do_audio_callback(int callNo, int source, int encoded, int format, - int size, unsigned char *data) +void iaxc_do_audio_callback(int callNo, unsigned int ts, int source, + int encoded, int format, int size, unsigned char *data) { iaxc_event e; e.type = IAXC_EVENT_AUDIO; + e.ev.audio.ts = ts; e.ev.audio.encoded = encoded; assert(source == IAXC_SOURCE_REMOTE || source == IAXC_SOURCE_LOCAL); e.ev.audio.source = source; @@ -899,7 +900,7 @@ break; if ( audio_prefs & IAXC_AUDIO_PREF_RECV_LOCAL_RAW ) - iaxc_do_audio_callback(selected_call, + iaxc_do_audio_callback(selected_call, 0, IAXC_SOURCE_LOCAL, 0, 0, to_read * 2, (unsigned char *)buf); @@ -1077,8 +1078,8 @@ /* Pass encoded audio back to the app if required */ if ( audio_prefs & IAXC_AUDIO_PREF_RECV_REMOTE_ENCODED ) - iaxc_do_audio_callback(callNo, IAXC_SOURCE_REMOTE, 1, - format & IAXC_AUDIO_FORMAT_MASK, + iaxc_do_audio_callback(callNo, e->ts, IAXC_SOURCE_REMOTE, + 1, format & IAXC_AUDIO_FORMAT_MASK, e->datalen - total_consumed, e->data + total_consumed); @@ -1099,8 +1100,8 @@ // the number to obtain the size in bytes. // format will also be 0 since this is raw audio int size = (fr_samples - samples - mainbuf_delta) * 2; - iaxc_do_audio_callback(callNo, IAXC_SOURCE_REMOTE, 0, 0, - size, (unsigned char *)fr); + iaxc_do_audio_callback(callNo, e->ts, IAXC_SOURCE_REMOTE, + 0, 0, size, (unsigned char *)fr); } if ( iaxc_audio_output_mode != 0 ) @@ -1135,7 +1136,7 @@ if ( call->vformat ) { if ( iaxc_receive_video(call, selected_call, e->data, - e->datalen, call->vformat) < 0 ) + e->datalen, e->ts, call->vformat) < 0 ) { iaxc_usermsg(IAXC_STATUS, "Bad or incomplete video packet. Unable to decode."); Modified: trunk/lib/iaxclient_lib.h =================================================================== --- trunk/lib/iaxclient_lib.h 2007-05-09 15:53:14 UTC (rev 975) +++ trunk/lib/iaxclient_lib.h 2007-05-09 16:01:26 UTC (rev 976) @@ -119,7 +119,8 @@ void os_init(void); void iaxc_usermsg(int type, const char *fmt, ...); void iaxc_do_levels_callback(float input, float output); -void iaxc_do_audio_callback(int callNo, int remote, int encoded, int format, int size, unsigned char *data); +void iaxc_do_audio_callback(int callNo, unsigned int ts, int remote, + int encoded, int format, int size, unsigned char *data); #include "iaxclient.h" @@ -277,7 +278,8 @@ int iaxc_video_initialize(); int iaxc_video_destroy(); int iaxc_receive_video(struct iaxc_call * call, int sel_call, - void * encoded_video, int encoded_video_len, int format); + void * encoded_video, int encoded_video_len, + unsigned int ts, int format); int iaxc_send_video(struct iaxc_call *, int); extern double iaxc_silence_threshold; Modified: trunk/lib/video.c =================================================================== --- trunk/lib/video.c 2007-05-09 15:53:14 UTC (rev 975) +++ trunk/lib/video.c 2007-05-09 16:01:26 UTC (rev 976) @@ -367,12 +367,14 @@ * - encoded - true if data is encoded * - rgb32 - if true, convert data to RGB32 before showing */ -void show_video_frame(char *videobuf, int size, int cn, int source, int encoded, int rgb32) +void show_video_frame(char *videobuf, int size, int cn, int source, int encoded, + unsigned int ts, int rgb32) { iaxc_event e; char * buffer; e.type = IAXC_EVENT_VIDEO; + e.ev.video.ts = ts; if ( size <= 0 ) fprintf(stderr, "WARNING: size %d in show_video_frame\n", size); @@ -429,7 +431,7 @@ // Send the raw frame to the main app, if necessary if ( iaxc_video_prefs & IAXC_VIDEO_PREF_RECV_LOCAL_RAW ) { - show_video_frame(videobuf, inlen, -1, IAXC_SOURCE_LOCAL, 0, + show_video_frame(videobuf, inlen, -1, IAXC_SOURCE_LOCAL, 0, 0, iaxc_video_prefs & IAXC_VIDEO_PREF_RECV_RGB32); } @@ -511,7 +513,7 @@ if ( iaxc_video_prefs & IAXC_VIDEO_PREF_RECV_LOCAL_ENCODED ) { show_video_frame(slice_set.data[i], slice_set.size[i], - -1, IAXC_SOURCE_LOCAL, 1, 0); + -1, IAXC_SOURCE_LOCAL, 1, 0, 0); } if ( !(iaxc_video_prefs & IAXC_VIDEO_PREF_SEND_DISABLE) ) @@ -542,7 +544,8 @@ /* process an incoming video frame */ int iaxc_receive_video(struct iaxc_call *call, int sel_call, - void *encoded_video, int encoded_video_len, int format) + void *encoded_video, int encoded_video_len, + unsigned int ts, int format) { static char videobuf[VIDEO_BUFSIZ]; int outsize = VIDEO_BUFSIZ; @@ -563,7 +566,7 @@ if ( iaxc_video_prefs & IAXC_VIDEO_PREF_RECV_REMOTE_ENCODED ) { show_video_frame((char *)encoded_video, encoded_video_len, -1, - IAXC_SOURCE_REMOTE, 1, 0); + IAXC_SOURCE_REMOTE, 1, ts, 0); } /* destroy vdecoder if it is incorrect type */ @@ -626,7 +629,7 @@ if ( outsize > 0 ) { show_video_frame(videobuf, outsize, sel_call, - IAXC_SOURCE_REMOTE, 0, + IAXC_SOURCE_REMOTE, 0, ts, iaxc_video_prefs & IAXC_VIDEO_PREF_RECV_RGB32); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpg...@us...> - 2007-08-13 22:42:47
|
Revision: 1081 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1081&view=rev Author: jpgrayson Date: 2007-08-13 15:42:45 -0700 (Mon, 13 Aug 2007) Log Message: ----------- Remove unused SSUtility.[ch] code. Tidy whitespace in vdigGrab.[ch]. Modified Paths: -------------- trunk/lib/Makefile.am trunk/lib/videoLib/macosx/vdigGrab.c trunk/lib/videoLib/macosx/vdigGrab.h Removed Paths: ------------- trunk/lib/videoLib/macosx/SSUtility.c trunk/lib/videoLib/macosx/SSUtility.h Modified: trunk/lib/Makefile.am =================================================================== --- trunk/lib/Makefile.am 2007-08-13 22:41:29 UTC (rev 1080) +++ trunk/lib/Makefile.am 2007-08-13 22:42:45 UTC (rev 1081) @@ -165,8 +165,6 @@ SRCS_MACOSX= \ portmixer/px_mac_core/px_mac_core.c \ unixfuncs.c \ - videoLib/macosx/SSUtility.c \ - videoLib/macosx/SSUtility.h \ videoLib/macosx/macgrab.c \ videoLib/macosx/vdigGrab.c \ videoLib/macosx/vdigGrab.h Deleted: trunk/lib/videoLib/macosx/SSUtility.c =================================================================== --- trunk/lib/videoLib/macosx/SSUtility.c 2007-08-13 22:41:29 UTC (rev 1080) +++ trunk/lib/videoLib/macosx/SSUtility.c 2007-08-13 22:42:45 UTC (rev 1081) @@ -1,273 +0,0 @@ -/* - * SSUtility.c - * seeSaw - * - * Created by Daniel Heckenberg. - * Copyright (c) 2004 Daniel Heckenberg. All rights reserved. - * (danielh.seeSaw<at>cse<dot>unsw<dot>edu<dot>au) - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the right to use, copy, modify, merge, publish, communicate, sublicence, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * TO THE EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED - * "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - */ - -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> -#include <math.h> - -#include "SSUtility.h" - -void -printError(const char* format, ...) -{ - va_list arglist; - fprintf(stderr, "seeSaw: "); - va_start( arglist, format ); - vfprintf( stderr, format, arglist ); - va_end( arglist ); -} - -long inline -min (long l1, long l2) -{ - return (l1 < l2) ? l1 : l2; -} - -int inline -ceilpow2i(int i) -{ - return 1 << (int) ceil(log2(i)); -} - -float inline -ceilpow2f(float f) -{ - return (float) (1L << (long) ceil(log2(f))); -} - -#pragma mark ---- Window Management data ---- - -#define HASHTABLE_SIZE 16 - -typedef struct tagIDPair -{ - int ID; - void* pData; - struct tagIDPair* pNext; -} IDPair; - -typedef struct tagHashTable -{ - int size; - IDPair** ppEntries; -} HashTable; - -static HashTable* gpHT = NULL; - -#pragma mark ---- Hash table forward declarations ---- - -/* Forward declaration of Hash table functions */ -HashTable* -hashNew(int size); - -void -hashDelete(HashTable* pHT); - -int -hashInsert(HashTable* pHT, int ID, void* pData); - -void* -hashRemove(HashTable* pHT, int ID); - -void* -hashRecall(HashTable* pHT, int ID); - -#pragma mark ---- Window Management functions ---- - -static HashTable* -getHT(void) -{ - if (!gpHT) - { - gpHT = hashNew(HASHTABLE_SIZE); - } - return gpHT; -} - -void* -getDataForID(int ID) -{ - void* pData; - if ((pData = hashRecall(getHT(), ID))) - return pData; - else - { - printError("getDataForID: ID not found\n"); - return NULL; - } -} - -void* -addDataforID(int ID, void* pData) -{ - if ((hashInsert(getHT(), ID, pData))) - { - return pData; - } else - { - printError("addDataforID: no more windows available\n"); - return NULL; - } -} - -void -removeDataforID(int ID) -{ - if (!hashRemove(getHT(), ID)) - { - printError("removeDataforID: ID not found\n"); - } -} - -#pragma mark ---- Hash table functions ---- - -int hashFunction(HashTable* pHT, int ID) -{ - return ID % pHT->size; -} - -HashTable* hashNew(int size) -{ - int i; - HashTable* pHT; - - pHT = (HashTable*) malloc(sizeof(HashTable)); - if (pHT) - { - if ((pHT->ppEntries = (IDPair**)malloc(sizeof(IDPair*)*size))) - { - pHT->size = size; - for (i = 0; i < size; ++i) - { - pHT->ppEntries[i] = NULL; - } - } else - { - free(pHT); - pHT = NULL; - } - } - return pHT; -} - -void -hashDelete(HashTable* pHT) -{ - int h; - IDPair* pEntry = NULL; - IDPair* pEntryNext = NULL; - - for (h = 0; h < pHT->size; ++h) - { - for (pEntry = pHT->ppEntries[h]; pEntry; ) - { - pEntryNext = pEntry->pNext; - free(pEntry); - pEntry = pEntryNext; - } - } -} - -IDPair* -hashLocate(HashTable* pHT, int ID, int createFlag) -{ - int h; - IDPair* pEntry = NULL; - - h = hashFunction(pHT, ID); - for (pEntry = pHT->ppEntries[h]; pEntry; pEntry=pEntry->pNext) - { - if ((pEntry->ID) == ID) - return pEntry; - } - if (createFlag) - { - pEntry = (IDPair*) malloc(sizeof(IDPair)); - pEntry->ID = ID; - pEntry->pData = NULL; - pEntry->pNext = pHT->ppEntries[h]; - pHT->ppEntries[h] = pEntry; - } - return pEntry; -} - -void* -hashRemove(HashTable* pHT, int ID) -{ - int h; - IDPair* pEntry = NULL; - IDPair* pLastEntry = NULL; - void* pData = NULL; - - h = hashFunction(pHT, ID); - for (pEntry = pHT->ppEntries[h]; pEntry; pLastEntry=pEntry, pEntry=pEntry->pNext) - { - if ((pEntry->ID) == ID) - { - if (pEntry == pHT->ppEntries[h]) - { - pHT->ppEntries[h] = pEntry->pNext; - } else if (pLastEntry) - { - pLastEntry->pNext = pEntry->pNext; - } - pData = pEntry->pData; - free(pEntry); - break; - } - } - return pData; -} - -int -hashInsert(HashTable* pHT, int ID, void* pData) -{ - IDPair* pEntry = NULL; - - // Fail on duplicate ID - if (hashLocate(pHT, ID, 0)) - return 0; - - pEntry = hashLocate(pHT, ID, 1); - pEntry->pData = pData; - return 1; -} - -void* -hashRecall(HashTable* pHT, int ID) -{ - IDPair* pEntry = NULL; - - if((pEntry = hashLocate(pHT, ID, 0))) - { - return pEntry->pData; - } - - return NULL; -} Deleted: trunk/lib/videoLib/macosx/SSUtility.h =================================================================== --- trunk/lib/videoLib/macosx/SSUtility.h 2007-08-13 22:41:29 UTC (rev 1080) +++ trunk/lib/videoLib/macosx/SSUtility.h 2007-08-13 22:42:45 UTC (rev 1081) @@ -1,55 +0,0 @@ -/* - * SSUtility.h - * seeSaw - * - * Created by Daniel Heckenberg. - * Copyright (c) 2004 Daniel Heckenberg. All rights reserved. - * (danielh.seeSaw<at>cse<dot>unsw<dot>edu<dot>au) - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the right to use, copy, modify, merge, publish, communicate, sublicence, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * TO THE EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED - * "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - */ - -#ifndef SSUTILITY_H -#define SSUTILITY_H - -void -printError(const char* format, ...); - -long inline -min (long l1, long l2); - -int inline -ceilpow2i(int i); - -float inline -ceilpow2f(float f); - -#pragma mark ---- Window Management functions ---- - -void* -getDataForID(int ID); - -void* -addDataforID(int ID, void* pData); - -void -removeDataforID(int ID); - -#endif //SSUTILITY_H \ No newline at end of file Modified: trunk/lib/videoLib/macosx/vdigGrab.c =================================================================== --- trunk/lib/videoLib/macosx/vdigGrab.c 2007-08-13 22:41:29 UTC (rev 1080) +++ trunk/lib/videoLib/macosx/vdigGrab.c 2007-08-13 22:42:45 UTC (rev 1081) @@ -26,11 +26,8 @@ * */ -#include "SSUtility.h" #include "vdigGrab.h" -#pragma mark ---- VdigGrab data ---- - struct tagVdigGrab { // State @@ -60,13 +57,11 @@ Fixed cpFrameRate; }; -#pragma mark ---- Forward declarations ---- - Boolean MySGModalFilterProc ( - DialogPtr theDialog, - const EventRecord *theEvent, - short *itemHit, - long refCon ); + DialogPtr theDialog, + const EventRecord *theEvent, + short *itemHit, + long refCon ); SeqGrabComponent MakeSequenceGrabber(WindowRef pWindow); @@ -80,8 +75,6 @@ OSErr vdgGetSettings(VdigGrab* pVdg); -#pragma mark ---- VdigGrab functions ---- - VdigGrab* vdgNew() { @@ -122,14 +115,16 @@ { OSErr err; - // Use the SG Dialog to allow the user to select device and compression settings - /* if (err = RequestSGSettings( pVdg->seqGrab, - pVdg->sgchanVideo)) + // Use the SG Dialog to allow the user to select device and + // compression settings +#if 0 + if (err = RequestSGSettings( pVdg->seqGrab, + pVdg->sgchanVideo)) { printError("RequestSGSettings err=%d\n", err); goto endFunc; } - */ +#endif if ((err = vdgGetSettings(pVdg))) { printError("vdgGetSettings err=%d\n", err); @@ -230,8 +225,8 @@ /* // Apple's SoftVDig doesn't seem to like these calls - if (err = VDCaptureStateChanging( pVdg->vdCompInst, - vdFlagCaptureLowLatency | vdFlagCaptureSetSettingsBegin)) + if (err = VDCaptureStateChanging(pVdg->vdCompInst, + vdFlagCaptureLowLatency | vdFlagCaptureSetSettingsBegin)) { printError("VDCaptureStateChanging err=%d\n", err); // goto endFunc; @@ -329,7 +324,7 @@ goto endFunc; } - if ((err = VDCompressOneFrameAsync( pVdg->vdCompInst ))) + if ((err = VDCompressOneFrameAsync( pVdg->vdCompInst ))) { printError("VDCompressOneFrameAsync err=%d\n", err); goto endFunc; @@ -349,9 +344,9 @@ OSErr vdgGetDataRate( VdigGrab* pVdg, - long* pMilliSecPerFrame, - Fixed* pFramesPerSecond, - long* pBytesPerSecond) + long* pMilliSecPerFrame, + Fixed* pFramesPerSecond, + long* pBytesPerSecond) { OSErr err; @@ -370,7 +365,7 @@ OSErr vdgGetImageDescription( VdigGrab* pVdg, - ImageDescriptionHandle vdImageDesc ) + ImageDescriptionHandle vdImageDesc ) { OSErr err; @@ -401,29 +396,51 @@ (*pVdg->vdImageDesc)->cType = FOUR_CHAR_CODE('yuvu'); // kYUVUPixelFormat // make a scaling matrix for the sequence -// sourceRect.right = (*pVdg->vdImageDesc)->width; -// sourceRect.bottom = (*pVdg->vdImageDesc)->height; -// RectMatrix(&scaleMatrix, &sourceRect, &pMungData->bounds); + //sourceRect.right = (*pVdg->vdImageDesc)->width; + //sourceRect.bottom = (*pVdg->vdImageDesc)->height; + //RectMatrix(&scaleMatrix, &sourceRect, &pMungData->bounds); - // begin the process of decompressing a sequence of frames - // this is a set-up call and is only called once for the sequence - the ICM will interrogate different codecs - // and construct a suitable decompression chain, as this is a time consuming process we don't want to do this - // once per frame (eg. by using DecompressImage) - // for more information see Ice Floe #8 http://developer.apple.com/quicktime/icefloe/dispatch008.html - // the destination is specified as the GWorld - if ((err = DecompressSequenceBeginS(&pVdg->dstImageSeq, // pointer to field to receive unique ID for sequence - pVdg->vdImageDesc, // handle to image description structure + // begin the process of decompressing a sequence of frames + // this is a set-up call and is only called once for the sequence + // - the ICM will interrogate different codecs and construct a + // suitable decompression chain, as this is a time consuming + // process we don't want to do this once per frame (eg. by using + // DecompressImage) for more information see Ice Floe #8 + // http://developer.apple.com/quicktime/icefloe/dispatch008.html + // the destination is specified as the GWorld + if ((err = DecompressSequenceBeginS( + // pointer to field to receive unique + // ID for sequence + &pVdg->dstImageSeq, + // handle to image description structure + pVdg->vdImageDesc, 0, 0, - dstPort, //GetWindowPort(pMungData->pWindow), // port for the DESTINATION image - NULL, // graphics device handle, if port is set, set to NULL - NULL, //&sourceRect, // source rectangle defining the portion of the image to decompress - NULL, //&scaleMatrix, // transformation matrix - srcCopy, // transfer mode specifier - (RgnHandle)NULL, // clipping region in dest. coordinate system to use as a mask + // port for the DESTINATION image + //GetWindowPort(pMungData->pWindow), + dstPort, + // graphics device handle, if port is + // set, set to NULL + NULL, + // source rectangle defining the + // portion of the image to decompress + //&sourceRect, + NULL, + // transformation matrix + //&scaleMatrix, + NULL, + // transfer mode specifier + srcCopy, + // clipping region in dest. coordinate + // system to use as a mask + (RgnHandle)NULL, 0, // flags - codecHighQuality, //codecNormalQuality, // accuracy in decompression - bestSpeedCodec))) //anyCodec); //bestSpeedCodec); // compressor identifier or special identifiers ie. bestSpeedCodec + // accuracy in decompression + codecHighQuality, + // compressor identifier or special + // identifiers ie. bestSpeedCodec + bestSpeedCodec))) + //anyCodec); //bestSpeedCodec); { printError("DecompressSequenceBeginS err=%d\n", err); goto endFunc; @@ -434,9 +451,9 @@ } OSErr -vdgDecompressionSequenceWhen( VdigGrab* pVdg, - Ptr theData, - long dataSize) +vdgDecompressionSequenceWhen(VdigGrab* pVdg, + Ptr theData, + long dataSize) { OSErr err; CodecFlags ignore = 0; @@ -665,8 +682,6 @@ free(pVdg); } -#pragma mark ---- Vdig utility functions ---- - OSErr vdgGetSettings(VdigGrab* pVdg) { @@ -691,8 +706,8 @@ } // Get the selected vdig from the SG - if (!(pVdg->vdCompInst = SGGetVideoDigitizerComponent(pVdg->sgchanVideo))) - { + if (!(pVdg->vdCompInst = SGGetVideoDigitizerComponent(pVdg->sgchanVideo))) + { printError("SGGetVideoDigitizerComponent error\n"); goto endFunc; } @@ -770,8 +785,8 @@ goto endFunc; } -// err = SGSetChannelBounds(*sgchanVideo, rect); - // set usage for new video channel to avoid playthrough + //err = SGSetChannelBounds(*sgchanVideo, rect); + // set usage for new video channel to avoid playthrough // note we don't set seqGrabPlayDuringRecord if ((err = SGSetChannelUsage(*psgchanVideo, flags | seqGrabRecord))) { @@ -791,12 +806,11 @@ } OSErr -RequestSGSettings( SeqGrabComponent seqGrab, - SGChannel sgchanVideo ) +RequestSGSettings( SeqGrabComponent seqGrab, SGChannel sgchanVideo ) { OSErr err; - SGModalFilterUPP MySGModalFilterUPP; + SGModalFilterUPP MySGModalFilterUPP; if (!(MySGModalFilterUPP = NewSGModalFilterUPP (MySGModalFilterProc))) { printError("NewSGModalFilterUPP error\n"); @@ -805,9 +819,11 @@ } // let the user configure and choose the device and settings - // "Due to a bug in all versions QuickTime 6.x for the function call "SGSettingsDialog()" - // when used with the "seqGrabSettingsPreviewOnly" parameter, all third party panels will - // be excluded." from http://www.outcastsoft.com/ASCDFG1394.html 15/03/04 + // "Due to a bug in all versions QuickTime 6.x for the function call + // "SGSettingsDialog()" when used with the + // "seqGrabSettingsPreviewOnly" parameter, all third party panels + // will be excluded." + // from http://www.outcastsoft.com/ASCDFG1394.html 15/03/04 //if (err = SGSettingsDialog(seqGrab, sgchanVideo, 0, NULL, seqGrabSettingsPreviewOnly, MySGModalFilterUPP, 0)) if ((err = SGSettingsDialog(seqGrab, sgchanVideo, 0, NULL, 0, MySGModalFilterUPP, 0))) @@ -828,18 +844,18 @@ // From QT sample code // Declaration of a typical application-defined function Boolean MySGModalFilterProc ( - DialogPtr theDialog, - const EventRecord *theEvent, - short *itemHit, - long refCon ) + DialogPtr theDialog, + const EventRecord *theEvent, + short *itemHit, + long refCon ) { // Ordinarily, if we had multiple windows we cared about, we'd handle // updating them in here, but since we don't, we'll just clear out // any update events meant for us - Boolean handled = false; + Boolean handled = false; if ((theEvent->what == updateEvt) && - ((WindowPtr) theEvent->message == (WindowPtr) refCon)) + ((WindowPtr) theEvent->message == (WindowPtr) refCon)) { BeginUpdate ((WindowPtr) refCon); EndUpdate ((WindowPtr) refCon); @@ -848,12 +864,10 @@ return (handled); } -#pragma mark ---- Public utility functions ---- - OSErr -createOffscreenGWorld( GWorldPtr* pGWorldPtr, - OSType pixelFormat, - Rect* pBounds) +createOffscreenGWorld(GWorldPtr* pGWorldPtr, + OSType pixelFormat, + Rect* pBounds) { OSErr err; CGrafPtr theOldPort; @@ -871,8 +885,8 @@ goto endFunc; } - // lock the pixmap and make sure it's locked because - // we can't decompress into an unlocked PixMap + // lock the pixmap and make sure it's locked because + // we can't decompress into an unlocked PixMap if (!LockPixels(GetGWorldPixMap(*pGWorldPtr))) printError("createOffscreenGWorld: Can't lock pixels!\n"); @@ -894,5 +908,3 @@ DisposeGWorld(gworld); } - - Modified: trunk/lib/videoLib/macosx/vdigGrab.h =================================================================== --- trunk/lib/videoLib/macosx/vdigGrab.h 2007-08-13 22:41:29 UTC (rev 1080) +++ trunk/lib/videoLib/macosx/vdigGrab.h 2007-08-13 22:42:45 UTC (rev 1081) @@ -32,12 +32,8 @@ #include <Carbon/Carbon.h> #include <QuickTime/QuickTime.h> -#pragma mark ---- VdigGrab data ---- - typedef struct tagVdigGrab VdigGrab; -#pragma mark ---- VdigGrab functions ---- - VdigGrab* vdgNew(); @@ -109,8 +105,6 @@ void vdgDelete(VdigGrab* pVdg); -#pragma mark ---- Utility functions ---- - OSErr createOffscreenGWorld( GWorldPtr* pGWorldPtr, OSType pixelFormat, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpg...@us...> - 2007-08-15 17:36:35
|
Revision: 1084 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1084&view=rev Author: jpgrayson Date: 2007-08-15 10:36:35 -0700 (Wed, 15 Aug 2007) Log Message: ----------- Remove code for the proprietary vss h264 codec. Removed Paths: ------------- trunk/lib/codec_h264_vss.c trunk/lib/codec_h264_vss.h Deleted: trunk/lib/codec_h264_vss.c =================================================================== --- trunk/lib/codec_h264_vss.c 2007-08-15 17:35:25 UTC (rev 1083) +++ trunk/lib/codec_h264_vss.c 2007-08-15 17:36:35 UTC (rev 1084) @@ -1,621 +0,0 @@ -/* - * iaxclient: a cross-platform IAX softphone library - * - * Copyrights: - * Copyright (C) 2003-2006, Horizon Wimba, Inc. - * Copyright (C) 2007, Wimba, Inc. - * - * Contributors: - * Mihai Balea <mihaiAThatesDOTms> - * - * This program is free software, distributed under the terms of - * the GNU Lesser (Library) General Public License. - */ - -#define USE_H264_RTP_FOO - -#include "iaxclient_lib.h" -#include "codec_h264_vss.h" -#include "vssh_encoder.h" -#include "vssh_decoder.h" -#ifdef USE_H264_RTP_FOO -#include "vss_rtp.h" -#endif - -#define MAX_SLICE_SIZE 8000 - -#ifndef USE_H264_RTP_FOO -// Annex B file format start code -#define START_CODE_LEN 4 -static const byte START_CODE[START_CODE_LEN] = {0, 0, 0, 1}; -#endif - -struct encoder_t -{ - void * handle; - vssh_encoder_settings_t settings; -#ifdef USE_H264_RTP_FOO - rtp_context_t * rtp_context; - vss_time start_time; - int output_buffer_size; - unsigned char * output_buffer; -#endif -}; - -struct decoder_t -{ - void * handle; - vssh_decoder_settings_t settings; -#ifdef USE_H264_RTP_FOO - rtp_context_t * rtp_context; -#endif -}; - -static char *get_error_text(int rc) -{ - switch (rc) - { - case VSSH_ERR_GENERAL: // -1 - return "general fault"; - case VSSH_ERR_MEMORY: // -2 - return "not enough memory"; - case VSSH_ERR_ARG: // -3 - return "wrong function argument value"; - case VSSH_ERR_EXPIRED: // -4 - return "evaluation has expired"; - case VSSH_ERR_SKIP_FRAME: // -5 - return "frame was skipped"; - case VSSH_ERR_FRAME_DIMENSIONS: // -6 - return "invalid input frame dimensions "; - case VSSH_ERR_SETTINGS: // -7 - return "invalid encoder settings"; - case VSSH_ERR_MORE_DATA: // -8 - return "need more input data"; - case VSSH_ERR_FILE: // -9 - return "file operation failed"; - case VSSH_ERR_STREAM_PRED_TYPE: // -10 - return "invalid prediction type"; - case VSSH_ERR_STREAM_DIRECT: // -11 - return "invalid direct parameters"; - case VSSH_ERR_STREAM_EOS: // -12 - return "unexpected end of stream"; - case VSSH_ERR_STREAM_CAVLC: // -13 - return "invalid CAVLC data"; - case VSSH_ERR_STREAM_REF_FRAME_NO: // -14 - return "invalid ref. frame number"; - case VSSH_ERR_STREAM_CBP: // -15 - return "invalid CBP"; - case VSSH_ERR_STREAM_SUBDIV_TYPE: // -16 - return "invalid subdivision type"; - case VSSH_ERR_STREAM_SPS: // -17 - return "invalid SPS"; - case VSSH_ERR_STREAM_MB_TYPE: // -18 - return "invalid macroblock type"; - case VSSH_ERR_STREAM_SUBDIV_8X8_TYPE: // -19 - return "invalid subdivision 8x8 type"; - case VSSH_ERR_STREAM_SLICE_BEFORE_SPS_OR_PPS: // -20 - return "invalid SPS or PPS reference"; - case VSSH_ERR_STREAM_WRONG_PPS_ID: // -21 - return "wrong (non-existing) PPS id"; - case VSSH_ERR_PPS_FMO_6_PARAM: // -22 - return "wrong FMO paramater value in PPS"; - case VSSH_ERR_WRONG_REORDER_CODE: // -23 - return "wrong reorder mode"; - case VSSH_ERR_PROFILE_NOT_SUPPORTED: // -24 - return "profile is not supported"; - case VSSH_ERR_NON_REF_IDR_SLICE: // -25 - return "IDR slice marked as non-ref"; - case VSSH_ERR_STREAM_FU: // -27 - return "invalid FU (see RFC 3984)"; - case VSSH_ERR_STREAM_EXTRA_MBS: // -28 - return "extra (unexpected) macroblocks detected"; - case VSSH_ERR_STREAM_QP_DELTA: // -29 - return "wrong QP delta encountered"; - case VSSH_ERR_NOT_SUPPORTED_SLICE_GROUPS: // -101 - return "slice groups not supported"; - case VSSH_ERR_NOT_SUPPORTED_ADAPTIVE_FRAME_FIELD: // -102 - return "adaptive frame/field coding not supported"; - case VSSH_ERR_NOT_SUPPORTED_FRAMES_AND_FIELDS_MUX: // -103 - return "frames and fields mux not supported"; - case VSSH_ERR_NOT_SUPPORTED_SLICE_TYPE: // -104 - return "unsupported slice type (SI or SP)"; - case VSSH_ERR_NOT_SUPPORTED_PIC_TIMING_PIC_STRUCT: // -106 - return "not supported pic_timing structure"; - } - return "unknown error"; -} - -#ifdef USE_H264_RTP_FOO -static int rtp_send_callback(void * ctx, char * packet, int packet_size) -{ - /* We are encapsulating these rtp packets in iax packets. To this - * end, we put the packet into the slice set. - */ - struct slice_set_t * slice_set = (struct slice_set_t *)ctx; - - memcpy(slice_set->data[slice_set->num_slices], packet, packet_size); - slice_set->size[slice_set->num_slices] = packet_size; - slice_set->num_slices += 1; - - return 0; -} -#else -static int append_slice(struct slice_set_t * slice_set, byte * src, int srclen) -{ - if ( srclen + START_CODE_LEN > MAX_TRUNK_LEN ) - { - fprintf(stderr, "h264_vss encoder: failed to append slice\n"); - return -1; - } - - memcpy(slice_set->data[slice_set->num_slices], - START_CODE, START_CODE_LEN); - - memcpy(slice_set->data[slice_set->num_slices] + START_CODE_LEN, - src, srclen); - - slice_set->size[slice_set->num_slices] = srclen + START_CODE_LEN; - slice_set->num_slices += 1; - - return 0; -} -#endif - -static yuv_frame_t * compose_yuv_frame(struct iaxc_video_codec * c, int inlen, - char * in) -{ - struct encoder_t * encoder; - yuv_frame_t * input_frame; - int y_size; - int i; - byte * src; - byte * dst; - - encoder = (struct encoder_t *)c->encstate; - - /* If no input frame can be obtained it means that the encoder buffers - * are full, so we need to sleep for a while here to yield control to - * other threads. - */ - while ( !(input_frame = vssh_enc_get_free_frame(encoder->handle)) ) - iaxc_millisleep(5); - -#ifdef USE_H264_RTP_FOO - /* Set the input frame timestamp. This timestamp eventually makes its - * way into the rtp headers for the NALU(s) generated for this frame. - * vss_gettime() gives us the time in microseconds, we have to scale - * it to units of 10MHz for vss_rtp_rtpts() so that we end up with a - * timestamp with 90kHz units which is what rtp uses. - */ - input_frame->info.timestamp = vss_rtp_rtpts(encoder->rtp_context, - 10 * (vss_gettime() - encoder->start_time)); -#endif - - /* Calculate Y channel size */ - y_size = c->width * c->height; - - /* Fill input frame */ - - /* Y channel */ - src = (byte *)in; - dst = input_frame->y; - for ( i = 0; i < c->height; i++ ) - { - memcpy(dst, src, c->width); - src += c->width; - dst += input_frame->width; - } - - /* U channel */ - src = (byte *)(in + y_size); - dst = input_frame->u; - for ( i = 0; i < c->height / 2; i++ ) - { - memcpy(dst, src, c->width / 2); - src += c->width / 2; - dst += input_frame->width / 2; - } - - /* V channel */ - src = (byte *)(in + y_size + y_size / 4); - dst = input_frame->v; - for ( i = 0; i < c->height / 2; i++ ) - { - memcpy(dst, src, c->width / 2); - src += c->width / 2; - dst += input_frame->width/2; - } - - return input_frame; -} - -static int encode(struct iaxc_video_codec *c, int inlen, char *in, struct slice_set_t *slice_set) -{ - struct encoder_t * encoder; - yuv_frame_t * input_frame; - int sps_done = 0; - - // Sanity checks - if ( !c || !c->encstate || in == NULL || slice_set == NULL ) - return -1; - - encoder = (struct encoder_t *)c->encstate; - - input_frame = compose_yuv_frame(c, inlen, in); - - // Pass the frame to the encoder - vssh_enc_set_frame(encoder->handle, input_frame, NULL); - -#ifdef USE_H264_RTP_FOO - /* The rtp_send_callback() function gets this as its ctx argument */ - encoder->rtp_context->network_context = slice_set; -#endif - - slice_set->num_slices = 0; - slice_set->key_frame = 0; - - while ( 1 ) - { - vssh_slice_data_t slice; -#ifdef USE_H264_RTP_FOO - vss_uint encoded_ts; - int actual_size; -#endif - int ret; - -#ifdef USE_H264_RTP_FOO - slice.slice_data = encoder->output_buffer; - slice.slice_size = encoder->output_buffer_size; - - ret = vssh_enc_encode_packet(encoder->handle, &slice, - 0, /* single NAL packetization mode */ - c->fragsize, - &actual_size); -#else - ret = vssh_enc_get_slice(encoder->handle, &slice); -#endif - - if ( ret != VSSH_OK ) - break; - -#ifdef USE_H264_RTP_FOO - encoded_ts = (vss_uint)slice.frame_info.timestamp; -#endif - - // If the slice is the first slice in an IDR (key) frame, add the - // SPS and PPS headers to allow for decoder (re)initialziation - // This way, a client can connect in the middle of a stream, as soon as - // an IDR frame arrives - if ( !sps_done && slice.frame_info.idr_flag ) - { - vssh_spps_data_t spps; - - if ( vssh_enc_get_sps(encoder->handle, &spps) != VSSH_OK ) - { - fprintf(stderr, - "h264_vss encoder: failed getting sps\n"); - return -1; - } - -#ifdef USE_H264_RTP_FOO - vss_rtp_send_packet(encoder->rtp_context, - spps.spps_data, spps.spps_size, - 0, encoded_ts, 0, 0); -#else - if ( append_slice(slice_set, spps.spps_data, spps.spps_size) < 0 ) - return -1; -#endif - - if ( vssh_enc_get_pps(encoder->handle, &spps) != VSSH_OK ) - { - fprintf(stderr, - "h264_vss encoder: failed getting pps\n"); - return -1; - } - -#ifdef USE_H264_RTP_FOO - vss_rtp_send_packet(encoder->rtp_context, - spps.spps_data, spps.spps_size, - 0, encoded_ts, 0, 0); -#else - if ( append_slice(slice_set, spps.spps_data, spps.spps_size) < 0 ) - return -1; -#endif - - sps_done = 1; - slice_set->key_frame = 1; - } - -#ifdef USE_H264_RTP_FOO - vss_rtp_send_packet(encoder->rtp_context, - slice.slice_data, actual_size, - 0, encoded_ts, 0, 0); -#else - if ( append_slice(slice_set, slice.slice_data, slice.slice_size) < 0 ) - return -1; -#endif - } - - return 0; -} - -static int decode(struct iaxc_video_codec *c, int inlen, char *in, int *outlen, char *out) -{ - struct decoder_t * decoder; - yuv_frame_t frame; - int ret; -#ifdef USE_H264_RTP_FOO - rtp_hdr_t * hdr; - vss_byte * payload; - int payload_size; -#endif - - // Sanity checks - if ( !c || !c->decstate || in == NULL || inlen <= 0 || out == NULL || outlen == NULL ) - return -1; - - decoder = (struct decoder_t *)c->decstate; - - if ( decoder->handle == NULL ) - return -1; - -#ifdef USE_H264_RTP_FOO - ret = vss_rtp_parse_packet(decoder->rtp_context, (unsigned char *)in, - inlen, &hdr, &payload); - - if ( ret < 0 ) - { - fprintf(stderr, "h264_vss decoder: failed to parse rtp packet\n"); - return 1; - } - - payload_size = inlen - (payload - (vss_byte *)in); - - if ( !payload ) - vssh_dec_flush(decoder->handle, 1); - else - vssh_dec_feed_data_ex(decoder->handle, payload, payload_size, - 1, /* is nal unit */ - hdr->ts); -#else - // Feed the encoded data to the decoder - if ( vssh_dec_feed_data(decoder->handle, (byte *)in, inlen, 0) != VSSH_OK ) - { - fprintf(stderr, "h264_vss decoder: failed to feed decoder\n"); - return 1; - } -#endif - - // Check for a completely decoded frame - ret = vssh_dec_decode_frame(decoder->handle, &frame); - - if ( ret > 0 ) - { - /* Valid decoded frame returned */ - int y_size; - int frame_size; - - y_size = frame.width * frame.height; - frame_size = y_size * 3 / 2; - - if ( frame_size > *outlen ) - { - fprintf(stderr, - "h264_vss decoder: decoded frame bigger than output buffer\n"); - *outlen = 0; - return -1; - } - - /* Copy frame to output buffer */ - memcpy(out, frame.y, y_size); - out += y_size; - memcpy(out, frame.u, y_size/4); - out += y_size / 4; - memcpy(out, frame.v, y_size/4); - - *outlen = frame_size; - - return 0; - } - else if ( ret < 0 ) - { - if ( ret == VSSH_ERR_STREAM_SLICE_BEFORE_SPS_OR_PPS ) - { - fprintf(stderr, - "h264_vss decoder: stream slice received when waiting for SPS\n"); - } - else - { - fprintf(stderr, - "h264_vss decoder: failed to decode frame\n"); - return -1; - } - } - - /* Decoded frame is not yet available */ - return 1; -} - -static void destroy(struct iaxc_video_codec *c) -{ - struct encoder_t *encoder; - struct decoder_t *decoder; - - if ( c == NULL ) return; - - if ( c->encstate != NULL ) - { - encoder = (struct encoder_t *)c->encstate; - vssh_enc_close(encoder->handle); -#ifdef USE_H264_RTP_FOO - vss_rtp_close(encoder->rtp_context); - free(encoder->output_buffer); -#endif - free(encoder); - } - if ( c->decstate != NULL ) - { - decoder = (struct decoder_t *)c->decstate; - vssh_dec_close(decoder->handle); -#ifdef USE_H264_RTP_FOO - vss_rtp_close(decoder->rtp_context); -#endif - free(decoder); - } - free(c); -} - -static void prepareEncoderSettings(vssh_encoder_settings_t *settings, int width, int height, int framerate, int bitrate, int fragsize) -{ - // zero all structure fields - memset(settings, 0, sizeof(*settings)); - vssh_enc_default_settings(settings); - - // disable MultiThreading - settings->mt_settings.disable = 1; - - // disable SNR calculation - settings->calc_snr = 0; - - // enable auto configuration - settings->auto_config = 1; - - // describe input (source) - settings->user_settings.input.material = 0; // material: 0=progressive, 1=interlaced; - settings->user_settings.input.noisy = 0; // noise level [0..64]; - settings->frame_width = width; - settings->frame_height = height; - - // describe desired output - settings->user_settings.output.bitrate = bitrate; // desired bitrate, kbps; - settings->user_settings.output.detect = 1; // scene change detection: 0/1; - settings->user_settings.output.interval = framerate * 1; // key frame interval: [0..300] - settings->user_settings.output.target = 1; // target application: 0=playback, 1=streaming; - - // codec operational parameters - settings->user_settings.codec.multipass = 0; // multipass: 0=single pass, 1=first pass, 2=second pass; - settings->user_settings.codec.quality = 0; // codec quality: 0=realtime, 1=fast, 2=good, 3=best; - - // provide frame rate - settings->gop_settings.num_units = 10000; - settings->gop_settings.time_scale = framerate * settings->gop_settings.num_units; - - // slice settings - // 0=off; 1=#mb in slice; 2=#bytes in slice; 3 =#slices in picture - settings->slice_settings.slice_mode = 2; - settings->slice_settings.slice_param = fragsize; -} - -struct iaxc_video_codec *iaxc_video_codec_h264_new(int format, int w, int h, int framerate, int bitrate, int fragsize) -{ - struct iaxc_video_codec *c = NULL; - struct encoder_t *encoder = NULL; - struct decoder_t *decoder = NULL; - int ret; - - // Sanity check - // TODO: better sanity checks here - if ( w <= 0 || h <= 0 || framerate <= 0 || bitrate <= 0 || fragsize <= 0 ) - { - fprintf(stderr, "Could not initialize H.264 codec: sanity checks failed\n"); - return NULL; - } - // Width and height must be multiples of 16 - if ( w % 16 || h % 16 ) - { - fprintf(stderr, "Could not initialize H.264 codec: width and height must be multiples of 16\n"); - return NULL; - } - if ( fragsize > MAX_SLICE_SIZE ) - fragsize = MAX_SLICE_SIZE; - - c = calloc(sizeof(struct iaxc_video_codec), 1); - encoder = calloc(sizeof(struct encoder_t), 1); - decoder = calloc(sizeof(struct decoder_t), 1); - if ( !c || !encoder || !decoder ) - { - free(encoder); - free(decoder); - free(c); - fprintf(stderr, "Could not allocate memory for the H.264 codec\n"); - return NULL; - } - - // Set up the encoder - bitrate = bitrate / 1000; // Codec requires bitrate to be in kbps - prepareEncoderSettings(&(encoder->settings), w, h, framerate, bitrate, fragsize); - ret = vssh_enc_open(&(encoder->handle), &(encoder->settings)); - if ( ret != VSSH_OK ) - { - fprintf(stderr, - "Could not initialize H.264 encoder: description = %s\n", - get_error_text(ret)); - return NULL; - } - -#ifdef USE_H264_RTP_FOO - encoder->rtp_context = vss_rtp_open( - PAYLOAD_TYPE_H264, fragsize, - w, h, - rtp_send_callback, 0); - - if ( !encoder->rtp_context ) - { - fprintf(stderr, "h264_vss encoder: failed to open rtp context\n"); - return 0; - } - - encoder->start_time = vss_gettime(); - - encoder->output_buffer_size = w * h * 3 / 2; - encoder->output_buffer = (unsigned char *) - malloc(encoder->output_buffer_size); - - if ( !encoder->output_buffer ) - { - fprintf(stderr, "h264_vss encoder: failed to allocate output buffer\n"); - return 0; - } -#endif - - // Set up the decoder - ret = vssh_dec_open_ex(&(decoder->handle), &(decoder->settings)); - if ( ret != VSSH_OK || decoder->handle == NULL ) - { - fprintf(stderr, "Could not initialize H.264 decoder: description = %s", - get_error_text(ret)); - return NULL; - } - -#ifdef USE_H264_RTP_FOO - decoder->rtp_context = vss_rtp_open2(PAYLOAD_TYPE_H264, - MAX_SLICE_SIZE, /* Maximum rtp packet payload size */ - w, h, - 16, /* Maximum frames in rtp receiving queue */ - 256 * 1024, /* Maximum frame size in receiving queue */ - 1); /* Delete not ready frames */ - - if ( !decoder->rtp_context ) - { - fprintf(stderr, "h264_vss decoder: failed to open rtp context\n"); - return 0; - } -#endif - - c->width = w; - c->height = h; - c->framerate = framerate; - c->bitrate = bitrate; - c->fragsize = fragsize; - - // Set up the iaxclient codec structure - c->encstate = encoder; - c->decstate = decoder; - c->encode = encode; - c->decode = decode; - c->destroy = destroy; - c->format = IAXC_FORMAT_H264; - sprintf(c->name, "Vanguard Software Solutions H.264 codec"); - - return c; -} Deleted: trunk/lib/codec_h264_vss.h =================================================================== --- trunk/lib/codec_h264_vss.h 2007-08-15 17:35:25 UTC (rev 1083) +++ trunk/lib/codec_h264_vss.h 2007-08-15 17:36:35 UTC (rev 1084) @@ -1,15 +0,0 @@ -/* - * iaxclient: a cross-platform IAX softphone library - * - * Copyrights: - * Copyright (C) 2003-2006, Horizon Wimba, Inc. - * Copyright (C) 2007, Wimba, Inc. - * - * Contributors: - * Mihai Balea <mihaiAThatesDOTms> - * - * This program is free software, distributed under the terms of - * the GNU Lesser (Library) General Public License. - */ - -struct iaxc_video_codec *iaxc_video_codec_h264_new(int format, int w, int h, int framerate, int bitrate, int fragsize); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sb...@us...> - 2007-09-12 14:25:20
|
Revision: 1120 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1120&view=rev Author: sbalea Date: 2007-09-12 07:25:23 -0700 (Wed, 12 Sep 2007) Log Message: ----------- Call transfer improvements: - add argument error checking to iaxc_blind_transfer - add iaxc_setup_call_transfer API, that wraps iax_setup_transfer with some error checking Patch provided by Erik Bunce Modified Paths: -------------- trunk/lib/iaxclient.h trunk/lib/iaxclient_lib.c Modified: trunk/lib/iaxclient.h =================================================================== --- trunk/lib/iaxclient.h 2007-09-10 17:57:17 UTC (rev 1119) +++ trunk/lib/iaxclient.h 2007-09-12 14:25:23 UTC (rev 1120) @@ -295,6 +295,7 @@ EXPORT void iaxc_send_busy_on_incoming_call(int callNo); EXPORT void iaxc_answer_call(int callNo); EXPORT void iaxc_blind_transfer_call(int callNo, const char * number); +EXPORT void iaxc_setup_call_transfer(int sourceCallNo, int targetCallNo); EXPORT void iaxc_dump_all_calls(void); EXPORT void iaxc_dump_call(void); EXPORT void iaxc_reject_call(void); Modified: trunk/lib/iaxclient_lib.c =================================================================== --- trunk/lib/iaxclient_lib.c 2007-09-10 17:57:17 UTC (rev 1119) +++ trunk/lib/iaxclient_lib.c 2007-09-12 14:25:23 UTC (rev 1120) @@ -1439,9 +1439,23 @@ EXPORT void iaxc_blind_transfer_call(int callNo, const char * dest_extension) { + if ((callNo < 0) || + !(calls[callNo].state & IAXC_CALL_STATE_ACTIVE)) + return; + iax_transfer(calls[callNo].session, dest_extension); } +EXPORT void iaxc_setup_call_transfer(int sourceCallNo, int targetCallNo) +{ + if ((sourceCallNo < 0) || (targetCallNo < 0) || + ((calls[sourceCallNo].state & IAXC_CALL_STATE_ACTIVE) == 0) || + ((calls[targetCallNo].state & IAXC_CALL_STATE_ACTIVE) == 0)) + return; + + iax_setup_transfer(calls[sourceCallNo].session, calls[targetCallNo].session); +} + static void iaxc_dump_one_call(int callNo) { if (callNo < 0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sb...@us...> - 2007-09-26 20:06:29
|
Revision: 1160 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1160&view=rev Author: sbalea Date: 2007-09-26 13:06:30 -0700 (Wed, 26 Sep 2007) Log Message: ----------- Eliminate some duplicate code that appeard after the last merge Modified Paths: -------------- trunk/lib/codec_theora.c trunk/lib/video.c Modified: trunk/lib/codec_theora.c =================================================================== --- trunk/lib/codec_theora.c 2007-09-26 19:38:11 UTC (rev 1159) +++ trunk/lib/codec_theora.c 2007-09-26 20:06:30 UTC (rev 1160) @@ -349,8 +349,6 @@ if ( !c->encstate ) goto bail; - video_reset_codec_stats(c); - c->format = format; c->width = w; c->height = h; Modified: trunk/lib/video.c =================================================================== --- trunk/lib/video.c 2007-09-26 19:38:11 UTC (rev 1159) +++ trunk/lib/video.c 2007-09-26 20:06:30 UTC (rev 1160) @@ -872,14 +872,6 @@ return 0; } -void video_reset_codec_stats(struct iaxc_video_codec *vcodec) -{ - if ( vcodec == NULL ) return; - - memset(&vcodec->video_stats, 0, sizeof(struct iaxc_video_stats)); - gettimeofday(&vcodec->video_stats.start_time, NULL); -} - static struct slicer_context *sc = NULL; EXPORT int iaxc_push_video(void *data, unsigned int size, int fragment) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <do...@us...> - 2007-10-08 23:02:44
|
Revision: 1184 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1184&view=rev Author: dohpaz Date: 2007-10-08 16:02:47 -0700 (Mon, 08 Oct 2007) Log Message: ----------- Add an iaxc_dump_call_number() API function so I can drop a non-selected call. Modified Paths: -------------- trunk/lib/iaxclient.h trunk/lib/iaxclient_lib.c Modified: trunk/lib/iaxclient.h =================================================================== --- trunk/lib/iaxclient.h 2007-10-05 18:03:18 UTC (rev 1183) +++ trunk/lib/iaxclient.h 2007-10-08 23:02:47 UTC (rev 1184) @@ -764,6 +764,12 @@ EXPORT void iaxc_dump_all_calls(void); /*! + Hangs up and frees call \a callNo + \param callNo The call number to reject. +*/ +EXPORT void iaxc_dump_call_number( int callNo ); + +/*! Hangs up and frees the currently selected call. */ EXPORT void iaxc_dump_call(void); Modified: trunk/lib/iaxclient_lib.c =================================================================== --- trunk/lib/iaxclient_lib.c 2007-10-05 18:03:18 UTC (rev 1183) +++ trunk/lib/iaxclient_lib.c 2007-10-08 23:02:47 UTC (rev 1184) @@ -1473,6 +1473,16 @@ } +EXPORT void iaxc_dump_call_number( int callNo ) +{ + if ( ( callNo >= 0 ) && ( callNo < max_calls ) ) + { + get_iaxc_lock(); + iaxc_dump_one_call(callNo); + put_iaxc_lock(); + } +} + EXPORT void iaxc_dump_call(void) { if ( selected_call >= 0 ) @@ -1493,7 +1503,7 @@ EXPORT void iaxc_reject_call_number( int callNo ) { - if ( callNo >= 0 ) + if ( ( callNo >= 0 ) && ( callNo < max_calls ) ) { get_iaxc_lock(); iax_reject(calls[callNo].session, "Call rejected manually."); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sb...@us...> - 2007-10-30 17:36:28
|
Revision: 1238 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1238&view=rev Author: sbalea Date: 2007-10-30 10:36:30 -0700 (Tue, 30 Oct 2007) Log Message: ----------- Incoming DTMF patch provided by Bertrand. Thanks. Modified Paths: -------------- trunk/lib/iaxclient.h trunk/lib/iaxclient_lib.c Modified: trunk/lib/iaxclient.h =================================================================== --- trunk/lib/iaxclient.h 2007-10-30 03:10:21 UTC (rev 1237) +++ trunk/lib/iaxclient.h 2007-10-30 17:36:30 UTC (rev 1238) @@ -533,6 +533,21 @@ }; /*! + A structure containing information about a DTMF event + */ +struct iaxc_ev_dtmf { + /*! + The call this DTMF event is for. + */ + int callNo; + + /*! + The digit represented by this DTMF tone + */ + char digit; +}; + +/*! A structure describing a single IAXClient event. */ typedef struct iaxc_event_struct { @@ -568,8 +583,10 @@ struct iaxc_ev_video video; /*! Contains audio data if type = IAXC_EVENT_AUDIO */ struct iaxc_ev_audio audio; - /*! Contains registration data if type = AXC_EVENT_REGISTRATION */ - struct iaxc_ev_registration reg; + /*! Contains registration data if type = IAXC_EVENT_REGISTRATION */ + struct iaxc_ev_registration reg; + /*! Contains DTMF data if type = IAXC_EVENT_DTMF */ + struct iaxc_ev_dtmf dtmf; } ev; } iaxc_event; Modified: trunk/lib/iaxclient_lib.c =================================================================== --- trunk/lib/iaxclient_lib.c 2007-10-30 03:10:21 UTC (rev 1237) +++ trunk/lib/iaxclient_lib.c 2007-10-30 17:36:30 UTC (rev 1238) @@ -369,6 +369,15 @@ iaxci_post_event(e); } +void iaxci_do_dtmf_callback(int callNo, char digit) +{ + iaxc_event e; + e.type = IAXC_EVENT_DTMF; + e.ev.dtmf.callNo = callNo; + e.ev.dtmf.digit = digit; + iaxci_post_event(e); +} + static int iaxc_remove_registration_by_id(int id) { struct iaxc_registration *curr, *prev; @@ -1187,6 +1196,10 @@ iaxci_do_state_callback(callNo); iaxci_usermsg(IAXC_STATUS,"Call %d transfer released", callNo); break; + case IAX_EVENT_DTMF: + iaxci_do_dtmf_callback(callNo,e->subclass); + iaxci_usermsg(IAXC_STATUS, "DTMF digit %c received", e->subclass); + break; default: iaxci_usermsg(IAXC_STATUS, "Unknown event: %d for call %d", e->etype, callNo); break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bc...@us...> - 2007-11-01 15:23:41
|
Revision: 1254 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1254&view=rev Author: bcholew Date: 2007-11-01 08:23:44 -0700 (Thu, 01 Nov 2007) Log Message: ----------- Document ownership of memory returned by iaxc_video_devices_get(). Properly cleanup vidcap device lists on shutdown. Modified Paths: -------------- trunk/lib/iaxclient.h trunk/lib/video.c Modified: trunk/lib/iaxclient.h =================================================================== --- trunk/lib/iaxclient.h 2007-11-01 14:22:18 UTC (rev 1253) +++ trunk/lib/iaxclient.h 2007-11-01 15:23:44 UTC (rev 1254) @@ -1134,9 +1134,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: trunk/lib/video.c =================================================================== --- trunk/lib/video.c 2007-11-01 14:22:18 UTC (rev 1253) +++ trunk/lib/video.c 2007-11-01 15:23:44 UTC (rev 1254) @@ -1639,9 +1639,19 @@ 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); + 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: <sb...@us...> - 2007-11-05 15:09:34
|
Revision: 1265 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1265&view=rev Author: sbalea Date: 2007-11-05 07:09:32 -0800 (Mon, 05 Nov 2007) Log Message: ----------- Merge change from the elbunce branch: add ability to send text messages to an active call Modified Paths: -------------- trunk/lib/iaxclient.h trunk/lib/iaxclient_lib.c Modified: trunk/lib/iaxclient.h =================================================================== --- trunk/lib/iaxclient.h 2007-11-04 19:17:58 UTC (rev 1264) +++ trunk/lib/iaxclient.h 2007-11-05 15:09:32 UTC (rev 1265) @@ -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 Modified: trunk/lib/iaxclient_lib.c =================================================================== --- trunk/lib/iaxclient_lib.c 2007-11-04 19:17:58 UTC (rev 1264) +++ trunk/lib/iaxclient_lib.c 2007-11-05 15:09:32 UTC (rev 1265) @@ -1510,6 +1510,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: <jpg...@us...> - 2007-11-25 12:32:24
|
Revision: 1283 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1283&view=rev Author: jpgrayson Date: 2007-11-25 04:32:28 -0800 (Sun, 25 Nov 2007) Log Message: ----------- Build fixes for VC6 courtesy of Teri Schoech. Thank you again. Modified Paths: -------------- trunk/lib/iaxclient_lib.h trunk/lib/portmixer/px_win_wmme/px_win_wmme.c trunk/lib/ringbuffer.c Modified: trunk/lib/iaxclient_lib.h =================================================================== --- trunk/lib/iaxclient_lib.h 2007-11-25 12:31:48 UTC (rev 1282) +++ trunk/lib/iaxclient_lib.h 2007-11-25 12:32:28 UTC (rev 1283) @@ -71,6 +71,9 @@ #define THREADJOIN(t) /* causes deadlock with wx GUI on MSW */ /* #define THREADJOIN(t) WaitForSingleObject(t, INFINITE) */ +#ifndef _WIN32_WINNT +extern WINBASEAPI BOOL WINAPI TryEnterCriticalSection( LPCRITICAL_SECTION lpCriticalSection ); +#endif #define MUTEX CRITICAL_SECTION #define MUTEXINIT(m) InitializeCriticalSection(m) #define MUTEXLOCK(m) EnterCriticalSection(m) Modified: trunk/lib/portmixer/px_win_wmme/px_win_wmme.c =================================================================== --- trunk/lib/portmixer/px_win_wmme/px_win_wmme.c 2007-11-25 12:31:48 UTC (rev 1282) +++ trunk/lib/portmixer/px_win_wmme/px_win_wmme.c 2007-11-25 12:32:28 UTC (rev 1283) @@ -626,7 +626,14 @@ int Px_SetMicrophoneBoost( PxMixer* mixer, int enable ) { + MIXERLINE mixerLine ; + LPMIXERCONTROL mixerControl ; + MIXERLINECONTROLS mixerLineControls ; + MIXERCONTROLDETAILS mixerControlDetails ; + MIXERCONTROLDETAILS_BOOLEAN value ; MMRESULT mmr = MMSYSERR_ERROR ; + DWORD boost_id = -1 ; + DWORD x ; // cast void pointer PxInfo* info = ( PxInfo* )( mixer ) ; @@ -638,7 +645,6 @@ // get line info // - MIXERLINE mixerLine ; mixerLine.cbStruct = sizeof( MIXERLINE ) ; mixerLine.dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE ; @@ -655,9 +661,8 @@ // get all controls // - LPMIXERCONTROL mixerControl = (MIXERCONTROL *)malloc( sizeof( MIXERCONTROL ) * mixerLine.cControls ) ; + mixerControl = (MIXERCONTROL *)malloc( sizeof( MIXERCONTROL ) * mixerLine.cControls ) ; - MIXERLINECONTROLS mixerLineControls ; mixerLineControls.cbStruct = sizeof( MIXERLINECONTROLS ) ; mixerLineControls.dwLineID = mixerLine.dwLineID ; mixerLineControls.cControls = mixerLine.cControls ; @@ -681,10 +686,7 @@ // find boost control // - DWORD boost_id = -1 ; - DWORD x = 0 ; - - for ( ; x < mixerLineControls.cControls ; ++x ) + for ( x = 0 ; x < mixerLineControls.cControls ; ++x ) { // check control type if ( mixerControl[x].dwControlType & MIXERCONTROL_CONTROLTYPE_BOOLEAN ) @@ -715,9 +717,6 @@ // get control details // - MIXERCONTROLDETAILS_BOOLEAN value ; - - MIXERCONTROLDETAILS mixerControlDetails ; mixerControlDetails.cbStruct = sizeof( MIXERCONTROLDETAILS ) ; mixerControlDetails.dwControlID = boost_id ; mixerControlDetails.cChannels = 1 ; @@ -764,7 +763,14 @@ int Px_GetMicrophoneBoost( PxMixer* mixer ) { + MIXERLINE mixerLine ; + LPMIXERCONTROL mixerControl ; + MIXERLINECONTROLS mixerLineControls ; + MIXERCONTROLDETAILS mixerControlDetails ; + MIXERCONTROLDETAILS_BOOLEAN value ; MMRESULT mmr = MMSYSERR_ERROR ; + DWORD boost_id = -1 ; + DWORD x ; // cast void pointer PxInfo* info = ( PxInfo* )( mixer ) ; @@ -776,7 +782,6 @@ // get line info // - MIXERLINE mixerLine ; mixerLine.cbStruct = sizeof( MIXERLINE ) ; mixerLine.dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE ; @@ -793,9 +798,8 @@ // get all controls // - LPMIXERCONTROL mixerControl = (MIXERCONTROL *)malloc( sizeof( MIXERCONTROL ) * mixerLine.cControls ) ; + mixerControl = (MIXERCONTROL *)malloc( sizeof( MIXERCONTROL ) * mixerLine.cControls ) ; - MIXERLINECONTROLS mixerLineControls ; mixerLineControls.cbStruct = sizeof( MIXERLINECONTROLS ) ; mixerLineControls.dwLineID = mixerLine.dwLineID ; mixerLineControls.cControls = mixerLine.cControls ; @@ -819,10 +823,7 @@ // find boost control // - DWORD boost_id = -1 ; - DWORD x = 0 ; - - for ( ; x < mixerLineControls.cControls ; ++x ) + for ( x = 0 ; x < mixerLineControls.cControls ; ++x ) { // check control type if ( mixerControl[x].dwControlType & MIXERCONTROL_CONTROLTYPE_BOOLEAN ) @@ -853,9 +854,6 @@ // get control details // - MIXERCONTROLDETAILS_BOOLEAN value ; - - MIXERCONTROLDETAILS mixerControlDetails ; mixerControlDetails.cbStruct = sizeof( MIXERCONTROLDETAILS ) ; mixerControlDetails.dwControlID = boost_id ; mixerControlDetails.cChannels = 1 ; @@ -879,6 +877,8 @@ int Px_SetCurrentInputSourceByName( PxMixer* mixer, const char* name ) { + int x ; + // cast void pointer PxInfo* info = ( PxInfo* )( mixer ) ; @@ -894,8 +894,7 @@ // set input source // - int x = 0 ; - for ( ; x < info->numInputs ; ++x ) + for ( x = 0 ; x < info->numInputs ; ++x ) { // compare passed name with control name if ( strncasecmp( info->src[x].name, name, strlen( name ) ) == 0 ) Modified: trunk/lib/ringbuffer.c =================================================================== --- trunk/lib/ringbuffer.c 2007-11-25 12:31:48 UTC (rev 1282) +++ trunk/lib/ringbuffer.c 2007-11-25 12:32:28 UTC (rev 1283) @@ -125,22 +125,29 @@ # endif # endif #elif defined(_MSC_VER) -# include <intrin.h> -# pragma intrinsic(_ReadWriteBarrier) -# pragma intrinsic(_ReadBarrier) -# pragma intrinsic(_WriteBarrier) -# define rb_FullMemoryBarrier() _ReadWriteBarrier() -# define rb_ReadMemoryBarrier() _ReadBarrier() -# define rb_WriteMemoryBarrier() _WriteBarrier() -#else -# ifdef ALLOW_SMP_DANGERS -# ifdef _MSC_VER +# if ( _MSC_VER > 1200 ) +# include <intrin.h> +# pragma intrinsic(_ReadWriteBarrier) +# pragma intrinsic(_ReadBarrier) +# pragma intrinsic(_WriteBarrier) +# define rb_FullMemoryBarrier() _ReadWriteBarrier() +# define rb_ReadMemoryBarrier() _ReadBarrier() +# define rb_WriteMemoryBarrier() _WriteBarrier() +# else +# ifdef ALLOW_SMP_DANGERS # pragma message("Memory barriers not defined on this system or system unknown") # pragma message("For SMP safety, you should fix this.") +# define rb_FullMemoryBarrier() +# define rb_ReadMemoryBarrier() +# define rb_WriteMemoryBarrier() # else -# warning Memory barriers not defined on this system or system unknown -# warning For SMP safety, you should fix this. +# error Memory barriers are not defined on this system. You can still compile by defining ALLOW_SMP_DANGERS, but SMP safety will not be guaranteed. # endif +# endif +#else +# ifdef ALLOW_SMP_DANGERS +# warning Memory barriers not defined on this system or system unknown +# warning For SMP safety, you should fix this. # define rb_FullMemoryBarrier() # define rb_ReadMemoryBarrier() # define rb_WriteMemoryBarrier() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bc...@us...> - 2007-12-12 22:13:54
|
Revision: 1306 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1306&view=rev Author: bcholew Date: 2007-12-12 14:13:49 -0800 (Wed, 12 Dec 2007) Log Message: ----------- Use iaxc_lock to protect struct iaxc_call calls[] array from concurrent access by libvidcap's callback thread and main processing thread. Make put_iaxc_lock() not static - to allow video.c to call it. Add try_iaxc_lock(). Modified Paths: -------------- trunk/lib/iaxclient_lib.c trunk/lib/video.c Modified: trunk/lib/iaxclient_lib.c =================================================================== --- trunk/lib/iaxclient_lib.c 2007-12-07 15:41:28 UTC (rev 1305) +++ trunk/lib/iaxclient_lib.c 2007-12-12 22:13:49 UTC (rev 1306) @@ -138,8 +138,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: trunk/lib/video.c =================================================================== --- trunk/lib/video.c 2007-12-07 15:41:28 UTC (rev 1305) +++ trunk/lib/video.c 2007-12-12 22:13:49 UTC (rev 1306) @@ -123,6 +123,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; @@ -643,22 +647,37 @@ 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 ) { fprintf(stderr, "video format not set for call %d\n", selected_call); - return -1; + goto callback_failed; } if ( !need_encode ) @@ -675,7 +694,7 @@ call->vencoder = 0; } - return 0; + goto callback_done; } else { @@ -694,7 +713,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", @@ -706,7 +726,7 @@ &slice_set) ) { fprintf(stderr, "failed to encode captured video\n"); - return -1; + goto callback_failed; } } @@ -725,7 +745,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 ) @@ -753,7 +773,7 @@ fprintf(stderr, "failed sending slice call %d " "size %d\n", selected_call, slice_set.size[i]); - return -1; + goto callback_failed; } /* More statistics */ @@ -769,7 +789,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. |
From: <sb...@us...> - 2008-02-06 00:00:47
|
Revision: 1342 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1342&view=rev Author: sbalea Date: 2008-02-05 16:00:52 -0800 (Tue, 05 Feb 2008) Log Message: ----------- Fix return values in a couple of functions (eliminate some compile warnings) Modified Paths: -------------- trunk/lib/iaxclient.h trunk/lib/iaxclient_lib.c Modified: trunk/lib/iaxclient.h =================================================================== --- trunk/lib/iaxclient.h 2008-02-05 23:56:33 UTC (rev 1341) +++ trunk/lib/iaxclient.h 2008-02-06 00:00:52 UTC (rev 1342) @@ -1372,7 +1372,7 @@ Sets the IAX debug set to \a enable. \param enable If non-zero enable iax protocol debugging */ -EXPORT int iaxc_debug_iax_set(int enable); +EXPORT void iaxc_debug_iax_set(int enable); #ifdef __cplusplus } Modified: trunk/lib/iaxclient_lib.c =================================================================== --- trunk/lib/iaxclient_lib.c 2008-02-05 23:56:33 UTC (rev 1341) +++ trunk/lib/iaxclient_lib.c 2008-02-06 00:00:52 UTC (rev 1342) @@ -1241,7 +1241,7 @@ EXPORT int iaxc_register(const char * user, const char * pass, const char * host) { - iaxc_register_ex(user, pass, host, 60); + return iaxc_register_ex(user, pass, host, 60); } EXPORT int iaxc_register_ex(const char * user, const char * pass, const char * host, int refresh) @@ -1967,13 +1967,13 @@ return 0; } -int iaxc_debug_iax_set(int enable) +void iaxc_debug_iax_set(int enable) { #ifdef DEBUG_SUPPORT if (enable) iax_enable_debug(); else iax_disable_debug(); -#endif +#endif } 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:23:51
|
Revision: 1410 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1410&view=rev Author: jpgrayson Date: 2008-04-15 15:23:20 -0700 (Tue, 15 Apr 2008) Log Message: ----------- Add IAXC_FILTER_DEREVERB flag to enable/disable speexdsp's dereverb preprocessor feature. Note that currently speexdsp's dereverb feature doesn't do much. Modified Paths: -------------- trunk/lib/audio_encode.c trunk/lib/iaxclient.h Modified: trunk/lib/audio_encode.c =================================================================== --- trunk/lib/audio_encode.c 2008-04-15 22:21:25 UTC (rev 1409) +++ trunk/lib/audio_encode.c 2008-04-15 22:23:20 UTC (rev 1410) @@ -104,12 +104,14 @@ speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_AGC, &i); i = (iaxci_filters & IAXC_FILTER_DENOISE) ? 1 : 0; speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DENOISE, &i); + i = (iaxci_filters & IAXC_FILTER_DEREVERB) ? 1 : 0; + speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DEREVERB, &i); /* - * We can tweak these parameters to play with VAD sensitivity. - * For now, we use the default values since it seems they are a good starting point. - * However, if need be, this is the code that needs to change - */ + * We can tweak these parameters to play with VAD sensitivity. + * For now, we use the default values since it seems they are a good starting point. + * However, if need be, this is the code that needs to change + */ i = 35; speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_PROB_START, &i); i = 20; @@ -149,8 +151,8 @@ calculate_level((short *)audio, len, &input_level); - /* only preprocess if we're interested in VAD, AGC, or DENOISE */ - if ( (iaxci_filters & (IAXC_FILTER_DENOISE | IAXC_FILTER_AGC)) || + /* go through the motions only if we need at least one of the preprocessor filters */ + if ( (iaxci_filters & (IAXC_FILTER_DENOISE | IAXC_FILTER_AGC | IAXC_FILTER_DEREVERB)) || iaxci_silence_threshold > 0.0f ) silent = !speex_preprocess(st, (spx_int16_t *)audio, NULL); @@ -350,7 +352,8 @@ if ( format == 0 ) { - fprintf(stderr, "audio_decode_audio: Format is zero (should't happen)!\n"); + fprintf(stderr, "audio_decode_audio: Format is zero " + "(should not happen)!\n"); return -1; } Modified: trunk/lib/iaxclient.h =================================================================== --- trunk/lib/iaxclient.h 2008-04-15 22:21:25 UTC (rev 1409) +++ trunk/lib/iaxclient.h 2008-04-15 22:23:20 UTC (rev 1410) @@ -1063,6 +1063,7 @@ #define IAXC_FILTER_ECHO (1<<2) /*!< Echo cancellation filter */ #define IAXC_FILTER_AAGC (1<<3) /*!< Analog (mixer-based) Automatic Gain Control */ #define IAXC_FILTER_CN (1<<4) /*!< Send Comfort Noise (CN) frames when silence is detected */ +#define IAXC_FILTER_DEREVERB (1<<5) /*!< Reverb reduction filter */ /*! Returns the set of audio filters being applied. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpg...@us...> - 2008-04-16 21:29:11
|
Revision: 1414 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1414&view=rev Author: jpgrayson Date: 2008-04-16 14:29:18 -0700 (Wed, 16 Apr 2008) Log Message: ----------- Patch from Steven Henke adding radio tranceiver functionality to iaxclient. Modified Paths: -------------- trunk/lib/iaxclient.h trunk/lib/iaxclient_lib.c trunk/lib/libiax2/src/frame.h trunk/lib/libiax2/src/iax-client.h trunk/lib/libiax2/src/iax.c Modified: trunk/lib/iaxclient.h =================================================================== --- trunk/lib/iaxclient.h 2008-04-16 14:29:08 UTC (rev 1413) +++ trunk/lib/iaxclient.h 2008-04-16 21:29:18 UTC (rev 1414) @@ -143,6 +143,7 @@ #define IAXC_CALL_STATE_SELECTED (1<<5) /*!< Indicates the call is selected */ #define IAXC_CALL_STATE_BUSY (1<<6) /*!< Indicates a call is busy */ #define IAXC_CALL_STATE_TRANSFER (1<<7) /*!< Indicates the call transfer has been released */ +#define IAXC_CALL_STATE_KEYED (1<<8) /*!< Indicates the call radio is activated */ /*! Indicates that text is for an IAXClient status change */ #define IAXC_TEXT_TYPE_STATUS 1 @@ -773,6 +774,18 @@ EXPORT void iaxc_answer_call(int callNo); /*! + Radio Transmitter and Receiver Control Activiate + \param callNo The number of the call to activate +*/ +EXPORT void iaxc_key_radio(int callNo); + +/*! + Radio Transmitter and Receiver Control Deactivate + \param callNo The number of the call to deactivate +*/ +EXPORT void iaxc_unkey_radio(int callNo); + +/*! Initiate a blind call transfer of \a callNo to \a number. \param callNo The active call to transfer. \param number The number to transfer the call to. See draft-guy-iax-03 section 8.4.1 for further details. Modified: trunk/lib/iaxclient_lib.c =================================================================== --- trunk/lib/iaxclient_lib.c 2008-04-16 14:29:08 UTC (rev 1413) +++ trunk/lib/iaxclient_lib.c 2008-04-16 21:29:18 UTC (rev 1414) @@ -1153,6 +1153,16 @@ // XXX does the session go away now? iaxc_clear_call(callNo); break; + case IAX_EVENT_KEY: + calls[callNo].state |= IAXC_CALL_STATE_KEYED; + iaxci_do_state_callback(callNo); + iaxci_usermsg(IAXC_STATUS,"Call %d Radio Key", callNo); + break; + case IAX_EVENT_UNKEY: + calls[callNo].state &= ~IAXC_CALL_STATE_KEYED; + iaxci_do_state_callback(callNo); + iaxci_usermsg(IAXC_STATUS,"Call %d Radio Unkey", callNo); + break; case IAX_EVENT_REJECT: iaxci_usermsg(IAXC_STATUS, "Call rejected by remote"); iaxc_clear_call(callNo); @@ -1425,6 +1435,22 @@ iaxci_do_state_callback(callNo); } +EXPORT void iaxc_key_radio(int callNo) +{ + if ( callNo < 0 ) + return; + + iax_key_radio(calls[callNo].session); +} + +EXPORT void iaxc_unkey_radio(int callNo) +{ + if ( callNo < 0 ) + return; + + iax_unkey_radio(calls[callNo].session); +} + EXPORT void iaxc_blind_transfer_call(int callNo, const char * dest_extension) { if ( callNo < 0 || !(calls[callNo].state & IAXC_CALL_STATE_ACTIVE) ) Modified: trunk/lib/libiax2/src/frame.h =================================================================== --- trunk/lib/libiax2/src/frame.h 2008-04-16 14:29:08 UTC (rev 1413) +++ trunk/lib/libiax2/src/frame.h 2008-04-16 21:29:18 UTC (rev 1414) @@ -99,6 +99,8 @@ #define AST_CONTROL_FLASH 9 /* Flash hook */ #define AST_CONTROL_WINK 10 /* Wink */ #define AST_CONTROL_OPTION 11 /* Set an option */ +#define AST_CONTROL_KEY 12 /* Key Radio */ +#define AST_CONTROL_UNKEY 13 /* Unkey Radio */ #define AST_FRIENDLY_OFFSET 64 /* Reserved header space */ Modified: trunk/lib/libiax2/src/iax-client.h =================================================================== --- trunk/lib/libiax2/src/iax-client.h 2008-04-16 14:29:08 UTC (rev 1413) +++ trunk/lib/libiax2/src/iax-client.h 2008-04-16 21:29:18 UTC (rev 1414) @@ -80,8 +80,9 @@ #define IAX_EVENT_CNG 32 /* Comfort-noise (almost silence) */ #define IAX_EVENT_POKE 33 #define IAX_EVENT_VIDEO 34 /* Send/receive video */ +#define IAX_EVENT_KEY 35 /* Radio Control Key */ +#define IAX_EVENT_UNKEY 36 /* Radio Control UnKey */ - /* moved from iax.c to support attended transfer */ #define IAX_EVENT_REREQUEST 999 #define IAX_EVENT_TXREPLY 1000 @@ -195,6 +196,9 @@ extern int iax_send_video(struct iax_session *session, int format, unsigned char *data, int datalen, int fullframe); extern int iax_send_video_trunk(struct iax_session *session, int format, char *data, int datalen, int fullframe, int ntrunk); +extern int iax_key_radio(struct iax_session *session); +extern int iax_unkey_radio(struct iax_session *session); + extern void iax_destroy(struct iax_session * session); extern void iax_enable_debug(void); Modified: trunk/lib/libiax2/src/iax.c =================================================================== --- trunk/lib/libiax2/src/iax.c 2008-04-16 14:29:08 UTC (rev 1413) +++ trunk/lib/libiax2/src/iax.c 2008-04-16 21:29:18 UTC (rev 1414) @@ -1878,6 +1878,16 @@ return send_command(session, AST_FRAME_CONTROL, AST_CONTROL_ANSWER, 0, NULL, 0, -1); } +int iax_key_radio(struct iax_session *session) +{ + return send_command(session, AST_FRAME_CONTROL, AST_CONTROL_KEY, 0, NULL, 0, -1); +} + +int iax_unkey_radio(struct iax_session *session) +{ + return send_command(session, AST_FRAME_CONTROL, AST_CONTROL_UNKEY, 0, NULL, 0, -1); +} + int iax_load_complete(struct iax_session *session) { return send_command(session, AST_FRAME_HTML, AST_HTML_LDCOMPLETE, 0, NULL, 0, -1); @@ -2958,6 +2968,14 @@ e->etype = IAX_EVENT_RINGA; e = schedule_delivery(e, ts, updatehistory); break; + case AST_CONTROL_KEY: + e->etype = IAX_EVENT_KEY; + e = schedule_delivery(e, ts, updatehistory); + break; + case AST_CONTROL_UNKEY: + e->etype = IAX_EVENT_UNKEY; + e = schedule_delivery(e, ts, updatehistory); + break; default: DEBU(G "Don't know what to do with AST control %d\n", subclass); free(e); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpg...@us...> - 2008-04-24 18:48:57
|
Revision: 1426 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1426&view=rev Author: jpgrayson Date: 2008-04-24 11:49:01 -0700 (Thu, 24 Apr 2008) Log Message: ----------- Merge new acoustic echo cancellation (AEC) code into trunk. This code has been simmering in branches/team/mihai/echocan for some time. This new code takes advantage of the speex echo cancellation improvements introduced in speex-1.2beta2. Echo cancellation is disabled by default on Windows. Echo cancellation is not yet working well with WMME. Modified Paths: -------------- trunk/lib/audio_encode.c trunk/lib/audio_encode.h trunk/lib/audio_portaudio.c Modified: trunk/lib/audio_encode.c =================================================================== --- trunk/lib/audio_encode.c 2008-04-24 17:52:51 UTC (rev 1425) +++ trunk/lib/audio_encode.c 2008-04-24 18:49:01 UTC (rev 1426) @@ -25,6 +25,18 @@ #include "codec_speex.h" #include <speex/speex_preprocess.h> +/* Determine if we should do AEC */ +#if defined(SPEEX_EC) && !defined(WIN32) +#define DO_EC +#else +#undef DO_EC +#endif + +#ifdef DO_EC +#include <speex/speex_echo.h> +#include "ringbuffer.h" +#endif + #ifdef CODEC_ILBC #include "codec_ilbc.h" #endif @@ -41,6 +53,35 @@ static int speex_state_rate = 0; int iaxci_filters = IAXC_FILTER_AGC|IAXC_FILTER_DENOISE|IAXC_FILTER_AAGC|IAXC_FILTER_CN; +static MUTEX audio_lock; + +/* echo_tail length, in samples */ +#define ECHO_TAIL 512 + +/* Maximum attenuation of residual echo in dB (negative number) */ +#define ECHO_SUPPRESS -60 +/* Maximum attenuation of residual echo when near end is active, in dB (negative number) */ +#define ECHO_SUPPRESS_ACTIVE -60 + +/* Size of ring buffer used for echo cancellation. Must be power of 2. */ +#define EC_RING_SIZE 512 + +#ifdef DO_EC +static SpeexEchoState *ec = 0; +static rb_RingBuffer ecOutRing; +static char outRingBuf[EC_RING_SIZE]; +#endif + +/* AAGC threshold */ +#define AAGC_VERY_HOT 16 +#define AAGC_HOT 8 +#define AAGC_COLD 4 + +/* AAGC increments */ +#define AAGC_RISE_SLOW 0.10f +#define AAGC_DROP_SLOW 0.15f +#define AAGC_DROP_FAST 0.20f + /* use to measure time since last audio was processed */ static struct timeval timeLastInput ; static struct timeval timeLastOutput ; @@ -141,20 +182,34 @@ float volume; int silent = 0; + MUTEXLOCK(&audio_lock); if ( !st || speex_state_size != len || speex_state_rate != rate ) { if (st) speex_preprocess_state_destroy(st); st = speex_preprocess_state_init(len,rate); +#ifdef DO_EC + if ( ec ) + { + int i; + + speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_ECHO_STATE, ec); + i = ECHO_SUPPRESS; + speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_ECHO_SUPPRESS, &i); + i = ECHO_SUPPRESS_ACTIVE; + speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_ECHO_SUPPRESS_ACTIVE, &i); + } +#endif speex_state_size = len; speex_state_rate = rate; set_speex_filters(); } + MUTEXUNLOCK(&audio_lock); calculate_level(audio, len, &input_level); /* go through the motions only if we need at least one of the preprocessor filters */ - if ( (iaxci_filters & (IAXC_FILTER_DENOISE | IAXC_FILTER_AGC | IAXC_FILTER_DEREVERB)) || + if ( (iaxci_filters & (IAXC_FILTER_DENOISE | IAXC_FILTER_AGC | IAXC_FILTER_DEREVERB | IAXC_FILTER_ECHO)) || iaxci_silence_threshold > 0.0f ) silent = !speex_preprocess(st, (spx_int16_t *)audio, NULL); @@ -410,12 +465,87 @@ set_speex_filters(); } +int audio_echo_cancellation(short *inputBuffer, short *outputBuffer, int samples) +{ +#ifdef DO_EC + int i; + short delayedBuf[1024]; + short cancelledBuffer[1024]; + + /* if ec is off, clear ec state -- this way, we start fresh if/when + * it's turned back on. */ + MUTEXLOCK(&audio_lock); + if ( !(iaxci_filters & IAXC_FILTER_ECHO) ) + { + if ( ec ) + { + speex_echo_state_destroy(ec); + ec = NULL; + if ( st ) + { + speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_ECHO_STATE, NULL); + } + } + + MUTEXUNLOCK(&audio_lock); + return 0; + } + + /* we want echo cancellation */ + if ( !ec ) + { + rb_InitializeRingBuffer(&ecOutRing, EC_RING_SIZE, &outRingBuf); + ec = speex_echo_state_init(SAMPLES_PER_FRAME, ECHO_TAIL); + + if ( st ) + { + speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_ECHO_STATE, ec); + i = ECHO_SUPPRESS; + speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_ECHO_SUPPRESS, &i); + i = ECHO_SUPPRESS_ACTIVE; + speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_ECHO_SUPPRESS_ACTIVE, &i); + } + } + MUTEXUNLOCK(&audio_lock); + + // Put our data in the EC ring buffer. + // Echo canceller needs SAMPLES_PER_FRAME samples, so if we don't have enough + // at this time, we just store what we have and return. + rb_WriteRingBuffer(&ecOutRing, outputBuffer, samples * 2); + if ( rb_GetRingBufferReadAvailable(&ecOutRing) < (SAMPLES_PER_FRAME * 2) ) + return -1; + + rb_ReadRingBuffer(&ecOutRing, delayedBuf, SAMPLES_PER_FRAME * 2); + + speex_echo_cancellation(ec, inputBuffer, delayedBuf, cancelledBuffer); + + memcpy(inputBuffer, cancelledBuffer, samples * sizeof(short)); +#endif + return 0; +} + int audio_initialize() { + MUTEXINIT(&audio_lock); return 0; } int audio_destroy() { + MUTEXLOCK(&audio_lock); + if ( st ) + { + speex_preprocess_state_destroy(st); + st = NULL; + } +#ifdef DO_EC + if ( ec ) + { + speex_echo_state_destroy(ec); + ec = NULL; + } +#endif + MUTEXUNLOCK(&audio_lock); + MUTEXDESTROY(&audio_lock); return 0; } Modified: trunk/lib/audio_encode.h =================================================================== --- trunk/lib/audio_encode.h 2008-04-24 17:52:51 UTC (rev 1425) +++ trunk/lib/audio_encode.h 2008-04-24 18:49:01 UTC (rev 1426) @@ -15,6 +15,14 @@ #ifndef _AUDIO_ENCODE_H #define _AUDIO_ENCODE_H +/* Some audio parameters */ +#define MAX_SAMPLE_RATE 48000 +#ifndef MS_PER_FRAME +# define MS_PER_FRAME 20 +#endif +#define SAMPLES_PER_FRAME (MS_PER_FRAME * iaxci_sample_rate / 1000) +#define MAX_SAMPLES_PER_FRAME (MS_PER_FRAME * MAX_SAMPLE_RATE / 1000) + extern int iaxci_sample_rate; /* Minimum dB possible in the iaxclient world. This level @@ -22,16 +30,6 @@ */ #define AUDIO_ENCODE_SILENCE_DB -99.0f -/* AAGC threshold */ -#define AAGC_VERY_HOT 16 -#define AAGC_HOT 8 -#define AAGC_COLD 4 - -/* AAGC increments */ -#define AAGC_RISE_SLOW 0.10f -#define AAGC_DROP_SLOW 0.15f -#define AAGC_DROP_FAST 0.20f - struct iaxc_call; struct iax_event; @@ -44,5 +42,7 @@ int audio_decode_audio(struct iaxc_call * p, void * out, void * data, int len, int iEncodeType, int * samples); +int audio_echo_cancellation(short *inputBuffer, short *outputBuffer, int samples); + #endif Modified: trunk/lib/audio_portaudio.c =================================================================== --- trunk/lib/audio_portaudio.c 2008-04-24 17:52:51 UTC (rev 1425) +++ trunk/lib/audio_portaudio.c 2008-04-24 18:49:01 UTC (rev 1426) @@ -38,27 +38,6 @@ #include "ringbuffer.h" #include "portmixer.h" -#ifdef USE_MEC2 -#define DO_EC -#include "mec3.h" -static echo_can_state_t *ec; -#endif - -#ifdef SPAN_EC -#define DO_EC -#include "ec/echo.h" -static echo_can_state_t *ec; -#endif - -#if defined(SPEEX_EC) && ! defined (WIN32) -#define DO_EC -#define restrict __restrict -#include "speex/speex_echo.h" -static SpeexEchoState *ec; -#endif - -#define EC_RING_SZ 8192 /* must be pow(2) */ - typedef short SAMPLE; static PaStream *iStream, *oStream, *aStream; @@ -68,18 +47,6 @@ static int mixers_initialized; -#define MAX_SAMPLE_RATE 48000 -#ifndef MS_PER_FRAME -# define MS_PER_FRAME 20 -#endif -#define SAMPLES_PER_FRAME (MS_PER_FRAME * iaxci_sample_rate / 1000) - -/* static frame buffer allocation */ -#define MAX_SAMPLES_PER_FRAME (MS_PER_FRAME * MAX_SAMPLE_RATE / 1000) - -/* echo_tail length, in frames must be pow(2) for mec/span ? */ -#define ECHO_TAIL 4096 - /* RingBuffer Size; Needs to be Pow(2), 1024 = 512 samples = 64ms */ #ifndef OUTRBSZ # define OUTRBSZ 32768 @@ -372,84 +339,6 @@ return retval; /* found? */ } -static void iaxc_echo_can(short *inputBuffer, short *outputBuffer, int n) -{ - static rb_RingBuffer ecOutRing; - static char outRingBuf[EC_RING_SZ]; - static long bias = 0; - short delayedBuf[1024]; - int i; - - /* remove bias -- whether ec is on or not. */ - for ( i = 0; i < n; i++ ) - { - bias += ((((long int) inputBuffer[i]) << 15) - bias) >> 14; - inputBuffer[i] -= (short int) (bias >> 15); - } - - /* if ec is off, clear ec state -- this way, we start fresh if/when - * it's turned back on. */ - if ( !(iaxc_get_filters() & IAXC_FILTER_ECHO) ) - { -#if defined(DO_EC) - if ( ec ) - { -#if defined(USE_MEC2) || defined(SPAN_EC) - echo_can_free(ec); - ec = NULL; -#elif defined(SPEEX_EC) - speex_echo_state_destroy(ec); - ec = NULL; -#endif - } -#endif - - return; - } - - /* we want echo cancellation */ - -#if defined(DO_EC) - if ( !ec ) - { - rb_InitializeRingBuffer(&ecOutRing, EC_RING_SZ, &outRingBuf); -#if defined(USE_MEC2) || defined(SPAN_EC) - ec = echo_can_create(ECHO_TAIL, 0); -#elif defined(SPEEX_EC) - ec = speex_echo_state_init(SAMPLES_PER_FRAME, ECHO_TAIL); -#endif - } -#endif - - /* fill ecOutRing */ - rb_WriteRingBuffer(&ecOutRing, outputBuffer, n * 2); - - // Make sure we have enough buffer. - // Currently, just one SAMPLES_PER_FRAME's worth. - if ( rb_GetRingBufferReadAvailable(&ecOutRing) < ((n + SAMPLES_PER_FRAME) * 2) ) - return; - - rb_ReadRingBuffer(&ecOutRing, delayedBuf, n * 2); - -#if defined(DO_EC) && defined(SPEEX_EC) - { - short cancelledBuffer[1024]; - - speex_echo_cancel(ec, inputBuffer, delayedBuf, - cancelledBuffer, NULL); - - for ( i = 0; i < n; i++ ) - inputBuffer[i] = cancelledBuffer[i]; - } -#endif - -#if defined(USE_MEC2) || defined(SPAN_EC) - for ( i = 0; i < n; i++ ) - inputBuffer[i] = echo_can_update(ec, delayedBuf[i], - inputBuffer[i]); -#endif -} - static int pa_callback(const void *inputBuffer, void *outputBuffer, unsigned long samplesPerFrame, const PaStreamCallbackTimeInfo* outTime, @@ -524,23 +413,26 @@ if ( inputBuffer ) { + int res; + /* input overflow might happen here */ if ( virtualMonoIn ) { stereo2mono(virtualInBuffer, (SAMPLE *)inputBuffer, samplesPerFrame); - iaxc_echo_can(virtualInBuffer, virtualOutBuffer, - samplesPerFrame); - - rb_WriteRingBuffer(&inRing, virtualInBuffer, totBytes); + res = audio_echo_cancellation(virtualInBuffer, + virtualOutBuffer, + samplesPerFrame); + if ( !res ) + rb_WriteRingBuffer(&inRing, virtualInBuffer, totBytes); } else { - iaxc_echo_can((short *)inputBuffer, - (short *)outputBuffer, - samplesPerFrame); - - rb_WriteRingBuffer(&inRing, inputBuffer, totBytes); + res = audio_echo_cancellation((short *)inputBuffer, + (short *)outputBuffer, + samplesPerFrame); + if ( !res) + rb_WriteRingBuffer(&inRing, inputBuffer, totBytes); } } @@ -599,7 +491,7 @@ &in_stream_params, &out_stream_params, iaxci_sample_rate, - paFramesPerBufferUnspecified, //FEEBACK - unsure if appropriate + SAMPLES_PER_FRAME, paNoFlag, (PaStreamCallback *)pa_callback, NULL); @@ -612,7 +504,7 @@ &in_stream_params, &no_device, iaxci_sample_rate, - paFramesPerBufferUnspecified, //FEEBACK - unsure if appropriate + SAMPLES_PER_FRAME, paNoFlag, (PaStreamCallback *)pa_callback, NULL); @@ -622,7 +514,7 @@ &no_device, &out_stream_params, iaxci_sample_rate, - paFramesPerBufferUnspecified, //FEEBACK - unsure if appropriate + SAMPLES_PER_FRAME, paNoFlag, (PaStreamCallback *)pa_callback, NULL); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpg...@us...> - 2007-05-09 18:24:03
|
Revision: 978 http://svn.sourceforge.net/iaxclient/?rev=978&view=rev Author: jpgrayson Date: 2007-05-09 11:23:55 -0700 (Wed, 09 May 2007) Log Message: ----------- Update mixer levels code to use float consistently. Previously, many of the interfaces used doubles for mixer levels, but under the hood, portmixer and speex only use float precision. So we now avoid having an inflated sense of precision for the mixer levels. Modified Paths: -------------- trunk/lib/audio_encode.c trunk/lib/audio_portaudio.c trunk/lib/iaxclient.h trunk/lib/iaxclient_lib.c trunk/lib/iaxclient_lib.h Modified: trunk/lib/audio_encode.c =================================================================== --- trunk/lib/audio_encode.c 2007-05-09 16:07:05 UTC (rev 977) +++ trunk/lib/audio_encode.c 2007-05-09 18:23:55 UTC (rev 978) @@ -25,10 +25,10 @@ #include "codec_ilbc.h" #endif -double iaxc_silence_threshold = -9e99; +float iaxc_silence_threshold = -9e99f; -static double input_level = 0.0; -static double output_level = 0.0; +static float input_level = 0.0f; +static float output_level = 0.0f; static SpeexPreprocessState *st = NULL; static int speex_state_size = 0; @@ -50,49 +50,39 @@ }; -static double vol_to_db(double vol) +static float vol_to_db(float vol) { /* avoid calling log10() on zero which yields inf or * negative numbers which yield nan */ if ( vol <= 0.0 ) return 0.0; else - return log10(vol) * 20; + return log10f(vol) * 20; } -/* just get the current input/output volumes, and return them. */ -int iaxc_get_inout_volumes(int *input, int *output) -{ - if(input) - *input = (int)vol_to_db(input_level); - if(output) - *output = (int)vol_to_db(output_level); - - return 0; -} - static int do_level_callback() { static struct timeval last = {0,0}; struct timeval now; - double input_db; - double output_db; + float input_db; + float output_db; - gettimeofday(&now,NULL); - if(last.tv_sec != 0 && iaxc_usecdiff(&now,&last) < 100000) + gettimeofday(&now, 0); + + if ( last.tv_sec != 0 && iaxc_usecdiff(&now, &last) < 100000 ) return 0; last = now; /* if input has not been processed in the last second, set to silent */ - input_db = ( iaxc_usecdiff( &now, &timeLastInput ) < 1000000 ) - ? vol_to_db( input_level ) : -99.9; + input_db = iaxc_usecdiff(&now, &timeLastInput) < 1000000 ? + vol_to_db(input_level) : -99.9f; /* if output has not been processed in the last second, set to silent */ - output_db = ( iaxc_usecdiff( &now, &timeLastOutput ) < 1000000 ) - ? vol_to_db( output_level ) : -99.9; + output_db = iaxc_usecdiff(&now, &timeLastOutput) < 1000000 ? + vol_to_db(output_level) : -99.9f; - iaxc_do_levels_callback((float) input_db, (float) output_db); + iaxc_do_levels_callback(input_db, output_db); return 0; } @@ -120,7 +110,7 @@ speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_PROB_CONTINUE, &f); } -static void calculate_level(short *audio, int len, double *level) +static void calculate_level(short *audio, int len, float *level) { int big_sample = 0; int i; @@ -132,17 +122,19 @@ sample : big_sample; } - *level += ((double)big_sample / 32767.0 - *level) / 5.0; + *level += ((float)big_sample / 32767.0f - *level) / 5.0f; } static int input_postprocess(void *audio, int len, int rate) { - double volume; - static double lowest_volume = 1.0; - int silent=0; + static float lowest_volume = 1.0f; + float volume; + int silent = 0; - if(!st || (speex_state_size != len) || (speex_state_rate != rate)) { - if (st) speex_preprocess_state_destroy(st); + if ( !st || speex_state_size != len || speex_state_rate != rate ) + { + if (st) + speex_preprocess_state_destroy(st); st = speex_preprocess_state_init(len,rate); speex_state_size = len; speex_state_rate = rate; @@ -152,58 +144,62 @@ calculate_level((short *)audio, len, &input_level); /* only preprocess if we're interested in VAD, AGC, or DENOISE */ - if((iaxc_filters & (IAXC_FILTER_DENOISE | IAXC_FILTER_AGC)) || iaxc_silence_threshold > 0) + if ( (iaxc_filters & (IAXC_FILTER_DENOISE | IAXC_FILTER_AGC)) || + iaxc_silence_threshold > 0.0f ) silent = !speex_preprocess(st, (spx_int16_t *)audio, NULL); /* Analog AGC: Bring speex AGC gain out to mixer, with lots of hysteresis */ /* use a higher continuation threshold for AAGC than for VAD itself */ - if(!silent && - (iaxc_silence_threshold != 0) && + if ( !silent && + iaxc_silence_threshold != 0.0f && (iaxc_filters & IAXC_FILTER_AGC) && (iaxc_filters & IAXC_FILTER_AAGC) && - (st->speech_prob > 0.20) - ) + st->speech_prob > 0.20f ) { static int i = 0; i++; - if((i&0x3f) == 0) { + if ( (i & 0x3f) == 0 ) + { const float loudness = st->loudness2; - if((loudness > 8000.0) || (loudness < 4000.0)) { - const double level = iaxc_input_level_get(); - /* fprintf(stderr, "loudness = %f, level = %f\n", loudness, level); */ - /* lower quickly if we're really too hot */ - if((loudness > 16000.0) && (level > 0.5)) { - /* fprintf(stderr, "lowering quickly level\n"); */ - iaxc_input_level_set(level - 0.2); + + if ( loudness > 8000.0f || loudness < 4000.0f ) + { + const float level = iaxc_input_level_get(); + + if ( loudness > 16000.0f && level > 0.5f ) + { + /* lower quickly if we're really too hot */ + iaxc_input_level_set(level - 0.2f); } - /* lower less quickly if we're a bit too hot */ - else if((loudness > 8000.0) && (level >= 0.15)) { - /* fprintf(stderr, "lowering slowly level\n"); */ - iaxc_input_level_set(level - 0.1); + else if ( loudness > 8000.0f && level >= 0.15f ) + { + /* lower less quickly if we're a bit too hot */ + iaxc_input_level_set(level - 0.1f); } - /* raise slowly if we're cold */ - else if((loudness < 4000.0) && (level <= 0.9)) { - /* fprintf(stderr, "raising level\n"); */ - iaxc_input_level_set(level + 0.1); + else if ( loudness < 4000.0f && level <= 0.9f ) + { + /* raise slowly if we're cold */ + iaxc_input_level_set(level + 0.1f); } } } } - /* this is ugly. Basically just don't get volume level if speex thought - * we were silent. just set it to 0 in that case */ - if(iaxc_silence_threshold > 0 && silent) - input_level = 0; + /* This is ugly. Basically just don't get volume level if speex thought + * we were silent. Just set it to 0 in that case */ + if ( iaxc_silence_threshold > 0.0f && silent ) + input_level = 0.0f; do_level_callback(); volume = vol_to_db(input_level); - if(volume < lowest_volume) lowest_volume = volume; + if ( volume < lowest_volume ) + lowest_volume = volume; - if(iaxc_silence_threshold > 0) + if ( iaxc_silence_threshold > 0.0f ) return silent; else return volume < iaxc_silence_threshold; Modified: trunk/lib/audio_portaudio.c =================================================================== --- trunk/lib/audio_portaudio.c 2007-05-09 16:07:05 UTC (rev 977) +++ trunk/lib/audio_portaudio.c 2007-05-09 18:23:55 UTC (rev 978) @@ -145,8 +145,8 @@ /* forward declarations */ static int pa_start (struct iaxc_audio_driver *d ); static void handle_paerror(PaError err, char * where); -static int pa_input_level_set(struct iaxc_audio_driver *d, double level); -static double pa_input_level_get(struct iaxc_audio_driver *d); +static int pa_input_level_set(struct iaxc_audio_driver *d, float level); +static float pa_input_level_get(struct iaxc_audio_driver *d); /* scan devices and stash pointers to dev structures. * But, these structures only remain valid while Pa is initialized, @@ -748,9 +748,7 @@ static int pa_start(struct iaxc_audio_driver *d) { - PaError err; - static int errcnt=0; - double level; + static int errcnt = 0; if ( running ) return 0; @@ -793,14 +791,14 @@ errcnt = 0; // only count consecutive errors. - err = Pa_StartStream(iStream); - if(err != paNoError) return -1; + if ( Pa_StartStream(iStream) != paNoError ) + return -1; iMixer = Px_OpenMixer(iStream, 0); if ( !oneStream ) { - err = Pa_StartStream(oStream); + PaError err = Pa_StartStream(oStream); oMixer = Px_OpenMixer(oStream, 0); if ( err != paNoError ) { @@ -821,8 +819,7 @@ if ( auxStream ) { pa_openauxstream(d); - err = Pa_StartStream(aStream); - if(err != paNoError) + if ( Pa_StartStream(aStream) != paNoError ) { auxStream = 0; } @@ -846,17 +843,17 @@ } } - /* try to set the microphone boost -- we just turn off this "boost" feature, because - it often leads to clipping, which we can't fix later -- but we can deal with low input levels - much more gracefully */ + /* try to set the microphone boost -- we just turn off this + * "boost" feature, because it often leads to clipping, which + * we can't fix later -- but we can deal with low input levels + * much more gracefully */ Px_SetMicrophoneBoost( iMixer, 0 ); - /* if the input level is very low, raise it up a bit. + /* If the input level is very low, raise it up a bit. * Otherwise, AGC cannot detect speech, and cannot adjust * levels */ - level = pa_input_level_get(d); - if ( level < 0.5 ) - pa_input_level_set(d, 0.6); + if ( pa_input_level_get(d) < 0.5f ) + pa_input_level_set(d, 0.6f); mixers_initialized = 1; } @@ -980,10 +977,11 @@ return Pa_Terminate(); } -static double pa_input_level_get(struct iaxc_audio_driver *d) +static float pa_input_level_get(struct iaxc_audio_driver *d) { /* iMixer should be non-null if we using either one or two streams */ - if(!iMixer) return -1; + if ( !iMixer ) + return -1; /* make sure this device supports input volume controls */ if ( Px_GetNumInputSources( iMixer ) == 0 ) @@ -992,7 +990,7 @@ return Px_GetInputVolume(iMixer); } -static double pa_output_level_get(struct iaxc_audio_driver *d) +static float pa_output_level_get(struct iaxc_audio_driver *d) { PxMixer *mix; @@ -1002,65 +1000,63 @@ if ( oMixer ) mix = oMixer; - else if (iMixer) + else if ( iMixer ) mix = iMixer; else return -1; /* prefer the pcm output, but default to the master output */ - if ( Px_SupportsPCMOutputVolume( mix ) ) - return Px_GetPCMOutputVolume( mix ); + if ( Px_SupportsPCMOutputVolume(mix) ) + return Px_GetPCMOutputVolume(mix); else - return Px_GetMasterVolume( mix ); + return Px_GetMasterVolume(mix); } -static int pa_input_level_set(struct iaxc_audio_driver *d, double level) +static int pa_input_level_set(struct iaxc_audio_driver *d, float level) { - if(!iMixer) return -1; - /* make sure this device supports input volume controls */ - if ( Px_GetNumInputSources( iMixer ) == 0 ) + if ( !iMixer || Px_GetNumInputSources(iMixer) == 0 ) return -1; - //fprintf(stderr, "setting input level to %f\n", level); - Px_SetInputVolume(iMixer, (float) level); + Px_SetInputVolume(iMixer, level); + return 0; } -static int pa_output_level_set(struct iaxc_audio_driver *d, double level) +static int pa_output_level_set(struct iaxc_audio_driver *d, float level) { PxMixer *mix; - if(oMixer) + if ( oMixer ) mix = oMixer; - else if (iMixer) + else if ( iMixer ) mix = iMixer; else return -1; /* prefer the pcm output, but default to the master output */ - if ( Px_SupportsPCMOutputVolume( mix ) ) - Px_SetPCMOutputVolume(mix, (float) level); + if ( Px_SupportsPCMOutputVolume(mix) ) + Px_SetPCMOutputVolume(mix, level); else - Px_SetMasterVolume(mix, (float) level); + Px_SetMasterVolume(mix, level); return 0; } static int pa_mic_boost_get(struct iaxc_audio_driver* d) { - int enable = -1; - if ( iMixer != NULL ) - enable = Px_GetMicrophoneBoost( iMixer ); - return enable; + if ( !iMixer ) + return -1; + + return Px_GetMicrophoneBoost(iMixer); } int pa_mic_boost_set(struct iaxc_audio_driver* d, int enable) { - int err = -1; - if ( iMixer != NULL ) - err = Px_SetMicrophoneBoost(iMixer, enable); - return err; + if ( !iMixer ) + return -1; + + return Px_SetMicrophoneBoost(iMixer, enable); } /* initialize audio driver */ Modified: trunk/lib/iaxclient.h =================================================================== --- trunk/lib/iaxclient.h 2007-05-09 16:07:05 UTC (rev 977) +++ trunk/lib/iaxclient.h 2007-05-09 18:23:55 UTC (rev 978) @@ -303,7 +303,7 @@ EXPORT void iaxc_send_text(char *text); EXPORT void iaxc_send_url(char *url, int link); /* link == 1 ? AST_HTML_LINKURL : AST_HTML_URL */ EXPORT void iaxc_millisleep(long ms); -EXPORT void iaxc_set_silence_threshold(double thr); +EXPORT void iaxc_set_silence_threshold(float thr); EXPORT void iaxc_set_audio_output(int mode); EXPORT int iaxc_select_call(int callNo); EXPORT int iaxc_first_free_call(); @@ -351,10 +351,10 @@ EXPORT int iaxc_audio_devices_get(struct iaxc_audio_device **devs, int *nDevs, int *input, int *output, int *ring); EXPORT int iaxc_audio_devices_set(int input, int output, int ring); -EXPORT double iaxc_input_level_get(); -EXPORT double iaxc_output_level_get(); -EXPORT int iaxc_input_level_set(double level); -EXPORT int iaxc_output_level_set(double level); +EXPORT float iaxc_input_level_get(); +EXPORT float iaxc_output_level_get(); +EXPORT int iaxc_input_level_set(float level); +EXPORT int iaxc_output_level_set(float level); struct iaxc_sound { Modified: trunk/lib/iaxclient_lib.c =================================================================== --- trunk/lib/iaxclient_lib.c 2007-05-09 16:07:05 UTC (rev 977) +++ trunk/lib/iaxclient_lib.c 2007-05-09 18:23:55 UTC (rev 978) @@ -142,7 +142,7 @@ } } -EXPORT void iaxc_set_silence_threshold(double thr) +EXPORT void iaxc_set_silence_threshold(float thr) { iaxc_silence_threshold = thr; iaxc_set_speex_filters(); @@ -1777,22 +1777,22 @@ return ret; } -EXPORT double iaxc_input_level_get() +EXPORT float iaxc_input_level_get() { return audio_driver.input_level_get(&audio_driver); } -EXPORT double iaxc_output_level_get() +EXPORT float iaxc_output_level_get() { return audio_driver.output_level_get(&audio_driver); } -EXPORT int iaxc_input_level_set(double level) +EXPORT int iaxc_input_level_set(float level) { return audio_driver.input_level_set(&audio_driver, level); } -EXPORT int iaxc_output_level_set(double level) +EXPORT int iaxc_output_level_set(float level) { return audio_driver.output_level_set(&audio_driver, level); } Modified: trunk/lib/iaxclient_lib.h =================================================================== --- trunk/lib/iaxclient_lib.h 2007-05-09 16:07:05 UTC (rev 977) +++ trunk/lib/iaxclient_lib.h 2007-05-09 18:23:55 UTC (rev 978) @@ -148,10 +148,10 @@ int (*input)(struct iaxc_audio_driver *d, void *samples, int *nSamples); /* levels */ - double (*input_level_get)(struct iaxc_audio_driver *d); - double (*output_level_get)(struct iaxc_audio_driver *d); - int (*input_level_set)(struct iaxc_audio_driver *d, double level); - int (*output_level_set)(struct iaxc_audio_driver *d, double level); + float (*input_level_get)(struct iaxc_audio_driver *d); + float (*output_level_get)(struct iaxc_audio_driver *d); + int (*input_level_set)(struct iaxc_audio_driver *d, float level); + int (*output_level_set)(struct iaxc_audio_driver *d, float level); /* sounds */ int (*play_sound)(struct iaxc_sound *s, int ring); @@ -282,7 +282,7 @@ unsigned int ts, int format); int iaxc_send_video(struct iaxc_call *, int); -extern double iaxc_silence_threshold; +extern float iaxc_silence_threshold; extern int iaxc_audio_output_mode; int post_event_callback(iaxc_event e); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpg...@us...> - 2007-07-02 19:48:15
|
Revision: 1048 http://svn.sourceforge.net/iaxclient/?rev=1048&view=rev Author: jpgrayson Date: 2007-07-02 12:48:05 -0700 (Mon, 02 Jul 2007) Log Message: ----------- Constify some character pointers. Makes pedantic compilers more happiful. Modified Paths: -------------- trunk/lib/iaxclient.h trunk/lib/iaxclient_lib.c trunk/lib/libiax2/src/iax-client.h trunk/lib/libiax2/src/iax.c Modified: trunk/lib/iaxclient.h =================================================================== --- trunk/lib/iaxclient.h 2007-07-02 15:01:17 UTC (rev 1047) +++ trunk/lib/iaxclient.h 2007-07-02 19:48:05 UTC (rev 1048) @@ -283,22 +283,22 @@ EXPORT void iaxc_shutdown(); EXPORT void iaxc_set_formats(int preferred, int allowed); EXPORT void iaxc_set_min_outgoing_framesize(int samples); -EXPORT void iaxc_set_callerid(char *name, char *number); +EXPORT void iaxc_set_callerid(const char * name, const char * number); EXPORT int iaxc_start_processing_thread(); EXPORT int iaxc_stop_processing_thread(); -EXPORT int iaxc_call(char *num); +EXPORT int iaxc_call(const char * num); EXPORT int iaxc_unregister( int id ); -EXPORT int iaxc_register(char *user, char *pass, char *host); -EXPORT void iaxc_send_busy_on_incoming_call(int callNo); //frik +EXPORT int iaxc_register(const char * user, const char * pass, const char * host); +EXPORT void iaxc_send_busy_on_incoming_call(int callNo); EXPORT void iaxc_answer_call(int callNo); -EXPORT void iaxc_blind_transfer_call(int callNo, char *number); +EXPORT void iaxc_blind_transfer_call(int callNo, const char * number); EXPORT void iaxc_dump_all_calls(void); EXPORT void iaxc_dump_call(void); EXPORT void iaxc_reject_call(void); EXPORT void iaxc_reject_call_number(int callNo); EXPORT void iaxc_send_dtmf(char digit); -EXPORT void iaxc_send_text(char *text); -EXPORT void iaxc_send_url(char *url, int link); /* link == 1 ? AST_HTML_LINKURL : AST_HTML_URL */ +EXPORT void iaxc_send_text(const char * text); +EXPORT void iaxc_send_url(const char *url, int link); /* link == 1 ? AST_HTML_LINKURL : AST_HTML_URL */ EXPORT void iaxc_millisleep(long ms); EXPORT void iaxc_set_silence_threshold(float thr); EXPORT void iaxc_set_audio_output(int mode); @@ -329,7 +329,7 @@ #define IAXC_AD_RING_DEFAULT (1<<5) struct iaxc_audio_device { - char *name; /* name of the device */ + const char * name; /* name of the device */ long capabilities; /* flags, defined above */ int devID; /* driver-specific ID */ }; Modified: trunk/lib/iaxclient_lib.c =================================================================== --- trunk/lib/iaxclient_lib.c 2007-07-02 15:01:17 UTC (rev 1047) +++ trunk/lib/iaxclient_lib.c 2007-07-02 19:48:05 UTC (rev 1048) @@ -204,7 +204,7 @@ } // Messaging functions -static void default_message_callback(char *message) +static void default_message_callback(const char * message) { fprintf(stderr, "IAXCLIENT: %s\n", message); } @@ -682,7 +682,7 @@ minimum_outgoing_framesize = samples; } -EXPORT void iaxc_set_callerid(char *name, char *number) +EXPORT void iaxc_set_callerid(const char * name, const char * number) { int i; @@ -1259,7 +1259,7 @@ return count; } -EXPORT int iaxc_register(char *user, char *pass, char *host) +EXPORT int iaxc_register(const char * user, const char * pass, const char * host) { struct iaxc_registration *newreg; @@ -1322,7 +1322,7 @@ } } -EXPORT int iaxc_call(char *num) +EXPORT int iaxc_call(const char * num) { int video_format_capability; int video_format_preferred; @@ -1420,9 +1420,9 @@ iaxci_do_state_callback(callNo); } -EXPORT void iaxc_blind_transfer_call(int callNo, char *DestExtn) +EXPORT void iaxc_blind_transfer_call(int callNo, const char * dest_extension) { - iax_transfer(calls[callNo].session, DestExtn); + iax_transfer(calls[callNo].session, dest_extension); } static void iaxc_dump_one_call(int callNo) @@ -1487,7 +1487,7 @@ } } -EXPORT void iaxc_send_text(char *text) +EXPORT void iaxc_send_text(const char * text) { if (selected_call >= 0) { @@ -1498,7 +1498,7 @@ } } -EXPORT void iaxc_send_url(char *url, int link) +EXPORT void iaxc_send_url(const char * url, int link) { if (selected_call >= 0) { @@ -1848,7 +1848,7 @@ #ifdef LIBVER -EXPORT char* iaxc_version(char* ver) +EXPORT char* iaxc_version(char * ver) { strncpy(ver, LIBVER, IAXC_EVENT_BUFSIZ); return ver; Modified: trunk/lib/libiax2/src/iax-client.h =================================================================== --- trunk/lib/libiax2/src/iax-client.h 2007-07-02 15:01:17 UTC (rev 1047) +++ trunk/lib/libiax2/src/iax-client.h 2007-07-02 19:48:05 UTC (rev 1048) @@ -167,15 +167,15 @@ extern int iax_send_voice(struct iax_session *session, int format, unsigned char *data, int datalen, int samples); extern int iax_send_cng(struct iax_session *session, int level, unsigned char *data, int datalen); extern int iax_send_image(struct iax_session *session, int format, unsigned char *data, int datalen); -extern int iax_send_url(struct iax_session *session, char *url, int link); -extern int iax_send_text(struct iax_session *session, char *text); +extern int iax_send_url(struct iax_session *session, const char *url, int link); +extern int iax_send_text(struct iax_session *session, const char *text); extern int iax_send_ping(struct iax_session *session); extern int iax_load_complete(struct iax_session *session); extern int iax_reject(struct iax_session *session, char *reason); extern int iax_busy(struct iax_session *session); extern int iax_congestion(struct iax_session *session); extern int iax_hangup(struct iax_session *session, char *byemsg); -extern int iax_call(struct iax_session *session, char *cidnum, char *cidname, char *ich, char *lang, int wait, int format, int capability); +extern int iax_call(struct iax_session *session, const char *cidnum, const char *cidname, const char *ich, const char *lang, int wait, int format, int capability); extern int iax_accept(struct iax_session *session, int format); extern int iax_answer(struct iax_session *session); extern int iax_sendurl(struct iax_session *session, char *url); @@ -183,13 +183,13 @@ extern int iax_send_link_reject(struct iax_session *session); extern int iax_ring_announce(struct iax_session *session); extern struct sockaddr_in iax_get_peer_addr(struct iax_session *session); -extern int iax_register(struct iax_session *session, char *hostname, char *peer, char *secret, int refresh); +extern int iax_register(struct iax_session *session, const char *hostname, const char *peer, const char *secret, int refresh); extern int iax_lag_request(struct iax_session *session); extern int iax_dial(struct iax_session *session, char *number); /* Dial on a TBD call */ extern int iax_dialplan_request(struct iax_session *session, char *number); /* Request dialplan status for number */ extern int iax_quelch(struct iax_session *session); extern int iax_unquelch(struct iax_session * session); -extern int iax_transfer(struct iax_session *session, char *number); +extern int iax_transfer(struct iax_session *session, const char *number); extern int iax_quelch_moh(struct iax_session *session, int MOH); extern int iax_send_video(struct iax_session *session, int format, unsigned char *data, int datalen, int fullframe); extern int iax_send_video_trunk(struct iax_session *session, int format, char *data, int datalen, int fullframe, int ntrunk); Modified: trunk/lib/libiax2/src/iax.c =================================================================== --- trunk/lib/libiax2/src/iax.c 2007-07-02 15:01:17 UTC (rev 1047) +++ trunk/lib/libiax2/src/iax.c 2007-07-02 19:48:05 UTC (rev 1048) @@ -1292,7 +1292,7 @@ } -int iax_transfer(struct iax_session *session, char *number) +int iax_transfer(struct iax_session *session, const char *number) { static int res; //Return Code struct iax_ie_data ied; //IE Data Structure (Stuff To Send) @@ -1677,7 +1677,7 @@ return 0; } -int iax_register(struct iax_session *session, char *server, char *peer, char *secret, int refresh) +int iax_register(struct iax_session *session, const char *server, const char *peer, const char *secret, int refresh) { /* Send a registration request */ char tmp[256]; @@ -1780,14 +1780,14 @@ return send_command(session, AST_FRAME_HTML, AST_HTML_LDCOMPLETE, 0, NULL, 0, -1); } -int iax_send_url(struct iax_session *session, char *url, int link) +int iax_send_url(struct iax_session *session, const char *url, int link) { return send_command(session, AST_FRAME_HTML, link ? AST_HTML_LINKURL : AST_HTML_URL, 0, (unsigned char *)url, (int)strlen(url), -1); } -int iax_send_text(struct iax_session *session, char *text) +int iax_send_text(struct iax_session *session, const char *text) { return send_command(session, AST_FRAME_TEXT, 0, 0, (unsigned char *)text, (int)strlen(text) + 1, -1); @@ -2009,7 +2009,7 @@ return x; } -int iax_call(struct iax_session *session, char *cidnum, char *cidname, char *ich, char *lang, int wait, int formats, int capabilities) +int iax_call(struct iax_session *session, const char *cidnum, const char *cidname, const char *ich, const char *lang, int wait, int formats, int capabilities) { char tmp[256]=""; char *part1, *part2; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bc...@us...> - 2007-07-25 14:39:24
|
Revision: 1076 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1076&view=rev Author: bcholew Date: 2007-07-25 07:39:25 -0700 (Wed, 25 Jul 2007) Log Message: ----------- Modify iaxclient and libiax2 to ensure that the callno is properly (randomly) initialized. Courtesy of jpgrayson. Modified Paths: -------------- trunk/lib/iaxclient.h trunk/lib/iaxclient_lib.c trunk/lib/libiax2/src/iax.c Modified: trunk/lib/iaxclient.h =================================================================== --- trunk/lib/iaxclient.h 2007-07-20 18:34:36 UTC (rev 1075) +++ trunk/lib/iaxclient.h 2007-07-25 14:39:25 UTC (rev 1076) @@ -278,7 +278,7 @@ // NOTE: must be called before iaxc_initialize() EXPORT void iaxc_set_preferred_source_udp_port(int sourceUdpPort); -EXPORT unsigned short iaxc_get_bind_port(); +EXPORT short iaxc_get_bind_port(); EXPORT int iaxc_initialize(int num_calls); EXPORT void iaxc_shutdown(); EXPORT void iaxc_set_formats(int preferred, int allowed); Modified: trunk/lib/iaxclient_lib.c =================================================================== --- trunk/lib/iaxclient_lib.c 2007-07-20 18:34:36 UTC (rev 1075) +++ trunk/lib/iaxclient_lib.c 2007-07-25 14:39:25 UTC (rev 1076) @@ -92,7 +92,7 @@ static MUTEX iaxc_lock; static MUTEX event_queue_lock; -static int netfd; +static short iaxci_bound_port = -1; // default to use port 4569 unless set by iaxc_set_preferred_source_udp_port static int source_udp_port = IAX_DEFAULT_PORTNO; @@ -541,29 +541,16 @@ return iax_video_bypass_jitter(calls[selected_call].session,mode); } -EXPORT unsigned short iaxc_get_bind_port() +EXPORT short iaxc_get_bind_port() { - struct sockaddr_in addtmp; - socklen_t addlen; - int result; - - addlen = sizeof( addtmp ); - result = getsockname(netfd,(struct sockaddr *)&addtmp, &addlen ); - if ( result < 0 ) - { - iaxci_usermsg(IAXC_ERROR, "Fatal error: failed to get the iax port\n"); - return -1; - } - - return ntohs(addtmp.sin_port); + return iaxci_bound_port; } EXPORT int iaxc_initialize(int num_calls) { int i; + int port; - /* os-specific initializations: init gettimeofday fake stuff in - * Win32, etc) */ os_init(); setup_jb_output(); @@ -573,23 +560,27 @@ iaxc_set_audio_prefs(0); - if ( iaxc_sendto == (iaxc_sendto_t)sendto ) - { - int port; + if ( iaxc_recvfrom != (iaxc_recvfrom_t)recvfrom ) + iax_set_networking(iaxc_sendto, iaxc_recvfrom); - if ( (port = iax_init(source_udp_port)) < 0 ) - { - iaxci_usermsg(IAXC_ERROR, - "Fatal error: failed to initialize iax with port %d", - port); - return -1; - } - netfd = iax_get_fd(); - } else + /* Note that iax_init() only sets up the receive port when the + * sendto/recvfrom functions have not been replaced. We need + * to call iaxc_init in either case because there is other + * initialization beyond the socket setup that needs to be done. + */ + if ( (port = iax_init(source_udp_port)) < 0 ) { - iax_set_networking(iaxc_sendto, iaxc_recvfrom); + iaxci_usermsg(IAXC_ERROR, + "Fatal error: failed to initialize iax with port %d", + port); + return -1; } + if ( iaxc_recvfrom == (iaxc_recvfrom_t)recvfrom ) + iaxci_bound_port = (short)port; + else + iaxci_bound_port = -1; + /* tweak the jitterbuffer settings */ iax_set_jb_target_extra( jb_target_extra ); Modified: trunk/lib/libiax2/src/iax.c =================================================================== --- trunk/lib/libiax2/src/iax.c 2007-07-20 18:34:36 UTC (rev 1075) +++ trunk/lib/libiax2/src/iax.c 2007-07-25 14:39:25 UTC (rev 1076) @@ -885,16 +885,17 @@ int iax_init(int preferredportno) { int portno = preferredportno; - struct sockaddr_in sin; - socklen_t sinlen; - int flags; - int bufsize = 256 * 1024; - if(iax_recvfrom == (iax_recvfrom_t) recvfrom) + if (iax_recvfrom == (iax_recvfrom_t)recvfrom) { + struct sockaddr_in sin; + socklen_t sinlen; + int flags; + int bufsize = 256 * 1024; + if (netfd > -1) { - /* Sokay, just don't do anything */ + /* Okay, just don't do anything */ DEBU(G "Already initialized."); return 0; } @@ -906,9 +907,12 @@ return -1; } - if (preferredportno == 0) preferredportno = IAX_DEFAULT_PORTNO; - if (preferredportno < 0) preferredportno = 0; + if (preferredportno == 0) + preferredportno = IAX_DEFAULT_PORTNO; + if (preferredportno < 0) + preferredportno = 0; + sin.sin_family = AF_INET; sin.sin_addr.s_addr = 0; sin.sin_port = htons((short)preferredportno); @@ -973,18 +977,22 @@ return -1; } #endif + /* Mihai: increase UDP socket buffers to avoid packet loss. */ + 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."); + } + portno = ntohs(sin.sin_port); + DEBU(G "Started on port %d\n", portno); } - // Mihai: attempt to increase UDP socket buffers to avoid packet loss - 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."); - } + srand((unsigned int)time(0)); callnums = rand() % 32767 + 1; transfer_id = rand() % 32767 + 1; - DEBU(G "Started on port %d\n", portno); + return portno; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpg...@us...> - 2007-09-21 22:26:11
|
Revision: 1151 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1151&view=rev Author: jpgrayson Date: 2007-09-21 15:26:11 -0700 (Fri, 21 Sep 2007) Log Message: ----------- Put more video-specific code in video.c. Remove some unused code. Modified Paths: -------------- trunk/lib/codec_theora.c trunk/lib/iaxclient_lib.c trunk/lib/video.c trunk/lib/video.h Modified: trunk/lib/codec_theora.c =================================================================== --- trunk/lib/codec_theora.c 2007-09-20 21:30:19 UTC (rev 1150) +++ trunk/lib/codec_theora.c 2007-09-21 22:26:11 UTC (rev 1151) @@ -470,8 +470,6 @@ if ( !c->encstate ) goto bail; - video_reset_codec_stats(c); - c->format = format; c->width = w; c->height = h; Modified: trunk/lib/iaxclient_lib.c =================================================================== --- trunk/lib/iaxclient_lib.c 2007-09-20 21:30:19 UTC (rev 1150) +++ trunk/lib/iaxclient_lib.c 2007-09-21 22:26:11 UTC (rev 1151) @@ -772,42 +772,10 @@ } #ifdef USE_VIDEO -#define VIDEO_STATS_INTERVAL 1000 // In ms -static struct timeval video_stats_start; - -static void send_video_stats() -{ - iaxc_event e; - struct timeval now; - long time; - - // make sure there is a call to do stats on - if (selected_call < 0) - return; - - gettimeofday(&now, NULL); - time = iaxci_msecdiff(&now, &video_stats_start); - if ( time > VIDEO_STATS_INTERVAL ) - { - video_get_stats(&calls[selected_call], &e.ev.videostats.stats, 1); -/* fprintf(stderr, "Video stats: sent_slices=%ld, acc_sent_size=%ld, outbound_frames=%ld, avg_outbound_fps=%f, avg_outbound_bps=%ld, " - "received_slices=%ld, acc_recv_size=%ld, inbound_frames=%ld, dropped_frames=%ld, avg_inbound_fps=%f, avg_inbound_bps=%ld\n", - stats.sent_slices, stats.acc_sent_size, stats.outbound_frames, stats.avg_outbound_fps, stats.avg_outbound_bps, - stats.received_slices, stats.acc_recv_size, stats.inbound_frames, stats.dropped_frames, stats.avg_inbound_fps, stats.avg_inbound_bps);*/ - e.type = IAXC_EVENT_VIDEOSTATS; - e.ev.videostats.callNo = selected_call; - iaxci_post_event(e); - - video_stats_start = now; - } -} - static THREADFUNCDECL(video_proc_thread_func) { struct iaxc_call *call; - gettimeofday(&video_stats_start, NULL); - while ( !video_proc_thread_flag ) { if (selected_call >= 0) @@ -816,9 +784,8 @@ call = NULL; video_send_video(call, selected_call); + video_send_stats(call); - send_video_stats(); - // Tight spinloops are bad, mmmkay? iaxc_millisleep(LOOP_SLEEP); } @@ -827,7 +794,7 @@ return 0; } -#endif /* USE_VIDEO */ +#endif EXPORT int iaxc_start_processing_thread() { Modified: trunk/lib/video.c =================================================================== --- trunk/lib/video.c 2007-09-20 21:30:19 UTC (rev 1150) +++ trunk/lib/video.c 2007-09-21 22:26:11 UTC (rev 1151) @@ -284,6 +284,62 @@ call->vencoder->fragsize = fs; } +static void reset_codec_stats(struct iaxc_video_codec *vcodec) +{ + if ( !vcodec ) + return; + + memset(&vcodec->video_stats, 0, sizeof(struct iaxc_video_stats)); + gettimeofday(&vcodec->video_stats.start_time, 0); +} + +static void reset_video_stats(struct iaxc_call *call) +{ + if ( !call ) + return; + + reset_codec_stats(call->vdecoder); + reset_codec_stats(call->vencoder); +} + +/* Collect and return video statistics. Also reset statistics if required. + * Returns a pointer to the data. + * Right now we use two different codecs for encoding and decoding. We need + * to collate information from both and wrap it into one nice struct. + */ +static int get_stats(struct iaxc_call *call, struct iaxc_video_stats *stats, + int reset) +{ + if ( !call || !stats ) + return -1; + + memset(stats, 0, sizeof(*stats)); + + if ( call->vencoder ) + { + stats->sent_slices = call->vencoder->video_stats.sent_slices; + stats->acc_sent_size = call->vencoder->video_stats.acc_sent_size; + stats->outbound_frames = call->vencoder->video_stats.outbound_frames; + stats->avg_outbound_bps = call->vencoder->video_stats.avg_outbound_bps; + stats->avg_outbound_fps = call->vencoder->video_stats.avg_outbound_fps; + } + + if ( call->vdecoder ) + { + stats->received_slices = call->vdecoder->video_stats.received_slices; + stats->acc_recv_size = call->vdecoder->video_stats.acc_recv_size; + stats->inbound_frames = call->vdecoder->video_stats.inbound_frames; + stats->dropped_frames = call->vdecoder->video_stats.dropped_frames; + stats->avg_inbound_bps = call->vdecoder->video_stats.avg_inbound_bps; + stats->avg_inbound_fps = call->vdecoder->video_stats.avg_inbound_fps; + } + + if ( reset ) + reset_video_stats(call); + + return 0; +} + /* TODO: The encode parameter to this function is unused within this * function. However, clients of this function still use this parameter. * What ends up happening is we instantiate the codec encoder/decoder @@ -303,52 +359,43 @@ */ static struct iaxc_video_codec *create_codec(int format, int encode) { + struct iaxc_video_codec * vcodec = 0; + iaxci_usermsg(IAXC_TEXT_TYPE_NOTICE, "Creating codec format 0x%x", format); + switch ( format ) { case IAXC_FORMAT_H261: case IAXC_FORMAT_H263: case IAXC_FORMAT_H263_PLUS: case IAXC_FORMAT_MPEG4: -#ifdef USE_FFMPEG - return codec_video_ffmpeg_new(format, - iaxc_video_width, - iaxc_video_height, - iaxc_video_framerate, - iaxc_video_bitrate, - iaxc_video_fragsize); -#else - return NULL; -#endif - case IAXC_FORMAT_H264: #ifdef USE_FFMPEG - return codec_video_ffmpeg_new(format, + vcodec = codec_video_ffmpeg_new(format, iaxc_video_width, iaxc_video_height, iaxc_video_framerate, iaxc_video_bitrate, iaxc_video_fragsize); -#else - return NULL; #endif + break; -#ifdef USE_THEORA case IAXC_FORMAT_THEORA: - return codec_video_theora_new(format, +#ifdef USE_THEORA + vcodec = codec_video_theora_new(format, iaxc_video_width, iaxc_video_height, iaxc_video_framerate, iaxc_video_bitrate, iaxc_video_fragsize); -#else - return NULL; #endif + break; } - // Must never happen... - return NULL; + reset_codec_stats(vcodec); + + return vcodec; } /* @@ -422,9 +469,7 @@ /* It is okay if we do not get any video; video capture may be * disabled. */ - if ( !videobuf || - (iaxc_video_prefs & IAXC_VIDEO_PREF_CAPTURE_DISABLE) - ) + if ( !videobuf || (iaxc_video_prefs & IAXC_VIDEO_PREF_CAPTURE_DISABLE) ) return 0; // Send the raw frame to the main app, if necessary @@ -434,7 +479,9 @@ iaxc_video_prefs & IAXC_VIDEO_PREF_RECV_RGB32); } - if ( sel_call < 0 || !call || !(call->state & (IAXC_CALL_STATE_COMPLETE | IAXC_CALL_STATE_OUTGOING) ) ) + if ( sel_call < 0 || !call || + !(call->state & (IAXC_CALL_STATE_COMPLETE | + IAXC_CALL_STATE_OUTGOING)) ) { return -1; } @@ -498,7 +545,7 @@ } // Statistics - gettimeofday(&now, NULL); + gettimeofday(&now, 0); call->vencoder->video_stats.outbound_frames++; time = iaxci_msecdiff(&now, &call->vencoder->video_stats.start_time); if ( time > 0 ) @@ -600,7 +647,7 @@ } /* Statistics */ - gettimeofday(&now, NULL); + gettimeofday(&now, 0); time = iaxci_msecdiff(&now, &call->vdecoder->video_stats.start_time); call->vdecoder->video_stats.received_slices++; call->vdecoder->video_stats.acc_recv_size += encoded_video_len; @@ -727,7 +774,6 @@ yuv2rgb_tables_initialized = 1; } - /* * Faster function to convert YUV420 images to RGB32 * RGB32: 0xFFRRGGBB @@ -784,133 +830,36 @@ } } -/* - * Original function that converts YUV420 images to RGB32 - * RGB32: 0xFFRRGGBB - * Make sure the src and dest buffers have enough room - * dest should be width * height * 4 bytes in size - * Based on the formulas found at http://en.wikipedia.org/wiki/YUV - */ -// void iaxc_YUV420_to_RGB32(int width, int height, char *src, char *dest) -// { -// int i; -// unsigned char * y = (unsigned char *)src; -// unsigned char * u = y + width * height; -// unsigned char * v = u + width * height / 4; -// unsigned int * dst = (unsigned int *)dest; -// -// for ( i = 0; i < height; i++ ) -// { -// int j; -// -// unsigned char * uu = u; -// unsigned char * vv = v; -// -// for ( j = 0; j < width; j++ ) -// { -// int yyy = *y - 16; -// int uuu = *uu - 128; -// int vvv = *vv - 128; -// -// int r = ( 298*yyy + 409*vvv + 128) >> 8; -// int g = ( 298*yyy - 100*uuu - 208*vvv + 128) >> 8; -// int b = ( 298*yyy + 516*uuu + 128) >> 8; -// -// // Clip values to make sure they fit in range -// if ( r < 0 ) -// r = 0; -// else if ( r > 255 ) -// r = 255; -// -// if ( g < 0 ) -// g = 0; -// else if ( g > 255 ) -// g = 255; -// -// if ( b < 0 ) -// b = 0; -// else if ( b > 255 ) -// b = 255; -// -// *(dst++) = 0xff000000 | -// ((unsigned char)r << 16) | -// ((unsigned char)g << 8) | -// ((unsigned char)b << 0); -// -// y++; -// -// if ( j & 1 ) -// { -// uu++; -// vv++; -// } -// } -// -// if ( i & 1 ) -// { -// u += width >> 1; -// v += width >> 1; -// } -// } -// } - int iaxc_is_camera_working() { return video_driver.is_camera_working(&video_driver); } -static void reset_video_stats(struct iaxc_call *call) +int video_send_stats(struct iaxc_call * call) { - if ( !call ) - return; + const long video_stats_interval = 1000; /* milliseconds */ + static struct timeval video_stats_start = {0, 0}; + iaxc_event e; + struct timeval now; - video_reset_codec_stats(call->vdecoder); - video_reset_codec_stats(call->vencoder); -} - -// Collect and return video statistics -// Also reset statistics if required; -// Returns a pointer to the data -// Right now we use two different codecs for encoding and decoding. We need to collate information -// from both and wrap it into one nice struct -int video_get_stats(struct iaxc_call *call, struct iaxc_video_stats *stats, - int reset) -{ - if ( !call || !stats ) + if ( !call ) return -1; - memset(stats, 0, sizeof(*stats)); + if ( video_stats_start.tv_sec == 0 && video_stats_start.tv_usec == 0 ) + gettimeofday(&video_stats_start, 0); - if ( call->vencoder != NULL ) - { - stats->sent_slices = call->vencoder->video_stats.sent_slices; - stats->acc_sent_size = call->vencoder->video_stats.acc_sent_size; - stats->outbound_frames = call->vencoder->video_stats.outbound_frames; - stats->avg_outbound_bps = call->vencoder->video_stats.avg_outbound_bps; - stats->avg_outbound_fps = call->vencoder->video_stats.avg_outbound_fps; - } + gettimeofday(&now, 0); - if ( call->vdecoder != NULL ) + if ( iaxci_msecdiff(&now, &video_stats_start) > video_stats_interval ) { - stats->received_slices = call->vdecoder->video_stats.received_slices; - stats->acc_recv_size = call->vdecoder->video_stats.acc_recv_size; - stats->inbound_frames = call->vdecoder->video_stats.inbound_frames; - stats->dropped_frames = call->vdecoder->video_stats.dropped_frames; - stats->avg_inbound_bps = call->vdecoder->video_stats.avg_inbound_bps; - stats->avg_inbound_fps = call->vdecoder->video_stats.avg_inbound_fps; + get_stats(call, &e.ev.videostats.stats, 1); + e.type = IAXC_EVENT_VIDEOSTATS; + e.ev.videostats.callNo = selected_call; + iaxci_post_event(e); + + video_stats_start = now; } - if ( reset ) - reset_video_stats(call); - return 0; } -void video_reset_codec_stats(struct iaxc_video_codec *vcodec) -{ - if ( vcodec == NULL ) return; - - memset(&vcodec->video_stats, 0, sizeof(struct iaxc_video_stats)); - gettimeofday(&vcodec->video_stats.start_time, NULL); -} - Modified: trunk/lib/video.h =================================================================== --- trunk/lib/video.h 2007-09-20 21:30:19 UTC (rev 1150) +++ trunk/lib/video.h 2007-09-21 22:26:11 UTC (rev 1151) @@ -52,15 +52,12 @@ int video_destroy(void); -int video_get_stats(struct iaxc_call * call, - struct iaxc_video_stats * stats, int reset); - -void video_reset_codec_stats(struct iaxc_video_codec * codec); - int video_send_video(struct iaxc_call *, int); int video_recv_video(struct iaxc_call * call, int sel_call, void * encoded_video, int encoded_video_len, unsigned int ts, int format); +int video_send_stats(struct iaxc_call *); + #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpg...@us...> - 2007-10-04 22:37:37
|
Revision: 1177 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1177&view=rev Author: jpgrayson Date: 2007-10-04 15:37:39 -0700 (Thu, 04 Oct 2007) Log Message: ----------- Fix problem with negative port numbers. There is a mailing list thread describing the problem here: http://sourceforge.net/mailarchive/forum.php?thread_name=46EBD7B4.8070506%40gmail.com&forum_name=iaxclient-devel Modified Paths: -------------- trunk/lib/iaxclient.h trunk/lib/iaxclient_lib.c Modified: trunk/lib/iaxclient.h =================================================================== --- trunk/lib/iaxclient.h 2007-10-03 21:13:49 UTC (rev 1176) +++ trunk/lib/iaxclient.h 2007-10-04 22:37:39 UTC (rev 1177) @@ -22,7 +22,7 @@ #ifdef __cplusplus extern "C" { #endif - + /*! \file iaxclient.h \brief The IAXClient API @@ -635,7 +635,7 @@ \return The UDP port bound to; -1 if no port or */ -EXPORT short iaxc_get_bind_port(); +EXPORT int iaxc_get_bind_port(); /*! Initializes the IAXClient library Modified: trunk/lib/iaxclient_lib.c =================================================================== --- trunk/lib/iaxclient_lib.c 2007-10-03 21:13:49 UTC (rev 1176) +++ trunk/lib/iaxclient_lib.c 2007-10-04 22:37:39 UTC (rev 1177) @@ -99,7 +99,7 @@ static MUTEX iaxc_lock; static MUTEX event_queue_lock; -static short iaxci_bound_port = -1; +static int iaxci_bound_port = -1; // default to use port 4569 unless set by iaxc_set_preferred_source_udp_port static int source_udp_port = IAX_DEFAULT_PORTNO; @@ -554,7 +554,7 @@ return iax_video_bypass_jitter(calls[selected_call].session,mode); } -EXPORT short iaxc_get_bind_port() +EXPORT int iaxc_get_bind_port() { return iaxci_bound_port; } @@ -590,7 +590,7 @@ } if ( iaxc_recvfrom == (iaxc_recvfrom_t)recvfrom ) - iaxci_bound_port = (short)port; + iaxci_bound_port = port; else iaxci_bound_port = -1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpg...@us...> - 2007-10-30 21:06:07
|
Revision: 1247 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1247&view=rev Author: jpgrayson Date: 2007-10-30 14:06:10 -0700 (Tue, 30 Oct 2007) Log Message: ----------- Fix constness issues. Modified Paths: -------------- trunk/lib/codec_theora.c trunk/lib/slice.c trunk/lib/slice.h Modified: trunk/lib/codec_theora.c =================================================================== --- trunk/lib/codec_theora.c 2007-10-30 20:25:44 UTC (rev 1246) +++ trunk/lib/codec_theora.c 2007-10-30 21:06:10 UTC (rev 1247) @@ -111,7 +111,8 @@ free(c); } -static int decode(struct iaxc_video_codec *c, int inlen, char *in, int *outlen, char *out) +static int decode(struct iaxc_video_codec *c, int inlen, const char *in, + int *outlen, char *out) { struct theora_decoder *d; ogg_packet op; Modified: trunk/lib/slice.c =================================================================== --- trunk/lib/slice.c 2007-10-30 20:25:44 UTC (rev 1246) +++ trunk/lib/slice.c 2007-10-30 21:06:10 UTC (rev 1247) @@ -32,7 +32,7 @@ return 0; } -int slice(char *data, +int slice(const char *data, unsigned int size, struct slice_set_t *slice_set, struct slicer_context *sc @@ -93,7 +93,8 @@ dsc->frame_complete = 0; } -char * deslice(char *in, int inlen, int *outlen, struct deslicer_context *dsc) +char * +deslice(const char *in, int inlen, int *outlen, struct deslicer_context *dsc) { unsigned char frame_index, slice_index, num_slices, version; unsigned short source_id; Modified: trunk/lib/slice.h =================================================================== --- trunk/lib/slice.h 2007-10-30 20:25:44 UTC (rev 1246) +++ trunk/lib/slice.h 2007-10-30 21:06:10 UTC (rev 1247) @@ -77,7 +77,7 @@ * sc - holds stream information such as source id and frame index * Returns 0 if completed successfully or a negative value if failure. */ -int slice(char *data, +int slice(const char *data, unsigned int size, struct slice_set_t *slice_set, struct slicer_context *sc @@ -103,6 +103,7 @@ * Returns a pointer to a buffer containing the completed frame and updates * outlen with the frame size if successful */ -char * deslice(char *in, int inlen, int *outlen, struct deslicer_context *dsc); +char * +deslice(const char *in, int inlen, int *outlen, struct deslicer_context *dsc); -#endif // __SLICE_H__ +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpg...@us...> - 2008-04-24 13:24:13
|
Revision: 1422 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1422&view=rev Author: jpgrayson Date: 2008-04-24 06:24:06 -0700 (Thu, 24 Apr 2008) Log Message: ----------- Fix analog automatic gain control (AAGC). - Speex changed SPEEX_PREPROCESS_GET_AGC_LOUDNESS to return an int instead of a float; adjust for that change. - Use constants instead of magic numbers in AAGC logic. Modified Paths: -------------- trunk/lib/audio_encode.c trunk/lib/audio_encode.h Modified: trunk/lib/audio_encode.c =================================================================== --- trunk/lib/audio_encode.c 2008-04-23 15:33:35 UTC (rev 1421) +++ trunk/lib/audio_encode.c 2008-04-24 13:24:06 UTC (rev 1422) @@ -170,26 +170,26 @@ if ( (i & 0x3f) == 0 ) { - float loudness; + int loudness; speex_preprocess_ctl(st, SPEEX_PREPROCESS_GET_AGC_LOUDNESS, &loudness); - if ( loudness > 8000.0f || loudness < 4000.0f ) + if ( loudness > AAGC_HOT || loudness < AAGC_COLD ) { const float level = iaxc_input_level_get(); - if ( loudness > 16000.0f && level > 0.5f ) + if ( loudness > AAGC_VERY_HOT && level > 0.5f ) { /* lower quickly if we're really too hot */ - iaxc_input_level_set(level - 0.2f); + iaxc_input_level_set(level - AAGC_DROP_FAST); } - else if ( loudness > 8000.0f && level >= 0.15f ) + else if ( loudness > AAGC_HOT && level >= 0.15f ) { /* lower less quickly if we're a bit too hot */ - iaxc_input_level_set(level - 0.1f); + iaxc_input_level_set(level - AAGC_DROP_SLOW); } - else if ( loudness < 4000.0f && level <= 0.9f ) + else if ( loudness < AAGC_COLD && level <= 0.9f ) { /* raise slowly if we're cold */ - iaxc_input_level_set(level + 0.1f); + iaxc_input_level_set(level + AAGC_RISE_SLOW); } } } Modified: trunk/lib/audio_encode.h =================================================================== --- trunk/lib/audio_encode.h 2008-04-23 15:33:35 UTC (rev 1421) +++ trunk/lib/audio_encode.h 2008-04-24 13:24:06 UTC (rev 1422) @@ -20,6 +20,16 @@ */ #define AUDIO_ENCODE_SILENCE_DB -99.0f +/* AAGC threshold */ +#define AAGC_VERY_HOT 16 +#define AAGC_HOT 8 +#define AAGC_COLD 4 + +/* AAGC increments */ +#define AAGC_RISE_SLOW 0.10f +#define AAGC_DROP_SLOW 0.15f +#define AAGC_DROP_FAST 0.20f + struct iaxc_call; struct iax_event; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpg...@us...> - 2008-04-24 14:18:31
|
Revision: 1423 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1423&view=rev Author: jpgrayson Date: 2008-04-24 07:18:28 -0700 (Thu, 24 Apr 2008) Log Message: ----------- Fix problem where media (audio, video, CNG) frames might be sent prior to the call being ACCEPTed. When iaxclient initiates a call, it sends a NEW frame. The server end of the call must send back an ACCEPT frame prior to the call being in the "Linked" state. It is only after the call is in this Linked state that media frames may be transmitted by iaxclient. Note that media frames _are_ allowed to be transmitted prior to the call being ANSWERed (or completed in iaxclient parlance). See this thread for details: http://osdir.com/ml/telephony.pbx.asterisk.iaxclient.devel/2005-08/msg00021.html This modifies iaxclient's decision logic for when it may send audio. Basically either the call has to have been answered (IAXC_CALL_STATE_COMPLETE) or the call has to be outgoing and the audio format set (which happens when the ACCEPT frame comes back from the server). For video, we take the same approach and only allow video to go out after ACCEPT for outgoing calls and after ANSWER (complete) for incoming calls. Without this fix, it is possible for iaxclient to send a NEW and (for example) CNG frames in short succession. The server may then receive the CNG frame first, before the NEW frame. The server sends the correct INVAL response to this call-less CNG frame which results in iaxclient destroying the call and sending a hangup event to the application. This is pretty bad, but then to make things wierder, the server will, of course, receive the NEW frame shortly after the CNG frame and respond to that with an ACCEPT frame. C --> NEW -\/--> S C --> CNG -/\--> S C <-- INVAL <-- S * server received CNG first C <-- ACCEPT <-- S * server responds to NEW second! Modified Paths: -------------- trunk/lib/iaxclient_lib.c trunk/lib/video.c Modified: trunk/lib/iaxclient_lib.c =================================================================== --- trunk/lib/iaxclient_lib.c 2008-04-24 13:24:06 UTC (rev 1422) +++ trunk/lib/iaxclient_lib.c 2008-04-24 14:18:28 UTC (rev 1423) @@ -832,11 +832,13 @@ /* TODO: maybe we shouldn't allocate 8kB on the stack here. */ short buf [4096]; + struct iaxc_call * call = + selected_call >= 0 ? &calls[selected_call] : 0; + int want_send_audio = - selected_call >= 0 && - ((calls[selected_call].state & IAXC_CALL_STATE_OUTGOING) || - (calls[selected_call].state & IAXC_CALL_STATE_COMPLETE)) - && !(audio_prefs & IAXC_AUDIO_PREF_SEND_DISABLE); + call && !(audio_prefs & IAXC_AUDIO_PREF_SEND_DISABLE) && + ((call->state & IAXC_CALL_STATE_COMPLETE) || + (call->format && (call->state & IAXC_CALL_STATE_OUTGOING))); int want_local_audio = (audio_prefs & IAXC_AUDIO_PREF_RECV_LOCAL_RAW) || @@ -852,9 +854,8 @@ audio_driver.start(&audio_driver); /* use codec minimum if higher */ - cmin = want_send_audio && calls[selected_call].encoder ? - calls[selected_call].encoder->minimum_frame_size : - 1; + cmin = want_send_audio && call->encoder ? + call->encoder->minimum_frame_size : 1; to_read = cmin > minimum_outgoing_framesize ? cmin : minimum_outgoing_framesize; @@ -887,10 +888,9 @@ to_read * 2, (unsigned char *)buf); if ( want_send_audio ) - audio_send_encoded_audio(&calls[selected_call], - selected_call, buf, - calls[selected_call].format & - IAXC_AUDIO_FORMAT_MASK, + audio_send_encoded_audio(call, selected_call, + buf, call->format & + IAXC_AUDIO_FORMAT_MASK, to_read); } } @@ -1370,6 +1370,15 @@ codec_destroy( callNo ); + /* When the ACCEPT comes back from the other-end, these formats + * are set. Whether the format is set or not determines whether + * we are in the Linked state (see the iax2 rfc). + * These will have already been cleared by iaxc_clear_call(), + * but we reset them anyway just to be pedantic. + */ + calls[callNo].format = 0; + calls[callNo].vformat = 0; + if ( ext ) { strncpy(calls[callNo].remote_name, num, IAXC_EVENT_BUFSIZ); Modified: trunk/lib/video.c =================================================================== --- trunk/lib/video.c 2008-04-24 13:24:06 UTC (rev 1422) +++ trunk/lib/video.c 2008-04-24 14:18:28 UTC (rev 1423) @@ -668,18 +668,26 @@ call = &calls[selected_call]; - if ( !call || !(call->state & (IAXC_CALL_STATE_COMPLETE | - IAXC_CALL_STATE_OUTGOING)) ) + if ( call->vformat && + ( call->state & IAXC_CALL_STATE_COMPLETE || + call->state & IAXC_CALL_STATE_OUTGOING ) ) { - goto callback_done; + /* For incoming calls, we must ANSWER (complete) the + * call before sending video. For outgoing calls, the + * call must only be ACCEPTed (vformat set) before we + * start sending video. + */ } - - if ( call->vformat == 0 ) + else if ( !call->vformat && call->state & IAXC_CALL_STATE_COMPLETE ) { fprintf(stderr, "video format not set for call %d\n", selected_call); goto callback_failed; } + else + { + goto callback_done; + } if ( !need_encode ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpg...@us...> - 2008-04-24 17:52:45
|
Revision: 1425 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1425&view=rev Author: jpgrayson Date: 2008-04-24 10:52:51 -0700 (Thu, 24 Apr 2008) Log Message: ----------- Merge some cleanups from the echo cancellation branch into trunk. Modified Paths: -------------- trunk/lib/audio_encode.c trunk/lib/audio_encode.h trunk/lib/audio_portaudio.c trunk/lib/iaxclient_lib.c Modified: trunk/lib/audio_encode.c =================================================================== --- trunk/lib/audio_encode.c 2008-04-24 17:15:57 UTC (rev 1424) +++ trunk/lib/audio_encode.c 2008-04-24 17:52:51 UTC (rev 1425) @@ -34,6 +34,8 @@ static float input_level = 0.0f; static float output_level = 0.0f; +int iaxci_sample_rate = 8000; + static SpeexPreprocessState *st = NULL; static int speex_state_size = 0; static int speex_state_rate = 0; @@ -408,3 +410,12 @@ set_speex_filters(); } +int audio_initialize() +{ + return 0; +} + +int audio_destroy() +{ + return 0; +} Modified: trunk/lib/audio_encode.h =================================================================== --- trunk/lib/audio_encode.h 2008-04-24 17:15:57 UTC (rev 1424) +++ trunk/lib/audio_encode.h 2008-04-24 17:52:51 UTC (rev 1425) @@ -15,6 +15,8 @@ #ifndef _AUDIO_ENCODE_H #define _AUDIO_ENCODE_H +extern int iaxci_sample_rate; + /* Minimum dB possible in the iaxclient world. This level * is intended to represent silence. */ @@ -33,6 +35,9 @@ struct iaxc_call; struct iax_event; +int audio_initialize(); +int audio_destroy(); + int audio_send_encoded_audio(struct iaxc_call * most_recent_answer, int callNo, void * data, int iEncodeType, int samples); Modified: trunk/lib/audio_portaudio.c =================================================================== --- trunk/lib/audio_portaudio.c 2008-04-24 17:15:57 UTC (rev 1424) +++ trunk/lib/audio_portaudio.c 2008-04-24 17:52:51 UTC (rev 1425) @@ -33,6 +33,7 @@ #endif #include "audio_portaudio.h" +#include "audio_encode.h" #include "iaxclient_lib.h" #include "ringbuffer.h" #include "portmixer.h" @@ -58,7 +59,6 @@ #define EC_RING_SZ 8192 /* must be pow(2) */ - typedef short SAMPLE; static PaStream *iStream, *oStream, *aStream; @@ -66,15 +66,13 @@ static int selectedInput, selectedOutput, selectedRing; -static int sample_rate = 8000; static int mixers_initialized; - #define MAX_SAMPLE_RATE 48000 #ifndef MS_PER_FRAME -# define MS_PER_FRAME 40 +# define MS_PER_FRAME 20 #endif -#define SAMPLES_PER_FRAME (MS_PER_FRAME * sample_rate / 1000) +#define SAMPLES_PER_FRAME (MS_PER_FRAME * iaxci_sample_rate / 1000) /* static frame buffer allocation */ #define MAX_SAMPLES_PER_FRAME (MS_PER_FRAME * MAX_SAMPLE_RATE / 1000) @@ -124,11 +122,12 @@ #endif /* size in bytes of ringbuffer target */ -#define RBOUTTARGET_BYTES (RBOUTTARGET * (sample_rate / 1000) * sizeof(SAMPLE)) +#define RBOUTTARGET_BYTES (RBOUTTARGET * (iaxci_sample_rate / 1000) * sizeof(SAMPLE)) static char inRingBuf[INRBSZ], outRingBuf[OUTRBSZ]; static rb_RingBuffer inRing, outRing; +/* TODO: This is used without explicit initialization */ static int outRingLenAvg; static int oneStream; @@ -457,11 +456,10 @@ PaStreamCallbackFlags statusFlags, void *userData) { + short virtualInBuffer[MAX_SAMPLES_PER_FRAME]; + short virtualOutBuffer[MAX_SAMPLES_PER_FRAME]; int totBytes = samplesPerFrame * sizeof(SAMPLE); - short virtualInBuffer[MAX_SAMPLES_PER_FRAME * 2]; - short virtualOutBuffer[MAX_SAMPLES_PER_FRAME * 2]; - #if 0 /* I think this can't happen */ if(virtualMono && samplesPerFrame > SAMPLES_PER_FRAME) { @@ -600,7 +598,7 @@ err = Pa_OpenStream(&iStream, &in_stream_params, &out_stream_params, - sample_rate, + iaxci_sample_rate, paFramesPerBufferUnspecified, //FEEBACK - unsure if appropriate paNoFlag, (PaStreamCallback *)pa_callback, @@ -613,7 +611,7 @@ err = Pa_OpenStream(&iStream, &in_stream_params, &no_device, - sample_rate, + iaxci_sample_rate, paFramesPerBufferUnspecified, //FEEBACK - unsure if appropriate paNoFlag, (PaStreamCallback *)pa_callback, @@ -623,7 +621,7 @@ err = Pa_OpenStream(&oStream, &no_device, &out_stream_params, - sample_rate, + iaxci_sample_rate, paFramesPerBufferUnspecified, //FEEBACK - unsure if appropriate paNoFlag, (PaStreamCallback *)pa_callback, @@ -714,7 +712,7 @@ err = Pa_OpenStream(&aStream, NULL, &ring_stream_params, - sample_rate, + iaxci_sample_rate, paFramesPerBufferUnspecified, //FEEBACK - unsure if appropriate paNoFlag, (PaStreamCallback *)pa_aux_callback, @@ -728,7 +726,7 @@ err = Pa_OpenStream(&aStream, NULL, &ring_stream_params, - sample_rate, + iaxci_sample_rate, paFramesPerBufferUnspecified, //FEEBACK - unsure if appropriate paNoFlag, (PaStreamCallback *)pa_aux_callback, @@ -1092,7 +1090,7 @@ { PaError err; - sample_rate = sr; + iaxci_sample_rate = sr; /* initialize portaudio */ if ( paNoError != (err = Pa_Initialize()) ) Modified: trunk/lib/iaxclient_lib.c =================================================================== --- trunk/lib/iaxclient_lib.c 2008-04-24 17:15:57 UTC (rev 1424) +++ trunk/lib/iaxclient_lib.c 2008-04-24 17:52:51 UTC (rev 1425) @@ -626,6 +626,7 @@ if ( !test_mode ) { + audio_initialize(); #ifndef AUDIO_ALSA if ( pa_initialize(&audio_driver, 8000) ) { @@ -672,6 +673,7 @@ if ( !test_mode ) { audio_driver.destroy(&audio_driver); + audio_destroy(); #ifdef USE_VIDEO video_destroy(); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |