Search in sources :

Example 41 with ParseException

use of java.text.ParseException in project Openfire by igniterealtime.

the class ConferenceManager method playTreatment.

/**
     * Play a treatment to the specified conference
     */
public static void playTreatment(String conferenceId, String treatment) throws ParseException {
    if (Logger.logLevel >= Logger.LOG_MOREINFO) {
        Logger.println("playing treatment " + treatment + " to " + conferenceId);
    }
    synchronized (conferenceList) {
        ConferenceManager conferenceManager;
        conferenceManager = findConferenceManager(conferenceId);
        try {
            conferenceManager.addTreatment(treatment);
        } catch (IOException e) {
            throw new ParseException("bad treatment " + " " + e.getMessage(), 0);
        }
        return;
    }
}
Also used : IOException(java.io.IOException) ParseException(java.text.ParseException)

Example 42 with ParseException

use of java.text.ParseException in project Openfire by igniterealtime.

the class ConferenceMember method addCall.

public void addCall(String whisperGroupId) throws ParseException {
    synchronized (conferenceManager) {
        synchronized (whisperGroups) {
            WhisperGroup whisperGroup = wgManager.findWhisperGroup(whisperGroupId);
            if (whisperGroup == null) {
                Logger.println("Call " + cp + " Whisper group " + whisperGroupId + " doesn't exist.  " + "Automatically creating it with attenuation 0 " + "and locked");
                try {
                    whisperGroup = conferenceManager.createWhisperGroup(whisperGroupId, 0.0D);
                    whisperGroup.setTransient(true);
                    whisperGroup.setLocked(true);
                } catch (ParseException e) {
                    Logger.println("Can't create whisper group " + whisperGroupId + " " + e.getMessage());
                    throw new ParseException("Can't create whisper group " + whisperGroupId + " " + e.getMessage(), 0);
                }
            }
            addCall(whisperGroup);
        }
    }
}
Also used : ParseException(java.text.ParseException)

Example 43 with ParseException

use of java.text.ParseException in project Openfire by igniterealtime.

the class NSOutgoingCallAgent method initiateCall.

public void initiateCall() throws IOException {
    InetSocketAddress isa = callHandler.getReceiveAddress();
    if (isa == null) {
        throw new IOException("can't get receiver socket!");
    }
    setState(CallState.INVITED);
    TreatmentManager treatmentManager = null;
    if (cp.getInputTreatment() != null) {
        if (cp.getInputTreatment().length() > 0) {
            try {
                /*
				 * Just make sure we can open the file
				 */
                treatmentManager = new TreatmentManager(cp.getInputTreatment(), RtpPacket.PCM_ENCODING, mixerMediaPreference.getSampleRate(), mixerMediaPreference.getChannels());
                treatmentManager.stopTreatment(false);
            } catch (IOException e) {
                Logger.println("Invalid input treatment:  " + cp.getInputTreatment());
                throw new IOException("Invalid input treatment:  " + cp.getInputTreatment());
            }
        }
        /*
			 * This is a special call which is used to play
			 * an input treatment as its input.
			 * There is no remote endpoint.
			 */
        try {
            setRemoteMediaInfo(treatmentManager);
        } catch (ParseException e) {
            throw new IOException(e.getMessage());
        }
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) TreatmentManager(com.sun.voip.TreatmentManager) IOException(java.io.IOException) ParseException(java.text.ParseException)

Example 44 with ParseException

use of java.text.ParseException 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 45 with ParseException

use of java.text.ParseException in project Openfire by igniterealtime.

the class SipUtil method getUserNameFromSdp.

public static String getUserNameFromSdp(Request request) {
    byte[] rawContent = request.getRawContent();
    if (rawContent == null) {
        return null;
    }
    String sdpBody = new String(rawContent);
    SdpInfo sdpInfo;
    try {
        sdpInfo = SdpManager.parseSdp(sdpBody);
    } catch (ParseException e) {
        return null;
    }
    return sdpInfo.getUserName();
}
Also used : SdpInfo(com.sun.voip.SdpInfo) ParseException(java.text.ParseException)

Aggregations

ParseException (java.text.ParseException)3530 Date (java.util.Date)1381 SimpleDateFormat (java.text.SimpleDateFormat)1296 IOException (java.io.IOException)366 ArrayList (java.util.ArrayList)334 DateFormat (java.text.DateFormat)305 Calendar (java.util.Calendar)288 Test (org.junit.Test)274 HashMap (java.util.HashMap)139 Matcher (java.util.regex.Matcher)99 File (java.io.File)97 GregorianCalendar (java.util.GregorianCalendar)97 Map (java.util.Map)95 List (java.util.List)92 BigDecimal (java.math.BigDecimal)72 Locale (java.util.Locale)68 ParsePosition (java.text.ParsePosition)57 Timestamp (java.sql.Timestamp)55 InputStream (java.io.InputStream)53 DecimalFormat (java.text.DecimalFormat)50