IOS Video Live/smart Home (line of code, zero-based) lesson:1 overall architecture

Source: Internet
Author: User
<span id="Label3"></p><p><p><span style="font-size:18px"><span style="white-space:pre"></span>Some time ago due to work need to do a video Live/smart home class Application. A summary of streaming media processing for iOS audio and video columns. Here want to record the entire development process, on the one hand, and everyone to explore the study, on the other hand can also be convenient to check the leak after the Vacancy.</span></p></p><p><p><span style="font-size:18px"><span style="white-space:pre"></span>the <span style="color:#3366ff">entire development does not rely on any third-party framework, all streaming protocols are a row of lines knocked up, why? </span>The <span style="color:#cc33cc">fish is better than the award </span></span></p></p><p><p><span style="font-size:18px"><span style="color:rgb(204,51,204); white-space:pre"></span>Let's start by understanding the architecture of the entire Software.</span></p></p><p style="text-align:center"><p style="text-align:center"><span style="font-size:18px"><br></span></p></p><p><p><span style="font-size:18px"><span style="white-space:pre"></span>Front end we have introduced in the iOS audio&video column very detailed, including the camera, the audio and video processing all has done the detailed Analysis. Back end We also <span style="font-size:18px">made a detailed introduction to the IOS audio&video column in the ffmpeg, Advanced use, also no longer discussed here. The following is a detailed analysis of the network Section. </span></span></p></p><p><p><span style="font-size:18px; color:#cc33cc"><span style="font-size:18px"><span style="white-space:pre"></span>(1) RTCP</span></span></p></p><p><p><span style="white-space:pre"></span><span style="font-size:18px">RTCP:RTP</span> <span style="font-size:18px; white-space:pre">Control Protocol</span> <span style="font-size:18px; white-space:pre">, real-time Transmission control protocol, general and RTP use, mainly for data</span> <span style="font-size:18px; white-space:pre">Transmission of monitoring, control Functions. At the same time RTCP is based on UDP Transmission. </span> <span style="font-size:18px">This information transmitted by RTCP is important,</span> <span style="font-size:18px; white-space:pre">including: timestamps (for synchronization), serial numbers (for packet drops and reorder detection), and payload formats (</span> <span style="font-size:18px"> <span style="white-space:pre">encoding formats for data). </span>a simple summary of this is <span style="white-space:pre">for</span> <span style="white-space:pre">QoS</span> </span> <span style="font-size:18px; white-space:pre">feedback and synchronous media streaming. In comparison with rtp, half of its bandwidth is about 5% of RTP. Very Small. </span><span style="white-space:pre"><span style="font-size:18px"></span></span></p></p><p><p><span style="font-size:18px; white-space:pre"><span style="white-space:pre"></span>Depending on the state of use, RTCP is divided into the following situations:</span></p></p><p style="text-align:center"><p style="text-align:center"><span style="font-size:18px; white-space:pre"><span style="white-space:pre"></span></span></p></p><p><p><span style="font-size:18px"><span style="white-space:pre"></span>live, Smart Home Projects just use the Send side report, here we will in the following code in detail Analysis.</span></p></p><p><p><span style="font-size:18px"><span style="white-space:pre"></span><span style="color:#cc33cc">(2) RTP</span><span style="white-space:pre"></span></span></p></p><p><p><span style="font-size:18px"><span style="white-space:pre">real-time Transport Protocol, real-time transmission protocol, generally used for the transmission of multimedia Data. </span>audio and video mainly through this protocol transmission, it is built on the UDP protocol, more efficient but allow packet loss. So in the media reorganization need to do a lot of Work. The RTP protocol package format is as Follows:</span></p></p><p style="text-align:center"><p style="text-align:center"><span style="font-size:18px"><span style="white-space:pre"></span></span></p></p><p><p><span style="font-size:18px; color:#cc33cc"><span style="white-space:pre"></span>(3) SDP</span></p></p><p><p><span style="font-size:18px"><span style="white-space:pre"></span></span></p></p><p align="left"><p align="left"><span style="color:#262626"><span style="white-space:pre"></span>Let's take a look at the Packet-grabbing network request process:</span></p></p><p><p><span style="font-size:18px"><span style="white-space:pre"></span></span></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"></span>Server Response Data. Part of our concern: RTSP</strong></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"></span>response=rtsp/1.0 OK</strong></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"></span>Cseq:1</strong></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"></span>content-base:rtsp://192.168.36.168/</strong></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"></span>date:2015 July 29 Gmt+8 2:52:00</strong></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"></span>Content-type:application/sdp</strong></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"></span>content-length:424</strong></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"> </span>SDP section:</strong></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"></span>V=0</strong></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"></span>o=-1804289383 1804289383 in IP4 192.168.36.168</strong></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"></span>S=livestream from IOS</strong></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"></span>C=INIP4 0.0.0.0</strong></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"></span>t=00</strong></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"></span>a=control:*</strong></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"></span>M=video0 RTP/AVP 96</strong></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"></span>b=tias:85528</strong></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"></span>a=maxprate:9.0000</strong></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"></span>A=control:streamid=1</strong></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"></span>a=rtpmap:96h264/90000</strong></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"></span>a=mimetype:string; " video/h264 "</strong></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"></span>a=framesize:96720-480</strong></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"></span>a=width:integer;720</strong></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"></span>a=height:integer;480i</strong></p></p><p align="left"><p align="left"><strong><span style="white-space:pre"></span>A=fmtp:96packetization-mode=1;profile-level-id=64001e;sprop-parameter-sets=z2qahqxwwlq9pqagicba,ko4cpla=</strong></p></p><p><p><span style="font-size:18px"><span style="white-space:pre"></span>It can be clearly seen that the RTSP protocol consists of two parts, the <span style="color:rgb(38,38,38)">first</span> part is the <span style="color:rgb(38,38,38)">rtsp</span> <span style="color:rgb(38,38,38)">Transport protocol, and the other part is the</span> <span style="color:rgb(38,38,38)">SDP</span> <span style="color:rgb(38,38,38)">Protocol. SDP is not exactly the transport layer protocol, but planning to the session Layer protocol Section. </span></span> <span style="color:rgb(38,38,38); white-space:pre"><span style="font-size:18px"> <span style="color:rgb(38,38,38)">SDP</span><span style="color:#262626">(</span><span style="color:#262626">sessiondescription</span> Protocol <span style="color:#262626"> ) is a file generated by the server that describes the encoding information of the media file and the link to the server, which the client uses to set the parameters of the playback software. </span></span></span></p></p><p><p><span style="font-size:18px; color:#cc33cc"><span style="white-space:pre"></span>(4) RTSP</span></p></p><p><p><span style="font-size:18px"><span style="white-space:pre"></span>With the above analysis, we have a basic understanding of the entire structure, then there is the last part of the RTSP Protocol. <span style="font-family:arial,宋体,sans-serif; line-height:24px; text-indent:28px">Live Streaming</span> <span style="color:#000000">Transport Protocol</span> <span style="font-family:arial,宋体,sans-serif; line-height:24px; text-indent:28px">, is</span> <span style="color:#000000">TCP/IP Protocol</span> <span style="font-family:arial,宋体,sans-serif; line-height:24px; text-indent:28px">System of a</span> <span style="color:#000000">Application Layer</span> <span style="font-family:arial,宋体,sans-serif; line-height:24px; text-indent:28px">Agreement. Similar to the HTTP Protocol. As for the specific structure of the agreement we put it in the back together with the Code. </span></span></p></p><p><p><span style="font-size:18px"><span style="font-family:arial,宋体,sans-serif; line-height:24px; text-indent:28px"><span style="white-space:pre"></span>Here's a simple process for RTSP streaming: This is a typical request process:</span></span></p></p><p><p><span style="text-indent:28px"><span style="white-space:pre"><span style="font-size:18px"></span></span></span></p></p><p align="left"><p align="left"><span style="font-size:18px">1. client->server:<span style="color:#cc33cc">option</span> Request//ask s what methods are available</span></p></p><p align="left"><p align="left"><span style="font-size:18px">1. <span style="font-size:18px; text-indent:28px; white-space:pre">Server</span>-<span style="font-size:18px; text-indent:28px; white-space:pre">Client</span>:<span style="color:#cc33cc">OPTION</span> response//s response information includes all available methods provided</span></p></p><p align="left"><p align="left"><span style="font-size:18px">2. <span style="font-size:18px; text-indent:28px; white-space:pre">Client</span>-<span style="font-size:18px; text-indent:28px; white-space:pre">Server</span>:<span style="color:#339999">DESCRIBE</span> request//requires Media Initialization description information provided by S</span></p></p><p align="left"><p align="left"><span style="font-size:18px">2. <span style="font-size:18px; text-indent:28px; white-space:pre">Server</span>-<span style="font-size:18px; text-indent:28px; white-space:pre">Client</span>:<span style="color:#339999">DESCRIBE</span> response//s Response Media initialization description information, mostly SDP</span></p></p><p align="left"><p align="left"><span style="font-size:18px">3. <span style="font-size:18px; text-indent:28px; white-space:pre">Client</span>-<span style="font-size:18px; text-indent:28px; white-space:pre">Server</span>:<span style="color:#cc0000">Setup</span> request//settings session properties, and transfer mode, reminding S to establish a session</span></p></p><p align="left"><p align="left"><span style="font-size:18px">3. <span style="font-size:18px; text-indent:28px; white-space:pre">Server</span>-<span style="font-size:18px; text-indent:28px; white-space:pre">Client</span>:<span style="color:#cc0000">setup</span> response//s establish session, return session identifier, and session-related information</span></p></p><p align="left"><p align="left"><span style="font-size:18px">4. <span style="font-size:18px; text-indent:28px; white-space:pre">Client</span>-<span style="font-size:18px; text-indent:28px; white-space:pre">Server</span>:<span style="color:#3366ff"></span> play request//c requests playback</span></p></p><p align="left"><p align="left"><span style="font-size:18px">4. <span style="font-size:18px; text-indent:28px; white-space:pre">Server</span>-<span style="font-size:18px; text-indent:28px; white-space:pre">Client</span>:<span style="color:#3366ff">PLAY</span> response//s Back the information that should be requested</span></p></p><p align="left"><p align="left"><span style="font-size:18px"><span style="font-size:18px; text-indent:28px; white-space:pre">Server</span>-<span style="font-size:18px; text-indent:28px; white-space:pre">Client</span>: Sending streaming media data</span></p></p><p align="left"><p align="left"><span style="font-size:18px">5. <span style="font-size:18px; text-indent:28px; white-space:pre">Client</span>-<span style="font-size:18px; text-indent:28px; white-space:pre">Server</span>:<span style="color:#cc6600">TEARDOWN</span> REQUEST//C requests Close session</span></p></p><p align="left"><p align="left"><span style="font-size:18px">5. <span style="font-size:18px; text-indent:28px; white-space:pre">Server</span>-<span style="font-size:18px; text-indent:28px; white-space:pre">Client</span>:<span style="color:#cc6600">TEARDOWN</span> response//s back to request</span></p></p><br><p><p><span style="font-size:18px"><br></span></p></p><p><p><span style="font-size:18px"><br></span></p></p><p><p><span style="font-size:18px"><br></span></p></p><p><p><span style="font-size:18px"><br></span></p></p><p><p><span style="font-size:18px"><br></span></p></p><p><p><span style="font-size:18px"><br></span></p></p><p><p><span style="font-size:18px"><br></span></p></p><p><p><span style="font-size:18px"><br></span></p></p><p><p><span style="font-size:18px"><br></span></p></p> <p style="font-size:12px;"><p style="font-size:12px;">Copyright Notice: This article for Bo Master original article, without Bo Master permission not Reproduced.</p></p> <p><p>IOS Video Live/smart Home (line of code, zero-based) lesson:1 overall architecture</p></p></span>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.