Search in sources :

Example 6 with MediaInfo

use of com.sun.voip.MediaInfo in project Openfire by igniterealtime.

the class CallSetupAgent method stopCallAnsweredTreatment.

/**
     * Stop call answered treatment
     */
public void stopCallAnsweredTreatment() {
    if (callAnsweredTreatment != null) {
        if (Logger.logLevel >= Logger.LOG_MOREINFO) {
            Logger.println("Call " + callHandler + " Stop callAnsweredTreatment player...");
        }
        callAnsweredTreatment.stopTreatment();
        callAnsweredTreatment = null;
    } else {
        if (cp.getJoinConfirmationTimeout() != 0) {
            if (getState() == CallState.INVITED) {
                setState(CallState.ANSWERED);
                MediaInfo mediaInfo = callHandler.getConferenceManager().getMediaInfo();
                setState(CallState.ESTABLISHED, "ConferencePayload='" + mediaInfo.getPayload() + "'" + " BridgeIPAddress='" + Bridge.getPrivateHost() + "'");
            }
        }
    }
}
Also used : MediaInfo(com.sun.voip.MediaInfo)

Example 7 with MediaInfo

use of com.sun.voip.MediaInfo in project Openfire by igniterealtime.

the class NSOutgoingCallAgent method setRemoteMediaInfo.

public void setRemoteMediaInfo(String sdp) throws ParseException {
    if (getState() != CallState.INVITED) {
        Logger.println("Call " + cp + ":  NSOutgoingCallAgent:  bad state " + getState());
        return;
    }
    sdp = sdp.replaceAll("\\+", "\r\n");
    Logger.println("Call " + cp + ":  NSOutgoingCallAgent:  remote SDP:  " + sdp);
    SdpInfo sdpInfo = sipUtil.getSdpInfo(sdp, false);
    MediaInfo mediaInfo = sdpInfo.getMediaInfo();
    InetSocketAddress isa = new InetSocketAddress(sdpInfo.getRemoteHost(), sdpInfo.getRemotePort());
    Logger.println("Call " + cp + ":  NSOutgoingCallAgent:  " + mediaInfo + " remote " + isa);
    setEndpointAddress(isa, mediaInfo.getPayload(), sdpInfo.getTransmitMediaInfo().getPayload(), sdpInfo.getTelephoneEventPayload());
    if (callAnswered) {
        Logger.writeFile("Call " + cp + ":  NSOutgoingCallAgent: done remote SDP");
        return;
    }
    /*
		 * The CallParticipant has answered.
		 * If join confirmation is required, we remain in the
		 * INVITED state.
		 */
    callAnswered = true;
    if (cp.getJoinConfirmationTimeout() == 0) {
        setState(CallState.ANSWERED);
    }
    /*
		 * Start treatment if any and wait for it to finish.
		 * When the treatment finishes, notification will
		 * be delivered to our parent which will indicate
		 * we're ready for the conference.
		 *
		 * If there's no treatment to be played, we're ready now
		 * unless we're waiting for join confirmation..
		 */
    initializeCallAnsweredTreatment();
    if (callAnsweredTreatment != null) {
        startCallAnsweredTreatment();
    } else {
        if (cp.getJoinConfirmationTimeout() == 0) {
            setState(CallState.ESTABLISHED);
        }
    }
}
Also used : MediaInfo(com.sun.voip.MediaInfo) InetSocketAddress(java.net.InetSocketAddress) SdpInfo(com.sun.voip.SdpInfo)

Example 8 with MediaInfo

use of com.sun.voip.MediaInfo in project Openfire by igniterealtime.

the class MemberReceiver method restartInputTreatment.

