wcs开发_WCS 5.2的评论—用于Webcast和Webcam开发人员的WebRTC服务器

wcs开发

Alice is an experienced full stack developer, who is capable of writing a SAAS project framework on her favorite framework using php in a week. As for frontend, she prefers Vue.js. 

Alice是一位经验丰富的全栈开发人员,能够在一周内使用php在她最喜欢的框架上编写SAAS项目框架。 至于前端,她更喜欢Vue.js。

A client contacts you via Telegram, asking you to develop website that will be the meeting place for the employer and the employee to conduct an in-person interview. In-person means face-to-face, a direct video contact in real time with video and voice. «Why not use Skype?» some may ask. It just so happened that serious projects – and each startup undoubtedly considers itself a serious project – are trying to offer an internal communications service for a variety of reasons, including:

客户通过电报与您联系,要求您开发一个网站,该网站将成为供雇主和员工进行面试的聚会场所。 面对面是指面对面的视频和语音实时实时视频联系。 «为什么不使用Skype?» 有人会问。 碰巧的是,认真的项目(每个初创公司都认为自己是认真的项目)出于各种原因试图提供内部通信服务,其中包括:

1) They don’t want to lend its users to third-party communicators (Skype, Hangouts, etc.) and want to retain them in the service.

1)他们不想将其用户借给第三方交流者(Skype,环聊等),并希望将其保留在服务中。

2) The want to monitor their communications, such as call history and interview results.

2)想要监视他们的通讯,例如通话记录和采访结果。

3) Record calls (naturally, notifying both parties about the recording).

3)录音(自然地,将录音通知双方)。

4) They don’t want to depend on policies and updates of third-party services. Everyone knows this story: Skype got updated, and everything goes up in smoke…

4)他们不想依赖于第三方服务的策略和更新。 每个人都知道这个故事:Skype更新了,一切都烟消云散了……

It seems like an easy task. WebRTC comes up when googling on the topic, and it seems like you can organize a peer-to-peer connection between two browsers, but there are still some questions:

这似乎是一个简单的任务。 在主题上进行搜索时出现WebRTC,似乎可以在两个浏览器之间组织对等连接,但是仍然存在一些问题:

1) Where to get STUN/TURN servers?

1)从哪里获得STUN / TURN服务器?

2) Can we do without them?

2)如果没有他们,我们可以做吗?

3) How to record a peer-to-peer WebRTC call?

3)如何记录对等WebRTC呼叫?

4) What will happen if we need to add a third party to the call, for example, an HR manager or another specialist from the employer? 

4)如果我们需要在通话中添加第三方,例如人力资源经理或雇主的另一位专家,将会发生什么?

It turns out that WebRTC and peer-to-peer alone are not enough, and it is not clear what to do with all this to launch the required video functions of the service.

事实证明,仅WebRTC和点对点是不够的,并且不清楚如何处理所有这些以启动服务所需的视频功能。

文章内容 (Article content)

内容 (Contents)

服务器和API (Server and API)

To close these gaps, server solutions and peer-server-peer architecture are used. Web Call Server 5.2 (hereinafter — WCS) is one of the server solutions; it is a development platform that allows you to add such video functions to the project and not worry about STUN/TURN and peer-to-peer connection stability.

为了缩小这些差距,使用了服务器解决方案和对等服务器对等体系结构。 Web Call Server 5.2(以下简称WCS)是服务器解决方案之一。 它是一个开发平台,可让您将此类视频功能添加到项目中,而不必担心STUN / TURN和对等连接的稳定性。

At the highest level, WCS is a JavaScript API + server part. API is used for development using regular JavaScript on the browser side, and the server processes video traffic, acting as a Stateful Proxy for media traffic.

在最高级别,WCS是JavaScript API +服务器部分。 API用于在浏览器端使用常规JavaScript进行开发,并且服务器处理视频流量,并充当媒体流量的状态代理。

In addition to the JavaScript API, there is also the Android SDK and iOS SDK, which are needed to develop native mobile applications for iOS and Android, respectively.

除了JavaScript API,还有Android SDK和iOS SDK,分别需要为iOS和Android开发本机移动应用程序。

For example, publishing a stream to the server (streaming from a webcam towards the server) looks like this:

例如,将流发布到服务器(从网络摄像头流向服务器)看起来像这样:

Web SDK

Web SDK

session.createStream({name:”stream123”}).publish();

Android SDK

Android SDK

publishStream = session.createStream(streamOptions)
publishStream.publish();

iOS SDK

iOS SDK

FPWCSApi2Stream *stream = [session createStream:options error:&error];
if(![stream publish:&error]) {
//published without errors
}

