From 3f78a9ac8ffd5072ba489f680fc6acbd7438557a Mon Sep 17 00:00:00 2001 From: WangShuo1143368701 <1143368701@qq.com> Date: Tue, 6 Mar 2018 15:15:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=95=9C=E5=83=8F=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 2 +- .../wangshuo/wslive/wslivedemo/LiveUI.java | 42 ++++++++++++++++ .../res/layout/layout_activity_live_ui.xml | 18 +++++++ app/src/main/res/mipmap-xhdpi/live.jpg | Bin 0 -> 52555 bytes app/src/main/res/mipmap-xxhdpi/live.jpg | Bin 0 -> 52555 bytes .../lake/librestreaming/client/RESClient.java | 4 ++ .../librestreaming/client/RESVideoClient.java | 3 ++ .../me/lake/librestreaming/core/GLHelper.java | 46 ++++++++++++++++++ .../librestreaming/core/RESHardVideoCore.java | 37 +++++++++++--- .../librestreaming/core/RESSoftVideoCore.java | 5 ++ .../librestreaming/core/RESVideoCore.java | 2 + .../ws/StreamLiveCameraView.java | 12 +++++ 12 files changed, 163 insertions(+), 8 deletions(-) create mode 100644 app/src/main/res/mipmap-xhdpi/live.jpg create mode 100644 app/src/main/res/mipmap-xxhdpi/live.jpg diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f423621..7e6e263 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -16,7 +16,7 @@ diff --git a/app/src/main/java/com/wangshuo/wslive/wslivedemo/LiveUI.java b/app/src/main/java/com/wangshuo/wslive/wslivedemo/LiveUI.java index 1a634e5..ebc45de 100644 --- a/app/src/main/java/com/wangshuo/wslive/wslivedemo/LiveUI.java +++ b/app/src/main/java/com/wangshuo/wslive/wslivedemo/LiveUI.java @@ -1,9 +1,12 @@ package com.wangshuo.wslive.wslivedemo; +import android.graphics.Bitmap; import android.view.View; import android.widget.Button; +import android.widget.ImageView; import android.widget.Toast; +import me.lake.librestreaming.core.listener.RESScreenShotListener; import me.lake.librestreaming.filter.hardvideofilter.BaseHardVideoFilter; import me.lake.librestreaming.ws.StreamLiveCameraView; import me.lake.librestreaming.ws.filter.hardfilter.FishEyeFilterHard; @@ -20,6 +23,7 @@ public class LiveUI implements View.OnClickListener { private StreamLiveCameraView liveCameraView; private String rtmpUrl = ""; boolean isFilter = false; + boolean isMirror = false; private Button btnStartStreaming; private Button btnStopStreaming; @@ -27,6 +31,10 @@ public class LiveUI implements View.OnClickListener { private Button btnStopRecord; private Button btnFliter; private Button btnSwapCamera; + private Button btnScreenshot; + private Button btnMirror; + + private ImageView imageView; public LiveUI(LiveActivity liveActivity , StreamLiveCameraView liveCameraView , String rtmpUrl) { this.activity = liveActivity; @@ -54,6 +62,20 @@ private void init() { btnSwapCamera = (Button) activity.findViewById(R.id.btn_swapCamera); btnSwapCamera.setOnClickListener(this); + + btnScreenshot = (Button) activity.findViewById(R.id.btn_screenshot); + btnScreenshot.setOnClickListener(this); + + btnMirror = (Button) activity.findViewById(R.id.btn_mirror); + btnMirror.setOnClickListener(this); + + imageView = (ImageView) activity.findViewById(R.id.iv_image); + imageView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + imageView.setVisibility(View.GONE); + } + }); } @Override @@ -94,6 +116,26 @@ public void onClick(View view) { case R.id.btn_swapCamera://切换摄像头 liveCameraView.swapCamera(); break; + case R.id.btn_screenshot://截帧 + liveCameraView.takeScreenShot(new RESScreenShotListener() { + @Override + public void onScreenShotResult(Bitmap bitmap) { + if(bitmap != null){ + imageView.setVisibility(View.VISIBLE); + imageView.setImageBitmap(bitmap); + } + + } + }); + break; + case R.id.btn_mirror://镜像 + if(isMirror){ + liveCameraView.setMirror(true,false,false); + }else { + liveCameraView.setMirror(true,true,true); + } + isMirror = !isMirror; + break; default: break; } diff --git a/app/src/main/res/layout/layout_activity_live_ui.xml b/app/src/main/res/layout/layout_activity_live_ui.xml index dc67537..83cc1c5 100644 --- a/app/src/main/res/layout/layout_activity_live_ui.xml +++ b/app/src/main/res/layout/layout_activity_live_ui.xml @@ -24,6 +24,16 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滤镜"/> +