sdk add conference rtp forward api

This commit is contained in:
heavyrian2012
2022-12-22 11:53:38 +08:00
parent 9c69fbc7d4
commit 4628b3b0b6
7 changed files with 92 additions and 9 deletions
@@ -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";
@@ -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<Stream> streams;
}
@@ -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;
}
}
@@ -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<RtpStream> streams;
}
public String roomId;
public List<RtpForwarder> forwarders;
}
@@ -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;
}
}
@@ -46,14 +46,22 @@ public class ConferenceAdmin {
return AdminHttpUtils.httpJsonPost(path, conferenceRoomId, Void.class);
}
public static IMResult<Void> rtpForward(String roomId, String userId, String rtpHost, int rtpPort) throws Exception {
public static IMResult<Void> 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<Void> 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<PojoConferenceRtpForwarders> 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);
}
}
@@ -1709,7 +1709,26 @@ public class Main {
}
}
IMResult<Void> rtpForwardResult = ConferenceAdmin.rtpForward("5156250396", "lhgqmws2k", "192.168.1.81", 8000);
IMResult<PojoConferenceRtpForwarders> 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<Void> 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<Void> 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 {