{"id":618,"date":"2019-04-18T18:40:27","date_gmt":"2019-04-18T10:40:27","guid":{"rendered":"http:\/\/blog.peergine.com\/?p=618"},"modified":"2019-04-30T10:12:46","modified_gmt":"2019-04-30T02:12:46","slug":"%e7%9b%b4%e6%92%ad%e6%a8%a1%e5%9d%97%e6%92%ad%e6%94%be%e7%ab%af%e5%90%8e%e5%8f%b0%e5%89%8d%e5%8f%b0%e5%88%87%e6%8d%a2%e5%a4%84%e7%90%86","status":"publish","type":"post","link":"http:\/\/blog.peergine.com\/?p=618","title":{"rendered":"\u76f4\u64ad\u6a21\u5757\u64ad\u653e\u7aef\u540e\u53f0\u524d\u53f0\u5207\u6362\u5904\u7406"},"content":{"rendered":"<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=618\/#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\" >1.\u9501\u5c4f\u540e\u5982\u679c\u88ab\u7cfb\u7edf\u6e05\u7406\u5185\u5b58\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=618\/#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=618\/#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><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\"><\/span>1.\u9501\u5c4f\u540e\u5982\u679c\u88ab\u7cfb\u7edf\u6e05\u7406\u5185\u5b58\u4e86.<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\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<p>@Override<\/p>\n<p>protected void onDestroy() {<\/p>\n<p>LiveLogout();<\/p>\n<p>super.onDestroy();<\/p>\n<p>}<\/p>\n<p>private void LiveLogout() {<\/p>\n<p>LiveDisconnect();<\/p>\n<p>if (m_Wnd != null) {<\/p>\n<p>m_View.removeView(m_Wnd);<\/p>\n<p>pgLibLiveMultiView.Release(m_Wnd);<\/p>\n<p>m_View = null;<\/p>\n<p>m_Wnd = null;<\/p>\n<p>m_Live.Clean();<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<h2><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<p>\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<p>public int count = 0;<\/p>\n<p>@Override<\/p>\n<p>protected void onResume() {<\/p>\n<p>if (count == 0) {<\/p>\n<p>\/\/Log.v(TAG, &#8220;\u5207\u5230\u524d\u53f0&#8221;);<\/p>\n<p>Toast.makeText(MainActivity.this, &#8220;\u5207\u5230\u524d\u53f0&#8221;, Toast.LENGTH_SHORT).show();<\/p>\n<p>if(m_bLogin) {<\/p>\n<p>m_Live.Connect(m_sDevID);<\/p>\n<p>m_Live.VideoStart(m_sDevID, 0, &#8220;&#8221;, m_Wnd);<\/p>\n<p>}else{<\/p>\n<p>String sInfo = &#8220;\u56e0\u4e3a\u540e\u53f0\u653e\u7f6e\u592a\u4e45\u5bfc\u81f4\u6389\u7ebf\uff0c\u8bf7\u7b49\u5f85\u64ad\u653e\u7aef\u91cd\u65b0\u4e0a\u7ebf&#8221;;<\/p>\n<p>Toast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>count++;<\/p>\n<p>super.onResume();<\/p>\n<p>}<\/p>\n<p>@Override<\/p>\n<p>protected void onPause() {<\/p>\n<p>count&#8211;;<\/p>\n<p>if (count == 0) {<\/p>\n<p>Toast.makeText(MainActivity.this, &#8220;\u5207\u5230\u540e\u53f0&#8221;, Toast.LENGTH_SHORT).show();<\/p>\n<p>m_Live.VideoStop(m_sDevID,0);<\/p>\n<p>m_Live.Disconnect(m_sDevID);<\/p>\n<p>}<\/p>\n<p>super.onPause();<\/p>\n<p>}<\/p>\n<h2><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<p>private boolean m_bLogin = false;<\/p>\n<p>private pgLibLive.OnEventListener m_OnEvent = new pgLibLive.OnEventListener() {<\/p>\n<p>@Override<\/p>\n<p>public void event(String sAct, String sData, String sRender) {<\/p>\n<p>\/\/ TODO Auto-generated method stub<\/p>\n<p>if (sAct.equals(&#8220;VideoStatus&#8221;)) {<\/p>\n<p>\/\/ Video status report<\/p>\n<p>}<\/p>\n<p>else if (sAct.equals(&#8220;Notify&#8221;)) {<\/p>\n<p>\/\/ Receive the notify from capture side<\/p>\n<p>String sInfo = &#8220;Receive notify: data=&#8221; + sData;<\/p>\n<p>Toast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();<\/p>\n<p>}<\/p>\n<p>else if (sAct.equals(&#8220;RenderJoin&#8221;)) {<\/p>\n<p>\/\/ A render join<\/p>\n<p>String sInfo = &#8220;Render join: render=&#8221; + sRender;<\/p>\n<p>Toast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();<\/p>\n<p>}<\/p>\n<p>else if (sAct.equals(&#8220;RenderLeave&#8221;)) {<\/p>\n<p>\/\/ A render leave<\/p>\n<p>String sInfo = &#8220;Render leave: render=&#8221; + sRender;<\/p>\n<p>Toast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();<\/p>\n<p>}<\/p>\n<p>else if (sAct.equals(&#8220;Message&#8221;)) {<\/p>\n<p>\/\/ Receive the message from render or capture<\/p>\n<p>String sInfo = &#8220;Receive msg: data=&#8221; + sData + &#8220;, render=&#8221; + sRender;<\/p>\n<p>Toast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();<\/p>\n<p>}<\/p>\n<p>else if (sAct.equals(&#8220;Login&#8221;)) {<\/p>\n<p>\/\/ Login reply<\/p>\n<p>if (sData.equals(&#8220;0&#8221;)) {<\/p>\n<p>String sInfo = &#8220;Login success&#8221;;<\/p>\n<p>Toast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();<\/p>\n<p>m_bLogin = true;<\/p>\n<p>}<\/p>\n<p>else {<\/p>\n<p>String sInfo = &#8220;Login failed, error=&#8221; + sData;<\/p>\n<p>Toast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();<\/p>\n<p>m_bLogin = false;<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>else if (sAct.equals(&#8220;Logout&#8221;)) {<\/p>\n<p>\/\/ Logout<\/p>\n<p>String sInfo = &#8220;Logout&#8221;;<\/p>\n<p>Toast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();<\/p>\n<p>m_bLogin = false;<\/p>\n<p>}<\/p>\n<p>else if (sAct.equals(&#8220;Connect&#8221;)) {<\/p>\n<p>\/\/ Connect to capture<\/p>\n<p>String sInfo = &#8220;Connect to capture&#8221;;<\/p>\n<p>Toast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();<\/p>\n<p>}<\/p>\n<p>else if (sAct.equals(&#8220;Disconnect&#8221;)) {<\/p>\n<p>\/\/ Disconnect from capture<\/p>\n<p>String sInfo = &#8220;Disconnect from capture&#8221;;<\/p>\n<p>Toast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();<\/p>\n<p>}<\/p>\n<p>else if (sAct.equals(&#8220;Reject&#8221;)) {<\/p>\n<p>String sInfo = &#8220;Reject by capture&#8221;;<\/p>\n<p>Toast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();<\/p>\n<p>m_bLogin = false;<\/p>\n<p>}<\/p>\n<p>else if (sAct.equals(&#8220;Offline&#8221;)) {<\/p>\n<p>\/\/ The capture is offline.<\/p>\n<p>String sInfo = &#8220;Capture offline&#8221;;<\/p>\n<p>Toast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();<\/p>\n<p>m_bLogin = false;<\/p>\n<p>}<\/p>\n<p>else if (sAct.equals(&#8220;LanScanResult&#8221;)) {<\/p>\n<p>\/\/ Lan scan result.<\/p>\n<p>String sInfo = &#8220;Lan scan result: &#8221; + sData;<\/p>\n<p>Toast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();<\/p>\n<p>m_sTransferInfo.setText(sData);<\/p>\n<p>}<\/p>\n<p>else if (sAct.equals(&#8220;ForwardAllocReply&#8221;)) {<\/p>\n<p>String sInfo = &#8220;Forward alloc relpy: error=&#8221; + sData;<\/p>\n<p>Toast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();<\/p>\n<p>}<\/p>\n<p>else if (sAct.equals(&#8220;ForwardFreeReply&#8221;)) {<\/p>\n<p>String sInfo = &#8220;Forward free relpy: error=&#8221; + sData;<\/p>\n<p>Toast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();<\/p>\n<p>}<\/p>\n<p>else if (sAct.equals(&#8220;VideoCamera&#8221;)) {<\/p>\n<p>String sInfo = &#8220;The picture is save to: &#8221; + sData;<\/p>\n<p>Toast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();<\/p>\n<p>}<\/p>\n<p>else if (sAct.equals(&#8220;FileAccept&#8221;)) {<\/p>\n<p>String sInfo = &#8220;File accept: &#8221; + sData;<\/p>\n<p>Toast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();<\/p>\n<p>}<\/p>\n<p>else if (sAct.equals(&#8220;FileReject&#8221;)) {<\/p>\n<p>FileReject();<\/p>\n<p>}<\/p>\n<p>else if (sAct.equals(&#8220;FileAbort&#8221;)) {<\/p>\n<p>\/\/ \u53d6\u6d88 \u4e0a\u4f20\u6216 \u4e0b\u8f7d<\/p>\n<p>FileAbort();<\/p>\n<p>}<\/p>\n<p>else if (sAct.equals(&#8220;FileFinish&#8221;)) {\/\/ \u6587\u4ef6\u4f20\u8f93\u5b8c\u6bd5<\/p>\n<p>FileFinish();<\/p>\n<p>}<\/p>\n<p>else if (sAct.equals(&#8220;FileProgress&#8221;)) {<\/p>\n<p>FileProgress(sData);<\/p>\n<p>}<\/p>\n<p>else if (sAct.equals(&#8220;SvrNotify&#8221;)) {<\/p>\n<p>String sInfo = &#8220;Receive server notify: &#8221; + sData;<\/p>\n<p>Toast.makeText(MainActivity.this, sInfo, Toast.LENGTH_SHORT).show();<\/p>\n<p>}<\/p>\n<p>Log.d(&#8220;pgLiveRender&#8221;, &#8220;OnEvent: Act=&#8221; + sAct + &#8220;, Data=&#8221; + sData<\/p>\n<p>+ &#8220;, Render=&#8221; + sRender);<\/p>\n<p>}<\/p>\n<p>};<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.\u9501\u5c4f\u540e\u5982\u679c\u88ab\u7cfb\u7edf\u6e05\u7406\u5185\u5b58\u4e86. \u60a8\u9700\u8981\u5728\u5e94\u7528\u9500\u6bc1\u56de\u8c03\u91cc\u9762\u624b\u52a8videoStop\uff0c\u5e76\u4e14Clean\u6389\u5b9e&hellip; <a href=\"http:\/\/blog.peergine.com\/?p=618\" class=\"more-link read-more\" rel=\"bookmark\">\u7ee7\u7eed\u9605\u8bfb <span class=\"screen-reader-text\">\u76f4\u64ad\u6a21\u5757\u64ad\u653e\u7aef\u540e\u53f0\u524d\u53f0\u5207\u6362\u5904\u7406<\/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":[17,5,21],"tags":[],"class_list":["post-618","post","type-post","status-publish","format-standard","hentry","category-p2psdk","category-sdk","category-21","h-entry","h-as-article"],"views":2613,"_links":{"self":[{"href":"http:\/\/blog.peergine.com\/index.php?rest_route=\/wp\/v2\/posts\/618","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=618"}],"version-history":[{"count":3,"href":"http:\/\/blog.peergine.com\/index.php?rest_route=\/wp\/v2\/posts\/618\/revisions"}],"predecessor-version":[{"id":634,"href":"http:\/\/blog.peergine.com\/index.php?rest_route=\/wp\/v2\/posts\/618\/revisions\/634"}],"wp:attachment":[{"href":"http:\/\/blog.peergine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.peergine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=618"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.peergine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}