Real-time video communication via WebRTC (I.)
Real-time video communication via WEBRTC (II.)
Real-time video communication via WEBRTC (iii)
In the previous article, we explained WebRTC 's overview, history, security, and developer tools. The next step is to explain the process of building WebRTC through the WebRTC three API, which will be explained in this article MediaStream.
MediaStream (alias Getusermedia)
The MediaStream API represents the synchronization of media data streams. For example, the video stream from the camera is synchronized and tracked.
The simplest way to understand MediaStream is to look at its practical application:
In Chrome or opera, open the demo Simpl.info/gum.
Open the command line.
View the global range of data rheology.
Each mediastream has an input that can be interpreted as a navigator generated by MediaStream. Getusermedia () can transmit video elements or rtcpeerconnection.
The Getusermedia () method has three parameters:
A Constraint object
A successful callback, if successful, will return a MediaStream
A failed callback that will return an Error object if it fails.
Each mediastream has a label, like ' Xk7eulhsuhkbnjlwkw4yygnjj8onsgwhbvlq ', Getaudiotradks () and Getaudiotracks () Method will return an array of Mediastreamtracks objects.
For Simpl.info/gum This example, Stream.getaudiotracks () returns an empty array (because there is no audio), assuming that a camera connection has been successful, getvideotracks () Returns an array of Mediastreamtrack objects that represent the data streams obtained from the camera. Each mediastreamtrack has a type (' video ' or ' audio '), and a label (for one or more channels), in this case, only video track, but it's easy to imagine where you can use this example, For example, a chat application front camera, rear camera, a screen sharing software and so on.
In Chrome or opera, the Url.createobjecturl () method converts MediaStream into a Blob url,blob URL that can be viewed as the src of a video element. (In Firefox and Opera, the src of the video can be set by the data stream itself).
Getusermedia can also be used as an input node for the Network audio API:
。。。。。
Source: Real-time video communication via WEBRTC (II.)
Real-time video communication via WEBRTC (ii)