|
@@ -1,12 +1,7 @@
|
1
|
1
|
package com.syan.agora;
|
2
|
2
|
|
3
|
3
|
import android.graphics.Rect;
|
4
|
|
-import android.media.MediaRecorder;
|
5
|
|
-import android.net.wifi.p2p.nsd.WifiP2pServiceRequest;
|
6
|
4
|
import android.support.annotation.Nullable;
|
7
|
|
-import android.support.v7.widget.LinearLayoutCompat;
|
8
|
|
-import android.telecom.Call;
|
9
|
|
-import android.util.Log;
|
10
|
5
|
|
11
|
6
|
import com.facebook.react.bridge.Arguments;
|
12
|
7
|
import com.facebook.react.bridge.Callback;
|
|
@@ -36,112 +31,112 @@ import io.agora.rtc.video.AgoraImage;
|
36
|
31
|
import io.agora.rtc.video.VideoEncoderConfiguration;
|
37
|
32
|
|
38
|
33
|
import static com.facebook.react.bridge.UiThreadUtil.runOnUiThread;
|
39
|
|
-import static io.agora.rtc.Constants.AudioScenario;
|
40
|
|
-import static io.agora.rtc.Constants.AudioProfile;
|
41
|
34
|
|
42
|
35
|
public class AgoraModule extends ReactContextBaseJavaModule {
|
43
|
36
|
|
44
|
|
- private static String FPS1 = "FPS1";
|
45
|
|
- private static String FPS7 = "FPS7";
|
46
|
|
- private static String FPS10 = "FPS10";
|
47
|
|
- private static String FPS15 = "FPS15";
|
48
|
|
- private static String FPS24 = "FPS24";
|
49
|
|
- private static String FPS30 = "FPS30";
|
50
|
|
- private static String FPS60 = "FPS60";
|
51
|
|
- private static String Adaptative = "Adaptative";
|
52
|
|
- private static String FixedLandscape = "FixedLandscape";
|
53
|
|
- private static String FixedPortrait = "FixedPortrait";
|
54
|
|
- private static String Host = "Host";
|
55
|
|
- private static String Audience = "Audience";
|
56
|
|
- private static String UserOfflineReasonQuit = "UserOfflineReasonQuit";
|
57
|
|
- private static String UserOfflineReasonDropped = "UserOfflineReasonDropped";
|
58
|
|
- private static String UserOfflineReasonBecomeAudience = "UserOfflineReasonBecomeAudience";
|
59
|
|
- private static String AudioSampleRateType32000 = "AudioSampleRateType32000";
|
60
|
|
- private static String AudioSampleRateType44100 = "AudioSampleRateType44100";
|
61
|
|
- private static String AudioSampleRateType48000 = "AudioSampleRateType48000";
|
62
|
|
- private static String CodecTypeBaseLine = "CodecTypeBaseLine";
|
63
|
|
- private static String CodecTypeMain = "CodecTypeMain";
|
64
|
|
- private static String CodecTypeHigh = "CodecTypeHigh";
|
65
|
|
- private static String QualityLow = "QualityLow";
|
66
|
|
- private static String QualityMedium = "QualityMedium";
|
67
|
|
- private static String QualityHigh = "QualityHigh";
|
68
|
|
- private static String Disconnected = "Disconnected";
|
69
|
|
- private static String Connecting = "Connecting";
|
70
|
|
- private static String Connected = "Connected";
|
71
|
|
- private static String Reconnecting = "Reconnecting";
|
72
|
|
- private static String ConnectionFailed = "ConnectionFailed";
|
73
|
|
- private static String ConnectionChangedConnecting = "ConnectionChangedConnecting";
|
74
|
|
- private static String ConnectionChangedJoinSuccess = "ConnectionChangedJoinSuccess";
|
75
|
|
- private static String ConnectionChangedInterrupted = "ConnectionChangedInterrupted";
|
76
|
|
- private static String ConnectionChangedBannedByServer = "ConnectionChangedBannedByServer";
|
77
|
|
- private static String ConnectionChangedJoinFailed = "ConnectionChangedJoinFailed";
|
78
|
|
- private static String ConnectionChangedLeaveChannel = "ConnectionChangedLeaveChannel";
|
79
|
|
- private static String AudioOutputRoutingDefault = "AudioOutputRoutingDefault";
|
80
|
|
- private static String AudioOutputRoutingHeadset = "AudioOutputRoutingHeadset";
|
81
|
|
- private static String AudioOutputRoutingEarpiece = "AudioOutputRoutingEarpiece";
|
82
|
|
- private static String AudioOutputRoutingHeadsetNoMic = "AudioOutputRoutingHeadsetNoMic";
|
83
|
|
- private static String AudioOutputRoutingSpeakerphone = "AudioOutputRoutingSpeakerphone";
|
84
|
|
- private static String AudioOutputRoutingLoudspeaker = "AudioOutputRoutingLoudspeaker";
|
85
|
|
- private static String AudioOutputRoutingHeadsetBluetooth = "AudioOutputRoutingHeadsetBluetooth";
|
86
|
|
- private static String NetworkQualityUnknown = "NetworkQualityUnknown";
|
87
|
|
- private static String NetworkQualityExcellent = "NetworkQualityExcellent";
|
88
|
|
- private static String NetworkQualityGood = "NetworkQualityGood";
|
89
|
|
- private static String NetworkQualityPoor = "NetworkQualityPoor";
|
90
|
|
- private static String NetworkQualityBad = "NetworkQualityBad";
|
91
|
|
- private static String NetworkQualityVBad = "NetworkQualityVBad";
|
92
|
|
- private static String NetworkQualityDown = "NetworkQualityDown";
|
93
|
|
- private static String AudioProfileDefault = "AudioProfileDefault";
|
94
|
|
- private static String AudioProfileSpeechStandard = "AudioProfileSpeechStandard";
|
95
|
|
- private static String AudioProfileMusicStandard = "AudioProfileMusicStandard";
|
96
|
|
- private static String AgoraAudioProfileMusicStandardStereo = "AudioProfileMusicStandardStereo";
|
97
|
|
- private static String AudioProfileMusicHighQuality = "AudioProfileMusicHighQuality";
|
98
|
|
- private static String AudioProfileMusicHighQualityStereo = "AudioProfileMusicHighQualityStereo";
|
99
|
|
- private static String AudioScenarioDefault = "AudioScenarioDefault";
|
100
|
|
- private static String AudioScenarioChatRoomEntertainment = "AudioScenarioChatRoomEntertainment";
|
101
|
|
- private static String AudioScenarioEducation = "AudioScenarioEducation";
|
102
|
|
- private static String AudioScenarioGameStreaming = "AudioScenarioGameStreaming";
|
103
|
|
- private static String AudioScenarioShowRoom = "AudioScenarioShowRoom";
|
104
|
|
- private static String AudioScenarioChatRoomGaming = "AudioScenarioChatRoomGaming";
|
105
|
|
- private static String AudioEqualizationBand31 = "AudioEqualizationBand31";
|
106
|
|
- private static String AudioEqualizationBand62 = "AudioEqualizationBand62";
|
107
|
|
- private static String AudioEqualizationBand125 = "AudioEqualizationBand125";
|
108
|
|
- private static String AudioEqualizationBand250 = "AudioEqualizationBand250";
|
109
|
|
- private static String AudioEqualizationBand500 = "AudioEqualizationBand500";
|
110
|
|
- private static String AudioEqualizationBand1K = "AudioEqualizationBand1K";
|
111
|
|
- private static String AudioEqualizationBand2K = "AudioEqualizationBand2K";
|
112
|
|
- private static String AudioEqualizationBand4K = "AudioEqualizationBand4K";
|
113
|
|
- private static String AudioEqualizationBand8K = "AudioEqualizationBand8K";
|
114
|
|
- private static String AudioEqualizationBand16K = "AudioEqualizationBand16K";
|
115
|
|
- private static String AudioRawFrameOperationModeReadOnly = "AudioRawFrameOperationModeReadOnly";
|
116
|
|
- private static String AudioRawFrameOperationModeWriteOnly = "AudioRawFrameOperationModeWriteOnly";
|
117
|
|
- private static String AudioRawFrameOperationModeReadWrite = "AudioRawFrameOperationModeReadWrite";
|
118
|
|
- private static String VideoStreamTypeHigh = "VideoStreamTypeHigh";
|
119
|
|
- private static String VideoStreamTypeLow = "VideoStreamTypeLow";
|
120
|
|
- private static String VideoMirrorModeAuto = "VideoMirrorModeAuto";
|
121
|
|
- private static String VideoMirrorModeEnabled = "VideoMirrorModeEnabled";
|
122
|
|
- private static String VideoMirrorModeDisabled = "VideoMirrorModeDisabled";
|
123
|
|
- private static String ChannelProfileCommunication = "ChannelProfileCommunication";
|
124
|
|
- private static String ChannelProfileLiveBroadcasting = "ChannelProfileLiveBroadcasting";
|
125
|
|
- private static String ChannelProfileGame = "ChannelProfileGame";
|
126
|
|
- private static String ErrorCodeNoError = "ErrorCodeNoError";
|
127
|
|
- private static String ErrorCodeFailed = "ErrorCodeFailed";
|
128
|
|
- private static String ErrorCodeInvalidArgument = "ErrorCodeInvalidArgument";
|
129
|
|
- private static String ErrorCodeTimedOut = "ErrorCodeTimedOut";
|
130
|
|
- private static String ErrorCodeAlreadyInUse = "ErrorCodeAlreadyInUse";
|
|
37
|
+ private static final String FPS1 = "FPS1";
|
|
38
|
+ private static final String FPS7 = "FPS7";
|
|
39
|
+ private static final String FPS10 = "FPS10";
|
|
40
|
+ private static final String FPS15 = "FPS15";
|
|
41
|
+ private static final String FPS24 = "FPS24";
|
|
42
|
+ private static final String FPS30 = "FPS30";
|
|
43
|
+ private static final String FPS60 = "FPS60";
|
|
44
|
+ private static final String Adaptative = "Adaptative";
|
|
45
|
+ private static final String FixedLandscape = "FixedLandscape";
|
|
46
|
+ private static final String FixedPortrait = "FixedPortrait";
|
|
47
|
+ private static final String Host = "Host";
|
|
48
|
+ private static final String Audience = "Audience";
|
|
49
|
+ private static final String UserOfflineReasonQuit = "UserOfflineReasonQuit";
|
|
50
|
+ private static final String UserOfflineReasonDropped = "UserOfflineReasonDropped";
|
|
51
|
+ private static final String UserOfflineReasonBecomeAudience = "UserOfflineReasonBecomeAudience";
|
|
52
|
+ private static final String AudioSampleRateType32000 = "AudioSampleRateType32000";
|
|
53
|
+ private static final String AudioSampleRateType44100 = "AudioSampleRateType44100";
|
|
54
|
+ private static final String AudioSampleRateType48000 = "AudioSampleRateType48000";
|
|
55
|
+ private static final String CodecTypeBaseLine = "CodecTypeBaseLine";
|
|
56
|
+ private static final String CodecTypeMain = "CodecTypeMain";
|
|
57
|
+ private static final String CodecTypeHigh = "CodecTypeHigh";
|
|
58
|
+ private static final String QualityLow = "QualityLow";
|
|
59
|
+ private static final String QualityMedium = "QualityMedium";
|
|
60
|
+ private static final String QualityHigh = "QualityHigh";
|
|
61
|
+ private static final String Disconnected = "Disconnected";
|
|
62
|
+ private static final String Connecting = "Connecting";
|
|
63
|
+ private static final String Connected = "Connected";
|
|
64
|
+ private static final String Reconnecting = "Reconnecting";
|
|
65
|
+ private static final String ConnectionFailed = "ConnectionFailed";
|
|
66
|
+ private static final String ConnectionChangedConnecting = "ConnectionChangedConnecting";
|
|
67
|
+ private static final String ConnectionChangedJoinSuccess = "ConnectionChangedJoinSuccess";
|
|
68
|
+ private static final String ConnectionChangedInterrupted = "ConnectionChangedInterrupted";
|
|
69
|
+ private static final String ConnectionChangedBannedByServer = "ConnectionChangedBannedByServer";
|
|
70
|
+ private static final String ConnectionChangedJoinFailed = "ConnectionChangedJoinFailed";
|
|
71
|
+ private static final String ConnectionChangedLeaveChannel = "ConnectionChangedLeaveChannel";
|
|
72
|
+ private static final String AudioOutputRoutingDefault = "AudioOutputRoutingDefault";
|
|
73
|
+ private static final String AudioOutputRoutingHeadset = "AudioOutputRoutingHeadset";
|
|
74
|
+ private static final String AudioOutputRoutingEarpiece = "AudioOutputRoutingEarpiece";
|
|
75
|
+ private static final String AudioOutputRoutingHeadsetNoMic = "AudioOutputRoutingHeadsetNoMic";
|
|
76
|
+ private static final String AudioOutputRoutingSpeakerphone = "AudioOutputRoutingSpeakerphone";
|
|
77
|
+ private static final String AudioOutputRoutingLoudspeaker = "AudioOutputRoutingLoudspeaker";
|
|
78
|
+ private static final String AudioOutputRoutingHeadsetBluetooth = "AudioOutputRoutingHeadsetBluetooth";
|
|
79
|
+ private static final String NetworkQualityUnknown = "NetworkQualityUnknown";
|
|
80
|
+ private static final String NetworkQualityExcellent = "NetworkQualityExcellent";
|
|
81
|
+ private static final String NetworkQualityGood = "NetworkQualityGood";
|
|
82
|
+ private static final String NetworkQualityPoor = "NetworkQualityPoor";
|
|
83
|
+ private static final String NetworkQualityBad = "NetworkQualityBad";
|
|
84
|
+ private static final String NetworkQualityVBad = "NetworkQualityVBad";
|
|
85
|
+ private static final String NetworkQualityDown = "NetworkQualityDown";
|
|
86
|
+ private static final String AudioProfileDefault = "AudioProfileDefault";
|
|
87
|
+ private static final String AudioProfileSpeechStandard = "AudioProfileSpeechStandard";
|
|
88
|
+ private static final String AudioProfileMusicStandard = "AudioProfileMusicStandard";
|
|
89
|
+ private static final String AgoraAudioProfileMusicStandardStereo = "AudioProfileMusicStandardStereo";
|
|
90
|
+ private static final String AudioProfileMusicHighQuality = "AudioProfileMusicHighQuality";
|
|
91
|
+ private static final String AudioProfileMusicHighQualityStereo = "AudioProfileMusicHighQualityStereo";
|
|
92
|
+ private static final String AudioScenarioDefault = "AudioScenarioDefault";
|
|
93
|
+ private static final String AudioScenarioChatRoomEntertainment = "AudioScenarioChatRoomEntertainment";
|
|
94
|
+ private static final String AudioScenarioEducation = "AudioScenarioEducation";
|
|
95
|
+ private static final String AudioScenarioGameStreaming = "AudioScenarioGameStreaming";
|
|
96
|
+ private static final String AudioScenarioShowRoom = "AudioScenarioShowRoom";
|
|
97
|
+ private static final String AudioScenarioChatRoomGaming = "AudioScenarioChatRoomGaming";
|
|
98
|
+ private static final String AudioEqualizationBand31 = "AudioEqualizationBand31";
|
|
99
|
+ private static final String AudioEqualizationBand62 = "AudioEqualizationBand62";
|
|
100
|
+ private static final String AudioEqualizationBand125 = "AudioEqualizationBand125";
|
|
101
|
+ private static final String AudioEqualizationBand250 = "AudioEqualizationBand250";
|
|
102
|
+ private static final String AudioEqualizationBand500 = "AudioEqualizationBand500";
|
|
103
|
+ private static final String AudioEqualizationBand1K = "AudioEqualizationBand1K";
|
|
104
|
+ private static final String AudioEqualizationBand2K = "AudioEqualizationBand2K";
|
|
105
|
+ private static final String AudioEqualizationBand4K = "AudioEqualizationBand4K";
|
|
106
|
+ private static final String AudioEqualizationBand8K = "AudioEqualizationBand8K";
|
|
107
|
+ private static final String AudioEqualizationBand16K = "AudioEqualizationBand16K";
|
|
108
|
+ private static final String AudioRawFrameOperationModeReadOnly = "AudioRawFrameOperationModeReadOnly";
|
|
109
|
+ private static final String AudioRawFrameOperationModeWriteOnly = "AudioRawFrameOperationModeWriteOnly";
|
|
110
|
+ private static final String AudioRawFrameOperationModeReadWrite = "AudioRawFrameOperationModeReadWrite";
|
|
111
|
+ private static final String VideoStreamTypeHigh = "VideoStreamTypeHigh";
|
|
112
|
+ private static final String VideoStreamTypeLow = "VideoStreamTypeLow";
|
|
113
|
+ private static final String VideoMirrorModeAuto = "VideoMirrorModeAuto";
|
|
114
|
+ private static final String VideoMirrorModeEnabled = "VideoMirrorModeEnabled";
|
|
115
|
+ private static final String VideoMirrorModeDisabled = "VideoMirrorModeDisabled";
|
|
116
|
+ private static final String ChannelProfileCommunication = "ChannelProfileCommunication";
|
|
117
|
+ private static final String ChannelProfileLiveBroadcasting = "ChannelProfileLiveBroadcasting";
|
|
118
|
+ private static final String ChannelProfileGame = "ChannelProfileGame";
|
|
119
|
+ private static final String ErrorCodeNoError = "ErrorCodeNoError";
|
|
120
|
+ private static final String ErrorCodeFailed = "ErrorCodeFailed";
|
|
121
|
+ private static final String ErrorCodeInvalidArgument = "ErrorCodeInvalidArgument";
|
|
122
|
+ private static final String ErrorCodeTimedOut = "ErrorCodeTimedOut";
|
|
123
|
+ private static final String ErrorCodeAlreadyInUse = "ErrorCodeAlreadyInUse";
|
131
|
124
|
// private static String ErrorCodeAbort = "ErrorCodeAbort";
|
132
|
|
- private static String ErrorCodeEncryptedStreamNotAllowedPublished = "ErrorCodeEncryptedStreamNotAllowedPublished";
|
|
125
|
+ private static final String ErrorCodeEncryptedStreamNotAllowedPublished = "ErrorCodeEncryptedStreamNotAllowedPublished";
|
133
|
126
|
// private static String ErrorCodeResourceLimited = "ErrorCodeResourceLimited";
|
134
|
|
- private static String InjectStreamStatusStartSuccess = "InjectStreamStatusStartSuccess";
|
135
|
|
- private static String InjectStreamStatusStartAlreadyExist = "InjectStreamStatusStartAlreadyExist";
|
136
|
|
- private static String InjectStreamStatusStartUnauthorized = "InjectStreamStatusStartUnauthorized";
|
137
|
|
- private static String InjectStreamStatusStartTimeout = "InjectStreamStatusStartTimeout";
|
138
|
|
- private static String InjectStreamStatusStartFailed = "InjectStreamStatusStartFailed";
|
139
|
|
- private static String InjectStreamStatusStopSuccess = "InjectStreamStatusStopSuccess";
|
140
|
|
- private static String InjectStreamStatusStopNotFound = "InjectStreamStatusStopNotFound";
|
141
|
|
- private static String InjectStreamStatusStopUnauthorized = "InjectStreamStatusStopUnauthorized";
|
142
|
|
- private static String InjectStreamStatusStopTimeout = "InjectStreamStatusStopTimeout";
|
143
|
|
- private static String InjectStreamStatusStopFailed = "InjectStreamStatusStopFailed";
|
144
|
|
- private static String InjectStreamStatusBroken = "InjectStreamStatusBroken";
|
|
127
|
+ private static final String InjectStreamStatusStartSuccess = "InjectStreamStatusStartSuccess";
|
|
128
|
+ private static final String InjectStreamStatusStartAlreadyExist = "InjectStreamStatusStartAlreadyExist";
|
|
129
|
+ private static final String InjectStreamStatusStartUnauthorized = "InjectStreamStatusStartUnauthorized";
|
|
130
|
+ private static final String InjectStreamStatusStartTimeout = "InjectStreamStatusStartTimeout";
|
|
131
|
+ private static final String InjectStreamStatusStartFailed = "InjectStreamStatusStartFailed";
|
|
132
|
+ private static final String InjectStreamStatusStopSuccess = "InjectStreamStatusStopSuccess";
|
|
133
|
+ private static final String InjectStreamStatusStopNotFound = "InjectStreamStatusStopNotFound";
|
|
134
|
+ private static final String InjectStreamStatusStopUnauthorized = "InjectStreamStatusStopUnauthorized";
|
|
135
|
+ private static final String InjectStreamStatusStopTimeout = "InjectStreamStatusStopTimeout";
|
|
136
|
+ private static final String InjectStreamStatusStopFailed = "InjectStreamStatusStopFailed";
|
|
137
|
+ private static final String InjectStreamStatusBroken = "InjectStreamStatusBroken";
|
|
138
|
+ private static final String AgoraAudioMode = "AgoraAudioMode";
|
|
139
|
+ private static final String AgoraVideoMode = "AgoraVideoMode";
|
145
|
140
|
|
146
|
141
|
public AgoraModule(ReactApplicationContext context) {
|
147
|
142
|
super(context);
|
|
@@ -254,6 +249,8 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
254
|
249
|
constants.put(QualityLow, Constants.AUDIO_RECORDING_QUALITY_LOW);
|
255
|
250
|
constants.put(QualityMedium, Constants.AUDIO_RECORDING_QUALITY_MEDIUM);
|
256
|
251
|
constants.put(QualityHigh, Constants.AUDIO_RECORDING_QUALITY_HIGH);
|
|
252
|
+ constants.put(AgoraAudioMode, 0);
|
|
253
|
+ constants.put(AgoraVideoMode, 1);
|
257
|
254
|
return constants;
|
258
|
255
|
}
|
259
|
256
|
|
|
@@ -2169,8 +2166,8 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
2169
|
2166
|
public void setLiveTranscoding(ReadableMap options) {
|
2170
|
2167
|
try {
|
2171
|
2168
|
LiveTranscoding transcoding = new LiveTranscoding();
|
2172
|
|
- ReadableMap size = options.getMap("size");
|
2173
|
|
- if (size != null) {
|
|
2169
|
+ if (options.hasKey("size") && null != options.getMap("size")) {
|
|
2170
|
+ ReadableMap size = options.getMap("size");
|
2174
|
2171
|
transcoding.width = size.getInt("width");
|
2175
|
2172
|
transcoding.height = size.getInt("height");
|
2176
|
2173
|
}
|