As a result, we can implement not only a web application, but also full-fledged ups for Google Play and the App Store with video streaming support. If we add mobile SDK to the top-level picture, we will get this:

结果,我们不仅可以实现Web应用程序,还可以为具有视频流支持的Google Play和App Store完善功能。 如果我们将移动SDK添加到顶层图片,则会得到以下信息:

传入流 (Incoming streams)

The streaming server, which is WCS, starts with incoming streams. To distribute something, we need to have it. To distribute video streams to viewers, it is necessary that these streams enter the server, go through its RAM, and exit through the network card. Therefore, the first question that we need to ask when familiarizing ourselves with the media server is what protocols and formats the latter uses to accept streams. In the case of WCS, these are the following technologies: WebRTC, RTMP, RTSP, VOD, SIP/RTP.

流服务器(即WCS)从传入流开始。 要分发某些东西,我们需要它。 要将视频流分发给查看者,这些流必须进入服务器,通过其RAM并通过网卡退出。 因此,在熟悉媒体服务器时,我们需要问的第一个问题是媒体服务器用来接受流的协议和格式。 对于WCS,这些是以下技术:WebRTC,RTMP,RTSP,VOD,SIP / RTP。

Each of the protocols can be used by diverse clients. For example, not only the stream from the browser can enter via WebRTC, but also from another server. In the table below there are the possible sources of incoming traffic.

每个协议都可以由不同的客户端使用。 例如,不仅来自浏览器的流可以通过WebRTC进入,而且还可以从其他服务器进入。 在下表中,可能是传入流量的来源。

WebRTCRTMPRTSPVODSIP/RTP
  • Web SDK

    • camera + mic
    • canvas
    • screen sharing
  • Android SDK
  • iOS SDK
  • WCS

    • push
    • pull
  • CDN
  • RTMP encoder

    • ffmpeg
    • OBS
    • Wirecast
  • Adobe Encoder
  • WCS

    • push
    • pull
  • Flash Player
  • IP camera
  • RTSP server
  • Filesystem
  • AWS S3
  • SIP endpoint
  • SIP conferencing
WebRTC RTMP RTSP 视频点播 SIP / RTP
  • Web SDK

    • 相机+麦克风
    • 帆布
    • 屏幕共享
  • Android SDK
  • iOS SDK
  • WCS

  • CDN
  • RTMP编码器

    • ffmpeg
    • OBS
    • 有线广播
  • Adobe编码器
  • WCS

  • Flash播放器
  • 网络摄像机
  • RTSP服务器
  • 文件系统
  • AWS S3
  • SIP端点
  • SIP会议

If we go through the sources of incoming traffic, we can add the following:

如果我们查看传入流量的来源,则可以添加以下内容:

传入的WebRTC (Incoming WebRTC)

Web SDK allows not only capturing the camera and microphone, but also using the capabilities of the browser API to access the screen by means of screen sharing. In addition, we can capture an arbitrary Canvas element, and all that is drawn on it for subsequent broadcasting is canvas streaming:

Web SDK不仅可以捕获相机和麦克风,还可以使用浏览器API的功能通过屏幕共享来访问屏幕。 此外,我们可以捕获任意的Canvas元素,并在其上进行后续广播的所有内容都是canvas流:

Due to the mobile specifics, the Android SDK and iOS SDK have the ability to switch between the front and rear cameras of the device on the go. This allows us to switch the source during streaming without having to pause the stream.

根据移动设备的具体情况,Android SDK和iOS SDK可以在旅途中在设备的前后摄像头之间进行切换。 这使我们能够在流传输期间切换源,而不必暂停流。

The incoming WebRTC stream can also be obtained from another WCS server using the push, pull and CDN methods, which will be discussed later.

传入的WebRTC流也可以使用push,pull和CDN方法从另一个WCS服务器获得,这将在后面进行讨论。

传入的RTMP (Incoming RTMP)

The RTMP protocol is widely used in the streamers’ favorite OBS, as well as in other encoders: Wirecast, Adobe Media Encoder, ffmpeg, etc. Using one of these encoders, we can capture the stream and send it to the server.

RTMP协议广泛用于流媒体最喜欢的OBS以及其他编码器中:Wirecast,Adobe Media Encoder,ffmpeg等。使用这些编码器之一,我们可以捕获流并将其发送到服务器。

We can also pick up an RTMP stream from another media server or WCS server using the push and pull methods. In the case of push, the initiator is the remote server. In the case of pull, we turn to the local server to pull the stream from the remote one.

我们还可以使用push和pull方法从另一台媒体服务器或WCS服务器中提取RTMP流。 在推送的情况下,发起者是远程服务器。 在拉的情况下,我们转向本地服务器以从远程服务器拉流。

