Browse Source

add android rn support

matrixbirds 5 years ago
parent
commit
9f4a3fb648

+ 108
- 30
android/src/main/java/com/syan/agora/AgoraManager.java View File

@@ -1,18 +1,25 @@
1 1
 package com.syan.agora;
2 2
 
3 3
 import android.content.Context;
4
+import android.support.v7.widget.LinearLayoutCompat;
4 5
 import android.util.Log;
5 6
 import android.util.SparseArray;
6 7
 import android.view.SurfaceView;
7 8
 
8 9
 import com.facebook.react.bridge.ReadableMap;
10
+import com.facebook.react.bridge.WritableMap;
9 11
 
10 12
 import java.util.ArrayList;
11 13
 import java.util.List;
14
+import java.util.Map;
12 15
 
13 16
 import io.agora.rtc.IRtcEngineEventHandler;
14 17
 import io.agora.rtc.RtcEngine;
15 18
 import io.agora.rtc.video.VideoCanvas;
19
+import io.agora.rtc.video.VideoEncoderConfiguration;
20
+
21
+import static io.agora.rtc.video.VideoEncoderConfiguration.*;
22
+
16 23
 
17 24
 /**
18 25
  * Created by Leon on 2017/4/9.
@@ -45,31 +52,77 @@ public class AgoraManager {
45 52
         return sAgoraManager;
46 53
     }
47 54
 
55
+    private FRAME_RATE getVideoEncoderEnum (int val) {
56
+        FRAME_RATE type = FRAME_RATE.FRAME_RATE_FPS_1;
57
+        switch (val) {
58
+            case 1:
59
+                type = FRAME_RATE.FRAME_RATE_FPS_1;
60
+            case 7:
61
+                type = FRAME_RATE.FRAME_RATE_FPS_7;
62
+            case 10:
63
+                type = FRAME_RATE.FRAME_RATE_FPS_10;
64
+            case 15:
65
+                type = FRAME_RATE.FRAME_RATE_FPS_15;
66
+            case 24:
67
+                type = FRAME_RATE.FRAME_RATE_FPS_24;
68
+            case 30:
69
+                type = FRAME_RATE.FRAME_RATE_FPS_30;
70
+        }
71
+        return type;
72
+    }
73
+
74
+    private ORIENTATION_MODE getOrientationModeEnum (int val) {
75
+        ORIENTATION_MODE type = ORIENTATION_MODE.ORIENTATION_MODE_ADAPTIVE;
76
+        switch (val) {
77
+            case 0:
78
+                type = ORIENTATION_MODE.ORIENTATION_MODE_ADAPTIVE;
79
+            case 1:
80
+                type = ORIENTATION_MODE.ORIENTATION_MODE_FIXED_LANDSCAPE;
81
+            case 2:
82
+                type = ORIENTATION_MODE.ORIENTATION_MODE_FIXED_PORTRAIT;
83
+        }
84
+        return type;
85
+    }
86
+
48 87
     /**
49
-     * 初始化RtcEngine
88
+     * initialize rtc engine
50 89
      */
