官方标准版如何编译webrtc ( how to compile webrtc )

Before you start

First, be sure to install the  prerequisite software(如下红色字体部分).

Depot Tools

1. You'll need to have the depot tools installed:
https://sites.google.com/a/chromium.org/dev/developers/how-tos/depottools

2. You need git installed (needed for getting WebM source):
http://git-scm.com/

Linux (Ubuntu/Debian)

This, and more, is described on the Chromium site:
http://code.google.com/p/chromium/wiki/LinuxBuildInstructions

A script is provided for Ubuntu, which is available after your first gclient sync:
$ ./build/install-build-deps.sh

Pulse Audio is missing from the script. On Ubuntu, this is provided by the libpulse-dev package.

Although the install-build-deps.sh script is the recommended method, it will install much more than you need. Here is a (hopefully complete) minimal list of packages to install (sudo apt-get install...):

  g++ (>= 4.2)
  python (>= 2.4)
  libasound2-dev
  libpulse-dev
  libjpeg62-dev
  libxv-dev
  libgtk2.0-dev
  libexpat1-dev

For 32-bit builds on a 64-bit system:
  lib32asound2-dev
  ia32-libs

Tips for other distributions are available on the Chromium page.

Windows

  • Visual Studio 2008 or newer, with all service packs installed.
    • Using the free version Visual C++ Express does not work out of the box, but we think it should be possible by installing WDK, see Chromium's instructions for this (Additional Software, step 6). If you make it work, please let us know at the mailing list discuss-webrtc, and we will update this documentation. 
  • Microsoft SDK 7.1 Older versions might work as well, as long as they support Vista specific features (building on XP should be fine).
    • Ensure the library and include directories for the SDK are set in MSVC|Tools|Options|Projects and Solutions|VC++ Directories (e.g. C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib).
  • Microsoft DirectX SDK (June 2010) (others might work as well). Please check that this SDK gets installed like this:
    • Verify MSVC|Tools|Options|Projects and Solutions|VC++ Directories has Include: $(DXSDK_DIR)include and Lib: $(DXSDK_DIR)lib\x86.
    • Make sure the DirectX include directories appear first in the search path, otherwise you may get build errors.
  • Python
  • For Visual 2010 some extra steps are needed:
    • Install VS2010 SP1.
    • In case VS2010 is not detected automatically by GYP or in case you have multiple versions of Visual Studio in your build machine, then to generate the .sln/.vcxproj, you need to set an environment variable: GYP_MSVS_VERSION=2010
    • For test programs that use MFC, make sure that the solution links to the MFC libraries statically. This gets automatically set in VS2005, but there is a bug in solution file generator for VS2010.

OS X

 XCode 3.0 or higher

Android

These instructions are tested on a Linux development machine.
  • Install the Android NDK according to these instructions. 
  • Install the Android SDK according to these instructions. Note that there is a step which will require you to use a GUI. If you’re on a headless machine you can download all platforms by runningandroid update sdk --no-ui instead ofandroid. 
You will need to set up ANDROID_SDK_ROOT and ANDROID_NDK_ROOT so the build system finds the tool chain. Put this into your .bashrc, but with the correct paths to where you put the SDK and NDK:

# For clank build, set the ANDROID_SDK_ROOT and ANDROID_NDK_ROOT to
# the path you want to install them.

# Note: the directory name has to be 'android-sdk-linux',
# otherwise the install script wouldn't work.
export ANDROID_SDK_ROOT=/usr/local/google/bin/android-sdk-linux

# Note: the directory name has to be 'android-ndk-r7', otherwise the
# install script wouldn't work
export ANDROID_NDK_ROOT=/usr/local/google/bin/android-ndk-r7


The currently supported platforms are Windows, Mac OS X, and Linux.

Getting the code and building

Create a working directory, enter it, and run:
$ gclient config  --name trunk  http://webrtc.googlecode.com/svn/trunk/peerconnection
$ gclient sync --force

