@byteplus/react-native-rtc 1.0.0 → 1.0.2
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/android/build.gradle +1 -1
- package/android/src/main/java/com/volcengine/reactnative/vertc/vod/VertcVod.java +10 -26
- package/android/src/main/java/com/volcengine/reactnative/vertc/vod/VideoAudioProcessor.java +8 -9
- package/android/src/main/java/com/volcengine/reactnative/vertc/vod/VodAudioProxy.java +44 -0
- package/android/src/main/java/com/volcengine/reactnative/vertc/vod/VodAudioVoiceWrapperObject.java +355 -0
- package/android/src/main/java/com/volcengine/reactnative/vertc/vod/VodMock.java +6 -17
- package/android/src/main/java/com/volcengine/reactnative/vertc/vod/VodVideoProxy.java +97 -0
- package/ios/vod/VertcVod.m +3 -10
- package/ios/vod/VodAudioProcessor.h +1 -1
- package/ios/vod/VodAudioProcessor.mm +1 -3
- package/ios/vod/VodVideoProcessor.h +1 -3
- package/ios/vod/VodVideoProcessor.m +2 -22
- package/lib/commonjs/index.js +871 -865
- package/lib/module/index.js +871 -865
- package/lib/typescript/codegen/pack/api.d.ts +634 -637
- package/lib/typescript/codegen/pack/callback.d.ts +248 -251
- package/lib/typescript/codegen/pack/errorcode.d.ts +36 -36
- package/lib/typescript/codegen/pack/keytype.d.ts +181 -181
- package/lib/typescript/core/rtc-video.d.ts +1 -7
- package/lib/typescript/core.d.ts +4 -4
- package/lib/typescript/interface.d.ts +63 -64
- package/lib/typescript/platforms/android/vod.d.ts +2 -2
- package/package.json +2 -2
- package/react-native-rtc.podspec +6 -5
- package/android/src/main/java/com/volcengine/reactnative/vertc/vod/VodVideoEngineCallbackProxy.java +0 -94
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Copyright © 2022 BytePlusRTC All rights reserved.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
package com.volcengine.reactnative.vertc.vod;
|
|
5
|
+
|
|
6
|
+
import android.graphics.SurfaceTexture;
|
|
7
|
+
import android.opengl.EGLContext;
|
|
8
|
+
import android.util.Log;
|
|
9
|
+
import android.view.Surface;
|
|
10
|
+
|
|
11
|
+
import com.ss.bytertc.engine.RTCVideo;
|
|
12
|
+
import com.ss.bytertc.engine.data.ColorSpace;
|
|
13
|
+
import com.ss.bytertc.engine.data.ReturnStatus;
|
|
14
|
+
import com.ss.bytertc.engine.data.StreamIndex;
|
|
15
|
+
import com.ss.bytertc.engine.data.VideoPixelFormat;
|
|
16
|
+
import com.ss.bytertc.engine.data.VideoRotation;
|
|
17
|
+
import com.ss.bytertc.engine.data.VideoSourceType;
|
|
18
|
+
import com.ss.bytertc.engine.video.VideoFrame;
|
|
19
|
+
import com.ss.bytertc.engine.video.builder.GLTextureVideoFrameBuilder;
|
|
20
|
+
import com.ss.ttvideoengine.TTVideoEngine;
|
|
21
|
+
import com.ss.ttvideoengine.VideoEngineCallback;
|
|
22
|
+
|
|
23
|
+
public class VodVideoProxy {
|
|
24
|
+
private String TAG = "VodVideoProxy";
|
|
25
|
+
|
|
26
|
+
private TTVideoEngine mVideoEngine;
|
|
27
|
+
private RTCVideo mRTCVideo;
|
|
28
|
+
|
|
29
|
+
private OESTextureProcessor mOESTextureProcessor;
|
|
30
|
+
|
|
31
|
+
private final OESTextureProcessor.IProcessorCallback mProcessorCallback = new OESTextureProcessor.IProcessorCallback() {
|
|
32
|
+
@Override
|
|
33
|
+
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
|
|
34
|
+
TTVideoEngine videoEngine = mVideoEngine;
|
|
35
|
+
if (videoEngine != null) {
|
|
36
|
+
videoEngine.setSurface(new Surface(surface));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@Override
|
|
41
|
+
public void onSurfaceTextureDestroyed(SurfaceTexture surface) {
|
|
42
|
+
TTVideoEngine videoEngine = mVideoEngine;
|
|
43
|
+
if (videoEngine != null) {
|
|
44
|
+
videoEngine.setSurface(null);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@Override
|
|
49
|
+
public void onFrameAvailable(EGLContext eglContext, int oesTextureId, float[] transformMatrix, int width, int height, long timestamp) {
|
|
50
|
+
GLTextureVideoFrameBuilder builder = new GLTextureVideoFrameBuilder(VideoPixelFormat.TEXTURE_OES)
|
|
51
|
+
.setTextureID(oesTextureId)
|
|
52
|
+
.setWidth(width)
|
|
53
|
+
.setHeight(height)
|
|
54
|
+
.setRotation(VideoRotation.VIDEO_ROTATION_0)
|
|
55
|
+
.setTextureMatrix(transformMatrix)
|
|
56
|
+
// .setTimeStampUs(timestamp)
|
|
57
|
+
.setTimeStampUs(System.nanoTime())
|
|
58
|
+
.setColorSpace(ColorSpace.UNKNOWN)
|
|
59
|
+
.setEGLContext(eglContext);
|
|
60
|
+
VideoFrame frame = builder.build();
|
|
61
|
+
// frame.retain();
|
|
62
|
+
// Log.d(TAG, "pushScreenVideoFrame: " + frame));
|
|
63
|
+
int ret_status = mRTCVideo.pushScreenVideoFrame(frame);
|
|
64
|
+
boolean result = ret_status == ReturnStatus.RETURN_STATUS_SUCCESS.value()
|
|
65
|
+
|| ret_status == ReturnStatus.RETURN_STATUS_VIDEO_TIMESTAMP_WARNING.value();
|
|
66
|
+
if (!result) {
|
|
67
|
+
Log.d(TAG, "pushScreenVideoFrame fail: " + ret_status);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
public void initEngine(TTVideoEngine videoEngine, RTCVideo rtcEngine) {
|
|
73
|
+
OESTextureProcessor textureProcessor = mOESTextureProcessor;
|
|
74
|
+
if (textureProcessor != null) {
|
|
75
|
+
textureProcessor.destroy();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
mVideoEngine = videoEngine;
|
|
79
|
+
mRTCVideo = rtcEngine;
|
|
80
|
+
mOESTextureProcessor = new OESTextureProcessor();
|
|
81
|
+
|
|
82
|
+
// var width = mVideoEngine.getVideoWidth();
|
|
83
|
+
// var height = mVideoEngine.getVideoWidth();
|
|
84
|
+
var width = 1920;
|
|
85
|
+
var height = 1080;
|
|
86
|
+
mRTCVideo.setVideoSourceType(StreamIndex.STREAM_INDEX_SCREEN, VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL);
|
|
87
|
+
mOESTextureProcessor.initSurfaceTexture(width, height, mProcessorCallback);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public void release() {
|
|
91
|
+
if (mOESTextureProcessor != null) {
|
|
92
|
+
mOESTextureProcessor.destroy();
|
|
93
|
+
mOESTextureProcessor = null;
|
|
94
|
+
}
|
|
95
|
+
mVideoEngine = null;
|
|
96
|
+
}
|
|
97
|
+
}
|
package/ios/vod/VertcVod.m
CHANGED
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
|
|
13
13
|
@interface VertcVod ()
|
|
14
14
|
|
|
15
|
-
@property (nonatomic, strong) NSDictionary *options;
|
|
16
15
|
@property (nonatomic, strong) ByteRTCVideo *rtcEngine;
|
|
17
16
|
@property (nonatomic, strong) TTVideoEngine *videoEngine;
|
|
18
17
|
@property (nonatomic, strong) VodAudioProcessor *audioProcesser;
|
|
@@ -50,10 +49,9 @@
|
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
self.rtcEngine = rtc;
|
|
53
|
-
self.options = options;
|
|
54
52
|
self.videoEngine = videoEngine;
|
|
55
|
-
self.audioProcesser = [[VodAudioProcessor alloc] initWithRTCKit:rtc
|
|
56
|
-
self.videoProcesser = [[VodVideoProcessor alloc] initWithRTCKit:rtc
|
|
53
|
+
self.audioProcesser = [[VodAudioProcessor alloc] initWithRTCKit:rtc];
|
|
54
|
+
self.videoProcesser = [[VodVideoProcessor alloc] initWithRTCKit:rtc];
|
|
57
55
|
|
|
58
56
|
ttAudioWrapper.open = openAudio;
|
|
59
57
|
ttAudioWrapper.process = processAudio;
|
|
@@ -75,10 +73,6 @@
|
|
|
75
73
|
ttAudioWrapper.context = NULL;
|
|
76
74
|
ttVideoWrapper.context = NULL;
|
|
77
75
|
[rtc setVideoSourceType:ByteRTCVideoSourceTypeInternal WithStreamIndex:ByteRTCStreamIndexScreen];
|
|
78
|
-
[rtc setScreenAudioSourceType:ByteRTCAudioSourceTypeInternal];
|
|
79
|
-
self.options = nil;
|
|
80
|
-
self.rtcEngine = nil;
|
|
81
|
-
self.videoEngine = nil;
|
|
82
76
|
return 0;
|
|
83
77
|
}
|
|
84
78
|
|
|
@@ -120,8 +114,7 @@ static void videoProcessFunc(void *context, CVPixelBufferRef frame, int64_t time
|
|
|
120
114
|
}
|
|
121
115
|
|
|
122
116
|
static void videoReleaseFunc(void *context) {
|
|
123
|
-
|
|
124
|
-
[process releaseVideo];
|
|
117
|
+
|
|
125
118
|
}
|
|
126
119
|
|
|
127
120
|
@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;
|
|
23
23
|
|
|
24
24
|
/// Open audio
|
|
25
25
|
/// @param samplerate Samplerate
|
|
@@ -13,7 +13,6 @@ int VoidAudioMixingID = 3001;
|
|
|
13
13
|
@interface VodAudioProcessor ()
|
|
14
14
|
|
|
15
15
|
@property (nonatomic, weak) ByteRTCVideo *rtcKit;
|
|
16
|
-
@property (nonatomic, weak) NSDictionary *options;
|
|
17
16
|
@property (nonatomic, assign) int length;
|
|
18
17
|
|
|
19
18
|
@end
|
|
@@ -26,10 +25,9 @@ int VoidAudioMixingID = 3001;
|
|
|
26
25
|
int64_t _lastTimestamp;
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
- (instancetype)initWithRTCKit:(ByteRTCVideo *)rtcKit
|
|
28
|
+
- (instancetype)initWithRTCKit:(ByteRTCVideo *)rtcKit {
|
|
30
29
|
if (self = [super init]) {
|
|
31
30
|
self.rtcKit = rtcKit;
|
|
32
|
-
self.options = options;
|
|
33
31
|
_lastDiffTimestamp = 0;
|
|
34
32
|
_lastTimestamp = 0;
|
|
35
33
|
[rtcKit setScreenAudioSourceType:ByteRTCAudioSourceTypeExternal];
|
|
@@ -16,13 +16,11 @@
|
|
|
16
16
|
|
|
17
17
|
/// Initialize
|
|
18
18
|
/// @param rtcKit ByteRTCEngineKit
|
|
19
|
-
- (instancetype)initWithRTCKit:(ByteRTCVideo *)rtcKit
|
|
19
|
+
- (instancetype)initWithRTCKit:(ByteRTCVideo *)rtcKit;
|
|
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
|
-
|
|
28
26
|
@end
|
|
@@ -14,41 +14,21 @@
|
|
|
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;
|
|
20
17
|
|
|
21
18
|
@end
|
|
22
19
|
|
|
23
20
|
@implementation VodVideoProcessor
|
|
24
21
|
|
|
25
|
-
- (instancetype)initWithRTCKit:(ByteRTCVideo *)rtcKit
|
|
22
|
+
- (instancetype)initWithRTCKit:(ByteRTCVideo *)rtcKit {
|
|
26
23
|
if (self = [super init]) {
|
|
27
24
|
self.rtcKit = rtcKit;
|
|
28
|
-
self.options = options;
|
|
29
|
-
self.fps = [[options valueForKey:@"fps"] intValue];
|
|
30
|
-
self.time = 0;
|
|
31
25
|
[rtcKit setVideoSourceType:ByteRTCVideoSourceTypeExternal WithStreamIndex:ByteRTCStreamIndexScreen];
|
|
32
26
|
}
|
|
33
27
|
return self;
|
|
34
28
|
}
|
|
35
29
|
|
|
36
30
|
- (void)processVideo:(CVPixelBufferRef)frame timestamp:(int64_t)timestamp {
|
|
37
|
-
|
|
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");
|
|
31
|
+
[self.rtcKit pushScreenVideoFrame:frame time:CMTimeMake(timestamp, 1) rotation:0];
|
|
52
32
|
}
|
|
53
33
|
|
|
54
34
|
@end
|