当前位置: 首页 > news >正文

WebRTC清晰度和流畅度

WebRTC清晰度和流畅度

flyfish

WebRTC提供了4种模式DISABLED,MAINTAIN_FRAMERATE,MAINTAIN_RESOLUTION,BALANCED

// Based on the spec in
// https://w3c.github.io/webrtc-pc/#idl-def-rtcdegradationpreference.
// These options are enforced on a best-effort basis. For instance, all of
// these options may suffer some frame drops in order to avoid queuing.
// TODO(sprang): Look into possibility of more strictly enforcing the
// maintain-framerate option.
// TODO(deadbeef): Default to "balanced", as the spec indicates?
enum class DegradationPreference {// Don't take any actions based on over-utilization signals. Not part of the// web API.DISABLED,// On over-use, request lower resolution, possibly causing down-scaling.MAINTAIN_FRAMERATE,// On over-use, request lower frame rate, possibly causing frame drops.MAINTAIN_RESOLUTION,// Try to strike a "pleasing" balance between frame rate or resolution.BALANCED,
};

接口是

  // See https://crbug.com/653531 and https://w3c.github.io/mst-content-hint.enum class ContentHint { kNone, kFluid, kDetailed, kText };

根据源码 接口这里不是一一对应的kDetailed和kText是类似的

webrtc::DegradationPreference
WebRtcVideoChannel::WebRtcVideoSendStream::GetDegradationPreference() const {// Do not adapt resolution for screen content as this will likely// result in blurry and unreadable text.// `this` acts like a VideoSource to make sure SinkWants are handled on the// correct thread.if (!enable_cpu_overuse_detection_) {return webrtc::DegradationPreference::DISABLED;}webrtc::DegradationPreference degradation_preference;if (rtp_parameters_.degradation_preference.has_value()) {degradation_preference = *rtp_parameters_.degradation_preference;} else {if (parameters_.options.content_hint ==webrtc::VideoTrackInterface::ContentHint::kFluid) {degradation_preference =webrtc::DegradationPreference::MAINTAIN_FRAMERATE;} else if (parameters_.options.is_screencast.value_or(false) ||parameters_.options.content_hint ==webrtc::VideoTrackInterface::ContentHint::kDetailed ||parameters_.options.content_hint ==webrtc::VideoTrackInterface::ContentHint::kText) {degradation_preference =webrtc::DegradationPreference::MAINTAIN_RESOLUTION;} else if (IsEnabled(call_->trials(), "WebRTC-Video-BalancedDegradation")) {// Standard wants balanced by default, but it needs to be tuned first.degradation_preference = webrtc::DegradationPreference::BALANCED;} else {// Keep MAINTAIN_FRAMERATE by default until BALANCED has been tuned for// all codecs and launched.degradation_preference =webrtc::DegradationPreference::MAINTAIN_FRAMERATE;}}return degradation_preference;
}

使用方法

// create a new webrtc stream
{std::lock_guard<std::mutex> mlock(m_streamMapMutex);std::map<std::string, std::pair<rtc::scoped_refptr<webrtc::VideoTrackSourceInterface>, rtc::scoped_refptr<webrtc::AudioSourceInterface>>>::iterator it = m_stream_map.find(streamLabel);if (it != m_stream_map.end()){std::pair<rtc::scoped_refptr<webrtc::VideoTrackSourceInterface>, rtc::scoped_refptr<webrtc::AudioSourceInterface>> pair = it->second;rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> videoSource(pair.first);if (!videoSource){RTC_LOG(LS_ERROR) << "Cannot create capturer video:" << videourl;}else{rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track = m_peer_connection_factory->CreateVideoTrack(streamLabel + "_video", videoSource.get());if ((video_track) && (!peer_connection->AddTrack(video_track, {streamLabel}).ok())){RTC_LOG(LS_ERROR) << "Adding VideoTrack to MediaStream failed";}else{RTC_LOG(LS_INFO) << "VideoTrack added to PeerConnection";ret = true;}					}

上述代码video_track创建好之后,调用

video_track->set_content_hint(webrtc::VideoTrackInterface::ContentHint::kDetailed);

参考
https://w3c.github.io/webrtc-pc/#idl-def-rtcdegradationpreference
https://crbug.com/653531 and https://w3c.github.io/mst-content-hint

http://www.lryc.cn/news/155611.html

相关文章:

  • 华为数通方向HCIP-DataCom H12-821题库(单选题:181-200)
  • 海康威视二次开发适配安卓电视盒子
  • NIO原理浅析(二)
  • leetcode每日一练-第53题-最大子数组和
  • 京东云接入【风险识别】接口
  • 在 linux 虚拟机上安装配置 hive
  • 作品集(陆续上传中)
  • 论文解读 | 三维点云深度学习的综述
  • 基于costas环的载波同步系统matlab性能仿真
  • 解码自我注意的魔力:深入了解其直觉和机制
  • mysql之存储引擎
  • 服务器日志出现大量NTLM(NT LAN Manager)攻击
  • Spring学习|Spring简介、IOC控制反转理解、IOC创建对象方式
  • DDR2 IP核调式记录2
  • 【ES6】js 中class的extends、super关键字用法和避坑点
  • mysql排名函数row_number()over(order by)和with * as 的用法
  • linux局域网IP地址冲突检测
  • 远距离WiFi模组方案,实现移动设备之间高效通信,无人机远程图传应用
  • Docker构建Springboot项目,并发布测试
  • flutter架构全面解析
  • QHttpServer
  • 21.3 CSS 背景属性
  • Ansible 常用命令50条
  • ceph源码阅读 erasure-code
  • C++ 之 命名空间
  • MyBatis关系映射
  • DVWA失效的访问控制
  • docker 笔记2 Docker镜像和数据卷
  • java springboot 时间格式序列化 UTC8
  • 攻防世界-Get-the-key.txt