51
-    public void init(Context context, IRtcEngineEventHandler mRtcEventHandler, ReadableMap options) {
90
+    public int init(Context context, IRtcEngineEventHandler mRtcEventHandler, ReadableMap options) {
52 91
         this.context = context;
53 92
 
54
-        //创建RtcEngine对象,mRtcEventHandler为RtcEngine的回调
93
+        //create rtcEngine instance and setup rtcEngine eventHandler
55 94
         try {
56 95
             mRtcEngine = RtcEngine.create(context, options.getString("appid"), mRtcEventHandler);
57
-
96
+            if (null != options.getString("secret")) {
97
+                mRtcEngine.setEncryptionSecret(options.getString("secret"));
98
+                if (null != options.getString("secretMode")) {
99
+                    mRtcEngine.setEncryptionMode(options.getString("secretMode"));
100
+                }
101
+            }
58 102
         } catch (Exception e) {
59
-            throw new RuntimeException("NEED TO check rtc sdk init fatal error\n" + Log.getStackTraceString(e));
103
+            throw new RuntimeException("create rtc engine failed\n" + Log.getStackTraceString(e));
60 104
         }
61
-        //开启视频功能
105
+        mRtcEngine.enableDualStreamMode(true);
106
+        mRtcEngine.setChannelProfile(options.getInt("channelProfile"));
62 107
         mRtcEngine.enableVideo();
63
-        mRtcEngine.setVideoProfile(options.getInt("videoProfile"), options.getBoolean("swapWidthAndHeight")); //视频配置,
64
-        mRtcEngine.enableWebSdkInteroperability(true);  //设置和web通信
65
-        mRtcEngine.setChannelProfile(options.getInt("channelProfile")); //设置模式
66
-        mRtcEngine.setClientRole(options.getInt("clientRole"), null); //设置角色
108
+        ReadableMap config = options.getMap("videoEncoderConfig");
109
+        VideoEncoderConfiguration encoderConfig = new VideoEncoderConfiguration(
110
+            config.getInt("width"),
111
+            config.getInt("height"),
112
+            getVideoEncoderEnum(config.getInt("frameRate")),
113
+            config.getInt("bitrate"),
114
+            getOrientationModeEnum(config.getInt("orientationMode"))
115
+        );
116
+        mRtcEngine.setVideoEncoderConfiguration(encoderConfig);
117
+        mRtcEngine.setAudioProfile(options.getInt("audioProfile"), options.getInt("audioScenario"));
118
+        mRtcEngine.setClientRole(options.getInt("clientRole"));
119
+        return mRtcEngine.enableWebSdkInteroperability(true);
67 120
     }
68 121
 
69 122
     /**
70 123
      * 设置本地视频,即前置摄像头预览
71 124
      */
72
-    public AgoraManager setupLocalVideo() {
125
+    public int setupLocalVideo() {
73 126
         //创建一个SurfaceView用作视频预览
74 127
         SurfaceView surfaceView = RtcEngine.CreateRendererView(context);
75 128
         //将SurfaceView保存起来在SparseArray中,后续会将其加入界面。key为视频的用户id,这里是本地视频, 默认id是0
@@ -78,36 +131,61 @@ public class AgoraManager {
78 131
 
79 132
         //设置本地视频,渲染模式选择VideoCanvas.RENDER_MODE_HIDDEN,如果选其他模式会出现视频不会填充满整个SurfaceView的情况,
80 133
         //具体渲染模式参考官方文档https://docs.agora.io/cn/user_guide/API/android_api.html#set-local-video-view-setuplocalvideo
81
-        mRtcEngine.setupLocalVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, mLocalUid));
82
-        return this;//返回AgoraManager以作链式调用
134
+        return mRtcEngine.setupLocalVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, mLocalUid));
83 135
     }
84 136
 
85
-    public AgoraManager setupRemoteVideo(int uid) {
137
+    public int setupRemoteVideo(int uid) {
86 138
 
87 139
         SurfaceView surfaceView = RtcEngine.CreateRendererView(context);
88 140
         mSurfaceViews.put(uid, surfaceView);
89
-        mRtcEngine.setupRemoteVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid));
90
-        return this;
141
+        return mRtcEngine.setupRemoteVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid));
91 142
     }
92 143
 
