Search in sources :

Example 1 with VoiceUserJoinedEvent

use of org.bigbluebutton.freeswitch.voice.events.VoiceUserJoinedEvent in project bigbluebutton by bigbluebutton.

the class FreeswitchConferenceEventListener method sendMessageToBigBlueButton.

private void sendMessageToBigBlueButton(final VoiceConferenceEvent event) {
    Runnable task = new Runnable() {

        public void run() {
            if (event instanceof VoiceUserJoinedEvent) {
                System.out.println("************** FreeswitchConferenceEventListener received voiceUserJoined ");
                VoiceUserJoinedEvent evt = (VoiceUserJoinedEvent) event;
                vcs.userJoinedVoiceConf(evt.getRoom(), evt.getVoiceUserId(), evt.getUserId(), evt.getCallerIdName(), evt.getCallerIdNum(), evt.getMuted(), evt.getSpeaking(), evt.getAvatarURL());
            } else if (event instanceof VoiceUserLeftEvent) {
                System.out.println("************** FreeswitchConferenceEventListener received VoiceUserLeftEvent ");
                VoiceUserLeftEvent evt = (VoiceUserLeftEvent) event;
                vcs.userLeftVoiceConf(evt.getRoom(), evt.getUserId());
            } else if (event instanceof VoiceUserMutedEvent) {
                System.out.println("************** FreeswitchConferenceEventListener VoiceUserMutedEvent ");
                VoiceUserMutedEvent evt = (VoiceUserMutedEvent) event;
                vcs.userMutedInVoiceConf(evt.getRoom(), evt.getUserId(), evt.isMuted());
            } else if (event instanceof VoiceUserTalkingEvent) {
                System.out.println("************** FreeswitchConferenceEventListener VoiceUserTalkingEvent ");
                VoiceUserTalkingEvent evt = (VoiceUserTalkingEvent) event;
                vcs.userTalkingInVoiceConf(evt.getRoom(), evt.getUserId(), evt.isTalking());
            } else if (event instanceof VoiceStartRecordingEvent) {
                VoiceStartRecordingEvent evt = (VoiceStartRecordingEvent) event;
                System.out.println("************** FreeswitchConferenceEventListener VoiceStartRecordingEvent recording=[" + evt.startRecord() + "]");
                vcs.voiceConfRecordingStarted(evt.getRoom(), evt.getRecordingFilename(), evt.startRecord(), evt.getTimestamp());
            } else if (event instanceof DeskShareStartedEvent) {
                DeskShareStartedEvent evt = (DeskShareStartedEvent) event;
                System.out.println("************** FreeswitchConferenceEventListener DeskShareStartedEvent");
                vcs.deskShareStarted(evt.getRoom(), evt.getCallerIdNum(), evt.getCallerIdName());
            } else if (event instanceof DeskShareEndedEvent) {
                DeskShareEndedEvent evt = (DeskShareEndedEvent) event;
                System.out.println("************** FreeswitchConferenceEventListener DeskShareEndedEvent");
                vcs.deskShareEnded(evt.getRoom(), evt.getCallerIdNum(), evt.getCallerIdName());
            } else if (event instanceof DeskShareRTMPBroadcastEvent) {
                if (((DeskShareRTMPBroadcastEvent) event).getBroadcast()) {
                    DeskShareRTMPBroadcastEvent evt = (DeskShareRTMPBroadcastEvent) event;
                    System.out.println("************** FreeswitchConferenceEventListener DeskShareRTMPBroadcastStartedEvent");
                    vcs.deskShareRTMPBroadcastStarted(evt.getRoom(), evt.getBroadcastingStreamUrl(), evt.getVideoWidth(), evt.getVideoHeight(), evt.getTimestamp());
                } else {
                    DeskShareRTMPBroadcastEvent evt = (DeskShareRTMPBroadcastEvent) event;
                    System.out.println("************** FreeswitchConferenceEventListener DeskShareRTMPBroadcastStoppedEvent");
                    vcs.deskShareRTMPBroadcastStopped(evt.getRoom(), evt.getBroadcastingStreamUrl(), evt.getVideoWidth(), evt.getVideoHeight(), evt.getTimestamp());
                }
            }
        }
    };
    runExec.execute(task);
}
Also used : VoiceUserTalkingEvent(org.bigbluebutton.freeswitch.voice.events.VoiceUserTalkingEvent) DeskShareEndedEvent(org.bigbluebutton.freeswitch.voice.events.DeskShareEndedEvent) DeskShareRTMPBroadcastEvent(org.bigbluebutton.freeswitch.voice.events.DeskShareRTMPBroadcastEvent) VoiceStartRecordingEvent(org.bigbluebutton.freeswitch.voice.events.VoiceStartRecordingEvent) DeskShareStartedEvent(org.bigbluebutton.freeswitch.voice.events.DeskShareStartedEvent) VoiceUserLeftEvent(org.bigbluebutton.freeswitch.voice.events.VoiceUserLeftEvent) VoiceUserMutedEvent(org.bigbluebutton.freeswitch.voice.events.VoiceUserMutedEvent) VoiceUserJoinedEvent(org.bigbluebutton.freeswitch.voice.events.VoiceUserJoinedEvent)

