addLiveStreamTask method Null safety
- NERtcLiveStreamTaskInfo taskInfo,
- AddLiveTaskCallback? callback
Add a live streaming task. After the method is successfully called, the current user can receive the notification about the status of the live streaming task. The operation is valid during a call.
taskInfo live streaming task info
AddLiveTaskCallback operation result. The callback is triggered when the operation succeeds
Implementation
Future<int> addLiveStreamTask(
NERtcLiveStreamTaskInfo taskInfo, AddLiveTaskCallback? callback) async {
int serial = -1;
if (callback != null) {
serial = _onceEventHandler.addOnceCallback((args) {
callback(args['taskId'], args['errCode']);
});
}
List<Map<dynamic, dynamic>>? userTranscodingList =
taskInfo.layout?.userTranscodingList?.map((e) => e._toMap()).toList();
IntValue reply =
await _api.addLiveStreamTask(AddOrUpdateLiveStreamTaskRequest()
..serial = serial
..taskId = taskInfo.taskId
..url = taskInfo.url
..serverRecordEnabled = taskInfo.serverRecordEnabled
..liveMode = taskInfo.liveMode
..layoutWidth = taskInfo.layout?.width
..layoutHeight = taskInfo.layout?.height
..layoutBackgroundColor = taskInfo.layout?.backgroundColor?.value
..layoutImageUrl = taskInfo.layout?.backgroundImg?.url
..layoutImageX = taskInfo.layout?.backgroundImg?.x
..layoutImageY = taskInfo.layout?.backgroundImg?.y
..layoutImageWidth = taskInfo.layout?.backgroundImg?.width
..layoutImageHeight = taskInfo.layout?.backgroundImg?.height
..layoutUserTranscodingList = userTranscodingList);
return reply.value ?? -1;
}