AgoraIO-Extensions / AgoraIO-Extensions/Agora-Flutter-SDK

Why i'm getting same remote id for multiple stream.

未关闭
#2,465 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Dart
星标
795
派生
448
平均合并
12 小时 19 分钟
30 天内合并 PR
14

描述

I want to show the multiple video stream in one screen like cctv camera view. but only play the first stream and other remaining stream not playing.
I have notice one point is, i have do the loop to createAgoraRtcEngine each and every stream separately but getting same remote id for all the stream.

Please help me for this how i can play all the stream parallel.

below i have mention the code for understanding.


snapShot.requireData.forEach((element) async {
{
_playAutoPlay(cameraModel: element);
await Future.delayed(const Duration(seconds: 5));
}
});

void _playAutoPlay({required CCRoomAgoraModel cameraModel}) async
{
isLoaded = false;
await initAgora(cameraModel: cameraModel);
await Future.delayed(const Duration(milliseconds: 500));
await agoraStartStream(cameraModel: cameraModel);
roomController.update();
}

Future initAgora({required CCRoomAgoraModel cameraModel}) async {
try {
cameraModel.agoraEngine = createAgoraRtcEngine();
await cameraModel.agoraEngine!.initialize(
RtcEngineContext(
appId: CCConfig.agoraAppId,
channelProfile: ChannelProfileType.channelProfileLiveBroadcasting,
),
);

// Enable video
await cameraModel.agoraEngine!.enableVideo();
cameraModel.isInitialized = true;
// Register event handler
cameraModel.agoraEngine!.registerEventHandler(
RtcEngineEventHandler(
onJoinChannelSuccess: (RtcConnection connection, int elapsed) {

},
onUserJoined: (RtcConnection connection, int remoteUid, int elapsed) {
CCPrint(name: "AgoraCheck", value: "Remote ID: ${remoteUid.toString()} == Camera Name: ${cameraModel.equipment_name} ",
);
cameraModel.remoteUid = remoteUid;
cameraModel.isLive = true;
setState(() {});
},
onUserOffline: (
RtcConnection connection,
int uid,
UserOfflineReasonType reason,
) {
CCPrint(name: "AgoraCheck", value: "onUserOffline");
cameraModel.isLive = false;
setState(() {});

},
onLeaveChannel: (RtcConnection connection, RtcStats stats) {
CCPrint(name: "AgoraCheck", value: "onLeaveChannel");

},
onError: (ErrorCodeType err, String msg) {

},
onRtcStats: (RtcConnection connection, RtcStats stats) {

},
),
);


} catch (e) {
CCPrint(name: "AgoraCheck", value: "init catch $e");
}
}

Future agoraStartStream({required CCRoomAgoraModel cameraModel}) async {
try {
// statusMessage.value = 'Connecting to broadcast...';

// Set user role as audience (viewer)
await cameraModel.agoraEngine!.setClientRole(
role: ClientRoleType.clientRoleAudience,
);

// Join channel
await cameraModel.agoraEngine!.joinChannel(
token: cameraModel.agora_token,
channelId: cameraModel.equipment_code.toString(),
uid: int.parse(cameraModel.remoteUid.toString()),
options: ChannelMediaOptions(
clientRoleType: ClientRoleType.clientRoleAudience,
autoSubscribeAudio: true,
autoSubscribeVideo: true,
publishMicrophoneTrack: false,
// Viewer doesn't send audio
publishCameraTrack: false,
// Viewer doesn't send video
channelProfile: ChannelProfileType.channelProfileLiveBroadcasting,
),
);
setState(() {});
} catch (e) {
CCPrint(name: "AgoraCheck", value: "start catch $e");
}
}

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。