2008年9月8日 星期一

Opensource SIP Stak compared

Martin van den Berg, August 2004.
I've spend some time looking at open-source SIP stacks. There are more open-source SIP stacks on the net than described here! I was only looking at those having a LGPL alike license and written in C or C++.
The information presented on this page are my personal findings, syntisized from the resp. websites, mailing lists and sources. If you find an error or have comments or additions, please let me know: martinvdberg@gmail.com
The candidate stacks, documented in following subsections are:
* OPAL As a dual stack SIP and OpenH323, OPAL is the successor of OpenH323.
* VOCAL A stack primary used in servers - has a relationship with Cisco.
* sipX Pingtel its SIP stack, contributed to the SIPfoundry.
* reSIProcate A object oriented SIP library, written in C++. Spin-off of the VOCAL project.
* oSIP An ANSI C library, leaves control to the application.

OPAL

OPAL is the Open Phone Abstraction Library, and is the successor to OpenH323. There were a couple of architectural issues in OpenH323, especially in the area of the codecs and media channels, that required a major rewrite. OPAL is designed to be an infrastructure for any protocol, not just H.323. It enables normalized interfaces so an application can quickly use a range of "call protocols", be it H.323, SIP, PSTN hardware, PC sound cards, MGCP or whatever proprietary protocol might exist. They all look the same to the application. OPAL and OpenH323 under Mozilla Public License (MPL). A prototype SIP implementation is also included.
The long-term goal is to use OPAL instead of openH323 as primary development library. A release with verified working SIP and OpenH323 was planned in mid June 2004. At this point OPAL is in an experimental phase.
OpenH323 is big in footprint and code. A lot of functionality is covered, especially for H.323 but codecs, RTP and SDP are also included. OPAL is planned to better support re-use or removal of sub-components. The community that uses and supports OpenH323 is large. The mailing list shows a lot of activity but has its focus primarily at H.323 instead of SIP.
The whole project relies on a platform abstraction layer: the PWLIB. This library is ported (and supported) onto many platforms including VxWorks, Linux, Win32 etc...
Although the structure of the library is complex, the quality of the code looks good. It is coded in C++ and depends mainly on class hierarchies. The OPAL library is designed to realize either User Agents (endpoints), proxies (gateways) or registrars, any other than that will result in modifications.
VOCAL
VOCAL is an open-source VoIP project, hosted en contributed by Vovida.org. Vovida.org is a communications community site dedicated to providing a forum for open source software used in datacom and telecom environments. Vovida.org is a unit of Cisco.
VOCAL is not just a stack; it provides the building blocks for a VoIP system. The focus is mainly on servers such as proxy servers, redirect servers, H323-SIP translators etc... Supported platforms are Lunix and Solaris. The SIP stack however is available as a C++ object oriented library. At this moment, the stack is only partially RFC3261 compliant. The latest VOCAL version (v.1.5.0) dates from April 2003. Although not up to date, a little bit of documentation is available.
Support is available via mailing lists, which is moderated and low volume. Questions like "what features does the stack support" are unfortunately blocked. Therefore, not all facts of this stack are known.
SipX
SipX is a family of SIP related projects, hosted by SIPFoundry. SipX is completely separate from reSIProcate (also hosted by the SIPfoundry). Pingtel contributed SipX to the SIPFoundry (Feb 2004). Actually, Pingtel formed the SIPfoundry nonprofit organization to shepherd efforts to create open-source IP telephony, messaging, presence and collaboration software. Pingtel is a commercial company that makes VOIP softphones and PBX software.
The sipXtacklib is a C++ object oriented SIP stack library, licensed under LGPL. Stable releases are available.
The SipX stack is small but functional and is being used in commercial products. The stack is also designed to function in an embedded environment. The open source software however, does not include the VxWorks port. Within the SipX family a registrar, proxy and softphone are available that use the sipXtacklib. The total footprint size is approx. 4Mb, excluding features can reduce this and stripping libraries like glib.
SipX is likely to be more portable than reSIProcate since it doesn't use advanced C++ features. Like other open source projects, the libraries looked at (sipXtacklib and sipXportLib) are poorly documented. Help however is available via the mail list.
ReSIProcate
Around 2 years ago, some people got together to write a C++ SIP stack that was supposed to be a clean slate 3261-based design. This lead to vocal2, hosted within the VOCAL project (but it has never shared any core design with the VOCAL code-base). One thing led to another and the project left the VOVIDA SCM umbrella and was reborn at www.resiprocate.org using sourceforge's project tools, but independent SCM (CVS). Time passed and PingTel announced their Open Source initiative, inviting other VoIP (and specifically SIP) related projects to participate. The reSIProcate team decided, in favour of visibility to be a part of the SipFoundry - as a separate project under the SipFoundry umbrella.
reSIProcate is a high performance, object-oriented, C++ sip stack that is compliant with RFC 3261. It includes support for a wide variety of operating systems, including Windows and Linux. It has full support for UDP, TCP, and TLS transports on both IPv4 and IPv6. It also implements the full set of specifications for DNS usage in SIP, including NAPTR and SRV lookups (RFCs: 3263, 2915, 2782) using an asynchronous DNS library (ares).
The reSIProcate project (at this time) is really mostly a stack and not a set of applications & stack like some other SIP projects. reSIProcate is currently used in commercial products and is quite stable. reSIProcate is suitable for implementing one of the following SIP applications:
* Phones (e.g. embedded);
* Softphones (any platform);
* Gateways;
* Proxies;
* B2buas, or;
* IM / Presence Servers or Clients.
Commercial deployments are:
* PurpleComm (
www.purplecomm.com)
o SipDragon: Proxy, Registrar, Voicemail, Presence Server
o Windows Softphone (
http://meet2talk.com)
* Jasomi Networks (
www.jasomi.com)
o PeerPoint * CSP - Italy (
www.csp.it)
o IM/Audio/Video UA for Windows
o Conference Server and h.323 gateway in development
* Computer Talk Technology (
www.computer-talk.com)
o Evaluating use of resiprocate for Contact Center product
A reSIProcate VxWorks port is not available. It is possible to port the library under the condition that a modern compiler is used that complies with the "ANSI 2000 C++" standard since not all compilers (fully) support the partial specializations and template operations used. E.g. it is reported to be build by gcc-2.95 and VC7.0 but cannot be build by VC6.0.
The library relies of two other open source initiatives: Ares (DNS resolver) and openssl (TLS). ReSIProcate is poorly documented but has a relatively active mail list. At first glance, the library does not seem to be designed for embedded systems.
oSIP
(from http://www.gnu.org/software/osip/)
The oSIP project has started in July 2000. The first official and public release was published in May 2001.
The oSIP library is at first a free software project. In the context of the third generation network, more and more telecom operators will use IP technology, the favorite land of Linux. One aspect of this evolution is that the future of Linux is highly dependent on the multimedia tools that will be available. oSIP, as a SIP implementation, will allow building interoperable registrar, user-agent (software phones), and proxy thus giving more chance to Linux to be part of the next generation telephony products.
But oSIP is not only targeted towards PC applications. oSIP is enough flexible and tiny to be used on small OS with low requirements. From the 0.7.0 release, the thread support is now optional and the design of the application is entirely chosen by the end-developer. oSIP will fit embedded systems. oSIP is known to run on the real time OS VxWorks and other ports should be simple.
The oSIP stack is a flat ANSI-C library. Its footprint is less than 400kb for a win32 compile. The oSIP stack doesn't offer a full-blown SIP solution. Instead it provides a message parser and API only. It has no OS dependencies. Creation of threads, sockets etc... are left to the application. In other words, oSIP doesn't force a specific architecture, threading- or socket usage.
oSIP, in fact, is made up out of three separate libraries. First, there is the parser, capable of reading and writing SIP and SDP messages. The second is a transaction/session manager, which provides state machines. The API of the latter is low-level so a third library is provided that provides a higher-level API but has a GPL license.
Open-source implementations based upon oSIP are:
* linphone - a linux softphone
* partysip - SIP proxy/registrar/redirect server
* siproxd - simple linux SIP proxy
從最後的comparision看來,他是推薦osip: 又小,功能又齊,u又os independent.

2008年8月27日 星期三

[轉貼]BCB 控制 USB

#include <vcl.h>
#include <dir.h>
#include <setupapi.h>
#include "C:/WINDDK/3790/inc/ddk/w2k/usbdi.h"
#include "C:/WINDDK/3790/inc/ddk/w2k/devioctl.h"
#include <initguid.h>
//---------------------------------------------------------------------------
// 下面必須為驅動程式的 GUID 值, 這裡我亂寫的數
DEFINE_GUID(USB_DRIVER_GUID, 0x12345678,0xabcd,0x1122,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0x00);
//---------------------------------------------------------------------------
HANDLE OpenOneDevice(HDEVINFO hDvcInfo, PSP_INTERFACE_DEVICE_DATA DvcInfoData, char *sDevNameBuf)
{
  HANDLE hOut = INVALID_HANDLE_VALUE;

  ULONG  iReqLen = 0;
  SetupDiGetInterfaceDeviceDetail(hDvcInfo, DvcInfoData, NULL, 0, &amp;iReqLen, NULL);

  ULONG iDevDataLen = iReqLen; //sizeof(SP_FNCLASS_DEVICE_DATA) + 512;
  PSP_INTERFACE_DEVICE_DETAIL_DATA pDevData = (PSP_INTERFACE_DEVICE_DETAIL_DATA)malloc(iDevDataLen);

  pDevData-&gt;cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);
  if(SetupDiGetInterfaceDeviceDetail(hDvcInfo, DvcInfoData, pDevData, iDevDataLen, &amp;iReqLen, NULL))
   {
     strcpy(sDevNameBuf, pDevData-&gt;DevicePath);
     hOut = CreateFile(pDevData-&gt;DevicePath, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
   }

  free(pDevData);
  return hOut;
}
//---------------------------------------------------------------------------
HANDLE OpenUsbDevice(const GUID *pGuid, char *sDevNameBuf)
{
  HANDLE hOut = INVALID_HANDLE_VALUE;

  HDEVINFO hDevInfo = SetupDiGetClassDevs(pGuid, NULL, NULL, DIGCF_PRESENT|DIGCF_INTERFACEDEVICE);

  SP_INTERFACE_DEVICE_DATA deviceInfoData;
  deviceInfoData.cbSize = sizeof (SP_INTERFACE_DEVICE_DATA);

  ULONG nGuessCount = MAXLONG;
  for(ULONG iDevIndex=0; iDevIndex
   {
     if(SetupDiEnumDeviceInterfaces(hDevInfo, 0, pGuid, iDevIndex, &amp;deviceInfoData))
      {
        if((hOut=OpenOneDevice(hDevInfo, &amp;deviceInfoData, sDevNameBuf)) != INVALID_HANDLE_VALUE)
          break;
      }
     else if(GetLastError() == ERROR_NO_MORE_ITEMS) //No more items
      {
        break;
      }
   }
  SetupDiDestroyDeviceInfoList(hDevInfo);
  return hOut;
}
//---------------------------------------------------------------------------
bool GetUsbDeviceFileName(const GUID *pGuid, char *sDevNameBuf)
{
  HANDLE hDev = OpenUsbDevice(pGuid, sDevNameBuf);
  if(hDev != INVALID_HANDLE_VALUE)
   {
     CloseHandle(hDev);
     return true;
   }
  return false;
}
//---------------------------------------------------------------------------
HANDLE OpenMyDevice()
{
  char DeviceName[MAXPATH] = "";
  return OpenUsbDevice(&amp;USB_DRIVER_GUID, DeviceName);
}
//---------------------------------------------------------------------------
HANDLE OpenMyDevPipe(const char *PipeName)
{
  char DeviceName[MAXPATH] = "";
  if(GetUsbDeviceFileName(&amp;USB_DRIVER_GUID, DeviceName))
   {
     strcat(DeviceName,"\\");
     strcat(DeviceName,PipeName);
     return CreateFile(DeviceName, GENERIC_WRITE|GENERIC_READ, FILE_SHARE_WRITE|FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
   }
  return INVALID_HANDLE_VALUE;
}
//---------------------------------------------------------------------------


//打開 USB 口讀寫, 由驅動程式的 Pipe 名確定 

HANDLE hPipe = OpenMyDevPipe("MyPipe1"); //驅動程式裡面的 Pipe 名, 對應訪問某個端點的 I/O, 這裡我亂寫的, 需要與驅動一致
if(hPipe != INVALID_HANDLE_VALUE) //打開 Pipe 成功
 {
   ReadFile(hPipe, Buffer, BufSize, &amp;nBytesRead, NULL); //從 hPipe 裡讀取數據到 Buffer 裡
   //WriteFile(hPipe, Buffer, BytesToWrite, &amp;nBytesWritten, NULL); //把 Buffer 裡面的 BytesToWrite 位元組寫入 hPipe
   CloseHandle(hPipe);
 }

//使用 DeviceIoControl 訪問 USB 設備

HANDLE hDevice = OpenMyDevice();
if(hDevice != INVALID_HANDLE_VALUE) //打開設備成功
 {
   //這些 DeviceIoControl 功能都是由設備定義的, 具體看設備和驅動的資料
   if(DeviceIoControl(hDevice, IOCTL_READ_xxxx, &amp;IOBlock, sizeof(IOBLOCK), &amp;c, 1, &amp;nBytes, NULL))
    {
      //成功
    }
   CloseHandle(hDevice);
}

USB 設備、USB 驅動、USB 應用程式

1.USB 設備硬體部分
  a.這個硬體的標識是用的 Vender ID 和 Product ID, 即“廠家標識”和“產品標識”
  b.這個硬體規定了各個 End Point (端點) 的性質, 讀/寫 及 類型 (Control/Interrupt/Bulk/Isochronous)
  c.這個硬體的固件裡面有 DeviceIoControl 的實現部分, 規定了這個函數的具體參數和動作
2.USB 設備驅動
①硬體介面
  a.需要識別 Vender ID 和 Product ID
  b.對每個 EndPoint 的每個 I/O 分配一個 Pipe, 並且起一個名字作為軟體介面
  c.做 DeviceIoControl 的介面
②軟體介面
  a.GUID, 驅動程式的標識, 每個驅動程式使用不同的 GUID, GUID 是識別驅動的, 與硬體無關 (驅動程式升級版本 GUID 不能修改)
  b.硬體介面裡面的 b: Pipe 名字是軟體介面, 這個 Pipe 名字純粹由驅動定義的, 和硬體無關, 升級驅動不能改 Pipe 的名字
  c.硬體介面裡面的 c 的各個參數也是軟體的介面, 這些參數是由硬體帶來的, 不是驅動規定的, 當然也可以在驅動裡面轉義, 隱藏設備的真實情況
③這個驅動程式是用 WinDDK 編譯的, 可以用文字編輯器或其他開發工具的編輯器編程式碼, 然後調用 WinDDK 編譯
3.讀寫 USB 口的程式
①與驅動的介面
  a.利用驅動程式裡面的 GUID 找出設備的檔案名, 用 CreateFile 函數打開設備。我前面的程式裡面的 OpenUsbDevice 就是這個作用
  b.通過 a.得到的設備檔案名和驅動程式裡面的 Pipe 名打開 Pipe, 訪問這個 Pipe 對應的 USB 端點 (讀寫資料)
  c.使用 a.的 CreateFile 得到的控制碼, 通過 DeviceIoControl 實現設備規定的動作
②有關需要的資料
  a.Vender ID, Product ID 和 GUID 一般在驅動程式的 .inf 檔裡面能看到, 如果找不到就需要和廠家聯繫
  b.Pipe 的名字是驅動程式規定的, 需要有驅動程式的資料才能知道
  c.DeviceIoControl 的參數需要有驅動程式的資料或者硬體資料才能知道
③這個程式一般用 C/C++ 直接編寫, 如果使用其他語言(VB/PB等)需要調用 C/C++ 編的 DLL


其他相關內容:

USB 驅動程式可以到註冊表裡面找到:
"HKEY_LOCAL_MACHINE\\SYSTEM\\ControlSet001\\Enum\\USB\\Vid_廠家標識&amp;Pid_產品標識\\驅動程式"

裡面的 ClassGUID 就是驅動程式的 GUID 標識, 例如 {36FC9E60-C465-11CF-8056-444553540000}
相當於程式的: DEFINE_GUID(USB_DRIVER_GUID, 0x36FC9E60,0xC465,0x11CF,0x80,0x56,0x44,0x45,0x53,0x54,0x00,0x00);
另外在這個註冊表鍵裡面還可找到有關設備的其他描述, 例如 DeviceDesc = "USB Mass Storage Device" 等

Real-Time Tracking Of Human Eyes Using a Webcam

http://www.codeproject.com/KB/cpp/TrackEye.aspx

OpenCV cam

http://yester-place.blogspot.com/2008/06/gui-cvcamh.html

2008年8月26日 星期二

OpenCV

http://finalevil.blogspot.com/2008/03/opencv02c-builderbcbopencv.html

[轉貼]在ARM9(s3c2410)上移植GUI系統(gtk+ 與 DirectFb)

==================================================== 文檔名:在ARM9(s3c2410)上移植GUI系統(gtk+ 與 DirectFb) 文檔撰寫人:盧名揚(chinalmy) 第一次完成日期:2008_08_06 E-mail:chinalmy@yahoo.com.cn 附加: 由於下學期大四要找工作了,所以比較忙。只是做一些筆記性的記錄。再加上整個GUI系統移植後還有許多問題。在9月初將整理一份詳盡的"How -To"文檔。但是我能保證的是,所有步驟沒有隱瞞或者遺漏。如果你遇到困難,可以與我聯繫,很樂意與你交流。更加歡迎留言或來信批評指正,謝 謝。 另外,這份文檔只有參考價值。如果你完全按照步驟來完成交叉編譯工作,難度比較大。如果你比較忙的話,我很樂意把交叉編譯好的“GTK-DFB”文檔,與你分享,當作一個參考。歡迎來信索取。!~(為了交流方便,我的手機是:13851807025) ==================================================== 近期完成了 GTK+ 與 DirectFB 往ARM9上的移植。 我開發平臺是:Magic2410(廣東周立功生產) Fedora8 (完整安裝方式) 我所用的軟體:Gtk-DFB相關: 1:zlib-1.2.3.tar.bz2 2:libpng-1.2.19.tar.bz2 3:glib-2.12.13.tar.bz2 4:atk-1.19.3.tar.bz2 5:freetype-2.3.5.tar.bz2 6:libxml2-2.6.30.tar.gz 7:fontconfig-2.4.2.tar.gz 8:jpegsrc.v6b.tar.gz 9:DirectFB-1.0.0.tar.gz 10:cairo-1.4.12.tar.gz 11:pango-1.16.5.tar.gz 12:gtk+-2.10.14.tar.bz2 交叉編譯相關: arm-linux-gcc-3.4.1.tar.bz2 環境變數: export target=arm-linux export PATH=$PATH:/home/chinalmy/gtk_dfb/arm_tool_arm_3.4.1/bin export PREFIX=/home/chinalmy/gtk_dfb/target export LD_LIBRARY_PATH=/home/chinalmy/gtk_dfb/target/lib export PKG_CONFIG_PATH=/home/chinalmy/gtk_dfb/target/lib/pkgconfig export PATH=$PREFIX/bin:$PATH 步驟: --------------------------------------------------------- 說明:其中“./configure”與“make”並不是直接執行的命令,後接有具體參數,為了清晰的緣故,詳請見附錄一。 --------------------------------------------------------- ①zlib-1.2.3.tar.bz2 ↓./configure ↓make clean ↓make ↓make install --------------------------------------------------------- --------------------------------------------------------- ②libpng-1.2.19.tar.bz2 ↓./configure ↓make clean ↓make ↓make install --------------------------------------------------------- --------------------------------------------------------- ③glib-2.12.13.tar.bz2 ↓在configure中找到“cannot run test program while cross compiling”與“cross-compiling”,並把各自所在行的下方的“{ (exit 1); exit 1; };”去掉。 ↓./configure ↓修改 glib/giounix.c 中的 #include ↓make clean ↓make ↓make install --------------------------------------------------------- --------------------------------------------------------- ④atk-1.19.3.tar.bz2 ↓./configure ↓修改MakeFile 中的 glib_genmarshal 為 /usr/bin/glib_genmarshal ↓exit ↓去掉 export LD_LIBRARY_PATH=/home/chinalmy/gtk_dfb/target/lib ↓重新設定刪減後的環境變數 ↓make clean ↓make ↓make install ↓加上 export LD_LIBRARY_PATH=/home/chinalmy/gtk_dfb/target/lib --------------------------------------------------------- --------------------------------------------------------- ⑤freetype-2.3.5.tar.bz2 ↓./configure ↓make clean ↓make ↓make install --------------------------------------------------------- --------------------------------------------------------- ⑥libxml2-2.6.30.tar.gz ↓./configure ↓make clean ↓make ↓make install --------------------------------------------------------- --------------------------------------------------------- ⑦fontconfig-2.4.2.tar.gz ↓./configure ↓exit ↓去掉 export LD_LIBRARY_PATH=/home/chinalmy/gtk_dfb/target/lib ↓重新設定刪減後的環境變數 ↓make clean ↓make ↓make install ↓加上 export LD_LIBRARY_PATH=/home/chinalmy/gtk_dfb/target/lib --------------------------------------------------------- --------------------------------------------------------- ⑧jpegsrc.v6b.tar.gz ↓./configure ↓make clean ↓make ↓make install ↓make install_lib ↓make install_headers --------------------------------------------------------- --------------------------------------------------------- ⑨DirectFB-1.0.0.tar.gz ↓./configure ↓make clean ↓make ↓make install --------------------------------------------------------- ⑩cairo-1.4.12.tar.gz ↓./configure ↓make clean ↓make ↓make install ↓新增以下 lib 到 cairo.pc 中: -lfreetype -lfontconfig -ldirectfb -lz -ldirect -lpng12 -lxml2 -lfusion --------------------------------------------------------- ①①pango-1.16.5.tar.gz ↓./configure ↓make clean ↓make ↓make install ↓添加以下lib到pango.pc中: -lglib-2.0 -lgmodule-2.0 -lgobject-2.0 添加以下lib到pangocairo.pc中: -lpangoft2-1.0 ↓製造pango.modules(詳見附錄二) --------------------------------------------------------- ①②gtk+-2.10.14.tar.bz2 ↓./configure ↓exit ↓去掉 export LD_LIBRARY_PATH=/home/chinalmy/gtk_dfb/target/lib export PATH=$PREFIX/bin:$PATH ↓重新設定刪減後的環境變數 ↓make clean ↓make ↓make install ↓如果你在編譯的過程中遇到jpeg 出錯無法通過的話,sorry我還沒有解決這個問題。你可以在"configure"中把他遮罩掉(加上--without-libjpeg ) ↓如果你在編譯的過程中遇到png 出錯無法通過的話,那麼請把/include/下的“zlib.h”“zconf”copy到/libpng12/下 ↓製造gdk_pixbuf.loaders -> 到“etc/gtk-2.0/” 下(見附錄二) --------------------------------------------------------- --------------------------------------------------------- 大結局::) 至此,整個GTK-DFB 圖形系統製造完畢,目前你需要解決字體的問題,在arm9開發箱上的顯示全是“小方框”。 英文字體(就是尾碼ttf的東西),到處都有就不多說了;中文字體我用的是winxp下的“仿宋”(3M大小)。效果還不錯`~呵呵 把字體放到你的"etc/font"下麵confgure 檔所指向的檔目錄下。 等等!你還需要把交叉編譯工具鏈中的“librt*”一共四個文件copy到“/lib”中。(有可能是我所用交叉編譯器的原因)