diff --git a/common/src/main/java/cn/wildfirechat/common/APIPath.java b/common/src/main/java/cn/wildfirechat/common/APIPath.java index d3cd6bd1..52e73ee8 100644 --- a/common/src/main/java/cn/wildfirechat/common/APIPath.java +++ b/common/src/main/java/cn/wildfirechat/common/APIPath.java @@ -95,6 +95,8 @@ public interface APIPath { String Conference_Destroy = "/admin/conference/destroy"; String Conference_Recording = "/admin/conference/recording"; String Conference_Rtp_Forward = "/admin/conference/rtp_forward"; + String Conference_Stop_Rtp_Forward = "/admin/conference/stop_rtp_forward"; + String Conference_List_Rtp_Forward = "/admin/conference/list_rtp_forward"; String Channel_User_Info = "/channel/user_info"; String Channel_Update_Profile = "/channel/update_profile"; diff --git a/common/src/main/java/cn/wildfirechat/pojos/PojoConferenceParticipant.java b/common/src/main/java/cn/wildfirechat/pojos/PojoConferenceParticipant.java index daf4fe0a..c51fbf7b 100644 --- a/common/src/main/java/cn/wildfirechat/pojos/PojoConferenceParticipant.java +++ b/common/src/main/java/cn/wildfirechat/pojos/PojoConferenceParticipant.java @@ -1,6 +1,15 @@ package cn.wildfirechat.pojos; +import java.util.List; + public class PojoConferenceParticipant { + public static class Stream { + public String type; + public String mid; + public String codec; + } + public String userId; public boolean publishing; + public List streams; } diff --git a/common/src/main/java/cn/wildfirechat/pojos/PojoConferenceRtpForwardReq.java b/common/src/main/java/cn/wildfirechat/pojos/PojoConferenceRtpForwardReq.java index 389047da..416ee514 100644 --- a/common/src/main/java/cn/wildfirechat/pojos/PojoConferenceRtpForwardReq.java +++ b/common/src/main/java/cn/wildfirechat/pojos/PojoConferenceRtpForwardReq.java @@ -5,16 +5,24 @@ public class PojoConferenceRtpForwardReq { public String publisherId; public String host; public int audioPort; + public int audioPt; + public long audioSSRC; public int videoPort; + public int videoPt; + public long videoSSRC; public PojoConferenceRtpForwardReq() { } - public PojoConferenceRtpForwardReq(String roomId, String publisherId, String host, int audioPort, int videoPort) { + public PojoConferenceRtpForwardReq(String roomId, String publisherId, String host, int audioPort, int audioPt, long audioSSRC, int videoPort, int videoPt, long videoSSRC) { this.roomId = roomId; this.publisherId = publisherId; this.host = host; this.audioPort = audioPort; + this.audioPt = audioPt; + this.audioSSRC = audioSSRC; this.videoPort = videoPort; + this.videoPt = videoPt; + this.videoSSRC = videoSSRC; } } diff --git a/common/src/main/java/cn/wildfirechat/pojos/PojoConferenceRtpForwarders.java b/common/src/main/java/cn/wildfirechat/pojos/PojoConferenceRtpForwarders.java new file mode 100644 index 00000000..75dc63fd --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/PojoConferenceRtpForwarders.java @@ -0,0 +1,21 @@ +package cn.wildfirechat.pojos; + +import java.util.List; + +public class PojoConferenceRtpForwarders { + public static class RtpForwarder { + public static class RtpStream { + public long streamId; + public String type; + public String host; + public int port; + public long ssrc; + public int pt; + } + + public String publisherId; + public List streams; + } + public String roomId; + public List forwarders; +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/PojoConferenceStopRtpForwardReq.java b/common/src/main/java/cn/wildfirechat/pojos/PojoConferenceStopRtpForwardReq.java new file mode 100644 index 00000000..8686b281 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/PojoConferenceStopRtpForwardReq.java @@ -0,0 +1,16 @@ +package cn.wildfirechat.pojos; + +public class PojoConferenceStopRtpForwardReq { + public String roomId; + public String publisherId; + public long streamId; + + public PojoConferenceStopRtpForwardReq() { + } + + public PojoConferenceStopRtpForwardReq(String roomId, String publisherId, long streamId) { + this.roomId = roomId; + this.publisherId = publisherId; + this.streamId = streamId; + } +} diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/ConferenceAdmin.java b/sdk/src/main/java/cn/wildfirechat/sdk/ConferenceAdmin.java index e1bfaa8c..a0977e2c 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/ConferenceAdmin.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/ConferenceAdmin.java @@ -46,14 +46,22 @@ public class ConferenceAdmin { return AdminHttpUtils.httpJsonPost(path, conferenceRoomId, Void.class); } - public static IMResult rtpForward(String roomId, String userId, String rtpHost, int rtpPort) throws Exception { + public static IMResult rtpForward(String roomId, String userId, String rtpHost, int audioPort, int audioPt, long audioSSRC, int videoPort, int videoPt, long videoSSRC) throws Exception { String path = APIPath.Conference_Rtp_Forward; - PojoConferenceRtpForwardReq req = new PojoConferenceRtpForwardReq(); - req.roomId = roomId; - req.publisherId = userId; - req.host = rtpHost; - req.audioPort = rtpPort; - req.videoPort = rtpPort; + PojoConferenceRtpForwardReq req = new PojoConferenceRtpForwardReq(roomId, userId, rtpHost, audioPort, audioPt, audioSSRC, videoPort, videoPt, videoSSRC); return AdminHttpUtils.httpJsonPost(path, req, Void.class); } + + public static IMResult stopRtpForward(String roomId, String userId, long streamId) throws Exception { + String path = APIPath.Conference_Stop_Rtp_Forward; + PojoConferenceStopRtpForwardReq req = new PojoConferenceStopRtpForwardReq(roomId, userId, streamId); + return AdminHttpUtils.httpJsonPost(path, req, Void.class); + } + + public static IMResult listRtpForwarders(String roomId) throws Exception { + String path = APIPath.Conference_List_Rtp_Forward; + PojoConferenceRoomId req = new PojoConferenceRoomId(); + req.roomId = roomId; + return AdminHttpUtils.httpJsonPost(path, req, PojoConferenceRtpForwarders.class); + } } diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/Main.java b/sdk/src/main/java/cn/wildfirechat/sdk/Main.java index c99d0a02..75dad928 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/Main.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/Main.java @@ -1709,7 +1709,26 @@ public class Main { } } - IMResult rtpForwardResult = ConferenceAdmin.rtpForward("5156250396", "lhgqmws2k", "192.168.1.81", 8000); + IMResult listForwarderResult = ConferenceAdmin.listRtpForwarders("6366963312"); + if(listForwarderResult == null || listForwarderResult.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) { + System.out.println("list rtp forward failure"); + } else { + System.out.println("list rtp forward success"); + listForwarderResult.getResult().forwarders.forEach(rtpForwarder -> rtpForwarder.streams.forEach(rtpStream -> { + try { + IMResult stopRtpForwardResult = ConferenceAdmin.stopRtpForward(listForwarderResult.getResult().roomId, rtpForwarder.publisherId, rtpStream.streamId); + if(stopRtpForwardResult == null || stopRtpForwardResult.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) { + System.out.println("rtp forward stop failure"); + } else { + System.out.println("rtp forward stop success"); + } + } catch (Exception e) { + e.printStackTrace(); + } + })); + } + + IMResult rtpForwardResult = ConferenceAdmin.rtpForward("6366963312", "cygqmws2k", "192.168.1.81", 10000, 111, 0, 10005, 98, 0); if(rtpForwardResult == null || rtpForwardResult.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) { System.out.println("rtp forward failure"); } else {