@byteplus/react-native-rtc 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +313 -5
- package/android/build.gradle +14 -33
- package/android/src/main/java/com/volcengine/reactnative/vertc/VertcViewManager.java +1 -1
- package/android/src/main/java/com/volcengine/reactnative/vertc/events/ClassHelper.java +149 -0
- package/android/src/main/java/com/volcengine/reactnative/vertc/vod/VertcVod.java +29 -13
- package/android/src/main/java/com/volcengine/reactnative/vertc/vod/VideoAudioProcessor.java +9 -11
- package/android/src/main/java/com/volcengine/reactnative/vertc/vod/VodMock.java +17 -6
- package/android/src/main/java/com/volcengine/reactnative/vertc/vod/VodVideoEngineCallbackProxy.java +94 -0
- package/ios/VertcView.m +1 -1
- package/ios/VertcViewManager.m +1 -1
- package/ios/vod/VertcVod.m +20 -5
- package/ios/vod/VodAudioProcessor.h +6 -1
- package/ios/vod/VodAudioProcessor.mm +9 -1
- package/ios/vod/VodVideoProcessor.h +3 -1
- package/ios/vod/VodVideoProcessor.m +22 -2
- package/lib/commonjs/index.js +132 -17
- package/lib/module/index.js +132 -17
- package/lib/typescript/codegen/pack/keytype.d.ts +3 -3
- package/lib/typescript/component.d.ts +9 -2
- package/lib/typescript/core/rtc-video.d.ts +8 -1
- package/lib/typescript/platforms/android/vod.d.ts +2 -2
- package/package.json +1 -1
- package/react-native-rtc.podspec +39 -16
- package/android/src/main/java/com/volcengine/reactnative/vertc/vod/VodAudioProxy.java +0 -44
- package/android/src/main/java/com/volcengine/reactnative/vertc/vod/VodAudioVoiceWrapperObject.java +0 -355
- package/android/src/main/java/com/volcengine/reactnative/vertc/vod/VodVideoProxy.java +0 -97
|
@@ -20,14 +20,16 @@ import java.nio.ByteBuffer;
|
|
|
20
20
|
import java.util.concurrent.TimeUnit;
|
|
21
21
|
|
|
22
22
|
public class VideoAudioProcessor extends AudioProcessor {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
private final VodAudioProcessor processor;
|
|
26
|
-
private final RTCVideo mRTCEngine;
|
|
23
|
+
public String TAG = "VideoAudioProcessor";
|
|
27
24
|
|
|
28
|
-
|
|
25
|
+
private org.json.JSONObject mOptions;
|
|
26
|
+
private final VodAudioProcessor processor;
|
|
27
|
+
private final RTCVideo mRTCEngine;
|
|
28
|
+
|
|
29
|
+
public VideoAudioProcessor(RTCVideo engine, org.json.JSONObject options) {
|
|
29
30
|
processor = new VodAudioProcessor(engine);
|
|
30
31
|
mRTCEngine = engine;
|
|
32
|
+
mOptions = options;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
public void updateScreenConfig(int width, int height) {
|
|
@@ -38,7 +40,6 @@ public class VideoAudioProcessor extends AudioProcessor {
|
|
|
38
40
|
videoEncoderConfig.height = height;
|
|
39
41
|
videoEncoderConfig.encodePreference = ScreenVideoEncoderConfig.EncoderPreference.MaintainFramerate;
|
|
40
42
|
mRTCEngine.setScreenVideoEncoderConfig(videoEncoderConfig);
|
|
41
|
-
// mRTCEngine.publishScreen(RTCEngine.MediaStreamType.RTC_MEDIA_STREAM_TYPE_BOTH);
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
@Override
|
|
@@ -53,7 +54,6 @@ public class VideoAudioProcessor extends AudioProcessor {
|
|
|
53
54
|
|
|
54
55
|
@Override
|
|
55
56
|
public void audioClose() {
|
|
56
|
-
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
@Override
|
|
@@ -61,16 +61,14 @@ public class VideoAudioProcessor extends AudioProcessor {
|
|
|
61
61
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
public void onFrameAvailable(EGLContext eglContext, int oesTextureId, float[] transformMatrix, int width, int height) {
|
|
65
|
-
long nanoTime = System.currentTimeMillis() * TimeUnit.MILLISECONDS.toNanos(1);
|
|
64
|
+
public void onFrameAvailable(EGLContext eglContext, int oesTextureId, float[] transformMatrix, int width, int height, long timestamp) {
|
|
66
65
|
GLTextureVideoFrameBuilder builder = new GLTextureVideoFrameBuilder(VideoPixelFormat.TEXTURE_OES)
|
|
67
66
|
.setTextureID(oesTextureId)
|
|
68
67
|
.setWidth(width)
|
|
69
68
|
.setHeight(height)
|
|
70
69
|
.setRotation(VideoRotation.VIDEO_ROTATION_0)
|
|
71
70
|
.setTextureMatrix(transformMatrix)
|
|
72
|
-
.setTimeStampUs(
|
|
73
|
-
.setColorSpace(ColorSpace.UNKNOWN)
|
|
71
|
+
.setTimeStampUs(timestamp)
|
|
74
72
|
.setEGLContext(eglContext);
|
|
75
73
|
int ret_status = mRTCEngine.pushScreenVideoFrame(builder.build());
|
|
76
74
|
boolean result = ret_status == ReturnStatus.RETURN_STATUS_SUCCESS.value()
|
|
@@ -5,36 +5,47 @@ package com.volcengine.reactnative.vertc.vod;
|
|
|
5
5
|
|
|
6
6
|
import android.os.Handler;
|
|
7
7
|
import android.os.Looper;
|
|
8
|
-
import android.util.Log;
|
|
9
8
|
|
|
10
9
|
import com.ss.bytertc.engine.RTCVideo;
|
|
10
|
+
import com.ss.bytertc.engine.data.AudioSourceType;
|
|
11
|
+
import com.ss.bytertc.engine.data.StreamIndex;
|
|
11
12
|
import com.ss.bytertc.engine.data.VideoPixelFormat;
|
|
12
13
|
import com.ss.bytertc.engine.data.VideoRotation;
|
|
14
|
+
import com.ss.bytertc.engine.data.VideoSourceType;
|
|
13
15
|
import com.ss.bytertc.engine.video.VideoFrame;
|
|
14
16
|
import com.ss.bytertc.engine.video.builder.CpuBufferVideoFrameBuilder;
|
|
15
17
|
|
|
16
18
|
import java.nio.ByteBuffer;
|
|
17
19
|
import java.util.concurrent.TimeUnit;
|
|
18
20
|
|
|
21
|
+
// For Test pushScreenVideoFrame
|
|
19
22
|
public class VodMock {
|
|
20
|
-
public String TAG = "
|
|
23
|
+
public String TAG = "VodMockTest";
|
|
21
24
|
|
|
22
25
|
private final RTCVideo mRTCEngine;
|
|
26
|
+
private final int mFps;
|
|
23
27
|
|
|
24
28
|
public VodMock(RTCVideo engine) {
|
|
25
29
|
mRTCEngine = engine;
|
|
30
|
+
mFps = 30;
|
|
26
31
|
}
|
|
27
32
|
|
|
28
|
-
public void
|
|
33
|
+
public void start() {
|
|
34
|
+
mRTCEngine.setScreenAudioSourceType(AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL);
|
|
35
|
+
mRTCEngine.setVideoSourceType(StreamIndex.STREAM_INDEX_SCREEN, VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL);
|
|
36
|
+
useFakeVideoFrame();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private void useFakeVideoFrame() {
|
|
29
40
|
final Handler handler = new Handler(Looper.getMainLooper());
|
|
30
41
|
var width = 998;
|
|
31
42
|
var height = 554;
|
|
32
43
|
Runnable runnable = new Runnable() {
|
|
33
44
|
@Override
|
|
34
45
|
public void run() {
|
|
35
|
-
handler.postDelayed(this,
|
|
46
|
+
handler.postDelayed(this, 1000 / mFps);
|
|
36
47
|
|
|
37
|
-
var frame =
|
|
48
|
+
var frame = buildInternalVideoFrame(width, height);
|
|
38
49
|
mRTCEngine.pushScreenVideoFrame(frame);
|
|
39
50
|
// Log.d(TAG, "pushScreenVideoFrame");
|
|
40
51
|
}
|
|
@@ -42,7 +53,7 @@ public class VodMock {
|
|
|
42
53
|
handler.post(runnable);
|
|
43
54
|
}
|
|
44
55
|
|
|
45
|
-
|
|
56
|
+
private VideoFrame buildInternalVideoFrame(int width, int height){
|
|
46
57
|
int chromaWidth = (width + 1) / 2;
|
|
47
58
|
int chromaHeight = (height + 1) /2;
|
|
48
59
|
int uvSize = chromaWidth * chromaHeight;
|
package/android/src/main/java/com/volcengine/reactnative/vertc/vod/VodVideoEngineCallbackProxy.java
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// Copyright © 2022 BytePlusRTC All rights reserved.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
package com.volcengine.reactnative.vertc.vod;
|
|
5
|
+
|
|
6
|
+
import android.util.Log;
|
|
7
|
+
|
|
8
|
+
import com.ss.ttvideoengine.TTVideoEngine;
|
|
9
|
+
import com.ss.ttvideoengine.VideoEngineCallback;
|
|
10
|
+
|
|
11
|
+
import java.lang.reflect.Field;
|
|
12
|
+
import java.lang.reflect.Method;
|
|
13
|
+
import java.lang.reflect.Proxy;
|
|
14
|
+
|
|
15
|
+
// TTVideoEngine 只会保存一个 VideoEngineCallback
|
|
16
|
+
// 但是我们需要监听 VideoEngineCallback,会和用户设置的 VideoEngineCallback 冲突
|
|
17
|
+
// 因此,我们添加一层代理,同时触发用户的 VideoEngineCallback 和我们内部的 VideoEngineCallback
|
|
18
|
+
// 结束后再 reset
|
|
19
|
+
public class VodVideoEngineCallbackProxy implements VideoEngineCallback {
|
|
20
|
+
public final String TAG = "VodVideoEngineCallback";
|
|
21
|
+
|
|
22
|
+
public VideoEngineCallback mOriginalCallback = null;
|
|
23
|
+
public VideoEngineCallback mCallback = null;
|
|
24
|
+
public VideoEngineCallback mProxyCallback = null;
|
|
25
|
+
|
|
26
|
+
public VodVideoEngineCallbackProxy(TTVideoEngine ttVideoEngine, VideoEngineCallback callback) {
|
|
27
|
+
mCallback = callback;
|
|
28
|
+
mOriginalCallback = findOriginalCallback(ttVideoEngine);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public VideoEngineCallback listen() {
|
|
32
|
+
Class<VideoEngineCallback> clazz = VideoEngineCallback.class;
|
|
33
|
+
Object dynamicObserver = Proxy.newProxyInstance(
|
|
34
|
+
clazz.getClassLoader(), // 使用Observer接口的类加载器
|
|
35
|
+
new Class[]{clazz}, // 指定要代理的接口
|
|
36
|
+
(proxy, method, args) -> {
|
|
37
|
+
if (mOriginalCallback != null) {
|
|
38
|
+
triggerCallback(method, args);
|
|
39
|
+
return invokeOriginal(method, args);
|
|
40
|
+
}
|
|
41
|
+
return triggerCallback(method, args);
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
mProxyCallback = (VideoEngineCallback) dynamicObserver;
|
|
45
|
+
return mProxyCallback;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public void reset(TTVideoEngine ttVideoEngine) {
|
|
49
|
+
if (ttVideoEngine != null) {
|
|
50
|
+
if (findOriginalCallback(ttVideoEngine) == mProxyCallback) {
|
|
51
|
+
ttVideoEngine.setVideoEngineCallback(mOriginalCallback);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private Object invokeOriginal(Method method, Object[] args) {
|
|
57
|
+
try {
|
|
58
|
+
Method originalCallbackMethod = mOriginalCallback.getClass().getMethod(method.getName(), method.getParameterTypes());
|
|
59
|
+
return originalCallbackMethod.invoke(mOriginalCallback, args);
|
|
60
|
+
} catch (Exception ignore) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private Object triggerCallback(Method method, Object[] args) {
|
|
66
|
+
try {
|
|
67
|
+
Method cbMethod = mCallback.getClass().getMethod(method.getName(), method.getParameterTypes());
|
|
68
|
+
return cbMethod.invoke(mCallback, args);
|
|
69
|
+
} catch (Exception ignore) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private VideoEngineCallback findOriginalCallback(TTVideoEngine ttVideoEngine) {
|
|
75
|
+
if (ttVideoEngine == null) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
Field mVideoEngineField = TTVideoEngine.class.getDeclaredField("mVideoEngine");
|
|
80
|
+
mVideoEngineField.setAccessible(true);
|
|
81
|
+
Object mVideoEngine = mVideoEngineField.get(ttVideoEngine);
|
|
82
|
+
Field mListenerCompactField = mVideoEngine.getClass().getDeclaredField("mListenerCompact");
|
|
83
|
+
mListenerCompactField.setAccessible(true);
|
|
84
|
+
Object mListenerCompact = mListenerCompactField.get(mVideoEngine);
|
|
85
|
+
Field mEngineCallbackField = mListenerCompact.getClass().getDeclaredField("mEngineCallback");
|
|
86
|
+
mEngineCallbackField.setAccessible(true);
|
|
87
|
+
Object mEngineCallback = mEngineCallbackField.get(mListenerCompact);
|
|
88
|
+
return (VideoEngineCallback) mEngineCallback;
|
|
89
|
+
} catch (Exception e) {
|
|
90
|
+
Log.w(TAG, "can't find original TTVideoEngine Callback, reason: " + e.getMessage());
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
package/ios/VertcView.m
CHANGED
package/ios/VertcViewManager.m
CHANGED
package/ios/vod/VertcVod.m
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
@interface VertcVod ()
|
|
14
14
|
|
|
15
|
+
@property (nonatomic, strong) NSDictionary *options;
|
|
15
16
|
@property (nonatomic, strong) ByteRTCVideo *rtcEngine;
|
|
16
17
|
@property (nonatomic, strong) TTVideoEngine *videoEngine;
|
|
17
18
|
@property (nonatomic, strong) VodAudioProcessor *audioProcesser;
|
|
@@ -49,9 +50,13 @@
|
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
self.rtcEngine = rtc;
|
|
53
|
+
self.options = options;
|
|
52
54
|
self.videoEngine = videoEngine;
|
|
53
|
-
self.audioProcesser = [[VodAudioProcessor alloc] initWithRTCKit:rtc];
|
|
54
|
-
self.videoProcesser = [[VodVideoProcessor alloc] initWithRTCKit:rtc];
|
|
55
|
+
self.audioProcesser = [[VodAudioProcessor alloc] initWithRTCKit:rtc options:options];
|
|
56
|
+
self.videoProcesser = [[VodVideoProcessor alloc] initWithRTCKit:rtc options:options];
|
|
57
|
+
|
|
58
|
+
[rtc setVideoSourceType:ByteRTCVideoSourceTypeExternal WithStreamIndex:ByteRTCStreamIndexScreen];
|
|
59
|
+
[rtc setScreenAudioSourceType:ByteRTCAudioSourceTypeExternal];
|
|
55
60
|
|
|
56
61
|
ttAudioWrapper.open = openAudio;
|
|
57
62
|
ttAudioWrapper.process = processAudio;
|
|
@@ -70,9 +75,16 @@
|
|
|
70
75
|
|
|
71
76
|
- (int) stopVodPlayerCapture:(ByteRTCVideo *)rtc;
|
|
72
77
|
{
|
|
78
|
+
[self.videoEngine setAudioProcessor:NULL];
|
|
79
|
+
self.audioProcesser = nil;
|
|
80
|
+
self.videoProcesser = nil;
|
|
73
81
|
ttAudioWrapper.context = NULL;
|
|
74
82
|
ttVideoWrapper.context = NULL;
|
|
75
83
|
[rtc setVideoSourceType:ByteRTCVideoSourceTypeInternal WithStreamIndex:ByteRTCStreamIndexScreen];
|
|
84
|
+
[rtc setScreenAudioSourceType:ByteRTCAudioSourceTypeInternal];
|
|
85
|
+
self.options = nil;
|
|
86
|
+
self.rtcEngine = nil;
|
|
87
|
+
self.videoEngine = nil;
|
|
76
88
|
return 0;
|
|
77
89
|
}
|
|
78
90
|
|
|
@@ -99,11 +111,13 @@ static void processAudio (void *context, float **inouts, int samples, int64_t ti
|
|
|
99
111
|
}
|
|
100
112
|
|
|
101
113
|
static void closeAudio (void *context) {
|
|
102
|
-
|
|
114
|
+
VodAudioProcessor *process = (__bridge VodAudioProcessor *)(context);
|
|
115
|
+
[process closeAudio];
|
|
103
116
|
}
|
|
104
117
|
|
|
105
118
|
static void releaseAudio (void *context) {
|
|
106
|
-
|
|
119
|
+
VodAudioProcessor *process = (__bridge VodAudioProcessor *)(context);
|
|
120
|
+
[process releaseAudio];
|
|
107
121
|
}
|
|
108
122
|
|
|
109
123
|
|
|
@@ -114,7 +128,8 @@ static void videoProcessFunc(void *context, CVPixelBufferRef frame, int64_t time
|
|
|
114
128
|
}
|
|
115
129
|
|
|
116
130
|
static void videoReleaseFunc(void *context) {
|
|
117
|
-
|
|
131
|
+
VodVideoProcessor *process = (__bridge VodVideoProcessor *)(context);
|
|
132
|
+
[process releaseVideo];
|
|
118
133
|
}
|
|
119
134
|
|
|
120
135
|
@end
|
|
@@ -19,7 +19,7 @@ extern int VoidAudioMixingID;
|
|
|
19
19
|
|
|
20
20
|
/// Initialize
|
|
21
21
|
/// @param rtcKit ByteRTCEngineKit
|
|
22
|
-
- (instancetype)initWithRTCKit:(ByteRTCVideo *)rtcKit;
|
|
22
|
+
- (instancetype)initWithRTCKit:(ByteRTCVideo *)rtcKit options:(NSDictionary *)options;
|
|
23
23
|
|
|
24
24
|
/// Open audio
|
|
25
25
|
/// @param samplerate Samplerate
|
|
@@ -31,5 +31,10 @@ extern int VoidAudioMixingID;
|
|
|
31
31
|
/// @param samples Samples
|
|
32
32
|
- (void)processAudio:(float **)inouts samples:(int)samples timestamp:(int64_t)timestamp;
|
|
33
33
|
|
|
34
|
+
/// Close audio
|
|
35
|
+
- (void)closeAudio;
|
|
36
|
+
|
|
37
|
+
/// Release audio
|
|
38
|
+
- (void)releaseAudio;
|
|
34
39
|
|
|
35
40
|
@end
|
|
@@ -13,6 +13,7 @@ int VoidAudioMixingID = 3001;
|
|
|
13
13
|
@interface VodAudioProcessor ()
|
|
14
14
|
|
|
15
15
|
@property (nonatomic, weak) ByteRTCVideo *rtcKit;
|
|
16
|
+
@property (nonatomic, weak) NSDictionary *options;
|
|
16
17
|
@property (nonatomic, assign) int length;
|
|
17
18
|
|
|
18
19
|
@end
|
|
@@ -25,9 +26,10 @@ int VoidAudioMixingID = 3001;
|
|
|
25
26
|
int64_t _lastTimestamp;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
- (instancetype)initWithRTCKit:(ByteRTCVideo *)rtcKit {
|
|
29
|
+
- (instancetype)initWithRTCKit:(ByteRTCVideo *)rtcKit options:(NSDictionary *)options {
|
|
29
30
|
if (self = [super init]) {
|
|
30
31
|
self.rtcKit = rtcKit;
|
|
32
|
+
self.options = options;
|
|
31
33
|
_lastDiffTimestamp = 0;
|
|
32
34
|
_lastTimestamp = 0;
|
|
33
35
|
[rtcKit setScreenAudioSourceType:ByteRTCAudioSourceTypeExternal];
|
|
@@ -40,6 +42,12 @@ int VoidAudioMixingID = 3001;
|
|
|
40
42
|
_channels = channels;
|
|
41
43
|
}
|
|
42
44
|
|
|
45
|
+
- (void)closeAudio {
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
- (void)releaseAudio {
|
|
49
|
+
}
|
|
50
|
+
|
|
43
51
|
- (void)processAudio:(float **)inouts samples:(int)samples timestamp:(int64_t)timestamp {
|
|
44
52
|
NSTimeInterval time = [[NSDate dateWithTimeIntervalSinceNow:0] timeIntervalSince1970] * 1000;
|
|
45
53
|
NSTimeInterval diffTime = (time - _lastDiffTimestamp);
|
|
@@ -16,11 +16,13 @@
|
|
|
16
16
|
|
|
17
17
|
/// Initialize
|
|
18
18
|
/// @param rtcKit ByteRTCEngineKit
|
|
19
|
-
- (instancetype)initWithRTCKit:(ByteRTCVideo *)rtcKit;
|
|
19
|
+
- (instancetype)initWithRTCKit:(ByteRTCVideo *)rtcKit options:(NSDictionary *)options;
|
|
20
20
|
|
|
21
21
|
/// Process video
|
|
22
22
|
/// @param frame Video pixel buffer
|
|
23
23
|
/// @param timestamp Timestamp
|
|
24
24
|
- (void)processVideo:(CVPixelBufferRef)frame timestamp:(int64_t)timestamp;
|
|
25
25
|
|
|
26
|
+
- (void)releaseVideo;
|
|
27
|
+
|
|
26
28
|
@end
|
|
@@ -14,21 +14,41 @@
|
|
|
14
14
|
@interface VodVideoProcessor ()
|
|
15
15
|
|
|
16
16
|
@property (nonatomic, weak) ByteRTCVideo *rtcKit;
|
|
17
|
+
@property (nonatomic, weak) NSDictionary *options;
|
|
18
|
+
@property (nonatomic, assign) NSInteger time;
|
|
19
|
+
@property (nonatomic, assign) int fps;
|
|
17
20
|
|
|
18
21
|
@end
|
|
19
22
|
|
|
20
23
|
@implementation VodVideoProcessor
|
|
21
24
|
|
|
22
|
-
- (instancetype)initWithRTCKit:(ByteRTCVideo *)rtcKit {
|
|
25
|
+
- (instancetype)initWithRTCKit:(ByteRTCVideo *)rtcKit options:(NSDictionary *)options {
|
|
23
26
|
if (self = [super init]) {
|
|
24
27
|
self.rtcKit = rtcKit;
|
|
28
|
+
self.options = options;
|
|
29
|
+
self.fps = [[options valueForKey:@"fps"] intValue];
|
|
30
|
+
self.time = 0;
|
|
25
31
|
[rtcKit setVideoSourceType:ByteRTCVideoSourceTypeExternal WithStreamIndex:ByteRTCStreamIndexScreen];
|
|
26
32
|
}
|
|
27
33
|
return self;
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
- (void)processVideo:(CVPixelBufferRef)frame timestamp:(int64_t)timestamp {
|
|
31
|
-
|
|
37
|
+
if (_fps < 1) {
|
|
38
|
+
if (timestamp > 0) {
|
|
39
|
+
_fps = 1000 / (timestamp - 0);
|
|
40
|
+
NSLog(@"detect video fps=%d", _fps);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
int res = [self.rtcKit pushScreenVideoFrame:frame time:CMTimeMake(self.time, self.fps) rotation:0];
|
|
44
|
+
if (res != 0) {
|
|
45
|
+
NSLog(@"bytertc pushScreenVideoFrame fail return '%d'", res);
|
|
46
|
+
}
|
|
47
|
+
self.time += 1;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
- (void)releaseVideo {
|
|
51
|
+
NSLog(@"video release");
|
|
32
52
|
}
|
|
33
53
|
|
|
34
54
|
@end
|
package/lib/commonjs/index.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
6
|
var reactNative = require('react-native');
|
|
7
|
+
var React = require('react');
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* base64.ts
|
|
@@ -312,6 +313,17 @@ function packObject(receiver, ctor) {
|
|
|
312
313
|
function unpackObject(proxyInstance, _nativeClass) {
|
|
313
314
|
return proxyInstance._instance;
|
|
314
315
|
}
|
|
316
|
+
|
|
317
|
+
function findProto(ctor, name) {
|
|
318
|
+
let proto = ctor.prototype;
|
|
319
|
+
while (proto) {
|
|
320
|
+
if (Object.getOwnPropertyDescriptor(proto, name)) {
|
|
321
|
+
return proto;
|
|
322
|
+
}
|
|
323
|
+
proto = Object.getPrototypeOf(proto);
|
|
324
|
+
}
|
|
325
|
+
return undefined;
|
|
326
|
+
}
|
|
315
327
|
function extendsClassMethod(ctor, methodName, overrideFn) {
|
|
316
328
|
const proto = ctor.prototype;
|
|
317
329
|
const originalFn = ctor.prototype[methodName];
|
|
@@ -319,6 +331,24 @@ function extendsClassMethod(ctor, methodName, overrideFn) {
|
|
|
319
331
|
return overrideFn(originalFn?.bind(this)).apply(this, args);
|
|
320
332
|
};
|
|
321
333
|
}
|
|
334
|
+
function extendsClassMember(ctor, memberName) {
|
|
335
|
+
return (handler) => {
|
|
336
|
+
const targetProto = findProto(ctor, memberName);
|
|
337
|
+
const originalDesc = targetProto
|
|
338
|
+
? Object.getOwnPropertyDescriptor(targetProto, memberName)
|
|
339
|
+
: undefined;
|
|
340
|
+
const newDesc = handler({
|
|
341
|
+
getter: originalDesc?.get,
|
|
342
|
+
setter: originalDesc?.set,
|
|
343
|
+
});
|
|
344
|
+
Object.defineProperty(ctor.prototype, memberName, {
|
|
345
|
+
enumerable: originalDesc?.enumerable ?? true,
|
|
346
|
+
configurable: originalDesc?.configurable ?? true,
|
|
347
|
+
get: newDesc.getter || originalDesc?.get,
|
|
348
|
+
set: newDesc.setter || originalDesc?.set,
|
|
349
|
+
});
|
|
350
|
+
};
|
|
351
|
+
}
|
|
322
352
|
|
|
323
353
|
let impl;
|
|
324
354
|
function setupEnv(e) {
|
|
@@ -43376,9 +43406,9 @@ exports.LocalProxyError = void 0;
|
|
|
43376
43406
|
})(exports.LocalProxyError || (exports.LocalProxyError = {}));
|
|
43377
43407
|
exports.MediaStreamType = void 0;
|
|
43378
43408
|
(function (MediaStreamType) {
|
|
43379
|
-
MediaStreamType[MediaStreamType["RTC_MEDIA_STREAM_TYPE_AUDIO"] =
|
|
43380
|
-
MediaStreamType[MediaStreamType["RTC_MEDIA_STREAM_TYPE_VIDEO"] =
|
|
43381
|
-
MediaStreamType[MediaStreamType["RTC_MEDIA_STREAM_TYPE_BOTH"] =
|
|
43409
|
+
MediaStreamType[MediaStreamType["RTC_MEDIA_STREAM_TYPE_AUDIO"] = 1] = "RTC_MEDIA_STREAM_TYPE_AUDIO";
|
|
43410
|
+
MediaStreamType[MediaStreamType["RTC_MEDIA_STREAM_TYPE_VIDEO"] = 2] = "RTC_MEDIA_STREAM_TYPE_VIDEO";
|
|
43411
|
+
MediaStreamType[MediaStreamType["RTC_MEDIA_STREAM_TYPE_BOTH"] = 3] = "RTC_MEDIA_STREAM_TYPE_BOTH";
|
|
43382
43412
|
})(exports.MediaStreamType || (exports.MediaStreamType = {}));
|
|
43383
43413
|
exports.MediaDeviceState = void 0;
|
|
43384
43414
|
(function (MediaDeviceState) {
|
|
@@ -67092,7 +67122,7 @@ var VertcVod$1 = function () {
|
|
|
67092
67122
|
function VertcVod_1() {
|
|
67093
67123
|
__runInitializers(this, _instanceExtraInitializers);
|
|
67094
67124
|
}
|
|
67095
|
-
VertcVod_1.prototype.startVodPlayerCapture = function (video, player,
|
|
67125
|
+
VertcVod_1.prototype.startVodPlayerCapture = function (video, player, options) {
|
|
67096
67126
|
throw new Error('not implement');
|
|
67097
67127
|
};
|
|
67098
67128
|
VertcVod_1.prototype.stopVodPlayerCapture = function (video) {
|
|
@@ -67156,6 +67186,77 @@ var VertcVod = function () {
|
|
|
67156
67186
|
return _classThis;
|
|
67157
67187
|
}();
|
|
67158
67188
|
|
|
67189
|
+
extendsClassMember(LocalVideoStats, 'codecType')(function () {
|
|
67190
|
+
return {
|
|
67191
|
+
getter: function () {
|
|
67192
|
+
var _a;
|
|
67193
|
+
var $os = env.getOS();
|
|
67194
|
+
if ($os === 'android') {
|
|
67195
|
+
var value = this._instance.codecType;
|
|
67196
|
+
var $m = (_a = {},
|
|
67197
|
+
_a[exports.VideoCodecType.VIDEO_CODEC_TYPE_H264] = exports.VideoCodecType.VIDEO_CODEC_TYPE_H264,
|
|
67198
|
+
_a[exports.VideoCodecType.VIDEO_CODEC_TYPE_BYTEVC1] = exports.VideoCodecType.VIDEO_CODEC_TYPE_BYTEVC1,
|
|
67199
|
+
_a[VideoConfig$VideoCodecType.VIDEO_CODEC_TYPE_H264] = exports.VideoCodecType.VIDEO_CODEC_TYPE_H264,
|
|
67200
|
+
_a[VideoConfig$VideoCodecType.VIDEO_CODEC_TYPE_BYTEVC1] = exports.VideoCodecType.VIDEO_CODEC_TYPE_BYTEVC1,
|
|
67201
|
+
_a);
|
|
67202
|
+
if (!(value in $m)) {
|
|
67203
|
+
throw new Error('invalid value:' + value);
|
|
67204
|
+
}
|
|
67205
|
+
// @ts-ignore
|
|
67206
|
+
return $m[value];
|
|
67207
|
+
}
|
|
67208
|
+
else if ($os === 'ios') {
|
|
67209
|
+
return t_VideoCodecType.ios_to_ts(this._instance.codecType);
|
|
67210
|
+
}
|
|
67211
|
+
else {
|
|
67212
|
+
throw new Error('Not Support Platform ' + $os);
|
|
67213
|
+
}
|
|
67214
|
+
},
|
|
67215
|
+
};
|
|
67216
|
+
});
|
|
67217
|
+
extendsClassMember(RemoteVideoStats, 'codecType')(function () {
|
|
67218
|
+
return {
|
|
67219
|
+
getter: function () {
|
|
67220
|
+
var _a;
|
|
67221
|
+
var $os = env.getOS();
|
|
67222
|
+
if ($os === 'android') {
|
|
67223
|
+
var value = this._instance.codecType;
|
|
67224
|
+
var $m = (_a = {},
|
|
67225
|
+
_a[exports.VideoCodecType.VIDEO_CODEC_TYPE_H264] = exports.VideoCodecType.VIDEO_CODEC_TYPE_H264,
|
|
67226
|
+
_a[exports.VideoCodecType.VIDEO_CODEC_TYPE_BYTEVC1] = exports.VideoCodecType.VIDEO_CODEC_TYPE_BYTEVC1,
|
|
67227
|
+
_a[VideoConfig$VideoCodecType.VIDEO_CODEC_TYPE_H264] = exports.VideoCodecType.VIDEO_CODEC_TYPE_H264,
|
|
67228
|
+
_a[VideoConfig$VideoCodecType.VIDEO_CODEC_TYPE_BYTEVC1] = exports.VideoCodecType.VIDEO_CODEC_TYPE_BYTEVC1,
|
|
67229
|
+
_a);
|
|
67230
|
+
if (!(value in $m)) {
|
|
67231
|
+
throw new Error('invalid value:' + value);
|
|
67232
|
+
}
|
|
67233
|
+
// @ts-ignore
|
|
67234
|
+
return $m[value];
|
|
67235
|
+
}
|
|
67236
|
+
else if ($os === 'ios') {
|
|
67237
|
+
return t_VideoCodecType.ios_to_ts(this._instance.codecType);
|
|
67238
|
+
}
|
|
67239
|
+
else {
|
|
67240
|
+
throw new Error('Not Support Platform ' + $os);
|
|
67241
|
+
}
|
|
67242
|
+
},
|
|
67243
|
+
};
|
|
67244
|
+
});
|
|
67245
|
+
extendsClassMethod(android_RTCRoomEventHandler, 'onStreamRemove', function () {
|
|
67246
|
+
return function impl(stream, reason) {
|
|
67247
|
+
if (this._instance.onStreamRemove) {
|
|
67248
|
+
this._instance.onStreamRemove(packObject(stream, RTCStream), t_StreamRemoveReason.android_to_ts(reason));
|
|
67249
|
+
}
|
|
67250
|
+
};
|
|
67251
|
+
});
|
|
67252
|
+
extendsClassMethod(ios_RTCRoomEventHandler, 'rtcRoom$onStreamRemove$stream$reason', function () {
|
|
67253
|
+
return function impl(rtcRoom, uid, stream, reason) {
|
|
67254
|
+
if (this._instance.onStreamRemove) {
|
|
67255
|
+
this._instance.onStreamRemove(packObject(stream, RTCStream), t_StreamRemoveReason.ios_to_ts(reason));
|
|
67256
|
+
}
|
|
67257
|
+
};
|
|
67258
|
+
});
|
|
67259
|
+
|
|
67159
67260
|
extendsClassMethod(RTCVideo, 'feedback', function () {
|
|
67160
67261
|
return function impl(options, info) {
|
|
67161
67262
|
var _this = this;
|
|
@@ -67278,31 +67379,29 @@ extendsClassMethod(RTCVideo, 'setRemoteAudioPlaybackVolume', function () {
|
|
|
67278
67379
|
});
|
|
67279
67380
|
var VodHelperKey = '_vod';
|
|
67280
67381
|
extendsClassMethod(RTCVideo, 'startVodPlayerCapture', function () {
|
|
67281
|
-
return function impl(player) {
|
|
67382
|
+
return function impl(player, options) {
|
|
67282
67383
|
var _this = this;
|
|
67283
|
-
|
|
67384
|
+
if (options === void 0) { options = {}; }
|
|
67385
|
+
if (!player) {
|
|
67386
|
+
throw new Error('Vod player instance is required.');
|
|
67387
|
+
}
|
|
67388
|
+
var unpackedPlayer = unpackObject(player);
|
|
67284
67389
|
var a = function () {
|
|
67285
67390
|
var androidRtc = unpackObject(_this);
|
|
67286
|
-
var androidStreamIndex = t_StreamIndex.ts_to_android(streamIndex);
|
|
67287
|
-
// androidRtc.setVideoSourceType(
|
|
67288
|
-
// androidStreamIndex,
|
|
67289
|
-
// $p_a.VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL,
|
|
67290
|
-
// );
|
|
67291
|
-
// androidRtc.setScreenAudioSourceType(
|
|
67292
|
-
// $p_a.AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL,
|
|
67293
|
-
// );
|
|
67294
67391
|
var ins = new VertcVod$1();
|
|
67295
67392
|
_this[VodHelperKey] = ins;
|
|
67296
|
-
return ins.startVodPlayerCapture(androidRtc,
|
|
67393
|
+
return ins.startVodPlayerCapture(androidRtc, unpackedPlayer, options);
|
|
67297
67394
|
};
|
|
67298
67395
|
var i = function () {
|
|
67299
67396
|
var iosRtc = unpackObject(_this);
|
|
67300
67397
|
var ins = new VertcVod();
|
|
67301
67398
|
_this[VodHelperKey] = ins;
|
|
67302
|
-
return ins.startVodPlayerCapture(iosRtc,
|
|
67399
|
+
return ins.startVodPlayerCapture(iosRtc, unpackedPlayer, options);
|
|
67303
67400
|
};
|
|
67304
67401
|
var $os = env.getOS();
|
|
67305
67402
|
if ($os === 'android') {
|
|
67403
|
+
// Using surface texutre for rendering.
|
|
67404
|
+
unpackedPlayer.setIntOption(199, 0);
|
|
67306
67405
|
return a();
|
|
67307
67406
|
}
|
|
67308
67407
|
else if ($os === 'ios') {
|
|
@@ -67764,7 +67863,23 @@ var RTCManager = /** @class */ (function () {
|
|
|
67764
67863
|
}());
|
|
67765
67864
|
|
|
67766
67865
|
var NativeViewComponentName = 'VertcView';
|
|
67767
|
-
var
|
|
67866
|
+
var VertcView = reactNative.requireNativeComponent(NativeViewComponentName);
|
|
67867
|
+
var NativeViewComponent = /** @class */ (function (_super) {
|
|
67868
|
+
__extends(NativeViewComponent, _super);
|
|
67869
|
+
function NativeViewComponent() {
|
|
67870
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
67871
|
+
}
|
|
67872
|
+
NativeViewComponent.prototype.render = function () {
|
|
67873
|
+
var _a = this.props, viewId = _a.viewId, kind = _a.kind, children = _a.children, style = _a.style, onLoad = _a.onLoad;
|
|
67874
|
+
return React.createElement(VertcView, {
|
|
67875
|
+
viewId: viewId,
|
|
67876
|
+
kind: kind,
|
|
67877
|
+
style: style,
|
|
67878
|
+
onViewLoad: onLoad,
|
|
67879
|
+
}, children);
|
|
67880
|
+
};
|
|
67881
|
+
return NativeViewComponent;
|
|
67882
|
+
}(React.Component));
|
|
67768
67883
|
|
|
67769
67884
|
/** {en}
|
|
67770
67885
|
* @detail keytype
|