VC:开发日记(Web) - zhonglong/TPV GitHub Wiki

一月二十五日

For Error 1007, it means that the web socket connect was successful (FreeSWITCH is running and received the request from the browser to setup a media path), but none of the IP/Port combinations returned by FreeSWITCH enabled the browser to connect and start transmitting media. To diagnose this error, open about:webrtc in FireFox and click ‘show details’ for the most recent connection. Look under the column Remote Candidate and check if you see the internal IP address of the BigBlueButton server. If so, you probably have a misconfiguration in the FreeSWITCH settings. Re-check against the examples shown above. If the correct IP address is shown, you probably have an issue where your firewall isn’t allowing UDP packets through in both directions on the required ports. Check your firewall documentation for help, or ask the BigBlueButton community mailing list.

1007: ICE negotiation failed - The browser and FreeSWITCH try to negotiate ports to use to stream the media and that negotiation failed. Possible Causes:

  • NAT is blocking the connection
  • Firewall is blocking the UDP connection/ports

1007错误 http://docs.bigbluebutton.org/install/install.html

一月二十二日

SIPBridge SIPBridge通过callback函数,传递错误类型和详细信息给AudioManager显示通知。 错误类型在SIPBridge的父类BaseAudioBridge中定义。

this.baseErrorCodes = {
  INVALID_TARGET: 'INVALID_TARGET',
  CONNECTION_ERROR: 'CONNECTION_ERROR',
  REQUEST_TIMEOUT: 'REQUEST_TIMEOUT',
  GENERIC_ERROR: 'GENERIC_ERROR',
  MEDIA_ERROR: 'MEDIA_ERROR',
  WEBRTC_NOT_SUPPORTED: 'WEBRTC_NOT_SUPPORTED',
  ICE_NEGOTIATION_FAILED: 'ICE_NEGOTIATION_FAILED',
};

抛出错误的场景包括:

  • transferCall:呼叫转移超时?
  • exitAudio:挂断超时
  • createUserAgent:UA断开,对应WebRTC错误码或者连接错误
  • setupEventHandlers:会话终止,以及ICE连接失败或关闭
  • joinAudio:其它未处理的异常

一月十八日

AudioManager => callStateCallback函数 加入音频会议的回调函数,当出现错误时会弹出通知: this.notify(this.messages.error[error] || this.messages.error.GENERIC_ERROR, true); logger.error('Audio Error:', error, bridgeError); 根据上报的错误类型(error),弹出对应的提示语;若错误类型不在列表中,则弹出通用的提示语“出错了,请重试”;

已知的错误类型包括:

  • GENERIC_ERROR: 出错了,请重试,
  • CONNECTION_ERROR: 连接错误,
  • REQUEST_TIMEOUT: 请求超时,
  • INVALID_TARGET: 获取您的媒体设备时出错,
  • MEDIA_ERROR: 获取您的媒体设备时出错,
  • WEBRTC_NOT_SUPPORTED: 未得到支持的浏览器版本,
  • ICE_NEGOTIATION_FAILED: ICE协商失败,
  • 1001: WebSocket连接断开,
  • 1002: 无法建立WebSocket连接,
  • 1003: 未得到支持的浏览器版本,
  • 1004: 呼叫失败,
  • 1005: 呼叫异常中断,
  • 1006: 呼叫超时,
  • 1007: ICE协商失败,
  • 1008: 传输失败,
  • 1009: 无法获取STUN/TURN服务器信息,
  • 1010: ICE协商超时,
  • 1011: ICE收集超时, 其中1001至1011代表WebSocket错误。

目前主要集中在1006,1007和未知错误三种,其中未知错误需要借助LOG进一步定位。 1006和1007大概率与网络状态有关,断开网络会提示1006和1007错误,当服务器带宽耗尽也会提示1007错误。 出错提示很可能会连续两次,这是因为AudioManager设置了MAX_LISTEN_ONLY_RETRIES = 1,失败后重试一次的缘故。

AudioManager => init函数 初始化AudioManager时会指定bridge类型,

this.bridge = USE_SIP ? new SIPBridge(userData) : new VertoBridge(userData);
if (this.useKurento) {
  this.listenOnlyBridge = new KurentoBridge(userData);
}

根据配置 "useSIPAudio": true "enableListenOnly": false 所以bridge固定采用SIPBridge,对应代码/imports/api/audio/client/bridge/sip。

十二月十三日

There are reasons why one would like to use VP8:

  1. It has been there from the start, so its implementation is highly optimized already
  2. Royalty free, so no need to deal with patents and payments and whatnot. I know there’s FUD around patents in VP8, but for the most part, 100% of the industry is treating it as free
  3. It nicely supports simulcast, so quite friendly to video group calling scenarios

There are reasons why one would like to use H.264:

  1. You already have H.264 equipment, so don’t want to transcode – be it cameras, video conferencing gear or the need to broadcast via HLS or RTMP
  2. You want to support Safari
  3. You want to leverage hardware based encoding and decoding to increase battery life on your mobile devices

The Challenging Path to WebRTC H.264 Video Codec Hardware Support https://bloggeek.me/webrtc-h264-video-codec-hardware-support/

十二月十二日

今天在10.0.0.2服务器上配置好Android app编译环境,GeckoView基于20181210版本,源码提交记录是449730:13f891b92db1。 编译步骤为:

  1. 进入 /home/xmic/mozilla/mozilla-central 工作目录;
  2. 将 andriod_app_vc 拷贝到 mobile/android 目录下,将 zxinglibrary 也移动到 mobile/android 目录下;
  3. 运行 ./mach gradle assembleWithGeckoBinaries 命令编译;
  4. APK在 objdir-frontend/gradle/build/mobile/android/app/output/apk 目录下。

