/** Handle a dial request */ public void handleDialRequest(String phoneNumber) { try { System.err.println( "Audio Static:" + PhoneManager.isUseStaticLocator() + " Using:" + PhoneManager.isUsingMediaLocator()); // cancel call request if no Media Locator if (PhoneManager.isUseStaticLocator() && PhoneManager.isUsingMediaLocator()) { return; } PhoneManager.setUsingMediaLocator(true); SessionDescription sdpData = mediaManager.generateSdpDescription(); Call call = sipManager.establishCall(phoneNumber, sdpData.toString()); if (call == null) return; call.setLocalSdpDescription(sdpData); call.addStateChangeListener(this); Interlocutor interlocutor = new Interlocutor(); interlocutor.setCall(call); guiManager.addInterlocutor(interlocutor); } catch (Exception e) { Log.error("handleDialRequest", e); } }
/** Handle a answer request */ public boolean handleAnswerRequest(Interlocutor interlocutor) { // cancel call request if no Media Locator if (PhoneManager.isUseStaticLocator() && PhoneManager.isUsingMediaLocator()) { return false; } PhoneManager.setUsingMediaLocator(true); SessionDescription sdpData = null; try { sdpData = mediaManager.generateSdpDescription(); interlocutor.getCall().setLocalSdpDescription(sdpData); } catch (MediaException ex) { try { sipManager.sendServerInternalError(interlocutor.getID()); } catch (CommunicationsException ex1) { Log.error("handleAnswerRequest", ex1); } return false; } try { sipManager.answerCall(interlocutor.getID(), sdpData.toString()); } catch (CommunicationsException exc) { Log.error("handleAnswerRequest", exc); return false; } return true; }
public boolean setup(SessionDescription sd, int mediaIndex) { boolean finish = false; try { Vector<MediaDescription> mds = sd.getMediaDescriptions(true); if (mds.size() <= mediaIndex) { finish = true; } else { MediaDescription md = mds.get(mediaIndex); RtpSessionExt rtp = rtspStack.createRtpSession(md); rtp.bind(false, true); // sendTCPSetup(md.getAttribute("control"), rtp.getRtpInterleaved(), // rtp.getRtcpInterleaved()); sendUDPSetup(md.getAttribute("control"), rtp.getRtpPort(), rtp.getRtcpPort()); setState(RTSP.SETUP); } } catch (SdpException e) { throw new IllegalArgumentException(e); } catch (IllegalStateException e) { logger.error(e.getMessage(), e); } catch (IOException e) { logger.error(e.getMessage(), e); } return finish; }
// Issue 308: https://telestax.atlassian.net/browse/RESTCOMM-308 @SuppressWarnings("unchecked") private static String patch(final byte[] data, final String externalIp) throws UnknownHostException, SdpException { final String text = new String(data); final SessionDescription sdp = SdpFactory.getInstance().createSessionDescription(text); SessionName sessionName = SdpFactory.getInstance().createSessionName("Restcomm B2BUA"); sdp.setSessionName(sessionName); // Handle the connection at the session level. fix(sdp.getConnection(), externalIp); // Handle the connections at the media description level. final Vector<MediaDescription> descriptions = sdp.getMediaDescriptions(false); for (final MediaDescription description : descriptions) { fix(description.getConnection(), externalIp); } sdp.getOrigin().setAddress(externalIp); return sdp.toString(); }