93
-    public AgoraManager joinChannel(String channel, int uid) {
94
-        mRtcEngine.joinChannel(null, channel, null, uid);
95
-        return this;
144
+    public int setEnableSpeakerphone(boolean enabled) {
145
+        return mRtcEngine.setEnableSpeakerphone(enabled);
96 146
     }
97 147
 
98
-    public AgoraManager joinChannelWithToken(String token, String channel, int uid) {
99
-        mRtcEngine.joinChannel(token, channel, null, uid);
100
-        return this;
148
+    public int setDefaultAudioRouteToSpeakerphone(boolean enabled) {
149
+        return mRtcEngine.setDefaultAudioRoutetoSpeakerphone(enabled);
101 150
     }
102 151
 
103
-    public AgoraManager enableLastmileTest() {
104
-        mRtcEngine.enableLastmileTest();
105
-        return this;
152
+    public int renewToken(String token) {
153
+        return mRtcEngine.renewToken(token);
154
+    }
155
+
156
+    public int setClientRole(int role) {
157
+        return mRtcEngine.setClientRole(role);
158
+    }
159
+
160
+    public int enableWebSdkInteroperability(boolean enabled) {
161
+        return mRtcEngine.enableWebSdkInteroperability(enabled);
162
+    }
163
+
164
+    public int getConnectionState() {
165
+        return mRtcEngine.getConnectionState();
166
+    }
167
+    public int joinChannel(ReadableMap options) {
168
+        String token = options.getString("token");
169
+        String channel = options.getString("channel");
170
+        String optionalInfo = options.getString("optionalInfo");
171
+        int uid = options.getInt("uid");
172
+        return mRtcEngine.joinChannel(token, channel, optionalInfo, uid);
173
+    }
174
+
175
+//    public int joinChannelWithToken(ReadableMap options) {
176
+//        String token = options.getString("token");
177
+//        String channel = options.getString("channel");
178
+//        String optionalInfo = options.getString("optionalInfo");
179
+//        int uid = options.getInt("uid");
180
+//        return mRtcEngine.joinChannel(token, channel, optionalInfo, uid);
181
+//    }
182
+
183
+    public int enableLastmileTest() {
184
+        return mRtcEngine.enableLastmileTest();
106 185
     }
107 186
 
108
-    public AgoraManager disableLastmileTest() {
109
-        mRtcEngine.disableLastmileTest();
110
-        return this;
187
+    public int disableLastmileTest() {
188
+        return mRtcEngine.disableLastmileTest();
111 189
     }
112 190
 
113 191
     public void startPreview() {
@@ -118,8 +196,8 @@ public class AgoraManager {
118 196
         mRtcEngine.stopPreview();
119 197
     }
120 198
 
121
-    public void leaveChannel() {
122
-        mRtcEngine.leaveChannel();
199
+    public int leaveChannel() {
200
+        return mRtcEngine.leaveChannel();
123 201
     }
124 202
 
125 203
     public void removeSurfaceView(int uid) {

+ 2078
- 223
android/src/main/java/com/syan/agora/AgoraModule.java
File diff suppressed because it is too large
View File


+ 298
- 0
android/src/main/java/com/syan/agora/ConvertUtils.java View File

@@ -0,0 +1,298 @@
1
+package com.syan.agora;
2
+
3
+import android.support.annotation.Nullable;
4
+
5
+import com.facebook.react.bridge.Arguments;
6
+import com.facebook.react.bridge.ReadableArray;
7
+import com.facebook.react.bridge.ReadableMap;
8
+import com.facebook.react.bridge.ReadableMapKeySetIterator;
9
+import com.facebook.react.bridge.ReadableType;
10
+import com.facebook.react.bridge.WritableArray;
11
+import com.facebook.react.bridge.WritableMap;
12
+import com.facebook.react.bridge.WritableNativeArray;
13
+import com.facebook.react.bridge.WritableNativeMap;
14
+
15
+import org.json.JSONArray;
16
+import org.json.JSONException;
17
+import org.json.JSONObject;
18
+
19
+import java.util.ArrayList;
20
+import java.util.HashMap;
21
+import java.util.Iterator;
22
+import java.util.List;
23
+import java.util.Map;
24
+
25
+public class ConvertUtils {
26
+    public static Map<String, Object> readableMapToMap(final @Nullable ReadableMap readableMap) {
27
+        if (readableMap == null) {
28
+            return new HashMap<>();
29
+        }
30
+
31
+        final ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
32
+        if (!iterator.hasNextKey()) {
33
+            return new HashMap<>();
34
+        }
35
+
36
+        final Map<String, Object> result = new HashMap<>();
37
+        while (iterator.hasNextKey()) {
38
+            final String key = iterator.nextKey();
39
+            result.put(key, toObject(readableMap, key));
40
+        }
41
+
42
+        return result;
43
+    }
44
+
45
+    public static Object toObject(@Nullable ReadableMap readableMap, String key) {
46
+        if (readableMap == null) {
47
+            return null;
48
+        }
49
+
50
+        Object result;
51
+
52
+        final ReadableType readableType = readableMap.getType(key);
53
+        switch (readableType) {
54
+            case Null:
55
+                result = key;
56
+                break;
57
+            case Boolean:
58
+                result = readableMap.getBoolean(key);
59
+                break;
60
+            case Number:
61
+                // Can be int or double.
62
+                double tmp = readableMap.getDouble(key);
63
+                if (tmp == (int) tmp) {
64
+                    result = (int) tmp;
65
+                } else {
66
+                    result = tmp;
67
+                }
68
+                break;
69
+            case String:
70
+                result = readableMap.getString(key);
71
+                break;
72
+            case Map:
73
+                result = readableMapToMap(readableMap.getMap(key));
74
+                break;
75
+            case Array:
76
+                result = readableArrayToList(readableMap.getArray(key));
77
+                break;
78
+            default:
79
+                throw new IllegalArgumentException("Could not convert object with key: " + key + ".");
80
+        }
81
+
82
+        return result;
83
+    }
84
+
85
+    /**
86
+     * toList converts a {@link ReadableArray} into an ArrayList.
87
+     *
88
+     * @param readableArray The ReadableArray to be conveted.
89
+     * @return An ArrayList containing the data that was in the ReadableArray.
90
+     */
91
+    public static List<Object> readableArrayToList(final @Nullable ReadableArray readableArray) {
92
+        if (readableArray == null) {
93
+            return null;
94
+        }
95
+
96
+        List<Object> result = new ArrayList<>(readableArray.size());
97
+        for (int index = 0; index < readableArray.size(); index++) {
98
+            final ReadableType readableType = readableArray.getType(index);
99
+            switch (readableType) {
100
+                case Null:
101
+                    result.add(String.valueOf(index));
102
+                    break;
103
+                case Boolean:
104
+                    result.add(readableArray.getBoolean(index));
105
+                    break;
106
+                case Number:
107
+                    // Can be int or double.
108
+                    double tmp = readableArray.getDouble(index);
109
+                    if (tmp == (int) tmp) {
110
+                        result.add((int) tmp);
111
+                    } else {
112
+                        result.add(tmp);
113
+                    }
114
+                    break;
115
+                case String:
116
+                    result.add(readableArray.getString(index));
117
+                    break;
118
+                case Map:
119
+                    result.add(readableMapToMap(readableArray.getMap(index)));
120
+                    break;
121
+                case Array:
122
+                    result = readableArrayToList(readableArray.getArray(index));
123
+                    break;
124
+                default:
125
+                    throw new IllegalArgumentException("Could not convert object with index: " + index + ".");
126
+            }
127
+        }
128
+
129
+        return result;
130
+    }
131
+
132
+    /**
133
+     * better
134
+     *
135
+     * @param jsonArray
136
+     * @return
137
+     * @throws JSONException
138
+     */
139
+    public static WritableArray jsonToReact(final JSONArray jsonArray) throws JSONException {
140
+        final WritableArray writableArray = Arguments.createArray();
141
+        for (int i = 0; i < jsonArray.length(); i++) {
142
+            final Object value = jsonArray.get(i);
143
+            if (value instanceof Float || value instanceof Double) {
144
+                writableArray.pushDouble(jsonArray.getDouble(i));
145
+            } else if (value instanceof Number) {
146
+                writableArray.pushInt(jsonArray.getInt(i));
147
+            } else if (value instanceof String) {
148
+                writableArray.pushString(jsonArray.getString(i));
149
+            } else if (value instanceof Boolean) {
150
+                writableArray.pushBoolean(jsonArray.getBoolean(i));
151
+            } else if (value instanceof JSONObject) {
152
+                writableArray.pushMap(jsonToReact(jsonArray.getJSONObject(i)));
153
+            } else if (value instanceof JSONArray) {
154
+                writableArray.pushArray(jsonToReact(jsonArray.getJSONArray(i)));
155
+            } else if (value == JSONObject.NULL) {
156
+                writableArray.pushNull();
157
+            }
158
+        }
159
+        return writableArray;
160
+    }
161
+
162
+    /**
163
+     * better
164
+     *
165
+     * @param jsonObject
166
+     * @return
167
+     * @throws JSONException
168
+     */
169
+    public static WritableMap jsonToReact(final JSONObject jsonObject) throws JSONException {
170
+        final WritableMap writableMap = Arguments.createMap();
171
+        final Iterator iterator = jsonObject.keys();
172
+        while (iterator.hasNext()) {
173
+            final String key = (String) iterator.next();
174
+            final Object value = jsonObject.get(key);
175
+            if (value instanceof Float || value instanceof Double) {
176
+                writableMap.putDouble(key, jsonObject.getDouble(key));
177
+            } else if (value instanceof Number) {
178
+                writableMap.putInt(key, jsonObject.getInt(key));
179
+            } else if (value instanceof String) {
180
+                writableMap.putString(key, jsonObject.getString(key));
181
+            } else if (value instanceof JSONObject) {
182
+                writableMap.putMap(key, jsonToReact(jsonObject.getJSONObject(key)));
183
+            } else if (value instanceof JSONArray) {
184
+                writableMap.putArray(key, jsonToReact(jsonObject.getJSONArray(key)));
185
+            } else if (value instanceof Boolean) {
186
+                writableMap.putBoolean(key, jsonObject.getBoolean(key));
187
+            } else if (value == JSONObject.NULL) {
188
+                writableMap.putNull(key);
189
+            }
190
+        }
191
+        return writableMap;
192
+    }
193
+
194
+    public static WritableMap convertJsonToMap(JSONObject jsonObject) throws JSONException {
195
+        WritableMap map = new WritableNativeMap();
196
+
197
+        Iterator<String> iterator = jsonObject.keys();
198
+        while (iterator.hasNext()) {
199
+            String key = iterator.next();
200
+            Object value = jsonObject.get(key);
201
+            if (value instanceof JSONObject) {
202
+                map.putMap(key, convertJsonToMap((JSONObject) value));
203
+            } else if (value instanceof JSONArray) {
204
+                map.putArray(key, convertJsonToArray((JSONArray) value));
205
+            } else if (value instanceof Boolean) {
206
+                map.putBoolean(key, (Boolean) value);
207
+            } else if (value instanceof Integer) {
208
+                map.putInt(key, (Integer) value);
209
+            } else if (value instanceof Double) {
210
+                map.putDouble(key, (Double) value);
211
+            } else if (value instanceof String) {
212
+                map.putString(key, (String) value);
213
+            } else {
214
+                map.putString(key, value.toString());
215
+            }
216
+        }
217
+        return map;
218
+    }
219
+
220
+    public static WritableArray convertJsonToArray(JSONArray jsonArray) throws JSONException {
221
+        WritableArray array = new WritableNativeArray();
222
+
223
+        for (int i = 0; i < jsonArray.length(); i++) {
224
+            Object value = jsonArray.get(i);
225
+            if (value instanceof JSONObject) {
226
+                array.pushMap(convertJsonToMap((JSONObject) value));
227
+            } else if (value instanceof JSONArray) {
228
+                array.pushArray(convertJsonToArray((JSONArray) value));
229
+            } else if (value instanceof Boolean) {
230
+                array.pushBoolean((Boolean) value);
231
+            } else if (value instanceof Integer) {
232
+                array.pushInt((Integer) value);
233
+            } else if (value instanceof Double) {
234
+                array.pushDouble((Double) value);
235
+            } else if (value instanceof String) {
236
+                array.pushString((String) value);
237
+            } else {
238
+                array.pushString(value.toString());
239
+            }
240
+        }
241
+        return array;
242
+    }
243
+
244
+    public static JSONObject convertMapToJson(ReadableMap readableMap) throws JSONException {
245
+        JSONObject object = new JSONObject();
246
+        ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
247
+        while (iterator.hasNextKey()) {
248
+            String key = iterator.nextKey();
249
+            switch (readableMap.getType(key)) {
250
+                case Null:
251
+                    object.put(key, JSONObject.NULL);
252
+                    break;
253
+                case Boolean:
254
+                    object.put(key, readableMap.getBoolean(key));
255
+                    break;
256
+                case Number:
257
+                    object.put(key, readableMap.getDouble(key));
258
+                    break;
259
+                case String:
260
+                    object.put(key, readableMap.getString(key));
261
+                    break;
262
+                case Map:
263
+                    object.put(key, convertMapToJson(readableMap.getMap(key)));
264
+                    break;
265
+                case Array:
266
+                    object.put(key, convertArrayToJson(readableMap.getArray(key)));
267
+                    break;
268
+            }
269
+        }
270
+        return object;
271
+    }
272
+
273
+    public static JSONArray convertArrayToJson(ReadableArray readableArray) throws JSONException {
274
+        JSONArray array = new JSONArray();
275
+        for (int i = 0; i < readableArray.size(); i++) {
276
+            switch (readableArray.getType(i)) {
277
+                case Null:
278
+                    break;
279
+                case Boolean:
280
+                    array.put(readableArray.getBoolean(i));
281
+                    break;
282
+                case Number:
283
+                    array.put(readableArray.getDouble(i));
284
+                    break;
285
+                case String:
286
+                    array.put(readableArray.getString(i));
287
+                    break;
288
+                case Map:
289
+                    array.put(convertMapToJson(readableArray.getMap(i)));
290
+                    break;
291
+                case Array:
292
+                    array.put(convertArrayToJson(readableArray.getArray(i)));
293
+                    break;
294
+            }
295
+        }
296
+        return array;
297
+    }
298
+}

+ 19
- 0
android/src/main/java/com/syan/agora/ReactNativeAgoraException.java View File

@@ -0,0 +1,19 @@
1
+package com.syan.agora;
2
+
3
+
4
+import com.facebook.react.bridge.WritableMap;
5
+
6
+public class ReactNativeAgoraException extends Exception {
7
+
8
+    private int code;
9
+
10
+    public ReactNativeAgoraException(String message, final int code) {
11
+        super(message);
12
+        this.code = code;
13
+    }
14
+
15
+    public int getCode() {
16
+        return this.code;
17
+    }
18
+
19
+}

+ 0
- 3
android/src/main/jniLibs/arm64-v8a/libagora-crypto.so View File

@@ -1,3 +0,0 @@
1
-version https://git-lfs.github.com/spec/v1
2
-oid sha256:00adfb3f68244fedd280628b0cdf417c9a69440d6540d1c377eb37ceea846543
3
-size 2060784

+ 0
- 3
android/src/main/jniLibs/arm64-v8a/libagora-rtc-sdk-jni.so View File

@@ -1,3 +0,0 @@
1
-version https://git-lfs.github.com/spec/v1
2
-oid sha256:66b7e3c53fcc22924eec575d0d58cf8bbacb46a96a9072b981f1961844177850
3
-size 10738584

+ 0
- 3
android/src/main/jniLibs/armeabi-v7a/libagora-crypto.so View File

@@ -1,3 +0,0 @@
1
-version https://git-lfs.github.com/spec/v1
2
-oid sha256:777fd656f842dbcc210013c691457b4d316043a4bf810bdbf4dd76b437b11fd1
3
-size 1827952

+ 0
- 3
android/src/main/jniLibs/armeabi-v7a/libagora-rtc-sdk-jni.so View File

@@ -1,3 +0,0 @@
1
-version https://git-lfs.github.com/spec/v1
2
-oid sha256:eabb164d93521798f5bc117b86723e063e4cbe6dd16362811b894e737dd3088a
3
-size 7854896

+ 0
- 181
android/src/main/jniLibs/include/IAgoraMediaEngine.h View File

@@ -1,181 +0,0 @@
1
-#ifndef AGORA_MEDIA_ENGINE_H
2
-#define AGORA_MEDIA_ENGINE_H
3
-#if defined _WIN32 || defined __CYGWIN__
4
-typedef __int64 int64_t;
5
-typedef unsigned __int64 uint64_t;
6
-#else
7
-#include <stdint.h>
8
-#endif
9
-
10
-namespace agora
11
-{
12
-namespace media
13
-{
14
-
15
-enum MEDIA_SOURCE_TYPE {
16
-    AUDIO_PLAYOUT_SOURCE = 0,
17
-    AUDIO_RECORDING_SOURCE = 1,
18
-};
19
-
20
-class IAudioFrameObserver
21
-{
22
-public:
23
-  enum AUDIO_FRAME_TYPE {
24
-    FRAME_TYPE_PCM16 = 0,  //PCM 16bit little endian
25
-  };
26
-  struct AudioFrame {
27
-    AUDIO_FRAME_TYPE type;
28
-    int samples;  //number of samples in this frame
29
-    int bytesPerSample;  //number of bytes per sample: 2 for PCM16
30
-    int channels;  //number of channels (data are interleaved if stereo)
31
-    int samplesPerSec;  //sampling rate
32
-    void* buffer;  //data buffer
33
-    int64_t renderTimeMs;
34
-  };
35
-public:
36
-  virtual bool onRecordAudioFrame(AudioFrame& audioFrame) = 0;
37
-  virtual bool onPlaybackAudioFrame(AudioFrame& audioFrame) = 0;
38
-  virtual bool onMixedAudioFrame(AudioFrame& audioFrame) = 0;
39
-  virtual bool onPlaybackAudioFrameBeforeMixing(unsigned int uid, AudioFrame& audioFrame) = 0;
40
-};
41
-
42
-class IVideoFrameObserver
43
-{
44
-public:
45
-  enum VIDEO_FRAME_TYPE {
46
-    FRAME_TYPE_YUV420 = 0,  //YUV 420 format
47
-  };
48
-  struct VideoFrame {
49
-    VIDEO_FRAME_TYPE type;
50
-    int width;  //width of video frame
51
-    int height;  //height of video frame
52
-    int yStride;  //stride of Y data buffer
53
-    int uStride;  //stride of U data buffer
54
-    int vStride;  //stride of V data buffer
55
-    void* yBuffer;  //Y data buffer
56
-    void* uBuffer;  //U data buffer
57
-    void* vBuffer;  //V data buffer
58
-    int rotation; // rotation of this frame (0, 90, 180, 270)
59
-    int64_t renderTimeMs;
60
-  };
61
-public:
62
-  virtual bool onCaptureVideoFrame(VideoFrame& videoFrame) = 0;
63
-  virtual bool onRenderVideoFrame(unsigned int uid, VideoFrame& videoFrame) = 0;
64
-};
65
-
66
-class IVideoFrame
67
-{
68
-public:
69
-  enum PLANE_TYPE {
70
-    Y_PLANE = 0,
71
-    U_PLANE = 1,
72
-    V_PLANE = 2,
73
-    NUM_OF_PLANES = 3
74
-  };
75
-  enum VIDEO_TYPE {
76
-    VIDEO_TYPE_UNKNOWN = 0,
77
-    VIDEO_TYPE_I420 = 1,
78
-    VIDEO_TYPE_IYUV = 2,
79
-    VIDEO_TYPE_RGB24 = 3,
80
-    VIDEO_TYPE_ABGR = 4,
81
-    VIDEO_TYPE_ARGB = 5,
82
-    VIDEO_TYPE_ARGB4444 = 6,
83
-    VIDEO_TYPE_RGB565 = 7,
84
-    VIDEO_TYPE_ARGB1555 = 8,
85
-    VIDEO_TYPE_YUY2 = 9,
86
-    VIDEO_TYPE_YV12 = 10,
87
-    VIDEO_TYPE_UYVY = 11,
88
-    VIDEO_TYPE_MJPG = 12,
89
-    VIDEO_TYPE_NV21 = 13,
90
-    VIDEO_TYPE_NV12 = 14,
91
-    VIDEO_TYPE_BGRA = 15,
92
-    VIDEO_TYPE_RGBA = 16,
93
-  };
94
-  virtual void release() = 0;
95
-  virtual const unsigned char* buffer(PLANE_TYPE type) const = 0;
96
-
97
-  // Copy frame: If required size is bigger than allocated one, new buffers of
98
-  // adequate size will be allocated.
99
-  // Return value: 0 on success ,-1 on error.
100
-  virtual int copyFrame(IVideoFrame** dest_frame) const = 0;
101
-
102
-  // Convert frame
103
-  // Input:
104
-  //   - src_frame        : Reference to a source frame.
105
-  //   - dst_video_type   : Type of output video.
106
-  //   - dst_sample_size  : Required only for the parsing of MJPG.
107
-  //   - dst_frame        : Pointer to a destination frame.
108
-  // Return value: 0 if OK, < 0 otherwise.
109
-  // It is assumed that source and destination have equal height.
110
-  virtual int convertFrame(VIDEO_TYPE dst_video_type, int dst_sample_size, unsigned char* dst_frame) const = 0;
111
-
112
-  // Get allocated size per plane.
113
-  virtual int allocated_size(PLANE_TYPE type) const = 0;
114
-
115
-  // Get allocated stride per plane.
116
-  virtual int stride(PLANE_TYPE type) const = 0;
117
-
118
-  // Get frame width.
119
-  virtual int width() const = 0;
120
-
121
-  // Get frame height.
122
-  virtual int height() const = 0;
123
-
124
-  // Get frame timestamp (90kHz).
125
-  virtual unsigned int timestamp() const = 0;
126
-
127
-  // Get render time in milliseconds.
128
-  virtual int64_t render_time_ms() const = 0;
129
-
130
-  // Return true if underlying plane buffers are of zero size, false if not.
131
-  virtual bool IsZeroSize() const = 0;
132
-};
133
-
134
-class IExternalVideoRenderCallback
135
-{
136
-public:
137
-  virtual void onViewSizeChanged(int width, int height) = 0;
138
-  virtual void onViewDestroyed() = 0;
139
-};
140
-
141
-struct ExternalVideoRenerContext
142
-{
143
-  IExternalVideoRenderCallback* renderCallback;
144
-  void* view;
145
-  int renderMode;
146
-  int zOrder;
147
-  float left;
148
-  float top;
149
-  float right;
150
-  float bottom;
151
-};
152
-
153
-class IExternalVideoRender
154
-{
155
-public:
156
-  virtual void release() = 0;
157
-  virtual int initialize() = 0;
158
-  virtual int deliverFrame(const IVideoFrame& videoFrame, int rotation, bool mirrored) = 0;
159
-};
160
-
161
-class IExternalVideoRenderFactory
162
-{
163
-public:
164
-  virtual IExternalVideoRender* createRenderInstance(const ExternalVideoRenerContext& context) = 0;
165
-};
166
-
167
-class IMediaEngine
168
-{
169
-public:
170
-  virtual void release() = 0;
171
-  virtual int registerAudioFrameObserver(IAudioFrameObserver* observer) = 0;
172
-  virtual int registerVideoFrameObserver(IVideoFrameObserver* observer) = 0;
173
-  virtual int registerVideoRenderFactory(IExternalVideoRenderFactory* factory) = 0;
174
-  virtual int pushAudioFrame(MEDIA_SOURCE_TYPE type, IAudioFrameObserver::AudioFrame *frame, bool wrap = false){ return -1; }
175
-};
176
-
177
-} //media
178
-
179
-} //agora
180
-
181
-#endif //AGORA_MEDIA_ENGINE_H

+ 0
- 2255
android/src/main/jniLibs/include/IAgoraRtcEngine.h
File diff suppressed because it is too large
View File


+ 0
- 3
android/src/main/jniLibs/x86/libagora-crypto.so View File

@@ -1,3 +0,0 @@
1
-version https://git-lfs.github.com/spec/v1
2
-oid sha256:4bcff7feb240245929181925615a8d0c6dae29421d7addcc63944e8f0d38f24c
3
-size 2252020

+ 0
- 3
android/src/main/jniLibs/x86/libagora-rtc-sdk-jni.so View File

@@ -1,3 +0,0 @@
1
-version https://git-lfs.github.com/spec/v1
2
-oid sha256:b26bd88d0fa14fc86740dc202aa52f45e4e83f3b7e56f7706629298bade49eeb
3
-size 12276564

+ 900
- 349
package-lock.json
File diff suppressed because it is too large
View File