十二月十日

Build Instructions (Android WebView) https://www.chromium.org/developers/how-tos/build-instructions-android-webview Checking out and building Chromium for Android https://chromium.googlesource.com/chromium/src/+/master/docs/android_build_instructions.md The official GitHub mirror of the Chromium source https://github.com/chromium/chromium

按 Checking out and building Chromium for Android 官方文档,编译以下几个模块:

  • autoninja -C out/Default chrome_public_apk
  • autoninja -C out/Default monochrome_public_apk
  • autoninja -C out/Default system_webview_apk

按 Build Instructions (Android WebView) 官方文档,安装 SystemWebView.apk。

adb uninstall com.google.android.webview # May fail adb uninstall com.android.webview # May fail adb disable-verity; adb reboot adb root adb remount adb shell stop adb shell rm -rf /system/app/webview /system/app/WebViewGoogle /system/app/WebViewStub adb shell start adb install -r -d out/Release/apks/SystemWebView.apk

Chromium源码在 172.20.30.7 服务器,~/chromium 目录,用户名:mobile,密码:mobileasc。

Issue 2549283002: Android: enable WebRTC HW H264 with a flag by default (Closed) https://codereview.chromium.org/2549283002/

Add support for H264 software encoding in Android https://bugs.chromium.org/p/chromium/issues/detail?id=719023

十二月七日

WebRTC协议栈,已经定义支持的编码格式和优先级:VP8 > VP9 > H264

// Supported video codecs.
// Note: order here implies priority for building offers!
UniquePtr<JsepVideoCodecDescription> vp8(
    new JsepVideoCodecDescription("120", "VP8", 90000));
// Defaults for mandatory params
vp8->mConstraints.maxFs = 12288;  // Enough for 2048x1536
vp8->mConstraints.maxFps = 60;
mSupportedCodecs.push_back(std::move(vp8));

UniquePtr<JsepVideoCodecDescription> vp9(
    new JsepVideoCodecDescription("121", "VP9", 90000));
// Defaults for mandatory params
vp9->mConstraints.maxFs = 12288;  // Enough for 2048x1536
vp9->mConstraints.maxFps = 60;
mSupportedCodecs.push_back(std::move(vp9));

UniquePtr<JsepVideoCodecDescription> h264_1(
    new JsepVideoCodecDescription("126", "H264", 90000));
h264_1->mPacketizationMode = 1;
// Defaults for mandatory params
h264_1->mProfileLevelId = 0x42E00D;
mSupportedCodecs.push_back(std::move(h264_1));

UniquePtr<JsepVideoCodecDescription> h264_0(
    new JsepVideoCodecDescription("97", "H264", 90000));
h264_0->mPacketizationMode = 0;
// Defaults for mandatory params
h264_0->mProfileLevelId = 0x42E00D;
mSupportedCodecs.push_back(std::move(h264_0));

视频编码顺序 https://searchfox.org/mozilla-central/source/media/webrtc/signaling/src/jsep/JsepSessionImpl.cpp

十二月六日

Mozilla Source Code Directory Structure https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Source_Code/Directory_structure

Simple Firefox for Android build https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Build_Instructions/Simple_Firefox_for_Android_build

Code search tools https://dxr.mozilla.org/mozilla-central/source/ https://searchfox.org/mozilla-central/source/

按 Simple Firefox for Android build 官方文档,编译 Artifact Mode。 运行 ./mach build 命令,可能报错无法下载某些包,多试几次。 运行 ./mach package 命令,默认是没有签名的,需按提示运行 keytool 命令,debug.keystore 密码是 android。 运行 ./mach gradle assembleWithGradleBinariesDebug 命令,编译Android应用模块。

FireFox源码在 10.0.0.2 服务器,/home/xmic/mozilla 目录,用户名:xmic,密码:xmicasc。

十二月三日

The most popular codec, H.264, is patent-encumbered and licensed by MPEG LA, under terms that prevent distributing it with open source products including Firefox. Cisco has announced today that they are going to release a gratis, high quality, open source H.264 implementation — along with gratis binary modules compiled from that source and hosted by Cisco for download. Here’s a little more detail about how things are going to work: Cisco is going to release, under the BSD license, an H.264 stack, and build it into binary modules compiled for all popular or feasibly supportable platforms, which can be loaded into any application (including Firefox). The binary modules will be available for download from Cisco, and Cisco will pay for the patent license from the MPEG LA. Firefox will automatically download and install the appropriate binary module onto each user’s machine when needed, unless disabled in the user’s preferences. Firefox already supports H.264 for the video element using platform codecs where they are available, but as noted in my last blog post on the topic, not all OSes ship with H.264 included.

OpenH264 http://www.openh264.org/

Video Interoperability on the Web Gets a Boost From Cisco’s H.264 Codec https://blog.mozilla.org/blog/2013/10/30/video-interoperability-on-the-web-gets-a-boost-from-ciscos-h-264-codec/

十一月十六日

The codec error usually happens with Chinese phones that don't have the h264 codec available.

On /usr/local/bigbluebutton/bbb-webrtc-sfu/config/default.yml, there's an option called webcam-force-h264

  • webcam-force-h264: true will force H264 and any device that doesn't have it will fail to share or view videos.
  • webcam-force-h264: false will let the process go untouched. If there's VP8 in the SDP as the preferred codec, it'll pick VP8. If there's only H264, it'll pick H264. So iOS devices will be able to join. There'll be transcoding between VP8 and H264 if deemed necessary, though.