8000 Do not call reStartCamera() for screen capture (#552) · tmthecoder/flutter-webrtc@cfa1e88 · GitHub
[go: up one dir, main page]

Skip to content

Commit cfa1e88

Browse files
authored
Do not call reStartCamera() for screen capture (flutter-webrtc#552)
* Do not call reStartCamera() for screen capture * Add configuration "cryptoOptions" in parseRTCConfiguration()
1 parent d47e5af commit cfa1e88

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

android/src/main/java/com/cloudwebrtc/webrtc/GetUserMediaImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ public void onStop() {
495495
info.width = wm.getDefaultDisplay().getWidth();
496496
info.height = wm.getDefaultDisplay().getHeight();
497497
info.fps = DEFAULT_FPS;
498+
info.isScreenCapture = true;
498499
info.capturer = videoCapturer;
499500

500501
videoCapturer.startCapture(info.width, info.height, info.fps);
@@ -1024,7 +1025,7 @@ private class NoSuchFieldWithNameException extends NoSuchFieldException {
10241025

10251026
public void reStartCamera(IsCameraEnabled getCameraId) {
10261027
for (Map.Entry<String, VideoCapturerInfo> item : mVideoCapturers.entrySet()) {
1027-
if (getCameraId.isEnabled(item.getKey())) {
1028+
if (!item.getValue().isScreenCapture && getCameraId.isEnabled(item.getKey())) {
10281029
item.getValue().capturer.startCapture(
10291030
item.getValue().width,
10301031
item.getValue().height,
@@ -1043,5 +1044,6 @@ public class VideoCapturerInfo {
10431044
int width;
10441045
int height;
10451046
int fps;
1047+
boolean isScreenCapture = false;
10461048
}
10471049
}

android/src/main/java/com/cloudwebrtc/webrtc/MethodCallHandlerImpl.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.cloudwebrtc.webrtc.utils.ObjectType;
2121

2222
import org.webrtc.AudioTrack;
23+
import org.webrtc.CryptoOptions;
2324
import org.webrtc.DefaultVideoDecoderFactory;
2425
import org.webrtc.DefaultVideoEncoderFactory;
2526
import org.webrtc.DtmfSender;
@@ -924,7 +925,17 @@ private RTCConfiguration parseRTCConfiguration(ConstraintsMap map) {
924925
final boolean v = map.getBoolean("presumeWritableWhenFullyRelayed");
925926
conf.presumeWritableWhenFullyRelayed = v;
926927
}
927-
928+
// cryptoOptions
929+
if (map.hasKey("cryptoOptions")
930+
&& map.getType("cryptoOptions") == ObjectType.Map) {
931+
final ConstraintsMap cryptoOptions = map.getMap("cryptoOptions");
932+
conf.cryptoOptions = CryptoOptions.builder()
933+
.setEnableGcmCryptoSuites(cryptoOptions.hasKey("enableGcmCryptoSuites") && cryptoOptions.getBoolean("enableGcmCryptoSuites"))
934+
.setRequireFrameEncryption(cryptoOptions.hasKey("requireFrameEncryption") && cryptoOptions.getBoolean("requireFrameEncryption"))
935+
.setEnableEncryptedRtpHeaderExtensions(cryptoOptions.hasKey("enableEncryptedRtpHeaderExtensions") && cryptoOptions.getBoolean("enableEncryptedRtpHeaderExtensions"))
936+
.setEnableAes128Sha1_32CryptoCipher(cryptoOptions.hasKey("enableAes128Sha1_32CryptoCipher") && cryptoOptions.getBoolean("enableAes128Sha1_32CryptoCipher"))
937+
.createCryptoOptions();
938+
}
928939
return conf;
929940
}
930941

0 commit comments

Comments
 (0)
0