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 摘要。