开发 openwebrtc 应用

本文档介绍了如何使用OpenWebRTC和Bowser开发WebRTC应用程序,包括API和前缀的使用、选择摄像头的方法、调试技巧等内容,并提供了一个适用于多种浏览器的参考应用程序。





Developing WebRTC web applications for OpenWebRTC and Bowser:  

     https://github.com/EricssonResearch/openwebrtc/wiki/Developing-WebRTC-web-applications-for-OpenWebRTC-and-Bowser


OpenWebRTC supports the latest WebRTC JavaScript API and web apps that run in OpenWebRTC / Bowser will most likely also work in other WebRTC enabled browsers, such as Chrome and Firefox.

The WebRTC API is not yet finalised and part of the reason for OpenWebRTC's existence is to be an interoperable implementation. As with any other web API, small differences in how the APIs work in the respective browsers can exist.

This page hopes to document them to make your life easier when writing web code to work with other popular browsers and OpenWebRTC (in the form of Bowser, the openwebrtc-daemon or, for example, an iOS hybrid app.)






Bowser-specific Notes

For Bowser-specific notes, see here

WebRTC API and prefixes

Where needed the webkit prefix is used for WebRTC API's. Examples of top level WebRTC API's:

navigator.webkitGetUserMedia = getUserMedia;
webkitMediaStream = MediaStream;
webkitRTCPeerConnection = RTCPeerConnection;
RTCSessionDescription
RTCIceCandidate

All API's are defined in webrtc.js if you want to check the source.

General Notes

  • WebRTC classes may not exist until after the page load has finished - This is because the page needs to download and execute owr.js. You need to be aware of this if you check for webrtc support on page load.
  • Video DOM elements will be swapped out
    • Don't cache the DOM elements in JavaScript
    • Be aware that certain attributes (like angular ng-*) will be lost from video elements. Put them on a container <div>.

Selecting camera

On devices where multiple cameras are available, such as mobile devices, you can select which camera that should be used ("user" or "environment"):

var mode = "user"; // or "environment"
var options = { "audio": true, "video": { "facingMode": mode } };
navigator.webkitGetUserMedia(options, function (stream) {
   ...
});

Reference application

If you get stuck we also provide a reference WebRTC application that works in Bowser/OpenWebRTC, Chrome and Firefox.

Debugging

The preferred method for debugging WebRTC web applications quickly is to run the web application in Firefox or OS X Safari, along with the OpenWebRTC daemon and browser extension. This is particularly useful to debug issues related to call setup and signalling.




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值