Example 2 with VoiceUserJoinedEvent

use of org.bigbluebutton.freeswitch.voice.events.VoiceUserJoinedEvent in project bigbluebutton by bigbluebutton.

the class ESLEventListener method conferenceEventJoin.

@Override
public void conferenceEventJoin(String uniqueId, String confName, int confSize, EslEvent event) {
    Integer memberId = this.getMemberIdFromEvent(event);
    Map<String, String> headers = event.getEventHeaders();
    String callerId = this.getCallerIdFromEvent(event);
    String callerIdName = this.getCallerIdNameFromEvent(event);
    //Was inverted which was causing a State issue
    boolean muted = headers.get("Speak").equals("true") ? false : true;
    boolean speaking = headers.get("Talking").equals("true") ? true : false;
    String voiceUserId = callerIdName;
    Matcher gapMatcher = GLOBAL_AUDION_PATTERN.matcher(callerIdName);
    if (gapMatcher.matches()) {
        System.out.println("Ignoring GLOBAL AUDIO USER [" + callerIdName + "]");
        return;
    }
    // Voice conferences' name is of the form ddddd
    if (confName.endsWith(DESKSHARE_CONFERENCE_NAME_SUFFIX)) {
        System.out.println("User joined deskshare conference, user=[" + callerIdName + "], " + "conf=[" + confName + "] callerId=[" + callerId + "]");
        DeskShareStartedEvent dsStart = new DeskShareStartedEvent(confName, callerId, callerIdName);
        conferenceEventListener.handleConferenceEvent(dsStart);
    } else {
        Matcher matcher = CALLERNAME_PATTERN.matcher(callerIdName);
        if (matcher.matches()) {
            voiceUserId = matcher.group(1).trim();
            callerIdName = matcher.group(2).trim();
        }
        System.out.println("User joined voice conference, user=[" + callerIdName + "], conf=[" + confName + "] callerId=[" + callerId + "]");
        VoiceUserJoinedEvent pj = new VoiceUserJoinedEvent(voiceUserId, memberId.toString(), confName, callerId, callerIdName, muted, speaking, "none");
        conferenceEventListener.handleConferenceEvent(pj);
    }
}
Also used : Matcher(java.util.regex.Matcher) DeskShareStartedEvent(org.bigbluebutton.freeswitch.voice.events.DeskShareStartedEvent) VoiceUserJoinedEvent(org.bigbluebutton.freeswitch.voice.events.VoiceUserJoinedEvent)

Example 3 with VoiceUserJoinedEvent

use of org.bigbluebutton.freeswitch.voice.events.VoiceUserJoinedEvent in project bigbluebutton by bigbluebutton.

the class GetAllUsersCommand method handleResponse.

