web instant messaging technology

Past methods:
  1. Ajax polling/long polling (the browser needs to continuously send requests to the server)
  2. Long connection (send a request, keep the connection without a response, send the request again after responding)
new method:
WebSocket
  • Open up the communication between the browser and the WebSocket server
  • After the browser and the server have established a connection, the two parties can freely transmit information through this connection channel, and this connection continues until one party actively closes the connection
WebRTC
  • Establish a channel between the browser and the browser. This channel can send any data without going through the server.
  • WebRTC can transmit the getUserMediaobtained video and audio streams to realize video chat.
  • Point-to-point communication application scenarios: webqq, chess and other two-person battle games, one-on-one online interviews, online education, etc.

Wireshark network communication packet capture tool

stream media

Transmission method of video stream:

  1. Point-to-point transmission p2p (not suitable for multiple people, easy to collapse)
  2. Third-party streaming media server transmission
  3. Independently build streaming media server transmission

Live broadcast technology

Application scenarios: personal live broadcasts, mobile phone live broadcasts, security cameras, etc.

Live streaming process:

  • Acquisition terminal: video acquisition, pc/mobile terminal camera and some camera equipment;
  • Streaming media server: receives the video stream pushed up from the collection end, and then pushes the video stream to the playback end;
  • Player: Various apps, players in web pages. Pull the video stream on the streaming media to transcode and play;

Push Streaming: The process of encapsulating the data collected in the acquisition phase and transmitting it to the server.
Pull stream: The process of pulling data from the server with a specified address.

Common streaming media protocols:

  1. RTMP (Real-time Message Transmission Protocol)
    can be used for the push and pull ends.
    In the RTMP protocol, the video must be H264 encoded, and the audio must be AAC or MP3 encoded, and mostly packaged in flv format.
    In the RTMP protocol, the transmission is basically a stream file in FLV format, which can only be played with a flash player.
  2. RTSP is
    used to push the stream, and the real-time effect is very good, suitable for video chat, video surveillance and other directions.
  3. HLS is
    used to pull the
    HTTP-based real-time streaming media transmission protocol defined by Apple.
    The transmission content includes two parts:
    1. M3U8 description file 2. TS media file
      TS media file video must be H264 encoding, audio must be AAC or MP3 encoding
  4. HTTP-FLV is
    used to pull the stream. The protocol is http + flv
    to encapsulate the audio and video data into flv format, and then transmit it to the client through the http protocol
Key words
  • freeswitch (a cross-platform, highly scalable, free, multi-protocol telephone softswitch platform) is
    generally used for server-side mixing
  • WebAssembly is
    a technical solution that can write code in non-javascript languages ​​and can run on the browser.
    Official website: https://wasm.zcopy.site/
  • Flv.js (HTML5 Flash video player)
  • Video.js

Guess you like

Origin blog.csdn.net/weixin_40693643/article/details/108465781