WebRTC Video Pipeline

概述 视频流水线是指视频从发送端摄像头捕捉视频图像,将视频流进行转换,编码,打包,发送,直到接收端进行解包,缓存,解码再到将视频图像渲染到画布上或者视频元素中 # linux send h264 rtp stream: gst-launch-1.0 -v ximagesrc \ ! video/x-raw,framerate=20/1 \ ! videoscale ! videoconvert \ ! x264enc tune=zerolatency bitrate=500 speed-preset=superfast \ ! rtph264pay \ ! udpsink host=127.0.0.1 port=5000 # Macos send h264 rtp stream: gst-launch-1.0 -v avfvideosrc capture-screen=true \ ! video/x-raw,framerate=20/1 \ ! videoscale ! videoconvert \ ! x264enc tune=zerolatency […] →Read more

异步编程模式

大约有两种基本的异步编程模式 Task-Based Asynchronous Pattern 基于任务的异步模式 以一个单个的方法(Task)来表示异步操作的发起和完成, 它引入了 Async, Await 这样的关键字 任务执行会返回一个 Promise 或 Future, 代表未来执行的结果 Event-Based Asynchronous Pattern 基于事件的异步模式 以事件驱动的模式来提供异步的行为,主要使用了事件回调和事件处理器的方式,类似于观察者模式的结构 它遵循了著名的好莱坞原则 “Don’t call us, we’ll call you” – “别打电话给我们,我们会打给你的” 在具体实现上,有三种模型 多进程 RPC 远程过程调用就是典型的用例,在多个进程间通过网络消息传输来进行异步调用,例如 Ajax。 在一台主机的多进程还可以使用众多的 IPC 方法,我觉得最好用的还是 UDS (Unix Domain Socket) 其地址族为 AF_UNIX,Socket type 可以是 SOCK_STREAM(类比 TCP) 和 SOCK_DGRAM(类比 UDP), SCOK_SEQPACKET(类比 SCTP) nc -U /tmp/test.sock […] →Read more

DTLS handshake

DTLS record header DTLS Header Field Purpose 8-bit Message Type This field contains the type of DTLS record being sent. Valid types are as follows:- ChangeCipherSpec: 0x14- Alert: 0x15- Handshake: 0x16- Application Data: 0x17 16-bit Protocol Version This field contains the DTLS protocol version. Valid values are as follows:- DTLS 1.1: 0xFEFD 16-bit Epoch This […] →Read more

10 Tips for Working at Home Like a Pro BY HELEN GALL

top 10 tips to help keep you productive and sane. Set a schedule and stick to it. This will help you maintain work-life balance; otherwise, you might find that you’re suddenly working longer hours than usual. Create a daily routine. Get ready for work the same way you do when you’re going to the office, […] →Read more

WebRTC’s data channel uses dcSCTP instead of usrSCTP

Feautre https://bugs.chromium.org/p/webrtc/issues/detail?id=12614 Message Starting with Chrome M95 for the Canary and Dev channels, we’re going to start to rollout the DcSCTP library for the SCTP transport used by WebRTC’s Data Channels. It is a new implementation with a focus on security and compatibility with the previous implementation. No action should be required on your part […] →Read more

线程切换的经典模式

以 WebRTC library 为例,这两百行代码演示了线程切换的经典模式。 一个线程会有一个对应的任务队列,线程会不断检查这个队列,如果有任务就执行,无任务就等待 往这个任务队列中提交一个任务,就等于从当前线程切换了到了这个任务线程。 当然这个实现方面还是有些细节, 为了线程安全,GetNextTask 时需要加锁 /* * Copyright 2018 The WebRTC Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights […] →Read more

How to disable SRTP in WebRTC library

Take peerconnection_client as example webrtc::PeerConnectionFactoryInterface::Options options; options.disable_encryption = this->disable_srtp_; peer_connection_factory_->SetOptions(options); step 1 change C:\webrtc-checkout\src\examples\peerconnection\client\flag_defs.h ABSL_FLAG(bool, disable_srtp, false, "disable srtp or not: false-enable srtp, true-disable srtp"); step 2 change C:\webrtc-checkout\src\examples\peerconnection\client\conductor.h class Conductor : public webrtc::PeerConnectionObserver, public webrtc::CreateSessionDescriptionObserver, public PeerConnectionClientObserver, public MainWndCallback { public: void DisableSrtp(bool flag); bool disable_srtp_; }; void Conductor::DisableSrtp(bool flag) { this->disable_srtp_ = flag; […] →Read more

How to get media stats from peer connection

Take Peerconection_client as example step 1 class RtcStatsRecorder : public webrtc::RTCStatsCollectorCallback { public: void OnStatsDelivered(const rtc::scoped_refptr<const webrtc::RTCStatsReport>& report) override; }; step 2 void RtcStatsRecorder::OnStatsDelivered(const rtc::scoped_refptr<const webrtc::RTCStatsReport>& report) { RTC_LOG(LS_INFO) << report.ToJson() << endl; } →Read more

WebRTC 源码阅读笔记之 TrendlineEstimator

Trendline 趋势线估算器所实现的接口称为 DelayIncreaseDetectorInterface, 意谓延迟增长检测器. 每一个反馈的 PacketResult 都会用来更新这个趋势线, 这个趋势线的斜率反应了网络延迟的变化, 可以从趋势线的斜率和自适应的阈值可能得出带宽的使用状况: kBwNormal: 带宽使用正常 kBwUnderusing: 带宽使用不足 kBwOverusing: 带宽使用过度 class TrendlineEstimator : public DelayIncreaseDetectorInterface { public: TrendlineEstimator(const WebRtcKeyValueConfig* key_value_config, NetworkStatePredictor* network_state_predictor); ~TrendlineEstimator() override; /* * 用新的采样来更新估算器, 这个 delta 是指包组中第一个包和最后一个包之间的发送时间,或接收时间差 * Update the estimator with a new sample. The deltas should represent deltas * between timestamp groups as defined by […] →Read more

What is CPaaS

What is CPaaS CPaaS (Communications Platform as a Service) is a cloud-based, programmable multichannel communications platform that enables developers to customize and build on existing applications and software. CPaaS offers turnkey communications capabilities such as voice calls, SMS messaging, video conferencing, and more that programmers can add to their software without the need for additional […] →Read more