public void restartInputTreatment() {
    if (Logger.logLevel >= Logger.LOG_MOREINFO) {
        Logger.println("Call " + cp + " restartInputTreatment " + cp.getInputTreatment());
    }
    if (whisperGroup == null) {
        Logger.println("Call " + cp + " restartInputTreatment wg is null!");
        return;
    }
    synchronized (this) {
        if (cp.getInputTreatment() != null && cp.getInputTreatment().length() > 0) {
            try {
                MediaInfo conferenceMediaInfo = conferenceManager.getMediaInfo();
                String absolutePath = cp.getInputTreatment();
                if (cp.getRecordDirectory() != null) {
                    absolutePath = Recorder.getAbsolutePath(cp.getRecordDirectory(), cp.getInputTreatment());
                }
                if (Logger.logLevel >= Logger.LOG_INFO) {
                    Logger.println("Call " + cp + " new input treatment " + absolutePath);
                }
                new InputTreatment(this, absolutePath, 0, conferenceMediaInfo.getSampleRate(), conferenceMediaInfo.getChannels());
            } catch (IOException e) {
                Logger.println(cp + " Unable to restart input treatment " + cp.getInputTreatment() + ": " + e.getMessage());
                callHandler.cancelRequest("unable to restart input treatment " + cp.getInputTreatment() + ": " + e.getMessage());
            }
        }
    }
}
Also used : MediaInfo(com.sun.voip.MediaInfo) IOException(java.io.IOException)

Example 9 with MediaInfo

use of com.sun.voip.MediaInfo in project Openfire by igniterealtime.

the class MemberReceiver method initialize.

/**
     * Initialize this member.  The call has been established and
     * we now know the port at which the member (CallParticipant)
     * listens for data.
     */