传入的RTSP (Incoming RTSP)

Sources of RTSP traffic are usually IP cameras or third-party media servers that support RTSP protocol. Despite the fact that when initiating an RTSP connection, the initiator is WCS, the audio and video traffic in the direction from the IP camera moves towards the WCS server. Therefore, we consider the stream from the camera to be incoming.

RTSP流量的来源通常是IP摄像机或支持RTSP协议的第三方媒体服务器。 尽管启动RTSP连接时启动器是WCS,但从IP摄像机到该方向的音频和视频流量都向WCS服务器移动。 因此,我们认为来自摄像机的流是传入的。

收视点播 (Incoming VOD)

At first glance, it might seem that the VOD (Video On Demand) function is exclusively associated with outgoing streams and with the file playback by browsers. But in our case, this is not entirely true. WCS broadcasts an mp4 file from the file system to localhost; as a result, an incoming stream is created, as if it came from a third-party source. Further, if we restrict one viewer to one mp4 file, we get the classic VOD, where the viewer gets the stream and plays it from the very beginning. If we do not restrict one viewer to one mp4 file, we get VOD LIVE – a variation of VOD, in which viewers can play the same file as a stream, connecting to the playback point at which all the others are currently located (pre-recorded television broadcast mode).

乍一看,VOD(视频点播)功能似乎与传出的流以及浏览器播放的文件专门相关。 但是在我们的情况下,这并不完全正确。 WCS将mp4文件从文件系统广播到本地主机; 结果,将创建传入流,就好像它是来自第三方源。 此外,如果我们将一个查看器限制为一个mp4文件,我们将获得经典的VOD,查看器从一开始就获取流并进行播放。 如果我们不将一个观看者限制为一个mp4文件,则会获得VOD LIVE(VOD直播),这是VOD的一种变体,其中观看者可以播放与流相同的文件,并连接到当前所有其他播放器所在的播放点(录制的电视广播模式)。

传入的SIP / RTP (Incoming SIP/RTP)

To receive incoming RTP traffic inside a SIP session, we need to set up a call with a third-party SIP gateway. If the connection is successfully established, the audio and/or video traffic will go from the SIP gateway, which will be wrapped in the incoming stream on the WCS side.

要在SIP会话中接收传入的RTP流量,我们需要使用第三方SIP网关建立呼叫。 如果成功建立连接,则音频和/或视频流量将来自SIP网关,该网关将包装在WCS侧的传入流中。

外流 (Outgoing streams)

After receiving the stream to the server, we can replicate the stream received to one or many viewers on request. The viewer requests a stream from the player or other device. Such streams are called outgoing or “viewer streams,” because sessions of such streams are always initiated on the side of the viewer/player. The set of playback technologies includes the following protocols/formats: WebRTC, RTMP, RTSP, MSE, and HLS.

将流接收到服务器后,我们可以根据需要将接收到的流复制到一个或多个查看器。 观众向播放器或其他设备请求流。 此类流称为传出流或“查看者流”,因为此类流的会话始终在观看者/播放器方面启动。 回放技术集包括以下协议/格式:WebRTC,RTMP,RTSP,MSE和HLS。

WebRTCRTMPRTSPMSEHLS
  • Web SDK
  • Android SDK
  • iOS SDK
  • WC

    • pull
    • CDN
  • Flash Player
  • RTMP Players
  • RTSP Player

    • VLC
    • WCS
    • etc
  • Web SDK
  • HLS players

    • hls.js
    • native Safari
WebRTC RTMP RTSP 微软 HLS
  • Web SDK
  • Android SDK
  • iOS SDK
  • 厕所

    • CDN
  • Flash播放器
  • RTMP播放器
  • RTSP播放器

    • VLC
    • WCS
    • 等等
  • Web SDK
  • HLS播放器

    • hls.js
    • 原生Safari

即将发布的WebRTC (Outgoing WebRTC)

In this case, the Web SDK, Android SDK and iOS SDK act as the API for the player. An example of playing WebRTC stream looks like this:

在这种情况下,Web SDK,Android SDK和iOS SDK充当播放器的API。 播放WebRTC流的示例如下所示:

Web SDK

Web SDK

session.createStream({name:”stream123”}).play();

Android SDK

Android SDK

playStream = session.createStream(streamOptions);
playStream.play();

iOS SDK

iOS SDK

FPWCSApi2Stream *stream = [session createStream:options error:nil];
    if(![stream play:&error]) 
    {
   //published without errors
   }

This is very similar to the publishing API, with the only difference being that instead of stream.publish(), stream.play() is called to play.

这与发布API非常相似,唯一的区别是调用stream.play()而不是stream.publish()。