public void handleResponse(EslMessage response, ConferenceEventListener eventListener) {
    //Test for Known Conference
    String firstLine = response.getBodyLines().get(0);
    if (!firstLine.startsWith("<?xml")) {
        //            System.out.println("Not XML: [{}]", firstLine);
        return;
    }
    XMLResponseConferenceListParser confXML = new XMLResponseConferenceListParser();
    //get a factory
    SAXParserFactory spf = SAXParserFactory.newInstance();
    try {
        //get a new instance of parser
        SAXParser sp = spf.newSAXParser();
        //Hack turning body lines back into string then to ByteStream.... BLAH!
        String responseBody = StringUtils.join(response.getBodyLines(), "\n");
        //http://mark.koli.ch/2009/02/resolving-orgxmlsaxsaxparseexception-content-is-not-allowed-in-prolog.html
        //This Sux!
        responseBody = responseBody.trim().replaceFirst("^([\\W]+)<", "<");
        ByteArrayInputStream bs = new ByteArrayInputStream(responseBody.getBytes());
        sp.parse(bs, confXML);
        //Maybe move this to XMLResponseConferenceListParser, sendConfrenceEvents ?
        VoiceUserJoinedEvent pj;
        for (ConferenceMember member : confXML.getConferenceList()) {
            //Foreach found member in conference create a JoinedEvent
            String callerId = member.getCallerId();
            String callerIdName = member.getCallerIdName();
            String voiceUserId = callerIdName;
            Matcher matcher = CALLERNAME_PATTERN.matcher(callerIdName);
            if (matcher.matches()) {
                voiceUserId = matcher.group(1).trim();
                callerIdName = matcher.group(2).trim();
            }
            pj = new VoiceUserJoinedEvent(voiceUserId, member.getId().toString(), confXML.getConferenceRoom(), callerId, callerIdName, member.getMuted(), member.getSpeaking(), null);
            eventListener.handleConferenceEvent(pj);
        }
    } catch (SAXException se) {
    //            System.out.println("Cannot parse repsonce. ", se);
    } catch (ParserConfigurationException pce) {
    //            System.out.println("ParserConfigurationException. ", pce);
    } catch (IOException ie) {
    //        	System.out.println("Cannot parse repsonce. IO Exception. ", ie);
    }
}
Also used : XMLResponseConferenceListParser(org.bigbluebutton.freeswitch.voice.freeswitch.response.XMLResponseConferenceListParser) ByteArrayInputStream(java.io.ByteArrayInputStream) Matcher(java.util.regex.Matcher) ConferenceMember(org.bigbluebutton.freeswitch.voice.freeswitch.response.ConferenceMember) SAXParser(javax.xml.parsers.SAXParser) VoiceUserJoinedEvent(org.bigbluebutton.freeswitch.voice.events.VoiceUserJoinedEvent) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) SAXParserFactory(javax.xml.parsers.SAXParserFactory) SAXException(org.xml.sax.SAXException)

Aggregations

VoiceUserJoinedEvent (org.bigbluebutton.freeswitch.voice.events.VoiceUserJoinedEvent)3 Matcher (java.util.regex.Matcher)2 DeskShareStartedEvent (org.bigbluebutton.freeswitch.voice.events.DeskShareStartedEvent)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 SAXParser (javax.xml.parsers.SAXParser)1 SAXParserFactory (javax.xml.parsers.SAXParserFactory)1 DeskShareEndedEvent (org.bigbluebutton.freeswitch.voice.events.DeskShareEndedEvent)1 DeskShareRTMPBroadcastEvent (org.bigbluebutton.freeswitch.voice.events.DeskShareRTMPBroadcastEvent)1 VoiceStartRecordingEvent (org.bigbluebutton.freeswitch.voice.events.VoiceStartRecordingEvent)1 VoiceUserLeftEvent (org.bigbluebutton.freeswitch.voice.events.VoiceUserLeftEvent)1 VoiceUserMutedEvent (org.bigbluebutton.freeswitch.voice.events.VoiceUserMutedEvent)1 VoiceUserTalkingEvent (org.bigbluebutton.freeswitch.voice.events.VoiceUserTalkingEvent)1 ConferenceMember (org.bigbluebutton.freeswitch.voice.freeswitch.response.ConferenceMember)1 XMLResponseConferenceListParser (org.bigbluebutton.freeswitch.voice.freeswitch.response.XMLResponseConferenceListParser)1 SAXException (org.xml.sax.SAXException)1