Skip to content

Commit

Permalink
udpate to v3.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
illuspas committed Jan 30, 2024
1 parent c0e57c5 commit eb87300
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 14 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 3.2.5 - 2024-01-30
封装Camera变焦,对焦,闪光灯接口

## 3.2.4 - 2024-01-24
优化start stop逻辑

Expand Down
8 changes: 4 additions & 4 deletions NodeMediaClient/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
defaultConfig {
minSdkVersion 21
targetSdkVersion 33
versionCode 30204
versionName "3.2.4"
versionCode 30205
versionName "3.2.5"
}

buildTypes {
Expand All @@ -23,7 +23,7 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
def camerax_version = "1.3.0"
def camerax_version = "1.3.1"
implementation "androidx.camera:camera-core:${camerax_version}"
implementation "androidx.camera:camera-camera2:${camerax_version}"
implementation "androidx.camera:camera-lifecycle:${camerax_version}"
Expand All @@ -40,7 +40,7 @@ afterEvaluate {
from components.release
groupId = 'com.github.NodeMedia'
artifactId = 'NodeMediaClient-Android'
version = '3.2.4'
version = '3.2.5'
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions NodeMediaClient/src/main/java/cn/nodemedia/NodePlayer.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ©2023 NodeMedia.cn
* ©2024 NodeMedia.cn
* <p>
* Copyright © 2015 - 2023 NodeMedia.cn All Rights Reserved.
* Copyright © 2015 - 2024 NodeMedia.cn All Rights Reserved.
*/

package cn.nodemedia;
Expand Down
95 changes: 88 additions & 7 deletions NodeMediaClient/src/main/java/cn/nodemedia/NodePublisher.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ©2023 NodeMedia
* ©2024 NodeMedia
* <p>
* Copyright © 2015 - 2023 NodeMedia.All Rights Reserved.
* Copyright © 2015 - 2024 NodeMedia.All Rights Reserved.
*/

package cn.nodemedia;
Expand All @@ -15,16 +15,23 @@
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
import androidx.camera.core.Camera;
import androidx.camera.core.CameraInfo;
import androidx.camera.core.CameraSelector;
import androidx.camera.core.FocusMeteringAction;
import androidx.camera.core.MeteringPoint;
import androidx.camera.core.Preview;
import androidx.camera.core.SurfaceOrientedMeteringPointFactory;
import androidx.camera.lifecycle.ProcessCameraProvider;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.LifecycleOwner;

import com.google.common.util.concurrent.ListenableFuture;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

Expand Down Expand Up @@ -64,6 +71,21 @@ public class NodePublisher {
public static final int EffectorTextureTypeT2D = 0;
public static final int EffectorTextureTypeEOS = 1;

/**
* 自动对焦
*/
public static final int FLAG_AF = 1;

/**
* 自动曝光
*/
public static final int FLAG_AE = 1 << 1;

/**
* 自动白平衡
*/
public static final int FLAG_AWB = 1 << 2;


private static final String TAG = "NodeMedia.java";
private OnNodePublisherEventListener onNodePublisherEventListener;
Expand Down Expand Up @@ -158,8 +180,65 @@ public Camera getCamera() {
return mCamera;
}

public CameraInfo getCameraInfo() {
return mCamera.getCameraInfo();
public float getMinZoomRatio() {
if (mCamera != null && mCamera.getCameraInfo().getZoomState().getValue() != null) {
return mCamera.getCameraInfo().getZoomState().getValue().getMinZoomRatio();
}
return 1.0f;
}

public float getMaxZoomRatio() {
if (mCamera != null && mCamera.getCameraInfo().getZoomState().getValue() != null) {
return mCamera.getCameraInfo().getZoomState().getValue().getMaxZoomRatio();
}
return 1.0f;
}

public float getZoomRatio() {
if (mCamera != null && mCamera.getCameraInfo().getZoomState().getValue() != null) {
return mCamera.getCameraInfo().getZoomState().getValue().getZoomRatio();
}
return 1.0f;
}

public float getLinearZoom() {
if (mCamera != null && mCamera.getCameraInfo().getZoomState().getValue() != null) {
return mCamera.getCameraInfo().getZoomState().getValue().getLinearZoom();
}
return 0.0f;
}

public void setRoomRatio(float ratio) {
if (mCamera != null) {
mCamera.getCameraControl().setZoomRatio(ratio);
}
}

public void setLinearZoom(float zoom) {
if (mCamera != null) {
mCamera.getCameraControl().setLinearZoom(zoom);
}
}

public void enableTorch(boolean enable) {
if (mCamera != null) {
mCamera.getCameraControl().enableTorch(enable);
}
}

public void startFocusAndMeteringCenter() {
startFocusAndMetering(1f, 1f, .5f, .5f, FocusMeteringAction.FLAG_AF | FocusMeteringAction.FLAG_AE | FocusMeteringAction.FLAG_AWB);
}

public void startFocusAndMetering(float w, float h, float x, float y, int mod) {
if (mCamera == null || glpv == null) {
return;
}
MeteringPoint point = new SurfaceOrientedMeteringPointFactory(w, h).createPoint(x, y);
FocusMeteringAction action = new FocusMeteringAction.Builder(point, mod)
.setAutoCancelDuration(2, TimeUnit.SECONDS)
.build();
mCamera.getCameraControl().startFocusAndMetering(action);
}

private void bindImageAnalysis(@NonNull ProcessCameraProvider cameraProvider, boolean front) {
Expand All @@ -170,7 +249,7 @@ private void bindImageAnalysis(@NonNull ProcessCameraProvider cameraProvider, bo
.setTargetRotation(videoOrientation)
.build();
preview.setSurfaceProvider(this.glpv.getSurfaceProvider());
mCamera = cameraProvider.bindToLifecycle((LifecycleOwner) this.ctx, cameraSelector , preview);
mCamera = cameraProvider.bindToLifecycle((LifecycleOwner) this.ctx, cameraSelector, preview);
}

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

/**
* 设置是否使用enhanced-rtmp 标准推流
*
* @param enhancedRtmp
*/
public native void setEnhancedRtmp(boolean enhancedRtmp);
Expand All @@ -243,6 +323,7 @@ protected void finalize() {
* 0.0 最小值 麦克风静音
* 1.0 默认值 原始音量
* 2.0 最大值 增益音量
*
* @param volume 0.0 ~~ 2.0
*/
public native void setVolume(float volume);
Expand Down Expand Up @@ -273,7 +354,7 @@ private void onViewChange() {
}
WindowManager wm = (WindowManager) this.ctx.getSystemService(Context.WINDOW_SERVICE);
int surfaceRotation = wm.getDefaultDisplay().getRotation();
int sensorRotationDegrees = getCameraInfo().getSensorRotationDegrees(this.videoOrientation);
int sensorRotationDegrees = mCamera.getCameraInfo().getSensorRotationDegrees(this.videoOrientation);
GPUImageChange(this.surfaceWidth, this.surfaceHeight, this.cameraWidth, this.cameraHeight, surfaceRotation, sensorRotationDegrees, this.isOpenFrontCamera);
}

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dependencyResolutionManagement {
### 2. Add the dependency
```
dependencies {
implementation 'com.github.NodeMedia:NodeMediaClient-Android:3.2.4'
implementation 'com.github.NodeMedia:NodeMediaClient-Android:3.2.5'
}
```

Expand Down

0 comments on commit eb87300

Please sign in to comment.