Using pjsua for android

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

CSipSimple supports two backends for audio. One is the OpenSLES one 
(this one has been integrated and probably improved in pjsip android 
branch) and the other is the Java-JNI implementation.
OpenSLES is only valid from 2.3 and is my default setting from android 
3.0 (because some manufacturers did crappy things). The jni 
implementation is used from android 1.6.

If you dive in Android source code you'll see that both OpenSL-ES and 
Java api relies on the same thing so in terms of performance what you 
win is the garbage collection cycles and the fact there is no conversion 
to java arrays (which doesn't have such a big impact). Other benefit of 
OpenSLES is that it doesn't needs to keep a reference on the dalvik jvm 
and can be managed directly in C independently of context.
If you want to try both options in CSipSimple, you can check the 
difference by changing a simple option.
As OpenSLES (for now) rely on android media server, you are still 
constrained by same things than a regular app.
Google engineers announced that they will rework libwilhelm (the one 
that implements opensl-es api) to use lower api libraries (such as 
libstagefright), but that's not yet the case, even in source code of 
4.1... So we are waiting for real time audio...

In terms of permission you are constrained to the same things than 
someone using the android audio server from a java app. Besides, 
normally even at lower layer they will take care to not open a door to 
apps. It's probably very easy to do by allowing rights to open audio 
device only to members of one group.

Normally strictly talking about unix permission it should not be a 
problem since you are root when running your binary. However... I'm not 
fully sure that the android media server doesn't takes an exclusive lock 
on libstagefright. In which case your app running as binary would not be 
allowed to do anything. That's just an idea, as I said in my first mail 
I never tried that because it doesn't make many sense to have a pure 
binary app.
The correct way to have a non platform app on android is to run it from 
an android application. And android application are apk. Apk are in 
charge to declare many things including permissions. And these 
permissions will indeed be applied to the sandboxed user.

What you could do however, if you really want to go the way of the 
binary, is to package your binary inside your apk and to call it from a 
very simple java app with an execute.

What is your exact use case? Normally in android you should not need to 
deploy applications by other (complicated from user point of view) means.

BTW, this said, the problem is maybe somewhere else. I'll test soon 
apjsua so if I encounter same problem maybe I'll be able to provide more 
feedback :).