A third-party WCS server can be the player, which will be instructed to pick up the stream via WebRTC from another server using the pull method or pick up the stream inside CDN.

第三方WCS服务器可以是播放器,将被指示使用Pull方法通过WebRTC从另一台服务器中拾取流或在CDN中拾取流。

传出RTMP (Outgoing RTMP)

Here there will be mainly RTMP players – both the well-known Flash Player and desktop and mobile applications that use the RTMP protocol, receive and play an RTMP stream. Despite the fact that Flash left the browser, it kept the RTMP protocol, which is widely used for video broadcasts, and the lack of native support in browsers does not prevent the use of this quite successful protocol in other client applications. It is known that RTMP is widely used in VR players for mobile applications on Android and iOS.

这里主要是RTMP播放器-著名的Flash Player以及使用RTMP协议的台式机和移动应用程序,都可以接收和播放RTMP流。 尽管Flash离开了浏览器,但它保留了RTMP协议,该协议已广泛用于视频广播,并且浏览器缺乏本机支持并不妨碍在其他客户端应用程序中使用这种相当成功的协议。 众所周知,RTMP在VR播放器中广泛用于Android和iOS上的移动应用程序。

传出RTSP (Outgoing RTSP)

The WCS server can act as an RTSP server and distribute the received stream via RTSP as a regular IP camera. In this case, the player must establish an RTSP connection with the server and pick up the stream for playback, as if it was an IP camera.

WCS服务器可以充当RTSP服务器,并通过RTSP作为常规IP摄像机分发接收到的流。 在这种情况下,播放器必须与服务器建立RTSP连接,并选择要播放的流,就好像它是IP摄像机一样。

即将离任的MSE (Outgoing MSE)

In this case, the player requests a stream from the server using the Websocket protocol. The server distributes audio and video data via web sockets. The data reaches the browser and is converted into chunks that the browser can play thanks to the native MSE extension supported out of the box. The player ultimately works on the basis of the HTML5 video element.

在这种情况下,播放器使用Websocket协议从服务器请求流。 服务器通过Web套接字分发音频和视频数据。 由于开箱即用的本机MSE扩展,数据到达浏览器并转换为浏览器可以播放的块。 播放器最终将基于HTML5视频元素进行工作。

即将离任的HLS (Outgoing HLS)

Here, WCS acts as an HLS server or Web server that supports HLS (HTTP Live Streaming). Once the incoming stream appears on the server, an .m3u8 HLS playlist is generated, which is given to the player in response to an HTTP request. The playlist describes which video segments the player should download and display. The player downloads video segments and plays it on the browser page, on the mobile device, on the desktop, in the Apple TV set-top box, and wherever HLS support is claimed.

在此,WCS充当支持HLS(HTTP实时流)的HLS服务器或Web服务器。 一旦传入的流出现在服务器上,就会生成一个.m3u8 HLS播放列表,该列表将响应HTTP请求而提供给播放器。 播放列表描述了播放器应下载和显示的视频片段。 播放器下载视频片段,然后在浏览器页面,移动设备,台式机,Apple TV机顶盒以及要求HLS支持的任何位置播放视频片段。

传入和传出 (Incoming and outgoing)

In total, we have 5 incoming and outgoing stream types. They are listed in the table:

总共,我们有5种传入和传出的流类型。 它们在表中列出:

ВходящиеИсходящие
WebRTC WebRTC
RTMP RTMP
RTSP RTSP
VOD MSE
SIP/RTP HLS
Входящие Исходящие
WebRTC WebRTC
RTMP RTMP
RTSP RTSP
视频点播 微软
SIP / RTP HLS

That is, we can upload the streams to the server, connect to them, and play them with suitable players. To play a WebRTC stream, use the Web SDK. To play a WebRTC stream as HLS, use an HLS player, etc. One stream can be played by many spectators. One-to-many broadcasts do work.

也就是说,我们可以将流上传到服务器,进行连接,然后使用合适的播放器进行播放。 要播放WebRTC流,请使用Web SDK。 要将WebRTC流作为HLS播放,请使用HLS播放器等。许多观众可以播放一个流。 一对多广播有效。

Now, let us describe what actions can be performed with streams.

现在,让我们描述一下流可以执行的动作。

传入流操作 (Incoming stream manipulation)

Outgoing streams with spectators are not easily manipulated. Indeed, if the viewer has established a session with the server and is already getting some kind of stream, there is no way to make any changes to it without breaking the session. For this reason, all manipulations and changes take place on incoming streams, at the point where its replication has not yet occurred. The stream that has undergone changes is then distributed to all connected viewers.

