当前位置:网站首页>WebRTC 中有关 Media Stream & Track & Channel 之间的关系
WebRTC 中有关 Media Stream & Track & Channel 之间的关系
2022-08-02 14:16:00 【freeabc】
有些接触 webrtc 的朋友,对有些概念名词和概念,以及它们之间的关系云里雾里,常常被它们绕晕。下面我就带大家理一理它们之间的关系。仅供参考!

1. Media Content
我们看到所有发布的媒体内容( Media Content ) 其实是由媒体流( Media Stream ) 组成的,一个 Media Content 最常见的展现形式就是一个音视频文件,形式各种各种,也可以包括一个场景。
是个广义的定义。每个 Media Content 可以由一个或多个 Media Stream 组成,我们的音视频文件大部分包含一个 Media Stream。
2. Media Stream
Media Stream 是由一个或多个媒体流轨道 ( Media Stream Track ) 组成,一个 Media Stream Track 你可以理解为一个麦克风,一个摄像头,当然 Media Stream 也可能来自网络的对端,因此
Media Stream Track 可以理解为一个网络 SOCKET ( 这里比喻不太恰当,其实 Media Stream Track 的数据来自 SOCKET ) ,这样更形象。
3. Media Stream Track
Media Stream Track 分为两种类型,一个是音频( audio ) , 一种是视频 ( video )
一个或多个 Media Stream Track 可以组成一个 Media Stream, Media Stream Track 上面已有对应的描述,最直接的理解可以看成一个本地的输入设备,或者一个对等端数据的搜集和处理单元,
更形象的是 SOCKET 的比喻。有些设备是由多通道( channel )组成的,比如:音频采集设备,就有单声道,立体声,播放设备就有前后左右,上下等方向上的声音标识,这就是我们所说的通道,
视频的通道,也是从不同角度对视频的采集。至此,我们明白了一个 Media Stream Track 包含一个或多个通道,通道是设备所附带的属性,不同设备,定义不同。
在 webrtc 我们和对等端最常用的场景就是建立一个 Media Stream 进行交互,那么就需要产生 video 和 audio 的 Media Stream Track ,有了这些我们只是有采集或渲染的部分了,整个通话
其实就是建立两个 pipeline , 一个发送, 一个接收。 我们调用 addTrack 接口就会绑定一个流,这个流底层就是负责 Media Stream Track 的发送和接收,也就是上面说的 SOCKET 。具体怎么把 track 与 stream 进行绑定,请参阅我其它博客
下面是我查找它们三者之间关系的描述资料,以飨读者。
https://webrtc.org/getting-started/media-capture-and-constraints?hl=en
Streams and tracks
A MediaStream represents a stream of media content, which consists of tracks (MediaStreamTrack) of audio and video. You can retrieve all the tracks from MediaStream
by calling MediaStream.getTracks(), which returns an array of MediaStreamTrack objects.
MediaStreamTrack
A MediaStreamTrack has a kind property that is either audio or video, indicating the kind of media it represents. Each track can be muted by toggling its enabled property.
A track has a Boolean property remote that indicates if it is sourced by a RTCPeerConnection and coming from a remote peer.
https://developer.mozilla.org/en-US/docs/Web/API/Media_Streams_API
A MediaStream consists of zero or more MediaStreamTrack objects, representing various audio or video tracks. Each MediaStreamTrack may have one or more channels.
The channel represents the smallest unit of a media stream, such as an audio signal associated with a given speaker, like left or right in a stereo audio track.
MediaStream objects have a single input and a single output. A MediaStream object generated by getUserMedia() is called local, and has as its source input one of
the user's cameras or microphones. A non-local MediaStream may be representing a media element, like <video> or <audio>, a stream originating over the network,
and obtained via the WebRTC RTCPeerConnection API, or a stream created using the Web Audio API MediaStreamAudioSourceNode.
The output of the MediaStream object is linked to a consumer. It can be a media elements, like <audio> or <video>, the WebRTC RTCPeerConnection API or a Web Audio
API MediaStreamAudioSourceNode.
https://w3c.github.io/mediacapture-main/#mediastreamtrack
The two main components in the MediaStream API are the MediaStreamTrack and MediaStream interfaces. The MediaStreamTrack object represents media of a single type
that originates from one media source in the User Agent, e.g. video produced by a web camera. A MediaStream is used to group several MediaStreamTrack objects into
one unit that can be recorded or rendered in a media element.
Each MediaStream can contain zero or more MediaStreamTrack objects. All tracks in a MediaStream are intended to be synchronized when rendered. This is not a hard
requirement, since it might not be possible to synchronize tracks from sources that have different clocks. Different MediaStream objects do not need to be synchronized.
边栏推荐
- 【软件测试】项目中关于测试人员的简单介绍
- 代码细节带来的极致体验,ShardingSphere 5.1.0 性能提升密钥
- 优先级表和Ascll表
- 为什么Volatile能保证双重检查锁的线程安全
- Doubly linked list (normal iterators and const iterators)
- 大厂年薪50w+招聘具有测试平台开发能力的测试工程师
- 【线程安全】用户级,内核级,组合级线程|线程同步的处理(条件变量)|strtok_r(可冲入函数)
- Server-Sent Events 一种轻量级的Push方式
- Windows下mysql服务无法启动:服务没有报告任何错误。
- mongodb连接本地服务失败的问题
猜你喜欢

【线程】 理解线程(并行)线程同步的处理(信号量,互斥锁,读写锁,条件变量)

华为Mux VLAN 二层流量隔离

audio console无法连接到RPC服务

关于机组的部分知识点随笔

双链表(普通迭代器和常性迭代器)

EastWave应用:光场与石墨烯和特异介质相互作用的研究
![The relationship between base classes and derived classes [inheritance] / polymorphism and virtual functions / [inheritance and polymorphism] abstract classes and simple factories](/img/c1/c695006706ce91233d9ac8ecb95c50.png)
The relationship between base classes and derived classes [inheritance] / polymorphism and virtual functions / [inheritance and polymorphism] abstract classes and simple factories

Mysql索引底层数据结构

消息队列的技术选型

Linux下mysql的彻底卸载
随机推荐
LAMP 环境搭建 yum源安装方式 (Apache 2.4.6 +mysql 8.0.28+php 8.1.3)
How to tick the word box?
Mysql删库恢复数据
Feign Client 超时时间配置不生效
MYSQL5.7详细安装步骤
虚拟机使用的是此版本 VMware Workstation 不支持的硬件版本。模块“Upgrade”启动失败。未能启动虚拟机。
固态硬盘到底要不要分区
"Array" look-up table method (leap year)
抽象类和接口 基本知识点复习
WEB自动化之键盘、鼠标操作
CPU缓存一致性协议MESI
Three-way joint interface data security issues
Debug on pure method is called
OpenPose command line
为什么Volatile能保证双重检查锁的线程安全
【线程网络】了解线程属性(fork/interview question)
移动拷贝构造函数
【个人向】线性表复习
Google AdSense注册流程
【Solidity智能合约基础】-- 基础运算与底层位运算