If you instead want to get the latest trunk without the peerconnection sample client and server, use:
$ gclient config http://webrtc.googlecode.com/svn/trunk

If you're a committer, substitute https for http. On Windows, use gclient.bat instead (or prefix the commands by invoking python).

On Linux, ensure your dependencies are up to date, as described on the  prerequisites page.

The sync will generate native build files for your environment using  gyp (Linux: make, OS X: XCode, Windows: Visual Studio). This generation can also be forced manually:
$ gclient runhooks --force

On Windows, gyp will use the latest Visual Studio on your system by default. In order to specify a particular Visual Studio version, there are a few options. You can set an environment variable  GYP_MSVS_VERSION=<version> before runhooks, or manually run the gyp command triggered by runhooks. From the trunk/ directory:
$ build/gyp_chromium --depth=. -G msvs_version=<version> webrtc.gyp

where <version> is, for example, 2008.

You should now be able to build the sample programs peerconnection_client (Windows and Linux only) and peerconnection_server (Windows, Linux, Mac).

Sample Application

The sample application creates a simple video chat client and server, using the  WebRTC Native APIs.

How to Build

On Linux:

$ cd trunk
$ make peerconnection_server

$ make peerconnection_client

On Windows: 

Use Visual Studio to open and build the trunk/webrtc.sln solution file.  This will build both  peerconnection_server.exeand  peerconnection_client.exe.

On Mac:
$ cd trunk
$ open webrtc.xcodeproj/

This will open XCode. Build the  peerconnection_server target using XCode. 

It is also possible to use regular Make to build. To do this, set the environment variable  GYP_GENERATORS to  make (in bash, type  GYP_GENERATORS=make) and then run  gclient sync. With this, you can for instance import the project into Eclipse as a makefile project and use that instead of XCode.

How to Run

The resulting binaries appear in  xcodebuild/Debug/ on Mac,  out/Debug/ on Linux and  build/Debug/ on Windows. 

Once built, start the  peerconnection_server application.  This is a simple web server that's built to exchange signaling messages between instances of  peerconnection_client (Note: the client is Windows only).

You can also use the test HTML page  ( trunk/hird_party/libjingle/source/talk/examples/peerconnection/server/server_test.html) to connect to the server and enable loopback when you've only got one instance of  peerconnection_client running.  Enabling loopback causes the client to set up a video/voice session with itself.

When the server is running, you'll see a message indicating that it is running:

Server listening on port 8888

On Windows, Linux

Next, start  peerconnection_client. This is a client application that uses the PeerConnection C++ API for setting up a video+voice session with a remote peer.  The application uses the server to send signaling messages (messages generated by the API) between the peers.

The UI of the application consists of these three parts:
  1. Connect to server.  Here you specify the machine that is currently running the server.  Hit "Connect" or press return.

  2. Select peer.  When you've connected with the server, you'll see a list of other peerconnection_clientinstances (or server_test.html) that are currently connected.  To connect with a peer, double click or select+press return.  This will start the local capture components (mic+webcam) as well as exchange signaling messages with the peer via the server.  You can verify this via the server console.

  3. Video chat.  When the signalling messages have been exchanged, the PeerConnection API creates channels for the voice and video streams and you will see the remote video in full window.
To end a chat session and go back to selecting a peer, press Esc. To disconnect from the server and go back to the initial UI, press Esc again.

On Mac, Linux

Open trunk/hird_party/libjingle/source/talk/examples/peerconnection/server/server_test.html. Click connect. Observe that the peerconnection_server announces your connection. Now you can open one more tab with the page, connect that too (with a different name) and send messages between the peers.

Building for Android (on Linux)

1. Check out as usual:
gclient config https://webrtc.googlecode.com/svn/trunk
gclient sync


2. Generate makefiles:
source ./build/android/envsetup.sh
gclient runhooks


3. Build
make

你可能感兴趣的:(linux,windows,android,server,application,Build)