{"id":19007,"date":"2025-04-19T01:22:23","date_gmt":"2025-04-18T17:22:23","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/19007.html"},"modified":"2025-04-19T01:22:23","modified_gmt":"2025-04-18T17:22:23","slug":"%e6%b7%b1%e5%85%a5%e5%88%86%e6%9e%90c%e8%af%ad%e8%a8%80%e7%bc%96%e5%86%99%e7%9a%84rtsp%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%ba%90%e7%a0%81","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/19007.html","title":{"rendered":"\u6df1\u5165\u5206\u6790C\u8bed\u8a00\u7f16\u5199\u7684RTSP\u670d\u52a1\u5668\u6e90\u7801"},"content":{"rendered":"<p>  \u672c\u6587\u8fd8\u6709\u914d\u5957\u7684\u7cbe\u54c1\u8d44\u6e90&#xff0c;\u70b9\u51fb\u83b7\u53d6  <img decoding=\"async\" alt=\"menu-r.4af5f7ec.gif\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418172222-68028a4e15389.gif\" style=\"width:16px;margin-left:4px;vertical-align:text-bottom\" \/><\/p>\n<p> \u7b80\u4ecb&#xff1a;RTSP&#xff08;\u5b9e\u65f6\u6d41\u5a92\u4f53\u534f\u8bae&#xff09;\u670d\u52a1\u5668\u5141\u8bb8\u5ba2\u6237\u7aef\u63a7\u5236\u548c\u540c\u6b65\u591a\u5a92\u4f53\u6570\u636e\u7684\u4f20\u8f93\u3002\u672c\u6587\u5c06\u8be6\u89e3\u4e00\u4e2aC\u8bed\u8a00\u5b9e\u73b0\u7684&#034;rtsp_server&#034;\u6e90\u7801&#xff0c;\u6db5\u76d6\u57fa\u7840\u6982\u5ff5\u3001\u6e90\u7801\u7ed3\u6784\u3001RTSP\u8bf7\u6c42\u5904\u7406\u3001RTP\/RTCP\u534f\u8bae\u5e94\u7528\u3001\u5b9e\u73b0\u7ec6\u8282\u3001\u7f16\u8bd1\u8fd0\u884c\u4ee5\u53ca\u8c03\u8bd5\u6d4b\u8bd5\u7b49\u73af\u8282&#xff0c;\u65e8\u5728\u5e2e\u52a9\u7406\u89e3RTSP\u670d\u52a1\u5668\u7684\u5de5\u4f5c\u539f\u7406\u548c\u5b9e\u73b0\u65b9\u6cd5&#xff0c;\u63d0\u5347\u7f51\u7edc\u670d\u52a1\u5f00\u53d1\u6280\u80fd\u3002 <img decoding=\"async\" alt=\"rtsp_server C \u6e90\u7801\u8be6\u89e3\u4e0e\u5206\u6790\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418172222-68028a4e26374.png\" \/><\/p>\n<h2> 1. RTSP\u534f\u8bae\u57fa\u7840\u6982\u5ff5 <\/h2>\n<h3> \u7b80\u4ecbRTSP\u534f\u8bae <\/h3>\n<p> RTSP&#xff08;Real Time Streaming Protocol&#xff09;\u662f\u4e00\u79cd\u7f51\u7edc\u63a7\u5236\u534f\u8bae&#xff0c;\u4e13\u4e3a\u6d41\u5a92\u4f53\u670d\u52a1\u3002\u5176\u4e3b\u8981\u529f\u80fd\u662f\u5728\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u4e4b\u95f4\u5efa\u7acb\u548c\u63a7\u5236\u5a92\u4f53\u4f1a\u8bdd\u3002RTSP\u8d1f\u8d23\u7ba1\u7406\u5a92\u4f53\u4f20\u8f93&#xff0c;\u5141\u8bb8\u5ba2\u6237\u7aef\u5728\u63a5\u6536\u6570\u636e\u7684\u540c\u65f6&#xff0c;\u5bf9\u5a92\u4f53\u7684\u64ad\u653e\u3001\u6682\u505c\u3001\u5feb\u8fdb\u7b49\u8fdb\u884c\u63a7\u5236\u3002 <\/p>\n<h3> RTSP\u4e0eRTP\/RTCP\u7684\u533a\u522b <\/h3>\n<p> \u4e0eRTSP\u7d27\u5bc6\u76f8\u5173\u7684\u662fRTP&#xff08;Real-time Transport Protocol&#xff09;\u548cRTCP&#xff08;Real-time Control Protocol&#xff09;\u3002RTSP\u7528\u4e8e\u5efa\u7acb\u548c\u63a7\u5236\u5a92\u4f53\u4f1a\u8bdd&#xff0c;\u800cRTP\u8d1f\u8d23\u5a92\u4f53\u6570\u636e\u7684\u4f20\u8f93\u548c\u65f6\u95f4\u540c\u6b65\u3002RTCP\u5219\u63d0\u4f9b\u8d28\u91cf\u53cd\u9988\u548c\u4f1a\u8bdd\u7edf\u8ba1\u4fe1\u606f\u3002RTSP\u901a\u5e38\u4e0d\u8d1f\u8d23\u5a92\u4f53\u6570\u636e\u7684\u4f20\u8f93&#xff0c;\u8fd9\u662fRTP\u7684\u5de5\u4f5c\u3002RTCP\u5219\u662f\u4e3a\u4e86\u63a7\u5236RTP\u6d41\u7684\u8d28\u91cf&#xff0c;\u5982\u4e22\u5305\u7387\u3001\u5ef6\u8fdf\u7b49\u6307\u6807\u7684\u53cd\u9988\u3002 <\/p>\n<h3> RTSP\u534f\u8bae\u7684\u7279\u70b9 <\/h3>\n<p> RTSP\u534f\u8bae\u662f\u4e00\u4e2a\u5e94\u7528\u5c42\u534f\u8bae&#xff0c;\u901a\u5e38\u8fd0\u884c\u5728TCP\u6216UDP\u4e4b\u4e0a&#xff0c;\u9ed8\u8ba4\u7aef\u53e3\u4e3a554\u3002\u5b83\u5141\u8bb8\u7528\u6237\u8fdc\u7a0b\u63a7\u5236\u6d41\u5a92\u4f53\u670d\u52a1\u5668&#xff0c;\u4f8b\u5982\u70b9\u64ad\u3001\u6682\u505c\u3001\u5feb\u8fdb\u3001\u5feb\u9000\u7b49\u64cd\u4f5c\u3002RTSP\u5177\u6709\u4f1a\u8bdd\u63a7\u5236\u673a\u5236&#xff0c;\u80fd\u591f\u7ba1\u7406\u5a92\u4f53\u7684\u5b9e\u65f6\u4f20\u8f93&#xff0c;\u4e14\u5177\u5907\u9ad8\u53ef\u9760\u6027\u548c\u826f\u597d\u7684\u6269\u5c55\u6027&#xff0c;\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8e\u89c6\u9891\u76d1\u63a7\u3001\u89c6\u9891\u70b9\u64ad\u548c\u7f51\u7edc\u4f1a\u8bae\u7b49\u9886\u57df\u3002 <\/p>\n<h2> 2. rtsp_server\u6e90\u7801\u7ed3\u6784\u5206\u6790 <\/h2>\n<h3> 2.1 \u6e90\u7801\u7684\u6574\u4f53\u67b6\u6784\u6982\u8ff0 <\/h3>\n<h4> 2.1.1 \u4e3b\u8981\u6a21\u5757\u5212\u5206\u4e0e\u529f\u80fd <\/h4>\n<p> rtsp_server \u662f\u4e00\u4e2a\u590d\u6742\u7684\u591a\u7ebf\u7a0b\u670d\u52a1\u5668\u5e94\u7528&#xff0c;\u65e8\u5728\u5b9e\u73b0 RTSP \u534f\u8bae\u7684\u6240\u6709\u6838\u5fc3\u529f\u80fd\u3002\u5b83\u88ab\u8bbe\u8ba1\u4e3a\u9ad8\u5ea6\u6a21\u5757\u5316&#xff0c;\u4ee5\u4fc3\u8fdb\u53ef\u6269\u5c55\u6027\u548c\u7ef4\u62a4\u6027\u3002rtsp_server \u7684\u4e3b\u8981\u6a21\u5757\u53ef\u4ee5\u5206\u4e3a\u4ee5\u4e0b\u51e0\u4e2a\u90e8\u5206&#xff1a; <\/p>\n<ul>\n<li>  \u7f51\u7edc\u901a\u4fe1\u6a21\u5757  &#xff1a;\u8d1f\u8d23\u5904\u7406 RTSP \u6d88\u606f\u7684\u7f51\u7edc\u4f20\u8f93&#xff0c;\u5305\u62ec\u5efa\u7acb\u8fde\u63a5\u3001\u76d1\u542c\u7aef\u53e3\u3001\u6570\u636e\u63a5\u6536\u548c\u53d1\u9001\u7b49\u3002 <\/li>\n<li>  \u4f1a\u8bdd\u7ba1\u7406\u6a21\u5757  &#xff1a;\u7ba1\u7406 RTSP \u4f1a\u8bdd&#xff0c;\u5305\u62ec\u4f1a\u8bdd\u521b\u5efa\u3001\u8ba4\u8bc1\u3001\u7ef4\u62a4\u548c\u5173\u95ed\u3002 <\/li>\n<li>  \u5a92\u4f53\u6d41\u63a7\u5236\u6a21\u5757  &#xff1a;\u5904\u7406\u5a92\u4f53\u6d41\u7684\u63a7\u5236\u903b\u8f91&#xff0c;\u4f8b\u5982\u64ad\u653e\u3001\u6682\u505c\u3001\u505c\u6b62\u3001\u5feb\u8fdb\u548c\u5feb\u9000\u3002 <\/li>\n<li>  \u5a92\u4f53\u5904\u7406\u6a21\u5757  &#xff1a;\u6267\u884c\u97f3\u89c6\u9891\u6570\u636e\u7684\u7f16\u89e3\u7801\u548c\u6d41\u5f0f\u4f20\u8f93\u3002 <\/li>\n<li>  \u5b89\u5168\u6a21\u5757  &#xff1a;\u786e\u4fdd\u6570\u636e\u4f20\u8f93\u7684\u5b89\u5168\u6027&#xff0c;\u5305\u62ec\u6570\u636e\u52a0\u5bc6\u3001\u8ba4\u8bc1\u548c\u6388\u6743\u673a\u5236\u3002 <\/li>\n<\/ul>\n<h4> 2.1.2 \u6838\u5fc3\u6587\u4ef6\u7684\u7ec4\u6210\u548c\u4f5c\u7528 <\/h4>\n<p> rtsp_server \u7684\u6838\u5fc3\u6587\u4ef6\u5206\u5e03\u5927\u81f4\u5982\u4e0b&#xff1a; <\/p>\n<ul>\n<li>  main.c  &#xff1a;\u7a0b\u5e8f\u7684\u5165\u53e3\u70b9&#xff0c;\u5305\u542b\u4e3b\u5faa\u73af&#xff0c;\u8d1f\u8d23\u521d\u59cb\u5316\u548c\u914d\u7f6e\u5176\u4ed6\u6a21\u5757\u3002 <\/li>\n<li>  network.c  \u548c  network.h  &#xff1a;\u8d1f\u8d23\u5904\u7406\u5e95\u5c42\u7f51\u7edc\u901a\u4fe1&#xff0c;\u5982 socket \u7f16\u7a0b\u548c\u8fde\u63a5\u7ba1\u7406\u3002 <\/li>\n<li>  session.c  \u548c  session.h  &#xff1a;\u7528\u4e8e\u5b9e\u73b0 RTSP \u4f1a\u8bdd\u7684\u903b\u8f91\u3002 <\/li>\n<li>  stream.c  \u548c  stream.h  &#xff1a;\u5904\u7406\u5a92\u4f53\u6d41\u7684\u63a7\u5236\u548c\u6570\u636e\u4f20\u8f93\u3002 <\/li>\n<li>  media.c  \u548c  media.h  &#xff1a;\u5c01\u88c5\u4e86\u5a92\u4f53\u6570\u636e\u5904\u7406\u7684\u63a5\u53e3&#xff0c;\u5982\u7f16\u89e3\u7801\u64cd\u4f5c\u3002 <\/li>\n<li>  security.c  \u548c  security.h  &#xff1a;\u5305\u542b\u5b89\u5168\u76f8\u5173\u7684\u5904\u7406&#xff0c;\u5982 SSL\/TLS \u52a0\u5bc6\u3002 <\/li>\n<\/ul>\n<h3> 2.2 \u5173\u952e\u6570\u636e\u7ed3\u6784\u89e3\u8bfb <\/h3>\n<h4> 2.2.1 \u4f1a\u8bdd\u7ba1\u7406\u7684\u6570\u636e\u7ed3\u6784 <\/h4>\n<p> \u5728 rtsp_server \u4e2d&#xff0c;\u4f1a\u8bdd\u662f\u901a\u8fc7\u4e00\u4e2a\u7ed3\u6784\u4f53  session_t  \u6765\u7ba1\u7406\u7684&#xff0c;\u5176\u5b9a\u4e49\u5982\u4e0b&#xff1a; <\/p>\n<p>typedef struct {<br \/>\n    char id[SESSION_ID_LENGTH]; \/\/ \u552f\u4e00\u4f1a\u8bdd\u6807\u8bc6\u7b26<br \/>\n    int state;                   \/\/ \u5f53\u524d\u4f1a\u8bdd\u72b6\u6001<br \/>\n    time_t timestamp;            \/\/ \u4f1a\u8bdd\u65f6\u95f4\u6233<br \/>\n    struct in_addr client_ip;    \/\/ \u5ba2\u6237\u7aef IP \u5730\u5740<br \/>\n    uint16_t client_port;        \/\/ \u5ba2\u6237\u7aef\u7aef\u53e3<br \/>\n    \/\/ \u5176\u4ed6\u5b57\u6bb5&#8230;<br \/>\n} session_t;<\/p>\n<p> \u6bcf\u4e2a\u4f1a\u8bdd\u90fd\u6709\u4e00\u4e2a\u552f\u4e00\u7684  id  \u7528\u4e8e\u6807\u8bc6&#xff0c;  state  \u5b57\u6bb5\u8868\u793a\u4f1a\u8bdd\u7684\u5f53\u524d\u72b6\u6001&#xff08;\u5982\u7b49\u5f85\u8ba4\u8bc1\u3001\u6d3b\u8dc3\u3001\u5df2\u5173\u95ed\u7b49&#xff09;\u3002  timestamp  \u5b57\u6bb5\u7528\u4e8e\u8ddf\u8e2a\u4f1a\u8bdd\u7684\u751f\u547d\u5468\u671f\u3002 <\/p>\n<h4> 2.2.2 \u5a92\u4f53\u6d41\u7684\u63a7\u5236\u7ed3\u6784 <\/h4>\n<p> \u5a92\u4f53\u6d41\u7684\u63a7\u5236\u901a\u8fc7  stream_t  \u7ed3\u6784\u4f53\u8fdb\u884c\u7ba1\u7406&#xff0c;\u5176\u5b9a\u4e49\u5982\u4e0b&#xff1a; <\/p>\n<p>typedef struct {<br \/>\n    char uri[URI_LENGTH]; \/\/ \u6d41\u7684 URI<br \/>\n    int state;            \/\/ \u6d41\u7684\u72b6\u6001<br \/>\n    int stream_type;      \/\/ \u6d41\u7684\u7c7b\u578b&#xff08;\u5982\u97f3\u9891\u3001\u89c6\u9891&#xff09;<br \/>\n    \/\/ \u6307\u5411\u5a92\u4f53\u6570\u636e\u7684\u6307\u9488\u7b49&#8230;<br \/>\n} stream_t;<\/p>\n<p>  stream_t  \u5305\u542b\u4e86\u6d41\u7684 URI&#xff0c;  state  \u5b57\u6bb5\u8868\u793a\u5f53\u524d\u6d41\u7684\u72b6\u6001&#xff08;\u4f8b\u5982&#xff0c;\u662f\u5426\u6b63\u5728\u64ad\u653e\u3001\u6682\u505c\u7b49&#xff09;&#xff0c;  stream_type  \u8868\u793a\u5a92\u4f53\u6d41\u7684\u7c7b\u578b\u3002 <\/p>\n<h4> 2.2.3 \u7f51\u7edc\u4f20\u8f93\u7684\u6570\u636e\u7ed3\u6784 <\/h4>\n<p> \u7f51\u7edc\u4f20\u8f93\u76f8\u5173\u7684\u6570\u636e\u7ed3\u6784  connection_t  \u7528\u4e8e\u7ba1\u7406\u4e0e\u5ba2\u6237\u7aef\u7684\u8fde\u63a5&#xff0c;\u5176\u5b9a\u4e49\u5982\u4e0b&#xff1a; <\/p>\n<p>typedef struct {<br \/>\n    int sock;                          \/\/ socket \u63cf\u8ff0\u7b26<br \/>\n    struct sockaddr_in client_addr;    \/\/ \u5ba2\u6237\u7aef\u5730\u5740<br \/>\n    int timeout;                       \/\/ \u8d85\u65f6\u8bbe\u7f6e<br \/>\n    struct pollfd pfd;                 \/\/ poll \u4e8b\u4ef6\u63cf\u8ff0\u7b26<br \/>\n    \/\/ \u5176\u4ed6\u5b57\u6bb5&#8230;<br \/>\n} connection_t;<\/p>\n<p>  connection_t  \u4e2d\u5305\u542b\u4e86 socket \u63cf\u8ff0\u7b26  sock  &#xff0c;\u5ba2\u6237\u7aef\u5730\u5740\u4fe1\u606f  client_addr  &#xff0c;\u8fde\u63a5\u7684\u8d85\u65f6\u65f6\u95f4  timeout  &#xff0c;\u4ee5\u53ca\u7528\u4e8e poll \u7cfb\u7edf\u8c03\u7528\u7684  pfd  \u7ed3\u6784\u3002 <\/p>\n<p> \u4ee5\u4e0a\u5c31\u662f rtsp_server \u6e90\u7801\u7ed3\u6784\u7684\u5173\u952e\u6570\u636e\u7ed3\u6784\u3002\u5728\u4e0b\u4e00\u7ae0\u8282\u4e2d&#xff0c;\u6211\u4eec\u5c06\u6df1\u5165\u5206\u6790 RTSP \u8bf7\u6c42\u7684\u5904\u7406\u6d41\u7a0b\u3002 <\/p>\n<h2> 3. RTSP\u8bf7\u6c42\u5904\u7406\u8be6\u89e3 <\/h2>\n<h3> 3.1 RTSP\u8bf7\u6c42\u6d88\u606f\u7684\u89e3\u6790\u6d41\u7a0b <\/h3>\n<p> RTSP\u534f\u8bae\u4f5c\u4e3a\u4e00\u79cd\u63a7\u5236\u5a92\u4f53\u4f1a\u8bdd\u7684\u534f\u8bae&#xff0c;\u5176\u8bf7\u6c42\u6d88\u606f\u7684\u89e3\u6790\u662f\u6574\u4e2aRTSP\u901a\u4fe1\u4e2d\u7684\u57fa\u77f3\u3002\u89e3\u6790\u8bf7\u6c42\u6d88\u606f\u7684\u4e3b\u8981\u76ee\u7684\u662f\u7406\u89e3\u548c\u6267\u884c\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42&#xff0c;\u5982\u64ad\u653e\u3001\u6682\u505c\u3001\u505c\u6b62\u7b49\u64cd\u4f5c\u3002 <\/p>\n<h4> 3.1.1 \u8bf7\u6c42\u884c\u7684\u89e3\u6790 <\/h4>\n<p> \u8bf7\u6c42\u884c\u901a\u5e38\u5305\u62ecRTSP\u65b9\u6cd5\u3001URI\u4ee5\u53caRTSP\u534f\u8bae\u7248\u672c\u3002\u4f8b\u5982&#xff0c;\u4e00\u4e2a\u5178\u578b\u7684RTSP\u8bf7\u6c42\u884c\u662f  DESCRIBE rtsp:\/\/***\/media.sdp RTSP\/1.0  \u3002\u8fd9\u4e2a\u8bf7\u6c42\u884c\u53ef\u4ee5\u89e3\u6790\u4e3a&#xff1a; <\/p>\n<ul>\n<li> \u65b9\u6cd5&#xff1a;DESCRIBE&#xff0c;\u8868\u793a\u5ba2\u6237\u7aef\u8bf7\u6c42\u670d\u52a1\u5668\u63cf\u8ff0\u5a92\u4f53\u4fe1\u606f\u3002 <\/li>\n<li> URI&#xff1a;rtsp:\/\/***\/media.sdp&#xff0c;\u6307\u793a\u670d\u52a1\u5668\u76ee\u6807\u8d44\u6e90\u7684\u4f4d\u7f6e\u3002 <\/li>\n<li> \u534f\u8bae\u7248\u672c&#xff1a;RTSP\/1.0&#xff0c;\u6807\u8bc6RTSP\u7248\u672c\u3002 <\/li>\n<\/ul>\n<p> \u89e3\u6790\u8bf7\u6c42\u884c\u7684\u4ee3\u7801\u7247\u6bb5\u5982\u4e0b&#xff1a; <\/p>\n<p>char *method &#061; strtok(line, &#034; &#034;); \/\/ \u63d0\u53d6\u65b9\u6cd5<br \/>\nchar *uri &#061; strtok(NULL, &#034; &#034;);    \/\/ \u63d0\u53d6URI<br \/>\nchar *version &#061; strtok(NULL, &#034;\\\\r\\\\n&#034;); \/\/ \u63d0\u53d6\u7248\u672c\u4fe1\u606f<\/p>\n<p>\/\/ \u53c2\u6570\u68c0\u67e5\u4e0e\u5904\u7406\u903b\u8f91&#8230;<\/p>\n<h4> 3.1.2 \u8bf7\u6c42\u5934\u7684\u89e3\u6790 <\/h4>\n<p> \u8bf7\u6c42\u5934\u5305\u542b\u4e86\u591a\u4e2a\u5b57\u6bb5&#xff0c;\u8fd9\u4e9b\u5b57\u6bb5\u63d0\u4f9b\u4e86\u8bf7\u6c42\u7684\u9644\u52a0\u4fe1\u606f\u3002\u6bd4\u5982  CSeq  \u5b57\u6bb5\u6307\u660e\u4e86\u8bf7\u6c42\u7684\u5e8f\u5217\u53f7&#xff0c;\u7528\u4e8e\u540c\u6b65\u8bf7\u6c42\u548c\u54cd\u5e94\u3002\u89e3\u6790\u8bf7\u6c42\u5934\u7684\u4ee3\u7801\u7247\u6bb5\u53ef\u80fd\u5982\u4e0b&#xff1a; <\/p>\n<p>while (1) {<br \/>\n    char *field_name &#061; strtok(NULL, &#034;: &#034;);<br \/>\n    char *field_value &#061; strtok(NULL, &#034;\\\\r\\\\n&#034;);<br \/>\n    if (field_name &#061;&#061; NULL || field_value &#061;&#061; NULL) break; \/\/ \u8bed\u6cd5\u7ed3\u675f<\/p>\n<p>    \/\/ \u5b57\u6bb5\u540d\u548c\u503c\u7684\u6620\u5c04\u5904\u7406&#8230;<br \/>\n}<\/p>\n<p> \u8bf7\u6c42\u5934\u7684\u89e3\u6790\u5e94\u652f\u6301\u591a\u884c\u5b57\u6bb5\u503c\u7684\u5904\u7406&#xff0c;\u4f8b\u5982  Session  \u5b57\u6bb5\u53ef\u80fd\u8de8\u8d8a\u591a\u884c\u3002 <\/p>\n<h3> 3.2 RTSP\u54cd\u5e94\u6d88\u606f\u7684\u6784\u9020\u6d41\u7a0b <\/h3>\n<p> RTSP\u54cd\u5e94\u6d88\u606f\u7684\u6784\u9020\u9700\u8981\u4e25\u683c\u6309\u7167RTSP\u534f\u8bae\u89c4\u8303\u6765\u6784\u9020\u54cd\u5e94\u884c\u548c\u54cd\u5e94\u5934&#xff0c;\u540c\u65f6\u643a\u5e26\u54cd\u5e94\u4f53\u3002 <\/p>\n<h4> 3.2.1 \u54cd\u5e94\u884c\u7684\u6784\u9020 <\/h4>\n<p> \u54cd\u5e94\u884c\u5305\u62ecRTSP\u7248\u672c\u3001\u72b6\u6001\u7801\u548c\u72b6\u6001\u7801\u63cf\u8ff0\u3002\u4f8b\u5982&#xff0c;\u6210\u529f\u7684\u54cd\u5e94\u53ef\u80fd\u5982\u4e0b\u6240\u793a&#xff1a; <\/p>\n<p>RTSP\/1.0 200 OK<\/p>\n<p> \u72b6\u6001\u7801  200  \u8868\u793a\u8bf7\u6c42\u5df2\u88ab\u6210\u529f\u5904\u7406\u3002 <\/p>\n<h4> 3.2.2 \u54cd\u5e94\u5934\u7684\u6784\u9020 <\/h4>\n<p> \u54cd\u5e94\u5934\u53ef\u4ee5\u5305\u542b\u591a\u79cd\u5b57\u6bb5&#xff0c;\u6bd4\u5982  Content-Type  \u6307\u660e\u54cd\u5e94\u4f53\u7684\u7c7b\u578b&#xff0c;  Content-Length  \u6307\u660e\u54cd\u5e94\u4f53\u7684\u957f\u5ea6\u3002\u6784\u9020\u54cd\u5e94\u5934\u7684\u4ee3\u7801\u7247\u6bb5\u53ef\u80fd\u5982\u4e0b&#xff1a; <\/p>\n<p>void construct_response_head(char *buffer, int content_length, const char* content_type) {<br \/>\n    snprintf(buffer, BUFFER_SIZE, &#034;RTSP\/1.0 %d %s\\\\r\\\\n&#034;, 200, &#034;OK&#034;);<br \/>\n    strcat(buffer, &#034;Content-Type: &#034;);<br \/>\n    strcat(buffer, content_type);<br \/>\n    strcat(buffer, &#034;\\\\r\\\\n&#034;);<br \/>\n    strcat(buffer, &#034;Content-Length: &#034;);<br \/>\n    strcat(buffer, content_length);<br \/>\n    strcat(buffer, &#034;\\\\r\\\\n\\\\r\\\\n&#034;);<br \/>\n}<\/p>\n<p> \u6784\u9020\u54cd\u5e94\u5934\u65f6&#xff0c;\u9700\u8981\u786e\u4fdd\u6b63\u786e\u8bbe\u7f6e\u5b57\u6bb5\u987a\u5e8f\u5e76\u7ec8\u6b62\u884c\u3002 <\/p>\n<h3> 3.3 \u4f1a\u8bdd\u72b6\u6001\u7684\u7ba1\u7406\u673a\u5236 <\/h3>\n<p> \u4f1a\u8bdd\u72b6\u6001\u7ba1\u7406\u662fRTSP\u670d\u52a1\u5668\u7684\u91cd\u8981\u7ec4\u6210\u90e8\u5206&#xff0c;\u5b83\u8d1f\u8d23\u4f1a\u8bdd\u7684\u5efa\u7acb\u3001\u7ef4\u62a4\u548c\u7ed3\u675f\u3002 <\/p>\n<h4> 3.3.1 \u4f1a\u8bdd\u7684\u5efa\u7acb\u548c\u7ef4\u62a4 <\/h4>\n<p> \u4f1a\u8bdd\u7684\u5efa\u7acb\u662f\u901a\u8fc7\u5ba2\u6237\u7aef\u53d1\u8d77DESCRIBE\u8bf7\u6c42&#xff0c;\u5e76\u901a\u8fc7\u670d\u52a1\u5668\u7684\u54cd\u5e94\u4e2d\u8fd4\u56de\u7684  Session  \u5934\u5b57\u6bb5\u3002\u7ef4\u62a4\u4f1a\u8bdd\u901a\u5e38\u9700\u8981\u5b9a\u671f\u4ea4\u4e92\u5982OPTIONS\u6216PLAY\u8bf7\u6c42&#xff0c;\u4ee5\u7ef4\u6301\u4f1a\u8bdd\u7684\u6d3b\u8dc3\u72b6\u6001\u3002 <\/p>\n<h4> 3.3.2 \u4f1a\u8bdd\u7684\u5173\u95ed\u548c\u6e05\u7406 <\/h4>\n<p> \u4f1a\u8bdd\u7684\u5173\u95ed\u53ef\u4ee5\u901a\u8fc7\u5ba2\u6237\u7aef\u53d1\u9001TEARDOWN\u8bf7\u6c42\u6765\u5b8c\u6210&#xff0c;\u6216\u8005\u670d\u52a1\u5668\u7aef\u5728\u4e00\u5b9a\u6761\u4ef6\u4e0b\u81ea\u52a8\u5173\u95ed\u7a7a\u95f2\u7684\u4f1a\u8bdd\u3002\u6e05\u7406\u4f1a\u8bdd\u65f6&#xff0c;\u9700\u8981\u91ca\u653e\u670d\u52a1\u5668\u7aef\u6240\u6709\u4e0e\u8be5\u4f1a\u8bdd\u76f8\u5173\u7684\u8d44\u6e90\u3002 <\/p>\n<p> \u603b\u7ed3\u4ee5\u4e0a\u5185\u5bb9&#xff0c;RTSP\u8bf7\u6c42\u5904\u7406\u6d41\u7a0b\u6db5\u76d6\u4e86\u4ece\u89e3\u6790\u5ba2\u6237\u7aef\u8bf7\u6c42\u5230\u6784\u9020\u54cd\u5e94\u6d88\u606f&#xff0c;\u5e76\u7ba1\u7406\u4f1a\u8bdd\u72b6\u6001\u7684\u5b8c\u6574\u8fc7\u7a0b\u3002\u6bcf\u4e00\u73af\u8282\u90fd\u9700\u8981\u4e25\u683c\u9075\u5b88RTSP\u534f\u8bae\u7684\u6807\u51c6&#xff0c;\u786e\u4fdd\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u4e4b\u95f4\u80fd\u591f\u6b63\u786e\u9ad8\u6548\u5730\u901a\u4fe1\u3002 <\/p>\n<h2> 4. RTP\u548cRTCP\u534f\u8bae\u5728\u5a92\u4f53\u6570\u636e\u4f20\u8f93\u4e2d\u7684\u5e94\u7528 <\/h2>\n<h3> 4.1 RTP\u534f\u8bae\u7684\u57fa\u672c\u539f\u7406\u548c\u5e94\u7528 <\/h3>\n<h4> 4.1.1 RTP\u6570\u636e\u5305\u7684\u5c01\u88c5\u4e0e\u4f20\u8f93 <\/h4>\n<p> RTP&#xff08;Real-time Transport Protocol&#xff0c;\u5b9e\u65f6\u4f20\u8f93\u534f\u8bae&#xff09;\u662f\u4e00\u79cd\u7f51\u7edc\u534f\u8bae&#xff0c;\u7528\u4e8e\u901a\u8fc7IP\u7f51\u7edc\u4f20\u8f93\u97f3\u9891\u548c\u89c6\u9891\u6d41\u3002\u5728\u591a\u5a92\u4f53\u901a\u4fe1\u7cfb\u7edf\u4e2d&#xff0c;RTP\u4e3b\u8981\u8d1f\u8d23\u6570\u636e\u7684\u7aef\u5230\u7aef\u4f20\u8f93\u529f\u80fd&#xff0c;\u786e\u4fdd\u5a92\u4f53\u6570\u636e\u53ef\u4ee5\u5b9e\u65f6\u3001\u8fde\u7eed\u5730\u4f20\u8f93\u7ed9\u63a5\u6536\u7aef\u3002RTP\u6570\u636e\u5305\u88ab\u5c01\u88c5\u5728UDP\u6570\u636e\u62a5\u6587\u4e2d\u8fdb\u884c\u4f20\u8f93&#xff0c;\u56e0\u4e3a\u5b83\u9700\u8981\u5feb\u901f\u4f20\u8f93&#xff0c;\u800cUDP\u6ca1\u6709\u590d\u6742\u7684\u8fde\u63a5\u5efa\u7acb\u8fc7\u7a0b&#xff0c;\u9002\u5408\u5b9e\u65f6\u901a\u4fe1\u3002 <\/p>\n<p> RTP\u6570\u636e\u5305\u7684\u7ed3\u6784\u5982\u4e0b&#xff1a; &#8211; RTP\u62a5\u5934&#xff1a;\u5305\u542b\u5e8f\u5217\u53f7\u3001\u65f6\u95f4\u6233\u3001SSRC&#xff08;\u540c\u6b65\u6e90\u6807\u8bc6\u7b26&#xff09;\u7b49\u4fe1\u606f\u3002 &#8211; \u8f7d\u8377&#xff1a;\u5b9e\u9645\u7684\u97f3\u9891\u6216\u89c6\u9891\u6570\u636e\u3002 <\/p>\n<p>  ***<br \/>\n  ***<br \/>\n &#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;<br \/>\n |V&#061;2|P|X|  CC   |M|     PT      |       sequence number         |<br \/>\n &#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;<br \/>\n |                           timestamp                           |<br \/>\n &#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;<br \/>\n |           synchronization source (SSRC) identifier            |<br \/>\n &#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;<br \/>\n |            contributing source (CSRC) identifiers             |<br \/>\n |                             &#8230;.                              |<br \/>\n &#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;<\/p>\n<p> \u5e8f\u5217\u53f7\u7528\u4e8e\u6570\u636e\u5305\u6392\u5e8f\u548c\u68c0\u6d4b\u4e22\u5931&#xff0c;\u65f6\u95f4\u6233\u8868\u793a\u5a92\u4f53\u6570\u636e\u5305\u7684\u91c7\u6837\u65f6\u95f4&#xff0c;SSRC\u7528\u4e8e\u6807\u8bc6\u540c\u6b65\u6e90\u3002 <\/p>\n<h4> 4.1.2 RTP\u6d41\u540c\u6b65\u548c\u65f6\u5e8f\u63a7\u5236 <\/h4>\n<p> \u4e3a\u4e86\u5728\u63a5\u6536\u7aef\u4fdd\u6301\u5a92\u4f53\u6570\u636e\u7684\u540c\u6b65\u548c\u65f6\u5e8f&#xff0c;RTP\u4f7f\u7528\u4e86\u65f6\u95f4\u6233\u548c\u5e8f\u5217\u53f7\u4e24\u4e2a\u5173\u952e\u5b57\u6bb5\u3002\u65f6\u95f4\u6233\u53cd\u6620\u4e86\u6570\u636e\u5305\u4e2d\u7b2c\u4e00\u4e2a\u5b57\u8282\u7684\u91c7\u6837\u65f6\u95f4&#xff0c;\u5e8f\u5217\u53f7\u7528\u4e8e\u68c0\u6d4b\u6570\u636e\u5305\u4e22\u5931\u548c\u91cd\u6392\u5e8f\u3002\u63a5\u6536\u7aef\u6839\u636e\u8fd9\u4e9b\u4fe1\u606f\u53ef\u4ee5\u6267\u884c\u7f13\u51b2\u3001\u540c\u6b65\u4ee5\u53ca\u7ea0\u6b63\u5931\u5e8f\u7684\u6570\u636e\u5305\u3002 <\/p>\n<p> \u63a5\u6536\u7aef\u5904\u7406RTP\u6d41\u7684\u57fa\u672c\u903b\u8f91\u5982\u4e0b&#xff1a; 1. \u5229\u7528\u65f6\u95f4\u6233\u5224\u65ad\u6570\u636e\u5305\u7684\u91c7\u6837\u65f6\u95f4\u3002 2. \u901a\u8fc7\u5e8f\u5217\u53f7\u68c0\u6d4b\u548c\u91cd\u65b0\u6392\u5e8f\u5230\u8fbe\u7684\u6570\u636e\u5305\u3002 3. \u5982\u679c\u68c0\u6d4b\u5230\u4e22\u5305&#xff0c;\u53ef\u4ee5\u8fdb\u884c\u9519\u8bef\u9690\u85cf\u6216\u8bf7\u6c42\u91cd\u4f20&#xff08;\u5982\u679c\u534f\u8bae\u652f\u6301&#xff09;\u3002 <\/p>\n<h3> 4.2 RTCP\u534f\u8bae\u7684\u57fa\u672c\u539f\u7406\u548c\u5e94\u7528 <\/h3>\n<h4> 4.2.1 RTCP\u62a5\u544a\u7684\u751f\u6210\u4e0e\u4f20\u8f93 <\/h4>\n<p> RTCP&#xff08;Real-time Control Protocol&#xff0c;\u5b9e\u65f6\u63a7\u5236\u534f\u8bae&#xff09;\u4e0eRTP\u914d\u5408\u4f7f\u7528&#xff0c;\u63d0\u4f9b\u4f20\u8f93\u63a7\u5236\u529f\u80fd\u3002RTCP\u5468\u671f\u6027\u5730\u5728\u63a5\u6536\u7aef\u751f\u6210\u63a7\u5236\u4fe1\u606f&#xff0c;\u5e76\u5728\u53d1\u9001\u7aef\u6536\u96c6\u8fd9\u4e9b\u4fe1\u606f&#xff0c;\u4ee5\u76d1\u63a7\u6570\u636e\u4f20\u8f93\u7684\u8d28\u91cf\u548c\u7edf\u8ba1\u4fe1\u606f&#xff0c;\u5e76\u63d0\u4f9b\u53cd\u9988\u3002RTCP\u63a7\u5236\u5305\u901a\u5e38\u5305\u542b\u53d1\u9001\u8005\u62a5\u544a&#xff08;SR&#xff09;\u548c\u63a5\u6536\u8005\u62a5\u544a&#xff08;RR&#xff09;&#xff0c;\u4ee5\u53ca\u5176\u4ed6\u7c7b\u578b\u7684\u63a7\u5236\u6d88\u606f&#xff0c;\u5982\u6e90\u63cf\u8ff0\u9879&#xff08;SDES&#xff09;&#xff0c;\u5e94\u7528\u7279\u5b9a\u7684\u6d88\u606f&#xff08;APP&#xff09;\u7b49\u3002 <\/p>\n<p> RTCP\u7684\u53d1\u9001\u8005\u62a5\u544a&#xff08;SR&#xff09;\u793a\u4f8b\u5982\u4e0b&#xff1a; <\/p>\n<p>  ***<br \/>\n  ***<br \/>\n &#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;<br \/>\n |V&#061;2|P|    RC     | PT&#061;SR&#061;200     |             length            |<br \/>\n &#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;<br \/>\n |                         SSRC of sender                        |<br \/>\n &#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;<br \/>\n |              NTP timestamp, most significant word             |<br \/>\n &#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;<br \/>\n |             NTP timestamp, least significant word             |<br \/>\n &#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;<br \/>\n |                         RTP timestamp                          |<br \/>\n &#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;<br \/>\n |                     sender&#039;s packet count                     |<br \/>\n &#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;<br \/>\n |                      sender&#039;s octet count                     |<br \/>\n &#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;<br \/>\n |                 SSRC_1 (SSRC of first source)                 |<br \/>\n &#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;<br \/>\n | fraction lost |       cumulative number of packets lost       |<br \/>\n &#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;<br \/>\n |           extended highest sequence number received           |<br \/>\n &#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;<br \/>\n |                      inter-arrival jitter                      |<br \/>\n &#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;<br \/>\n |                         last SR (LSR)                         |<br \/>\n &#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;-&#043;<br \/>\n |                   delay since last SR (DLSR)                  |<br \/>\n &#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;<br \/>\n |                 SSRC_2 (SSRC of second source)                |<br \/>\n &#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;<br \/>\n :            &#8230; continued additional blocks            :<br \/>\n &#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;&#061;&#043;<\/p>\n<p> \u5728\u6bcf\u4e2a\u62a5\u544a\u4e2d&#xff0c;\u4f1a\u5305\u542b\u53d1\u9001\u7aef\u548c\u63a5\u6536\u7aef\u7684\u7edf\u8ba1\u4fe1\u606f&#xff0c;\u5982\u4e22\u5305\u7387\u3001\u6296\u52a8\u7b49\u3002 <\/p>\n<h4> 4.2.2 \u5a92\u4f53\u8d28\u91cf\u53cd\u9988\u4e0e\u62e5\u585e\u63a7\u5236 <\/h4>\n<p> RTCP\u63d0\u4f9b\u4e86\u4e00\u4e2a\u53cd\u9988\u673a\u5236&#xff0c;\u63a5\u6536\u7aef\u53ef\u4ee5\u53d1\u9001RTCP\u63a5\u6536\u8005\u62a5\u544a&#xff08;RR&#xff09;\u7ed9\u53d1\u9001\u7aef&#xff0c;\u62a5\u544a\u4e2d\u5305\u542b\u63a5\u6536\u7aef\u5bf9\u5a92\u4f53\u8d28\u91cf\u7684\u8bc4\u4f30&#xff0c;\u4f8b\u5982\u4e22\u5305\u7387\u548c\u6296\u52a8\u3002\u53d1\u9001\u7aef\u6839\u636e\u8fd9\u4e9b\u53cd\u9988\u4fe1\u606f\u53ef\u4ee5\u8c03\u6574\u4f20\u8f93\u901f\u7387&#xff0c;\u8fdb\u884c\u62e5\u585e\u63a7\u5236\u4ee5\u4fdd\u8bc1\u8d28\u91cf\u3002 <\/p>\n<p> \u4f8b\u5982&#xff0c;\u5982\u679c\u68c0\u6d4b\u5230\u9ad8\u4e22\u5305\u7387&#xff0c;\u53d1\u9001\u7aef\u53ef\u80fd\u4f1a\u964d\u4f4e\u6bd4\u7279\u7387\u4ee5\u51cf\u5c11\u7f51\u7edc\u8d1f\u8f7d&#xff0c;\u53cd\u4e4b\u4ea6\u7136\u3002RTCP\u7684\u53cd\u9988\u8fd8\u53ef\u4ee5\u7528\u4e8e\u5176\u4ed6\u63a7\u5236\u529f\u80fd&#xff0c;\u5982\u5a92\u4f53\u540c\u6b65\u3001\u591a\u64ad\u7ba1\u7406\u3001\u4f1a\u8bae\u63a7\u5236\u7b49\u3002 <\/p>\n<h3> 4.3 RTP\/RTCP\u4e0eRTSP\u7684\u4ea4\u4e92\u673a\u5236 <\/h3>\n<h4> 4.3.1 \u534f\u8bae\u6808\u95f4\u7684\u534f\u540c\u5de5\u4f5c\u6d41\u7a0b <\/h4>\n<p> RTP\/RTCP\u4e0eRTSP\u534f\u8bae\u6808\u4e4b\u95f4\u9700\u8981\u534f\u540c\u5de5\u4f5c\u4ee5\u786e\u4fdd\u5a92\u4f53\u6d41\u7684\u5b9e\u65f6\u4f20\u8f93\u548c\u63a7\u5236\u3002RTSP\u534f\u8bae\u8d1f\u8d23\u5efa\u7acb\u548c\u63a7\u5236\u5a92\u4f53\u4f1a\u8bdd&#xff0c;\u800cRTP\/RTCP\u8d1f\u8d23\u5b9e\u9645\u7684\u5a92\u4f53\u6570\u636e\u4f20\u8f93\u548c\u4f20\u8f93\u63a7\u5236\u3002\u5728\u4f1a\u8bdd\u5efa\u7acb\u65f6&#xff0c;RTSP\u534f\u5546RTP\u7684\u7aef\u53e3\u548c\u5a92\u4f53\u6d41\u53c2\u6570&#xff0c;\u968f\u540eRTP\/RTCP\u5728\u8fd9\u4e9b\u53c2\u6570\u7684\u6307\u5bfc\u4e0b\u5f00\u59cb\u6570\u636e\u4f20\u8f93\u3002 <\/p>\n<p> RTSP\u4ea4\u4e92\u6d41\u7a0b\u4e00\u822c\u4e3a&#xff1a; 1. \u53d1\u9001SETUP\u8bf7\u6c42&#xff0c;\u914d\u7f6e\u5a92\u4f53\u4f1a\u8bdd\u3002 2. \u53d1\u9001PLAY\u8bf7\u6c42&#xff0c;\u5f00\u59cb\u5a92\u4f53\u4f20\u8f93\u3002 3. RTP\/RTCP\u5f00\u59cb\u4f20\u8f93\u6570\u636e&#xff0c;\u540c\u65f6RTCP\u53d1\u9001\u63a7\u5236\u62a5\u544a\u3002 4. \u4f20\u8f93\u8fc7\u7a0b\u4e2d&#xff0c;RTSP\u53ef\u4ee5\u8c03\u6574\u4f1a\u8bdd\u53c2\u6570&#xff0c;\u6216\u8005\u53d1\u9001TEARDOWN\u7ec8\u6b62\u4f1a\u8bdd\u3002 <\/p>\n<h4> 4.3.2 \u5a92\u4f53\u6d41\u7684\u5b9e\u65f6\u63a7\u5236\u548c\u8c03\u6574 <\/h4>\n<p> \u5b9e\u65f6\u5a92\u4f53\u6d41\u9700\u8981\u9002\u5e94\u7f51\u7edc\u6761\u4ef6\u7684\u53d8\u5316&#xff0c;\u8fdb\u884c\u5b9e\u65f6\u63a7\u5236\u548c\u8c03\u6574\u3002RTCP\u7684\u53cd\u9988\u4fe1\u606f\u53ef\u4ee5\u6307\u5bfc\u53d1\u9001\u7aef\u8c03\u6574\u5176\u53d1\u9001\u901f\u7387&#xff0c;\u800cRTSP\u63d0\u4f9b\u4e86\u4f1a\u8bdd\u63a7\u5236\u7684\u624b\u6bb5\u3002\u4f8b\u5982&#xff0c;\u5728\u7f51\u7edc\u5e26\u5bbd\u4e0b\u964d\u65f6&#xff0c;\u53d1\u9001\u7aef\u53ef\u4ee5\u964d\u4f4e\u7f16\u7801\u6bd4\u7279\u7387&#xff0c;\u6216\u8005\u5728\u4e22\u5305\u4e25\u91cd\u65f6\u8bf7\u6c42\u91cd\u4f20\u91cd\u8981\u6570\u636e\u5305\u3002 <\/p>\n<p> \u5177\u4f53\u63a7\u5236\u52a8\u4f5c\u5305\u62ec&#xff1a; &#8211; \u52a8\u6001\u8c03\u6574\u7f16\u7801\u53c2\u6570&#xff0c;\u5982\u6bd4\u7279\u7387\u3001\u5e27\u7387\u3002 &#8211; \u5728\u68c0\u6d4b\u5230\u7f51\u7edc\u62e5\u585e\u65f6&#xff0c;\u91c7\u53d6\u9002\u5e94\u6027\u4f20\u8f93\u7b56\u7565\u3002 &#8211; \u6839\u636e\u4f1a\u8bdd\u72b6\u6001&#xff0c;\u63a7\u5236\u5a92\u4f53\u7684\u64ad\u653e\u3001\u6682\u505c\u6216\u505c\u6b62\u3002 <\/p>\n<p> \u4ee5\u4e0a\u7ec6\u8282\u5c55\u793a\u4e86RTP\u548cRTCP\u534f\u8bae\u5728\u5b9e\u65f6\u5a92\u4f53\u4f20\u8f93\u4e2d\u7684\u57fa\u672c\u5e94\u7528\u548c\u4ea4\u4e92\u673a\u5236\u3002\u8fd9\u4e9b\u534f\u8bae\u6808\u4e4b\u95f4\u7684\u5bc6\u5207\u914d\u5408\u662f\u5b9e\u73b0\u7a33\u5b9a\u3001\u9ad8\u8d28\u91cf\u7684\u5b9e\u65f6\u901a\u4fe1\u7cfb\u7edf\u7684\u57fa\u7840\u3002 <\/p>\n<h2> 5. \u6e90\u7801\u5b9e\u73b0\u7ec6\u8282\u63a2\u8ba8 <\/h2>\n<h3> 5.1 \u7f51\u7edc\u5c42\u7684\u5b9e\u73b0\u7ec6\u8282 <\/h3>\n<h4> 5.1.1 \u7f51\u7edc\u4e8b\u4ef6\u7684\u76d1\u542c\u4e0e\u5904\u7406 <\/h4>\n<p> \u7f51\u7edc\u5c42\u7684\u5b9e\u73b0\u6d89\u53ca\u5230\u5e95\u5c42\u7684\u7f51\u7edc\u901a\u4fe1&#xff0c;\u5305\u62ec\u76d1\u542c\u3001\u63a5\u6536\u3001\u53d1\u9001\u6570\u636e\u5305\u7b49\u64cd\u4f5c\u3002\u4ee5\u4e00\u4e2a\u5178\u578b\u7684\u57fa\u4e8e\u4e8b\u4ef6\u9a71\u52a8\u7684\u7f51\u7edc\u6846\u67b6\u4e3a\u4f8b&#xff0c;\u7f51\u7edc\u4e8b\u4ef6\u7684\u76d1\u542c\u4e0e\u5904\u7406\u901a\u5e38\u662f\u7531\u4e00\u4e2a\u4e8b\u4ef6\u5faa\u73af&#xff08;event loop&#xff09;\u6765\u9a71\u52a8\u7684&#xff0c;\u8be5\u5faa\u73af\u4f1a\u76d1\u63a7\u591a\u4e2asocket\u7684\u4e8b\u4ef6&#xff0c;\u5e76\u5728\u9002\u5f53\u7684\u65f6\u673a\u8c03\u7528\u76f8\u5e94\u7684\u56de\u8c03\u51fd\u6570\u5904\u7406\u8fd9\u4e9b\u4e8b\u4ef6\u3002 <\/p>\n<p>\/\/ \u793a\u4f8b\u4ee3\u7801&#xff1a;\u7f51\u7edc\u4e8b\u4ef6\u76d1\u542c\u4e0e\u5904\u7406\u4f2a\u4ee3\u7801<\/p>\n<p>\/\/ \u521d\u59cb\u5316socket<br \/>\nint socket_fd &#061; socket(AF_INET, SOCK_STREAM, 0);<br \/>\n\/\/ \u8bbe\u7f6esocket\u4e3a\u975e\u963b\u585e\u6a21\u5f0f<br \/>\nfcntl(socket_fd, F_SETFL, O_NONBLOCK);<\/p>\n<p>\/\/ \u7ed1\u5b9a\u5730\u5740\u548c\u7aef\u53e3<br \/>\nstruct sockaddr_in server_addr;<br \/>\nmemset(&amp;server_addr, 0, sizeof(server_addr));<br \/>\nserver_addr.sin_family &#061; AF_INET;<br \/>\nserver_addr.sin_port &#061; htons(554); \/\/ RTSP\u7aef\u53e3<br \/>\nserver_addr.sin_addr.s_addr &#061; INADDR_ANY;<\/p>\n<p>bind(socket_fd, (struct sockaddr*)&amp;server_addr, sizeof(server_addr));<\/p>\n<p>\/\/ \u76d1\u542c\u8fde\u63a5<br \/>\nlisten(socket_fd, SOMAXCONN);<\/p>\n<p>\/\/ \u4e8b\u4ef6\u5faa\u73af<br \/>\nwhile (running) {<br \/>\n    \/\/ \u8c03\u7528\u5e95\u5c42\u51fd\u6570\u83b7\u53d6\u4e8b\u4ef6\u96c6\u5408<br \/>\n    fd_set readfds;<br \/>\n    FD_ZERO(&amp;readfds);<br \/>\n    FD_SET(socket_fd, &amp;readfds);<\/p>\n<p>    \/\/ \u7b49\u5f85\u4e8b\u4ef6<br \/>\n    int n &#061; select(socket_fd &#043; 1, &amp;readfds, NULL, NULL, NULL);<\/p>\n<p>    \/\/ \u5904\u7406\u4e8b\u4ef6<br \/>\n    if (FD_ISSET(socket_fd, &amp;readfds)) {<br \/>\n        \/\/ \u5904\u7406\u65b0\u7684\u8fde\u63a5\u8bf7\u6c42\u6216\u63a5\u6536\u6570\u636e<br \/>\n        struct sockaddr_in client_addr;<br \/>\n        socklen_t client_len &#061; sizeof(client_addr);<br \/>\n        int client_fd &#061; accept(socket_fd, (struct sockaddr*)&amp;client_addr, &amp;client_len);<\/p>\n<p>        \/\/ \u5c06\u65b0socket\u52a0\u5165\u5230\u4e8b\u4ef6\u76d1\u542c<br \/>\n        \/\/ &#8230;<br \/>\n    }<\/p>\n<p>    \/\/ \u5176\u4ed6\u4e8b\u4ef6\u5904\u7406<br \/>\n    \/\/ &#8230;<br \/>\n}<\/p>\n<p> \u5728\u4e0a\u8ff0\u4f2a\u4ee3\u7801\u4e2d&#xff0c;  socket  \u3001  bind  \u3001  listen  \u3001  select  \u3001  accept  \u662f\u5173\u952e\u7684\u7cfb\u7edf\u8c03\u7528&#xff0c;\u5206\u522b\u7528\u4e8e\u521b\u5efasocket\u3001\u7ed1\u5b9a\u5730\u5740\u3001\u76d1\u542c\u8fde\u63a5\u8bf7\u6c42\u3001\u4e8b\u4ef6\u76d1\u542c\u548c\u63a5\u53d7\u65b0\u7684\u8fde\u63a5\u8bf7\u6c42\u3002\u4e8b\u4ef6\u5faa\u73af\u4e2d\u8c03\u7528  select  \u51fd\u6570\u6765\u5224\u65ad\u54ea\u4e9bsocket\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff08;file descriptor&#xff09;\u662f&#034;\u53ef\u8bfb&#034;\u7684&#xff0c;\u968f\u540e\u5bf9&#034;\u53ef\u8bfb&#034;\u7684socket\u6267\u884c\u76f8\u5e94\u64cd\u4f5c&#xff0c;\u5982\u63a5\u53d7\u65b0\u7684\u8fde\u63a5\u6216\u8bfb\u53d6\u6570\u636e\u3002 <\/p>\n<h4> 5.1.2 \u7f51\u7edc\u7f13\u51b2\u533a\u7684\u7ba1\u7406 <\/h4>\n<p> \u7f51\u7edc\u7f13\u51b2\u533a\u7684\u7ba1\u7406\u5305\u62ec\u6570\u636e\u5305\u7684\u63a5\u6536\u3001\u7f13\u5b58\u3001\u8bfb\u53d6\u548c\u6e05\u7406\u7b49\u64cd\u4f5c\u3002\u5408\u7406\u7684\u7ba1\u7406\u65b9\u6cd5\u80fd\u591f\u63d0\u9ad8\u7f51\u7edcI\/O\u7684\u6027\u80fd&#xff0c;\u5e76\u51cf\u5c11\u6570\u636e\u4f20\u8f93\u7684\u5ef6\u8fdf\u3002\u7f13\u51b2\u533a\u7ba1\u7406\u901a\u5e38\u6d89\u53ca\u5185\u5b58\u5206\u914d\u3001\u6570\u636e\u5305\u7684\u987a\u5e8f\u63a7\u5236\u4ee5\u53ca\u5185\u5b58\u7684\u91ca\u653e\u3002 <\/p>\n<p> \u7f13\u51b2\u533a\u7684\u8bbe\u8ba1\u901a\u5e38\u9700\u8981\u8003\u8651\u4ee5\u4e0b\u51e0\u70b9&#xff1a; &#8211; \u52a8\u6001\u8c03\u6574\u7f13\u51b2\u533a\u5927\u5c0f\u4ee5\u9002\u5e94\u4e0d\u540c\u7684\u6570\u636e\u6d41\u91cf\u3002 &#8211; \u4f7f\u7528\u73af\u5f62\u7f13\u51b2\u533a&#xff08;ring buffer&#xff09;\u6765\u5b9e\u73b0\u9ad8\u6548\u7684\u6570\u636e\u5305\u5165\u961f\u548c\u51fa\u961f\u64cd\u4f5c\u3002 &#8211; \u4fdd\u8bc1\u6570\u636e\u5305\u7684\u987a\u5e8f\u6027\u548c\u540c\u6b65&#xff0c;\u5c24\u5176\u662f\u5bf9\u4e8eRTP\u6570\u636e\u6d41\u6765\u8bf4&#xff0c;\u6570\u636e\u5305\u7684\u987a\u5e8f\u76f4\u63a5\u5f71\u54cd\u5a92\u4f53\u64ad\u653e\u7684\u8fde\u8d2f\u6027\u3002 <\/p>\n<p>\/\/ \u73af\u5f62\u7f13\u51b2\u533a\u7684\u7b80\u5355\u5b9e\u73b0<br \/>\n#define BUFFER_SIZE 1024<\/p>\n<p>typedef struct {<br \/>\n    uint8_t buffer[BUFFER_SIZE];<br \/>\n    size_t read_pos;<br \/>\n    size_t write_pos;<br \/>\n    size_t bytes_used;<br \/>\n} RingBuffer;<\/p>\n<p>\/\/ \u6dfb\u52a0\u6570\u636e\u5230\u7f13\u51b2\u533a<br \/>\nvoid ring_buffer_add(RingBuffer* buf, const uint8_t* data, size_t size) {<br \/>\n    \/\/ \u5faa\u73af\u5199\u5165\u6570\u636e&#xff0c;\u5904\u7406\u7f13\u51b2\u533a\u5927\u5c0f\u9650\u5236\u548c\u73af\u5f62\u7279\u6027<br \/>\n    \/\/ &#8230;<br \/>\n}<\/p>\n<p>\/\/ \u4ece\u7f13\u51b2\u533a\u8bfb\u53d6\u6570\u636e<br \/>\nsize_t ring_buffer_read(RingBuffer* buf, uint8_t* data, size_t size) {<br \/>\n    \/\/ \u5faa\u73af\u8bfb\u53d6\u6570\u636e&#xff0c;\u76f4\u5230size\u9650\u5236\u6216\u7f13\u51b2\u533a\u4e3a\u7a7a<br \/>\n    \/\/ &#8230;<br \/>\n}<\/p>\n<p> \u73af\u5f62\u7f13\u51b2\u533a\u662f\u4e00\u79cd\u5faa\u73af\u961f\u5217\u7684\u5b9e\u73b0\u65b9\u5f0f&#xff0c;\u5728\u7f51\u7edc\u6570\u636e\u5305\u7684\u5904\u7406\u4e2d\u53ef\u4ee5\u6709\u6548\u5730\u51cf\u5c11\u6570\u636e\u5305\u62f7\u8d1d\u548c\u5185\u5b58\u5206\u914d\u7684\u6b21\u6570&#xff0c;\u63d0\u9ad8\u6570\u636e\u5904\u7406\u6548\u7387\u3002 <\/p>\n<h3> 5.2 \u5a92\u4f53\u6d41\u5904\u7406\u7684\u5b9e\u73b0\u7ec6\u8282 <\/h3>\n<h4> 5.2.1 \u97f3\u89c6\u9891\u6570\u636e\u7684\u7f16\u89e3\u7801\u8fc7\u7a0b <\/h4>\n<p> \u97f3\u89c6\u9891\u6570\u636e\u6d41\u7684\u5904\u7406\u662f\u591a\u5a92\u4f53\u5e94\u7528\u7684\u6838\u5fc3&#xff0c;\u6d89\u53ca\u5230\u7f16\u89e3\u7801\u5668\u7684\u9009\u62e9\u3001\u7f16\u89e3\u7801\u8fc7\u7a0b\u7684\u6267\u884c\u548c\u6570\u636e\u5305\u7684\u751f\u6210\u3002\u7f16\u89e3\u7801\u8fc7\u7a0b\u901a\u5e38\u5305\u62ec\u5bf9\u539f\u59cb\u6570\u636e\u7684\u538b\u7f29\u7f16\u7801\u4ee5\u53ca\u5bf9\u63a5\u6536\u6570\u636e\u7684\u89e3\u7801\u64ad\u653e\u3002 <\/p>\n<p> \u4ee5H.264\u89c6\u9891\u7f16\u89e3\u7801\u4e3a\u4f8b&#xff0c;\u7f16\u89e3\u7801\u8fc7\u7a0b\u9700\u8981\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4&#xff1a; <\/p>\n<li> \u89c6\u9891\u5e27\u7684\u83b7\u53d6&#xff1a;\u901a\u8fc7\u89c6\u9891\u6355\u83b7\u8bbe\u5907\u83b7\u53d6\u539f\u59cb\u89c6\u9891\u6570\u636e\u3002 <\/li>\n<li> \u5e27\u7c7b\u578b\u5224\u65ad&#xff1a;\u6839\u636e\u7f16\u7801\u7b56\u7565&#xff0c;\u51b3\u5b9a\u5f53\u524d\u5e27\u4e3aI\u5e27&#xff08;\u5173\u952e\u5e27&#xff09;\u3001P\u5e27&#xff08;\u524d\u5411\u9884\u6d4b\u5e27&#xff09;\u6216B\u5e27&#xff08;\u53cc\u5411\u9884\u6d4b\u5e27&#xff09;\u3002 <\/li>\n<li> \u5e27\u7f16\u7801&#xff1a;\u5bf9\u9009\u5b9a\u7684\u5e27\u7c7b\u578b\u8fdb\u884c\u7f16\u7801&#xff0c;\u5982H.264\u91c7\u7528\u5e27\u5185\u7f16\u7801\u548c\u5e27\u95f4\u7f16\u7801\u6280\u672f\u3002 <\/li>\n<li> \u5e27\u5c01\u88c5&#xff1a;\u7f16\u7801\u540e\u7684\u6570\u636e\u6309\u7167\u6307\u5b9a\u683c\u5f0f\u5c01\u88c5\u5230RTP\u6570\u636e\u5305\u4e2d&#xff0c;\u4ee5\u4fbf\u901a\u8fc7\u7f51\u7edc\u4f20\u8f93\u3002 <\/li>\n<p> \u89e3\u7801\u8fc7\u7a0b\u5219\u662f\u7f16\u7801\u7684\u9006\u8fc7\u7a0b&#xff0c;\u5373\u4eceRTP\u6570\u636e\u5305\u4e2d\u63d0\u53d6\u538b\u7f29\u7684\u97f3\u89c6\u9891\u6570\u636e&#xff0c;\u4f7f\u7528\u5bf9\u5e94\u7684\u89e3\u7801\u5668\u8fdb\u884c\u89e3\u7801&#xff0c;\u7136\u540e\u8f93\u51fa\u5230\u663e\u793a\u8bbe\u5907\u4e0a\u3002 <\/p>\n<p>\/\/ \u793a\u4f8b\u4ee3\u7801&#xff1a;H.264\u7f16\u7801\u6d41\u7a0b\u4f2a\u4ee3\u7801<\/p>\n<p>void encode_frame(uint8_t* raw_frame_data, size_t frame_size, &#8230;) {<br \/>\n    \/\/ \u521d\u59cb\u5316\u7f16\u7801\u5668\u53c2\u6570<br \/>\n    \/\/ &#8230;<\/p>\n<p>    \/\/ \u5f00\u59cb\u7f16\u7801<br \/>\n    int ret &#061; avcodec_send_frame(encoder_ctx, frame);<br \/>\n    while (ret &gt;&#061; 0) {<br \/>\n        AVPacket packet;<br \/>\n        ret &#061; avcodec_receive_packet(encoder_ctx, &amp;packet);<br \/>\n        if (ret &#061;&#061; AVERROR(EAGAIN) || ret &#061;&#061; AVERROR_EOF) {<br \/>\n            break;<br \/>\n        } else if (ret &lt; 0) {<br \/>\n            \/\/ \u7f16\u7801\u9519\u8bef\u5904\u7406<br \/>\n            \/\/ &#8230;<br \/>\n        }<\/p>\n<p>        \/\/ \u5c06\u7f16\u7801\u540e\u7684\u6570\u636e\u5c01\u88c5\u5230RTP\u5305<br \/>\n        \/\/ &#8230;<br \/>\n    }<br \/>\n}<\/p>\n<h4> 5.2.2 \u97f3\u89c6\u9891\u540c\u6b65\u673a\u5236\u7684\u5b9e\u73b0 <\/h4>\n<p> \u97f3\u89c6\u9891\u540c\u6b65\u662f\u786e\u4fdd\u64ad\u653e\u8d28\u91cf\u7684\u5173\u952e\u90e8\u5206\u3002\u5728\u591a\u5a92\u4f53\u6570\u636e\u6d41\u4e2d&#xff0c;\u97f3\u9891\u548c\u89c6\u9891\u662f\u5206\u5f00\u4f20\u8f93\u7684&#xff0c;\u56e0\u6b64\u9700\u8981\u4e00\u4e2a\u673a\u5236\u6765\u4fdd\u8bc1\u4e24\u8005\u5728\u64ad\u653e\u65f6\u7684\u540c\u6b65\u3002 <\/p>\n<p> \u97f3\u89c6\u9891\u540c\u6b65\u7684\u4e3b\u8981\u7b56\u7565\u5305\u62ec&#xff1a; <\/p>\n<li> \u65f6\u95f4\u6233\u540c\u6b65&#xff1a;\u4f7f\u7528RTP\u65f6\u95f4\u6233\u548cPTS&#xff08;Presentation Time Stamp&#xff09;\u6765\u540c\u6b65\u97f3\u9891\u548c\u89c6\u9891\u5e27\u7684\u64ad\u653e\u65f6\u95f4\u3002 <\/li>\n<li> \u7f13\u51b2\u7b56\u7565&#xff1a;\u5728\u63a5\u6536\u7aef\u5b9e\u65bd\u9002\u5f53\u7684\u7f13\u51b2\u7b56\u7565&#xff0c;\u4ee5\u9002\u5e94\u7f51\u7edc\u6296\u52a8\u548c\u4e0d\u540c\u6b65\u7684\u60c5\u51b5\u3002 <\/li>\n<li> \u81ea\u9002\u5e94\u673a\u5236&#xff1a;\u6839\u636e\u7f51\u7edc\u6761\u4ef6\u548c\u64ad\u653e\u72b6\u6001\u52a8\u6001\u8c03\u6574\u97f3\u89c6\u9891\u6d41\u7684\u64ad\u653e\u901f\u5ea6\u548c\u7f13\u51b2\u5927\u5c0f\u3002 <\/li>\n<p>\/\/ \u793a\u4f8b\u4ee3\u7801&#xff1a;\u97f3\u89c6\u9891\u540c\u6b65\u4f2a\u4ee3\u7801<\/p>\n<p>\/\/ RTP\u65f6\u95f4\u6233\u7528\u4e8e\u540c\u6b65\u97f3\u89c6\u9891\u6570\u636e\u5305<br \/>\n\/\/ audioPTS \u548c videoPTS \u5206\u522b\u4e3a\u97f3\u9891\u548c\u89c6\u9891\u6570\u636e\u5305\u7684\u65f6\u95f4\u6233<\/p>\n<p>if (abs(audioPTS &#8211; videoPTS) &gt; SOME_THRESHOLD) {<br \/>\n    \/\/ \u65f6\u95f4\u6233\u5dee\u5f02\u8fc7\u5927&#xff0c;\u8c03\u6574\u89c6\u9891\u64ad\u653e\u901f\u5ea6<br \/>\n    adjust_video_playback_speed();<br \/>\n} else {<br \/>\n    \/\/ \u65f6\u95f4\u6233\u5dee\u5f02\u5728\u53ef\u63a5\u53d7\u8303\u56f4\u5185&#xff0c;\u6b63\u5e38\u64ad\u653e<br \/>\n    play_audio_video();<br \/>\n}<\/p>\n<p> \u540c\u6b65\u673a\u5236\u7684\u5b9e\u73b0\u4f1a\u6839\u636e\u5177\u4f53\u7684\u7f16\u89e3\u7801\u683c\u5f0f\u548c\u64ad\u653e\u73af\u5883\u6709\u6240\u4e0d\u540c&#xff0c;\u4f46\u6838\u5fc3\u601d\u60f3\u662f\u4fdd\u8bc1\u97f3\u89c6\u9891\u6570\u636e\u5305\u5728\u64ad\u653e\u65f6\u8fbe\u5230\u540c\u6b65\u72b6\u6001\u3002 <\/p>\n<h3> 5.3 \u5b89\u5168\u673a\u5236\u7684\u5b9e\u73b0\u7ec6\u8282 <\/h3>\n<h4> 5.3.1 \u8ba4\u8bc1\u6388\u6743\u673a\u5236\u7684\u5b9e\u73b0 <\/h4>\n<p> \u4e3a\u4e86\u786e\u4fdd\u5a92\u4f53\u6d41\u4f20\u8f93\u7684\u5b89\u5168\u6027&#xff0c;\u6e90\u7801\u5b9e\u73b0\u4e2d\u9700\u8981\u5305\u542b\u8ba4\u8bc1\u6388\u6743\u673a\u5236\u3002\u4e00\u4e2a\u5e38\u89c1\u7684\u505a\u6cd5\u662f\u4f7f\u7528RTSP\u7684\u8ba4\u8bc1\u673a\u5236&#xff0c;\u4f8b\u5982\u57fa\u672c\u8ba4\u8bc1&#xff08;Basic Authentication&#xff09;\u6216\u6458\u8981\u8ba4\u8bc1&#xff08;Digest Authentication&#xff09;\u3002 <\/p>\n<p> \u57fa\u672c\u8ba4\u8bc1\u8981\u6c42\u5ba2\u6237\u7aef\u5728\u8bf7\u6c42\u4e2d\u53d1\u9001\u7ecf\u8fc7Base64\u7f16\u7801\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801&#xff0c;\u800c\u6458\u8981\u8ba4\u8bc1\u5219\u66f4\u4e3a\u590d\u6742&#xff0c;\u6d89\u53ca\u751f\u6210\u968f\u673a\u6570&#xff08;nonce&#xff09;\u3001\u6458\u8981\u503c&#xff08;HMAC&#xff09;\u7684\u8ba1\u7b97\u7b49\u3002 <\/p>\n<p>\/\/ \u793a\u4f8b\u4ee3\u7801&#xff1a;\u57fa\u672c\u8ba4\u8bc1\u5904\u7406\u4f2a\u4ee3\u7801<\/p>\n<p>\/\/ \u4ece\u8bf7\u6c42\u5934\u4e2d\u89e3\u6790\u51fa\u7528\u6237\u540d\u548c\u5bc6\u7801<br \/>\nchar* username;<br \/>\nchar* password;<br \/>\nparse_credentials_from_request(&amp;username, &amp;password);<\/p>\n<p>\/\/ \u5bf9\u7528\u6237\u540d\u548c\u5bc6\u7801\u8fdb\u884cBase64\u89e3\u7801<br \/>\nchar decoded_username[USERNAME_LEN];<br \/>\nchar decoded_password[PASSWORD_LEN];<br \/>\nbase64_decode(username, decoded_username);<br \/>\nbase64_decode(password, decoded_password);<\/p>\n<p>\/\/ \u9a8c\u8bc1\u7528\u6237\u540d\u548c\u5bc6\u7801<br \/>\nif (authenticate(username, password)) {<br \/>\n    \/\/ \u8ba4\u8bc1\u6210\u529f<br \/>\n    allow_request();<br \/>\n} else {<br \/>\n    \/\/ \u8ba4\u8bc1\u5931\u8d25<br \/>\n    deny_request();<br \/>\n}<\/p>\n<h4> 5.3.2 \u6570\u636e\u52a0\u5bc6\u4e0e\u4f20\u8f93\u5b89\u5168\u7684\u5b9e\u73b0 <\/h4>\n<p> \u9664\u4e86\u8ba4\u8bc1\u6388\u6743\u673a\u5236&#xff0c;\u6570\u636e\u52a0\u5bc6\u4e5f\u662f\u4fdd\u969c\u4f20\u8f93\u5b89\u5168\u7684\u91cd\u8981\u63aa\u65bd\u3002\u5728\u5a92\u4f53\u6d41\u4f20\u8f93\u4e2d&#xff0c;SSL\/TLS\u534f\u8bae\u5e38\u88ab\u7528\u6765\u52a0\u5bc6RTSP\u548cRTP\u6570\u636e\u5305\u3002 <\/p>\n<p> SSL\/TLS\u534f\u8bae\u63d0\u4f9b\u6570\u636e\u52a0\u5bc6\u3001\u8eab\u4efd\u9a8c\u8bc1\u548c\u6570\u636e\u5b8c\u6574\u6027\u6821\u9a8c&#xff0c;\u786e\u4fdd\u6570\u636e\u5728\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u7684\u5b89\u5168\u3002\u5728\u6e90\u7801\u4e2d\u5b9e\u73b0SSL\/TLS\u52a0\u5bc6\u6d89\u53ca\u5230\u4f7f\u7528\u76f8\u5e94\u7684\u5e93\u51fd\u6570&#xff0c;\u5982OpenSSL&#xff0c;\u6765\u521d\u59cb\u5316SSL\u4e0a\u4e0b\u6587\u3001\u5904\u7406SSL\u63e1\u624b\u8fc7\u7a0b\u4ee5\u53ca\u52a0\u5bc6\u89e3\u5bc6\u4f20\u8f93\u6570\u636e\u3002 <\/p>\n<p>\/\/ \u793a\u4f8b\u4ee3\u7801&#xff1a;SSL\/TLS\u52a0\u5bc6\u4f20\u8f93\u4f2a\u4ee3\u7801<\/p>\n<p>\/\/ \u521d\u59cb\u5316SSL\u4e0a\u4e0b\u6587<br \/>\nSSL_CTX* ctx &#061; SSL_CTX_new(SSLv23_server_method());<br \/>\nSSL_CTX_use_certificate_file(ctx, &#034;server.crt&#034;, SSL_FILETYPE_PEM);<br \/>\nSSL_CTX_use_PrivateKey_file(ctx, &#034;server.key&#034;, SSL_FILETYPE_PEM);<\/p>\n<p>\/\/ \u63a5\u53d7\u65b0\u8fde\u63a5\u5e76\u521d\u59cb\u5316SSL\u7ed3\u6784\u4f53<br \/>\nSSL* ssl &#061; SSL_new(ctx);<br \/>\nBIO* bio &#061; BIO_new_ssl_connect(ctx);<br \/>\nBIO_set_conn_hostname(bio, &#034;ssl:\/\/client:443&#034;);<\/p>\n<p>\/\/ \u8fdb\u884cSSL\u63e1\u624b&#xff0c;\u534f\u5546\u52a0\u5bc6\u53c2\u6570<br \/>\nSSL_set_bio(ssl, bio, bio);<br \/>\nint ret &#061; SSL_accept(ssl);<br \/>\nif (ret &lt;&#061; 0) {<br \/>\n    \/\/ SSL\u63e1\u624b\u5931\u8d25\u5904\u7406<br \/>\n    \/\/ &#8230;<br \/>\n}<\/p>\n<p>\/\/ \u52a0\u5bc6\u6570\u636e\u4f20\u8f93<br \/>\nwhile (SSL_read(ssl, buffer, sizeof(buffer)) &gt; 0) {<br \/>\n    \/\/ \u5904\u7406\u63a5\u6536\u5230\u7684\u6570\u636e<br \/>\n}<\/p>\n<p>\/\/ \u5173\u95edSSL\u8fde\u63a5<br \/>\nSSL_shutdown(ssl);<br \/>\nSSL_free(ssl);<br \/>\nSSL_CTX_free(ctx);<\/p>\n<p> SSL\/TLS\u7684\u5b9e\u73b0\u7ec6\u8282\u975e\u5e38\u590d\u6742&#xff0c;\u4e0a\u8ff0\u4ee3\u7801\u4ec5\u5c55\u793a\u4e86\u57fa\u672c\u7684SSL\/TLS\u4e0a\u4e0b\u6587\u521d\u59cb\u5316\u548c\u63e1\u624b\u8fc7\u7a0b&#xff0c;\u5b9e\u9645\u5f00\u53d1\u4e2d\u9700\u8981\u5904\u7406\u66f4\u591a\u7684\u7ec6\u8282&#xff0c;\u5982\u9519\u8bef\u5904\u7406\u3001\u91cd\u63e1\u624b\u7b56\u7565\u7b49\u3002 <\/p>\n<h2> 6. \u6e90\u7801\u7f16\u8bd1\u4e0e\u8fd0\u884c\u6b65\u9aa4 <\/h2>\n<p> \u5728\u8fd9\u4e00\u7ae0\u8282\u4e2d&#xff0c;\u6211\u4eec\u5c06\u6df1\u5165\u4e86\u89e3\u5982\u4f55\u51c6\u5907\u548c\u6267\u884c  rtsp_server  \u6e90\u7801\u7684\u7f16\u8bd1\u4e0e\u8fd0\u884c\u3002\u8fd9\u4e00\u8fc7\u7a0b\u5bf9\u4e8eIT\u4e13\u4e1a\u4eba\u5458\u6765\u8bf4\u662f\u81f3\u5173\u91cd\u8981\u7684&#xff0c;\u56e0\u4e3a\u7406\u89e3\u6e90\u7801\u7684\u7f16\u8bd1\u548c\u8fd0\u884c\u673a\u5236\u662f\u8fdb\u884c\u5b9a\u5236\u5316\u5f00\u53d1\u548c\u95ee\u9898\u6392\u67e5\u7684\u57fa\u77f3\u3002 <\/p>\n<h3> 6.1 \u6e90\u7801\u7f16\u8bd1\u524d\u7684\u73af\u5883\u51c6\u5907 <\/h3>\n<p> \u4e3a\u4e86\u786e\u4fdd\u7f16\u8bd1\u8fc7\u7a0b\u987a\u5229\u8fdb\u884c&#xff0c;\u9996\u5148\u9700\u8981\u642d\u5efa\u4e00\u4e2a\u5408\u9002\u7684\u5f00\u53d1\u73af\u5883\u3002\u8fd9\u5305\u62ec\u5b89\u88c5\u5fc5\u8981\u7684\u4f9d\u8d56\u5e93\u4ee5\u53ca\u914d\u7f6e\u5f00\u53d1\u5de5\u5177\u3002 <\/p>\n<h4> 6.1.1 \u4f9d\u8d56\u5e93\u7684\u5b89\u88c5\u4e0e\u914d\u7f6e <\/h4>\n<p> \u4f9d\u8d56\u5e93\u662f\u6784\u5efa\u9879\u76ee\u7684\u57fa\u7840&#xff0c;\u7f3a\u4e4f\u4efb\u4f55\u4e00\u4e2a\u90fd\u53ef\u80fd\u5bfc\u81f4\u7f16\u8bd1\u5931\u8d25\u3002\u5bf9\u4e8e  rtsp_server  \u8fd9\u6837\u7684\u9879\u76ee\u6765\u8bf4&#xff0c;\u5e38\u89c1\u7684\u4f9d\u8d56\u5305\u62ec\u4f46\u4e0d\u9650\u4e8e\u4ee5\u4e0b\u51e0\u4e2a&#xff1a; <\/p>\n<ul>\n<li>  FFmpeg  : \u7528\u4e8e\u5904\u7406\u97f3\u89c6\u9891\u6570\u636e\u3002 <\/li>\n<li>  OpenSSL  : \u4e3a\u7f16\u8bd1\u8fc7\u7a0b\u63d0\u4f9b\u5b89\u5168\u52a0\u5bc6\u652f\u6301\u3002 <\/li>\n<li>  libevent  : \u7528\u4e8e\u5904\u7406\u7f51\u7edc\u4e8b\u4ef6\u548c\u5f02\u6b65I\/O\u3002 <\/li>\n<\/ul>\n<p> \u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u8fd9\u4e9b\u4f9d\u8d56\u5e93&#xff08;\u4ee5Ubuntu\u7cfb\u7edf\u4e3a\u4f8b&#xff09;&#xff1a; <\/p>\n<p>sudo apt-get update<br \/>\nsudo apt-get install libssl-dev libevent-dev ffmpeg libavcodec-dev libavformat-dev<\/p>\n<h4> 6.1.2 \u7f16\u8bd1\u5668\u4e0e\u5f00\u53d1\u73af\u5883\u7684\u914d\u7f6e <\/h4>\n<p> \u786e\u4fdd\u5b89\u88c5\u4e86\u652f\u6301C\/C&#043;&#043;\u7684\u7f16\u8bd1\u5668&#xff0c;\u5982  gcc  \u548c  g&#043;&#043;  \u3002\u6b64\u5916&#xff0c;\u5bf9\u4e8e\u6e90\u7801\u7ba1\u7406&#xff0c;\u4f7f\u7528  git  \u662f\u975e\u5e38\u666e\u904d\u7684\u505a\u6cd5\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5\u8fd9\u4e9b\u5de5\u5177&#xff1a; <\/p>\n<p>sudo apt-get install build-essential git<\/p>\n<p> \u5b8c\u6210\u73af\u5883\u5b89\u88c5\u540e&#xff0c;\u6211\u4eec\u53ef\u4ee5\u5f00\u59cb\u4ece\u6e90\u7801\u5e93\u514b\u9686\u9879\u76ee\u4ee3\u7801&#xff1a; <\/p>\n<p>git clone &lt;rtsp_server_repo_url&gt;<\/p>\n<h3> 6.2 \u7f16\u8bd1\u4e0e\u5b89\u88c5\u8fc7\u7a0b\u8be6\u89e3 <\/h3>\n<p> \u6e90\u7801\u7f16\u8bd1\u662f\u5c06\u6e90\u4ee3\u7801\u6587\u4ef6\u8f6c\u6362\u4e3a\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8fc7\u7a0b\u3002\u5728\u8fd9\u4e00\u90e8\u5206&#xff0c;\u6211\u4eec\u5c06\u8be6\u7ec6\u63a2\u8ba8\u5982\u4f55\u914d\u7f6e\u7f16\u8bd1\u9009\u9879&#xff0c;\u5e76\u8fdb\u884c\u5b89\u88c5\u3002 <\/p>\n<h4> 6.2.1 \u7f16\u8bd1\u9009\u9879\u7684\u914d\u7f6e\u4e0e\u9009\u62e9 <\/h4>\n<p> \u7f16\u8bd1\u5668\u914d\u7f6e\u9009\u9879\u5bf9\u4e8e\u9879\u76ee\u7684\u6027\u80fd\u548c\u529f\u80fd\u6709\u7740\u91cd\u8981\u5f71\u54cd\u3002\u5728  rtsp_server  \u9879\u76ee\u4e2d&#xff0c;\u53ef\u4ee5\u901a\u8fc7  .\/configure  \u811a\u672c\u6765\u8fdb\u884c\u7f16\u8bd1\u914d\u7f6e&#xff1a; <\/p>\n<p>.\/configure &#8211;prefix&#061;&lt;installation_path&gt;<\/p>\n<p> \u8fd9\u91cc\u7684  &lt;installation_path&gt;  \u6307\u5b9a\u4e86\u5b89\u88c5\u76ee\u5f55&#xff0c;\u5982\u679c\u4e0d\u8bbe\u7f6e&#xff0c;\u9ed8\u8ba4\u4f1a\u5728  \/usr\/local  \u4e0b\u5b89\u88c5\u3002\u6267\u884c\u6b64\u547d\u4ee4\u540e&#xff0c;\u811a\u672c\u4f1a\u68c0\u67e5\u7cfb\u7edf\u73af\u5883\u5e76\u751f\u6210\u9002\u5408\u5f53\u524d\u7cfb\u7edf\u7684Makefile\u3002 <\/p>\n<h4> 6.2.2 \u5b89\u88c5\u6b65\u9aa4\u4e0e\u5e38\u89c1\u95ee\u9898\u89e3\u51b3 <\/h4>\n<p> \u4e00\u65e6\u6709\u4e86\u6b63\u786e\u7684Makefile&#xff0c;\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528  make  \u547d\u4ee4\u6765\u7f16\u8bd1\u9879\u76ee&#xff1a; <\/p>\n<p>make<\/p>\n<p> \u7f16\u8bd1\u5b8c\u6210\u540e&#xff0c;\u4f7f\u7528  make install  \u547d\u4ee4\u6765\u5b89\u88c5\u7a0b\u5e8f&#xff1a; <\/p>\n<p>sudo make install<\/p>\n<p> \u5728\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d&#xff0c;\u53ef\u80fd\u4f1a\u9047\u5230\u4f9d\u8d56\u7f3a\u5931\u3001\u7f16\u8bd1\u9519\u8bef\u7b49\u95ee\u9898\u3002\u89e3\u51b3\u65b9\u6848\u901a\u5e38\u5305\u62ec\u5b89\u88c5\u7f3a\u5931\u7684\u4f9d\u8d56\u3001\u68c0\u67e5\u7f16\u8bd1\u5668\u7248\u672c\u548c\u6743\u9650\u8bbe\u7f6e\u7b49\u3002 <\/p>\n<h3> 6.3 \u8fd0\u884c\u524d\u7684\u914d\u7f6e\u4e0e\u542f\u52a8 <\/h3>\n<p> \u7f16\u8bd1\u5b89\u88c5\u5b8c\u6210\u540e&#xff0c;\u6211\u4eec\u8fd8\u9700\u8981\u6839\u636e\u5b9e\u9645\u9700\u6c42\u5bf9\u914d\u7f6e\u6587\u4ef6\u8fdb\u884c\u4fee\u6539&#xff0c;\u5e76\u638c\u63e1\u5982\u4f55\u6b63\u786e\u542f\u52a8\u670d\u52a1\u3002 <\/p>\n<h4> 6.3.1 \u914d\u7f6e\u6587\u4ef6\u7684\u4fee\u6539\u4e0e\u53c2\u6570\u8bbe\u5b9a <\/h4>\n<p>  rtsp_server  \u901a\u5e38\u5e26\u6709\u4e00\u4e9b\u9ed8\u8ba4\u914d\u7f6e\u6587\u4ef6&#xff0c;\u4f4d\u4e8e\u5b89\u88c5\u76ee\u5f55\u4e0b\u7684  conf  \u6587\u4ef6\u5939\u4e2d\u3002\u7f16\u8f91\u8fd9\u4e9b\u6587\u4ef6\u6765\u6ee1\u8db3\u7279\u5b9a\u9700\u6c42&#xff1a; <\/p>\n<p>nano \/path\/to\/rtsp_server\/conf\/server.conf<\/p>\n<p> \u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u65f6&#xff0c;\u9700\u8981\u7279\u522b\u6ce8\u610f\u7aef\u53e3\u53f7\u3001\u65e5\u5fd7\u7ea7\u522b\u3001\u5a92\u4f53\u8def\u5f84\u7b49\u53c2\u6570\u7684\u8bbe\u5b9a\u3002 <\/p>\n<h4> 6.3.2 \u8fd0\u884c\u547d\u4ee4\u7684\u4f7f\u7528\u4e0e\u8c03\u8bd5\u6280\u5de7 <\/h4>\n<p> \u542f\u52a8\u670d\u52a1\u524d&#xff0c;\u786e\u4fdd\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\u6b63\u786e\u65e0\u8bef\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8  rtsp_server  &#xff1a; <\/p>\n<p>rtsp_server -c \/path\/to\/rtsp_server\/conf\/server.conf<\/p>\n<p> \u5982\u679c\u9700\u8981\u8c03\u8bd5&#xff0c;\u53ef\u4ee5\u4f7f\u7528  -d  \u53c2\u6570\u6765\u5f00\u542f\u8c03\u8bd5\u6a21\u5f0f&#xff1a; <\/p>\n<p>rtsp_server -d -c \/path\/to\/rtsp_server\/conf\/server.conf<\/p>\n<p> \u8c03\u8bd5\u6a21\u5f0f\u80fd\u591f\u8f93\u51fa\u66f4\u8be6\u7ec6\u7684\u65e5\u5fd7\u4fe1\u606f&#xff0c;\u5bf9\u4e8e\u95ee\u9898\u8bca\u65ad\u975e\u5e38\u6709\u7528\u3002 <\/p>\n<p> \u5728\u4e0b\u4e00\u7ae0\u8282\u4e2d&#xff0c;\u6211\u4eec\u5c06\u8ba8\u8bba\u5982\u4f55\u8fdb\u884c\u6e90\u7801\u8c03\u8bd5\u548c\u6d4b\u8bd5&#xff0c;\u8fd9\u5bf9\u4e8e\u4fdd\u8bc1  rtsp_server  \u7684\u7a33\u5b9a\u8fd0\u884c\u81f3\u5173\u91cd\u8981\u3002 <\/p>\n<p>  \u672c\u6587\u8fd8\u6709\u914d\u5957\u7684\u7cbe\u54c1\u8d44\u6e90&#xff0c;\u70b9\u51fb\u83b7\u53d6  <img decoding=\"async\" alt=\"menu-r.4af5f7ec.gif\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418172222-68028a4e15389.gif\" style=\"width:16px;margin-left:4px;vertical-align:text-bottom\" \/><\/p>\n<p> \u7b80\u4ecb&#xff1a;RTSP&#xff08;\u5b9e\u65f6\u6d41\u5a92\u4f53\u534f\u8bae&#xff09;\u670d\u52a1\u5668\u5141\u8bb8\u5ba2\u6237\u7aef\u63a7\u5236\u548c\u540c\u6b65\u591a\u5a92\u4f53\u6570\u636e\u7684\u4f20\u8f93\u3002\u672c\u6587\u5c06\u8be6\u89e3\u4e00\u4e2aC\u8bed\u8a00\u5b9e\u73b0\u7684&#034;rtsp_server&#034;\u6e90\u7801&#xff0c;\u6db5\u76d6\u57fa\u7840\u6982\u5ff5\u3001\u6e90\u7801\u7ed3\u6784\u3001RTSP\u8bf7\u6c42\u5904\u7406\u3001RTP\/RTCP\u534f\u8bae\u5e94\u7528\u3001\u5b9e\u73b0\u7ec6\u8282\u3001\u7f16\u8bd1\u8fd0\u884c\u4ee5\u53ca\u8c03\u8bd5\u6d4b\u8bd5\u7b49\u73af\u8282&#xff0c;\u65e8\u5728\u5e2e\u52a9\u7406\u89e3RTSP\u670d\u52a1\u5668\u7684\u5de5\u4f5c\u539f\u7406\u548c\u5b9e\u73b0\u65b9\u6cd5&#xff0c;\u63d0\u5347\u7f51\u7edc\u670d\u52a1\u5f00\u53d1\u6280\u80fd\u3002 <\/p>\n<p>  \u672c\u6587\u8fd8\u6709\u914d\u5957\u7684\u7cbe\u54c1\u8d44\u6e90&#xff0c;\u70b9\u51fb\u83b7\u53d6  <img decoding=\"async\" alt=\"menu-r.4af5f7ec.gif\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418172222-68028a4e15389.gif\" style=\"width:16px;margin-left:4px;vertical-align:text-bottom\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.8k\u6b21\uff0c\u70b9\u8d5e27\u6b21\uff0c\u6536\u85cf30\u6b21\u3002\u672c\u6587\u8fd8\u6709\u914d\u5957\u7684\u7cbe\u54c1\u8d44\u6e90\uff0c\u70b9\u51fb\u83b7\u53d6   \u7b80\u4ecb\uff1aRTSP\uff08\u5b9e\u65f6\u6d41\u5a92\u4f53\u534f\u8bae\uff09\u670d\u52a1\u5668\u5141\u8bb8\u5ba2\u6237\u7aef\u63a7\u5236\u548c\u540c\u6b65\u591a\u5a92\u4f53\u6570\u636e\u7684\u4f20\u8f93\u3002\u672c\u6587\u5c06\u8be6\u89e3\u4e00\u4e2aC\u8bed\u8a00\u5b9e\u73b0\u7684&quot;rtsp_server&quot;\u6e90\u7801\uff0c\u6db5\u76d6\u57fa\u7840\u6982\u5ff5\u3001\u6e90\u7801\u7ed3\u6784\u3001RTSP\u8bf7\u6c42\u5904\u7406\u3001RTP\/RTCP\u534f\u8bae\u5e94\u7528\u3001\u5b9e\u73b0\u7ec6\u8282\u3001\u7f16\u8bd1\u8fd0\u884c\u4ee5\u53ca\u8c03\u8bd5\u6d4b\u8bd5\u7b49\u73af\u8282\uff0c\u65e8\u5728\u5e2e\u52a9\u7406\u89e3RTSP\u670d\u52a1\u5668\u7684\u5de5\u4f5c\u539f\u7406\u548c\u5b9e\u73b0\u65b9\u6cd5\uff0c\u63d0\u5347\u7f51\u7edc\u670d\u52a1\u5f00\u53d1\u6280\u80fd\u3002  1. RTSP\u534f\u8bae\u57fa&#8230;_rtsp\u6e90\u7801<\/p>\n","protected":false},"author":2,"featured_media":19005,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"topic":[],"class_list":["post-19007","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u6df1\u5165\u5206\u6790C\u8bed\u8a00\u7f16\u5199\u7684RTSP\u670d\u52a1\u5668\u6e90\u7801 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/19007.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u6df1\u5165\u5206\u6790C\u8bed\u8a00\u7f16\u5199\u7684RTSP\u670d\u52a1\u5668\u6e90\u7801 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.8k\u6b21\uff0c\u70b9\u8d5e27\u6b21\uff0c\u6536\u85cf30\u6b21\u3002\u672c\u6587\u8fd8\u6709\u914d\u5957\u7684\u7cbe\u54c1\u8d44\u6e90\uff0c\u70b9\u51fb\u83b7\u53d6  \u7b80\u4ecb\uff1aRTSP\uff08\u5b9e\u65f6\u6d41\u5a92\u4f53\u534f\u8bae\uff09\u670d\u52a1\u5668\u5141\u8bb8\u5ba2\u6237\u7aef\u63a7\u5236\u548c\u540c\u6b65\u591a\u5a92\u4f53\u6570\u636e\u7684\u4f20\u8f93\u3002\u672c\u6587\u5c06\u8be6\u89e3\u4e00\u4e2aC\u8bed\u8a00\u5b9e\u73b0\u7684&quot;rtsp_server&quot;\u6e90\u7801\uff0c\u6db5\u76d6\u57fa\u7840\u6982\u5ff5\u3001\u6e90\u7801\u7ed3\u6784\u3001RTSP\u8bf7\u6c42\u5904\u7406\u3001RTP\/RTCP\u534f\u8bae\u5e94\u7528\u3001\u5b9e\u73b0\u7ec6\u8282\u3001\u7f16\u8bd1\u8fd0\u884c\u4ee5\u53ca\u8c03\u8bd5\u6d4b\u8bd5\u7b49\u73af\u8282\uff0c\u65e8\u5728\u5e2e\u52a9\u7406\u89e3RTSP\u670d\u52a1\u5668\u7684\u5de5\u4f5c\u539f\u7406\u548c\u5b9e\u73b0\u65b9\u6cd5\uff0c\u63d0\u5347\u7f51\u7edc\u670d\u52a1\u5f00\u53d1\u6280\u80fd\u3002 1. RTSP\u534f\u8bae\u57fa..._rtsp\u6e90\u7801\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/19007.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T17:22:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418172222-68028a4e15389.gif\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/19007.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/19007.html\",\"name\":\"\u6df1\u5165\u5206\u6790C\u8bed\u8a00\u7f16\u5199\u7684RTSP\u670d\u52a1\u5668\u6e90\u7801 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T17:22:23+00:00\",\"dateModified\":\"2025-04-18T17:22:23+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/19007.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/19007.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/19007.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u6df1\u5165\u5206\u6790C\u8bed\u8a00\u7f16\u5199\u7684RTSP\u670d\u52a1\u5668\u6e90\u7801\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u6df1\u5165\u5206\u6790C\u8bed\u8a00\u7f16\u5199\u7684RTSP\u670d\u52a1\u5668\u6e90\u7801 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/19007.html","og_locale":"zh_CN","og_type":"article","og_title":"\u6df1\u5165\u5206\u6790C\u8bed\u8a00\u7f16\u5199\u7684RTSP\u670d\u52a1\u5668\u6e90\u7801 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.8k\u6b21\uff0c\u70b9\u8d5e27\u6b21\uff0c\u6536\u85cf30\u6b21\u3002\u672c\u6587\u8fd8\u6709\u914d\u5957\u7684\u7cbe\u54c1\u8d44\u6e90\uff0c\u70b9\u51fb\u83b7\u53d6  \u7b80\u4ecb\uff1aRTSP\uff08\u5b9e\u65f6\u6d41\u5a92\u4f53\u534f\u8bae\uff09\u670d\u52a1\u5668\u5141\u8bb8\u5ba2\u6237\u7aef\u63a7\u5236\u548c\u540c\u6b65\u591a\u5a92\u4f53\u6570\u636e\u7684\u4f20\u8f93\u3002\u672c\u6587\u5c06\u8be6\u89e3\u4e00\u4e2aC\u8bed\u8a00\u5b9e\u73b0\u7684&quot;rtsp_server&quot;\u6e90\u7801\uff0c\u6db5\u76d6\u57fa\u7840\u6982\u5ff5\u3001\u6e90\u7801\u7ed3\u6784\u3001RTSP\u8bf7\u6c42\u5904\u7406\u3001RTP\/RTCP\u534f\u8bae\u5e94\u7528\u3001\u5b9e\u73b0\u7ec6\u8282\u3001\u7f16\u8bd1\u8fd0\u884c\u4ee5\u53ca\u8c03\u8bd5\u6d4b\u8bd5\u7b49\u73af\u8282\uff0c\u65e8\u5728\u5e2e\u52a9\u7406\u89e3RTSP\u670d\u52a1\u5668\u7684\u5de5\u4f5c\u539f\u7406\u548c\u5b9e\u73b0\u65b9\u6cd5\uff0c\u63d0\u5347\u7f51\u7edc\u670d\u52a1\u5f00\u53d1\u6280\u80fd\u3002 1. RTSP\u534f\u8bae\u57fa..._rtsp\u6e90\u7801","og_url":"https:\/\/www.wsisp.com\/helps\/19007.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T17:22:23+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418172222-68028a4e15389.gif"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"9 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/19007.html","url":"https:\/\/www.wsisp.com\/helps\/19007.html","name":"\u6df1\u5165\u5206\u6790C\u8bed\u8a00\u7f16\u5199\u7684RTSP\u670d\u52a1\u5668\u6e90\u7801 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T17:22:23+00:00","dateModified":"2025-04-18T17:22:23+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/19007.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/19007.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/19007.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u6df1\u5165\u5206\u6790C\u8bed\u8a00\u7f16\u5199\u7684RTSP\u670d\u52a1\u5668\u6e90\u7801"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/19007","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=19007"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/19007\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/19005"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=19007"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=19007"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=19007"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=19007"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}