Skip to content

Commit

Permalink
Merge branch 'feature/dev_screencapture' into 'develop'
Browse files Browse the repository at this point in the history
✨ Support start screen capture callback

See merge request sdk/express/zego_express_flutter_sdk!21
  • Loading branch information
kebo committed Jul 5, 2024
2 parents 69c3bca + 0911900 commit 6e0678a
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,19 @@ public void onScreenCaptureExceptionOccurred(ZegoScreenCaptureExceptionType exce
sink.success(map);
}

@Override
public void onScreenCaptureStart() {
super.onScreenCaptureStart();
ZegoLog.log("[onMobileScreenCaptureStart]");

if (guardSink()) { return; }

HashMap<String, Object> map = new HashMap<>();
map.put("method", "onMobileScreenCaptureStart");

sink.success(map);
}

/* Private Utils */

private ArrayList<HashMap<String, Object>> mapListFromUserList(ArrayList<ZegoUser> users) {
Expand Down
6 changes: 6 additions & 0 deletions lib/src/impl/zego_express_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3467,6 +3467,12 @@ class ZegoExpressImpl {
ZegoScreenCaptureExceptionType.values[map['exceptionType']]);
break;

case 'onMobileScreenCaptureStart':
if (ZegoExpressEngine.onMobileScreenCaptureStart == null) return;

ZegoExpressEngine.onMobileScreenCaptureStart!();
break;

/* AI Voice Changer */
case 'onAIVoiceChangerInit':
if (ZegoExpressEngine.onAIVoiceChangerInit == null) {
Expand Down
14 changes: 8 additions & 6 deletions lib/src/impl/zego_express_texture_renderer_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ class ZegoExpressTextureRenderer {
});
}

void setStateStreamSubscription(String code, StreamSubscription? subscription) {
void setStateStreamSubscription(
String code, StreamSubscription? subscription) {
var oldSubscription = _subscriptionMap.remove(code);
oldSubscription?.cancel();
if (subscription != null) {
Expand Down Expand Up @@ -199,8 +200,8 @@ class _ZegoTextureWidgetState extends State<ZegoTextureWidget> {
setState(() {});
}
});
ZegoExpressTextureRenderer()
.setStateStreamSubscription('${widget.textureID}#$hashCode', subscription);
ZegoExpressTextureRenderer().setStateStreamSubscription(
'${widget.textureID}#$hashCode', subscription);
_isInit = true;
}

Expand All @@ -209,7 +210,8 @@ class _ZegoTextureWidgetState extends State<ZegoTextureWidget> {
_isInit = false;
ZegoExpressImpl.sendCustomLogMessage(
'[WidgetState] dispose. widget: ${widget.textureID}, state hashCode: $hashCode');
ZegoExpressTextureRenderer().setStateStreamSubscription('${widget.textureID}#$hashCode', null);
ZegoExpressTextureRenderer()
.setStateStreamSubscription('${widget.textureID}#$hashCode', null);
super.dispose();
}

Expand All @@ -223,8 +225,8 @@ class _ZegoTextureWidgetState extends State<ZegoTextureWidget> {
var subscription = widget.stream.listen((event) {
setState(() {});
});
ZegoExpressTextureRenderer()
.setStateStreamSubscription('${widget.textureID}#$hashCode', subscription);
ZegoExpressTextureRenderer().setStateStreamSubscription(
'${widget.textureID}#$hashCode', subscription);
}

Rect _viewModeCalculate(
Expand Down
20 changes: 16 additions & 4 deletions lib/src/zego_express_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ class ZegoExpressEngine {
/// - [streamID] Stream ID.
static void Function(String streamID)? onPlayerRecvAudioFirstFrame;

/// The callback triggered when the first video frame is received. Except for Linux systems, this callback is thrown from the ui thread by default.
/// The callback triggered when the first video frame is received.
///
/// Available since: 1.1.0
/// Description: After the [startPlayingStream] function is called successfully, this callback will be called when SDK received the first frame of video data.
Expand Down Expand Up @@ -710,7 +710,7 @@ class ZegoExpressEngine {
/// Description: After the [startPlayingStream] function is called successfully, when the remote stream sends SEI (such as directly calling [sendSEI], audio mixing with SEI data, and sending custom video capture encoded data with SEI, etc.), the local end will receive this callback.
/// Trigger: After the [startPlayingStream] function is called successfully, when the remote stream sends SEI, the local end will receive this callback.
/// Caution:
/// 1. This function will switch the UI thread callback data, and the customer can directly operate the UI control in this callback function.
/// 1.The customer can directly operate the UI control in this callback function.
/// 2. Since the video encoder itself generates an SEI with a payload type of 5, or when a video file is used for publishing, such SEI may also exist in the video file. Therefore, if the developer needs to filter out this type of SEI, it can be before [createEngine] Call [ZegoEngineConfig.advancedConfig("unregister_sei_filter", "XXXXX")]. Among them, unregister_sei_filter is the key, and XXXXX is the uuid filter string to be set.
/// 3. When [mutePlayStreamVideo] or [muteAllPlayStreamVideo] is called to set only the audio stream to be pulled, the SEI will not be received.
///
Expand Down Expand Up @@ -823,8 +823,11 @@ class ZegoExpressEngine {

/// The callback triggered when there is a change to audio devices (i.e. new device added or existing device deleted).
///
/// Only supports desktop.
/// This callback is triggered when an audio device is added or removed from the system. By listening to this callback, users can update the sound collection or output using a specific device when necessary.
/// Available since: 1.1.0
/// Description: By listening to this callback, users can update the sound collection or output using a specific device when necessary.
/// When to trigger: This callback is triggered when an audio device is added or removed from the system.
/// Restrictions: None.
/// Platform differences: Only supports Windows and macOS.
///
/// - [updateType] Update type (add/delete)
/// - [deviceType] Audio device type
Expand Down Expand Up @@ -1660,6 +1663,15 @@ class ZegoExpressEngine {
static void Function(ZegoScreenCaptureExceptionType exceptionType)?
onMobileScreenCaptureExceptionOccurred;

/// The callback triggered when start screen capture
///
/// Available since: 3.16.0
/// Description: The callback triggered when calling the start mobile screen capture.
/// Trigger: After calling [startScreenCapture], this callback will be triggered when starting screen capture successfully, and [onScreenCaptureExceptionOccurred] will be triggered when failing.
/// Caution: The callback does not actually take effect until call [setEventHandler] to set.
/// Restrictions: Only available on Android.
static void Function()? onMobileScreenCaptureStart;

/// Initialize AI voice changer engine status callback.
///
/// Available since: 3.10.0.
Expand Down
1 change: 1 addition & 0 deletions lib/src/zego_express_api_publisher.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:typed_data';
import 'package:flutter/services.dart';
import 'zego_express_api.dart';
import 'impl/zego_express_impl.dart';
Expand Down

0 comments on commit 6e0678a

Please sign in to comment.