├── .github └── workflows │ └── issues.yml ├── .gitignore ├── ChangeLog.md ├── NodeMediaClient ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── cn │ │ └── nodemedia │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── cn │ │ │ └── nodemedia │ │ │ ├── NodePlayer.java │ │ │ ├── NodePublisher.java │ │ │ └── NodeStreamer.java │ └── jniLibs │ │ ├── arm64-v8a │ │ └── libNodeMediaClient.so │ │ ├── armeabi-v7a │ │ └── libNodeMediaClient.so │ │ ├── x86 │ │ └── libNodeMediaClient.so │ │ └── x86_64 │ │ └── libNodeMediaClient.so │ └── test │ └── java │ └── cn │ └── nodemedia │ └── ExampleUnitTest.java ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.github/workflows/issues.yml: -------------------------------------------------------------------------------- 1 | name: Close inactive issues 2 | on: 3 | schedule: 4 | - cron: "30 1 * * *" 5 | 6 | jobs: 7 | close-issues: 8 | runs-on: ubuntu-latest 9 | permissions: 10 | issues: write 11 | pull-requests: write 12 | steps: 13 | - uses: actions/stale@v3 14 | with: 15 | days-before-issue-stale: 30 16 | days-before-issue-close: 14 17 | stale-issue-label: "stale" 18 | stale-issue-message: "This issue is stale because it has been open for 30 days with no activity." 19 | close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale." 20 | days-before-pr-stale: -1 21 | days-before-pr-close: -1 22 | repo-token: ${{ secrets.GITHUB_TOKEN }} 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | 21 | # Local configuration file (sdk path, etc) 22 | local.properties 23 | 24 | # Proguard folder generated by Eclipse 25 | proguard/ 26 | 27 | # Log Files 28 | *.log 29 | 30 | # Android Studio Navigation editor temp files 31 | .navigation/ 32 | 33 | # Android Studio captures folder 34 | captures/ 35 | 36 | # Intellij 37 | *.iml 38 | .idea 39 | 40 | # Keystore files 41 | *.jks -------------------------------------------------------------------------------- /ChangeLog.md: -------------------------------------------------------------------------------- 1 | ## 3.2.9 - 2024-10-11 2 | 修复推流到youtube音频杂音的问题 3 | 4 | ## 3.2.8 - 2024-09-14 5 | 增加原始数据推流拉流类 6 | 7 | ## 3.2.7 - 2024-03-06 8 | 修复一处音频采样声道兼容问题 9 | 10 | ## 3.2.6 - 2024-03-06 11 | 修复一处摄像头预览异常 12 | 修复RN推流无声 13 | 14 | ## 3.2.5 - 2024-01-30 15 | 封装Camera变焦,对焦,闪光灯接口 16 | 17 | ## 3.2.4 - 2024-01-24 18 | 优化start stop逻辑 19 | 20 | ## 3.2.2 - 2023-12-15 21 | 更新SSL库,修复rtmps无法推流的问题 22 | 23 | ## 3.2.1 - 2023-12-12 24 | 推流API可以通过设置音量来控制静音或者增益 25 | 26 | ## 3.2.0 - 2023-12-06 27 | 全面兼容Enhanced-Rtmp标准推流和播放h265编码 28 | 29 | ## 3.1.16 - 2023-07-10 30 | 优化播放重连策略 31 | 修复播放录制部分情况未写入结束包 32 | 33 | ## 3.1.15 - 2023-07-05 34 | 优化实现播放时录像 35 | 36 | ## 3.1.14 - 2023-06-28 37 | 优化实现播放时录像 38 | 39 | ## 3.1.13 - 2023-06-26 40 | 实现播放时录像 41 | 42 | ## 3.1.12 - 2023-06-7 43 | 完善点播api 44 | 45 | ## 3.1.11 - 2023-05-16 46 | * 增加推流多输出,可用于多平台推流和直播录像 47 | 48 | ## 3.1.10 - 2023-05-12 49 | * 修复一处音频问题 50 | 51 | ## 3.1.9 - 2023-05-12 52 | * 修复异常 53 | * 修复stop未清屏 54 | 55 | ## 3.1.8 - 2023-04-28 56 | * 增加RTSP传输协议设置 57 | * 增加HTTP referer/UA 设置 58 | * 增加RTMP swfUrl/pageUrl 设置 59 | 60 | ## 3.1.7 - 2023-04-27 61 | * 支持双声道降噪 62 | -------------------------------------------------------------------------------- /NodeMediaClient/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /NodeMediaClient/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | id 'maven-publish' 4 | } 5 | 6 | android { 7 | compileSdkVersion 33 8 | defaultConfig { 9 | minSdkVersion 21 10 | targetSdkVersion 33 11 | versionCode 30209 12 | versionName "3.2.9" 13 | } 14 | 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | 22 | } 23 | 24 | dependencies { 25 | implementation fileTree(dir: 'libs', include: ['*.jar']) 26 | def camerax_version = "1.3.1" 27 | implementation "androidx.camera:camera-core:${camerax_version}" 28 | implementation "androidx.camera:camera-camera2:${camerax_version}" 29 | implementation "androidx.camera:camera-lifecycle:${camerax_version}" 30 | implementation "androidx.camera:camera-view:${camerax_version}" 31 | implementation "androidx.camera:camera-extensions:${camerax_version}" 32 | implementation "androidx.appcompat:appcompat:1.6.1" 33 | } 34 | 35 | afterEvaluate { 36 | publishing { 37 | publications { 38 | // Creates a Maven publication called "release". 39 | release(MavenPublication) { 40 | from components.release 41 | groupId = 'com.github.NodeMedia' 42 | artifactId = 'NodeMediaClient-Android' 43 | version = '3.2.9' 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /NodeMediaClient/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | 23 | -keep class cn.nodemedia.** {*;} -------------------------------------------------------------------------------- /NodeMediaClient/src/androidTest/java/cn/nodemedia/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package cn.nodemedia; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("cn.nodemedia.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /NodeMediaClient/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /NodeMediaClient/src/main/java/cn/nodemedia/NodePlayer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ©2024 NodeMedia.cn 3 | *