On 25/07/2012 17:07, Monty Python wrote:
> Thanks a lot for your reply!!
>
> I tried to launch the same application on a not-rooted device, and it
> gave me, unfortunately, the same result.
>
> I have also a question about CSipSimple. I've seen that that fork
> required to use a java support, maybe in order to avoid the problems
> with Android permissions', manifest files and so on. Anyway I am still
> perplexed, because NDK has the audio support through OpenSLES, and it
> gives also the support to sockets: so I initially thought that,
> working on C language, I should operate on Kernel level bypassing all
> the "Android Security Level".
>
> Next, I've read this article on source.android:
>
> http://source.android.com/tech/security/#android-platform-security-architecture
>
> I'm not misunderstanding, all the applications are run inside a
> "Application Sandbox", that it works in Kernel Mode. So, any attempt
> to run a "particular application" with audio, sockets ecc. is vain. Is
> there any way to bypass this "application sandbox"? Must I really use
> .apks in order to use Manifest permissions? Thanks again.
>
> On Tue, Jul 24, 2012 at 8:53 PM, Monty Python
> <pythonexperiment at gmail.com> wrote:
>> Hi,
>>
>> Just some ideas, (I never had this issue) but ... :
>>
>> It could be something with unix rights : on android, applications get
>> permissions from their manifest and when android os creates the user of the
>> sandbox for the app it adds this users to relevant groups.
>> Because could also be something with the media server of android os that
>> doesn't allow to use audio for not real android apps. So rather than
>> command line launch you should probably try to use the sample application
>> apk and install it properly. With "adb install your_apk_name.apk" .+
>>
>> Another possible root cause is that the emulator doesn't always play well
>> with the audio layer. First it's absolutely not performant, and second
>> sometimes it doesn't detects at all the host audio hardware. I would advise
>> you to use a real device if you have one. It's way better to develop for
>> the call / audio purpose. (However emulator is a solution to develop for
>> the user interface part).
>>
>> Best regards.
>>> 2012/7/25 Monty Python <pythonexperiment at gmail.com>
>>> I've also obtained the strace of the pjsua process, hoping that it
>>> could expound my problem. Thanks again.
>>> stat64("/vendor/lib/libstagefright_amrnb_common.so", 0xbea8f138) = -1
>>> ENOENT (No such file or directory)
>>> stat64("/system/lib/libstagefright_amrnb_common.so",
>>> {st_mode=S_IFREG|0644, st_size=50760, ...}) = 0
>>> open("/system/lib/libstagefright_amrnb_common.so", O_RDONLY|O_LARGEFILE) =
>>> 3
>>> lseek(3, 0, SEEK_SET)                   = 0
>>> read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\0\0\0\000"...,
>>> 4096) = 4096
>>> lseek(3, -8, SEEK_END)                  = 50752
>>> read(3, "\1\0\0\0\0\0\0\0", 8)          = 8
>>> mmap2(NULL, 53248, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1,
>>> 0) = 0x40b0e000
>>> mmap2(0x40b0e000, 46908, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED,
>>> 3, 0) = 0x40b0e000
>>> mprotect(0x40b0e000, 49152, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
>>> mmap2(0x40b1a000, 444, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
>>> 0xc) = 0x40b1a000
>>> close(3)                                = 0
>>> mprotect(0x40b0e000, 49152, PROT_READ|PROT_EXEC) = 0
>>> stat64("/vendor/lib/libstagefright_enc_common.so", 0xbea8f138) = -1
>>> ENOENT (No such file or directory)
>>> stat64("/system/lib/libstagefright_enc_common.so",
>>> {st_mode=S_IFREG|0644, st_size=5420, ...}) = 0
>>> open("/system/lib/libstagefright_enc_common.so", O_RDONLY|O_LARGEFILE) = 3
>>> lseek(3, 0, SEEK_SET)                   = 0
>>> read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\0\0\0\000"...,
>>> 4096) = 4096
>>> lseek(3, -8, SEEK_END)                  = 5412
>>> read(3, "\1\0\0\0\0\0\0\0", 8)          = 8
>>> mmap2(NULL, 8192, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1,
>>> 0) = 0x40b1b000
>>> mmap2(0x40b1b000, 1700, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3,
>>> 0) = 0x40b1b000
>>> mprotect(0x40b1b000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
>>> mmap2(0x40b1c000, 260, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
>>> 0x1) = 0x40b1c000
>>> close(3)                                = 0
>>> mprotect(0x40b1b000, 4096, PROT_READ|PROT_EXEC) = 0
>>> stat64("/vendor/lib/libstagefright_avc_common.so", 0xbea8f138) = -1
>>> ENOENT (No such file or directory)
>>> stat64("/system/lib/libstagefright_avc_common.so",
>>> {st_mode=S_IFREG|0644, st_size=21848, ...}) = 0
>>> open("/system/lib/libstagefright_avc_common.so", O_RDONLY|O_LARGEFILE) = 3
>>> lseek(3, 0, SEEK_SET)                   = 0
>>> read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\0\0\0\000"...,
>>> 4096) = 4096
>>> lseek(3, -8, SEEK_END)                  = 21840
>>> read(3, "\1\0\0\0\0\0\0\0", 8)          = 8
>>> mmap2(NULL, 24576, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1,
>>> 0) = 0x40b1d000
>>> mmap2(0x40b1d000, 19024, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED,
>>> 3, 0) = 0x40b1d000
>>> mprotect(0x40b1d000, 20480, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
>>> mmap2(0x40b22000, 256, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
>>> 0x5) = 0x40b22000
>>> close(3)                                = 0
>>> mprotect(0x40b1d000, 20480, PROT_READ|PROT_EXEC) = 0
>>> mprotect(0x40574000, 1159168, PROT_READ|PROT_EXEC) = 0
>>> mprotect(0x40106000, 4096, PROT_READ|PROT_WRITE) = 0
>>> mprotect(0x40106000, 4096, PROT_READ)   = 0
>>> mprotect(0x40106000, 4096, PROT_READ|PROT_WRITE) = 0
>>> mprotect(0x40106000, 4096, PROT_READ)   = 0
>>> mprotect(0x40106000, 4096, PROT_READ|PROT_WRITE) = 0
>>> mprotect(0x40106000, 4096, PROT_READ)   = 0
>>> mprotect(0x40106000, 4096, PROT_READ|PROT_WRITE) = 0
>>> mprotect(0x40106000, 4096, PROT_READ)   = 0
>>> mprotect(0x40106000, 4096, PROT_READ|PROT_WRITE) = 0
>>> mprotect(0x40106000, 4096, PROT_READ)   = 0
>>> mprotect(0x40106000, 4096, PROT_READ|PROT_WRITE) = 0
>>> mprotect(0x40106000, 4096, PROT_READ)   = 0
>>> mprotect(0x40071000, 155648, PROT_READ|PROT_EXEC) = 0
>>> mprotect(0x40106000, 4096, PROT_READ|PROT_WRITE) = 0
>>> mprotect(0x40106000, 4096, PROT_READ)   = 0
>>> mprotect(0x40106000, 4096, PROT_READ|PROT_WRITE) = 0
>>> mprotect(0x40106000, 4096, PROT_READ)   = 0
>>> mprotect(0x4006e000, 8192, PROT_READ|PROT_EXEC) = 0
>>> mprotect(0x8000, 1933312, PROT_READ|PROT_EXEC) = 0
>>> sigaction(49264, {0xb00144c4, [], SA_RESTART}, {0xb00144c4, [],
>>> SA_RESTART}, 0) = -1 EINVAL (Invalid argument)
>>> --- SIGSEGV (Segmentation fault) @ 0 (f0) ---
>>> open("/dev/log/main", O_WRONLY|O_LARGEFILE) = 3
>>> writev(3, [{"\7", 1}, {"libc\0", 5}, {"Fatal signal 11 (SIGSEGV) at
>>> 0x0"..., 49}], 3) = 55
>>> SYS_224(0x37, 0xbea8f850, 0x3, 0x38)    = 465
>>> socket(PF_UNIX, SOCK_STREAM, 0)         = 4
>>> connect(4, {sa_family=AF_UNIX, path=@android:debuggerd}, 20) = 0
>>> write(4, "?\1\0\0", 4)                  = 4
>>> read(4, 0xbea8f888, 1)                  = ? ERESTARTSYS (To be restarted)
>>> --- SIGCONT (Continue) @ 0 (0) ---
>>> read(4, "?", 1)                         = 1
>>> close(4)                                = 0
>>> sigaction(SIGSEGV, {SIG_DFL}, {0xb0005b29, [], SA_RESTART|SA_SIGINFO}, 0)
>>> = 0
>>> rt_sigreturn(0)                         = -1 EPERM (Operation not
>>> permitted)
>>> --- SIGSEGV (Segmentation fault) @ 0 (f0) ---
>>> +++ killed by SIGSEGV +++
>>>
>>> On Tue, Jul 24, 2012 at 8:53 PM, Monty Python
>>> <pythonexperiment at gmail.com> wrote:
>>>> Greetings to everyone!
>>>>
>>>> I'm trying to compile pjsua using the following branch:
>>>> http://svn.pjsip.org/repos/pjproject/branches/projects/android/. I've
>>>> tried to do a push (adb push pjsua /data/local/) to my android-sdk
>>>> emulator but, when I've tried to execute it via adb shell, the android
>>>> logcat gave me the following SIGFAULT error: where am I wrong? Thanks
>>>> in advance.
>>>>
>>>> F/libc    (  464): Fatal signal 11 (SIGSEGV) at 0x000000f0 (code=1)
>>>> I/DEBUG   (   33): *** *** *** *** *** *** *** *** *** *** *** *** ***
>>>> *** *** ***
>>>> I/DEBUG   (   33): Build fingerprint:
>>>> 'generic/sdk/generic:4.0.3/MR1/237985:eng/test-keys'
>>>> I/DEBUG   (   33): pid: 464, tid: 464  >>>
>>>> ./pjsua-arm-unknown-linux-androideabi <<<
>>>> I/DEBUG   (   33): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault
>>>> addr 000000f0
>>>> I/DEBUG   (   33):  r0 ffffffff  r1 beef7c30  r2 beef7c30  r3 ffffffff
>>>> I/DEBUG   (   33):  r4 00000000  r5 00000000  r6 00000000  r7 00000000
>>>> I/DEBUG   (   33):  r8 00000000  r9 00000000  10 00000000  fp 00000000
>>>> I/DEBUG   (   33):  ip 4003c4b9  sp beef7c60  lr 4003c4b1  pc b000469a
>>>>   cpsr 00000030
>>>> I/DEBUG   (   33):  d0  00000000bd6bc8e3  d1  0000000000000000
>>>> I/DEBUG   (   33):  d2  0000000000000000  d3  0000000000000000
>>>> I/DEBUG   (   33):  d4  0000000000000000  d5  41c8f0a46e800000
>>>> I/DEBUG   (   33):  d6  3f50624dd2f1a9fc  d7  c18af9670cce266f
>>>> I/DEBUG   (   33):  d8  0000000000000000  d9  0000000000000000
>>>> I/DEBUG   (   33):  d10 0000000000000000  d11 0000000000000000
>>>> I/DEBUG   (   33):  d12 0000000000000000  d13 0000000000000000
>>>> I/DEBUG   (   33):  d14 0000000000000000  d15 0000000000000000
>>>> I/DEBUG   (   33):  scr 00000010
>>>> I/DEBUG   (   33):
>>>> I/DEBUG   (   33):          #00  pc b000469a  /system/bin/linker
>>>> I/DEBUG   (   33):          #01  pc 000264ac  /system/lib/libc.so
>>> (__set_errno)
>>>> I/DEBUG   (   33):
>>>> I/DEBUG   (   33): code around pc:
>>>> I/DEBUG   (   33): b0004678 95004840 44784a40 4d414b40 447b447a
>>>> @H.. at JxD at KAMzD{D
>>>> I/DEBUG   (   33): b0004688 682d447d f44f9103 95017140 f0009402
>>>> }D-h..O. at q......
>>>> I/DEBUG   (   33): b0004698 f8d4ff67 b10330f0 f8d44798 b17000e0
>>>> g....0...G....p.
>>>> I/DEBUG   (   33): b00046a8 10e4f8d4 f7ff2200 2000f9b5 f8d4e007
>>>> ....."..... ....
>>>> I/DEBUG   (   33): b00046b8 f04f20a8 f04230ff f8c40102 b00710a8  .
>>>> O..0B.........
>>>> I/DEBUG   (   33):
>>>> I/DEBUG   (   33): code around lr:
>>>> I/DEBUG   (   33): 4003c490 f240b507 9300736c 33fff04f 466b9301
>>>> .. at .ls..O..3..kF
>>>> I/DEBUG   (   33): 4003c4a0 fd80f7ff bf00bd0e 4604b510 fe90f7ec
>>>> ...........F....
>>>> I/DEBUG   (   33): 4003c4b0 f04f6004 bd1030ff 0ffff110 db02b510
>>>> .`O..0..........
>>>> I/DEBUG   (   33): 4003c4c0 f7ff4240 bd10fff1 48214603 4478b5f0
>>>> @B.......F!H..xD
>>>> I/DEBUG   (   33): 4003c4d0 b0976800 68022150 4620ac01 92154e1d
>>>> .h..P!.h.. F.N..
>>>> I/DEBUG   (   33):
>>>> I/DEBUG   (   33): stack:
>>>> I/DEBUG   (   33):     beef7c20  00000000
>>>> I/DEBUG   (   33):     beef7c24  4003c4c7  /system/lib/libc.so
>>>> I/DEBUG   (   33):     beef7c28  00000000
>>>> I/DEBUG   (   33):     beef7c2c  4002f477  /system/lib/libc.so
>>>> I/DEBUG   (   33):     beef7c30  b00144c4
>>>> I/DEBUG   (   33):     beef7c34  00000000
>>>> I/DEBUG   (   33):     beef7c38  10000000
>>>> I/DEBUG   (   33):     beef7c3c  00000000
>>>> I/DEBUG   (   33):     beef7c40  00000000
>>>> I/DEBUG   (   33):     beef7c44  4002f49b  /system/lib/libc.so
>>>> I/DEBUG   (   33):     beef7c48  00000000
>>>> I/DEBUG   (   33):     beef7c4c  0000c090
>>>> /data/local/pjsua-arm-unknown-linux-androideabi
>>>> I/DEBUG   (   33):     beef7c50  b00144c4
>>>> I/DEBUG   (   33):     beef7c54  0000c070
>>>> /data/local/pjsua-arm-unknown-linux-androideabi
>>>> I/DEBUG   (   33):     beef7c58  df0027ad
>>>> I/DEBUG   (   33):     beef7c5c  00000000
>>>> I/DEBUG   (   33): #01 beef7c60  00000001
>>>> I/DEBUG   (   33):     beef7c64  beef7d47  [stack]
>>>> I/DEBUG   (   33):     beef7c68  00000000
>>>> I/DEBUG   (   33):     beef7c6c  beef7d6d  [stack]
>>>> I/DEBUG   (   33):     beef7c70  beef7d82  [stack]
>>>> I/DEBUG   (   33):     beef7c74  beef7d92  [stack]
>>>> I/DEBUG   (   33):     beef7c78  beef7dba  [stack]
>>>> I/DEBUG   (   33):     beef7c7c  beef7df7  [stack]
>>>> I/DEBUG   (   33):     beef7c80  beef7e10  [stack]
>>>> I/DEBUG   (   33):     beef7c84  beef7e2a  [stack]
>>>> I/DEBUG   (   33):     beef7c88  beef7f55  [stack]
>>>> I/DEBUG   (   33):     beef7c8c  beef7f68  [stack]
>>>> I/DEBUG   (   33):     beef7c90  beef7f83  [stack]
>>>> I/DEBUG   (   33):     beef7c94  beef7fa0  [stack]
>>>> I/DEBUG   (   33):     beef7c98  beef7fb3  [stack]
>>>> I/DEBUG   (   33):     beef7c9c  00000000
>>>> I/DEBUG   (   33):     beef7ca0  00000010
>>>> I/DEBUG   (   33):     beef7ca4  000030d7
>>>>
>>>>     M.P.
>>> _______________________________________________
>>> Visit our blog: http://blog.pjsip.org
>>>
>>> pjsip mailing list
>>> pjsip at lists.pjsip.org
>>> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
>>>
> _______________________________________________
> Visit our blog: http://blog.pjsip.org
>
> pjsip mailing list
> pjsip at lists.pjsip.org
> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org




[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux