This article describes how to open a RTMP The whole process from streaming media to video and audio data playing .

Be careful :RTMP The logical structure of

RTMP Provisions of the agreement , There are two prerequisites for playing a streaming media : First step , Set up a network connection (NetConnection); The second step , Build a network flow (NetStream). among , Network connectivity represents the underlying connectivity between server-side applications and clients . Network flow represents the channel for sending multimedia data . Only one network connection can be established between the server and the client , But based on this connection, you can create many network flows . Their relationship is shown in the picture :

1 Brief introduction

Play a RTMP Protocol streaming media needs to go through the following steps : handshake , Establishing a connection , Build the flow , Play .RTMP The connection starts with a handshake . The connection establishment phase is used to establish the connection between the client and the server “ network connections ”; The build flow phase is used to establish the “ Network flow ”; The playback phase is used to transmit video and audio data .

2 handshake (HandShake)

One RTMP The connection starts with a handshake , Both sides send three data blocks of fixed size

a)         The handshake starts with the client sending C0、C1 block . Server received C0 or C1 Post send S0 and S1.

b)         When the client is collected S0 and S1 after , Start sending C2. When the server is collected C0 and C1 after , Start sending S2.

c)         When the client and the server receive S2 and C2 after , The handshake is complete .

handshake

3 Set up a network connection (NetConnection)

a)         The client sends the “ Connect ”(connect) To the server , Request a connection to an instance of a service application .

b)         After the server receives the connection command message , Send confirmation window size (Window Acknowledgement Size) Protocol message to client , Also connect to the application mentioned in the connect command .

c)         Server send set bandwidth () Protocol message to client .

d)         After the client processes the set bandwidth protocol message , Send confirmation window size (Window Acknowledgement Size) Protocol messages to the server .

e)         The server sends the user control message “ The flow begins ”(Stream Begin) Message to client .

f)          The server sends the “ result ”(_result), Notify the client of the status of the connection .

Establishing a connection

4 Set up network flow (NetStream)

a)      The client sends the “ Create stream ”(createStream) Command to the server .

b)      Received by the server “ Create stream ” After the command , Send... In the command message “ result ”(_result), Notify the client of the status of the stream .

Build the flow

5 Play (Play)

a)         The client sends the “ Play ”(play) Command to server .

b)         After receiving the play command , Server send set block size (ChunkSize) Agreement message .

c)         The server sends the user control message “streambegin”, Tell the client stream ID.

d)         If the play command is successful , The server sends the “ Response state ” NetStream.Play.Start & NetStream.Play.reset, Inform client “ Play ” Command executed successfully .

e)         After that, the server sends the audio and video data that the client wants to play .

RTMP Protocol specification ( Chinese translation ):http://download.csdn.net/detail/leixiaohua1020/6563059

turn :http://blog.csdn.net/leixiaohua1020/article/details/11704355

RTMP Streaming media playing process ( turn ) More articles about

  1. RTMP Streaming media playing process

      RTMP Provisions of the agreement : First step , Set up a network connection (NetConnection): Basic connectivity between client and server The second step : Build a network flow (NetStream) Channel for sending multimedia ( Only one network connection can be established , Can be established ...

  2. RTMP Streaming media playing process ( turn )

    http://blog.csdn.net/leixiaohua1020/article/details/11704355 This article describes how to open a RTMP The whole process from streaming media to video and audio data playing . Be careful :RTM ...

  3. RTMP Streaming media playing process : handshake , Establishing a connection , Build the flow , Play

    This article talks about opening a RTMP The whole process from streaming media to video and audio data playing . There are two prerequisites for playing a streaming media : First step , Set up a network connection (NetConnection): The second step , Build a network flow (NetStream) ...

  4. videojs+hls+rtmp Streaming

    Preface : Just touching the front end , Xiaobai is one , If something goes wrong , Please correct me. , thank you ! notes : Video formats can be divided into two categories: local video suitable for local broadcast and network streaming video suitable for network broadcast . One . Introduction to Internet streaming media HTTP stream It's all ...

  5. [ summary ]RTMP Streaming media technology zero basic learning method

    This article mainly summarizes some of my learning RTMP Experience accumulated in the process of Streaming Media Technology . Also for later study RTMP Streaming media technology is a reference for people . This paper tries to go from simple to difficult , Step by step introduction RTMP All aspects of Streaming Media Technology , Let's start with applications , Gradually deepen the analysis of related work ...

  6. debugging libRTMP Code to analyze RTMP agreement

    RTMP yes Real Time Messaging Protocol( Real time messaging protocol ) An acronym for . The protocol is based on TCP, It's a protocol family , Often used in the field of live video .RTMP The default port of the protocol is 1935. Learn a protocol ...

  7. turn :RTMPDump Source code analysis

    0: Main function call analysis rtmpdump It's a RTMP Open Source Toolkit for streaming media , Support rtmp://, rtmpt://, rtmpe://, rtmpte://, and rtmps://. ...

  8. rtmpdump The code analysis turn

    RTMPdump Source code analysis 1: main() function rtmpdump It's a RTMP Streaming media toolkit , Support rtmp://, rtmpt://, rtmpe://, rtmpte://, ...

  9. RTMPdump(libRTMP) Source code analysis 4: The first step of connection —— handshake (Hand Shake)

    ===================================================== RTMPdump(libRTMP) Source code analysis series : RTMPdump Source code analysis  1: ...

Random recommendation

  1. BZOJ4060 : [Cerc2012]Word equations

    First, through hash Build up trees set up f[i][j] It means the first one i A special symbol from P Of the j Where does the bit start matching go Memory search , For the bottom greedy match . #include<cstdio> #include<cstri ...

  2. VI Classic plug-ins ctags

    Vi Classic plug-ins ctags( turn ) ( In order to improve work efficiency , You have to learn to use some tools ) . see key Related information describes the command :help keycodes ============================= ...

  3. Elaborate javascript Medium window.open() Parameter setting

    There is a problem today , Is to use javascript Medium window.open() Open a new web page , And the new page should be based on the original page , After looking up some information , Find a way out :( among ,url The address for the link ) ...

  4. canvas And ---- Floating ball

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  5. redis Database implementation

    redis Database implementation Database server End sum client End server End The database is server Storage at the end // redisServer structure struct redisServer { ...

  6. 201521123008《Java Programming 》 Summary of the eighth week experiment

    1. This week's learning summary 2. Written work The problem set of this assignment 1.List Deletion of specified elements in ( subject 4-1) 1.1 Summary of the experiment 1. When you delete an element, start with the last one , Avoid the position change after deleting the element, which leads to some elements not being deleted ...

  7. mybatis and hibernate The difference between

    mybaits It's incomplete orm( Object relation mapping (Object Relational Mapping) frame , You need to write it yourself sql sentence mybatis The difficulty of learning must be hibernate It is suitable for the soft model with low requirement of relational model ...

  8. mysql The son of query job

    # Data preparation drop table if exists class;create table class(    class_no int(2) unsigned zerofill primary key ...

  9. oracle monitor

    python Code #!/usr/bin/env python # -*- coding: UTF-8 -*- import subprocess import sys import re def ru ...

  10. ES6-- Closure array i The value of is equal to var Understanding the scope of

    var a = [];for (var i = 0; i < 10; i++) { a[i] = function () { console.log(i); };}a[6](); // 10 change ...