Skip to content

Commit eb87300

Browse files
committed
udpate to v3.2.5
1 parent c0e57c5 commit eb87300

File tree

5 files changed

+98
-14
lines changed

5 files changed

+98
-14
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 3.2.5 - 2024-01-30
2+
封装Camera变焦,对焦,闪光灯接口
3+
14
## 3.2.4 - 2024-01-24
25
优化start stop逻辑
36

NodeMediaClient/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ android {
88
defaultConfig {
99
minSdkVersion 21
1010
targetSdkVersion 33
11-
versionCode 30204
12-
versionName "3.2.4"
11+
versionCode 30205
12+
versionName "3.2.5"
1313
}
1414

1515
buildTypes {
@@ -23,7 +23,7 @@ android {
2323

2424
dependencies {
2525
implementation fileTree(dir: 'libs', include: ['*.jar'])
26-
def camerax_version = "1.3.0"
26+
def camerax_version = "1.3.1"
2727
implementation "androidx.camera:camera-core:${camerax_version}"
2828
implementation "androidx.camera:camera-camera2:${camerax_version}"
2929
implementation "androidx.camera:camera-lifecycle:${camerax_version}"
@@ -40,7 +40,7 @@ afterEvaluate {
4040
from components.release
4141
groupId = 'com.github.NodeMedia'
4242
artifactId = 'NodeMediaClient-Android'
43-
version = '3.2.4'
43+
version = '3.2.5'
4444
}
4545
}
4646
}

NodeMediaClient/src/main/java/cn/nodemedia/NodePlayer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* ©2023 NodeMedia.cn
2+
* ©2024 NodeMedia.cn
33
* <p>
4-
* Copyright © 2015 - 2023 NodeMedia.cn All Rights Reserved.
4+
* Copyright © 2015 - 2024 NodeMedia.cn All Rights Reserved.
55
*/
66

77
package cn.nodemedia;

NodeMediaClient/src/main/java/cn/nodemedia/NodePublisher.java

Lines changed: 88 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* ©2023 NodeMedia
2+
* ©2024 NodeMedia
33
* <p>
4-
* Copyright © 2015 - 2023 NodeMedia.All Rights Reserved.
4+
* Copyright © 2015 - 2024 NodeMedia.All Rights Reserved.
55
*/
66

77
package cn.nodemedia;
@@ -15,16 +15,23 @@
1515
import android.view.ViewGroup;
1616
import android.view.WindowManager;
1717
import android.widget.FrameLayout;
18+
1819
import androidx.annotation.NonNull;
1920
import androidx.camera.core.Camera;
20-
import androidx.camera.core.CameraInfo;
2121
import androidx.camera.core.CameraSelector;
22+
import androidx.camera.core.FocusMeteringAction;
23+
import androidx.camera.core.MeteringPoint;
2224
import androidx.camera.core.Preview;
25+
import androidx.camera.core.SurfaceOrientedMeteringPointFactory;
2326
import androidx.camera.lifecycle.ProcessCameraProvider;
2427
import androidx.core.content.ContextCompat;
2528
import androidx.lifecycle.LifecycleOwner;
29+
2630
import com.google.common.util.concurrent.ListenableFuture;
31+
2732
import java.util.concurrent.ExecutionException;
33+
import java.util.concurrent.TimeUnit;
34+
2835
import javax.microedition.khronos.egl.EGLConfig;
2936
import javax.microedition.khronos.opengles.GL10;
3037

@@ -64,6 +71,21 @@ public class NodePublisher {
6471
public static final int EffectorTextureTypeT2D = 0;
6572
public static final int EffectorTextureTypeEOS = 1;
6673

74+
/**
75+
* 自动对焦
76+
*/
77+
public static final int FLAG_AF = 1;
78+
79+
/**
80+
* 自动曝光
81+
*/
82+
public static final int FLAG_AE = 1 << 1;
83+
84+
/**
85+
* 自动白平衡
86+
*/
87+
public static final int FLAG_AWB = 1 << 2;
88+
6789

6890
private static final String TAG = "NodeMedia.java";
6991
private OnNodePublisherEventListener onNodePublisherEventListener;
@@ -158,8 +180,65 @@ public Camera getCamera() {
158180
return mCamera;
159181
}
160182

161-
public CameraInfo getCameraInfo() {
162-
return mCamera.getCameraInfo();
183+
public float getMinZoomRatio() {
184+
if (mCamera != null && mCamera.getCameraInfo().getZoomState().getValue() != null) {
185+
return mCamera.getCameraInfo().getZoomState().getValue().getMinZoomRatio();
186+
}
187+
return 1.0f;
188+
}
189+
190+
public float getMaxZoomRatio() {
191+
if (mCamera != null && mCamera.getCameraInfo().getZoomState().getValue() != null) {
192+
return mCamera.getCameraInfo().getZoomState().getValue().getMaxZoomRatio();
193+
}
194+
return 1.0f;
195+
}
196+
197+
public float getZoomRatio() {
198+
if (mCamera != null && mCamera.getCameraInfo().getZoomState().getValue() != null) {
199+
return mCamera.getCameraInfo().getZoomState().getValue().getZoomRatio();
200+
}
201+
return 1.0f;
202+
}
203+
204+
public float getLinearZoom() {
205+
if (mCamera != null && mCamera.getCameraInfo().getZoomState().getValue() != null) {
206+
return mCamera.getCameraInfo().getZoomState().getValue().getLinearZoom();
207+
}
208+
return 0.0f;
209+
}
210+
211+
public void setRoomRatio(float ratio) {
212+
if (mCamera != null) {
213+
mCamera.getCameraControl().setZoomRatio(ratio);
214+
}
215+
}
216+
217+
public void setLinearZoom(float zoom) {
218+
if (mCamera != null) {
219+
mCamera.getCameraControl().setLinearZoom(zoom);
220+
}
221+
}
222+
223+
public void enableTorch(boolean enable) {
224+
if (mCamera != null) {
225+
mCamera.getCameraControl().enableTorch(enable);
226+
}
227+
}
228+
229+
public void startFocusAndMeteringCenter() {
230+
startFocusAndMetering(1f, 1f, .5f, .5f, FocusMeteringAction.FLAG_AF | FocusMeteringAction.FLAG_AE | FocusMeteringAction.FLAG_AWB);
231+
}
232+
233+
public void startFocusAndMetering(float w, float h, float x, float y, int mod) {
234+
if (mCamera == null || glpv == null) {
235+
return;
236+
}
237+
MeteringPoint point = new SurfaceOrientedMeteringPointFactory(w, h).createPoint(x, y);
238+
FocusMeteringAction action = new FocusMeteringAction.Builder(point, mod)
239+
.setAutoCancelDuration(2, TimeUnit.SECONDS)
240+
.build();
241+
mCamera.getCameraControl().startFocusAndMetering(action);
163242
}
164243

165244
private void bindImageAnalysis(@NonNull ProcessCameraProvider cameraProvider, boolean front) {
@@ -170,7 +249,7 @@ private void bindImageAnalysis(@NonNull ProcessCameraProvider cameraProvider, bo
170249
.setTargetRotation(videoOrientation)
171250
.build();
172251
preview.setSurfaceProvider(this.glpv.getSurfaceProvider());
173-
mCamera = cameraProvider.bindToLifecycle((LifecycleOwner) this.ctx, cameraSelector , preview);
252+
mCamera = cameraProvider.bindToLifecycle((LifecycleOwner) this.ctx, cameraSelector, preview);
174253
}
175254

176255
private void onEvent(int event, String msg) {
@@ -234,6 +313,7 @@ protected void finalize() {
234313

235314
/**
236315
* 设置是否使用enhanced-rtmp 标准推流
316+
*
237317
* @param enhancedRtmp
238318
*/
239319
public native void setEnhancedRtmp(boolean enhancedRtmp);
@@ -243,6 +323,7 @@ protected void finalize() {
243323
* 0.0 最小值 麦克风静音
244324
* 1.0 默认值 原始音量
245325
* 2.0 最大值 增益音量
326+
*
246327
* @param volume 0.0 ~~ 2.0
247328
*/
248329
public native void setVolume(float volume);
@@ -273,7 +354,7 @@ private void onViewChange() {
273354
}
274355
WindowManager wm = (WindowManager) this.ctx.getSystemService(Context.WINDOW_SERVICE);
275356
int surfaceRotation = wm.getDefaultDisplay().getRotation();
276-
int sensorRotationDegrees = getCameraInfo().getSensorRotationDegrees(this.videoOrientation);
357+
int sensorRotationDegrees = mCamera.getCameraInfo().getSensorRotationDegrees(this.videoOrientation);
277358
GPUImageChange(this.surfaceWidth, this.surfaceHeight, this.cameraWidth, this.cameraHeight, surfaceRotation, sensorRotationDegrees, this.isOpenFrontCamera);
278359
}
279360

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ dependencyResolutionManagement {
4141
### 2. Add the dependency
4242
```
4343
dependencies {
44-
implementation 'com.github.NodeMedia:NodeMediaClient-Android:3.2.4'
44+
implementation 'com.github.NodeMedia:NodeMediaClient-Android:3.2.5'
4545
}
4646
```
4747

0 commit comments

Comments
 (0)