-
Notifications
You must be signed in to change notification settings - Fork 5.9k
/
VoiceEventRecorder.java
executable file
·140 lines (116 loc) · 5.59 KB
/
VoiceEventRecorder.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
*/
package org.bigbluebutton.core.service.recorder.voice;
import java.util.concurrent.TimeUnit;
import org.bigbluebutton.core.service.recorder.RecorderApplication;
import org.bigbluebutton.freeswitch.voice.events.VoiceConferenceEvent;
import org.bigbluebutton.freeswitch.voice.events.VoiceStartRecordingEvent;
import org.bigbluebutton.freeswitch.voice.events.VoiceUserJoinedEvent;
import org.bigbluebutton.freeswitch.voice.events.VoiceUserLeftEvent;
import org.bigbluebutton.freeswitch.voice.events.VoiceUserLockedEvent;
import org.bigbluebutton.freeswitch.voice.events.VoiceUserMutedEvent;
import org.bigbluebutton.freeswitch.voice.events.VoiceUserTalkingEvent;
public class VoiceEventRecorder {
private RecorderApplication recorder;
private Long genTimestamp() {
return TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
}
public void recordConferenceEvent(VoiceConferenceEvent event, String room) {
if (event instanceof VoiceUserJoinedEvent) {
recordParticipantJoinedEvent(event, room);
} else if (event instanceof VoiceUserLeftEvent) {
recordParticipantLeftEvent(event, room);
} else if (event instanceof VoiceUserMutedEvent) {
recordParticipantMutedEvent(event, room);
} else if (event instanceof VoiceUserTalkingEvent) {
recordParticipantTalkingEvent(event, room);
} else if (event instanceof VoiceUserLockedEvent) {
recordParticipantLockedEvent(event, room);
} else if (event instanceof VoiceStartRecordingEvent) {
recordStartRecordingEvent(event, room);
} else {
System.out.println("Processing UnknownEvent " + event.getClass().getName() + " for room: " + event.getRoom() );
}
}
private void recordStartRecordingEvent(VoiceConferenceEvent event, String room) {
VoiceStartRecordingEvent sre = (VoiceStartRecordingEvent) event;
StartRecordingVoiceRecordEvent evt = new StartRecordingVoiceRecordEvent(sre.startRecord());
evt.setMeetingId(room);
evt.setTimestamp(genTimestamp());
evt.setBridge(event.getRoom());
evt.setRecordingTimestamp(sre.getTimestamp());
evt.setFilename(sre.getRecordingFilename());
System.out.println("*** Recording voice " + sre.startRecord() + " timestamp: " + evt.toMap().get("recordingTimestamp") + " file: " + evt.toMap().get("filename"));
recorder.record(room, evt);
}
private void recordParticipantJoinedEvent(VoiceConferenceEvent event, String room) {
VoiceUserJoinedEvent pje = (VoiceUserJoinedEvent) event;
ParticipantJoinedVoiceRecordEvent evt = new ParticipantJoinedVoiceRecordEvent();
evt.setMeetingId(room);
evt.setTimestamp(genTimestamp());
evt.setBridge(event.getRoom());
evt.setParticipant(pje.getUserId().toString());
evt.setCallerName(pje.getCallerIdName());
evt.setCallerNumber(pje.getCallerIdName());
evt.setMuted(pje.getMuted());
evt.setTalking(pje.getSpeaking());
recorder.record(room, evt);
}
private void recordParticipantLeftEvent(VoiceConferenceEvent event, String room) {
ParticipantLeftVoiceRecordEvent evt = new ParticipantLeftVoiceRecordEvent();
evt.setMeetingId(room);
evt.setTimestamp(genTimestamp());
evt.setBridge(event.getRoom());
evt.setParticipant(((VoiceUserLeftEvent)event).getUserId().toString());
recorder.record(room, evt);
}
private void recordParticipantMutedEvent(VoiceConferenceEvent event, String room) {
VoiceUserMutedEvent pme = (VoiceUserMutedEvent) event;
ParticipantMutedVoiceRecordEvent evt = new ParticipantMutedVoiceRecordEvent();
evt.setMeetingId(room);
evt.setTimestamp(genTimestamp());
evt.setBridge(event.getRoom());
evt.setParticipant(((VoiceUserMutedEvent)event).getUserId().toString());
evt.setMuted(pme.isMuted());
recorder.record(room, evt);
}
private void recordParticipantTalkingEvent(VoiceConferenceEvent event, String room) {
VoiceUserTalkingEvent pte = (VoiceUserTalkingEvent) event;
ParticipantTalkingVoiceRecordEvent evt = new ParticipantTalkingVoiceRecordEvent();
evt.setMeetingId(room);
evt.setTimestamp(genTimestamp());
evt.setBridge(event.getRoom());
evt.setParticipant(((VoiceUserTalkingEvent)event).getUserId().toString());
evt.setTalking(pte.isTalking());
recorder.record(room, evt);
}
private void recordParticipantLockedEvent(VoiceConferenceEvent event, String room) {
VoiceUserLockedEvent ple = (VoiceUserLockedEvent) event;
ParticipantLockedVoiceRecordEvent evt = new ParticipantLockedVoiceRecordEvent();
evt.setMeetingId(room);
evt.setTimestamp(genTimestamp());
evt.setBridge(event.getRoom());
evt.setParticipant(((VoiceUserLockedEvent)event).getUserId().toString());
evt.setLocked(ple.isLocked());
recorder.record(room, evt);
}
public void setRecorderApplication(RecorderApplication recorder) {
this.recorder = recorder;
}
}