`

port exosip to android

    博客分类:
  • SIP
阅读更多

http://blog.csdn.net/rx_wen/archive/2010/12/19/6085411.aspx

 

Port exosip to android platform isn't a difficult task because exosip doesn't rely on any special system calls that aren't available on android. It only requires osip to compile, which can also be easily ported.
As an example, I created two applications to run against exosip lib. One is a native application that can run in android shell, the other is an java application that interact with exosip through jni. The dependency relationship between modules is:


The diagram below depicts the organization of files. They're organized this way so that they can be compiled through android ndk build system.

exosip_root (NDK_MODULE_PATH environment variable points here)

To comply with ndk build system's requirements, we create a directory named jni under sip_jni and sip_exe module, and place actual source file there. The Android.mk and Application.mk (optional) are placed in the jni directory as well. Keeping files this way, we can issue ndk-build command right in sip_jni or sip_exe directories to compile applications.
Note that we don't create jni directory for libosip and libexosip, their Android.mk is placed directly under libosip and libexosip directories. This is because they are dependent on by application modules. We don't need compile them directly, instead, the build system will build them automatically while building applications. In order to help build system find libosip and libexosip, we must set NDK_MODULE_PATH environment variable to the directory that directly containing  libosip and libexosip. The build system will search for them based on directory name, so their names matter.

To port exosip to android, the essential task is to create the Android.mk file, which specifies source files, c flags, ld flags, dependent libraries. We define HAVE_TIME_H and HAVE_SYS_SELECT_H to compile exosip successfully. And we define ENABLE_TRACE and OSIP_MT to enable logging and multi-threading. In the last line, $ ( call import - module , libosip ) tells the build system that exosip depends on osip, and all header files exported by osip ( LOCAL_EXPORT_C_INCLUDES := $ ( LOCAL_C_INCLUDES ) )  will be included by exosip automatically. 
import-module is a feature that isn't available in the build system in android source tree. It enables us organizing our projects in arbitrary manner. For example, we can place libosip and libexosip directories in another directory. The build system can still find them as long as NDK_MODULE_PATH is set to the directory containing them. It's much more flexible than specifying dependency relationship with relative path.

Sample:
The sample for this post is available at:
http://code.google.com/p/rxwen-blog-stuff/source/browse/trunk/android/exosip_sample/
It shows how to:

  1. use ndk build system
  2. use stl in c++ code
  3. create a very basic exosip application
  4. call native code from java
  5. call java code from native code

References:
ndk document
exosip user manual

分享到:
评论
2 楼 hgy1234 2011-09-14  

折腾了一整天,总算整明白了!

注意:
osip的源码目录必须是libosip,不能是osip;
eXosip的源码目录必须是libexosip,不能是eXosip。

编译过程的触发:
cd $ANDROID_NDK_ROOT
export NDK_MODULE_PATH=<工程目录>
./ndk-build -C $NDK_MODULE_PATH/sip_jni

Compile thumb  : exosip <= eXtl_tcp.c
<工程的目录>/libexosip/src/eXtl_tcp.c: In function '_tcp_tl_connect_socket':
<工程的目录>/libexosip/src/eXtl_tcp.c:1021: error: 'F_GETFL' undeclared (first use in this function)

类似的F_SETFL, O_NONBLOCK找不到头文件fcntl.h,
由于andriod重新编写了fcntl.h,并放在$ANDROID_NDK_ROOT/platforms/android-X/arch-arm/usr/include/asm-generic
所以,我以为修改$NDK_MODULE_PATH/libexosip/Android.mk
-        LOCAL_C_INCLUDES:= $(LOCAL_PATH)/include $(LOCAL_PATH)/src #\
+        LOCAL_C_INCLUDES:= $(LOCAL_PATH)/include $(LOCAL_PATH)/src \
-          $(LOCAL_PATH)/../libosip/include
+          $(ANDROID_NDK_ROOT)/platforms/android-3/arch-arm/usr/include/asm-generic
发现还是不行。

后来发现修改:
         LOCAL_CFLAGS += -DHAVE_TIME_H \
+                        -DHAVE_FCNTL_H \
-DHAVE_SYS_SELECT_H \
-DENABLE_TRACE \
-DOSIP_MT
问题就解决了,哈哈!
1 楼 hgy1234 2011-09-13  
能否给出主makefile的示例,即$NDK_MODULE_PATH/makefile,谢谢!

相关推荐

    使用Android NDK编译Android平台的eXosip库

    在Android平台上开发VoIP或SIP(Session Initiation Protocol)应用时,eXosip库是一个重要的组件。本文将深入探讨如何使用Android NDK(Native Development Kit)来编译适用于Android平台的eXosip库,包括静态库和...

    eXosip-build-android.sh

    使用ndk编译eXosip安卓端库执行脚本,ndk编译需要指定configure参数及设置相关路径,

    exoSip-manual.rar_exosip

    **exoSip 开发者手册** exoSip是一款开源的SIP(Session Initiation Protocol)栈,用于在各种网络应用程序中实现VoIP、多媒体通信和其他基于SIP的服务。本手册将深入探讨exoSip的开发流程,调用方法以及相关的宏...

    exOsip使用

    【exOsip 使用详解】 exOsip 是一个基于 OSIP(Open Session Initiation Protocol)库的开源 SIP(Session Initiation Protocol)应用框架。SIP 是一种互联网协议,用于建立、修改和终止多媒体通信会话,如语音通话...

    exosip开发手册.pdf

    9. **平台兼容性**:Exosip支持多种操作系统,如Linux、Windows、Android等。了解不同平台的特性,以及如何在不同环境下部署和使用Exosip,可以提高代码的可移植性。 10. **实战应用**:通过实际项目来实践Exosip...

    uac.zip_ eXosip2_exosip_exosip uac windows_josua user agent_sip

    标题中的"uac.zip_ eXosip2_exosip_exosip uac windows_josua user agent_sip"揭示了这个压缩包内容的核心:它包含了一个与User Account Control(UAC)相关的Windows应用程序,该程序基于eXosip2库,实现了SIP...

    eXosip2 源码 v4.0.0

    **eXosip2源码 v4.0.0 知识点详解** eXosip2是一款基于OSIP(Open SIP Interface)协议栈的开源SIP(Session Initiation Protocol)库,它提供了完整的SIP应用程序开发框架。SIP是一种用于多媒体通信的互联网标准...

    eXosip开发者手册

    《eXosip开发者手册》是一本专注于eXosip2协议栈的使用指南,它为开发者提供了详尽的接口说明和操作步骤。eXosip2是一个强大的SIP(Session Initiation Protocol)堆栈,用于处理SIP通信中的各种事务,如呼叫建立、...

    exoSip开发手册.pdf

    exoSip开发手册.pdf

    EXOSIP终端注册程序

    2. **SIP消息构造**:构建REGISTER请求消息,包括添加必要的头字段,如From、To、Call-ID、CSeq和Contact。 3. **发送与接收**:使用EXOSIP API发送REGISTER请求,并处理服务器返回的响应,如200 OK表示注册成功,...

    exoSip 开发者手册

    1.1 How-To initialize libeXosip2 初始化libeXosip2是建立与exoSip栈交互的第一步。这通常涉及设置全局配置参数,如端口号、代理服务器地址等,并创建一个上下文对象,供后续的SIP操作使用。 1.2 Call Management...

    【最新】Linux平台: 基于osip eXosip库的服务器, 客户端源码, 可以编译通过,正常使用修改IP地址就可以了

    在本文中,我们将深入探讨如何在Linux平台上使用osip和eXosip库构建服务器和客户端应用程序。osip(OpenSIP)是一个开源SIP(Session Initiation Protocol)栈,而eXosip是osip的扩展,提供了一种更高级别的API,...

    eXosip开发手册

    #### 一、eXosip栈的初始化(How-To initialize libeXosip2) 在使用eXosip进行开发时,首先需要完成的是eXosip上下文和libosip库(解析器与状态机)的初始化工作。这一过程是后续所有操作的基础。 ##### 1.1 初始...

    编译后的eXosip 3.6.0动态库

    eXosip是基于OSIP(Open SIP Library)的SIP栈实现,专为高性能和易用性设计。在本案例中,我们关注的是eXosip 3.6.0的动态库版本,这个版本被编译后用于直接调用,特别适用于GB28181标准的认证过程。 GB28181是...

    exoSip开发手册

    **exoSip开发手册** exoSip是一款开源的SIP(Session Initiation Protocol)栈,用于构建VoIP(Voice over Internet Protocol)应用和多媒体通信系统。SIP是一种互联网协议,用于控制多媒体通信会话,如语音和视频...

    exosip2开发手册.pdf

    exosip2开发手册.pdf

    exoSip+开发者手册

    《exoSip+开发者手册》是一本专门为开发者设计的指南,旨在帮助他们深入理解并有效利用exoSIP库进行软电话应用的开发。exoSIP是基于OSIP(OpenSIP)协议栈的一个强大实现,它提供了一套完整的API,用于处理SIP...

    exosip开发手册.pdf.zip

    **exosip开发手册.pdf.zip** 是一个包含exosip开发文档的压缩文件,主要针对的是eXosip的新版本用户。exosip是一个开源的SIP(Session Initiation Protocol)库,它提供了用于实现VoIP(Voice over Internet ...

Global site tag (gtag.js) - Google Analytics