带有观众的流出流不容易被操纵。 的确,如果查看者已经与服务器建立了会话并且已经获得某种流,则无法在不中断会话的情况下对其进行任何更改。 因此,所有操作和更改都在传入流上进行,此时复制尚未发生。 然后将经过更改的流分发给所有连接的查看器。

Stream opeartions include:

流选项包括:

— recording

—录音

— taking a snapshot

—拍摄快照

— adding a stream to the mixer

—将流添加到调音台

— stream transcoding

—流转码

— adding a watermark

—添加水印

— adding a FPS filter

—添加FPS过滤器

— image rotation by 90, 180, 270 degrees

—图像旋转90、180、270度

传入流录制 (Incoming stream recording)

Perhaps the most understandable and frequently encountered function. Indeed, in many cases, streams require recording: webinars, English lessons, consultations, etc. Recording can be initiated with either the Web SDK or the REST API with a special request:

也许是最易懂和经常遇到的功能。 实际上,在许多情况下,流都需要记录:网络研讨会,英语课程,咨询等。可以通过Web SDK或REST API发起记录,并有特殊要求:

/stream/startRecording {}

The result is saved in the file system as an mp4 file.

结果保存为mp4文件在文件系统中。

拍摄快照 (Taking a snapshot)

An equally common task is to take pictures of the current stream to display icons on the site. For example, we have 50 streams in a video surveillance system, each of which has one IP camera as a source. Displaying all 50 threads on one page is not only problematic for browser resources, but also pointless. In case of 30 FPS, the total FPS of the changing picture will be 1500, and the human eye simply will not accept such a display frequency. As a solution, we can configure automatic slicing or snapshot-taking on demand; in this case, images with an arbitrary frequency can be displayed on the site, for example, 1 frame in 10 seconds. Snapshots can be removed from the SDK through the REST API, or sliced automatically.

同样常见的任务是对当前流进行拍照以在站点上显示图标。 例如,在一个视频监视系统中,我们有50个流,每个流都有一个IP摄像机作为源。 在一页上显示所有50个线程不仅对浏览器资源有问题,而且毫无意义。 在30 FPS的情况下,变化图像的总FPS将为1500,而人眼根本不会接受这种显示频率。 作为解决方案,我们可以按需配置自动切片或快照; 在这种情况下,可以在现场显示任意频率的图像,例如,每10秒显示1帧。 快照可以通过REST API从SDK中删除,也可以自动切片。

The WCS server supports the REST method for receiving snapshots:

WCS服务器支持REST方法来接收快照:

/stream/snapshot

将流添加到混合器 (Adding a stream to the mixer)

An image from two or more sources can be combined into one for display to end viewers. This procedure is called mixing. Basic examples: 1) Video surveillance from multiple cameras on the screen in one picture. 2) Videoconference, where each user receives one stream, in which the rest are mixed, to save resources. The mixer is controlled via the REST API and has an MCU mode of operation for creating video conferences.

可以将来自两个或多个源的图像合并为一个图像,以显示给最终查看者。 此过程称为混合。 基本示例:1)从一张屏幕上的多个摄像机进行视频监控。 2)电视会议,每个用户接收一个流,其余流混合在一起以节省资源。 混音器通过REST API进行控制,并具有用于创建视频会议的MCU操作模式。

REST command to add a stream to the mixer:

REST命令将流添加到混合器:

/mixer/startup

流转码 (Stream transcoding)

transcoding_WebRTC_Android_iOS_SDK_API_WCS_browser_RTMP_RTSP_VOD_SIP_RTP

Streams sometimes need to be compressed in order to adapt for certain groups of client devices by resolution and bit rate. For this, transcoding is used. Transcoding can be enabled on the Web SDK side, through the REST API, or automatically through a special transcoding node in the CDN. For example, a video of 1280x720 can be transcoded to 640x360 for distribution to customers from a geographic region with a traditionally low bandwidth. Where are your satellites, Elon Musk?

有时需要压缩流,以通过分辨率和比特率适应某些客户端设备组。 为此,使用转码。 可以通过REST API在Web SDK端启用代码转换,也可以通过CDN中的特殊代码转换节点自动启用代码转换。 例如,可以将1280x720的视频转码为640x360,以从传统上带宽较低的地理区域分发给客户。 埃隆·马斯克(Elon Musk),您的卫星在哪里?

Used REST method:

使用的REST方法:

/transcoder/startup

添加水印 (Adding a watermark)

It is known that any content can be stolen and turned into WebRip, no matter what protection the player has. If your content is valuable, you can embed a watermark or logo into it that will greatly complicate its further use and public display. To add a watermark, just upload a PNG image, and it will be inserted into the video stream by transcoding. Therefore, you will have to prepare a couple of CPU cores on the server side in case you still decide to add a watermark to the stream. In order not to create the watermark on the server by transcoding, it is better to add it directly on the encoder/streamer, which often provide such an opportunity.

