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

WebRTC Peer Connection Example – Server

Overview 启动了一个 peerconnection server,也就是一个简单的 web server 用来在两个 client 之间交换信令,比如 SDP, ICE candidate 启动了两个 peerconnection client, 直接连接进行音频和视频媒体数据的传输 Windows peerconnection example peerconnection server server 比较简单,启动一个 HTTP server, 接受 client 的连接, 将接收的数据在 client 之间进行交换 两个 client 都连接到 server 上, 发送 HTTP 请求 /signin , server 把它作为一个成员(ChannelMember)加到内存中的成员列表中(PeerChannel.members) 这里有一个蹩脚的设计, 由于 server 提供的是 Http 服务,它不会主动发起请求到 client 总是等 client 来要数据(/wait),server 发现有消息缓存在内部队列(ChannelMember.queue_)中,它才把消息以 HTTP […] →Read more

WebRTC 源码阅读笔记之AcknowledgedBitrateEstimator

AcknowledgedBitrateEstimatorInterface 确认的比特率估算器接口 class AcknowledgedBitrateEstimatorInterface { public: static std::unique_ptr<AcknowledgedBitrateEstimatorInterface> Create( const WebRtcKeyValueConfig* key_value_config); virtual ~AcknowledgedBitrateEstimatorInterface(); virtual void IncomingPacketFeedbackVector( const std::vector<PacketResult>& packet_feedback_vector) = 0; virtual absl::optional<DataRate> bitrate() const = 0; virtual absl::optional<DataRate> PeekRate() const = 0; virtual void SetAlr(bool in_alr) = 0; virtual void SetAlrEndedTime(Timestamp alr_ended_time) = 0; }; AcknowledgedBitrateEstimator 确认的比特率估算器 class AcknowledgedBitrateEstimator : public AcknowledgedBitrateEstimatorInterface { […] →Read more

WebRTC 源码阅读笔记之 AlrDetector

Overview ALR(Application limited region detector)的基本原理就是 SentBitRate/EstimatedBitRate 的百分比与 kAlrStartUsagePercent(50)做比较,当小于该值认为网络受限,需要启动 probe 重新探测带宽,当大于 kAlrEndUsagePercent(80),认为网络恢复, 停止进行启动下次 probe 探测 AlrDetectorConfig 发送流量比率(sent_bitrate/estimated_bitrate) 作为网络容量的函数,用于确定应用程序受限区域 ALR(Application-Limited Region)。 ALR 区域在带宽剩余率大于 kAlrStartUsageRatio (默认为0.8) 时开始,在带宽剩余率大于 kAlrEndUsageRatio (默认为 0.5) 时结束。 注意: 带宽剩余率 = 1 – send_bitrate/estimated_bitrate 在对应用有限区域的 BW 调整进行有效微调之前,这是有意做了一些保守的。 struct AlrDetectorConfig { // Sent traffic ratio as a function of network capacity used to determine // application-limited […] →Read more

WebRTC 源码阅读笔记之传输层反馈 TransportPacketsFeedback

TransportPacketsFeedback 发送方将自己保存的包信息结合接收方反馈的接收消息 struct TransportPacketsFeedback { TransportPacketsFeedback(); TransportPacketsFeedback(const TransportPacketsFeedback& other); ~TransportPacketsFeedback(); //反馈的时间 Timestamp feedback_time = Timestamp::PlusInfinity(); //第一个没有响应的包的发送时间 Timestamp first_unacked_send_time = Timestamp::PlusInfinity(); //发送过的数据包大小 DataSize data_in_flight = DataSize::Zero(); //先前发送过的数据包大小 DataSize prior_in_flight = DataSize::Zero(); //反馈的数据包接收结果 std::vector<PacketResult> packet_feedbacks; // Arrival times for messages without send time information. std::vector<Timestamp> sendless_arrival_times; //将上述的反馈结果进行分类 std::vector<PacketResult> ReceivedWithSendInfo() const; std::vector<PacketResult> LostWithSendInfo() const; std::vector<PacketResult> PacketsWithFeedback() const; std::vector<PacketResult> […] →Read more