OWT web示例app源码分析samplertcservice

示例app的源码,看起来也有些复杂,不容易懂。写文章帮助理解记忆。

一、启动脚本:/home/oem/git/owt-server/dist-debug/bin/daemon.sh :

cd ${OWT_HOME}/apps/current_app/
nohup nice -n ${OWT_NICENESS} node . \

/home/oem/git/owt-server/dist-debug/apps/current_app/package.json:
"main": "samplertcservice.js",

在apps/current_app/目录,启动的是samplertcservice.js

samplertcservice.js使用nodejs 的 express / spdy框架,创建端口3001 3004监听服务,处理http请求。

icsREST = require('./rest');
// http请求的处理,都是调用 icsREST.API
app.get('/rooms', function(req, res) {
  'use strict';
  icsREST.API.getRooms(pageOption, function(rooms) {
    res.send(rooms);
  }, function(err) {
    res.send(err);
  });
});

二,目录结构

/home/oem/git/owt-server/dist-debug/apps/current_app/public/index.html
<script src="scripts/owt.js" type="text/javascript"></script>
    <script src="scripts/index.js" type="text/javascript"></script>
    <script src="scripts/rest-sample.js" type="text/javascript"></script>
    <script language="JavaScript">

runSocketIOSample();

下左图是源文件目录,下右图是chrome获取并解析的目录结构。说明owt.js实际上打包里src/sdk目录的javascript文件。

                 

 三,打开视频流程

//创建Owt.Conference.ConferenceClient()对象
https://192.168.1.106:3004/scripts/src/sdk/conference/client.js
/*The ConferenceClient handles PeerConnections between client and server. For conference controlling, please refer to REST API guide.*/

export const ConferenceClient = function(config, signalingImpl) {

file:///home/oem/git/owt-server/dist-debug/apps/current_app/public/scripts/index.js
const runSocketIOSample = function() {
    conference = new Owt.Conference.ConferenceClient();

// publish操作

https://192.168.1.106:3004/scripts/src/sdk/conference/channel.js
  _createPeerConnection() {
    this.pc = new RTCPeerConnection(pcConfiguration);

 async publish(stream, options, videoCodecs) {
    this._createPeerConnection();

file:///home/oem/git/owt-server/dist-debug/apps/current_app/public/scripts/owt.js
      function publish(_x3, _x4, _x5) {
        return _publish.apply(this, arguments);
      }

https://192.168.1.106:3004/scripts/src/sdk/conference/client.js
  this.publish = function(stream, options, videoCodecs) {
    return peerConnectionChannel.publish(stream, options, videoCodecs);
  };

file:///home/oem/git/owt-server/dist-debug/apps/current_app/public/scripts/index.js
    // Publish with options.
    conference.publish(localStream, publishOption).then(publication => {
        publicationGlobal = publication;
        mixStream(myRoom, publication.id, 'common', serverUrlBase)
        publication.addEventListener('error', (err) => {
        console.log('Publication error: ' + err.error.message);
                            });
                        });

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值