众所周知,无论播放器有什么保护,任何内容都可以被盗并变成WebRip。 如果您的内容有价值,则可以在其中嵌入水印或徽标,这将大大增加其进一步使用和公开展示的难度。 要添加水印,只需上传一个PNG图像,它将通过转码将其插入视频流。 因此,如果您仍然决定在流中添加水印,则必须在服务器端准备几个CPU内核。 为了不通过转码在服务器上创建水印,最好直接在编码器/流媒体上添加水印,这通常会提供这样的机会。

添加FPS过滤器 (Adding a FPS filter)

In some cases, it is required that the stream have an even FPS (frames per second). This may come in handy if we re-stream the stream to a third-party resource like Youtube or Facebook or play it with a sensitive HLS player. Filtering also requires transcoding, so make sure to properly assess the power of your server and prepare 2 cores per stream if such an operation is planned.

在某些情况下,要求流具有均匀的FPS(每秒帧数)。 如果我们将流重新流式传输到第三方资源(如Youtube或Facebook)或与敏感的HLS播放器一起播放,这可能会派上用场。 过滤还需要转码,因此,如果计划进行此类操作,请确保正确评估服务器的功能并为每个流准备2个内核。

图像旋转90、180、270度 (Image rotation by 90, 180, 270 degrees)

rotation_WebRTC_Android_iOS_SDK_API_WCS_browser_RTMP_RTSP_VOD_SIP_RTP

Mobile devices have the ability to change the resolution of the published stream depending on the angle of rotation. For example, you started to stream, holding the iPhone horizontally, and then rotated it. According to the WebRTC specification, the streamer browser of the mobile device (in this case iOS Safari) should signal the rotation to the server. In turn, The server must send this event to all subscribers. Otherwise, it would be like this – the streamer put the phone on its side, but still sees its camera vertically, while the viewers see a rotated image. To work with rotations on the SDK side, the corresponding cvoExtension extension is included.

移动设备具有根据旋转角度更改已发布流的分辨率的能力。 例如,您开始流式传输,水平握住iPhone,然后旋转它。 根据WebRTC规范,移动设备的流媒体浏览器(在本例中为iOS Safari)应向服务器发出旋转通知。 反过来,服务器必须将此事件发送给所有订阅者。 否则,将是这样–拖缆将手机放在一边,但仍然可以垂直看到其摄像头,而观看者只能看到旋转的图像。 为了在SDK端进行旋转,包含了相应的cvoExtension扩展。

传入流的管理 (Management of incoming streams )

Automatic — the configuration is usually set on the server side in the settings.

自动-配置通常是在服务器端的设置中进行设置的。

Действие с потокомWeb, iOS, Android SDKREST APIAutomaticCDN
Запись++
Снятие снапшота+++
Добавление в микшер++
Транскодирование потока++ +
Добавление водяного

знака

+
Добавление FPS-фильтра +
Поворот картинки на 90,

180, 270 градусов

+
Действиеспотоком 网络,iOS,Android SDK REST API 自动 CDN
Запись + +
Снятиеснапшота + + +
Добавлениевмикшер + +
Транскодированиепотока + + +
Добавлениеводяного

знака

+
ДобавлениеFPS-фильтра +
Повороткартинкина90,

180、270градусов

+

流中继 (Stream relaying)

Relaying is also an option for manipulating streams entering the server; it consists in forcing the stream to a third-party server. Relaying is synonymous with such words as republishing, push, inject.

中继也是操纵进入服务器的流的一种选择。 它包括强制将流传输到第三方服务器。 中继与重新发布,推送,插入等词同义。

Relaying can be implemented using one of the following protocols: WebRTC, RTMP, SIP/RTP. The table shows the direction in which the stream can be relayed.

可以使用以下协议之一实现中继:WebRTC,RTMP,SIP / RTP。 该表显示了可以中继流的方向。

WebRTCRTMPSIP/RTP
WCSRTMP server WCSSIP server
WebRTC RTMP SIP / RTP
WCS RTMP服务器WCS SIP服务器

WebRTC中继 (WebRTC relaying)

A stream can be relayed to another WCS server if for some reason it is required to make the stream available on another server. Relaying is done through the REST API via /push method. Upon receipt of such a REST request, WCS connects to the specified server and publishes a server-server stream to it. After that, the stream becomes available for playback on another machine.

如果出于某种原因需要使流在另一台服务器上可用,则可以将流中继到另一台WCS服务器。 通过REST API通过/ push方法进行中继。 收到这样的REST请求后,WCS将连接到指定的服务器并向其发布服务器-服务器流。 之后,该流可用于在另一台机器上回放。

