vsimon / webrtcbuilds

Getting started with WebRTC natively is no easy picnic. The goal of webrtcbuilds is to provide a single standalone WebRTC static library and package.
BSD 3-Clause "New" or "Revised" License
202 stars 164 forks source link

Looking an example of using the prebuilt Android libraries #5

Open eguendelman opened 9 years ago

eguendelman commented 9 years ago

I know Android support is still experimental, but is it working for some people? I want to build an Android native library (.so file) which uses WebRTC's peer connection layer to enable p2p media streaming. I haven't been able to figure out how to incorporate the prebuilt Android libraries into my Android.mk file. For one thing I'm not sure which of the supplied libraries (libwebrtc_full.a, libjingle_peerconnection_so.so, or libwebrtcdemo-jni.so) I should be linking to. I've been betting on the libjingle_peerconnection_so.so library, but keep on getting undefined symbols for all of the symbols in the rtc namespace.

The test code I am trying to compile (into an .so) is

#include "talk/app/webrtc/peerconnectionfactory.h"

extern "C"
{
void foo()
{
    rtc::Thread *worker = new rtc::Thread;
    rtc::Thread *signaling = new rtc::Thread;
    worker->Start();
    signaling->Start();
    rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> peerConnectionFactory = 
        webrtc::CreatePeerConnectionFactory(worker,signaling,0,0,0);
}
}

Thanks

vsimon commented 9 years ago

Hi Eran, I'd like to help but I'm more familiar with linux, osx, and windows platforms than android at the moment to give you a clear cut answer. And I'm even much less familiar with the Android NDK which I think is what you're asking about.

I'd have to figure out how to set up the Android SDK/Toolchain but my idea was to first try to see if I could build some of the android examples in the WebRTC repo from just from source and the prebuilt libraries. That is what I did for the other platforms.

As for which libraries to link, I'm not sure as I'm just packaging up all of the lib build artifacts in the packaging step.

But libjingle_peerconnection_so.so does seem to be the most promising:

$ nm lib/libjingle_peerconnection_so.so  | grep webrtc | grep CreatePeerConnectionFactory
00051d85 T Java_org_webrtc_PeerConnectionFactory_nativeCreatePeerConnectionFactory
0006d7e9 t _ZN6webrtc27CreatePeerConnectionFactoryEPN3rtc6ThreadES2_PNS_17AudioDeviceModuleEPN7cricket25WebRtcVideoEncoderFactoryEPNS5_25WebRtcVideoDecoderFactoryE
0006d68d t _ZN6webrtc27CreatePeerConnectionFactoryEv

...now glancing at this output, the last two symbols appear to be 'local' and not exported as global. This could be one potential problem. I'll have to dig into this further to give you a more definitive answer.

eguendelman commented 9 years ago

Thanks for your response. Yeah I have also succeeded with the Windows platform, but now trying to get it to work on Android.

I made a bit of progress, but not using these prebuilt libraries. I decided to build the Android WebRTC libraries myself, using https://github.com/pristineio/webrtc-build-scripts From this I get many individual static libraries, and I did finally get something extremely basic (even more basic than above) to compile by linking against specific static libs (.a) such as librtcbase.a and librtcbase_approved.a.

But I still have work to do to make it work for my real example, which also uses many other third party libraries including boost.