{"id":23310,"date":"2025-04-19T07:32:00","date_gmt":"2025-04-18T23:32:00","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/23310.html"},"modified":"2025-04-19T07:32:00","modified_gmt":"2025-04-18T23:32:00","slug":"c%e4%b8%8elive555%e5%ae%9e%e7%8e%b0rtsp%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/23310.html","title":{"rendered":"C++\u4e0eLive555\u5b9e\u73b0RTSP\u670d\u52a1\u5668"},"content":{"rendered":"<h3><\/h3>\n<h3>\u4e00\u3001\u5f15\u8a00&#xff08;Introduction&#xff09;<\/h3>\n<h3>1.1 RTSP\u670d\u52a1\u5668\u7684\u91cd\u8981\u6027&#xff08;Importance of RTSP Server&#xff09;<\/h3>\n<p>RTSP&#xff08;Real Time Streaming Protocol&#xff0c;\u5b9e\u65f6\u6d41\u4f20\u8f93\u534f\u8bae&#xff09;\u670d\u52a1\u5668\u5728\u73b0\u4ee3\u7f51\u7edc\u4f20\u8f93\u4e2d\u626e\u6f14\u7740\u81f3\u5173\u91cd\u8981\u7684\u89d2\u8272\u3002RTSP\u670d\u52a1\u5668\u4e3b\u8981\u7528\u4e8e\u63a7\u5236\u97f3\u9891\u6216\u89c6\u9891\u7684\u591a\u5a92\u4f53\u4f1a\u8bdd&#xff0c;\u5b83\u4e3a\u4e92\u8054\u7f51\u4e0a\u7684\u97f3\u9891\u89c6\u9891\u670d\u52a1\u63d0\u4f9b\u4e86\u4e00\u79cd\u63a7\u5236\u6846\u67b6&#xff0c;\u4f7f\u5f97\u7528\u6237\u53ef\u4ee5\u65b9\u4fbf\u5730\u64ad\u653e\u3001\u6682\u505c\u3001\u5feb\u8fdb\u3001\u5012\u9000\u7b49\u64cd\u4f5c&#xff0c;\u6781\u5927\u5730\u63d0\u9ad8\u4e86\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n<p>RTSP\u670d\u52a1\u5668\u7684\u91cd\u8981\u6027\u4e3b\u8981\u4f53\u73b0\u5728\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762&#xff1a;<\/p>\n<li>\u5b9e\u65f6\u6027&#xff08;Real-time&#xff09;&#xff1a;RTSP\u670d\u52a1\u5668\u652f\u6301\u5b9e\u65f6\u4f20\u8f93&#xff0c;\u8fd9\u5bf9\u4e8e\u76f4\u64ad\u3001\u89c6\u9891\u4f1a\u8bae\u7b49\u5e94\u7528\u573a\u666f\u81f3\u5173\u91cd\u8981\u3002\u7528\u6237\u53ef\u4ee5\u5b9e\u65f6\u63a5\u6536\u5e76\u64ad\u653e\u97f3\u89c6\u9891\u6570\u636e&#xff0c;\u65e0\u9700\u7b49\u5f85\u6574\u4e2a\u6587\u4ef6\u4e0b\u8f7d\u5b8c\u6210\u3002<\/li>\n<li>\u63a7\u5236\u6027&#xff08;Controllability&#xff09;&#xff1a;RTSP\u670d\u52a1\u5668\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u63a7\u5236\u547d\u4ee4&#xff0c;\u5982PLAY\u3001PAUSE\u3001TEARDOWN\u7b49&#xff0c;\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u8fd9\u4e9b\u547d\u4ee4\u5bf9\u97f3\u89c6\u9891\u64ad\u653e\u8fdb\u884c\u7cbe\u786e\u63a7\u5236\u3002<\/li>\n<li>\u6269\u5c55\u6027&#xff08;Scalability&#xff09;&#xff1a;RTSP\u670d\u52a1\u5668\u53ef\u4ee5\u652f\u6301\u5927\u91cf\u7684\u5e76\u53d1\u8fde\u63a5&#xff0c;\u9002\u5e94\u5927\u89c4\u6a21\u7528\u6237\u7684\u9700\u6c42\u3002\u540c\u65f6&#xff0c;RTSP\u670d\u52a1\u5668\u8fd8\u652f\u6301\u591a\u79cd\u4f20\u8f93\u534f\u8bae&#xff0c;\u5982TCP\u3001UDP\u7b49&#xff0c;\u5177\u6709\u5f88\u597d\u7684\u6269\u5c55\u6027\u3002<\/li>\n<li>\u4e92\u52a8\u6027&#xff08;Interactivity&#xff09;&#xff1a;RTSP\u670d\u52a1\u5668\u652f\u6301\u53cc\u5411\u6570\u636e\u4f20\u8f93&#xff0c;\u53ef\u4ee5\u5b9e\u73b0\u7528\u6237\u4e0e\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u4ea4\u4e92&#xff0c;\u5982\u804a\u5929\u3001\u6295\u7968\u7b49\u3002<\/li>\n<li>\u5b89\u5168\u6027&#xff08;Security&#xff09;&#xff1a;RTSP\u670d\u52a1\u5668\u652f\u6301\u591a\u79cd\u5b89\u5168\u673a\u5236&#xff0c;\u5982\u57fa\u4e8e\u8bc1\u4e66\u7684\u8eab\u4efd\u9a8c\u8bc1\u3001\u6570\u636e\u52a0\u5bc6\u7b49&#xff0c;\u53ef\u4ee5\u4fdd\u62a4\u7528\u6237\u7684\u9690\u79c1\u548c\u6570\u636e\u5b89\u5168\u3002<\/li>\n<p>\u56e0\u6b64&#xff0c;\u6df1\u5165\u7406\u89e3\u548c\u638c\u63e1RTSP\u670d\u52a1\u5668\u7684\u6784\u5efa\u548c\u4f18\u5316&#xff0c;\u5bf9\u4e8e\u63d0\u5347\u6211\u4eec\u7684\u7f51\u7edc\u5e94\u7528\u670d\u52a1\u8d28\u91cf&#xff0c;\u6ee1\u8db3\u7528\u6237\u5bf9\u4e8e\u97f3\u89c6\u9891\u670d\u52a1\u7684\u9ad8\u9700\u6c42\u5177\u6709\u91cd\u8981\u7684\u610f\u4e49\u3002\u5728\u63a5\u4e0b\u6765\u7684\u7ae0\u8282\u4e2d&#xff0c;\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528C&#043;&#043;\u548cLive555\u5e93\u6765\u6784\u5efa\u9ad8\u6548\u3001\u7a33\u5b9a\u7684RTSP\u670d\u52a1\u5668\u3002<\/p>\n<h3>1.2 C&#043;&#043;\u4e0eLive555\u5e93\u7684\u4f18\u52bf&#xff08;Advantages of C&#043;&#043; and Live555&#xff09;<\/h3>\n<p>\u5728\u6784\u5efaRTSP\u670d\u52a1\u5668\u7684\u8fc7\u7a0b\u4e2d&#xff0c;\u9009\u62e9\u5408\u9002\u7684\u7f16\u7a0b\u8bed\u8a00\u548c\u5e93\u662f\u975e\u5e38\u5173\u952e\u7684\u3002C&#043;&#043;\u548cLive555\u5e93\u5728\u8fd9\u65b9\u9762\u5177\u6709\u663e\u8457\u7684\u4f18\u52bf\u3002<\/p>\n<p>C&#043;&#043;\u7684\u4f18\u52bf&#xff1a;<\/p>\n<li>\u6027\u80fd\u4f18\u8d8a&#xff08;Superior Performance&#xff09;&#xff1a;C&#043;&#043;\u662f\u4e00\u79cd\u9759\u6001\u7c7b\u578b\u7684\u7f16\u8bd1\u8bed\u8a00&#xff0c;\u5b83\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u8bed\u8a00\u7279\u6027\u548c\u5f3a\u5927\u7684\u6027\u80fd&#xff0c;\u53ef\u4ee5\u6ee1\u8db3\u9ad8\u6027\u80fd\u670d\u52a1\u5668\u7684\u9700\u6c42\u3002<\/li>\n<li>\u5185\u5b58\u7ba1\u7406&#xff08;Memory Management&#xff09;&#xff1a;C&#043;&#043;\u63d0\u4f9b\u4e86\u76f4\u63a5\u7684\u5185\u5b58\u7ba1\u7406\u80fd\u529b&#xff0c;\u5f00\u53d1\u8005\u53ef\u4ee5\u7cbe\u786e\u5730\u63a7\u5236\u5185\u5b58\u7684\u5206\u914d\u548c\u91ca\u653e&#xff0c;\u8fd9\u5bf9\u4e8e\u5904\u7406\u5927\u91cf\u7684\u5e76\u53d1\u8fde\u63a5\u548c\u6570\u636e\u6d41\u975e\u5e38\u91cd\u8981\u3002<\/li>\n<li>\u9762\u5411\u5bf9\u8c61&#xff08;Object-Oriented&#xff09;&#xff1a;C&#043;&#043;\u662f\u4e00\u79cd\u652f\u6301\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u7684\u8bed\u8a00&#xff0c;\u5b83\u7684\u5c01\u88c5\u3001\u7ee7\u627f\u548c\u591a\u6001\u7b49\u7279\u6027\u4f7f\u5f97\u4ee3\u7801\u66f4\u52a0\u6a21\u5757\u5316&#xff0c;\u6613\u4e8e\u7ef4\u62a4\u548c\u6269\u5c55\u3002<\/li>\n<p>Live555\u5e93\u7684\u4f18\u52bf&#xff1a;<\/p>\n<li>\u4e13\u4e1a\u6027&#xff08;Professionalism&#xff09;&#xff1a;Live555\u662f\u4e00\u4e2a\u4e13\u95e8\u7528\u4e8e\u5b9e\u73b0RTSP\u670d\u52a1\u5668\u7684\u5f00\u6e90\u5e93&#xff0c;\u5b83\u63d0\u4f9b\u4e86\u4e00\u5957\u5b8c\u6574\u7684API&#xff0c;\u53ef\u4ee5\u65b9\u4fbf\u5730\u5b9e\u73b0RTSP\u7684\u5404\u79cd\u529f\u80fd\u3002<\/li>\n<li>\u7a33\u5b9a\u6027&#xff08;Stability&#xff09;&#xff1a;Live555\u5e93\u7ecf\u8fc7\u4e86\u957f\u65f6\u95f4\u7684\u6d4b\u8bd5\u548c\u4f7f\u7528&#xff0c;\u7a33\u5b9a\u6027\u975e\u5e38\u9ad8&#xff0c;\u53ef\u4ee5\u6ee1\u8db3\u751f\u4ea7\u73af\u5883\u7684\u9700\u6c42\u3002<\/li>\n<li>\u8de8\u5e73\u53f0&#xff08;Cross-platform&#xff09;&#xff1a;Live555\u5e93\u652f\u6301\u591a\u79cd\u64cd\u4f5c\u7cfb\u7edf&#xff0c;\u5305\u62ecWindows\u3001Linux\u3001Mac OS\u7b49&#xff0c;\u5f00\u53d1\u8005\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u5e73\u53f0\u4e0a\u8fdb\u884c\u5f00\u53d1\u548c\u90e8\u7f72\u3002<\/li>\n<li>\u793e\u533a\u652f\u6301&#xff08;Community Support&#xff09;&#xff1a;Live555\u6709\u4e00\u4e2a\u6d3b\u8dc3\u7684\u5f00\u6e90\u793e\u533a&#xff0c;\u5f00\u53d1\u8005\u53ef\u4ee5\u4ece\u793e\u533a\u83b7\u53d6\u5e2e\u52a9&#xff0c;\u5206\u4eab\u7ecf\u9a8c&#xff0c;\u540c\u65f6\u4e5f\u53ef\u4ee5\u4e3a\u793e\u533a\u8d21\u732e\u4ee3\u7801\u3002<\/li>\n<p>\u7efc\u4e0a&#xff0c;C&#043;&#043;\u548cLive555\u5e93\u662f\u6784\u5efaRTSP\u670d\u52a1\u5668\u7684\u7406\u60f3\u9009\u62e9\u3002\u5728\u63a5\u4e0b\u6765\u7684\u7ae0\u8282\u4e2d&#xff0c;\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528C&#043;&#043;\u548cLive555\u5e93\u6765\u6784\u5efaRTSP\u670d\u52a1\u5668\u3002<\/p>\n<h3>1.3 \u53ef\u80fd\u7528\u5230\u7684\u7c7b\u548c\u63a5\u53e3\u4ecb\u7ecd<\/h3>\n<p>\u5728Live555\u5e93\u4e2d&#xff0c;\u4ee5\u4e0b\u662f\u4e00\u4e9b\u53ef\u80fd\u4f1a\u7528\u5230\u7684\u7c7b\u548c\u65b9\u6cd5&#xff1a;<\/p>\n<li>UsageEnvironment\u7c7b&#xff1a;\u8fd9\u662f\u4e00\u4e2a\u62bd\u8c61\u57fa\u7c7b&#xff0c;\u7528\u4e8e\u5b9a\u4e49\u4e8b\u4ef6\u5faa\u73af\u3002\u4f60\u53ef\u80fd\u4f1a\u4f7f\u7528\u5230\u5b83\u7684taskScheduler()\u65b9\u6cd5\u6765\u83b7\u53d6\u4efb\u52a1\u8c03\u5ea6\u5668\u3002<\/li>\n<li>BasicUsageEnvironment\u7c7b&#xff1a;\u8fd9\u662fUsageEnvironment\u7684\u4e00\u4e2a\u5177\u4f53\u5b9e\u73b0&#xff0c;\u4f60\u53ef\u80fd\u4f1a\u4f7f\u7528\u5b83\u7684createNew()\u65b9\u6cd5\u6765\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u73af\u5883\u3002<\/li>\n<li>RTSPServer\u7c7b&#xff1a;\u8fd9\u4e2a\u7c7b\u7528\u4e8e\u521b\u5efa\u548c\u7ba1\u7406RTSP\u670d\u52a1\u5668\u3002\u4f60\u53ef\u80fd\u4f1a\u4f7f\u7528\u5230\u5b83\u7684createNew()\u65b9\u6cd5\u6765\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u670d\u52a1\u5668&#xff0c;\u4ee5\u53caaddServerMediaSession()\u65b9\u6cd5\u6765\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684\u5a92\u4f53\u4f1a\u8bdd\u3002<\/li>\n<li>ServerMediaSession\u7c7b&#xff1a;\u8fd9\u4e2a\u7c7b\u8868\u793a\u4e00\u4e2aRTSP\u670d\u52a1\u5668\u7684\u5a92\u4f53\u4f1a\u8bdd\u3002\u4f60\u53ef\u80fd\u4f1a\u4f7f\u7528\u5230\u5b83\u7684addSubsession()\u65b9\u6cd5\u6765\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684\u5b50\u4f1a\u8bdd\u3002<\/li>\n<li>H264VideoStreamFramer\u7c7b&#xff1a;\u8fd9\u4e2a\u7c7b\u7528\u4e8e\u521b\u5efaH.264\u89c6\u9891\u6d41\u3002\u4f60\u53ef\u80fd\u4f1a\u4f7f\u7528\u5230\u5b83\u7684createNew()\u65b9\u6cd5\u6765\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u89c6\u9891\u6d41\u3002<\/li>\n<p>\u4ee5\u4e0a\u53ea\u662f\u4e00\u4e9b\u57fa\u672c\u7684\u7c7b\u548c\u65b9\u6cd5&#xff0c;\u5b9e\u9645\u4f7f\u7528\u65f6\u53ef\u80fd\u8fd8\u9700\u8981\u5176\u4ed6\u7684\u7c7b\u548c\u65b9\u6cd5\u3002\u5177\u4f53\u7684\u4f7f\u7528\u65b9\u6cd5\u548c\u53c2\u6570\u5e94\u6839\u636eLive555\u7684\u5b98\u65b9\u6587\u6863\u548c\u6e90\u4ee3\u7801\u6765\u786e\u5b9a\u3002<\/p>\n<p>\u5728\u4f7f\u7528Live555\u5e93\u65f6&#xff0c;\u53ef\u80fd\u4f1a\u7528\u5230\u4ee5\u4e0b\u4e00\u4e9b\u51fd\u6570\u548c\u63a5\u53e3&#xff1a;<\/p>\n<li>RTSPClient::createNew: \u521b\u5efa\u4e00\u4e2a\u65b0\u7684RTSP\u5ba2\u6237\u7aef\u5b9e\u4f8b\u3002\u8fd9\u4e2a\u51fd\u6570\u9700\u8981\u4e00\u4e2a\u73af\u5883\u53d8\u91cf&#xff0c;RTSP URL&#xff0c;\u4ee5\u53ca\u4e00\u4e2a\u53ef\u9009\u7684\u5e94\u7528\u7a0b\u5e8f\u540d\u79f0\u548c\u7aef\u53e3\u53f7\u3002<\/li>\n<li>RTSPServer::createNew: \u521b\u5efa\u4e00\u4e2a\u65b0\u7684RTSP\u670d\u52a1\u5668\u5b9e\u4f8b\u3002\u8fd9\u4e2a\u51fd\u6570\u9700\u8981\u4e00\u4e2a\u73af\u5883\u53d8\u91cf\u548c\u4e00\u4e2a\u53ef\u9009\u7684\u670d\u52a1\u5668\u7aef\u53e3\u53f7\u3002<\/li>\n<li>RTSPClient::sendPlayCommand: \u53d1\u9001\u4e00\u4e2aPLAY\u547d\u4ee4\u5230RTSP\u670d\u52a1\u5668\u3002\u8fd9\u4e2a\u51fd\u6570\u9700\u8981\u4e00\u4e2a\u5a92\u4f53\u4f1a\u8bdd\u548c\u4e00\u4e2a\u53ef\u9009\u7684\u56de\u8c03\u51fd\u6570\u3002<\/li>\n<li>RTSPClient::sendPauseCommand: \u53d1\u9001\u4e00\u4e2aPAUSE\u547d\u4ee4\u5230RTSP\u670d\u52a1\u5668\u3002\u8fd9\u4e2a\u51fd\u6570\u9700\u8981\u4e00\u4e2a\u5a92\u4f53\u4f1a\u8bdd\u548c\u4e00\u4e2a\u53ef\u9009\u7684\u56de\u8c03\u51fd\u6570\u3002<\/li>\n<li>RTSPClient::sendTeardownCommand: \u53d1\u9001\u4e00\u4e2aTEARDOWN\u547d\u4ee4\u5230RTSP\u670d\u52a1\u5668\u3002\u8fd9\u4e2a\u51fd\u6570\u9700\u8981\u4e00\u4e2a\u5a92\u4f53\u4f1a\u8bdd\u548c\u4e00\u4e2a\u53ef\u9009\u7684\u56de\u8c03\u51fd\u6570\u3002<\/li>\n<li>RTSPServer::setUpTunnelingOverHTTP: \u8bbe\u7f6eRTSP\u670d\u52a1\u5668\u4ee5\u901a\u8fc7HTTP\u8fdb\u884c\u96a7\u9053\u4f20\u8f93\u3002\u8fd9\u4e2a\u51fd\u6570\u9700\u8981\u4e00\u4e2aHTTP\u7aef\u53e3\u53f7\u3002<\/li>\n<li>RTSPServer::addUserRecord: \u6dfb\u52a0\u4e00\u4e2a\u7528\u6237\u8bb0\u5f55\u5230RTSP\u670d\u52a1\u5668\u7684\u7528\u6237\u6570\u636e\u5e93\u3002\u8fd9\u4e2a\u51fd\u6570\u9700\u8981\u4e00\u4e2a\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002<\/li>\n<li>RTSPServer::removeUserRecord: \u4eceRTSP\u670d\u52a1\u5668\u7684\u7528\u6237\u6570\u636e\u5e93\u4e2d\u5220\u9664\u4e00\u4e2a\u7528\u6237\u8bb0\u5f55\u3002\u8fd9\u4e2a\u51fd\u6570\u9700\u8981\u4e00\u4e2a\u7528\u6237\u540d\u3002<\/li>\n<p>\u4ee5\u4e0a\u4fe1\u606f\u662f\u6839\u636eGitHub\u4e0a\u7684\u4ee3\u7801\u7247\u6bb5\u63d0\u53d6\u7684&#xff0c;\u53ef\u80fd\u5e76\u4e0d\u5b8c\u5168\u51c6\u786e&#xff0c;\u5177\u4f53\u4f7f\u7528\u65f6\u8fd8\u9700\u8981\u53c2\u8003Live555\u7684\u5b98\u65b9\u6587\u6863\u548c\u6e90\u4ee3\u7801\u3002<\/p>\n<h3>\u4e8c\u3001C&#043;&#043;\u4e0eLive555\u5e93\u6982\u8ff0&#xff08;Overview of C&#043;&#043; and Live555&#xff09;<\/h3>\n<h3>2.1 C&#043;&#043;\u8bed\u8a00\u7279\u6027&#xff08;Features of C&#043;&#043;&#xff09;<\/h3>\n<p>C&#043;&#043;\u662f\u4e00\u79cd\u901a\u7528\u7684\u7f16\u7a0b\u8bed\u8a00&#xff0c;\u5b83\u5728C\u8bed\u8a00\u7684\u57fa\u7840\u4e0a\u589e\u52a0\u4e86\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b&#xff08;Object-Oriented Programming&#xff0c;\u7b80\u79f0OOP&#xff09;\u7684\u7279\u6027\u3002C&#043;&#043;\u7684\u4e3b\u8981\u7279\u6027\u53ef\u4ee5\u5f52\u7eb3\u4e3a\u4ee5\u4e0b\u51e0\u70b9&#xff1a;<\/p>\n<li>\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b&#xff08;Object-Oriented Programming&#xff09;&#xff1a;C&#043;&#043;\u652f\u6301\u5c01\u88c5&#xff08;Encapsulation&#xff09;\u3001\u7ee7\u627f&#xff08;Inheritance&#xff09;\u548c\u591a\u6001&#xff08;Polymorphism&#xff09;\u7b49\u9762\u5411\u5bf9\u8c61\u7684\u57fa\u672c\u7279\u6027\u3002\u8fd9\u4e9b\u7279\u6027\u4f7f\u5f97C&#043;&#043;\u80fd\u591f\u66f4\u597d\u5730\u5904\u7406\u590d\u6742\u7684\u95ee\u9898&#xff0c;\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u91cd\u7528\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002<\/li>\n<li>\u6cdb\u578b\u7f16\u7a0b&#xff08;Generic Programming&#xff09;&#xff1a;C&#043;&#043;\u7684\u6a21\u677f&#xff08;Template&#xff09;\u7279\u6027\u652f\u6301\u6cdb\u578b\u7f16\u7a0b&#xff0c;\u8fd9\u4f7f\u5f97\u6211\u4eec\u53ef\u4ee5\u7f16\u5199\u51fa\u901a\u7528\u7684\u3001\u53ef\u91cd\u7528\u7684\u4ee3\u7801\u3002<\/li>\n<li>\u4f4e\u7ea7\u64cd\u4f5c&#xff08;Low-Level Manipulation&#xff09;&#xff1a;C&#043;&#043;\u5141\u8bb8\u7a0b\u5e8f\u5458\u8fdb\u884c\u76f4\u63a5\u7684\u5185\u5b58\u64cd\u4f5c&#xff0c;\u8fd9\u4f7f\u5f97C&#043;&#043;\u80fd\u591f\u7f16\u5199\u51fa\u9ad8\u6548\u7684\u4ee3\u7801&#xff0c;\u6ee1\u8db3\u5bf9\u6027\u80fd\u8981\u6c42\u8f83\u9ad8\u7684\u573a\u666f\u3002<\/li>\n<li>\u4e30\u5bcc\u7684\u5e93\u652f\u6301&#xff08;Rich Library Support&#xff09;&#xff1a;C&#043;&#043;\u6709\u7740\u4e30\u5bcc\u7684\u6807\u51c6\u5e93&#xff08;\u5982STL&#xff09;\u548c\u7b2c\u4e09\u65b9\u5e93&#xff08;\u5982Live555&#xff09;&#xff0c;\u8fd9\u4e9b\u5e93\u63d0\u4f9b\u4e86\u5927\u91cf\u7684\u6570\u636e\u7ed3\u6784\u548c\u7b97\u6cd5&#xff0c;\u6781\u5927\u5730\u63d0\u9ad8\u4e86\u5f00\u53d1\u6548\u7387\u3002<\/li>\n<li>\u517c\u5bb9C\u8bed\u8a00&#xff08;Compatibility with C&#xff09;&#xff1a;C&#043;&#043;\u51e0\u4e4e\u5b8c\u5168\u517c\u5bb9C\u8bed\u8a00&#xff0c;\u8fd9\u4f7f\u5f97C&#043;&#043;\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u5927\u91cf\u7684C\u8bed\u8a00\u4ee3\u7801\u548c\u5e93\u3002<\/li>\n<p>\u4ee5\u4e0a\u7279\u6027\u4f7f\u5f97C&#043;&#043;\u6210\u4e3a\u4e86\u4e00\u79cd\u5f3a\u5927\u800c\u7075\u6d3b\u7684\u7f16\u7a0b\u8bed\u8a00&#xff0c;\u5b83\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8e\u5404\u79cd\u9886\u57df&#xff0c;\u5305\u62ec\u64cd\u4f5c\u7cfb\u7edf\u3001\u6e38\u620f\u5f00\u53d1\u3001\u5d4c\u5165\u5f0f\u7cfb\u7edf\u3001\u5b9e\u65f6\u7cfb\u7edf\u3001\u7f51\u7edc\u7f16\u7a0b\u7b49\u3002\u5728RTSP\u670d\u52a1\u5668\u7684\u5f00\u53d1\u4e2d&#xff0c;C&#043;&#043;\u7684\u8fd9\u4e9b\u7279\u6027\u4e5f\u80fd\u591f\u5f97\u5230\u5145\u5206\u7684\u5229\u7528\u3002<\/p>\n<h3>2.2 Live555\u5e93\u7b80\u4ecb&#xff08;Introduction to Live555&#xff09;<\/h3>\n<p>Live555\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u6d41\u5a92\u4f53\u5e93&#xff0c;\u5b83\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684API\u63a5\u53e3&#xff0c;\u7528\u4e8e\u5b9e\u73b0RTSP&#xff08;Real Time Streaming Protocol&#xff09;\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u7684\u529f\u80fd\u3002Live555\u5e93\u7684\u4e3b\u8981\u7279\u6027\u53ef\u4ee5\u5f52\u7eb3\u4e3a\u4ee5\u4e0b\u51e0\u70b9&#xff1a;<\/p>\n<li>\u652f\u6301\u591a\u79cd\u6d41\u5a92\u4f53\u534f\u8bae&#xff1a;Live555\u652f\u6301\u591a\u79cd\u6d41\u5a92\u4f53\u534f\u8bae&#xff0c;\u5305\u62ecRTSP\u3001RTP&#xff08;Real-time Transport Protocol&#xff09;\u3001RTCP&#xff08;RTP Control Protocol&#xff09;\u7b49\u3002\u8fd9\u4f7f\u5f97Live555\u80fd\u591f\u5904\u7406\u5404\u79cd\u590d\u6742\u7684\u6d41\u5a92\u4f53\u4f20\u8f93\u4efb\u52a1\u3002<\/li>\n<li>\u652f\u6301\u591a\u79cd\u5a92\u4f53\u683c\u5f0f&#xff1a;Live555\u652f\u6301\u591a\u79cd\u5a92\u4f53\u683c\u5f0f&#xff0c;\u5305\u62ecH.264\u3001H.265\u3001AAC\u3001MP3\u7b49\u3002\u8fd9\u4f7f\u5f97Live555\u80fd\u591f\u5904\u7406\u5404\u79cd\u7c7b\u578b\u7684\u5a92\u4f53\u6570\u636e\u3002<\/li>\n<li>\u652f\u6301\u591a\u5e73\u53f0&#xff1a;Live555\u53ef\u4ee5\u5728\u591a\u79cd\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u8fd0\u884c&#xff0c;\u5305\u62ecWindows\u3001Linux\u3001Mac OS\u7b49\u3002\u8fd9\u4f7f\u5f97Live555\u5177\u6709\u5f88\u597d\u7684\u8de8\u5e73\u53f0\u6027\u3002<\/li>\n<li>\u9ad8\u6548\u7684\u6027\u80fd&#xff1a;Live555\u5728\u8bbe\u8ba1\u548c\u5b9e\u73b0\u4e0a\u6ce8\u91cd\u6548\u7387&#xff0c;\u5b83\u80fd\u591f\u5904\u7406\u5927\u91cf\u7684\u5e76\u53d1\u8fde\u63a5&#xff0c;\u6ee1\u8db3\u9ad8\u6027\u80fd\u7684\u9700\u6c42\u3002<\/li>\n<li>\u4e30\u5bcc\u7684\u793a\u4f8b\u4ee3\u7801&#xff1a;Live555\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u793a\u4f8b\u4ee3\u7801&#xff0c;\u8fd9\u4e9b\u4ee3\u7801\u8986\u76d6\u4e86\u5404\u79cd\u5e38\u89c1\u7684\u4f7f\u7528\u573a\u666f&#xff0c;\u5bf9\u4e8e\u5f00\u53d1\u8005\u6765\u8bf4\u662f\u5f88\u597d\u7684\u5b66\u4e60\u8d44\u6599\u3002<\/li>\n<p>\u5728RTSP\u670d\u52a1\u5668\u7684\u5f00\u53d1\u4e2d&#xff0c;Live555\u5e93\u7684\u8fd9\u4e9b\u7279\u6027\u4f7f\u5f97\u5b83\u6210\u4e3a\u4e86\u4e00\u4e2a\u7406\u60f3\u7684\u9009\u62e9\u3002\u901a\u8fc7\u4f7f\u7528Live555&#xff0c;\u6211\u4eec\u53ef\u4ee5\u66f4\u52a0\u65b9\u4fbf\u548c\u9ad8\u6548\u5730\u5b9e\u73b0RTSP\u670d\u52a1\u5668\u7684\u529f\u80fd\u3002<\/p>\n<h3>2.3 Live555\u5728RTSP\u670d\u52a1\u5668\u4e2d\u7684\u5e94\u7528&#xff08;Application of Live555 in RTSP Server&#xff09;<\/h3>\n<p>\u5728RTSP\u670d\u52a1\u5668\u7684\u5f00\u53d1\u4e2d&#xff0c;Live555\u5e93\u53d1\u6325\u7740\u91cd\u8981\u7684\u4f5c\u7528\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u4e3b\u8981\u7684\u5e94\u7528\u573a\u666f&#xff1a;<\/p>\n<li>\u5a92\u4f53\u6d41\u7684\u5c01\u88c5\u548c\u4f20\u8f93&#xff1a;Live555\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684\u7c7b\u548c\u51fd\u6570&#xff0c;\u7528\u4e8e\u5c01\u88c5\u548c\u4f20\u8f93\u5a92\u4f53\u6d41\u3002\u4f8b\u5982&#xff0c;\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528H264VideoStreamFramer\u7c7b\u6765\u5c01\u88c5H.264\u89c6\u9891\u6d41&#xff0c;\u7136\u540e\u4f7f\u7528RTPSink\u7c7b\u6765\u5c06\u5c01\u88c5\u540e\u7684\u6d41\u53d1\u9001\u5230\u5ba2\u6237\u7aef\u3002<\/li>\n<li>RTSP\u4f1a\u8bdd\u7684\u7ba1\u7406&#xff1a;Live555\u63d0\u4f9b\u4e86RTSPServer\u7c7b&#xff0c;\u7528\u4e8e\u7ba1\u7406RTSP\u4f1a\u8bdd\u3002RTSPServer\u7c7b\u53ef\u4ee5\u5904\u7406\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\u8bf7\u6c42&#xff0c;\u7ba1\u7406\u5a92\u4f53\u6d41\u7684\u64ad\u653e\u548c\u6682\u505c&#xff0c;\u4ee5\u53ca\u5904\u7406\u5176\u4ed6\u7684RTSP\u547d\u4ee4\u3002<\/li>\n<li>\u5a92\u4f53\u6e90\u7684\u7ba1\u7406&#xff1a;Live555\u63d0\u4f9b\u4e86MediaSession\u7c7b&#xff0c;\u7528\u4e8e\u7ba1\u7406\u5a92\u4f53\u6e90\u3002MediaSession\u7c7b\u53ef\u4ee5\u7ba1\u7406\u4e00\u4e2a\u6216\u591a\u4e2a\u5a92\u4f53\u6d41&#xff0c;\u5b83\u63d0\u4f9b\u4e86\u4e00\u79cd\u7edf\u4e00\u7684\u63a5\u53e3&#xff0c;\u4f7f\u5f97\u6211\u4eec\u53ef\u4ee5\u65b9\u4fbf\u5730\u63a7\u5236\u5a92\u4f53\u6d41\u7684\u64ad\u653e\u548c\u6682\u505c\u3002<\/li>\n<li>\u9519\u8bef\u5904\u7406\u548c\u65e5\u5fd7\u8bb0\u5f55&#xff1a;Live555\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684\u9519\u8bef\u5904\u7406\u548c\u65e5\u5fd7\u8bb0\u5f55\u529f\u80fd&#xff0c;\u8fd9\u4e9b\u529f\u80fd\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u597d\u5730\u8c03\u8bd5\u548c\u7ef4\u62a4RTSP\u670d\u52a1\u5668\u3002<\/li>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u7684\u5e94\u7528&#xff0c;\u6211\u4eec\u53ef\u4ee5\u770b\u5230&#xff0c;Live555\u5e93\u4e3aRTSP\u670d\u52a1\u5668\u7684\u5f00\u53d1\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u652f\u6301\u3002\u5728\u540e\u7eed\u7684\u7ae0\u8282\u4e2d&#xff0c;\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Live555\u5e93\u6765\u6784\u5efaRTSP\u670d\u52a1\u5668\u3002<\/p>\n<h3>\u4e09\u3001RTSP\u670d\u52a1\u5668\u7684\u6784\u5efa\u6d41\u7a0b&#xff08;Building Process of RTSP Server&#xff09;<\/h3>\n<h3>3.1 RTSP\u670d\u52a1\u5668\u7684\u57fa\u672c\u67b6\u6784&#xff08;Basic Architecture of RTSP Server&#xff09;<\/h3>\n<p>RTSP&#xff08;Real Time Streaming Protocol&#xff0c;\u5b9e\u65f6\u6d41\u4f20\u8f93\u534f\u8bae&#xff09;\u670d\u52a1\u5668\u662f\u4e00\u79cd\u4e13\u95e8\u7528\u4e8e\u63a7\u5236\u97f3\u9891\u6216\u89c6\u9891\u6d41\u7684\u4f20\u8f93\u7684\u670d\u52a1\u5668\u3002\u5b83\u7684\u4e3b\u8981\u529f\u80fd\u662f\u63a7\u5236\u6570\u636e\u6d41\u7684\u64ad\u653e\u3001\u6682\u505c\u3001\u56de\u653e\u7b49\u64cd\u4f5c&#xff0c;\u800c\u6570\u636e\u6d41\u7684\u4f20\u8f93\u5219\u901a\u5e38\u7531RTP&#xff08;Real-time Transport Protocol&#xff0c;\u5b9e\u65f6\u4f20\u8f93\u534f\u8bae&#xff09;\u6216\u8005UDP&#xff08;User Datagram Protocol&#xff0c;\u7528\u6237\u6570\u636e\u62a5\u534f\u8bae&#xff09;\u6765\u5b8c\u6210\u3002<\/p>\n<p>RTSP\u670d\u52a1\u5668\u7684\u57fa\u672c\u67b6\u6784\u4e3b\u8981\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u90e8\u5206&#xff1a;<\/p>\n<li>\u5ba2\u6237\u7aef&#xff08;Client&#xff09;&#xff1a;\u5ba2\u6237\u7aef\u662f\u53d1\u8d77RTSP\u8bf7\u6c42\u7684\u4e00\u65b9&#xff0c;\u901a\u5e38\u662f\u7528\u6237\u7684\u64ad\u653e\u8bbe\u5907&#xff0c;\u5982\u7535\u8111\u3001\u624b\u673a\u7b49\u3002<\/li>\n<li>\u670d\u52a1\u5668&#xff08;Server&#xff09;&#xff1a;\u670d\u52a1\u5668\u662f\u63a5\u6536\u548c\u5904\u7406RTSP\u8bf7\u6c42\u7684\u4e00\u65b9&#xff0c;\u8d1f\u8d23\u5bf9\u8bf7\u6c42\u8fdb\u884c\u54cd\u5e94&#xff0c;\u5e76\u63a7\u5236\u6570\u636e\u6d41\u7684\u4f20\u8f93\u3002<\/li>\n<li>\u5a92\u4f53\u6d41&#xff08;Media Stream&#xff09;&#xff1a;\u5a92\u4f53\u6d41\u662f\u670d\u52a1\u5668\u4f20\u8f93\u7684\u97f3\u9891\u6216\u89c6\u9891\u6570\u636e&#xff0c;\u901a\u5e38\u7531RTP\u6216UDP\u534f\u8bae\u8fdb\u884c\u4f20\u8f93\u3002<\/li>\n<li>\u63a7\u5236\u534f\u8bae&#xff08;Control Protocol&#xff09;&#xff1a;\u63a7\u5236\u534f\u8bae\u662f\u7528\u4e8e\u63a7\u5236\u5a92\u4f53\u6d41\u4f20\u8f93\u7684\u534f\u8bae&#xff0c;\u901a\u5e38\u662fRTSP\u534f\u8bae\u3002<\/li>\n<p>\u5728\u8fd9\u4e2a\u67b6\u6784\u4e2d&#xff0c;\u5ba2\u6237\u7aef\u901a\u8fc7\u53d1\u9001RTSP\u8bf7\u6c42&#xff08;\u5982PLAY\u3001PAUSE\u7b49&#xff09;\u7ed9\u670d\u52a1\u5668&#xff0c;\u670d\u52a1\u5668\u63a5\u6536\u5230\u8bf7\u6c42\u540e&#xff0c;\u901a\u8fc7\u63a7\u5236\u534f\u8bae\u6765\u63a7\u5236\u5a92\u4f53\u6d41\u7684\u4f20\u8f93\u3002\u4f8b\u5982&#xff0c;\u5f53\u5ba2\u6237\u7aef\u53d1\u9001\u4e00\u4e2aPLAY\u8bf7\u6c42\u65f6&#xff0c;\u670d\u52a1\u5668\u4f1a\u5f00\u59cb\u4f20\u8f93\u5a92\u4f53\u6d41&#xff1b;\u5f53\u5ba2\u6237\u7aef\u53d1\u9001\u4e00\u4e2aPAUSE\u8bf7\u6c42\u65f6&#xff0c;\u670d\u52a1\u5668\u4f1a\u6682\u505c\u4f20\u8f93\u5a92\u4f53\u6d41\u3002<\/p>\n<p>\u8fd9\u79cd\u67b6\u6784\u7684\u4f18\u70b9\u662f&#xff0c;\u5b83\u5c06\u6570\u636e\u6d41\u7684\u4f20\u8f93\u548c\u63a7\u5236\u5206\u79bb\u5f00\u6765&#xff0c;\u4f7f\u5f97\u670d\u52a1\u5668\u53ef\u4ee5\u66f4\u7075\u6d3b\u5730\u63a7\u5236\u6570\u636e\u6d41\u7684\u4f20\u8f93&#xff0c;\u800c\u5ba2\u6237\u7aef\u4e5f\u53ef\u4ee5\u66f4\u65b9\u4fbf\u5730\u63a7\u5236\u6570\u636e\u6d41\u7684\u64ad\u653e\u3002\u540c\u65f6&#xff0c;\u7531\u4e8eRTSP\u534f\u8bae\u662f\u57fa\u4e8eTCP&#xff08;Transmission Control Protocol&#xff0c;\u4f20\u8f93\u63a7\u5236\u534f\u8bae&#xff09;\u7684&#xff0c;\u56e0\u6b64\u5b83\u53ef\u4ee5\u63d0\u4f9b\u53ef\u9760\u7684\u6570\u636e\u4f20\u8f93&#xff0c;\u786e\u4fdd\u6570\u636e\u6d41\u7684\u5b8c\u6574\u6027\u548c\u51c6\u786e\u6027\u3002<\/p>\n<p>\u5728\u4e0b\u4e00\u8282\u4e2d&#xff0c;\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528C&#043;&#043;\u548cLive555\u5e93\u6765\u6784\u5efa\u4e00\u4e2aRTSP\u670d\u52a1\u5668&#xff0c;\u5305\u62ec\u5982\u4f55\u8bbe\u7f6e\u670d\u52a1\u5668\u3001\u5982\u4f55\u5904\u7406\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42&#xff0c;\u4ee5\u53ca\u5982\u4f55\u63a7\u5236\u5a92\u4f53\u6d41\u7684\u4f20\u8f93\u7b49\u3002<\/p>\n<h3>3.2 \u4f7f\u7528C&#043;&#043;\u548cLive555\u6784\u5efaRTSP\u670d\u52a1\u5668&#xff08;Building RTSP Server with C&#043;&#043; and Live555&#xff09;<\/h3>\n<p>Live555\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u6d41\u5a92\u4f53\u5e93&#xff0c;\u63d0\u4f9b\u4e86\u4e00\u5957\u5b8c\u6574\u7684API&#xff0c;\u53ef\u4ee5\u65b9\u4fbf\u5730\u6784\u5efaRTSP\u670d\u52a1\u5668\u3002\u5728\u8fd9\u4e00\u8282\u4e2d&#xff0c;\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528C&#043;&#043;\u548cLive555\u5e93\u6765\u6784\u5efa\u4e00\u4e2aRTSP\u670d\u52a1\u5668\u3002<\/p>\n<h4>\u6b65\u9aa4\u4e00&#xff1a;\u73af\u5883\u914d\u7f6e&#xff08;Environment Configuration&#xff09;<\/h4>\n<p>\u9996\u5148&#xff0c;\u6211\u4eec\u9700\u8981\u5728\u6211\u4eec\u7684\u5f00\u53d1\u73af\u5883\u4e2d\u5b89\u88c5Live555\u5e93\u3002Live555\u5e93\u652f\u6301\u591a\u79cd\u64cd\u4f5c\u7cfb\u7edf&#xff0c;\u5305\u62ecWindows\u3001Linux\u548cMac OS\u7b49\u3002\u6211\u4eec\u53ef\u4ee5\u4eceLive555\u7684\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u6e90\u4ee3\u7801&#xff0c;\u7136\u540e\u6309\u7167\u5b98\u65b9\u7684\u5b89\u88c5\u6307\u5357\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<h4>\u6b65\u9aa4\u4e8c&#xff1a;\u521b\u5efaRTSP\u670d\u52a1\u5668&#xff08;Creating RTSP Server&#xff09;<\/h4>\n<p>\u521b\u5efaRTSP\u670d\u52a1\u5668\u7684\u7b2c\u4e00\u6b65\u662f\u521b\u5efa\u4e00\u4e2aRTSP\u670d\u52a1\u5668\u5b9e\u4f8b\u3002\u5728Live555\u5e93\u4e2d&#xff0c;\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528RTSPServer::createNew\u51fd\u6570\u6765\u521b\u5efa\u4e00\u4e2aRTSP\u670d\u52a1\u5668\u5b9e\u4f8b\u3002\u8fd9\u4e2a\u51fd\u6570\u9700\u8981\u4e00\u4e2aUsageEnvironment\u53c2\u6570&#xff0c;\u8fd9\u662fLive555\u5e93\u4e2d\u7684\u4e00\u4e2a\u6838\u5fc3\u7c7b&#xff0c;\u7528\u4e8e\u5904\u7406\u4e8b\u4ef6\u5faa\u73af\u548c\u9519\u8bef\u62a5\u544a\u3002<\/p>\n<p>TaskScheduler* scheduler &#061; BasicTaskScheduler::createNew();<br \/>\nUsageEnvironment* env &#061; BasicUsageEnvironment::createNew(*scheduler);<br \/>\nRTSPServer* rtspServer &#061; RTSPServer::createNew(*env, 8554); <\/p>\n<p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d&#xff0c;\u6211\u4eec\u9996\u5148\u521b\u5efa\u4e86\u4e00\u4e2aTaskScheduler\u5b9e\u4f8b\u548c\u4e00\u4e2aUsageEnvironment\u5b9e\u4f8b&#xff0c;\u7136\u540e\u4f7f\u7528\u8fd9\u4e24\u4e2a\u5b9e\u4f8b\u4f5c\u4e3a\u53c2\u6570\u521b\u5efa\u4e86\u4e00\u4e2aRTSP\u670d\u52a1\u5668\u5b9e\u4f8b\u3002\u8fd9\u4e2aRTSP\u670d\u52a1\u5668\u76d1\u542c8554\u7aef\u53e3\u3002<\/p>\n<h4>\u6b65\u9aa4\u4e09&#xff1a;\u521b\u5efa\u5a92\u4f53\u4f1a\u8bdd&#xff08;Creating Media Session&#xff09;<\/h4>\n<p>\u521b\u5efaRTSP\u670d\u52a1\u5668\u540e&#xff0c;\u6211\u4eec\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u6216\u591a\u4e2a\u5a92\u4f53\u4f1a\u8bdd&#xff08;Media Session&#xff09;\u3002\u6bcf\u4e2a\u5a92\u4f53\u4f1a\u8bdd\u5bf9\u5e94\u4e00\u4e2a\u5a92\u4f53\u6d41&#xff0c;\u53ef\u4ee5\u662f\u97f3\u9891\u6d41\u3001\u89c6\u9891\u6d41\u6216\u8005\u5176\u4ed6\u7c7b\u578b\u7684\u5a92\u4f53\u6d41\u3002<\/p>\n<p>\u5728Live555\u5e93\u4e2d&#xff0c;\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528ServerMediaSession::createNew\u51fd\u6570\u6765\u521b\u5efa\u4e00\u4e2a\u5a92\u4f53\u4f1a\u8bdd\u3002\u8fd9\u4e2a\u51fd\u6570\u9700\u8981\u4e00\u4e2aUsageEnvironment\u53c2\u6570&#xff0c;\u4e00\u4e2a\u4f1a\u8bdd\u540d\u79f0&#xff0c;\u4ee5\u53ca\u4e00\u4e9b\u5176\u4ed6\u7684\u53c2\u6570&#xff0c;\u5982\u5a92\u4f53\u6e90\u3001\u5a92\u4f53\u7c7b\u578b\u7b49\u3002<\/p>\n<p>ServerMediaSession* sms &#061; ServerMediaSession::createNew(*env, &#034;testStream&#034;, &#034;testStream&#034;,<br \/>\n    &#034;Session streamed by \\\\&#034;testStream\\\\&#034;&#034;, True \/*SSM*\/);<br \/>\nrtspServer-&gt;addServerMediaSession(sms); <\/p>\n<p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d&#xff0c;\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a&#034;testStream&#034;\u7684\u5a92\u4f53\u4f1a\u8bdd&#xff0c;\u5e76\u5c06\u8fd9\u4e2a\u4f1a\u8bdd\u6dfb\u52a0\u5230\u4e86RTSP\u670d\u52a1\u5668\u4e2d\u3002<\/p>\n<h4>\u6b65\u9aa4\u56db&#xff1a;\u542f\u52a8\u4e8b\u4ef6\u5faa\u73af&#xff08;Starting Event Loop&#xff09;<\/h4>\n<p>\u6700\u540e&#xff0c;\u6211\u4eec\u9700\u8981\u542f\u52a8\u4e8b\u4ef6\u5faa\u73af&#xff0c;\u8ba9RTSP\u670d\u52a1\u5668\u5f00\u59cb\u5904\u7406\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\u3002<\/p>\n<p>env-&gt;taskScheduler().doEventLoop(); \/\/ does not return <\/p>\n<p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d&#xff0c;\u6211\u4eec\u8c03\u7528\u4e86doEventLoop\u51fd\u6570&#xff0c;\u8fd9\u4e2a\u51fd\u6570\u4f1a\u963b\u585e\u5f53\u524d\u7ebf\u7a0b&#xff0c;\u76f4\u5230\u4e8b\u4ef6\u5faa\u73af\u88ab\u505c\u6b62\u3002<\/p>\n<p>  Here is an example of a C&#043;&#043; program that uses the Live555 library to create an RTSP server: <\/p>\n<p>#include &#034;liveMedia.hh&#034;<br \/>\n#include &#034;BasicUsageEnvironment.hh&#034;<\/p>\n<p>int main(int argc, char** argv) {<br \/>\n  \/\/ Begin by setting up our usage environment:<br \/>\n  TaskScheduler* scheduler &#061; BasicTaskScheduler::createNew();<br \/>\n  UsageEnvironment* env &#061; BasicUsageEnvironment::createNew(*scheduler);<\/p>\n<p>  UserAuthenticationDatabase* authDB &#061; NULL;<br \/>\n#ifdef ACCESS_CONTROL<br \/>\n  \/\/ To implement client access control to the RTSP server, do the following:<br \/>\n  authDB &#061; new UserAuthenticationDatabase;<br \/>\n  authDB-&gt;addUserRecord(&#034;username1&#034;, &#034;password1&#034;); \/\/ replace these with real strings<br \/>\n  \/\/ Repeat the above with each &lt;username&gt;, &lt;password&gt; that you wish to allow<br \/>\n  \/\/ access to the server.<br \/>\n#endif<\/p>\n<p>  \/\/ Create the RTSP server. Try first with the default port number (554),<br \/>\n  \/\/ and then with the alternative port number (8554):<br \/>\n  RTSPServer* rtspServer;<br \/>\n  portNumBits rtspServerPortNum &#061; 554;<br \/>\n  rtspServer &#061; RTSPServer::createNew(*env, rtspServerPortNum, authDB);<br \/>\n  if (rtspServer &#061;&#061; NULL) {<br \/>\n    rtspServerPortNum &#061; 8554;<br \/>\n    rtspServer &#061; RTSPServer::createNew(*env, rtspServerPortNum, authDB);<br \/>\n  }<br \/>\n  if (rtspServer &#061;&#061; NULL) {<br \/>\n    *env &lt;&lt; &#034;Failed to create RTSP server: &#034; &lt;&lt; env-&gt;getResultMsg() &lt;&lt; &#034;\\\\n&#034;;<br \/>\n    exit(1);<br \/>\n  }<\/p>\n<p>  char* descriptionString<br \/>\n    &#061; (char*)&#034;Session streamed by \\\\&#034;testOnDemandRTSPServer\\\\&#034;&#034;;<\/p>\n<p>  \/\/ A H.264 video elementary stream:<br \/>\n  {<br \/>\n    char const* streamName &#061; &#034;h264ESVideoTest&#034;;<br \/>\n    char const* inputFileName &#061; &#034;test.264&#034;;<br \/>\n    ServerMediaSession* sms<br \/>\n      &#061; ServerMediaSession::createNew(*env, streamName, streamName,<br \/>\n      descriptionString);<br \/>\n    sms-&gt;addSubsession(H264VideoFileServerMediaSubsession<br \/>\n       ::createNew(*env, inputFileName, False));<br \/>\n    rtspServer-&gt;addServerMediaSession(sms);<\/p>\n<p>    announceStream(rtspServer, sms, streamName, inputFileName);<br \/>\n  }<\/p>\n<p>  env-&gt;taskScheduler().doEventLoop(); \/\/ does not return<\/p>\n<p>  return 0; \/\/ only to prevent compiler warning<br \/>\n} <\/p>\n<p>  This program creates an RTSP server that streams a H.264 video file named \u201ctest.264\u201d. The server listens on port 554 or 8554 if 554 is not available. The video stream is named \u201ch264ESVideoTest\u201d. The server runs an event loop that does not return, waiting for and responding to RTSP requests.<br \/>\n  Please note that you need to replace &#034;test.264&#034; with the actual path to your H.264 video file. Also, this is a simplified example and does not include error handling and other necessary production-level code.<br \/>\n  You can find the full code and more examples in the Live555 GitHub repository. <\/p>\n<h3>3.3 \u4ee3\u7801\u793a\u4f8b\u4e0e\u89e3\u6790&#xff08;Code Examples and Analysis&#xff09;<\/h3>\n<p>\u5728\u8fd9\u4e00\u90e8\u5206&#xff0c;\u6211\u4eec\u5c06\u901a\u8fc7\u4e00\u4e2a\u5177\u4f53\u7684\u4ee3\u7801\u793a\u4f8b\u6765\u5c55\u793a\u5982\u4f55\u4f7f\u7528C&#043;&#043;\u548cLive555\u5e93\u6784\u5efaRTSP\u670d\u52a1\u5668\u3002\u6211\u4eec\u5c06\u8be6\u7ec6\u89e3\u6790\u6bcf\u4e00\u884c\u4ee3\u7801\u7684\u4f5c\u7528&#xff0c;\u4ee5\u5e2e\u52a9\u8bfb\u8005\u66f4\u597d\u5730\u7406\u89e3\u548c\u638c\u63e1\u8fd9\u4e00\u8fc7\u7a0b\u3002<\/p>\n<p>\u9996\u5148&#xff0c;\u6211\u4eec\u9700\u8981\u5305\u542b\u5fc5\u8981\u7684\u5934\u6587\u4ef6\u3002Live555\u5e93\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684\u5934\u6587\u4ef6&#xff0c;\u8fd9\u4e9b\u5934\u6587\u4ef6\u5b9a\u4e49\u4e86\u6211\u4eec\u5728\u6784\u5efaRTSP\u670d\u52a1\u5668\u65f6\u6240\u9700\u8981\u7684\u5404\u79cd\u7c7b\u548c\u51fd\u6570\u3002<\/p>\n<p>#include &#034;liveMedia.hh&#034;<br \/>\n#include &#034;BasicUsageEnvironment.hh&#034;<br \/>\n#include &#034;GroupsockHelper.hh&#034; <\/p>\n<p>\u63a5\u4e0b\u6765&#xff0c;\u6211\u4eec\u9700\u8981\u521b\u5efa\u4e00\u4e2aUsageEnvironment\u5b9e\u4f8b\u3002UsageEnvironment\u662fLive555\u5e93\u4e2d\u7684\u4e00\u4e2a\u6838\u5fc3\u7c7b&#xff0c;\u5b83\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684\u57fa\u7840\u8bbe\u65bd&#xff0c;\u5982\u65e5\u5fd7\u8bb0\u5f55\u3001\u9519\u8bef\u5904\u7406\u7b49\u3002<\/p>\n<p>TaskScheduler* scheduler &#061; BasicTaskScheduler::createNew();<br \/>\nUsageEnvironment* env &#061; BasicUsageEnvironment::createNew(*scheduler); <\/p>\n<p>\u7136\u540e&#xff0c;\u6211\u4eec\u9700\u8981\u521b\u5efa\u4e00\u4e2aRTSPServer\u5b9e\u4f8b\u3002RTSPServer\u662fLive555\u5e93\u4e2d\u7684\u4e00\u4e2a\u6838\u5fc3\u7c7b&#xff0c;\u5b83\u5c01\u88c5\u4e86RTSP\u670d\u52a1\u5668\u7684\u4e3b\u8981\u529f\u80fd\u3002<\/p>\n<p>RTSPServer* rtspServer &#061; RTSPServer::createNew(*env, 8554);<br \/>\nif (rtspServer &#061;&#061; NULL) {<br \/>\n  *env &lt;&lt; &#034;Failed to create RTSP server: &#034; &lt;&lt; env-&gt;getResultMsg() &lt;&lt; &#034;\\\\n&#034;;<br \/>\n  exit(1);<br \/>\n} <\/p>\n<p>\u5728\u521b\u5efaRTSPServer\u5b9e\u4f8b\u540e&#xff0c;\u6211\u4eec\u9700\u8981\u521b\u5efa\u4e00\u4e2aServerMediaSession\u5b9e\u4f8b&#xff0c;\u5e76\u5c06\u5176\u6dfb\u52a0\u5230RTSPServer\u4e2d\u3002ServerMediaSession\u4ee3\u8868\u4e86\u4e00\u4e2a\u5a92\u4f53\u4f1a\u8bdd&#xff0c;\u5b83\u53ef\u4ee5\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u5a92\u4f53\u6d41\u3002<\/p>\n<p>ServerMediaSession* sms &#061; ServerMediaSession::createNew(*env, &#034;testStream&#034;, &#034;testStream&#034;,<br \/>\n                             &#034;Session streamed by \\\\&#034;testRTSPServer\\\\&#034;&#034;,<br \/>\n                             True \/*SSM*\/);<br \/>\nrtspServer-&gt;addServerMediaSession(sms); <\/p>\n<p>\u6700\u540e&#xff0c;\u6211\u4eec\u9700\u8981\u542f\u52a8\u4e8b\u4ef6\u5faa\u73af&#xff0c;\u5f00\u59cb\u5904\u7406\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\u3002<\/p>\n<p>env-&gt;taskScheduler().doEventLoop(); \/\/ does not return <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4e00\u4e2a\u7b80\u5355\u7684RTSP\u670d\u52a1\u5668\u7684\u6784\u5efa\u8fc7\u7a0b\u3002\u901a\u8fc7\u8fd9\u4e2a\u8fc7\u7a0b&#xff0c;\u6211\u4eec\u53ef\u4ee5\u770b\u5230&#xff0c;\u4f7f\u7528C&#043;&#043;\u548cLive555\u5e93\u6784\u5efaRTSP\u670d\u52a1\u5668\u662f\u4e00\u4ef6\u76f8\u5bf9\u7b80\u5355\u7684\u4e8b\u60c5\u3002\u53ea\u9700\u8981\u7406\u89e3\u5e76\u638c\u63e1Live555\u5e93\u4e2d\u7684\u51e0\u4e2a\u6838\u5fc3\u7c7b\u548c\u51fd\u6570&#xff0c;\u5c31\u53ef\u4ee5\u8f7b\u677e\u5730\u6784\u5efa\u51fa\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684RTSP\u670d\u52a1\u5668\u3002<\/p>\n<p>\u8fd9\u662f\u4e00\u4e2a\u4f7f\u7528Live555\u5e93\u5b9e\u73b0\u7684RTSP\u670d\u52a1\u5668\u7684C&#043;&#043;\u793a\u4f8b\u4ee3\u7801\u3002<\/p>\n<p>#include &#034;liveMedia.hh&#034; \/\/ \u5f15\u5165liveMedia\u5e93<br \/>\n#include &#034;BasicUsageEnvironment.hh&#034; \/\/ \u5f15\u5165BasicUsageEnvironment\u5e93<br \/>\n#include &#034;GroupsockHelper.hh&#034; \/\/ \u5f15\u5165GroupsockHelper\u5e93<\/p>\n<p>UsageEnvironment* env; \/\/ \u5b9a\u4e49\u73af\u5883\u53d8\u91cf<\/p>\n<p>char const* inputFileName &#061; &#034;test.mp4&#034;; \/\/ \u5b9a\u4e49\u8f93\u5165\u6587\u4ef6\u540d<br \/>\nFramedSource* videoSource; \/\/ \u5b9a\u4e49\u89c6\u9891\u6e90<br \/>\nRTPSink* videoSink; \/\/ \u5b9a\u4e49RTP\u63a5\u6536\u5668<\/p>\n<p>void play(); \/\/ \u5b9a\u4e49\u64ad\u653e\u51fd\u6570<\/p>\n<p>int main(int argc, char** argv) { \/\/ \u4e3b\u51fd\u6570<br \/>\n  TaskScheduler* scheduler &#061; BasicTaskScheduler::createNew(); \/\/ \u521b\u5efa\u65b0\u7684\u4efb\u52a1\u8c03\u5ea6\u5668<br \/>\n  env &#061; BasicUsageEnvironment::createNew(*scheduler); \/\/ \u521b\u5efa\u65b0\u7684\u73af\u5883<\/p>\n<p>  \/\/ \u521b\u5efa\u8f93\u5165\u6587\u4ef6\u6e90<br \/>\n  videoSource &#061; ByteStreamFileSource::createNew(*env, inputFileName);<br \/>\n  if (videoSource &#061;&#061; NULL) {<br \/>\n    *env &lt;&lt; &#034;Unable to open file \\\\&#034;&#034; &lt;&lt; inputFileName<br \/>\n         &lt;&lt; &#034;\\\\&#034; as a byte-stream file source\\\\n&#034;;<br \/>\n    exit(1);<br \/>\n  }<\/p>\n<p>  Groupsock rtpGroupsock(*env, destinationAddress, rtpPortNum, ttl); \/\/ \u521b\u5efaRTP\u7ec4\u5957\u63a5\u5b57<br \/>\n  videoSink &#061; H264VideoRTPSink::createNew(*env, &amp;rtpGroupsock, 96); \/\/ \u521b\u5efa\u65b0\u7684H264\u89c6\u9891RTP\u63a5\u6536\u5668<\/p>\n<p>  \/\/ \u5f00\u59cb\u64ad\u653e<br \/>\n  *env &lt;&lt; &#034;Beginning to read from file&#8230;\\\\n&#034;;<br \/>\n  play();<\/p>\n<p>  env-&gt;taskScheduler().doEventLoop(); \/\/ \u8fdb\u5165\u4e8b\u4ef6\u5faa\u73af<br \/>\n  return 0; \/\/ \u8fd4\u56de0\u8868\u793a\u7a0b\u5e8f\u6b63\u5e38\u7ed3\u675f<br \/>\n}<\/p>\n<p>void afterPlaying(void* clientData) { \/\/ \u64ad\u653e\u7ed3\u675f\u540e\u7684\u56de\u8c03\u51fd\u6570<br \/>\n  *env &lt;&lt; &#034;&#8230;done reading from file\\\\n&#034;;<br \/>\n  videoSink-&gt;stopPlaying(); \/\/ \u505c\u6b62\u64ad\u653e<br \/>\n  Medium::close(videoSink); \/\/ \u5173\u95ed\u63a5\u6536\u5668<br \/>\n  Medium::close(videoSource); \/\/ \u5173\u95ed\u6e90<br \/>\n  exit(0); \/\/ \u9000\u51fa\u7a0b\u5e8f<br \/>\n}<\/p>\n<p>void play() { \/\/ \u64ad\u653e\u51fd\u6570<br \/>\n  videoSink-&gt;startPlaying(*videoSource, afterPlaying, videoSink); \/\/ \u5f00\u59cb\u64ad\u653e<br \/>\n} <\/p>\n<p>\u8fd9\u4e2a\u793a\u4f8b\u4e2d&#xff0c;\u9996\u5148\u521b\u5efa\u4e86\u4e00\u4e2a\u4efb\u52a1\u8c03\u5ea6\u5668\u548c\u73af\u5883&#xff0c;\u7136\u540e\u521b\u5efa\u4e86\u4e00\u4e2a\u8f93\u5165\u6587\u4ef6\u6e90\u3002\u63a5\u7740&#xff0c;\u521b\u5efa\u4e86\u4e00\u4e2aRTP\u7ec4\u5957\u63a5\u5b57\u548c\u4e00\u4e2aH264\u89c6\u9891RTP\u63a5\u6536\u5668\u3002\u6700\u540e&#xff0c;\u5f00\u59cb\u64ad\u653e\u89c6\u9891&#xff0c;\u5e76\u5728\u64ad\u653e\u7ed3\u675f\u540e\u5173\u95ed\u63a5\u6536\u5668\u548c\u6e90\u3002<\/p>\n<p>\u8fd9\u53ea\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b&#xff0c;\u5b9e\u9645\u7684RTSP\u670d\u52a1\u5668\u53ef\u80fd\u9700\u8981\u5904\u7406\u66f4\u591a\u7684\u590d\u6742\u60c5\u51b5&#xff0c;\u4f8b\u5982\u5904\u7406\u591a\u4e2a\u5ba2\u6237\u7aef\u7684\u8fde\u63a5&#xff0c;\u5904\u7406\u4e0d\u540c\u7684RTSP\u547d\u4ee4\u7b49\u7b49\u3002<\/p>\n<h3>\u56db\u3001YUV\u6570\u636e\u7684\u63d2\u5165\u4e0e\u5904\u7406<\/h3>\n<h3>4.1 YUV\u6570\u636e\u7684\u7406\u89e3<\/h3>\n<p>YUV&#xff08;\u4eae\u5ea6\u3001\u8272\u5ea6&#xff09;\u662f\u4e00\u79cd\u989c\u8272\u7f16\u7801\u65b9\u6cd5&#xff0c;\u5e7f\u6cdb\u5e94\u7528\u4e8e\u89c6\u9891\u7cfb\u7edf\u3002\u5728YUV\u4e2d&#xff0c;Y\u4ee3\u8868\u4eae\u5ea6&#xff08;Luminance&#xff09;&#xff0c;U\u548cV\u4ee3\u8868\u8272\u5ea6&#xff08;Chrominance&#xff09;\u3002YUV\u7f16\u7801\u7684\u4e3b\u8981\u601d\u60f3\u662f&#xff0c;\u4eba\u773c\u5bf9\u4eae\u5ea6\u4fe1\u606f\u7684\u654f\u611f\u5ea6\u8fdc\u9ad8\u4e8e\u8272\u5ea6\u4fe1\u606f&#xff0c;\u56e0\u6b64&#xff0c;\u901a\u8fc7\u5bf9\u8272\u5ea6\u4fe1\u606f\u8fdb\u884c\u964d\u91c7\u6837&#xff0c;\u53ef\u4ee5\u5728\u4fdd\u6301\u89c6\u89c9\u8d28\u91cf\u7684\u540c\u65f6&#xff0c;\u5b9e\u73b0\u6570\u636e\u538b\u7f29\u3002<\/p>\n<p>YUV\u683c\u5f0f\u7684\u6570\u636e\u901a\u5e38\u4ee5\u4e09\u79cd\u5f62\u5f0f\u5b58\u5728&#xff1a;planar\u3001interleaved\u548csemi-planar\u3002\u5728planar\u683c\u5f0f\u4e2d&#xff0c;Y\u3001U\u3001V\u4e09\u4e2a\u5206\u91cf\u5206\u522b\u5b58\u50a8&#xff1b;\u5728interleaved\u683c\u5f0f\u4e2d&#xff0c;Y\u3001U\u3001V\u4e09\u4e2a\u5206\u91cf\u4ea4\u9519\u5b58\u50a8&#xff1b;\u5728semi-planar\u683c\u5f0f\u4e2d&#xff0c;Y\u5206\u91cf\u5355\u72ec\u5b58\u50a8&#xff0c;U\u548cV\u5206\u91cf\u4ea4\u9519\u5b58\u50a8\u3002<\/p>\n<p>\u5728\u89c6\u9891\u7f16\u7801\u548c\u4f20\u8f93\u4e2d&#xff0c;YUV\u6570\u636e\u7684\u5904\u7406\u662f\u975e\u5e38\u5173\u952e\u7684\u4e00\u73af\u3002\u9996\u5148&#xff0c;\u6211\u4eec\u9700\u8981\u5c06RGB\u56fe\u50cf\u8f6c\u6362\u4e3aYUV\u683c\u5f0f\u3002\u7136\u540e&#xff0c;\u6211\u4eec\u53ef\u4ee5\u5bf9YUV\u6570\u636e\u8fdb\u884c\u5404\u79cd\u5904\u7406&#xff0c;\u5982\u964d\u91c7\u6837\u3001\u91cf\u5316\u7b49&#xff0c;\u4ee5\u5b9e\u73b0\u6570\u636e\u538b\u7f29\u3002\u6700\u540e&#xff0c;\u6211\u4eec\u9700\u8981\u5c06\u5904\u7406\u540e\u7684YUV\u6570\u636e\u63d2\u5165\u5230\u89c6\u9891\u6d41\u4e2d\u3002<\/p>\n<p>\u5728C&#043;&#043;\u4e2d&#xff0c;\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528OpenCV\u5e93\u6765\u5904\u7406YUV\u6570\u636e\u3002OpenCV\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u51fd\u6570&#xff0c;\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884cRGB\u548cYUV\u4e4b\u95f4\u7684\u8f6c\u6362&#xff0c;\u4ee5\u53caYUV\u6570\u636e\u7684\u5904\u7406\u3002\u4f8b\u5982&#xff0c;\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528cv::cvtColor\u51fd\u6570\u6765\u8fdb\u884c\u989c\u8272\u7a7a\u95f4\u7684\u8f6c\u6362\u3002<\/p>\n<p>\u5728Live555\u4e2d&#xff0c;\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528DeviceSource\u7c7b\u6765\u63d2\u5165YUV\u6570\u636e\u3002DeviceSource\u7c7b\u63d0\u4f9b\u4e86\u4e00\u4e2adoGetNextFrame\u51fd\u6570&#xff0c;\u6211\u4eec\u53ef\u4ee5\u5728\u8fd9\u4e2a\u51fd\u6570\u4e2d\u63d2\u5165\u6211\u4eec\u7684YUV\u6570\u636e\u3002\u5177\u4f53\u7684\u63d2\u5165\u65b9\u6cd5&#xff0c;\u6211\u4eec\u5c06\u5728\u4e0b\u4e00\u8282\u8fdb\u884c\u8be6\u7ec6\u4ecb\u7ecd\u3002<\/p>\n<p>\u603b\u7684\u6765\u8bf4&#xff0c;\u7406\u89e3YUV\u6570\u636e\u7684\u5904\u7406&#xff0c;\u662f\u5b9e\u73b0\u9ad8\u6548\u89c6\u9891\u7f16\u7801\u548c\u4f20\u8f93\u7684\u5173\u952e\u3002\u5728\u63a5\u4e0b\u6765\u7684\u7ae0\u8282\u4e2d&#xff0c;\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728C&#043;&#043;\u548cLive555\u4e2d\u5904\u7406YUV\u6570\u636e&#xff0c;\u4ee5\u53ca\u5982\u4f55\u89e3\u51b3\u4e00\u4e9b\u5e38\u89c1\u7684\u95ee\u9898\u3002<\/p>\n<h3>4.2 \u5982\u4f55\u63d2\u5165YUV\u6570\u636e<\/h3>\n<p>\u5728Live555\u5e93\u4e2d&#xff0c;\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7DeviceSource\u7c7b\u6765\u63d2\u5165YUV\u6570\u636e\u3002DeviceSource\u7c7b\u662fFramedSource\u7c7b\u7684\u4e00\u4e2a\u5b50\u7c7b&#xff0c;\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2adoGetNextFrame()\u65b9\u6cd5&#xff0c;\u6211\u4eec\u53ef\u4ee5\u5728\u8fd9\u4e2a\u65b9\u6cd5\u4e2d\u63d2\u5165\u6211\u4eec\u7684YUV\u6570\u636e\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b&#xff0c;\u5c55\u793a\u4e86\u5982\u4f55\u5728doGetNextFrame()\u65b9\u6cd5\u4e2d\u63d2\u5165YUV\u6570\u636e&#xff1a;<\/p>\n<p>void DeviceSource::doGetNextFrame() {<br \/>\n    \/\/ \u83b7\u53d6YUV\u6570\u636e<br \/>\n    unsigned char* yuvData &#061; getYUVData();<\/p>\n<p>    \/\/ \u68c0\u67e5\u662f\u5426\u6709\u8db3\u591f\u7684\u7a7a\u95f4\u6765\u5b58\u50a8YUV\u6570\u636e<br \/>\n    if (fMaxSize &lt; fFrameSize) {<br \/>\n        fNumTruncatedBytes &#061; fFrameSize &#8211; fMaxSize;<br \/>\n        fFrameSize &#061; fMaxSize;<br \/>\n    } else {<br \/>\n        fNumTruncatedBytes &#061; 0;<br \/>\n    }<\/p>\n<p>    \/\/ \u5c06YUV\u6570\u636e\u590d\u5236\u5230fTo<br \/>\n    memmove(fTo, yuvData, fFrameSize);<\/p>\n<p>    \/\/ \u5b8c\u6210\u83b7\u53d6\u5e27\u6570\u636e<br \/>\n    FramedSource::afterGetting(this);<br \/>\n} <\/p>\n<p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d&#xff0c;\u6211\u4eec\u9996\u5148\u83b7\u53d6YUV\u6570\u636e&#xff0c;\u7136\u540e\u68c0\u67e5\u662f\u5426\u6709\u8db3\u591f\u7684\u7a7a\u95f4\u6765\u5b58\u50a8\u8fd9\u4e9b\u6570\u636e\u3002\u5982\u679c\u6ca1\u6709\u8db3\u591f\u7684\u7a7a\u95f4&#xff0c;\u6211\u4eec\u5c06\u622a\u65ad\u4e00\u90e8\u5206\u6570\u636e\u3002\u7136\u540e&#xff0c;\u6211\u4eec\u5c06YUV\u6570\u636e\u590d\u5236\u5230fTo&#xff0c;\u8fd9\u662f\u4e00\u4e2a\u6307\u5411\u5b58\u50a8\u5e27\u6570\u636e\u7684\u7f13\u51b2\u533a\u7684\u6307\u9488\u3002\u6700\u540e&#xff0c;\u6211\u4eec\u8c03\u7528FramedSource::afterGetting(this)\u6765\u5b8c\u6210\u83b7\u53d6\u5e27\u6570\u636e\u3002<\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f&#xff0c;\u8fd9\u53ea\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b&#xff0c;\u5b9e\u9645\u7684\u4ee3\u7801\u53ef\u80fd\u4f1a\u66f4\u590d\u6742\u3002\u4f8b\u5982&#xff0c;\u4f60\u53ef\u80fd\u9700\u8981\u5904\u7406YUV\u6570\u636e\u7684\u683c\u5f0f\u8f6c\u6362&#xff0c;\u6216\u8005\u5904\u7406YUV\u6570\u636e\u7684\u964d\u91c7\u6837\u7b49\u95ee\u9898\u3002\u6b64\u5916&#xff0c;\u4f60\u8fd8\u9700\u8981\u786e\u4fdd\u4f60\u7684\u4ee3\u7801\u662f\u7ebf\u7a0b\u5b89\u5168\u7684&#xff0c;\u56e0\u4e3aLive555\u5e93\u662f\u591a\u7ebf\u7a0b\u7684\u3002<\/p>\n<p>  Here\u2019s a code snippet from the Live555 library that deals with YUV data: <\/p>\n<p>\/\/ &#034;liveMedia&#034; includes a software-only implementation of a H.264 video encoder:<br \/>\n\/\/ &#034;H264VideoStreamDiscreteFramer&#034;.  This can be used &#8211; along with the &#034;H264VideoStreamFramer&#034; and &#034;H264VideoRTPSink&#034; classes &#8211; to implement a RTSP server that streams H.264 video (in RTP format).  However, because this implementation is software-only (i.e., does not use hardware-accelerated encoding), it is too slow to be practical for most applications.<\/p>\n<p>\/\/ The input to the &#034;H264VideoStreamDiscreteFramer&#034; is a sequence of &#039;nal units&#039; (in Annex B format).  Each &#039;nal unit&#039; begins with the byte sequence 0x00000001, followed by the &#039;nal unit&#039; data.  (Note that &#039;nal units&#039; are *not* the same as &#039;frames&#039;; there can be multiple &#039;nal units&#039; per frame.)<\/p>\n<p>\/\/ To use this software-only implementation, you would need to provide your own code to generate these &#039;nal units&#039;.  Typically, this would involve:<br \/>\n\/\/ 1\/ Getting video data (e.g., from a camera).<br \/>\n\/\/ 2\/ Converting this video data to YUV format.<br \/>\n\/\/ 3\/ Calling the &#034;x264_encoder_encode()&#034; function (defined in &#034;x264.h&#034;) to encode this YUV data into a &#039;nal unit&#039;.<br \/>\n\/\/ 4\/ Calling &#034;H264VideoStreamDiscreteFramer::inputFrame()&#034; to deliver this &#039;nal unit&#039; to the &#034;H264VideoStreamDiscreteFramer&#034;. <\/p>\n<p>  This code snippet outlines the steps needed to process YUV data in the Live555 library. It involves getting video data, converting it to YUV format, encoding this YUV data into a \u2018nal unit\u2019 using the \u201cx264_encoder_encode()\u201d function, and then delivering this \u2018nal unit\u2019 to the \u201cH264VideoStreamDiscreteFramer\u201d using the \u201cinputFrame()\u201d function.<br \/>\n  Please note that this is a software-only implementation and does not use hardware-accelerated encoding, so it may be too slow for some applications.<br \/>\n  You can find this code in the Live555 GitHub repository. <\/p>\n<h3>4.3 YUV\u6570\u636e\u7684\u5904\u7406\u4e0e\u4f18\u5316&#xff08;Processing and Optimization of YUV Data&#xff09;<\/h3>\n<p>\u5728\u5b9e\u9645\u7684RTSP\u670d\u52a1\u5668\u5f00\u53d1\u4e2d&#xff0c;\u6211\u4eec\u4e0d\u4ec5\u9700\u8981\u6b63\u786e\u5730\u63d2\u5165YUV\u6570\u636e&#xff0c;\u66f4\u9700\u8981\u5bf9\u5176\u8fdb\u884c\u6709\u6548\u7684\u5904\u7406\u548c\u4f18\u5316&#xff0c;\u4ee5\u63d0\u9ad8\u89c6\u9891\u6d41\u7684\u8d28\u91cf\u548c\u4f20\u8f93\u6548\u7387\u3002\u4ee5\u4e0b\u5c06\u4ece\u51e0\u4e2a\u5173\u952e\u7684\u65b9\u9762\u8fdb\u884c\u6df1\u5165\u7684\u63a2\u8ba8\u3002<\/p>\n<p>\u9996\u5148&#xff0c;\u6211\u4eec\u9700\u8981\u7406\u89e3YUV\u6570\u636e\u7684\u7279\u6027\u3002YUV\u662f\u4e00\u79cd\u989c\u8272\u7f16\u7801\u65b9\u6cd5&#xff0c;\u5b83\u5c06\u56fe\u50cf\u7684\u4eae\u5ea6\u4fe1\u606f&#xff08;Y&#xff09;\u548c\u8272\u5ea6\u4fe1\u606f&#xff08;UV&#xff09;\u5206\u5f00\u5904\u7406\u3002\u8fd9\u79cd\u8bbe\u8ba1\u7684\u4f18\u70b9\u662f\u53ef\u4ee5\u6839\u636e\u4eba\u773c\u5bf9\u4eae\u5ea6\u548c\u8272\u5ea6\u4fe1\u606f\u7684\u654f\u611f\u5ea6\u8fdb\u884c\u4f18\u5316&#xff0c;\u4ece\u800c\u63d0\u9ad8\u56fe\u50cf\u7684\u89c6\u89c9\u8d28\u91cf\u3002\u5728\u5904\u7406YUV\u6570\u636e\u65f6&#xff0c;\u6211\u4eec\u9700\u8981\u8003\u8651\u8fd9\u4e9b\u7279\u6027&#xff0c;\u4ee5\u4fbf\u66f4\u597d\u5730\u4f18\u5316\u89c6\u9891\u6d41\u3002<\/p>\n<p>\u5176\u6b21&#xff0c;\u6211\u4eec\u9700\u8981\u8003\u8651YUV\u6570\u636e\u7684\u683c\u5f0f\u3002YUV\u6570\u636e\u6709\u591a\u79cd\u683c\u5f0f&#xff0c;\u5982YUV420\u3001YUV422\u3001YUV444\u7b49&#xff0c;\u8fd9\u4e9b\u683c\u5f0f\u4e3b\u8981\u533a\u522b\u5728\u4e8e\u8272\u5ea6\u4fe1\u606f\u7684\u91c7\u6837\u7387\u3002\u5728\u9009\u62e9YUV\u683c\u5f0f\u65f6&#xff0c;\u6211\u4eec\u9700\u8981\u6839\u636e\u5b9e\u9645\u7684\u9700\u6c42\u548c\u9650\u5236\u8fdb\u884c\u9009\u62e9\u3002\u4f8b\u5982&#xff0c;\u5982\u679c\u6211\u4eec\u7684\u7f51\u7edc\u5e26\u5bbd\u6709\u9650&#xff0c;\u6211\u4eec\u53ef\u80fd\u4f1a\u9009\u62e9YUV420&#xff0c;\u56e0\u4e3a\u5b83\u7684\u8272\u5ea6\u4fe1\u606f\u91c7\u6837\u7387\u8f83\u4f4e&#xff0c;\u53ef\u4ee5\u51cf\u5c11\u6570\u636e\u91cf\u3002\u4f46\u662f&#xff0c;\u8fd9\u4e5f\u53ef\u80fd\u4f1a\u964d\u4f4e\u56fe\u50cf\u7684\u8272\u5f69\u8d28\u91cf\u3002\u56e0\u6b64&#xff0c;\u6211\u4eec\u9700\u8981\u5728\u6570\u636e\u91cf\u548c\u56fe\u50cf\u8d28\u91cf\u4e4b\u95f4\u627e\u5230\u4e00\u4e2a\u5e73\u8861\u3002<\/p>\n<p>\u518d\u6b21&#xff0c;\u6211\u4eec\u9700\u8981\u8003\u8651YUV\u6570\u636e\u7684\u8f6c\u6362\u3002\u5728\u5b9e\u9645\u7684\u5e94\u7528\u4e2d&#xff0c;\u6211\u4eec\u53ef\u80fd\u9700\u8981\u5c06YUV\u6570\u636e\u8f6c\u6362\u4e3a\u5176\u4ed6\u683c\u5f0f&#xff0c;\u5982RGB\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u9700\u8981\u4e00\u4e9b\u6570\u5b66\u8fd0\u7b97&#xff0c;\u6211\u4eec\u9700\u8981\u786e\u4fdd\u8fd9\u4e9b\u8fd0\u7b97\u7684\u6b63\u786e\u6027\u548c\u6548\u7387\u3002\u6b64\u5916&#xff0c;\u6211\u4eec\u8fd8\u9700\u8981\u8003\u8651\u5982\u4f55\u5904\u7406\u8f6c\u6362\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u51fa\u73b0\u7684\u95ee\u9898&#xff0c;\u5982\u989c\u8272\u5931\u771f\u3001\u8fb9\u7f18\u952f\u9f7f\u7b49\u3002<\/p>\n<p>\u6700\u540e&#xff0c;\u6211\u4eec\u9700\u8981\u8003\u8651YUV\u6570\u636e\u7684\u538b\u7f29\u3002\u5728\u89c6\u9891\u6d41\u4f20\u8f93\u4e2d&#xff0c;\u6570\u636e\u538b\u7f29\u662f\u975e\u5e38\u91cd\u8981\u7684&#xff0c;\u5b83\u53ef\u4ee5\u5927\u5927\u51cf\u5c11\u6570\u636e\u91cf&#xff0c;\u63d0\u9ad8\u4f20\u8f93\u6548\u7387\u3002\u4f46\u662f&#xff0c;\u6570\u636e\u538b\u7f29\u4e5f\u53ef\u80fd\u4f1a\u964d\u4f4e\u56fe\u50cf\u8d28\u91cf\u3002\u56e0\u6b64&#xff0c;\u6211\u4eec\u9700\u8981\u9009\u62e9\u5408\u9002\u7684\u538b\u7f29\u7b97\u6cd5&#xff0c;\u5e76\u5bf9\u5176\u8fdb\u884c\u4f18\u5316&#xff0c;\u4ee5\u8fbe\u5230\u6700\u4f73\u7684\u538b\u7f29\u6548\u679c\u3002<\/p>\n<p>\u603b\u7684\u6765\u8bf4&#xff0c;\u5904\u7406\u548c\u4f18\u5316YUV\u6570\u636e\u662f\u4e00\u4e2a\u590d\u6742\u7684\u8fc7\u7a0b&#xff0c;\u5b83\u6d89\u53ca\u5230\u8bb8\u591a\u56e0\u7d20\u548c\u6280\u672f\u3002\u6211\u4eec\u9700\u8981\u6df1\u5165\u7406\u89e3YUV\u6570\u636e\u7684\u7279\u6027&#xff0c;\u638c\u63e1\u76f8\u5173\u7684\u6280\u672f\u548c\u65b9\u6cd5&#xff0c;\u624d\u80fd\u6709\u6548\u5730\u5904\u7406\u548c\u4f18\u5316YUV\u6570\u636e&#xff0c;\u63d0\u9ad8RTSP\u670d\u52a1\u5668\u7684\u6027\u80fd\u548c\u8d28\u91cf\u3002<\/p>\n<h3>\u4e94\u3001I\u5e27\u4e0eP\u5e27\u7684\u987a\u5e8f\u95ee\u9898&#xff08;Order of I-frames and P-frames&#xff09;<\/h3>\n<h3>5.1 I\u5e27\u4e0eP\u5e27\u7684\u57fa\u672c\u7406\u89e3&#xff08;Basic Understanding of I-frames and P-frames&#xff09;<\/h3>\n<p>\u5728\u89c6\u9891\u7f16\u7801\u4e2d&#xff0c;I\u5e27&#xff08;Intra-coded Picture&#xff09;\u548cP\u5e27&#xff08;Predicted Picture&#xff09;\u662f\u4e24\u79cd\u5173\u952e\u7684\u5e27\u7c7b\u578b\u3002\u5b83\u4eec\u5728\u89c6\u9891\u6d41\u4e2d\u8d77\u7740\u81f3\u5173\u91cd\u8981\u7684\u4f5c\u7528&#xff0c;\u7406\u89e3\u5b83\u4eec\u7684\u7279\u6027\u548c\u529f\u80fd\u5bf9\u4e8e\u6df1\u5165\u638c\u63e1\u89c6\u9891\u7f16\u7801\u548c\u89e3\u7801\u6280\u672f\u975e\u5e38\u91cd\u8981\u3002<\/p>\n<p>I\u5e27&#xff0c;\u4e5f\u88ab\u79f0\u4e3a\u5173\u952e\u5e27&#xff08;Key Frame&#xff09;&#xff0c;\u662f\u89c6\u9891\u7f16\u7801\u4e2d\u7684\u4e00\u4e2a\u5b8c\u6574\u7684\u56fe\u50cf\u5e27\u3002\u5b83\u662f\u81ea\u6211\u5b8c\u6574\u7684&#xff0c;\u4e0d\u4f9d\u8d56\u4e8e\u5176\u4ed6\u5e27\u5c31\u53ef\u4ee5\u5b8c\u5168\u89e3\u7801\u3002I\u5e27\u901a\u5e38\u6bd4\u5176\u4ed6\u7c7b\u578b\u7684\u5e27\u8981\u5927&#xff0c;\u56e0\u4e3a\u5b83\u5305\u542b\u4e86\u4e00\u4e2a\u5b8c\u6574\u7684\u56fe\u50cf\u4fe1\u606f\u3002\u5728\u89c6\u9891\u6d41\u4e2d&#xff0c;I\u5e27\u662f\u5176\u4ed6\u5e27&#xff08;\u5982P\u5e27\u548cB\u5e27&#xff09;\u7684\u53c2\u8003\u5e27&#xff0c;\u5b83\u4eec\u7684\u5b58\u5728\u4f7f\u5f97\u89c6\u9891\u53ef\u4ee5\u8fdb\u884c\u968f\u673a\u8bbf\u95ee&#xff0c;\u4e5f\u5c31\u662f\u8bf4&#xff0c;\u53ea\u6709\u5728I\u5e27\u7684\u57fa\u7840\u4e0a&#xff0c;\u6211\u4eec\u624d\u80fd\u51c6\u786e\u5730\u8df3\u8f6c\u5230\u89c6\u9891\u7684\u4efb\u4f55\u4f4d\u7f6e\u3002<\/p>\n<p>P\u5e27&#xff0c;\u4e5f\u88ab\u79f0\u4e3a\u9884\u6d4b\u5e27&#xff0c;\u5b83\u4e0d\u662f\u4e00\u4e2a\u5b8c\u6574\u7684\u56fe\u50cf\u5e27&#xff0c;\u800c\u662f\u57fa\u4e8e\u524d\u4e00\u4e2aI\u5e27\u6216P\u5e27\u7684\u5dee\u5f02\u4fe1\u606f\u3002\u4e0eI\u5e27\u76f8\u6bd4&#xff0c;P\u5e27\u7684\u6570\u636e\u91cf\u8981\u5c0f\u5f97\u591a&#xff0c;\u56e0\u4e3a\u5b83\u53ea\u5305\u542b\u4e86\u4e0e\u524d\u4e00\u5e27\u7684\u5dee\u5f02\u4fe1\u606f&#xff0c;\u800c\u4e0d\u662f\u5b8c\u6574\u7684\u56fe\u50cf\u4fe1\u606f\u3002P\u5e27\u7684\u5b58\u5728\u4f7f\u5f97\u89c6\u9891\u6d41\u53ef\u4ee5\u5927\u5927\u51cf\u5c0f&#xff0c;\u4ece\u800c\u8282\u7701\u4e86\u5b58\u50a8\u548c\u4f20\u8f93\u7684\u5e26\u5bbd\u3002<\/p>\n<p>\u5728\u89c6\u9891\u7f16\u7801\u4e2d&#xff0c;I\u5e27\u548cP\u5e27\u7684\u987a\u5e8f\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u4e00\u822c\u6765\u8bf4&#xff0c;\u89c6\u9891\u6d41\u5f00\u59cb\u7684\u4f4d\u7f6e\u662f\u4e00\u4e2aI\u5e27&#xff0c;\u7136\u540e\u662f\u4e00\u7cfb\u5217\u7684P\u5e27\u3002\u8fd9\u79cd\u987a\u5e8f\u7684\u5b58\u5728&#xff0c;\u4f7f\u5f97\u89c6\u9891\u53ef\u4ee5\u4eceI\u5e27\u5f00\u59cb\u8fdb\u884c\u89e3\u7801&#xff0c;\u7136\u540e\u6839\u636eP\u5e27\u7684\u5dee\u5f02\u4fe1\u606f\u9010\u5e27\u89e3\u7801&#xff0c;\u4ece\u800c\u91cd\u5efa\u51fa\u5b8c\u6574\u7684\u89c6\u9891\u5e8f\u5217\u3002<\/p>\n<p>\u7136\u800c&#xff0c;\u5982\u679cI\u5e27\u548cP\u5e27\u7684\u987a\u5e8f\u51fa\u73b0\u9519\u8bef&#xff0c;\u90a3\u4e48\u53ef\u80fd\u4f1a\u5bfc\u81f4\u89c6\u9891\u7684\u89e3\u7801\u51fa\u73b0\u95ee\u9898\u3002\u4f8b\u5982&#xff0c;\u5982\u679c\u4e00\u4e2aP\u5e27\u7684\u53c2\u8003\u5e27&#xff08;\u5373\u524d\u4e00\u4e2aI\u5e27\u6216P\u5e27&#xff09;\u4e22\u5931\u6216\u9519\u8bef&#xff0c;\u90a3\u4e48\u8fd9\u4e2aP\u5e27\u5c31\u65e0\u6cd5\u6b63\u786e\u89e3\u7801&#xff0c;\u4ece\u800c\u53ef\u80fd\u5bfc\u81f4\u89c6\u9891\u51fa\u73b0\u4e71\u7801\u6216\u8005\u64ad\u653e\u4e0d\u987a\u7545\u7684\u95ee\u9898\u3002<\/p>\n<p>\u56e0\u6b64&#xff0c;\u6b63\u786e\u5730\u63a7\u5236I\u5e27\u548cP\u5e27\u7684\u987a\u5e8f&#xff0c;\u662f\u4fdd\u8bc1\u89c6\u9891\u8d28\u91cf\u7684\u4e00\u4e2a\u91cd\u8981\u56e0\u7d20\u3002\u5728\u5b9e\u9645\u7684\u7f16\u7a0b\u4e2d&#xff0c;\u6211\u4eec\u9700\u8981\u6df1\u5165\u7406\u89e3I\u5e27\u548cP\u5e27\u7684\u7279\u6027&#xff0c;\u4ee5\u53ca\u5b83\u4eec\u5728\u89c6\u9891\u7f16\u7801\u4e2d\u7684\u4f5c\u7528&#xff0c;\u624d\u80fd\u66f4\u597d\u5730\u63a7\u5236\u89c6\u9891\u7684\u7f16\u7801\u548c\u89e3\u7801\u8fc7\u7a0b\u3002<\/p>\n<p>\u5728\u5b9e\u9645\u7684\u7f16\u7a0b\u5b9e\u8df5\u4e2d&#xff0c;\u6211\u4eec\u901a\u5e38\u4f1a\u4f7f\u7528\u4e00\u79cd\u79f0\u4e3aGOP&#xff08;Group of Pictures&#xff09;\u7684\u7ed3\u6784\u6765\u63a7\u5236I\u5e27\u548cP\u5e27\u7684\u987a\u5e8f\u3002\u4e00\u4e2aGOP\u662f\u7531\u4e00\u4e2aI\u5e27\u548c\u968f\u540e\u7684\u4e00\u7cfb\u5217P\u5e27\u7ec4\u6210\u7684&#xff0c;\u5b83\u4ee3\u8868\u4e86\u4e00\u4e2a\u5b8c\u6574\u7684\u89c6\u9891\u5e8f\u5217\u3002\u5728\u4e00\u4e2aGOP\u4e2d&#xff0c;I\u5e27\u662f\u9996\u5e27&#xff0c;\u7136\u540e\u662f\u4e00\u7cfb\u5217\u7684P\u5e27\u3002\u8fd9\u79cd\u7ed3\u6784\u4f7f\u5f97\u6211\u4eec\u53ef\u4ee5\u5728\u6bcf\u4e2aGOP\u5f00\u59cb\u7684\u4f4d\u7f6e\u63d2\u5165\u4e00\u4e2aI\u5e27&#xff0c;\u7136\u540e\u6839\u636e\u89c6\u9891\u7684\u53d8\u5316\u60c5\u51b5\u63d2\u5165P\u5e27&#xff0c;\u4ece\u800c\u4fdd\u8bc1\u4e86I\u5e27\u548cP\u5e27\u7684\u6b63\u786e\u987a\u5e8f\u3002<\/p>\n<p>\u5728\u5b9e\u9645\u7684\u7f16\u7a0b\u5b9e\u8df5\u4e2d&#xff0c;\u6211\u4eec\u8fd8\u9700\u8981\u6ce8\u610fI\u5e27\u548cP\u5e27\u7684\u6570\u91cf\u548c\u6bd4\u4f8b\u3002\u4e00\u822c\u6765\u8bf4&#xff0c;I\u5e27\u7684\u6570\u91cf\u5e94\u8be5\u5c3d\u53ef\u80fd\u5c11&#xff0c;\u56e0\u4e3aI\u5e27\u7684\u6570\u636e\u91cf\u5927&#xff0c;\u4f1a\u5360\u7528\u66f4\u591a\u7684\u5b58\u50a8\u548c\u4f20\u8f93\u5e26\u5bbd\u3002\u800cP\u5e27\u7684\u6570\u91cf\u5e94\u8be5\u5c3d\u53ef\u80fd\u591a&#xff0c;\u56e0\u4e3aP\u5e27\u7684\u6570\u636e\u91cf\u5c0f&#xff0c;\u53ef\u4ee5\u6709\u6548\u5730\u51cf\u5c0f\u89c6\u9891\u6d41\u7684\u5927\u5c0f\u3002\u7136\u800c&#xff0c;\u5982\u679cP\u5e27\u7684\u6570\u91cf\u8fc7\u591a&#xff0c;\u90a3\u4e48\u53ef\u80fd\u4f1a\u5bfc\u81f4\u89c6\u9891\u7684\u8d28\u91cf\u4e0b\u964d&#xff0c;\u56e0\u4e3aP\u5e27\u662f\u57fa\u4e8e\u524d\u4e00\u5e27\u7684\u5dee\u5f02\u4fe1\u606f&#xff0c;\u5982\u679c\u5dee\u5f02\u4fe1\u606f\u8fc7\u591a&#xff0c;\u90a3\u4e48\u53ef\u80fd\u4f1a\u5bfc\u81f4\u89c6\u9891\u7684\u8d28\u91cf\u4e0b\u964d\u3002<\/p>\n<p>\u603b\u7684\u6765\u8bf4&#xff0c;\u7406\u89e3\u548c\u638c\u63e1I\u5e27\u548cP\u5e27\u7684\u7279\u6027&#xff0c;\u4ee5\u53ca\u5b83\u4eec\u5728\u89c6\u9891\u7f16\u7801\u4e2d\u7684\u4f5c\u7528&#xff0c;\u662f\u6211\u4eec\u8fdb\u884c\u89c6\u9891\u7f16\u7a0b\u7684\u4e00\u4e2a\u91cd\u8981\u57fa\u7840\u3002\u53ea\u6709\u6df1\u5165\u7406\u89e3\u8fd9\u4e9b\u57fa\u672c\u6982\u5ff5&#xff0c;\u6211\u4eec\u624d\u80fd\u66f4\u597d\u5730\u63a7\u5236\u89c6\u9891\u7684\u7f16\u7801\u548c\u89e3\u7801\u8fc7\u7a0b&#xff0c;\u4ece\u800c\u5b9e\u73b0\u9ad8\u8d28\u91cf\u7684\u89c6\u9891\u64ad\u653e\u3002<\/p>\n<h3>5.2 I\u5e27\u4e0eP\u5e27\u7684\u987a\u5e8f\u5bf9\u89c6\u9891\u8d28\u91cf\u7684\u5f71\u54cd&#xff08;Impact of I-frame and P-frame Order on Video Quality&#xff09;<\/h3>\n<p>I\u5e27\u548cP\u5e27\u7684\u987a\u5e8f\u5bf9\u89c6\u9891\u8d28\u91cf\u7684\u5f71\u54cd\u662f\u663e\u8457\u7684\u3002\u9996\u5148&#xff0c;\u6211\u4eec\u9700\u8981\u7406\u89e3&#xff0c;I\u5e27\u662f\u5b8c\u6574\u7684\u56fe\u50cf\u5e27&#xff0c;\u800cP\u5e27\u662f\u57fa\u4e8e\u524d\u4e00\u5e27\u7684\u5dee\u5f02\u4fe1\u606f\u3002\u56e0\u6b64&#xff0c;\u5982\u679cI\u5e27\u548cP\u5e27\u7684\u987a\u5e8f\u51fa\u73b0\u9519\u8bef&#xff0c;\u53ef\u80fd\u4f1a\u5bfc\u81f4\u89c6\u9891\u8d28\u91cf\u4e0b\u964d\u3002<\/p>\n<p>\u5728\u4e00\u4e2a\u6b63\u5e38\u7684\u89c6\u9891\u6d41\u4e2d&#xff0c;I\u5e27\u662f\u9996\u5e27&#xff0c;\u7136\u540e\u662f\u4e00\u7cfb\u5217\u7684P\u5e27\u3002\u8fd9\u79cd\u987a\u5e8f\u7684\u5b58\u5728&#xff0c;\u4f7f\u5f97\u89c6\u9891\u53ef\u4ee5\u4eceI\u5e27\u5f00\u59cb\u8fdb\u884c\u89e3\u7801&#xff0c;\u7136\u540e\u6839\u636eP\u5e27\u7684\u5dee\u5f02\u4fe1\u606f\u9010\u5e27\u89e3\u7801&#xff0c;\u4ece\u800c\u91cd\u5efa\u51fa\u5b8c\u6574\u7684\u89c6\u9891\u5e8f\u5217\u3002\u5982\u679c\u8fd9\u4e2a\u987a\u5e8f\u88ab\u6253\u4e71&#xff0c;\u4f8b\u5982&#xff0c;\u4e00\u4e2aP\u5e27\u7684\u53c2\u8003\u5e27&#xff08;\u5373\u524d\u4e00\u4e2aI\u5e27\u6216P\u5e27&#xff09;\u4e22\u5931\u6216\u9519\u8bef&#xff0c;\u90a3\u4e48\u8fd9\u4e2aP\u5e27\u5c31\u65e0\u6cd5\u6b63\u786e\u89e3\u7801&#xff0c;\u4ece\u800c\u53ef\u80fd\u5bfc\u81f4\u89c6\u9891\u51fa\u73b0\u4e71\u7801\u6216\u8005\u64ad\u653e\u4e0d\u987a\u7545\u7684\u95ee\u9898\u3002<\/p>\n<p>\u6b64\u5916&#xff0c;I\u5e27\u548cP\u5e27\u7684\u987a\u5e8f\u4e5f\u4f1a\u5f71\u54cd\u89c6\u9891\u7684\u64ad\u653e\u6027\u80fd\u3002\u7531\u4e8eI\u5e27\u662f\u5b8c\u6574\u7684\u56fe\u50cf\u5e27&#xff0c;\u5176\u6570\u636e\u91cf\u6bd4P\u5e27\u5927&#xff0c;\u56e0\u6b64&#xff0c;\u5982\u679cI\u5e27\u7684\u6570\u91cf\u8fc7\u591a&#xff0c;\u53ef\u80fd\u4f1a\u5bfc\u81f4\u89c6\u9891\u6d41\u7684\u5927\u5c0f\u589e\u52a0&#xff0c;\u4ece\u800c\u589e\u52a0\u4e86\u5b58\u50a8\u548c\u4f20\u8f93\u7684\u8d1f\u62c5\u3002\u76f8\u53cd&#xff0c;\u5982\u679cP\u5e27\u7684\u6570\u91cf\u8fc7\u591a&#xff0c;\u7531\u4e8eP\u5e27\u662f\u57fa\u4e8e\u524d\u4e00\u5e27\u7684\u5dee\u5f02\u4fe1\u606f&#xff0c;\u5982\u679c\u5dee\u5f02\u4fe1\u606f\u8fc7\u591a&#xff0c;\u53ef\u80fd\u4f1a\u5bfc\u81f4\u89c6\u9891\u7684\u8d28\u91cf\u4e0b\u964d\u3002<\/p>\n<p>\u56e0\u6b64&#xff0c;\u6b63\u786e\u5730\u63a7\u5236I\u5e27\u548cP\u5e27\u7684\u987a\u5e8f&#xff0c;\u662f\u4fdd\u8bc1\u89c6\u9891\u8d28\u91cf\u7684\u4e00\u4e2a\u91cd\u8981\u56e0\u7d20\u3002\u5728\u5b9e\u9645\u7684\u7f16\u7a0b\u4e2d&#xff0c;\u6211\u4eec\u9700\u8981\u6df1\u5165\u7406\u89e3I\u5e27\u548cP\u5e27\u7684\u7279\u6027&#xff0c;\u4ee5\u53ca\u5b83\u4eec\u5728\u89c6\u9891\u7f16\u7801\u4e2d\u7684\u4f5c\u7528&#xff0c;\u624d\u80fd\u66f4\u597d\u5730\u63a7\u5236\u89c6\u9891\u7684\u7f16\u7801\u548c\u89e3\u7801\u8fc7\u7a0b&#xff0c;\u4ece\u800c\u5b9e\u73b0\u9ad8\u8d28\u91cf\u7684\u89c6\u9891\u64ad\u653e\u3002<\/p>\n<h3>5.3 \u89e3\u51b3I\u5e27\u4e0eP\u5e27\u987a\u5e8f\u95ee\u9898\u7684\u7b56\u7565&#xff08;Strategies to Solve the Order Problem of I-frames and P-frames&#xff09;<\/h3>\n<p>\u89e3\u51b3I\u5e27\u4e0eP\u5e27\u987a\u5e8f\u95ee\u9898\u7684\u7b56\u7565\u4e3b\u8981\u6d89\u53ca\u5230\u7f16\u7801\u7b56\u7565\u548c\u89e3\u7801\u7b56\u7565\u4e24\u4e2a\u65b9\u9762\u3002<\/p>\n<h4>\u7f16\u7801\u7b56\u7565&#xff1a;<\/h4>\n<li>\u5408\u7406\u8bbe\u7f6eGOP&#xff08;Group of Pictures&#xff09;\u7ed3\u6784&#xff1a;\u5728\u7f16\u7801\u8fc7\u7a0b\u4e2d&#xff0c;\u6211\u4eec\u901a\u5e38\u4f1a\u4f7f\u7528GOP\u7ed3\u6784\u6765\u63a7\u5236I\u5e27\u548cP\u5e27\u7684\u987a\u5e8f\u3002\u4e00\u4e2aGOP\u7531\u4e00\u4e2aI\u5e27\u548c\u968f\u540e\u7684\u4e00\u7cfb\u5217P\u5e27\u7ec4\u6210\u3002\u5728\u8bbe\u7f6eGOP\u7ed3\u6784\u65f6&#xff0c;\u9700\u8981\u8003\u8651\u5230\u89c6\u9891\u7684\u5185\u5bb9\u7279\u6027&#xff0c;\u4f8b\u5982&#xff0c;\u5982\u679c\u89c6\u9891\u5185\u5bb9\u53d8\u5316\u8f83\u5927&#xff0c;\u53ef\u80fd\u9700\u8981\u66f4\u9891\u7e41\u5730\u63d2\u5165I\u5e27\u3002<\/li>\n<li>\u52a8\u6001\u8c03\u6574I\u5e27\u548cP\u5e27\u7684\u6bd4\u4f8b&#xff1a;\u5728\u7f16\u7801\u8fc7\u7a0b\u4e2d&#xff0c;\u53ef\u4ee5\u6839\u636e\u89c6\u9891\u5185\u5bb9\u7684\u53d8\u5316\u52a8\u6001\u8c03\u6574I\u5e27\u548cP\u5e27\u7684\u6bd4\u4f8b\u3002\u4f8b\u5982&#xff0c;\u5982\u679c\u89c6\u9891\u5185\u5bb9\u53d8\u5316\u8f83\u5927&#xff0c;\u53ef\u4ee5\u589e\u52a0I\u5e27\u7684\u6bd4\u4f8b&#xff1b;\u5982\u679c\u89c6\u9891\u5185\u5bb9\u53d8\u5316\u8f83\u5c0f&#xff0c;\u53ef\u4ee5\u589e\u52a0P\u5e27\u7684\u6bd4\u4f8b\u3002<\/li>\n<h4>\u89e3\u7801\u7b56\u7565&#xff1a;<\/h4>\n<li>\u9519\u8bef\u6062\u590d\u673a\u5236&#xff1a;\u5728\u89e3\u7801\u8fc7\u7a0b\u4e2d&#xff0c;\u5982\u679c\u53d1\u73b0I\u5e27\u6216P\u5e27\u4e22\u5931\u6216\u9519\u8bef&#xff0c;\u53ef\u4ee5\u91c7\u7528\u4e00\u4e9b\u9519\u8bef\u6062\u590d\u673a\u5236&#xff0c;\u4f8b\u5982&#xff0c;\u4f7f\u7528\u524d\u4e00\u5e27\u6216\u540e\u4e00\u5e27\u6765\u66ff\u4ee3\u4e22\u5931\u6216\u9519\u8bef\u7684\u5e27&#xff0c;\u6216\u8005\u4f7f\u7528\u63d2\u503c\u7b49\u65b9\u6cd5\u8fdb\u884c\u6062\u590d\u3002<\/li>\n<li>\u7f13\u51b2\u533a\u7ba1\u7406&#xff1a;\u5728\u89e3\u7801\u8fc7\u7a0b\u4e2d&#xff0c;\u53ef\u4ee5\u901a\u8fc7\u5408\u7406\u7ba1\u7406\u7f13\u51b2\u533a\u6765\u907f\u514dI\u5e27\u548cP\u5e27\u7684\u987a\u5e8f\u95ee\u9898\u3002\u4f8b\u5982&#xff0c;\u53ef\u4ee5\u8bbe\u7f6e\u4e00\u4e2a\u8db3\u591f\u5927\u7684\u7f13\u51b2\u533a&#xff0c;\u4ee5\u786e\u4fdd\u6240\u6709\u7684I\u5e27\u548cP\u5e27\u90fd\u80fd\u88ab\u6b63\u786e\u5730\u5b58\u50a8\u548c\u5904\u7406\u3002<\/li>\n<p>\u603b\u7684\u6765\u8bf4&#xff0c;\u89e3\u51b3I\u5e27\u4e0eP\u5e27\u987a\u5e8f\u95ee\u9898\u9700\u8981\u4ece\u7f16\u7801\u548c\u89e3\u7801\u4e24\u4e2a\u65b9\u9762\u8fdb\u884c\u8003\u8651&#xff0c;\u901a\u8fc7\u5408\u7406\u7684\u7b56\u7565\u548c\u6280\u672f&#xff0c;\u53ef\u4ee5\u6709\u6548\u5730\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898&#xff0c;\u4ece\u800c\u4fdd\u8bc1\u89c6\u9891\u7684\u8d28\u91cf\u548c\u64ad\u653e\u6027\u80fd\u3002<\/p>\n<h3>\u516d\u3001GOP\u56fe\u50cf\u7ec4\u7684\u7406\u89e3\u4e0e\u5e94\u7528&#xff08;Understanding and Application of GOP&#xff09;<\/h3>\n<h3>6.1 GOP\u56fe\u50cf\u7ec4\u7684\u57fa\u672c\u6982\u5ff5&#xff08;Basic Concept of GOP&#xff09;<\/h3>\n<p>GOP&#xff08;Group of Pictures&#xff09;\u56fe\u50cf\u7ec4\u662f\u89c6\u9891\u538b\u7f29\u7f16\u7801\u4e2d\u7684\u4e00\u4e2a\u91cd\u8981\u6982\u5ff5\u3002\u5728MPEG\u89c6\u9891\u7f16\u7801\u6807\u51c6\u4e2d&#xff0c;GOP\u662f\u7531\u8fde\u7eed\u7684\u89c6\u9891\u5e27\u7ec4\u6210\u7684\u5e8f\u5217&#xff0c;\u8fd9\u4e9b\u5e27\u5305\u62ecI\u5e27\u3001P\u5e27\u548cB\u5e27\u3002<\/p>\n<ul>\n<li>I\u5e27&#xff08;Intra-coded Picture&#xff09;&#xff1a;\u4e5f\u79f0\u4e3a\u5173\u952e\u5e27&#xff0c;\u662f\u81ea\u6211\u5b8c\u6574\u7684\u5e27&#xff0c;\u4e0d\u4f9d\u8d56\u4e8e\u5176\u4ed6\u4efb\u4f55\u5e27\u8fdb\u884c\u89e3\u7801\u3002I\u5e27\u5728\u89c6\u9891\u4e2d\u8d77\u5230\u4e86\u5173\u952e\u7684\u4f5c\u7528&#xff0c;\u5b83\u662f\u6bcf\u4e2aGOP\u7684\u7b2c\u4e00\u5e27&#xff0c;\u4e5f\u662fP\u5e27\u548cB\u5e27\u7684\u53c2\u8003\u5e27\u3002I\u5e27\u7684\u6570\u636e\u91cf\u6700\u5927&#xff0c;\u4f46\u89e3\u7801\u590d\u6742\u5ea6\u6700\u4f4e\u3002<\/li>\n<li>P\u5e27&#xff08;Predicted Picture&#xff09;&#xff1a;\u4e5f\u79f0\u4e3a\u9884\u6d4b\u5e27&#xff0c;\u5b83\u4f9d\u8d56\u4e8e\u524d\u9762\u7684I\u5e27\u6216P\u5e27\u8fdb\u884c\u89e3\u7801\u3002P\u5e27\u5305\u542b\u4e86\u4e0e\u53c2\u8003\u5e27\u7684\u5dee\u5f02\u4fe1\u606f&#xff0c;\u56e0\u6b64\u6570\u636e\u91cf\u6bd4I\u5e27\u5c0f&#xff0c;\u89e3\u7801\u590d\u6742\u5ea6\u6bd4I\u5e27\u9ad8\u3002<\/li>\n<li>B\u5e27&#xff08;Bidirectional Predicted Picture&#xff09;&#xff1a;\u4e5f\u79f0\u4e3a\u53cc\u5411\u9884\u6d4b\u5e27&#xff0c;\u5b83\u4f9d\u8d56\u4e8e\u524d\u540e\u7684I\u5e27\u6216P\u5e27\u8fdb\u884c\u89e3\u7801\u3002B\u5e27\u5305\u542b\u4e86\u4e0e\u524d\u540e\u53c2\u8003\u5e27\u7684\u5dee\u5f02\u4fe1\u606f&#xff0c;\u56e0\u6b64\u6570\u636e\u91cf\u6700\u5c0f&#xff0c;\u4f46\u89e3\u7801\u590d\u6742\u5ea6\u6700\u9ad8\u3002<\/li>\n<\/ul>\n<p>\u5728\u4e00\u4e2aGOP\u4e2d&#xff0c;I\u5e27\u3001P\u5e27\u548cB\u5e27\u7684\u6392\u5217\u987a\u5e8f\u548c\u6570\u91cf\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u9700\u8981\u8fdb\u884c\u8c03\u6574\u3002\u901a\u5e38&#xff0c;\u4e00\u4e2aGOP\u7684\u5f00\u59cb\u662f\u4e00\u4e2aI\u5e27&#xff0c;\u7136\u540e\u662f\u4e00\u4e9bP\u5e27\u548cB\u5e27\u3002I\u5e27\u7684\u95f4\u9694&#xff08;\u4e5f\u5c31\u662fGOP\u7684\u5927\u5c0f&#xff09;\u4f1a\u5f71\u54cd\u5230\u89c6\u9891\u7684\u538b\u7f29\u6548\u7387\u548c\u9519\u8bef\u6062\u590d\u80fd\u529b\u3002GOP\u7684\u5927\u5c0f\u8bbe\u7f6e\u5f97\u8d8a\u5927&#xff0c;\u538b\u7f29\u6548\u7387\u8d8a\u9ad8&#xff0c;\u4f46\u9519\u8bef\u6062\u590d\u80fd\u529b\u8d8a\u5f31&#xff1b;\u53cd\u4e4b&#xff0c;GOP\u7684\u5927\u5c0f\u8bbe\u7f6e\u5f97\u8d8a\u5c0f&#xff0c;\u538b\u7f29\u6548\u7387\u8d8a\u4f4e&#xff0c;\u4f46\u9519\u8bef\u6062\u590d\u80fd\u529b\u8d8a\u5f3a\u3002<\/p>\n<p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d&#xff0c;\u6211\u4eec\u9700\u8981\u6839\u636e\u7f51\u7edc\u73af\u5883\u3001\u5b58\u50a8\u7a7a\u95f4\u3001\u89c6\u9891\u8d28\u91cf\u7b49\u591a\u65b9\u9762\u56e0\u7d20&#xff0c;\u5408\u7406\u8bbe\u7f6eGOP\u7684\u5927\u5c0f\u548cI\u5e27\u3001P\u5e27\u3001B\u5e27\u7684\u6bd4\u4f8b&#xff0c;\u4ee5\u8fbe\u5230\u6700\u4f18\u7684\u89c6\u9891\u538b\u7f29\u6548\u679c\u3002<\/p>\n<h3>6.2 GOP\u5728RTSP\u670d\u52a1\u5668\u4e2d\u7684\u4f5c\u7528&#xff08;Role of GOP in RTSP Server&#xff09;<\/h3>\n<p>\u5728RTSP&#xff08;Real Time Streaming Protocol&#xff09;\u670d\u52a1\u5668\u4e2d&#xff0c;GOP&#xff08;Group of Pictures&#xff09;\u56fe\u50cf\u7ec4\u7684\u4f5c\u7528\u4e3b\u8981\u4f53\u73b0\u5728\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762&#xff1a;<\/p>\n<li>\u89c6\u9891\u538b\u7f29&#xff1a;GOP\u662f\u89c6\u9891\u538b\u7f29\u7f16\u7801\u4e2d\u7684\u4e00\u4e2a\u57fa\u672c\u5355\u4f4d\u3002\u901a\u8fc7\u5408\u7406\u8bbe\u7f6eGOP\u7684\u5927\u5c0f\u548cI\u5e27\u3001P\u5e27\u3001B\u5e27\u7684\u6bd4\u4f8b&#xff0c;\u53ef\u4ee5\u6709\u6548\u5730\u538b\u7f29\u89c6\u9891\u6570\u636e&#xff0c;\u51cf\u5c11\u7f51\u7edc\u4f20\u8f93\u548c\u5b58\u50a8\u7684\u538b\u529b\u3002<\/li>\n<li>\u9519\u8bef\u6062\u590d&#xff1a;\u5728\u7f51\u7edc\u4f20\u8f93\u8fc7\u7a0b\u4e2d&#xff0c;\u7531\u4e8e\u5404\u79cd\u539f\u56e0\u53ef\u80fd\u4f1a\u51fa\u73b0\u6570\u636e\u4e22\u5931\u7684\u60c5\u51b5\u3002\u8fd9\u65f6&#xff0c;\u5982\u679c\u4e22\u5931\u7684\u662fI\u5e27&#xff0c;\u90a3\u4e48\u540e\u7eed\u7684P\u5e27\u548cB\u5e27\u90fd\u65e0\u6cd5\u6b63\u5e38\u89e3\u7801&#xff0c;\u76f4\u5230\u4e0b\u4e00\u4e2aI\u5e27\u51fa\u73b0\u3002\u56e0\u6b64&#xff0c;\u901a\u8fc7\u8c03\u6574GOP\u7684\u5927\u5c0f&#xff0c;\u53ef\u4ee5\u5728\u538b\u7f29\u6548\u7387\u548c\u9519\u8bef\u6062\u590d\u80fd\u529b\u4e4b\u95f4\u627e\u5230\u4e00\u4e2a\u5e73\u8861\u3002<\/li>\n<li>\u89c6\u9891\u8d28\u91cf\u63a7\u5236&#xff1a;I\u5e27\u3001P\u5e27\u548cB\u5e27\u7684\u6570\u636e\u91cf\u548c\u89e3\u7801\u590d\u6742\u5ea6\u4e0d\u540c&#xff0c;\u5bf9\u89c6\u9891\u8d28\u91cf\u7684\u5f71\u54cd\u4e5f\u4e0d\u540c\u3002\u901a\u5e38&#xff0c;I\u5e27\u7684\u89c6\u9891\u8d28\u91cf\u6700\u9ad8&#xff0c;B\u5e27\u7684\u89c6\u9891\u8d28\u91cf\u6700\u4f4e\u3002\u56e0\u6b64&#xff0c;\u901a\u8fc7\u8c03\u6574I\u5e27\u3001P\u5e27\u548cB\u5e27\u7684\u6bd4\u4f8b&#xff0c;\u53ef\u4ee5\u5bf9\u89c6\u9891\u8d28\u91cf\u8fdb\u884c\u4e00\u5b9a\u7a0b\u5ea6\u7684\u63a7\u5236\u3002<\/li>\n<li>\u89c6\u9891\u64ad\u653e\u63a7\u5236&#xff1a;\u5728\u5b9e\u73b0\u89c6\u9891\u7684\u5feb\u8fdb\u3001\u5feb\u9000\u3001\u6682\u505c\u7b49\u64ad\u653e\u63a7\u5236\u529f\u80fd\u65f6&#xff0c;GOP\u4e5f\u8d77\u5230\u4e86\u5173\u952e\u7684\u4f5c\u7528\u3002\u4f8b\u5982&#xff0c;\u5feb\u8fdb\u65f6\u53ef\u4ee5\u8df3\u8fc7\u4e00\u4e9bGOP&#xff0c;\u5feb\u9000\u65f6\u53ef\u4ee5\u56de\u9000\u5230\u524d\u4e00\u4e2aGOP\u7684\u5f00\u59cb&#xff0c;\u6682\u505c\u65f6\u53ef\u4ee5\u505c\u5728\u5f53\u524dGOP\u7684\u7ed3\u675f\u3002<\/li>\n<p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d&#xff0c;\u6211\u4eec\u9700\u8981\u6839\u636e\u5b9e\u9645\u9700\u6c42\u548c\u7f51\u7edc\u73af\u5883&#xff0c;\u5408\u7406\u8bbe\u7f6eGOP\u7684\u53c2\u6570&#xff0c;\u4ee5\u5b9e\u73b0\u9ad8\u6548\u3001\u7a33\u5b9a\u7684\u89c6\u9891\u6d41\u4f20\u8f93\u3002<\/p>\n<h3>6.3 \u63d2\u5165GOP\u56fe\u50cf\u7ec4\u7684\u65b9\u6cd5\u4e0e\u6ce8\u610f\u4e8b\u9879&#xff08;Methods and Precautions for Inserting GOP&#xff09;<\/h3>\n<p>\u5728\u5b9e\u73b0RTSP\u670d\u52a1\u5668\u7684\u8fc7\u7a0b\u4e2d&#xff0c;GOP&#xff08;Group of Pictures&#xff09;\u56fe\u50cf\u7ec4\u7684\u63d2\u5165\u662f\u4e00\u4e2a\u5173\u952e\u6b65\u9aa4\u3002GOP\u662f\u7531\u4e00\u4e2aI\u5e27\u548c\u968f\u540e\u7684P\u5e27\u3001B\u5e27\u7ec4\u6210\u7684\u5e8f\u5217&#xff0c;\u5176\u4e2dI\u5e27\u662f\u5173\u952e\u5e27&#xff0c;P\u5e27\u548cB\u5e27\u662f\u5dee\u5206\u5e27\u3002\u63d2\u5165GOP\u56fe\u50cf\u7ec4\u53ef\u4ee5\u6709\u6548\u5730\u63d0\u9ad8\u89c6\u9891\u7684\u538b\u7f29\u6548\u7387&#xff0c;\u540c\u65f6\u4e5f\u5bf9\u89c6\u9891\u7684\u8d28\u91cf\u548c\u6d41\u7545\u6027\u6709\u91cd\u8981\u5f71\u54cd\u3002<\/p>\n<h4>\u63d2\u5165GOP\u56fe\u50cf\u7ec4\u7684\u65b9\u6cd5<\/h4>\n<p>\u63d2\u5165GOP\u56fe\u50cf\u7ec4\u7684\u4e3b\u8981\u65b9\u6cd5\u662f\u5728\u7f16\u7801\u89c6\u9891\u65f6\u8bbe\u7f6eGOP\u7684\u5927\u5c0f\u548c\u7ed3\u6784\u3002\u5728\u5927\u591a\u6570\u89c6\u9891\u7f16\u7801\u6807\u51c6\u4e2d&#xff0c;\u5982H.264\u548cH.265&#xff0c;\u90fd\u63d0\u4f9b\u4e86\u8bbe\u7f6eGOP\u5927\u5c0f\u7684\u9009\u9879\u3002\u5728\u7f16\u7801\u5668\u4e2d&#xff0c;\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u5173\u952e\u5e27\u95f4\u9694&#xff08;\u4e5f\u5c31\u662fGOP\u5927\u5c0f&#xff09;\u6765\u63a7\u5236GOP\u7684\u751f\u6210\u3002\u4f8b\u5982&#xff0c;\u5982\u679c\u8bbe\u7f6e\u5173\u952e\u5e27\u95f4\u9694\u4e3a10&#xff0c;\u90a3\u4e48\u6bcf10\u5e27\u5c31\u4f1a\u751f\u6210\u4e00\u4e2aI\u5e27&#xff0c;\u4ece\u800c\u5f62\u6210\u4e00\u4e2a\u65b0\u7684GOP\u3002<\/p>\n<p>\u5728\u8bbe\u7f6eGOP\u5927\u5c0f\u65f6&#xff0c;\u8fd8\u9700\u8981\u8003\u8651\u5230GOP\u7684\u7ed3\u6784&#xff0c;\u4e5f\u5c31\u662fI\u5e27\u3001P\u5e27\u548cB\u5e27\u7684\u6392\u5217\u65b9\u5f0f\u3002\u4e00\u822c\u6765\u8bf4&#xff0c;\u4e00\u4e2aGOP\u5f00\u59cb\u4e8e\u4e00\u4e2aI\u5e27&#xff0c;\u7136\u540e\u662f\u4e00\u7cfb\u5217\u7684P\u5e27\u548cB\u5e27\u3002P\u5e27\u662f\u57fa\u4e8e\u524d\u4e00\u5e27\u8fdb\u884c\u9884\u6d4b\u7684\u5e27&#xff0c;\u800cB\u5e27\u5219\u662f\u57fa\u4e8e\u524d\u540e\u4e24\u5e27\u8fdb\u884c\u9884\u6d4b\u7684\u5e27\u3002\u56e0\u6b64&#xff0c;GOP\u7684\u7ed3\u6784\u4f1a\u5f71\u54cd\u5230\u89c6\u9891\u7684\u538b\u7f29\u6548\u7387\u548c\u8d28\u91cf\u3002<\/p>\n<h4>\u63d2\u5165GOP\u56fe\u50cf\u7ec4\u7684\u6ce8\u610f\u4e8b\u9879<\/h4>\n<p>\u5728\u63d2\u5165GOP\u56fe\u50cf\u7ec4\u65f6&#xff0c;\u6709\u51e0\u70b9\u9700\u8981\u6ce8\u610f&#xff1a;<\/p>\n<li>GOP\u5927\u5c0f\u7684\u9009\u62e9&#xff1a;GOP\u7684\u5927\u5c0f\u4f1a\u5f71\u54cd\u5230\u89c6\u9891\u7684\u538b\u7f29\u6548\u7387\u548c\u8d28\u91cf\u3002\u4e00\u822c\u6765\u8bf4&#xff0c;\u8f83\u5927\u7684GOP\u53ef\u4ee5\u63d0\u9ad8\u538b\u7f29\u6548\u7387&#xff0c;\u4f46\u53ef\u80fd\u4f1a\u964d\u4f4e\u89c6\u9891\u7684\u8d28\u91cf\u3002\u56e0\u6b64&#xff0c;\u9700\u8981\u6839\u636e\u5b9e\u9645\u9700\u6c42\u6765\u9009\u62e9\u5408\u9002\u7684GOP\u5927\u5c0f\u3002<\/li>\n<li>I\u5e27\u3001P\u5e27\u548cB\u5e27\u7684\u987a\u5e8f&#xff1a;\u5728\u63d2\u5165GOP\u65f6&#xff0c;\u9700\u8981\u4fdd\u8bc1I\u5e27\u3001P\u5e27\u548cB\u5e27\u7684\u6b63\u786e\u987a\u5e8f\u3002\u5982\u679c\u987a\u5e8f\u9519\u8bef&#xff0c;\u53ef\u80fd\u4f1a\u5bfc\u81f4\u89c6\u9891\u7684\u89e3\u7801\u9519\u8bef&#xff0c;\u4ece\u800c\u5f71\u54cd\u5230\u89c6\u9891\u7684\u8d28\u91cf\u3002<\/li>\n<li>\u7f51\u7edc\u73af\u5883\u7684\u8003\u8651&#xff1a;\u5728\u5b9e\u73b0RTSP\u670d\u52a1\u5668\u65f6&#xff0c;\u8fd8\u9700\u8981\u8003\u8651\u5230\u7f51\u7edc\u73af\u5883\u7684\u5f71\u54cd\u3002\u5982\u679c\u7f51\u7edc\u73af\u5883\u4e0d\u7a33\u5b9a&#xff0c;\u53ef\u80fd\u9700\u8981\u9009\u62e9\u8f83\u5c0f\u7684GOP\u5927\u5c0f&#xff0c;\u4ee5\u51cf\u5c11\u7531\u4e8e\u7f51\u7edc\u4e22\u5305\u5bfc\u81f4\u7684\u89c6\u9891\u8d28\u91cf\u4e0b\u964d\u3002<\/li>\n<li>\u7f16\u7801\u5668\u7684\u8bbe\u7f6e&#xff1a;\u5728\u7f16\u7801\u5668\u4e2d&#xff0c;\u9700\u8981\u6b63\u786e\u8bbe\u7f6eGOP\u7684\u5927\u5c0f<\/li>\n<p>\u5bf9\u4e0d\u8d77&#xff0c;\u6211\u5728\u5c1d\u8bd5\u83b7\u53d6\u76f8\u5173\u4fe1\u606f\u65f6\u9047\u5230\u4e86\u4e00\u4e9b\u95ee\u9898\u3002\u4e0d\u8fc7&#xff0c;\u6211\u53ef\u4ee5\u7ee7\u7eed\u63d0\u4f9b\u4e00\u4e9b\u5173\u4e8e\u63d2\u5165GOP\u56fe\u50cf\u7ec4\u7684\u6ce8\u610f\u4e8b\u9879&#xff1a;<\/p>\n<li>\u540c\u6b65\u95ee\u9898&#xff1a;\u5728\u63d2\u5165GOP\u56fe\u50cf\u7ec4\u65f6&#xff0c;\u9700\u8981\u6ce8\u610f\u89c6\u9891\u548c\u97f3\u9891\u7684\u540c\u6b65\u95ee\u9898\u3002\u5982\u679c\u89c6\u9891\u548c\u97f3\u9891\u7684\u65f6\u95f4\u6233\u4e0d\u5339\u914d&#xff0c;\u53ef\u80fd\u4f1a\u5bfc\u81f4\u64ad\u653e\u65f6\u51fa\u73b0\u540c\u6b65\u95ee\u9898\u3002<\/li>\n<li>\u7f16\u7801\u683c\u5f0f\u7684\u9009\u62e9&#xff1a;\u5728\u63d2\u5165GOP\u56fe\u50cf\u7ec4\u65f6&#xff0c;\u8fd8\u9700\u8981\u8003\u8651\u5230\u7f16\u7801\u683c\u5f0f\u7684\u9009\u62e9\u3002\u4e0d\u540c\u7684\u7f16\u7801\u683c\u5f0f&#xff0c;\u5982H.264\u548cH.265&#xff0c;\u5bf9GOP\u7684\u5904\u7406\u65b9\u5f0f\u53ef\u80fd\u4f1a\u6709\u6240\u4e0d\u540c\u3002<\/li>\n<li>\u89c6\u9891\u6e90\u7684\u8d28\u91cf&#xff1a;\u5728\u63d2\u5165GOP\u56fe\u50cf\u7ec4\u65f6&#xff0c;\u8fd8\u9700\u8981\u8003\u8651\u5230\u89c6\u9891\u6e90\u7684\u8d28\u91cf\u3002\u5982\u679c\u89c6\u9891\u6e90\u7684\u8d28\u91cf\u8f83\u4f4e&#xff0c;\u5373\u4f7f\u6b63\u786e\u63d2\u5165\u4e86GOP\u56fe\u50cf\u7ec4&#xff0c;\u4e5f\u53ef\u80fd\u65e0\u6cd5\u63d0\u9ad8\u89c6\u9891\u7684\u8d28\u91cf\u3002<\/li>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5173\u4e8e\u63d2\u5165GOP\u56fe\u50cf\u7ec4\u7684\u4e00\u4e9b\u65b9\u6cd5\u548c\u6ce8\u610f\u4e8b\u9879\u3002\u5e0c\u671b\u8fd9\u4e9b\u4fe1\u606f\u80fd\u591f\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\u3002\u5982\u679c\u4f60\u8fd8\u6709\u5176\u4ed6\u95ee\u9898&#xff0c;\u6b22\u8fce\u968f\u65f6\u5411\u6211\u63d0\u95ee\u3002<\/p>\n<h3>6.4 \u4ee3\u7801\u793a\u4f8b<\/h3>\n<h4>6.4.1 \u5728RTSP\u670d\u52a1\u5668\u4e2d\u63d2\u5165GOP&#xff08;Group of Pictures&#xff09;\u7684C&#043;&#043;\u4ee3\u7801\u793a\u4f8b<\/h4>\n<p>\u8fd9\u662f\u4e00\u4e2a\u5728RTSP\u670d\u52a1\u5668\u4e2d\u63d2\u5165GOP&#xff08;Group of Pictures&#xff09;\u7684C&#043;&#043;\u4ee3\u7801\u793a\u4f8b\u3002\u8fd9\u6bb5\u4ee3\u7801\u4e3b\u8981\u662f\u901a\u8fc7\u8c03\u7528insertGOP\u51fd\u6570\u6765\u5b9e\u73b0\u7684\u3002\u5728\u8fd9\u4e2a\u51fd\u6570\u4e2d&#xff0c;\u9996\u5148\u521b\u5efa\u4e86\u4e00\u4e2a\u65b0\u7684GOP\u5bf9\u8c61&#xff0c;\u7136\u540e\u5c06\u5176\u6dfb\u52a0\u5230GOPs\u5217\u8868\u4e2d\u3002\u7136\u540e&#xff0c;\u5bf9\u6bcf\u4e2a\u5728GOP\u4e2d\u7684\u5e27&#xff0c;\u90fd\u8c03\u7528insertFrame\u51fd\u6570\u5c06\u5176\u6dfb\u52a0\u5230GOP\u4e2d\u3002\u6700\u540e&#xff0c;\u5982\u679cGOP\u7684\u5927\u5c0f\u8d85\u8fc7\u4e86\u6700\u5927\u9650\u5236&#xff0c;\u5c31\u4f1a\u5220\u9664\u6700\u65e9\u7684GOP\u3002<\/p>\n<p>void RTSPServer::insertGOP(GOP gop) {<br \/>\n    \/\/ Create a new GOP<br \/>\n    GOP newGOP &#061; GOP();<\/p>\n<p>    \/\/ Add the new GOP to the list of GOPs<br \/>\n    GOPs.push_back(newGOP);<\/p>\n<p>    \/\/ For each frame in the GOP, insert it into the new GOP<br \/>\n    for (Frame frame : gop.getFrames()) {<br \/>\n        newGOP.insertFrame(frame);<br \/>\n    }<\/p>\n<p>    \/\/ If the number of GOPs exceeds the maximum limit, remove the oldest GOP<br \/>\n    if (GOPs.size() &gt; MAX_GOPs) {<br \/>\n        GOPs.pop_front();<br \/>\n    }<br \/>\n} <\/p>\n<p>\u8bf7\u6ce8\u610f&#xff0c;\u8fd9\u53ea\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b&#xff0c;\u5b9e\u9645\u7684\u5b9e\u73b0\u53ef\u80fd\u4f1a\u6839\u636e\u5177\u4f53\u7684\u9700\u6c42\u548c\u73af\u5883\u6709\u6240\u4e0d\u540c\u3002\u4f8b\u5982&#xff0c;\u4f60\u53ef\u80fd\u9700\u8981\u5904\u7406\u9519\u8bef\u60c5\u51b5&#xff0c;\u6216\u8005\u5728\u63d2\u5165\u65b0\u7684GOP\u65f6\u8fdb\u884c\u4e00\u4e9b\u989d\u5916\u7684\u64cd\u4f5c\u3002<\/p>\n<p>\u6b64\u5916&#xff0c;\u8fd9\u6bb5\u4ee3\u7801\u5047\u8bbe\u4f60\u5df2\u7ecf\u6709\u4e86\u4e00\u4e2aGOP\u7c7b\u548c\u4e00\u4e2aFrame\u7c7b\u3002GOP\u7c7b\u5e94\u8be5\u6709\u4e00\u4e2agetFrames\u65b9\u6cd5\u6765\u83b7\u53d6GOP\u4e2d\u7684\u6240\u6709\u5e27&#xff0c;\u4ee5\u53ca\u4e00\u4e2ainsertFrame\u65b9\u6cd5\u6765\u6dfb\u52a0\u65b0\u7684\u5e27\u3002Frame\u7c7b\u5219\u4ee3\u8868\u4e86\u89c6\u9891\u6d41\u4e2d\u7684\u4e00\u4e2a\u5e27\u3002<\/p>\n<p>\u5728\u5b9e\u9645\u4f7f\u7528\u65f6&#xff0c;\u4f60\u53ef\u80fd\u9700\u8981\u6839\u636e\u4f60\u7684\u89c6\u9891\u6d41\u7684\u7279\u6027\u548c\u4f60\u7684\u670d\u52a1\u5668\u7684\u9700\u6c42\u6765\u8c03\u6574\u8fd9\u6bb5\u4ee3\u7801\u3002\u4f8b\u5982&#xff0c;\u4f60\u53ef\u80fd\u9700\u8981\u8c03\u6574MAX_GOPs\u7684\u503c&#xff0c;\u6216\u8005\u5728\u5220\u9664\u65e7\u7684GOP\u65f6\u8fdb\u884c\u4e00\u4e9b\u989d\u5916\u7684\u64cd\u4f5c\u3002<\/p>\n<h4>6.4.2 live555\u4ed3\u5e93\u4e2d\u5904\u7406H264\u89c6\u9891RTP sink\u7684\u7279\u6b8a\u5e27 \u4ee3\u7801\u793a\u4f8b<\/h4>\n<p>\/\/ File: liveMedia\/H264VideoRTPSink.cpp<br \/>\n\/\/ Repository: https:\/\/github.com\/rgaufert\/live555<\/p>\n<p>void H264VideoRTPSink::doSpecialFrameHandling(unsigned fragmentationOffset,<br \/>\n      unsigned char* frameStart,<br \/>\n      unsigned numBytesInFrame,<br \/>\n      struct timeval framePresentationTime,<br \/>\n      unsigned numRemainingBytes) {<br \/>\n  \/\/ Set the RTP &#039;M&#039; (marker) bit iff<br \/>\n  \/\/ 1\/ The most recently delivered fragment was the end of (or the only fragment of) an NAL unit, and<br \/>\n  \/\/ 2\/ This NAL unit was the last NAL unit of an &#039;access unit&#039; (i.e. video frame).<br \/>\n  \/\/ (RTP &#039;M&#039; bit is set for video frames only; not for audio frames)<\/p>\n<p>  \/\/ Begin by checking condition 1\/ above:<br \/>\n  if (numRemainingBytes &#061;&#061; 0) { \/\/ This fragment ends the current NAL unit<br \/>\n    \/\/ Check for condition 2\/ above:<br \/>\n    \/\/ This requires parsing the NAL unit&#039;s header byte, and the first byte of the NAL unit payload:<br \/>\n    if (numBytesInFrame &gt; 0) {<br \/>\n      unsigned char nal_unit_type &#061; (frameStart[0]&amp;0x1F);<br \/>\n      if (nal_unit_type &#061;&#061; 24 || nal_unit_type &#061;&#061; 25 || nal_unit_type &#061;&#061; 26 || nal_unit_type &#061;&#061; 27) {<br \/>\n\/\/ This is a STAP-A, STAP-B, MTAP16, or MTAP24 NAL unit.  Check the first NAL unit within it:<br \/>\nif (numBytesInFrame &gt; 1) {<br \/>\n  nal_unit_type &#061; (frameStart[1]&amp;0x1F);<br \/>\n} else {<br \/>\n  \/\/ This NAL unit is unusable; we shouldn&#039;t have sent it<br \/>\n  nal_unit_type &#061; 0;<br \/>\n}<br \/>\n      }<\/p>\n<p>      if (nal_unit_type &#061;&#061; 6 || nal_unit_type &#061;&#061; 7 || nal_unit_type &#061;&#061; 8) {<br \/>\n\/\/ This NAL unit is an SPS or PPS or a prefix NAL unit; next is a IDR picture<br \/>\nfCurrentNALUnitEndsAccessUnit &#061; True;<br \/>\n      } else if (nal_unit_type &lt;&#061; 5 &amp;&amp; nal_unit_type &gt; 0) {<br \/>\n\/\/ This NAL unit is a VCL NAL unit (slice_layer_without_partitioning_rbsp)<br \/>\n\/\/ We need to examine the first byte of the NAL unit&#039;s RBSP payload &#8211; the &#034;slice header&#034;:<br \/>\nunsigned char* sliceHeader &#061; &amp;frameStart[1]; \/\/ if the NAL unit is not fragmented<br \/>\nunsigned numBytesInNALUnitPayload &#061; numBytesInFrame &#8211; 1;<\/p>\n<p>\/\/ Begin by making sure we have at least one byte of the NAL unit payload data:<br \/>\nif (numBytesInNALUnitPayload &gt; 0) {<br \/>\n  if (nal_unit_type &#061;&#061; 28 || nal_unit_type &#061;&#061; 29) {<br \/>\n    \/\/ This is a FU-A or FU-B NAL unit.  We need to find the start of the NAL unit&#039;s payload data:<br \/>\n    if (numBytesInFrame &gt; 2) {<br \/>\n      sliceHeader &#061; &amp;frameStart[2];<br \/>\n      numBytesInNALUnitPayload &#061; numBytesInFrame &#8211; 2;<br \/>\n    } else {<br \/>\n      \/\/ This NAL unit is unusable; we shouldn&#039;t have sent it<br \/>\n      numBytesInNALUnitPayload &#061; 0;<br \/>\n    }<br \/>\n  }<\/p>\n<p>  if (numBytesInNALUnitPayload &gt; 0) {<br \/>\n    unsigned char slice_type &#061; sliceHeader[0]&amp;0x1F;<br \/>\n fCurrentNALUnitEndsAccessUnit &#061; False;<br \/>\n    if (fLastNALUnitEndsAccessUnit) {<br \/>\n      \/\/ This is the start of a new access unit<br \/>\n      if (fNextDeliverPresentationTime.tv_sec !&#061; 0 || fNextDeliverPresentationTime.tv_usec !&#061; 0) {<br \/>\n\/\/ We have a saved &#039;next presentation time&#039;.  Deliver the most recent frame with that presentation time now, before starting the new access unit<br \/>\nif (fNumSavedNALUnits &gt; 0) {<br \/>\n  doSpecialFrameHandling1(fNumSavedNALUnits, fSavedNALUnits, fSavedNALUnitSizes, fSavedNALUnitPresentationTimes, fNextDeliverPresentationTime);<br \/>\n  delete[] fSavedNALUnits;<br \/>\n  delete[] fSavedNALUnitSizes;<br \/>\n  delete[] fSavedNALUnitPresentationTimes;<br \/>\n}<br \/>\n      }<br \/>\n    }<br \/>\n    \/\/\u4fdd\u5b58I\u5e27<br \/>\n    if (nal_unit_type &#061;&#061; 5) {<br \/>\n      saveFrameParameters(slice_type, fragmentationOffset, frameStart, numBytesInFrame, framePresentationTime);<br \/>\n    }<\/p>\n<p>    fNextDeliverPresentationTime &#061; framePresentationTime;<br \/>\n    fNextDeliverPresentationTime.tv_sec &#043;&#061; fMaxPacketAge;<\/p>\n<p>    fLastNALUnitEndsAccessUnit &#061; fCurrentNALUnitEndsAccessUnit;<br \/>\n  }<br \/>\n}<br \/>\n      }<br \/>\n    }<br \/>\n  }<br \/>\n} <\/p>\n<p>\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d&#xff0c;\u6211\u4eec\u53ef\u4ee5\u770b\u5230&#xff1a;<\/p>\n<ul>\n<li>\u9996\u5148&#xff0c;\u901a\u8fc7\u6309\u4f4d\u4e0e\u64cd\u4f5c\u548c\u63a9\u78010x1F\u83b7\u53d6NAL\u5355\u5143\u7684\u7c7b\u578b\u3002<\/li>\n<li>\u5982\u679cNAL\u5355\u5143\u7c7b\u578b\u662f5&#xff08;IDR\u56fe\u50cf\u5e27&#xff09;&#xff0c;\u5219\u4fdd\u5b58\u8be5\u5e27\u7684\u53c2\u6570\u3002<\/li>\n<li>\u6700\u540e&#xff0c;\u5c06\u5f53\u524dNAL\u5355\u5143\u7684\u7ed3\u675f\u6807\u5fd7\u8d4b\u503c\u7ed9fLastNALUnitEndsAccessUnit\u53d8\u91cf&#xff0c;\u4ee5\u4fbf\u5728\u4e0b\u4e00\u6b21\u5904\u7406\u7279\u6b8a\u5e27\u65f6\u4f7f\u7528\u3002<\/li>\n<\/ul>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u662f\u4ecelive555\u4ed3\u5e93\u4e2d\u7684liveMedia\/H264VideoRTPSink.cpp\u6587\u4ef6\u4e2d\u63d0\u53d6\u7684&#xff0c;\u7528\u4e8e\u5904\u7406H264\u89c6\u9891RTP sink\u7684\u7279\u6b8a\u5e27\u60c5\u51b5\u3002\u5b83\u53ef\u4ee5\u5e2e\u52a9\u60a8\u7406\u89e3\u5982\u4f55\u5728C&#043;&#043;\u4e2d\u63d2\u5165GOP&#xff0c;\u5e76\u6839\u636e\u5e27\u7c7b\u578b\u8fdb\u884c\u76f8\u5e94\u7684\u64cd\u4f5c\u3002<\/p>\n<p>\u8bf7\u6ce8\u610f&#xff0c;\u8fd9\u53ea\u662f\u4ee3\u7801\u7247\u6bb5\u7684\u4e00\u90e8\u5206&#xff0c;\u5b8c\u6574\u7684\u4ee3\u7801\u903b\u8f91\u53ef\u80fd\u66f4\u590d\u6742\u3002\u8981\u6df1\u5165\u4e86\u89e3\u5982\u4f55\u5728RTSP\u670d\u52a1\u5668\u4e2d\u63d2\u5165GOP&#xff0c;\u8bf7\u53c2\u8003\u76f8\u5173\u7684\u6587\u6863\u3001\u8d44\u6599\u6216\u7814\u7a76live555\u9879\u76ee\u7684\u6e90\u4ee3\u7801\u3002<\/p>\n<h4>6.4.3 \u5982\u4f55\u5728RTSP\u670d\u52a1\u5668\u4e2d\u5904\u7406\u53d1\u9001\u5e27<\/h4>\n<p>\u8fd9\u662f\u4e00\u4e2a\u53ef\u80fd\u4f1a\u6709\u5e2e\u52a9\u7684GitHub\u4ed3\u5e93\u4e2d\u7684\u4ee3\u7801\u7247\u6bb5&#xff1a;<\/p>\n<p>\/\/ \u8fd9\u4e2a\u51fd\u6570\u5728\u7279\u5b9a\u7684\u65f6\u95f4\u95f4\u9694\u540e\u88ab\u8c03\u7528<br \/>\nvoid check_for_frame_to_send() {<br \/>\n    \/\/ \u68c0\u67e5\u662f\u5426\u6709\u5e27\u9700\u8981\u53d1\u9001<br \/>\n    if (!frames.empty()) {<br \/>\n        \/\/ \u83b7\u53d6\u7b2c\u4e00\u4e2a\u5e27<br \/>\n        auto frame &#061; frames.front();<\/p>\n<p>        \/\/ \u68c0\u67e5\u8fd9\u4e2a\u5e27\u662f\u5426\u662f\u5173\u952e\u5e27&#xff08;GOP&#xff09;<br \/>\n        if (frame-&gt;key_frame) {<br \/>\n            \/\/ \u53d1\u9001\u8fd9\u4e2a\u5e27<br \/>\n            send_frame(frame);<\/p>\n<p>            \/\/ \u4ece\u961f\u5217\u4e2d\u79fb\u9664\u8fd9\u4e2a\u5e27<br \/>\n            frames.pop();<br \/>\n        }<br \/>\n    }<br \/>\n} <\/p>\n<p>\u8fd9\u4e2aC&#043;&#043;\u4ee3\u7801\u7247\u6bb5\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b&#xff0c;\u5c55\u793a\u4e86\u4f60\u53ef\u80fd\u5982\u4f55\u5728RTSP\u670d\u52a1\u5668\u4e2d\u5904\u7406\u53d1\u9001\u5e27\u3002\u5b83\u68c0\u67e5\u662f\u5426\u6709\u5e27\u9700\u8981\u53d1\u9001&#xff0c;\u5982\u679c\u961f\u5217\u4e2d\u7684\u7b2c\u4e00\u4e2a\u5e27\u662f\u5173\u952e\u5e27&#xff08;\u6216\u8005GOP&#xff09;&#xff0c;\u90a3\u4e48\u5c31\u53d1\u9001\u8fd9\u4e2a\u5e27&#xff0c;\u7136\u540e\u4ece\u961f\u5217\u4e2d\u79fb\u9664\u5b83\u3002<\/p>\n<p>\u8bf7\u6ce8\u610f&#xff0c;\u8fd9\u53ea\u662f\u4e00\u4e2a\u7b80\u5316\u7684\u793a\u4f8b&#xff0c;\u5b9e\u9645\u7684\u5b9e\u73b0\u53ef\u80fd\u4f1a\u6839\u636e\u4f60\u7684\u7279\u5b9a\u9700\u6c42\u548c\u4f60\u4f7f\u7528\u7684\u5e93\u800c\u6709\u6240\u4e0d\u540c\u3002<\/p>\n<p>\u5728\u5904\u7406\u89c6\u9891\u6d41\u4e2d\u7684GOP\u65f6&#xff0c;\u8bf7\u8bb0\u4f4f&#xff1a;<\/p>\n<li>GOP\u4ee5\u5173\u952e\u5e27&#xff08;I\u5e27&#xff09;\u5f00\u59cb&#xff0c;\u8fd9\u4e2a\u5e27\u53ef\u4ee5\u72ec\u7acb\u4e8e\u5176\u4ed6\u4efb\u4f55\u5e27\u8fdb\u884c\u89e3\u7801\u3002<\/li>\n<li>GOP\u7684\u7ed3\u6784\u548c\u5927\u5c0f\u53ef\u4ee5\u663e\u8457\u5f71\u54cd\u89c6\u9891\u538b\u7f29\u7684\u6548\u7387\u548c\u5728\u89c6\u9891\u4e2d\u5bfb\u627e\u7684\u80fd\u529b\u3002<\/li>\n<li>\u5728\u6d41\u5a92\u4f53\u89c6\u9891\u65f6&#xff0c;\u4f60\u901a\u5e38\u5e0c\u671b\u786e\u4fdd\u4e0d\u540c\u89c6\u9891\u8f68\u9053\u4e2d\u7684\u5173\u952e\u5e27\u662f\u5bf9\u9f50\u7684&#xff0c;\u4ee5\u4fbf\u5728\u8f68\u9053\u4e4b\u95f4\u5e73\u6ed1\u5207\u6362\u3002<\/li>\n<h3>\u4e03\u3001\u64ad\u653e\u901f\u5ea6\u7684\u63a7\u5236\u4e0e\u500d\u901f\u64ad\u653e\u7684\u5b9e\u73b0&#xff08;Control of Playback Speed and Implementation of Speed-up Playback&#xff09;<\/h3>\n<h3>7.1 \u64ad\u653e\u901f\u5ea6\u7684\u63a7\u5236\u539f\u7406&#xff08;Principle of Playback Speed Control&#xff09;<\/h3>\n<p>\u5728\u6df1\u5165\u4e86\u89e3\u64ad\u653e\u901f\u5ea6\u63a7\u5236\u7684\u539f\u7406\u4e4b\u524d&#xff0c;\u6211\u4eec\u9996\u5148\u9700\u8981\u7406\u89e3\u89c6\u9891\u64ad\u653e\u7684\u57fa\u672c\u673a\u5236\u3002\u89c6\u9891\u64ad\u653e\u5b9e\u9645\u4e0a\u662f\u4e00\u7cfb\u5217\u9759\u6001\u56fe\u50cf&#xff08;\u5e27&#xff09;\u5728\u77ed\u65f6\u95f4\u5185\u8fde\u7eed\u64ad\u653e\u7684\u7ed3\u679c&#xff0c;\u8fd9\u79cd\u8fde\u7eed\u64ad\u653e\u7684\u901f\u5ea6\u88ab\u79f0\u4e3a\u5e27\u7387&#xff08;Frame Rate&#xff09;&#xff0c;\u5355\u4f4d\u901a\u5e38\u662fFPS&#xff08;Frames Per Second&#xff0c;\u6bcf\u79d2\u5e27\u6570&#xff09;\u3002\u5f53\u5e27\u7387\u8db3\u591f\u9ad8\u65f6&#xff0c;\u4eba\u773c\u4f1a\u5c06\u8fd9\u4e9b\u8fde\u7eed\u7684\u5e27\u89c6\u4e3a\u52a8\u6001\u7684\u89c6\u9891\u3002<\/p>\n<p>\u5728RTSP&#xff08;Real Time Streaming Protocol&#xff0c;\u5b9e\u65f6\u6d41\u4f20\u8f93\u534f\u8bae&#xff09;\u670d\u52a1\u5668\u4e2d&#xff0c;\u64ad\u653e\u901f\u5ea6\u7684\u63a7\u5236\u4e3b\u8981\u901a\u8fc7\u8c03\u6574\u5e27\u7387\u6765\u5b9e\u73b0\u3002\u5177\u4f53\u6765\u8bf4&#xff0c;\u5982\u679c\u6211\u4eec\u5e0c\u671b\u89c6\u9891\u64ad\u653e\u901f\u5ea6\u52a0\u5feb&#xff0c;\u90a3\u4e48\u53ef\u4ee5\u901a\u8fc7\u589e\u52a0\u5e27\u7387\u6765\u5b9e\u73b0&#xff1b;\u76f8\u53cd&#xff0c;\u5982\u679c\u6211\u4eec\u5e0c\u671b\u89c6\u9891\u64ad\u653e\u901f\u5ea6\u51cf\u6162&#xff0c;\u90a3\u4e48\u53ef\u4ee5\u901a\u8fc7\u964d\u4f4e\u5e27\u7387\u6765\u5b9e\u73b0\u3002<\/p>\n<p>\u7136\u800c&#xff0c;\u8fd9\u91cc\u6709\u4e00\u4e2a\u95ee\u9898\u9700\u8981\u6ce8\u610f&#xff0c;\u90a3\u5c31\u662f\u5e27\u7387\u7684\u8c03\u6574\u5fc5\u987b\u5728\u4e0d\u5f71\u54cd\u89c6\u9891\u8d28\u91cf\u7684\u524d\u63d0\u4e0b\u8fdb\u884c\u3002\u56e0\u4e3a\u5982\u679c\u5e27\u7387\u8fc7\u9ad8&#xff0c;\u867d\u7136\u53ef\u4ee5\u4f7f\u89c6\u9891\u64ad\u653e\u901f\u5ea6\u52a0\u5feb&#xff0c;\u4f46\u53ef\u80fd\u4f1a\u5bfc\u81f4\u89c6\u9891\u753b\u9762\u7684\u4e22\u5e27\u73b0\u8c61&#xff0c;\u5f71\u54cd\u89c2\u770b\u4f53\u9a8c&#xff1b;\u540c\u6837&#xff0c;\u5982\u679c\u5e27\u7387\u8fc7\u4f4e&#xff0c;\u867d\u7136\u53ef\u4ee5\u4f7f\u89c6\u9891\u64ad\u653e\u901f\u5ea6\u51cf\u6162&#xff0c;\u4f46\u53ef\u80fd\u4f1a\u5bfc\u81f4\u89c6\u9891\u753b\u9762\u7684\u5361\u987f\u73b0\u8c61&#xff0c;\u540c\u6837\u5f71\u54cd\u89c2\u770b\u4f53\u9a8c\u3002<\/p>\n<p>\u56e0\u6b64&#xff0c;\u5982\u4f55\u5728\u4fdd\u8bc1\u89c6\u9891\u8d28\u91cf\u7684\u540c\u65f6&#xff0c;\u6709\u6548\u5730\u63a7\u5236\u64ad\u653e\u901f\u5ea6&#xff0c;\u662fRTSP\u670d\u52a1\u5668\u9700\u8981\u89e3\u51b3\u7684\u91cd\u8981\u95ee\u9898\u3002\u5728\u4e0b\u4e00\u8282\u4e2d&#xff0c;\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7C&#043;&#043;\u548cLive555\u5e93\u6765\u5b9e\u73b0\u8fd9\u4e00\u76ee\u6807\u3002<\/p>\n<h3>7.2 \u5982\u4f55\u5b9e\u73b0\u500d\u901f\u64ad\u653e&#xff08;How to Implement Speed-up Playback&#xff09;<\/h3>\n<p>\u500d\u901f\u64ad\u653e\u662f\u73b0\u4ee3\u591a\u5a92\u4f53\u5e94\u7528\u4e2d\u5e38\u89c1\u7684\u529f\u80fd&#xff0c;\u5b83\u5141\u8bb8\u7528\u6237\u5728\u4fdd\u6301\u89c6\u9891\u548c\u97f3\u9891\u540c\u6b65\u7684\u540c\u65f6&#xff0c;\u52a0\u5feb\u6216\u51cf\u6162\u64ad\u653e\u901f\u5ea6\u3002\u5728C&#043;&#043;\u548cLive555\u5e93\u4e2d&#xff0c;\u5b9e\u73b0\u500d\u901f\u64ad\u653e\u7684\u5173\u952e\u5728\u4e8e\u6b63\u786e\u5730\u8c03\u6574\u5e27\u7684\u53d1\u9001\u901f\u5ea6\u3002<\/p>\n<p>\u9996\u5148&#xff0c;\u6211\u4eec\u9700\u8981\u7406\u89e3\u5728RTSP\u6d41\u4e2d&#xff0c;\u6bcf\u4e00\u5e27\u90fd\u6709\u4e00\u4e2a\u7279\u5b9a\u7684\u65f6\u95f4\u6233&#xff08;Timestamp&#xff09;\u3002\u8fd9\u4e2a\u65f6\u95f4\u6233\u51b3\u5b9a\u4e86\u5e27\u5728\u64ad\u653e\u8fc7\u7a0b\u4e2d\u7684\u663e\u793a\u65f6\u95f4\u3002\u5728\u6b63\u5e38\u64ad\u653e\u901f\u5ea6\u4e0b&#xff0c;\u6bcf\u4e00\u5e27\u7684\u663e\u793a\u65f6\u95f4\u4e0e\u5176\u5728\u89c6\u9891\u6587\u4ef6\u4e2d\u7684\u76f8\u5bf9\u4f4d\u7f6e\u662f\u4e00\u81f4\u7684\u3002\u4f8b\u5982&#xff0c;\u5982\u679c\u4e00\u4e2a\u89c6\u9891\u7684\u5e27\u7387\u662f30FPS&#xff0c;\u90a3\u4e48\u7b2c150\u5e27\u7684\u65f6\u95f4\u6233\u5c31\u5e94\u8be5\u662f5\u79d2\u3002<\/p>\n<p>\u7136\u800c&#xff0c;\u5728\u500d\u901f\u64ad\u653e\u4e2d&#xff0c;\u6211\u4eec\u9700\u8981\u6539\u53d8\u8fd9\u4e2a\u65f6\u95f4\u6233\u4ee5\u8fbe\u5230\u52a0\u5feb\u6216\u51cf\u6162\u64ad\u653e\u901f\u5ea6\u7684\u76ee\u7684\u3002\u5177\u4f53\u6765\u8bf4&#xff0c;\u5982\u679c\u6211\u4eec\u5e0c\u671b\u5b9e\u73b02\u500d\u901f\u64ad\u653e&#xff0c;\u90a3\u4e48\u6211\u4eec\u5c31\u9700\u8981\u5c06\u6bcf\u4e00\u5e27\u7684\u65f6\u95f4\u6233\u51cf\u534a&#xff1b;\u76f8\u53cd&#xff0c;\u5982\u679c\u6211\u4eec\u5e0c\u671b\u5b9e\u73b00.5\u500d\u901f\u64ad\u653e&#xff0c;\u90a3\u4e48\u6211\u4eec\u5c31\u9700\u8981\u5c06\u6bcf\u4e00\u5e27\u7684\u65f6\u95f4\u6233\u7ffb\u500d\u3002<\/p>\n<p>\u5728C&#043;&#043;\u548cLive555\u5e93\u4e2d&#xff0c;\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539RTP&#xff08;Real-time Transport Protocol&#xff0c;\u5b9e\u65f6\u4f20\u8f93\u534f\u8bae&#xff09;\u5305\u7684\u65f6\u95f4\u6233\u6765\u5b9e\u73b0\u8fd9\u4e00\u76ee\u6807\u3002\u5177\u4f53\u7684\u4ee3\u7801\u5b9e\u73b0\u53ef\u80fd\u4f1a\u6d89\u53ca\u5230\u4e00\u4e9b\u590d\u6742\u7684\u7ec6\u8282&#xff0c;\u4f8b\u5982\u5982\u4f55\u5904\u7406\u5e27\u7684\u4f9d\u8d56\u5173\u7cfb&#xff08;\u4f8b\u5982I\u5e27\u548cP\u5e27&#xff09;&#xff0c;\u5982\u4f55\u786e\u4fdd\u97f3\u89c6\u9891\u540c\u6b65\u7b49\u3002\u4f46\u603b\u7684\u6765\u8bf4&#xff0c;\u53ea\u8981\u6211\u4eec\u6b63\u786e\u5730\u8c03\u6574\u4e86\u5e27\u7684\u65f6\u95f4\u6233&#xff0c;\u5c31\u53ef\u4ee5\u5b9e\u73b0\u500d\u901f\u64ad\u653e\u7684\u529f\u80fd\u3002<\/p>\n<p>\/\/ \u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2aRTP\u5305\u5bf9\u8c61rtpPacket<br \/>\nRTPPacket rtpPacket;<\/p>\n<p>\/\/ \u83b7\u53d6\u5f53\u524d\u7684\u65f6\u95f4\u6233<br \/>\nuint32_t currentTimestamp &#061; rtpPacket.getTimestamp();<\/p>\n<p>\/\/ \u5047\u8bbe\u6211\u4eec\u5e0c\u671b\u5b9e\u73b02\u500d\u901f\u64ad\u653e&#xff0c;\u90a3\u4e48\u6211\u4eec\u9700\u8981\u5c06\u65f6\u95f4\u6233\u51cf\u534a<br \/>\nuint32_t newTimestamp &#061; currentTimestamp \/ 2;<\/p>\n<p>\/\/ \u8bbe\u7f6e\u65b0\u7684\u65f6\u95f4\u6233<br \/>\nrtpPacket.setTimestamp(newTimestamp); <\/p>\n<p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d&#xff0c;\u6211\u4eec\u9996\u5148\u83b7\u53d6\u4e86RTP\u5305\u7684\u5f53\u524d\u65f6\u95f4\u6233&#xff0c;\u7136\u540e\u5c06\u5176\u51cf\u534a&#xff0c;\u6700\u540e\u8bbe\u7f6e\u4e86\u65b0\u7684\u65f6\u95f4\u6233\u3002\u8fd9\u6837&#xff0c;\u5f53\u8fd9\u4e2aRTP\u5305\u88ab\u53d1\u9001\u51fa\u53bb\u65f6&#xff0c;\u5b83\u5c31\u4f1a\u5728\u64ad\u653e\u65f6\u88ab\u5feb\u901f\u5730\u663e\u793a\u51fa\u6765&#xff0c;\u4ece\u800c\u5b9e\u73b02\u500d\u901f\u64ad\u653e\u7684\u6548\u679c\u3002<\/p>\n<p>\u8bf7\u6ce8\u610f&#xff0c;\u8fd9\u53ea\u662f\u4e00\u4e2a\u975e\u5e38\u57fa\u7840\u7684\u793a\u4f8b&#xff0c;\u5b9e\u9645\u7684\u5b9e\u73b0\u53ef\u80fd\u4f1a\u6d89\u53ca\u5230\u66f4\u591a\u7684\u7ec6\u8282&#xff0c;\u4f8b\u5982\u5982\u4f55\u5904\u7406\u5e27\u7684\u4f9d\u8d56\u5173\u7cfb&#xff0c;\u5982\u4f55\u786e\u4fdd\u97f3\u89c6\u9891\u540c\u6b65\u7b49\u3002\u4f60\u53ef\u80fd\u9700\u8981\u6839\u636e\u4f60\u7684\u5177\u4f53\u9700\u6c42\u548c\u73af\u5883\u6765\u8c03\u6574\u8fd9\u4e2a\u793a\u4f8b\u3002<\/p>\n<h3>7.3 \u500d\u901f\u64ad\u653e\u7684\u5e94\u7528\u4e0e\u4f18\u5316&#xff08;Application and Optimization of Speed-up Playback&#xff09;<\/h3>\n<p>\u500d\u901f\u64ad\u653e\u7684\u5e94\u7528\u573a\u666f\u975e\u5e38\u5e7f\u6cdb&#xff0c;\u4f8b\u5982\u5728\u6559\u80b2\u9886\u57df&#xff0c;\u5b66\u751f\u53ef\u4ee5\u901a\u8fc7\u500d\u901f\u64ad\u653e\u6765\u5feb\u901f\u6d4f\u89c8\u8bfe\u7a0b\u5185\u5bb9&#xff1b;\u5728\u5a31\u4e50\u9886\u57df&#xff0c;\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u500d\u901f\u64ad\u653e\u6765\u8282\u7701\u89c2\u770b\u89c6\u9891\u7684\u65f6\u95f4\u3002\u7136\u800c&#xff0c;\u5c3d\u7ba1\u500d\u901f\u64ad\u653e\u770b\u4f3c\u7b80\u5355&#xff0c;\u4f46\u5728\u5b9e\u9645\u5e94\u7528\u4e2d&#xff0c;\u6211\u4eec\u8fd8\u9700\u8981\u8003\u8651\u5f88\u591a\u4f18\u5316\u7b56\u7565\u3002<\/p>\n<p>\u9996\u5148&#xff0c;\u6211\u4eec\u9700\u8981\u8003\u8651\u97f3\u9891\u7684\u5904\u7406\u3002\u5728\u89c6\u9891\u64ad\u653e\u4e2d&#xff0c;\u97f3\u9891\u548c\u89c6\u9891\u662f\u9700\u8981\u540c\u6b65\u7684\u3002\u5f53\u6211\u4eec\u6539\u53d8\u89c6\u9891\u7684\u64ad\u653e\u901f\u5ea6\u65f6&#xff0c;\u97f3\u9891\u7684\u64ad\u653e\u901f\u5ea6\u4e5f\u9700\u8981\u76f8\u5e94\u5730\u6539\u53d8\u3002\u7136\u800c&#xff0c;\u76f4\u63a5\u6539\u53d8\u97f3\u9891\u7684\u64ad\u653e\u901f\u5ea6\u53ef\u80fd\u4f1a\u5bfc\u81f4\u97f3\u9891\u7684\u53d8\u8c03&#xff0c;\u5f71\u54cd\u7528\u6237\u7684\u542c\u89c9\u4f53\u9a8c\u3002\u56e0\u6b64&#xff0c;\u6211\u4eec\u9700\u8981\u91c7\u7528\u4e00\u4e9b\u6280\u672f&#xff0c;\u4f8b\u5982\u65f6\u57df\u97f3\u9ad8\u7f29\u653e&#xff08;Time-Domain Pitch Scaling&#xff0c;TDPS&#xff09;\u6216\u9891\u57df\u97f3\u9ad8\u7f29\u653e&#xff08;Frequency-Domain Pitch Scaling&#xff0c;FDPS&#xff09;\u6765\u4fdd\u6301\u97f3\u9891\u7684\u97f3\u9ad8\u4e0d\u53d8\u3002<\/p>\n<p>\u5176\u6b21&#xff0c;\u6211\u4eec\u9700\u8981\u8003\u8651\u5e27\u7387\u7684\u95ee\u9898\u3002\u5728\u500d\u901f\u64ad\u653e\u4e2d&#xff0c;\u5982\u679c\u6211\u4eec\u7b80\u5355\u5730\u589e\u52a0\u5e27\u7387&#xff0c;\u53ef\u80fd\u4f1a\u5bfc\u81f4\u89c6\u9891\u7684\u4e22\u5e27&#xff0c;\u5f71\u54cd\u89c6\u9891\u7684\u6d41\u7545\u5ea6\u3002\u56e0\u6b64&#xff0c;\u6211\u4eec\u9700\u8981\u91c7\u7528\u4e00\u4e9b\u6280\u672f&#xff0c;\u4f8b\u5982\u5e27\u63d2\u503c&#xff08;Frame Interpolation&#xff09;\u6765\u751f\u6210\u4e2d\u95f4\u5e27&#xff0c;\u4fdd\u6301\u89c6\u9891\u7684\u6d41\u7545\u5ea6\u3002<\/p>\n<p>\u6700\u540e&#xff0c;\u6211\u4eec\u9700\u8981\u8003\u8651\u7528\u6237\u4f53\u9a8c\u3002\u5728\u5b9e\u73b0\u500d\u901f\u64ad\u653e\u7684\u529f\u80fd\u65f6&#xff0c;\u6211\u4eec\u9700\u8981\u63d0\u4f9b\u4e00\u4e2a\u7b80\u5355\u6613\u7528\u7684\u7528\u6237\u754c\u9762&#xff0c;\u8ba9\u7528\u6237\u53ef\u4ee5\u65b9\u4fbf\u5730\u8c03\u6574\u64ad\u653e\u901f\u5ea6\u3002\u6b64\u5916&#xff0c;\u6211\u4eec\u8fd8\u9700\u8981\u63d0\u4f9b\u4e00\u4e9b\u989d\u5916\u7684\u529f\u80fd&#xff0c;\u4f8b\u5982\u5feb\u8fdb\u3001\u5feb\u9000\u3001\u6682\u505c\u7b49&#xff0c;\u4ee5\u6ee1\u8db3\u7528\u6237\u7684\u4e0d\u540c\u9700\u6c42\u3002<\/p>\n<p>\u603b\u7684\u6765\u8bf4&#xff0c;\u5b9e\u73b0\u4e00\u4e2a\u4f18\u79c0\u7684\u500d\u901f\u64ad\u653e\u529f\u80fd&#xff0c;\u9700\u8981\u6211\u4eec\u4ece\u591a\u4e2a\u89d2\u5ea6\u8fdb\u884c\u8003\u8651\u548c\u4f18\u5316\u3002\u53ea\u6709\u8fd9\u6837&#xff0c;\u6211\u4eec\u624d\u80fd\u63d0\u4f9b\u4e00\u4e2a\u65e2\u529f\u80fd\u5f3a\u5927&#xff0c;\u53c8\u6613\u4e8e\u4f7f\u7528\u7684RTSP\u670d\u52a1\u5668\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.1k\u6b21\uff0c\u70b9\u8d5e19\u6b21\uff0c\u6536\u85cf19\u6b21\u3002UsageEnvironment\u7c7b\uff1a\u8fd9\u662f\u4e00\u4e2a\u62bd\u8c61\u57fa\u7c7b\uff0c\u7528\u4e8e\u5b9a\u4e49\u4e8b\u4ef6\u5faa\u73af\u3002\u4f60\u53ef\u80fd\u4f1a\u4f7f\u7528\u5230\u5b83\u7684taskScheduler()\u65b9\u6cd5\u6765\u83b7\u53d6\u4efb\u52a1\u8c03\u5ea6\u5668\u3002BasicUsageEnvironment\u7c7b\uff1a\u8fd9\u662fUsageEnvironment\u7684\u4e00\u4e2a\u5177\u4f53\u5b9e\u73b0\uff0c\u4f60\u53ef\u80fd\u4f1a\u4f7f\u7528\u5b83\u7684createNew()\u65b9\u6cd5\u6765\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u73af\u5883\u3002RTSPServer\u7c7b\uff1a\u8fd9\u4e2a\u7c7b\u7528\u4e8e\u521b\u5efa\u548c\u7ba1\u7406RTSP\u670d\u52a1\u5668\u3002_live555 rtsp\u670d\u52a1\u5668<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55,190,43],"topic":[],"class_list":["post-23310","post","type-post","status-publish","format-standard","hentry","category-server","tag-c","tag-190","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C++\u4e0eLive555\u5b9e\u73b0RTSP\u670d\u52a1\u5668 - \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\/23310.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C++\u4e0eLive555\u5b9e\u73b0RTSP\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.1k\u6b21\uff0c\u70b9\u8d5e19\u6b21\uff0c\u6536\u85cf19\u6b21\u3002UsageEnvironment\u7c7b\uff1a\u8fd9\u662f\u4e00\u4e2a\u62bd\u8c61\u57fa\u7c7b\uff0c\u7528\u4e8e\u5b9a\u4e49\u4e8b\u4ef6\u5faa\u73af\u3002\u4f60\u53ef\u80fd\u4f1a\u4f7f\u7528\u5230\u5b83\u7684taskScheduler()\u65b9\u6cd5\u6765\u83b7\u53d6\u4efb\u52a1\u8c03\u5ea6\u5668\u3002BasicUsageEnvironment\u7c7b\uff1a\u8fd9\u662fUsageEnvironment\u7684\u4e00\u4e2a\u5177\u4f53\u5b9e\u73b0\uff0c\u4f60\u53ef\u80fd\u4f1a\u4f7f\u7528\u5b83\u7684createNew()\u65b9\u6cd5\u6765\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u73af\u5883\u3002RTSPServer\u7c7b\uff1a\u8fd9\u4e2a\u7c7b\u7528\u4e8e\u521b\u5efa\u548c\u7ba1\u7406RTSP\u670d\u52a1\u5668\u3002_live555 rtsp\u670d\u52a1\u5668\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/23310.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-18T23:32:00+00:00\" \/>\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=\"19 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/23310.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/23310.html\",\"name\":\"C++\u4e0eLive555\u5b9e\u73b0RTSP\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T23:32:00+00:00\",\"dateModified\":\"2025-04-18T23:32:00+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/23310.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/23310.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/23310.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C++\u4e0eLive555\u5b9e\u73b0RTSP\u670d\u52a1\u5668\"}]},{\"@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":"C++\u4e0eLive555\u5b9e\u73b0RTSP\u670d\u52a1\u5668 - \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\/23310.html","og_locale":"zh_CN","og_type":"article","og_title":"C++\u4e0eLive555\u5b9e\u73b0RTSP\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.1k\u6b21\uff0c\u70b9\u8d5e19\u6b21\uff0c\u6536\u85cf19\u6b21\u3002UsageEnvironment\u7c7b\uff1a\u8fd9\u662f\u4e00\u4e2a\u62bd\u8c61\u57fa\u7c7b\uff0c\u7528\u4e8e\u5b9a\u4e49\u4e8b\u4ef6\u5faa\u73af\u3002\u4f60\u53ef\u80fd\u4f1a\u4f7f\u7528\u5230\u5b83\u7684taskScheduler()\u65b9\u6cd5\u6765\u83b7\u53d6\u4efb\u52a1\u8c03\u5ea6\u5668\u3002BasicUsageEnvironment\u7c7b\uff1a\u8fd9\u662fUsageEnvironment\u7684\u4e00\u4e2a\u5177\u4f53\u5b9e\u73b0\uff0c\u4f60\u53ef\u80fd\u4f1a\u4f7f\u7528\u5b83\u7684createNew()\u65b9\u6cd5\u6765\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u73af\u5883\u3002RTSPServer\u7c7b\uff1a\u8fd9\u4e2a\u7c7b\u7528\u4e8e\u521b\u5efa\u548c\u7ba1\u7406RTSP\u670d\u52a1\u5668\u3002_live555 rtsp\u670d\u52a1\u5668","og_url":"https:\/\/www.wsisp.com\/helps\/23310.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T23:32:00+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"19 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/23310.html","url":"https:\/\/www.wsisp.com\/helps\/23310.html","name":"C++\u4e0eLive555\u5b9e\u73b0RTSP\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T23:32:00+00:00","dateModified":"2025-04-18T23:32:00+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/23310.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/23310.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/23310.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"C++\u4e0eLive555\u5b9e\u73b0RTSP\u670d\u52a1\u5668"}]},{"@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\/23310","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=23310"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/23310\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=23310"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=23310"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=23310"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=23310"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}