/pull/push

— used REST method

-使用的REST方法

RTMP中继 (RTMP relaying)

As with WebRTC relaying, RTMP relaying to another server is also possible. The difference will only be in the relay protocol. RTMP relaying is also performed via /push and allows transferring the stream to both third-party RTMP servers and to services supporting RTMP Ingest: Youtube, Facebook streaming, etc. Thus, WebRTC stream can be relayed to RTMP. We might as well as relay any other stream entering the server, for example RTSP or VOD, to RTMP.

与WebRTC中继一样,也可以将RTMP中继到另一台服务器。 区别仅在于中继协议。 RTMP中继也通过/ push执行,并允许将流传输到第三方RTMP服务器和支持RTMP接收的服务:Youtube,Facebook流等。因此,WebRTC流可以中继到RTMP。 我们最好将进入服务器的任何其他流(例如RTSP或VOD)中继到RTMP。

The video stream is relayed to another RTMP server using REST calls.

使用REST调用将视频流中继到另一个RTMP服务器。

/push/startup

— used REST call

-使用的REST调用

SIP / RTP中继 (SIP/RTP relaying)

It is rarely used function. Most often, it is used in enterprise. For example, when we need to establish a SIP call with an external SIP conference server and redirect the audio or video stream to this call so that the audience of the conference sees some kind of video content: “Please watch this video” or “Colleagues, now let's watch an IP camera stream from the construction site”. We need to keep in mind that in this case, the conference itself exists and is managed on an external VKS-server with SIP support (recently, we have tested the solution from Polycom DMA), whereas we just connect and relay the existing stream to this server. The REST API function is called /inject and serves just for this case.

它是很少使用的功能。 通常,它用于企业中。 例如,当我们需要与外部SIP会议服务器建立SIP呼叫并将音频或视频流重定向到此呼叫,以便会议的观众看到某种视频内容时:“请观看此视频”或“同事” ,现在让我们观看施工现场的IP摄像机流”。 我们需要记住,在这种情况下,会议本身存在并在具有SIP支持的外部VKS服务器上进行管理(最近,我们已经测试了Polycom DMA的解决方案),而我们只是将现有流连接并中继到该服务器。 REST API函数称为/ inject,仅在这种情况下使用。

REST API command:

REST API命令:

/call/inject_stream/startup

将服务器连接到CDN内容处理网络 (Connecting servers to a CDN content processing network)

Usually, one server has a limited amount of resources. Therefore, for large online broadcasts where the audience counts for thousands and tens of thousands, scaling is necessary. Several WCS servers can be combined into one CDN content delivery network. Internally, CDN will work through WebRTC to maintain low latency during streaming.

通常,一台服务器的资源数量有限。 因此,对于观众数以万计的大型在线广播,必须进行扩展。 可以将多个WCS服务器组合到一个CDN内容传递网络中。 在内部,CDN将通过WebRTC来保持流式传输期间的低延迟。

The server can be configured in one of the following roles: Origin, Edge, or Transcoder. Origin type servers receive traffic and distribute it to the Edge servers, which are responsible for delivering the stream to viewers. If it is necessary to prepare a stream in several resolutions, Transcoder nodes are included in the scheme, which take on the resource-consuming mission of transcoding streams.

可以以以下角色之一配置服务器:Origin,Edge或Transcoder。 源类型服务器接收流量并将其分发到边缘服务器,这些边缘服务器负责将流传递给查看器。 如果有必要以几种分辨率准备一个流,则在方案中包括代码转换器节点,该代码转换器承担代码转换流的资源消耗任务。

总结一下 (To summarize)

WCS 5.2 is a server for developing applications with realtime audio and video support for browsers and mobile devices. Four APIs are provided for development: Web SDK, iOS SDK, Android SDK, REST API. We can publish (feed) video streams to the server using five protocols: WebRTC, RTMP, RTSP, VOD, SIP/RTP. From the server, we can play streams with players using five protocols: WebRTC, RTMP, RTSP, MSE, HLS. Streams can be controlled and undergo such operations as recording, slicing snapshots, mixing, transcoding, adding a watermark, filtering FPS, and broadcasting video turns on mobile devices. Streams can be relayed to other servers via WebRTC and RTMP protocols, as well as redirected to SIP conferences. Servers can be combined into a content delivery network and scaled to process an arbitrary number of video streams.

