patches 19/11/2024
This commit is contained in:
@@ -24,6 +24,8 @@ import java.net.SocketException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.pmw.tinylog.Logger;
|
||||
import peers.Config;
|
||||
|
||||
@@ -51,35 +53,47 @@ import peers.sip.transport.SipResponse;
|
||||
import peers.sip.transport.TransportManager;
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@SuppressWarnings({"unused", "FieldMayBeFinal", "FieldCanBeLocal", "UnusedReturnValue"})
|
||||
public class UserAgent {
|
||||
|
||||
public final static String CONFIG_FILE = "conf" + File.separator + "peers.xml";
|
||||
public final static int RTP_DEFAULT_PORT = 8000;
|
||||
|
||||
@Getter
|
||||
private String peersHome;
|
||||
@Getter
|
||||
private Config config;
|
||||
|
||||
@Getter
|
||||
private List<String> peers;
|
||||
//private List<Dialog> dialogs;
|
||||
|
||||
//TODO factorize echo and captureRtpSender
|
||||
@Setter
|
||||
@Getter
|
||||
private Echo echo;
|
||||
|
||||
@Getter
|
||||
private UAC uac;
|
||||
@Getter
|
||||
private UAS uas;
|
||||
|
||||
private ChallengeManager challengeManager;
|
||||
|
||||
@Getter
|
||||
private DialogManager dialogManager;
|
||||
private TransactionManager transactionManager;
|
||||
@Getter
|
||||
private TransportManager transportManager;
|
||||
|
||||
private int cseqCounter;
|
||||
@Getter
|
||||
private SipListener sipListener;
|
||||
|
||||
private SDPManager sdpManager;
|
||||
@Getter
|
||||
private AbstractSoundManager soundManager;
|
||||
@Getter
|
||||
private MediaManager mediaManager;
|
||||
|
||||
public UserAgent(SipListener sipListener, String peersHome,
|
||||
@@ -94,8 +108,8 @@ public class UserAgent {
|
||||
this(sipListener, config, null, soundManager);
|
||||
}
|
||||
|
||||
private UserAgent(SipListener sipListener, Config config, String peersHome,
|
||||
AbstractSoundManager soundManager)
|
||||
public UserAgent(SipListener sipListener, Config config, String peersHome,
|
||||
AbstractSoundManager soundManager)
|
||||
throws SocketException {
|
||||
this.sipListener = sipListener;
|
||||
if (peersHome == null) {
|
||||
@@ -110,18 +124,17 @@ public class UserAgent {
|
||||
this.config = config;
|
||||
|
||||
cseqCounter = 1;
|
||||
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append("starting user agent [");
|
||||
buf.append("myAddress: ");
|
||||
buf.append(config.getLocalInetAddress().getHostAddress()).append(", ");
|
||||
buf.append("sipPort: ");
|
||||
buf.append(config.getSipPort()).append(", ");
|
||||
buf.append("userpart: ");
|
||||
buf.append(config.getUserPart()).append(", ");
|
||||
buf.append("domain: ");
|
||||
buf.append(config.getDomain()).append("]");
|
||||
Logger.info(buf.toString());
|
||||
|
||||
String buf = "starting user agent [" +
|
||||
"myAddress: " +
|
||||
config.getLocalInetAddress().getHostAddress() + ", " +
|
||||
"sipPort: " +
|
||||
config.getSipPort() + ", " +
|
||||
"userpart: " +
|
||||
config.getUserPart() + ", " +
|
||||
"domain: " +
|
||||
config.getDomain() + "]";
|
||||
Logger.info(buf);
|
||||
|
||||
//transaction user
|
||||
|
||||
@@ -204,7 +217,7 @@ public class UserAgent {
|
||||
inviteHandler.setChallengeManager(challengeManager);
|
||||
byeHandler.setChallengeManager(challengeManager);
|
||||
|
||||
peers = new ArrayList<String>();
|
||||
peers = new ArrayList<>();
|
||||
//dialogs = new ArrayList<Dialog>();
|
||||
|
||||
sdpManager = new SDPManager(this);
|
||||
@@ -252,7 +265,7 @@ public class UserAgent {
|
||||
* Gives the sipMessage if sipMessage is a SipRequest or
|
||||
* the SipRequest corresponding to the SipResponse
|
||||
* if sipMessage is a SipResponse
|
||||
* @param sipMessage
|
||||
* @param sipMessage SipMessage
|
||||
* @return null if sipMessage is neither a SipRequest neither a SipResponse
|
||||
*/
|
||||
public SipRequest getSipRequest(SipMessage sipMessage) {
|
||||
@@ -274,33 +287,11 @@ public class UserAgent {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// public List<Dialog> getDialogs() {
|
||||
// return dialogs;
|
||||
// }
|
||||
|
||||
public List<String> getPeers() {
|
||||
return peers;
|
||||
}
|
||||
|
||||
// public Dialog getDialog(String peer) {
|
||||
// for (Dialog dialog : dialogs) {
|
||||
// String remoteUri = dialog.getRemoteUri();
|
||||
// if (remoteUri != null) {
|
||||
// if (remoteUri.contains(peer)) {
|
||||
// return dialog;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
public String generateCSeq(String method) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(cseqCounter++);
|
||||
buf.append(' ');
|
||||
buf.append(method);
|
||||
return buf.toString();
|
||||
return String.valueOf(cseqCounter++) +
|
||||
' ' +
|
||||
method;
|
||||
}
|
||||
|
||||
public boolean isRegistered() {
|
||||
@@ -308,18 +299,6 @@ public class UserAgent {
|
||||
.isRegistered();
|
||||
}
|
||||
|
||||
public UAS getUas() {
|
||||
return uas;
|
||||
}
|
||||
|
||||
public UAC getUac() {
|
||||
return uac;
|
||||
}
|
||||
|
||||
public DialogManager getDialogManager() {
|
||||
return dialogManager;
|
||||
}
|
||||
|
||||
public int getSipPort() {
|
||||
return transportManager.getSipPort();
|
||||
}
|
||||
@@ -348,35 +327,4 @@ public class UserAgent {
|
||||
return config.getOutboundProxy();
|
||||
}
|
||||
|
||||
public Echo getEcho() {
|
||||
return echo;
|
||||
}
|
||||
|
||||
public void setEcho(Echo echo) {
|
||||
this.echo = echo;
|
||||
}
|
||||
|
||||
public SipListener getSipListener() {
|
||||
return sipListener;
|
||||
}
|
||||
|
||||
public AbstractSoundManager getSoundManager() {
|
||||
return soundManager;
|
||||
}
|
||||
|
||||
public MediaManager getMediaManager() {
|
||||
return mediaManager;
|
||||
}
|
||||
|
||||
public Config getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public String getPeersHome() {
|
||||
return peersHome;
|
||||
}
|
||||
|
||||
public TransportManager getTransportManager() {
|
||||
return transportManager;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user