4 | * Copyright © 2015 - 2024 NodeMedia.cn All Rights Reserved. 5 | */ 6 | 7 | package cn.nodemedia; 8 | 9 | import android.content.Context; 10 | import android.graphics.SurfaceTexture; 11 | import android.view.Gravity; 12 | import android.view.Surface; 13 | import android.view.TextureView; 14 | import android.view.ViewGroup; 15 | import android.widget.FrameLayout; 16 | 17 | 18 | public class NodePlayer implements TextureView.SurfaceTextureListener { 19 | static { 20 | System.loadLibrary("NodeMediaClient"); 21 | } 22 | 23 | public static final int LOG_LEVEL_ERROR = 0; 24 | public static final int LOG_LEVEL_INFO = 1; 25 | public static final int LOG_LEVEL_DEBUG = 2; 26 | 27 | public static final String RTSP_TRANSPORT_UDP = "udp"; 28 | public static final String RTSP_TRANSPORT_TCP = "tcp"; 29 | public static final String RTSP_TRANSPORT_UDP_MULTICAST = "udp_multicast"; 30 | public static final String RTSP_TRANSPORT_HTTP = "http"; 31 | 32 | private static final String TAG = "NodeMedia.java"; 33 | 34 | private OnNodePlayerEventListener onNodePlayerEventListener = null; 35 | private TextureView tv = null; 36 | private Context ctx; 37 | private long id; 38 | 39 | private FrameLayout.LayoutParams LP = new FrameLayout.LayoutParams( 40 | FrameLayout.LayoutParams.MATCH_PARENT, 41 | FrameLayout.LayoutParams.MATCH_PARENT, 42 | Gravity.CENTER); 43 | 44 | /** 45 | * 创建NodePlayer 46 | * 47 | * @param context Android context 48 | * @param license 授权码 49 | */ 50 | public NodePlayer(Context context, String license) { 51 | id = jniInit(context, license); 52 | ctx = context; 53 | } 54 | 55 | @Override 56 | protected void finalize() { 57 | jniFree(); 58 | } 59 | 60 | 61 | /** 62 | * 附加到视图 63 | * 64 | * @param vg ViewGroup的子类 65 | */ 66 | public void attachView(ViewGroup vg) { 67 | if (this.tv == null) { 68 | this.tv = new TextureView(ctx); 69 | this.tv.setLayoutParams(LP); 70 | this.tv.setSurfaceTextureListener(this); 71 | this.tv.setKeepScreenOn(true); 72 | vg.addView(this.tv); 73 | } 74 | } 75 | 76 | /** 77 | * 返回当前的TextureView 78 | * 79 | * @return 当前的TextureView 80 | */ 81 | public TextureView getTextureView() { 82 | return this.tv; 83 | } 84 | 85 | /** 86 | * 从视图中移除 87 | */ 88 | public void detachView() { 89 | if (this.tv != null) { 90 | this.tv.setKeepScreenOn(false); 91 | this.tv = null; 92 | } 93 | } 94 | 95 | /** 96 | * 设置事件回调 97 | * @param listener 98 | */ 99 | public void setOnNodePlayerEventListener(OnNodePlayerEventListener listener) { 100 | this.onNodePlayerEventListener = listener; 101 | } 102 | 103 | private void onEvent(int event, String msg) { 104 | // Log.d(TAG, "on Event: " + event + " Message:" + msg); 105 | if (this.onNodePlayerEventListener != null) { 106 | this.onNodePlayerEventListener.onEventCallback(this, event, msg); 107 | } 108 | } 109 | 110 | private native long jniInit(Context context, String license); 111 | 112 | private native void jniFree(); 113 | 114 | /** 115 | * 开始播放 116 | * 117 | * @param url 播放的url 118 | * @return 119 | */ 120 | public native int start(String url); 121 | 122 | /** 123 | * 停止播放 124 | * 125 | * @return 126 | */ 127 | public native int stop(); 128 | 129 | /** 130 | * 暂停或恢复点播视频播放 131 | * 132 | * @param pause 是否暂停 133 | * @return 134 | */ 135 | public native int pause(boolean pause); 136 | 137 | /** 138 | * 时移 139 | * 140 | * @param pts 时移点,单位毫秒 141 | * @return 142 | */ 143 | public native int seek(long pts); 144 | 145 | /** 146 | * 视频截图 147 | * 148 | * @param filename 保存的文件名,jpeg格式 149 | * @return 150 | */ 151 | public native int screenshot(String filename); 152 | 153 | /** 154 | * 开始录制 155 | * @param filename 保存的文件名,支持mp4,flv,mkv,ts格式 156 | * @return 157 | */ 158 | public native int startRecord(String filename); 159 | 160 | /** 161 | * 停止录制 162 | * @return 163 | */ 164 | public native int stopRecord(); 165 | 166 | /** 167 | * 视频是否是点播回放 168 | * 169 | * @return 是否点播 170 | */ 171 | public native boolean isVod(); 172 | 173 | /** 174 | * 视频是否暂停了 175 | * 176 | * @return 是否暂停 177 | */ 178 | public native boolean isPause(); 179 | 180 | /** 181 | * 获取点播视频时长 182 | * 183 | * @return 单位毫秒 184 | */ 185 | public native long getDuration(); 186 | 187 | /** 188 | * 获取点播视频当前播放点 189 | * 190 | * @return 单位毫秒 191 | */ 192 | public native long getCurrentPosition(); 193 | 194 | /** 195 | * 获取点播视频缓冲点 196 | * 197 | * @return 单位毫秒 198 | */ 199 | public native long getBufferPosition(); 200 | 201 | /** 202 | * 获取点播视频缓冲百分比 203 | * @return 百分比 204 | */ 205 | public native int getBufferPercentage(); 206 | 207 | /** 208 | * 获取播放器是否正在播放 209 | * @return 210 | */ 211 | public native boolean isPlaying(); 212 | 213 | /** 214 | * 设置日志等级 215 | * 216 | * @param logLevel 等级 217 | */ 218 | public native void setLogLevel(int logLevel); 219 | 220 | /** 221 | * 设置缓存时长 222 | * 223 | * @param bufferTime 单位毫秒 224 | */ 225 | public native void setBufferTime(int bufferTime); 226 | 227 | /** 228 | * 设置缩放模式 229 | * 230 | * @param mode 模式 231 | */ 232 | public native void setScaleMode(int mode); 233 | 234 | /** 235 | * 设置视频surface 236 | * 237 | * @param surface 视频surface 238 | */ 239 | public native void setVideoSurface(Surface surface); 240 | 241 | public native void setRTMPPageUrl(String rtmpPageUrl); 242 | 243 | public native void setRTMPSwfUrl(String rtmpSwfUrl); 244 | 245 | /** 246 | * 设置RTSP的传输协议, 默认是UDP 247 | * @param rtspTransport 248 | */ 249 | public native void setRTSPTransport(String rtspTransport); 250 | 251 | /** 252 | * 设置HTTP Referer 253 | * @param httpReferer 254 | */ 255 | public native void setHTTPReferer(String httpReferer); 256 | 257 | /** 258 | * 设置HTTP User-Agent 259 | * @param httpUserAgent 260 | */ 261 | public native void setHTTPUserAgent(String httpUserAgent); 262 | /** 263 | * 设置视频解密密码 264 | * 265 | * @param cryptoKey 16字节密码 266 | */ 267 | public native void setCryptoKey(String cryptoKey); 268 | 269 | /** 270 | * 设置音量 271 | * 0.0 最小值 静音 272 | * 1.0 默认值 原始音量 273 | * @param volume 0.0 ~~ 1.0 274 | */ 275 | public native void setVolume(float volume); 276 | 277 | /** 278 | * 设置是否开启硬件加速 279 | * @param enable 开关 280 | */ 281 | public native void setHWAccelEnable(boolean enable); 282 | 283 | /** 284 | * 视频surface大小已改变 285 | */ 286 | public native void resizeVideoSurface(); 287 | 288 | public native void rotateVideo(int rotate); 289 | 290 | @Override 291 | public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) { 292 | setVideoSurface(new Surface(surfaceTexture)); 293 | // Log.i(TAG, "onSurfaceTextureAvailable: " + width + "x" + height); 294 | } 295 | 296 | @Override 297 | public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int width, int height) { 298 | // Log.i(TAG, "onSurfaceTextureSizeChanged: " + width + "x" + height); 299 | resizeVideoSurface(); 300 | } 301 | 302 | @Override 303 | public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) { 304 | // Log.i(TAG, "onSurfaceTextureDestroyed"); 305 | // setVideoSurface(null); 306 | return false; 307 | } 308 | 309 | @Override 310 | public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) { 311 | // Log.d(TAG, "onSurfaceTextureUpdated"); 312 | } 313 | 314 | public interface OnNodePlayerEventListener { 315 | void onEventCallback(NodePlayer player, int event, String msg); 316 | } 317 | 318 | } -------------------------------------------------------------------------------- /NodeMediaClient/src/main/java/cn/nodemedia/NodePublisher.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ©2024 NodeMedia 3 | *

4 | * Copyright © 2015 - 2024 NodeMedia.All Rights Reserved. 5 | */ 6 | 7 | package cn.nodemedia; 8 | 9 | import android.content.Context; 10 | import android.graphics.SurfaceTexture; 11 | import android.opengl.GLSurfaceView; 12 | import android.util.Size; 13 | import android.view.Gravity; 14 | import android.view.Surface; 15 | import android.view.ViewGroup; 16 | import android.view.WindowManager; 17 | import android.widget.FrameLayout; 18 | 19 | import androidx.annotation.NonNull; 20 | import androidx.camera.core.Camera; 21 | import androidx.camera.core.CameraSelector; 22 | import androidx.camera.core.FocusMeteringAction; 23 | import androidx.camera.core.MeteringPoint; 24 | import androidx.camera.core.Preview; 25 | import androidx.camera.core.SurfaceOrientedMeteringPointFactory; 26 | import androidx.camera.lifecycle.ProcessCameraProvider; 27 | import androidx.core.content.ContextCompat; 28 | import androidx.lifecycle.LifecycleOwner; 29 | 30 | import com.google.common.util.concurrent.ListenableFuture; 31 | 32 | import java.util.concurrent.ExecutionException; 33 | import java.util.concurrent.TimeUnit; 34 | 35 | import javax.microedition.khronos.egl.EGLConfig; 36 | import javax.microedition.khronos.opengles.GL10; 37 | 38 | public class NodePublisher { 39 | static { 40 | System.loadLibrary("NodeMediaClient"); 41 | } 42 | 43 | public static final int LOG_LEVEL_ERROR = 0; 44 | public static final int LOG_LEVEL_INFO = 1; 45 | public static final int LOG_LEVEL_DEBUG = 2; 46 | 47 | public static final int NMC_CODEC_ID_H264 = 27; 48 | public static final int NMC_CODEC_ID_H265 = 173; 49 | public static final int NMC_CODEC_ID_AAC = 86018; 50 | 51 | public static final int NMC_PROFILE_AUTO = 0; 52 | public static final int NMC_PROFILE_H264_BASELINE = 66; 53 | public static final int NMC_PROFILE_H264_MAIN = 77; 54 | public static final int NMC_PROFILE_H264_HIGH = 100; 55 | public static final int NMC_PROFILE_H265_MAIN = 1; 56 | public static final int NMC_PROFILE_AAC_LC = 1; 57 | public static final int NMC_PROFILE_AAC_HE = 4; 58 | public static final int NMC_PROFILE_AAC_HE_V2 = 28; 59 | public static final int NMC_PROFILE_AAC_LD = 22; 60 | public static final int NMC_PROFILE_AAC_ELD = 38; 61 | 62 | public static final int VIDEO_RC_CRF = 0; 63 | public static final int VIDEO_RC_ABR = 1; 64 | public static final int VIDEO_RC_CBR = 2; 65 | public static final int VIDEO_RC_VBV = 3; 66 | 67 | public static final int VIDEO_ORIENTATION_PORTRAIT = 0; 68 | public static final int VIDEO_ORIENTATION_LANDSCAPE_RIGHT = 1; 69 | public static final int VIDEO_ORIENTATION_LANDSCAPE_LEFT = 3; 70 | 71 | public static final int EffectorTextureTypeT2D = 0; 72 | public static final int EffectorTextureTypeEOS = 1; 73 | 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 | 89 | 90 | private static final String TAG = "NodeMedia.java"; 91 | private OnNodePublisherEventListener onNodePublisherEventListener; 92 | private OnNodePublisherEffectorListener onNodePublisherEffectorListener; 93 | private GLCameraView glpv; 94 | private Camera mCamera; 95 | private Context ctx; 96 | private long id; 97 | private int fpsCount; 98 | private long fpsTime; 99 | private boolean isOpenFrontCamera = false; 100 | private int videoOrientation = Surface.ROTATION_0; 101 | private int videoWidth = 720; 102 | private int videoHeight = 1280; 103 | private int cameraWidth = 0; 104 | private int cameraHeight = 0; 105 | private int surfaceWidth = 0; 106 | private int surfaceHeight = 0; 107 | 108 | private final FrameLayout.LayoutParams LP = new FrameLayout.LayoutParams( 109 | FrameLayout.LayoutParams.MATCH_PARENT, 110 | FrameLayout.LayoutParams.MATCH_PARENT, 111 | Gravity.CENTER); 112 | 113 | public NodePublisher(@NonNull Context context, @NonNull String license) { 114 | ctx = context; 115 | id = jniInit(context, license); 116 | } 117 | 118 | public void setOnNodePublisherEventListener(OnNodePublisherEventListener onNodePublisherEventListener) { 119 | this.onNodePublisherEventListener = onNodePublisherEventListener; 120 | } 121 | 122 | public void setOnNodePublisherEffectorListener(OnNodePublisherEffectorListener onNodePublisherEffectorListener) { 123 | this.onNodePublisherEffectorListener = onNodePublisherEffectorListener; 124 | } 125 | 126 | public void attachView(@NonNull ViewGroup vg) { 127 | if (this.glpv == null) { 128 | this.glpv = new GLCameraView(this.ctx); 129 | this.glpv.setLayoutParams(LP); 130 | this.glpv.setKeepScreenOn(true); 131 | vg.addView(this.glpv); 132 | } 133 | } 134 | 135 | public void detachView() { 136 | if (this.glpv != null) { 137 | this.glpv.setKeepScreenOn(false); 138 | this.glpv = null; 139 | closeCamera(); 140 | GPUImageDestroy(); 141 | } 142 | } 143 | 144 | public void setVideoOrientation(int orientation) { 145 | this.videoOrientation = orientation; 146 | } 147 | 148 | public void openCamera(boolean frontCamera) { 149 | this.isOpenFrontCamera = frontCamera; 150 | ListenableFuture cameraProviderFuture = ProcessCameraProvider.getInstance(ctx); 151 | cameraProviderFuture.addListener(() -> { 152 | try { 153 | ProcessCameraProvider cameraProvider = cameraProviderFuture.get(); 154 | bindImageAnalysis(cameraProvider, this.isOpenFrontCamera); 155 | } catch (ExecutionException | InterruptedException e) { 156 | e.printStackTrace(); 157 | } 158 | }, ContextCompat.getMainExecutor(this.ctx)); 159 | } 160 | 161 | public void closeCamera() { 162 | ListenableFuture cameraProviderFuture = ProcessCameraProvider.getInstance(ctx); 163 | cameraProviderFuture.addListener(() -> { 164 | try { 165 | ProcessCameraProvider cameraProvider = cameraProviderFuture.get(); 166 | cameraProvider.unbindAll(); 167 | } catch (ExecutionException | InterruptedException e) { 168 | e.printStackTrace(); 169 | } 170 | }, ContextCompat.getMainExecutor(this.ctx)); 171 | } 172 | 173 | public void switchCamera() { 174 | this.isOpenFrontCamera = !this.isOpenFrontCamera; 175 | closeCamera(); 176 | openCamera(this.isOpenFrontCamera); 177 | } 178 | 179 | public Camera getCamera() { 180 | return mCamera; 181 | } 182 | 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); 242 | } 243 | 244 | private void bindImageAnalysis(@NonNull ProcessCameraProvider cameraProvider, boolean front) { 245 | CameraSelector cameraSelector = front ? CameraSelector.DEFAULT_FRONT_CAMERA : CameraSelector.DEFAULT_BACK_CAMERA; 246 | Preview.SurfaceProvider provider = this.glpv.getSurfaceProvider(); 247 | if(provider == null) { 248 | return; 249 | } 250 | Preview preview = new Preview.Builder() 251 | .setTargetResolution(new Size(videoWidth, videoHeight)) 252 | .setTargetRotation(videoOrientation) 253 | .build(); 254 | preview.setSurfaceProvider(provider); 255 | mCamera = cameraProvider.bindToLifecycle((LifecycleOwner) this.ctx, cameraSelector, preview); 256 | } 257 | 258 | private void onEvent(int event, String msg) { 259 | // Log.d(TAG, "on Event: " + event + " Message:" + msg); 260 | if (this.onNodePublisherEventListener != null) { 261 | this.onNodePublisherEventListener.onEventCallback(this, event, msg); 262 | } 263 | } 264 | 265 | private void onCreateEffector() { 266 | if (this.onNodePublisherEffectorListener != null) { 267 | this.onNodePublisherEffectorListener.onCreateEffector(this.ctx); 268 | } 269 | } 270 | 271 | private int onProcessEffector(int textureID) { 272 | if (this.onNodePublisherEffectorListener != null) { 273 | textureID = this.onNodePublisherEffectorListener.onProcessEffector(textureID, this.videoWidth, this.videoHeight); 274 | } 275 | return textureID; 276 | } 277 | 278 | private void onReleaseEffector() { 279 | if (this.onNodePublisherEffectorListener != null) { 280 | this.onNodePublisherEffectorListener.onReleaseEffector(); 281 | } 282 | } 283 | 284 | protected void finalize() { 285 | jniFree(); 286 | } 287 | 288 | private native long jniInit(Context context, String license); 289 | 290 | private native void jniFree(); 291 | 292 | public native void setLogLevel(int logLevel); 293 | 294 | public native void setHWAccelEnable(boolean enable); 295 | 296 | public native void setDenoiseEnable(boolean enable); 297 | 298 | public native void setVideoFrontMirror(boolean mirror); 299 | 300 | public native void setCameraFrontMirror(boolean mirror); 301 | 302 | public native void setAudioCodecParam(int codec, int profile, int sampleRate, int channels, int bitrate); 303 | 304 | public native void setVideoCodecParam(int codec, int profile, int width, int height, int fps, int bitrate); 305 | 306 | public native void setVideoRateControl(int rc); 307 | 308 | public native void setKeyFrameInterval(int keyFrameInterval); 309 | 310 | /** 311 | * 设置视频解密密码 312 | * 313 | * @param cryptoKey 16字节密码 314 | */ 315 | public native void setCryptoKey(@NonNull String cryptoKey); 316 | 317 | /** 318 | * 设置是否使用enhanced-rtmp 标准推流 319 | * 320 | * @param enhancedRtmp 321 | */ 322 | public native void setEnhancedRtmp(boolean enhancedRtmp); 323 | 324 | /** 325 | * 设置音量 326 | * 0.0 最小值 麦克风静音 327 | * 1.0 默认值 原始音量 328 | * 2.0 最大值 增益音量 329 | * 330 | * @param volume 0.0 ~~ 2.0 331 | */ 332 | public native void setVolume(float volume); 333 | 334 | public native int addOutput(@NonNull String url); 335 | 336 | public native int removeOutputs(); 337 | 338 | public native int start(@NonNull String url); 339 | 340 | public native int stop(); 341 | 342 | public native void setEffectorTextureType(int type); 343 | 344 | private native int GPUImageCreate(int textureID); 345 | 346 | private native int GPUImageChange(int sw, int sh, int cw, int ch, int so, int co, boolean f); 347 | 348 | private native int GPUImageDraw(int textureID, float[] mtx, int len); 349 | 350 | private native int GPUImageDestroy(); 351 | 352 | private native int GPUImageGenOESTextureID(); 353 | 354 | private void onViewChange() { 355 | if (this.cameraWidth == 0 || this.cameraHeight == 0 || this.surfaceWidth == 0 || this.surfaceHeight == 0) { 356 | return; 357 | } 358 | WindowManager wm = (WindowManager) this.ctx.getSystemService(Context.WINDOW_SERVICE); 359 | int surfaceRotation = wm.getDefaultDisplay().getRotation(); 360 | int sensorRotationDegrees = mCamera.getCameraInfo().getSensorRotationDegrees(this.videoOrientation); 361 | GPUImageChange(this.surfaceWidth, this.surfaceHeight, this.cameraWidth, this.cameraHeight, surfaceRotation, sensorRotationDegrees, this.isOpenFrontCamera); 362 | } 363 | 364 | private class GLCameraView extends GLSurfaceView implements GLSurfaceView.Renderer { 365 | private static final String TAG = "NodeMedia.GLCameraView"; 366 | 367 | private SurfaceTexture surfaceTexture; 368 | private int textureId = -1; 369 | private Context context; 370 | private float transformMatrix[] = new float[16]; 371 | 372 | protected GLCameraView(Context context) { 373 | super(context); 374 | this.context = context; 375 | setEGLContextClientVersion(2); 376 | setRenderer(this); 377 | setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); 378 | } 379 | 380 | private Preview.SurfaceProvider getSurfaceProvider() { 381 | if(surfaceTexture == null) { 382 | return null; 383 | } 384 | return request -> { 385 | Size resolution = request.getResolution(); 386 | surfaceTexture.setDefaultBufferSize(resolution.getWidth(), resolution.getHeight()); 387 | request.provideSurface(new Surface(surfaceTexture), ContextCompat.getMainExecutor(this.context), result -> { 388 | result.getSurface().release(); 389 | }); 390 | this.queueEvent(() -> { 391 | NodePublisher.this.cameraWidth = resolution.getWidth(); 392 | NodePublisher.this.cameraHeight = resolution.getHeight(); 393 | NodePublisher.this.onViewChange(); 394 | }); 395 | }; 396 | } 397 | 398 | @Override 399 | public void onSurfaceCreated(GL10 gl10, EGLConfig eglConfig) { 400 | textureId = GPUImageGenOESTextureID(); 401 | surfaceTexture = new SurfaceTexture(textureId); 402 | surfaceTexture.setOnFrameAvailableListener(surfaceTexture -> requestRender()); 403 | NodePublisher.this.GPUImageCreate(textureId); 404 | } 405 | 406 | @Override 407 | public void onSurfaceChanged(GL10 gl10, int w, int h) { 408 | NodePublisher.this.surfaceWidth = w; 409 | NodePublisher.this.surfaceHeight = h; 410 | NodePublisher.this.onViewChange(); 411 | } 412 | 413 | @Override 414 | public void onDrawFrame(GL10 gl10) { 415 | surfaceTexture.updateTexImage(); 416 | surfaceTexture.getTransformMatrix(transformMatrix); 417 | NodePublisher.this.GPUImageDraw(textureId, transformMatrix, transformMatrix.length); 418 | } 419 | } 420 | 421 | public interface OnNodePublisherEffectorListener { 422 | 423 | void onCreateEffector(Context context); 424 | 425 | int onProcessEffector(int textureID, int width, int height); 426 | 427 | void onReleaseEffector(); 428 | 429 | } 430 | 431 | public interface OnNodePublisherEventListener { 432 | void onEventCallback(NodePublisher publisher, int event, String msg); 433 | } 434 | } -------------------------------------------------------------------------------- /NodeMediaClient/src/main/java/cn/nodemedia/NodeStreamer.java: -------------------------------------------------------------------------------- 1 | package cn.nodemedia; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.annotation.NonNull; 6 | 7 | public class NodeStreamer { 8 | static { 9 | System.loadLibrary("NodeMediaClient"); 10 | } 11 | 12 | public static final int NMC_RAW_VIDEO_YUV420 = 0; 13 | public static final int NMC_RAW_VIDEO_NV12 = 23; 14 | public static final int NMC_RAW_VIDEO_NV21 = 24; 15 | 16 | public static final int NMC_RAW_AUDIO_PCMU8 = 0; 17 | public static final int NMC_RAW_AUDIO_PCMS16 = 1; 18 | public static final int NMC_RAW_AUDIO_PCMS32 = 2; 19 | public static final int NMC_RAW_AUDIO_PCMF32 = 3; 20 | 21 | private Context ctx; 22 | private long id; 23 | 24 | private OnNodeStreamerEventListener nodeStreamerEventListener; 25 | 26 | private OnNodeStreamerMediaListener nodeStreamerMediaListener; 27 | 28 | public void setNodeStreamerEventListener(OnNodeStreamerEventListener nodeStreamerEventListener) { 29 | this.nodeStreamerEventListener = nodeStreamerEventListener; 30 | } 31 | 32 | public void setNodeStreamerMediaListener(OnNodeStreamerMediaListener nodeStreamerMediaListener) { 33 | this.nodeStreamerMediaListener = nodeStreamerMediaListener; 34 | } 35 | 36 | public NodeStreamer(@NonNull Context context, @NonNull String license) { 37 | ctx = context; 38 | id = jniInit(context, license); 39 | } 40 | 41 | private native long jniInit(Context context, String license); 42 | 43 | private native void jniFree(); 44 | 45 | public native void setRawVideoMediaFormat(int format, int width, int height); 46 | 47 | public native void setRawAudioMediaFormat(int format, int sampleRate, int channels); 48 | 49 | public native void setEncVideoMediaFormat(int codec, int profile, int width, int height, int fps, int keyInterval, int bitrate); 50 | 51 | public native void setEncAudioMediaFormat(int codec, int profile, int sampleRate, int channels, int bitrate); 52 | 53 | public native int sendRawVideoFrame(byte[] data, int length, long timestamp); 54 | 55 | public native int sendRawAudioFrame(byte[] data, int length, long timestamp); 56 | 57 | public native int startPull(String url); 58 | 59 | public native int stopPull(); 60 | 61 | public native int startPush(String url); 62 | 63 | public native int stopPush(); 64 | 65 | public interface OnNodeStreamerEventListener { 66 | void onEventCallback(NodeStreamer publisher, int event, String msg); 67 | } 68 | 69 | public interface OnNodeStreamerMediaListener { 70 | 71 | void onAudioInfoCallback(NodeStreamer publisher, int format, int sampleRate, int channels); 72 | 73 | void onVideoInfoCallback(NodeStreamer publisher, int format, int width, int height); 74 | 75 | void onAudioFrameCallback(NodeStreamer publisher, byte[] data, int length, long timestamp); 76 | 77 | void onVideoFrameCallback(NodeStreamer publisher, byte[] data, int length, long timestamp); 78 | 79 | } 80 | 81 | private void onEvent(int event, String msg) { 82 | // Log.d(TAG, "on Event: " + event + " Message:" + msg); 83 | if (this.nodeStreamerEventListener != null) { 84 | this.nodeStreamerEventListener.onEventCallback(this, event, msg); 85 | } 86 | } 87 | 88 | private void onAudioInfo(int format, int sampleRate, int channels) { 89 | // Log.d(TAG, "on Event: " + event + " Message:" + msg); 90 | if (this.nodeStreamerMediaListener != null) { 91 | this.nodeStreamerMediaListener.onAudioInfoCallback(this, format, sampleRate, channels); 92 | } 93 | } 94 | 95 | private void onVideoInfo(int format, int width, int height) { 96 | // Log.d(TAG, "on Event: " + event + " Message:" + msg); 97 | if (this.nodeStreamerMediaListener != null) { 98 | this.nodeStreamerMediaListener.onVideoInfoCallback(this, format, width, height); 99 | } 100 | } 101 | 102 | private void onAudioFrame(byte[] data, int length, long timestamp) { 103 | if (this.nodeStreamerMediaListener != null) { 104 | this.nodeStreamerMediaListener.onAudioFrameCallback(this, data, length, timestamp); 105 | } 106 | } 107 | 108 | private void onVideoFrame(byte[] data, int length, long timestamp) { 109 | if (this.nodeStreamerMediaListener != null) { 110 | this.nodeStreamerMediaListener.onVideoFrameCallback(this, data, length, timestamp); 111 | } 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /NodeMediaClient/src/main/jniLibs/arm64-v8a/libNodeMediaClient.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NodeMedia/NodeMediaClient-Android/a434c6c5394a4a854585442b9537d7ed17c0e295/NodeMediaClient/src/main/jniLibs/arm64-v8a/libNodeMediaClient.so -------------------------------------------------------------------------------- /NodeMediaClient/src/main/jniLibs/armeabi-v7a/libNodeMediaClient.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NodeMedia/NodeMediaClient-Android/a434c6c5394a4a854585442b9537d7ed17c0e295/NodeMediaClient/src/main/jniLibs/armeabi-v7a/libNodeMediaClient.so -------------------------------------------------------------------------------- /NodeMediaClient/src/main/jniLibs/x86/libNodeMediaClient.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NodeMedia/NodeMediaClient-Android/a434c6c5394a4a854585442b9537d7ed17c0e295/NodeMediaClient/src/main/jniLibs/x86/libNodeMediaClient.so -------------------------------------------------------------------------------- /NodeMediaClient/src/main/jniLibs/x86_64/libNodeMediaClient.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NodeMedia/NodeMediaClient-Android/a434c6c5394a4a854585442b9537d7ed17c0e295/NodeMediaClient/src/main/jniLibs/x86_64/libNodeMediaClient.so -------------------------------------------------------------------------------- /NodeMediaClient/src/test/java/cn/nodemedia/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package cn.nodemedia; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NodeMediaClient-Android 2 | [![](https://jitpack.io/v/NodeMedia/NodeMediaClient-Android.svg)](https://jitpack.io/#NodeMedia/NodeMediaClient-Android) 3 | A simple, high-performance, low-latency live streaming SDK. 4 | 5 | ## Features 6 | ### Play 7 | * RTMP/RTSP/HLS/HTTP/KMP/UDP protocols 8 | * FLV/MP4/fMP4/MKV/MPEGTS demuxers 9 | * H264/H265 video decoders 10 | * AAC/OPUS/G711/SPEEX/NELLYMOSER audio decoders 11 | * Hardware Acceleration 12 | * Low latency 13 | * Delay elimination 14 | * Take screenshot while playing 15 | * Take record while playing, support mp4/flv/ts/mkv format 16 | * Compatible with flv_extension_id and Enhanced-Rtmp standards 17 | 18 | ### Publish 19 | * RTMP/RTSP/HLS/HTTP/KMP/UDP protocols 20 | * FLV/MPEGTS muxers 21 | * H264/H265 video encoders 22 | * AAC audio encoder 23 | * Hardware Acceleration 24 | * Arbitrary video resolution 25 | * Multiple output 26 | * Compatible with flv_extension_id and Enhanced-Rtmp standards 27 | 28 | ## Install 29 | ### 1. Add the JitPack repository to your build file 30 | ``` 31 | dependencyResolutionManagement { 32 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 33 | repositories { 34 | google() 35 | mavenCentral() 36 | maven { url 'https://jitpack.io' } 37 | } 38 | } 39 | ``` 40 | 41 | ### 2. Add the dependency 42 | ``` 43 | dependencies { 44 | implementation 'com.github.NodeMedia:NodeMediaClient-Android:3.2.9' 45 | } 46 | ``` 47 | 48 | ## Play Live Streaming 49 | 50 | ### 1. Add permission INTERNET 51 | ``` 52 | 53 | ``` 54 | 55 | ### 2. Setting up the layout 56 | ``` 57 | 61 | 62 | ``` 63 | 64 | ### 3. Play the stream 65 | ``` 66 | private NodePlayer np; 67 | 68 | @Override 69 | protected void onCreate(Bundle savedInstanceState) { 70 | super.onCreate(savedInstanceState); 71 | supportRequestWindowFeature(Window.FEATURE_NO_TITLE); 72 | setContentView(R.layout.activity_playview); 73 | 74 | FrameLayout vv = findViewById(R.id.video_view); 75 | np = new NodePlayer(this,""); 76 | np.attachView(vv); 77 | np.start("rtmp://192.168.0.2/live/demo"); 78 | } 79 | 80 | @Override 81 | protected void onDestroy() { 82 | super.onDestroy(); 83 | np.detachView(); 84 | np.stop(); 85 | } 86 | ``` 87 | That's it. Very simple! 88 | 89 | 90 | ## Publish Live Streaming 91 | ### 1. Request more permissions 92 | ``` 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | ``` 101 | 102 | ### 2. Permission to apply 103 | ``` 104 | private static final String[] PERMISSIONS = new String[]{ 105 | Manifest.permission.READ_EXTERNAL_STORAGE, 106 | Manifest.permission.WRITE_EXTERNAL_STORAGE, 107 | Manifest.permission.CAMERA, 108 | Manifest.permission.RECORD_AUDIO}; 109 | private static final int REQUEST_PERMISSION_CODE = 0XFF00; 110 | 111 | @Override 112 | protected void onCreate(Bundle savedInstanceState) { 113 | super.onCreate(savedInstanceState); 114 | setContentView(R.layout.activity_main); 115 | requestPermission(); 116 | …………………… 117 | } 118 | 119 | private void requestPermission() { 120 | ActivityCompat.requestPermissions(MainActivity.this, PERMISSIONS, REQUEST_PERMISSION_CODE); 121 | } 122 | 123 | ``` 124 | 125 | ### 3. Setting up the layout 126 | ``` 127 | 131 | 132 | ``` 133 | 134 | ### 4.Start Publish 135 | ``` 136 | private NodePublisher np; 137 | 138 | @Override 139 | protected void onCreate(Bundle savedInstanceState) { 140 | super.onCreate(savedInstanceState); 141 | supportRequestWindowFeature(Window.FEATURE_NO_TITLE); 142 | setContentView(R.layout.activity_publish_view); 143 | FrameLayout fl = findViewById(R.id.camera_view); 144 | 145 | np = new NodePublisher(this, ""); 146 | np.setAudioCodecParam(NodePublisher.NMC_CODEC_ID_AAC, NodePublisher.NMC_PROFILE_AUTO, 48000, 1, 64_000); 147 | np.setVideoOrientation(NodePublisher.VIDEO_ORIENTATION_PORTRAIT); 148 | np.setVideoCodecParam(NodePublisher.NMC_CODEC_ID_H264, NodePublisher.NMC_PROFILE_AUTO, 480, 854, 30, 1_000_000); 149 | np.attachView(fl); 150 | np.openCamera(true); 151 | Button publishBtn = findViewById(R.id.publish_btn); 152 | publishBtn.setOnClickListener((v) -> { 153 | np.start("rtmp://192.168.0.2/live/demo"); 154 | }); 155 | } 156 | 157 | @Override 158 | protected void onDestroy() { 159 | super.onDestroy(); 160 | np.detachView(); 161 | np.closeCamera(); 162 | np.stop(); 163 | } 164 | ``` 165 | ## Demo 166 | [https://cdn.nodemedia.cn/NodeMediaClient/NodeMediaClient-AndroidDemo.zip](https://cdn.nodemedia.cn/NodeMediaClient/NodeMediaClient-AndroidDemo.zip) 167 | 168 | ## License 169 | A commercial license is required. 170 | [https://www.nodemedia.cn/product/nodemediaclient-android/](https://www.nodemedia.cn/product/nodemediaclient-android/) 171 | 172 | ## Business & Technical service 173 | * QQ: 281269007 174 | * Email: service@nodemedia.cn 175 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | 5 | repositories { 6 | google() 7 | jcenter() 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:4.2.2' 11 | 12 | 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | google() 21 | jcenter() 22 | maven { url 'https://jitpack.io' } 23 | 24 | } 25 | } 26 | 27 | task clean(type: Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | android.useAndroidX=true 19 | android.enableJetifier=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NodeMedia/NodeMediaClient-Android/a434c6c5394a4a854585442b9537d7ed17c0e295/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':NodeMediaClient' 2 | --------------------------------------------------------------------------------