WCS 5.2是用于开发具有对浏览器和移动设备的实时音频和视频支持的应用程序的服务器。 提供了四个用于开发的API:Web SDK,iOS SDK,Android SDK,REST API。 我们可以使用五种协议将视频流发布(馈送)到服务器:WebRTC,RTMP,RTSP,VOD,SIP / RTP。 在服务器上,我们可以使用五种协议与播放器一起播放流:WebRTC,RTMP,RTSP,MSE,HLS。 可以控制流,并进行诸如记录,切片快照,混合,代码转换,添加水印,过滤FPS以及在移动设备上播放视频广播之类的操作。 流可以通过WebRTC和RTMP协议中继到其他服务器,也可以重定向到SIP会议。 可以将服务器合并到内容交付网络中,并进行扩展以处理任意数量的视频流。

爱丽丝必须了解与服务器一起使用的知识 (What Alice must know to work with the server)

The developer needs to be able to use Linux. The following commands in the command line should not cause confusion:

开发人员需要能够使用Linux。 命令行中的以下命令不应引起混淆:

tar -xvzf wcs5.2.tar.gz
cd wcs5.2
./install.sh
tail -f flashphoner.log
ps aux | grep WebCallServer
top

One also need to know Vanilla JavaScript when it comes to Web development.

在进行Web开发时,还需要了解Vanilla JavaScript。

//publishing the stream
session.createStream({name:’mystream’}).publish();
//playing the stream
session.createStream({name:’mystream’}).play();

The ability to work with the back-end may also come in handy.

使用后端的功能也可能派上用场。

WCS can not only receive control commands through the REST API, but also send hooks — i.e. notifications about events that occur on it. For example, when trying to establish a connection from a browser or mobile application, WCS will trigger the /connect hook, and when trying to play a stream, it will trigger the playStream hook. Therefore, the developer will have to walk a little in the shoes of the back ender, who is able to create both a simple REST client and a small REST server for processing hooks.

WCS不仅可以通过REST API接收控制命令,还可以发送钩子,即有关发生的事件的通知。 例如,当尝试从浏览器或移动应用程序建立连接时,WCS将触发/ connect挂钩,而在尝试播放流时,它将触发playStream挂钩。 因此,开发人员将不得不稍稍落后于后端渲染器,后者能够创建简单的REST客户端和小型REST服务器来处理钩子。

REST API example

REST API示例

/rest-api/stream/find_all

— example of REST API for listing streams on the server

—用于在服务器上列出流的REST API示例

REST hook example

REST挂钩示例

https://myback-end.com/hook/connect

- REST hook /connect processing on the backend side.

-后端的REST挂钩/连接处理。

Linux, JavaScript, REST Client / Server — three elements that are enough to develop a production service on the WCS platform working with video streams.

Linux,JavaScript,REST客户端/服务器-三个元素足以在WCS平台上使用视频流开发生产服务。

Developing mobile applications will require knowledge of Java and Objective-C for Android and iOS, respectively.

开发移动应用程序将需要分别具有Java和Objective-C(适用于Android和iOS)的知识。

安装和启动 (Installation and launch)

There are three ways to quickly launch WCS today:

现在可以通过三种方式快速启动WCS:

1) Install Ubuntu 16.x LTS or Ubuntu 18.x LTS etc. on your Centos7. or be guided by article from the documentation.

1)在Centos7上安装Ubuntu 16.x LTS或Ubuntu 18.x LTS等。 或以文档中文章为指导。

or

要么

2) Get ready-made image on Amazon EC2.

2) 在Amazon EC2上获取现成的图像

or

要么

3) Get server ready-made image on Digital Ocean.

3) 在Digital Ocean上获取服务器现成的图像

And start an exciting project development with streaming video features.

并开始使用流视频功能进行激动人心的项目开发。

The review article turned out to be quite big. Thank you for the patience to read it.

该评论文章原来很大。 感谢您耐心阅读。

Have a good streaming!

拥有良好的流媒体!

链接 (Links)

WCS 5.2 — WebRTC сервер

WCS 5.2 — WebRTC版本

安装和启动 (Installation and launch)

Installation and launch WCS Launch ready-made image on Amazon EC2 Launch server ready-made image on DigitalOcean

安装并启动WCS 在Amazon EC2上 启动现成映像在DigitalOcean上启动服务器现成映像

开发包 (SDK)

Documentation Web SDK Documentation Android SDK Documentation iOS SDK

文档Web SDK 文档Android SDK 文档iOS SDK

案例 (Cases)

Incoming streams Outgoing streams Management of streams Stream relaying CDN for low latency WebRTC streaming

传入 流传 出流流的 管理 流中继 CDN以实现低延迟WebRTC流

文献资料 (Documentation)

Documentation Web Call Server 5.2

文档Web Call Server 5.2

翻译自: https://habr.com/en/company/flashphoner/blog/482956/

wcs开发

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值