{"id":631,"date":"2019-07-25T20:31:09","date_gmt":"2019-07-25T12:31:09","guid":{"rendered":"http:\/\/blog.peergine.com\/?p=631"},"modified":"2019-07-25T20:31:11","modified_gmt":"2019-07-25T12:31:11","slug":"p2p%e7%9b%b4%e6%92%ad%e6%a8%a1%e5%9d%97%ef%bc%88pgliblivemulti%ef%bc%89%e5%ae%89%e5%8d%93%e7%ab%af%e7%bc%96%e7%a8%8b%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a1%b9%e3%80%82","status":"publish","type":"post","link":"http:\/\/blog.peergine.com\/?p=631","title":{"rendered":"P2P\u76f4\u64ad\u6a21\u5757\uff08pgLibLiveMulti\uff09\u5b89\u5353\u7aef\u7f16\u7a0b\u6ce8\u610f\u4e8b\u9879\u3002"},"content":{"rendered":"\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_89 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\r\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"http:\/\/blog.peergine.com\/?p=631\/#1%E9%94%81%E5%B1%8F%E5%90%8E%E5%A6%82%E6%9E%9C%E8%A2%AB%E7%B3%BB%E7%BB%9F%E6%B8%85%E7%90%86%E5%86%85%E5%AD%98%E4%BA%86%E5%BA%94%E7%94%A8%E4%B9%9F%E5%B0%B1%E6%B2%A1%E6%9C%89%E4%BA%86\" >1.\u9501\u5c4f\u540e\u5982\u679c\u88ab\u7cfb\u7edf\u6e05\u7406\u5185\u5b58\u4e86\u5e94\u7528\u4e5f\u5c31\u6ca1\u6709\u4e86.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"http:\/\/blog.peergine.com\/?p=631\/#2%E5%A6%82%E6%9E%9C%E7%A8%8B%E5%BA%8F%E6%B2%A1%E8%A2%AB%E7%B3%BB%E7%BB%9F%E6%B8%85%E7%90%86%E5%BC%BA%E5%88%B6%E9%80%80%E5%87%BA\" >2.\u5982\u679c\u7a0b\u5e8f\u6ca1\u88ab\u7cfb\u7edf\u6e05\u7406\u5f3a\u5236\u9000\u51fa.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"http:\/\/blog.peergine.com\/?p=631\/#3_m_bLogin%E6%A0%87%E5%BF%97%E4%BD%8D%E8%AE%BE%E7%BD%AE\" >3. m_bLogin\u6807\u5fd7\u4f4d\u8bbe\u7f6e<\/a><\/li><\/ul><\/nav><\/div>\r\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1%E9%94%81%E5%B1%8F%E5%90%8E%E5%A6%82%E6%9E%9C%E8%A2%AB%E7%B3%BB%E7%BB%9F%E6%B8%85%E7%90%86%E5%86%85%E5%AD%98%E4%BA%86%E5%BA%94%E7%94%A8%E4%B9%9F%E5%B0%B1%E6%B2%A1%E6%9C%89%E4%BA%86\"><\/span>1.\u9501\u5c4f\u540e\u5982\u679c\u88ab\u7cfb\u7edf\u6e05\u7406\u5185\u5b58\u4e86\u5e94\u7528\u4e5f\u5c31\u6ca1\u6709\u4e86.<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u60a8\u9700\u8981\u5728\u5e94\u7528\u9500\u6bc1\u56de\u8c03\u91cc\u9762\u624b\u52a8videoStop\uff0c\u5e76\u4e14Clean\u6389\u5b9e\u4f8b\u3002\u8fd9\u6837\u505a\u662f\u9632\u6b62\u4e0b\u6b21\u767b\u5f55\u65f6\u53ef\u80fd\u767b\u5f55\u65f6\u95f4\u592a\u4e45\uff0c\u56e0\u4e3a\u670d\u52a1\u5668\u6709\u9000\u907f\u673a\u5236\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Override\nprotected void onDestroy() {\n\n\tLiveLogout();\n\n\tsuper.onDestroy();\n\n}\n\nprivate void LiveLogout() {\n\n\tLiveDisconnect();\n\n\tif (m_Wnd != null) {\n\n\t\tm_View.removeView(m_Wnd);\n\n\t\tpgLibLiveMultiView.Release(m_Wnd);\n\n\t\tm_View = null;\n\n\t\tm_Wnd = null;\n\n\t\tm_Live.Clean();\n\n\t}\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2%E5%A6%82%E6%9E%9C%E7%A8%8B%E5%BA%8F%E6%B2%A1%E8%A2%AB%E7%B3%BB%E7%BB%9F%E6%B8%85%E7%90%86%E5%BC%BA%E5%88%B6%E9%80%80%E5%87%BA\"><\/span>2.\u5982\u679c\u7a0b\u5e8f\u6ca1\u88ab\u7cfb\u7edf\u6e05\u7406\u5f3a\u5236\u9000\u51fa.<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u9000\u51fa\u5230\u540e\u53f0\u65f6\u76f4\u63a5disConnect\uff0cvideoStart\u3002\u5230\u524d\u53f0\u65f6\u5982\u679c\u64ad\u653e\u7aef\u8fd8\u5728\u7ebf\u5c31\u76f4\u63a5Connect \u5e76videostart\uff0c\u5982\u679c\u64ad\u653e\u7aef\u4e0d\u5728\u7ebf\u4e86\u5c31\u7b49\u5f85\u91cd\u65b0\u4e0a\u7ebf\u3002\u6b64\u65f6\u5982\u679c\u60f3\u8981\u9a6c\u4e0a\u767b\u5f55\u4e0a\u7ebf\uff0c\u9700\u8981\u624b\u52a8m_Live.Clean \u5e76 \u91cd\u65b0\u8c03\u7528\u521d\u59cb\u5316\u51fd\u6570\u767b\u5f55 \uff0c\u767b\u5f55\u6210\u529f\u540e\u518d\u6253\u5f00\u89c6\u9891\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public int count = 0;\n@Override\nprotected void onResume() {\n    if (count == 0) {\n\n        \/\/Log.v(TAG, \"\u5207\u5230\u524d\u53f0\");\n        Toast.makeText(MainActivity.this, \"\u5207\u5230\u524d\u53f0\", Toast.LENGTH_SHORT).show();\n        if (m_bLogin) {\n            m_Live.Connect(m_sDevID);\n\n            m_Live.VideoStart(m_sDevID, 0, \"\", m_Wnd);\n\n        } else {\n\n            String sInfo = \"\u56e0\u4e3a\u540e\u53f0\u653e\u7f6e\u592a\u4e45\u5bfc\u81f4\u6389\u7ebf\uff0c\u8bf7\u7b49\u5f85\u64ad\u653e\u7aef\u91cd\u65b0\u4e0a\u7ebf\";\n            Toast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();\n        }\n    }\n    count++;\n    super.onResume();\n}\n\n@Override\nprotected void onPause() {\n\n    count--;\n    if (count == 0) {\n        Toast.makeText(MainActivity.this, \"\u5207\u5230\u540e\u53f0\", Toast.LENGTH_SHORT).show();\n        m_Live.VideoStop(m_sDevID, 0);\n        m_Live.Disconnect(m_sDevID);\n    }\n    super.onPause();\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_m_bLogin%E6%A0%87%E5%BF%97%E4%BD%8D%E8%AE%BE%E7%BD%AE\"><\/span>3. m_bLogin\u6807\u5fd7\u4f4d\u8bbe\u7f6e<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>private boolean m_bLogin = false;\nprivate pgLibLive.OnEventListener m_OnEvent = new pgLibLive.OnEventListener() { \n \n@Override \n\npublic void event(String sAct, String sData, String sRender) { \n \n\t\/\/ TODO Auto-generated method stub \n\t \n\tif (sAct.equals(\"VideoStatus\")) { \n\t \n\t\t\/\/ Video status report \n\t \n\t}  \n\telse if (sAct.equals(\"Notify\")) { \n\t \n\t\t\/\/ Receive the notify from capture side  \n\t\tString sInfo = \"Receive notify: data=\" + sData;  \n\t\tToast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();  \n\t}  \n\telse if (sAct.equals(\"RenderJoin\")) {  \n\t\t\/\/ A render join  \n\t\tString sInfo = \"Render join: render=\" + sRender;  \n\t\tToast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();  \n\t}  \n\telse if (sAct.equals(\"RenderLeave\")) {  \n\t\t\/\/ A render leave \n\t\tString sInfo = \"Render leave: render=\" + sRender;\n\t\tToast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();\n\t}\n\telse if (sAct.equals(\"Message\")) {\n\t\t\/\/ Receive the message from render or capture\n\t\tString sInfo = \"Receive msg: data=\" + sData + \", render=\" + sRender;\n\t\tToast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();\n\t}\n\telse if (sAct.equals(\"Login\")) {\n\t\t\/\/ Login reply\n\t\tif (sData.equals(\"0\")) {\n\t\tString sInfo = \"Login success\";\n\t\tToast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();\n\t\tm_bLogin = true;\n\t\t}\n\t\telse {\n\t\tString sInfo = \"Login failed, error=\" + sData;\n\t\tToast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();\n\t\tm_bLogin = false;\n\t\t}\n\t}\n\telse if (sAct.equals(\"Logout\")) {\n\t\t\/\/ Logout\n\t\tString sInfo = \"Logout\";\n\t\tToast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();\n\t\tm_bLogin = false;\n\t}\n\telse if (sAct.equals(\"Connect\")) {\n\t\t\/\/ Connect to capture\n\t\tString sInfo = \"Connect to capture\";\n\t\tToast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();\n\t}\n\telse if (sAct.equals(\"Disconnect\")) {\n\t\t\/\/ Disconnect from capture\n\t\tString sInfo = \"Disconnect from capture\";\n\t\tToast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();\n\t}\n\telse if (sAct.equals(\"Reject\")) {\n\t\tString sInfo = \"Reject by capture\";\n\t\tToast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();\n\t\tm_bLogin = false;\n\t}\n\telse if (sAct.equals(\"Offline\")) {\n\t\t\/\/ The capture is offline.\n\t\tString sInfo = \"Capture offline\";\n\t\tToast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();\n\t\tm_bLogin = false;\n\t}\n\telse if (sAct.equals(\"LanScanResult\")) {\n\t\t\/\/ Lan scan result.\n\t\tString sInfo = \"Lan scan result: \" + sData;\n\t\tToast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();\n\t\tm_sTransferInfo.setText(sData);\n\t}\n\telse if (sAct.equals(\"ForwardAllocReply\")) {\n\t\tString sInfo = \"Forward alloc relpy: error=\" + sData;\n\t\tToast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();\n\t}\n\telse if (sAct.equals(\"ForwardFreeReply\")) {\n\t\tString sInfo = \"Forward free relpy: error=\" + sData;\n\t\tToast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();\n\t}\n\telse if (sAct.equals(\"VideoCamera\")) {\n\t\tString sInfo = \"The picture is save to: \" + sData;\n\t\tToast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();\n\t}\n\telse if (sAct.equals(\"FileAccept\")) {\n\t\tString sInfo = \"File accept: \" + sData;\n\t\tToast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();\n\t}\n\telse if (sAct.equals(\"FileReject\")) {\n\t\tFileReject();\n\t}\n\telse if (sAct.equals(\"FileAbort\")) {\n\t\t\/\/ \u53d6\u6d88 \u4e0a\u4f20\u6216 \u4e0b\u8f7d\n\t\tFileAbort();\n\t}\n\telse if (sAct.equals(\"FileFinish\")) {\/\/ \u6587\u4ef6\u4f20\u8f93\u5b8c\u6bd5\n\t\tFileFinish();\n\t}\n\telse if (sAct.equals(\"FileProgress\")) {\n\t\tFileProgress(sData);\n\t}\n\telse if (sAct.equals(\"SvrNotify\")) {\n\t\tString sInfo = \"Receive server notify: \" + sData;\n\t\tToast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();\n\t}\n\t\tLog.d(\"pgLiveRender\", \"OnEvent: Act=\" + sAct + \", Data=\" + sData\n\t\t+ \", Render=\" + sRender);\n\t}\n};<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1.\u9501\u5c4f\u540e\u5982\u679c\u88ab\u7cfb\u7edf\u6e05\u7406\u5185\u5b58\u4e86\u5e94\u7528\u4e5f\u5c31\u6ca1\u6709\u4e86. \u60a8\u9700\u8981\u5728\u5e94\u7528\u9500\u6bc1\u56de\u8c03\u91cc\u9762\u624b\u52a8videoStop\uff0c\u5e76\u4e14&hellip; <a href=\"http:\/\/blog.peergine.com\/?p=631\" class=\"more-link read-more\" rel=\"bookmark\">\u7ee7\u7eed\u9605\u8bfb <span class=\"screen-reader-text\">P2P\u76f4\u64ad\u6a21\u5757\uff08pgLibLiveMulti\uff09\u5b89\u5353\u7aef\u7f16\u7a0b\u6ce8\u610f\u4e8b\u9879\u3002<\/span><i class=\"fa fa-arrow-right\"><\/i><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-631","post","type-post","status-publish","format-standard","hentry","category-sdk","h-entry","h-as-article"],"views":2092,"_links":{"self":[{"href":"http:\/\/blog.peergine.com\/index.php?rest_route=\/wp\/v2\/posts\/631","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.peergine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.peergine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.peergine.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.peergine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=631"}],"version-history":[{"count":1,"href":"http:\/\/blog.peergine.com\/index.php?rest_route=\/wp\/v2\/posts\/631\/revisions"}],"predecessor-version":[{"id":665,"href":"http:\/\/blog.peergine.com\/index.php?rest_route=\/wp\/v2\/posts\/631\/revisions\/665"}],"wp:attachment":[{"href":"http:\/\/blog.peergine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=631"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.peergine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=631"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.peergine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}