简介

        本文旨在掌握如何使用webrtc库来编译我们编写的webrtc相关代码。文中提供一份简单的测试代码,末尾附上我用到的webrtc静态库。本文的开发环境为ubuntu14.04。由于webrtc源码编译太复杂,文中用到静态库是google上下载别人编译的,版本未知。

代码

test1.cpp

#include <iostream>
#include <unistd.h>

#include "webrtc/api/peerconnectioninterface.h"
#include "webrtc/api/jsep.h"
#include "webrtc/api/datachannelinterface.h"
#include "webrtc/api/test/fakeconstraints.h"
#include "webrtc/pc/test/mockpeerconnectionobservers.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/ssladapter.h"
#include "webrtc/base/sslstreamadapter.h"
#include "webrtc/base/thread.h"
#include "webrtc/p2p/base/common.h"
#include "webrtc/base/basictypes.h"
#include "webrtc/base/ssladapter.h"

//using rtc::scoped_ptr;
using rtc::scoped_refptr;
using webrtc::MediaStreamInterface;
using webrtc::CreatePeerConnectionFactory;
using webrtc::DataChannelInterface;
using webrtc::MockDataChannelObserver;
using webrtc::PeerConnectionFactoryInterface;
using webrtc::PeerConnectionInterface;
using webrtc::PeerConnectionObserver;
//using webrtc::PortAllocatorFactoryInterface;
//using webrtc::VideoSourceInterface;
using webrtc::VideoTrackInterface;

int main()
{
    fprintf(stderr,"Hello World\n");
    fprintf(stderr,"Initializing SSL\n");

    rtc::InitializeSSL(NULL);

    fprintf(stderr,"Initialized SSL\n");
    fprintf(stderr,"Closing SSL\n");

    rtc::CleanupSSL();

    fprintf(stderr,"Closed SSL\n");

    return 0;
}

编译

g++ -DWEBRTC_POSIX -std=gnu++11 -o simpleTest test1.cpp -I/opt/webrtc/include /opt/webrtc/lib/x64/Debug/libwebrtc_full.a -lpthread -lX11 -ldl

webrtc库下载

http://download.csdn.net/download/yingyemin/10174267

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