最近有一個語言項(xiàng)目方面的調(diào)研,需要評估一下libjingle,所以研究了半個月的libjingle,現(xiàn)在把經(jīng)驗(yàn)總結(jié)如下(如有不對,請不吝賜教):
1、libjingle庫所帶例子只支持rtpdump文件傳遞語音,不支持實(shí)時語音通話;
2、最新的幾個版本的libjingle庫去掉了GIPS voiceEngine的相關(guān)部分(可能是因?yàn)間oogle收購了GIPS);
3、那么在windows下要支持實(shí)時語音通話,可以用linphone media engine,不過這個庫是linux下的,所以遷移過來會費(fèi)不少精力(不知有沒有更好的方法):
要想在windows下用linphone media engine, 首先,按照README的說明添加如下代碼:
Add the following lines into the libjingle.scons file.
In the "talk.Library(env, name = "libjingle",..." section, you need to add:
"HAVE_LINPHONE",
"HAVE_SPEEX",
"HAVE_ILBC",
to the "cppdefines = [".
add:
"session/phone/linphonemediaengine.cc",
to the "srcs = [ ..."
add:
"third_party/mediastreamer/include",
"third_party/ortp/include"
to the "includedirs = [ ..."
In the "talk.App(env, name = "call",..." section, you need to add:
"ortp"
"mediastreamer",
to the "libs = [".
然后,
訪問http://download.savannah.gnu.org/releases-noredirect/linphone/ortp/sources/下載ortp代碼,
訪問http://download.savannah.gnu.org/releases-noredirect/linphone/mediastreamer/下載mediastreamer,
并復(fù)制到libjingle庫的third_party中,文件夾名需與上一步添加的路徑名一致。
在windows下需要dll,所以還得編譯兩個庫的dll,方法轉(zhuǎn)自:
http://www.cnblogs.com/joiner/archive/2010/06/18/1759941.html Mingw&msys的手動安裝;
http://www.cnblogs.com/joiner/archive/2010/06/18/1759943.html Mingw&msys環(huán)境中編譯mediastreamer2和ortp。
接著,
copy .lib文件到talk\build\dbg\lib目錄,
copy .dll到talk\build\dbg\staging目錄。
然后,修改libjingle庫的socketaddress.cc里的一個bug,參考http://mysuperbaby.iteye.com/blog/910830
增加紅色,解決域名轉(zhuǎn)IP的問題:
bool SocketAddress::StringToIP(const std::string& hostname, uint32* ip) {
in_addr addr;
struct hostent *host;
if (isalpha(hostname.c_str()[0]))
{
host = gethostbyname(hostname.c_str());
if (host == NULL)
{
printf("gethostbyname error\n");
return false;
}
memcpy(&addr.s_addr, host->h_addr_list[0],host->h_length);
}
else if (inet_aton(hostname.c_str(), &addr) == 0)
{
return false;
}
*ip = NetworkToHost32(addr.s_addr);
return true;
}
按照README的方法,編譯。
通過后運(yùn)行call.exe,與Gtalk通話。
如果音質(zhì)不好,斷斷續(xù)續(xù),可以在mingw&msys下,
移除 winsnd2.c 添加winsnd3.c 重新編譯ortp庫。
還有就是關(guān)于receiving RTCP packet: Connection reset by peer. 參考http://mysuperbaby.iteye.com/blog/911159
這篇文章,也沒有解決,不過不影響音質(zhì)。