public void initialize(ConferenceManager conferenceManager, CallHandler callHandler, byte mediaPayload, byte telephoneEventPayload, RtcpReceiver rtcpReceiver) {
    this.conferenceManager = conferenceManager;
    this.telephoneEventPayload = telephoneEventPayload;
    this.rtcpReceiver = rtcpReceiver;
    this.callHandler = callHandler;
    Logger.writeFile("Call " + cp + " MemberReceiver initialization started..." + cp.getProtocol());
    conferenceWhisperGroup = conferenceManager.getWGManager().getConferenceWhisperGroup();
    MediaInfo conferenceMediaInfo = conferenceManager.getMediaInfo();
    int outSampleRate = conferenceMediaInfo.getSampleRate();
    int outChannels = conferenceMediaInfo.getChannels();
    jitterManager = new JitterManager("Call " + cp.toString());
    if (cp.voiceDetection()) {
        if (Logger.logLevel >= Logger.LOG_MOREINFO) {
            Logger.println("Call " + cp + " starting speech Detector...");
        }
        speechDetector = new SpeechDetector(this.toString(), conferenceMediaInfo);
    }
    if (cp.getProtocol() != null && ("WebRtc".equals(cp.getProtocol()) || "Rtmfp".equals(cp.getProtocol()) || "Speaker".equals(cp.getProtocol()))) {
        conferenceManager.getConferenceReceiver().addMember(this);
        if (cp.getJoinConfirmationTimeout() == 0) {
            joinConfirmationReceived = true;
            readyToReceiveData = true;
            playJoinTreatment();
        }
    } else {
        try {
            myMediaInfo = SdpManager.findMediaInfo(mediaPayload);
        } catch (ParseException e) {
            Logger.println("Call " + cp + " Invalid mediaPayload " + mediaPayload);
            callHandler.cancelRequest("Invalid mediaPayload " + mediaPayload);
            return;
        }
        Logger.println("My media info:  " + myMediaInfo);
        int inSampleRate = myMediaInfo.getSampleRate();
        int inChannels = myMediaInfo.getChannels();
        //if (cp.getPhoneNumber().indexOf("@") >= 0) {
        ConferenceReceiver conferenceReceiver = conferenceManager.getConferenceReceiver();
        conferenceManager.getConferenceReceiver().addMember(this);
        /*
		 * For input treatments, the treatment manager does the resampling.
		 */
        if (cp.getInputTreatment() == null) {
            if (inSampleRate != outSampleRate || inChannels != outChannels) {
                try {
                    Logger.println("Call " + cp + " resample received data from " + inSampleRate + "/" + inChannels + " to " + outSampleRate + "/" + outChannels);
                    inSampleRateConverter = new SampleRateConverter(this.toString(), inSampleRate, inChannels, outSampleRate, outChannels);
                } catch (IOException e) {
                    callHandler.cancelRequest(e.getMessage());
                    return;
                }
            }
        }
        packet = new RtpReceiverPacket(cp.toString(), myMediaInfo.getEncoding(), inSampleRate, inChannels);
        if (initializationDone) {
            /*
			 * This is a re-initialize
			 */
            return;
        }
        //if (telephoneEventPayload == 0 && (cp.dtmfDetection() || cp.getJoinConfirmationTimeout() != 0)) {
        Logger.println("Call " + cp + " starting dtmf Detector..." + telephoneEventPayload + " " + cp.dtmfDetection());
        dtmfDecoder = new DtmfDecoder(this, myMediaInfo);
        if (myMediaInfo.getEncoding() == RtpPacket.SPEEX_ENCODING) {
            try {
                speexDecoder = new SpeexDecoder(inSampleRate, inChannels);
                Logger.println("Call " + cp + " created SpeexDecoder");
            } catch (SpeexException e) {
                Logger.println("Call " + cp + e.getMessage());
                callHandler.cancelRequest(e.getMessage());
                return;
            }
        } else if (myMediaInfo.getEncoding() == RtpPacket.PCM_ENCODING) {
            try {
                opusDecoder = Opus.decoder_create(opusSampleRate, opusChannels);
                if (opusDecoder == 0) {
                    Logger.println("Call " + cp + " OPUS decoder creation error ");
                    callHandler.cancelRequest("OPUS decoder creation error ");
                    return;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (cp.getJoinConfirmationTimeout() == 0) {
            joinConfirmationReceived = true;
            readyToReceiveData = true;
            playJoinTreatment();
        }
        if (cp.getInputTreatment() != null && cp.getInputTreatment().length() > 0) {
            String absolutePath = cp.getInputTreatment();
            try {
                if (cp.getRecordDirectory() != null) {
                    absolutePath = Recorder.getAbsolutePath(cp.getRecordDirectory(), cp.getInputTreatment());
                }
                if (Logger.logLevel >= Logger.LOG_INFO) {
                    Logger.println("Call " + cp + " New input treatment:  " + absolutePath);
                }
                synchronized (this) {
                    new InputTreatment(this, absolutePath, 0, conferenceMediaInfo.getSampleRate(), conferenceMediaInfo.getChannels());
                }
            } catch (IOException e) {
                e.printStackTrace();
                Logger.println("MemberReceiver:  Invalid input treatment " + absolutePath + ":  " + e.getMessage());
                callHandler.cancelRequest("Invalid input treatment " + absolutePath + ":  " + e.getMessage());
                return;
            }
        }
        String forwardingCallId = cp.getForwardingCallId();
        if (forwardingCallId != null) {
            CallHandler forwardingCall = CallHandler.findCall(forwardingCallId);
            if (forwardingCall == null) {
                Logger.println("Invalid forwardingCallId:  " + forwardingCallId);
                callHandler.cancelRequest("Invalid forwardingCallId:  " + forwardingCallId);
                return;
            }
            ConferenceMember m = forwardingCall.getMember();
            m.getMemberReceiver().addForwardMember(member.getMemberSender());
            /*
			 * If the source of the data is an input treatment, there
			 * is no need to have the forwarding call receive data
			 * from the remote side.
			 */
            if (cp.getInputTreatment() != null) {
                m.setConferenceMuted(true);
            }
        }
    }
    initializationDone = true;
    Logger.writeFile("Call " + cp + " MemberReceiver initialization done...");
}
Also used : SampleRateConverter(com.sun.voip.SampleRateConverter) IOException(java.io.IOException) JitterManager(com.sun.voip.JitterManager) Point(java.awt.Point) SpeexException(com.sun.voip.SpeexException) SpeexException(com.sun.voip.SpeexException) SocketException(java.net.SocketException) NoSuchElementException(java.util.NoSuchElementException) ParseException(java.text.ParseException) ClosedChannelException(java.nio.channels.ClosedChannelException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) MediaInfo(com.sun.voip.MediaInfo) ParseException(java.text.ParseException) SpeexDecoder(com.sun.voip.SpeexDecoder) SpeechDetector(com.sun.voip.SpeechDetector) RtpReceiverPacket(com.sun.voip.RtpReceiverPacket)

Example 10 with MediaInfo

use of com.sun.voip.MediaInfo in project Openfire by igniterealtime.

the class SipTPCCallAgent method handleReInvite.

private void handleReInvite(Request request, ServerTransaction st) {
    Logger.println("Call " + cp + " Re-INVITE\n" + request);
    if (request.getRawContent() == null) {
        Logger.error("Call " + cp + " no SDP in INVITE Request!");
        return;
    }
    String sdpBody = new String(request.getRawContent());
    SdpInfo sdpInfo;
    try {
        sdpInfo = sipUtil.getSdpInfo(sdpBody);
    } catch (ParseException e) {
        Logger.error("Call " + cp + " invalid SDP in re-INVITE Request! " + e.getMessage());
        return;
    }
    MediaInfo mediaInfo = sdpInfo.getMediaInfo();
    InetSocketAddress isa = new InetSocketAddress(sdpInfo.getRemoteHost(), sdpInfo.getRemotePort());
    InetSocketAddress rtcpAddress = sdpInfo.getRtcpAddress();
    setEndpointAddress(isa, mediaInfo.getPayload(), sdpInfo.getTransmitMediaInfo().getPayload(), sdpInfo.getTelephoneEventPayload(), rtcpAddress);
    isa = callHandler.getReceiveAddress();
    try {
        sipUtil.sendOkWithSdp(request, st, isa, sdpInfo);
    } catch (Exception e) {
        Logger.println("Call " + cp + " Failed to send ok with sdp for re-invite " + e.getMessage());
        return;
    }
}
Also used : MediaInfo(com.sun.voip.MediaInfo) InetSocketAddress(java.net.InetSocketAddress) SdpInfo(com.sun.voip.SdpInfo) ParseException(java.text.ParseException) IOException(java.io.IOException) InvalidArgumentException(javax.sip.InvalidArgumentException) ParseException(java.text.ParseException)

Aggregations

MediaInfo (com.sun.voip.MediaInfo)15 IOException (java.io.IOException)6 ParseException (java.text.ParseException)5 SdpInfo (com.sun.voip.SdpInfo)4 InetSocketAddress (java.net.InetSocketAddress)4 UnknownHostException (java.net.UnknownHostException)2 CallEvent (com.sun.voip.CallEvent)1 CallParticipant (com.sun.voip.CallParticipant)1 CallState (com.sun.voip.CallState)1 JitterManager (com.sun.voip.JitterManager)1 Recorder (com.sun.voip.Recorder)1 RtpReceiverPacket (com.sun.voip.RtpReceiverPacket)1 SampleRateConverter (com.sun.voip.SampleRateConverter)1 SpeechDetector (com.sun.voip.SpeechDetector)1 SpeexDecoder (com.sun.voip.SpeexDecoder)1 SpeexException (com.sun.voip.SpeexException)1 TreatmentManager (com.sun.voip.TreatmentManager)1 Point (java.awt.Point)1 SocketException (java.net.SocketException)1 ClosedChannelException (java.nio.channels.ClosedChannelException)1