当前位置:网站首页>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.
边栏推荐
猜你喜欢
随机推荐
SkyWalking Agent数据采集和上报原理浅析
在mininet中测试arp欺骗
Feign Client 超时时间配置不生效
自动化之参数化
【软件测试】基础篇
win10无法识别蓝牙麦克风
虚拟机使用的是此版本 VMware Workstation 不支持的硬件版本。模块“Upgrade”启动失败。未能启动虚拟机。
Oauth2.0 资源服务器搭建
"Array" look-up table method (leap year)
Vert.x web 接收请求时反序列化对象 Failed to decode 如何解决?
JMM&synchronized&volatile详解
内存和硬盘、磁盘的区别
转行软件测试,从零收入到月薪过万,人生迎来新转折
change the available bandwidth of tcp flow dynamically in mininet
Windows下mysql服务无法启动:服务没有报告任何错误。
Google AdSense注册流程
Oauth2.0 认证服务器搭建
【软件测试】自动化测试selenium3
Apache ShardingSphere 5.1.2 发布|全新驱动 API + 云原生部署,打造高性能数据网关...
【个人向】线性表复习