mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: webhook and CDR filterEventDispatched event
parent
9336773cbc
commit
c8feebaf57
|
@ -0,0 +1,43 @@
|
||||||
|
package io.openvidu.server.cdr;
|
||||||
|
|
||||||
|
import org.kurento.client.GenericMediaEvent;
|
||||||
|
import org.kurento.jsonrpc.Props;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
public class CDREventFilterEvent extends CDREvent {
|
||||||
|
|
||||||
|
private GenericMediaEvent event;
|
||||||
|
private String participantId;
|
||||||
|
private String streamId;
|
||||||
|
private String filterType;
|
||||||
|
|
||||||
|
public CDREventFilterEvent(String sessionId, String participantId, String streamId, String filterType,
|
||||||
|
GenericMediaEvent event) {
|
||||||
|
super(CDREventName.filterEventDispatched, sessionId, Long.parseLong(event.getTimestampMillis()));
|
||||||
|
this.event = event;
|
||||||
|
this.participantId = participantId;
|
||||||
|
this.streamId = streamId;
|
||||||
|
this.filterType = filterType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEventType() {
|
||||||
|
return this.event.getType();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Props getEventData() {
|
||||||
|
return this.event.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsonObject toJson() {
|
||||||
|
JsonObject json = super.toJson();
|
||||||
|
json.addProperty("participantId", this.participantId);
|
||||||
|
json.addProperty("streamId", this.streamId);
|
||||||
|
json.addProperty("filterType", this.filterType);
|
||||||
|
json.addProperty("eventType", this.event.getType());
|
||||||
|
json.addProperty("data", this.event.getData().toString());
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -19,6 +19,6 @@ package io.openvidu.server.cdr;
|
||||||
|
|
||||||
public enum CDREventName {
|
public enum CDREventName {
|
||||||
|
|
||||||
sessionCreated, sessionDestroyed, participantJoined, participantLeft, webrtcConnectionCreated, webrtcConnectionDestroyed, recordingStarted, recordingStopped, recordingStatusChanged
|
sessionCreated, sessionDestroyed, participantJoined, participantLeft, webrtcConnectionCreated, webrtcConnectionDestroyed, recordingStarted, recordingStopped, recordingStatusChanged, filterEventDispatched
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentSkipListSet;
|
import java.util.concurrent.ConcurrentSkipListSet;
|
||||||
|
|
||||||
|
import org.kurento.client.GenericMediaEvent;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import io.openvidu.java.client.Recording.Status;
|
import io.openvidu.java.client.Recording.Status;
|
||||||
|
@ -52,6 +53,7 @@ import io.openvidu.server.webhook.CDRLoggerWebhook;
|
||||||
* - 'recordingStarted' {sessionId, timestamp, id, name, hasAudio, hasVideo, resolution, recordingLayout, size}
|
* - 'recordingStarted' {sessionId, timestamp, id, name, hasAudio, hasVideo, resolution, recordingLayout, size}
|
||||||
* - 'recordingStopped' {sessionId, timestamp, id, name, hasAudio, hasVideo, resolution, recordingLayout, size}
|
* - 'recordingStopped' {sessionId, timestamp, id, name, hasAudio, hasVideo, resolution, recordingLayout, size}
|
||||||
* - 'recordingStatusChanged' {sessionId, timestamp, id, name, hasAudio, hasVideo, resolution, recordingLayout, size, status}
|
* - 'recordingStatusChanged' {sessionId, timestamp, id, name, hasAudio, hasVideo, resolution, recordingLayout, size, status}
|
||||||
|
* - 'filterEventDispatched' {sessionId, timestamp, participantId, streamId, filterType, eventType, data}
|
||||||
*
|
*
|
||||||
* PROPERTIES VALUES:
|
* PROPERTIES VALUES:
|
||||||
*
|
*
|
||||||
|
@ -219,6 +221,11 @@ public class CallDetailRecord {
|
||||||
this.log(new CDREventRecordingStatus(recording, recording.getCreatedAt(), finalReason, timestamp, status));
|
this.log(new CDREventRecordingStatus(recording, recording.getCreatedAt(), finalReason, timestamp, status));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void recordFilterEventDispatched(String sessionId, String participantId, String streamId, String filterType,
|
||||||
|
GenericMediaEvent event) {
|
||||||
|
this.log(new CDREventFilterEvent(sessionId, participantId, streamId, filterType, event));
|
||||||
|
}
|
||||||
|
|
||||||
private void log(CDREvent event) {
|
private void log(CDREvent event) {
|
||||||
this.loggers.forEach(logger -> {
|
this.loggers.forEach(logger -> {
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.kurento.client.GenericMediaEvent;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -540,14 +541,18 @@ public class SessionEventsHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onFilterEventDispatched(String connectionId, String streamId, String filterType, String eventType,
|
public void onFilterEventDispatched(String sessionId, String connectionId, String streamId, String filterType,
|
||||||
Object data, Set<Participant> participants, Set<String> subscribedParticipants) {
|
GenericMediaEvent event, Set<Participant> participants, Set<String> subscribedParticipants) {
|
||||||
|
|
||||||
|
CDR.recordFilterEventDispatched(sessionId, connectionId, streamId, filterType, event);
|
||||||
|
|
||||||
JsonObject params = new JsonObject();
|
JsonObject params = new JsonObject();
|
||||||
params.addProperty(ProtocolElements.FILTEREVENTLISTENER_CONNECTIONID_PARAM, connectionId);
|
params.addProperty(ProtocolElements.FILTEREVENTLISTENER_CONNECTIONID_PARAM, connectionId);
|
||||||
params.addProperty(ProtocolElements.FILTEREVENTLISTENER_STREAMID_PARAM, streamId);
|
params.addProperty(ProtocolElements.FILTEREVENTLISTENER_STREAMID_PARAM, streamId);
|
||||||
params.addProperty(ProtocolElements.FILTEREVENTLISTENER_FILTERTYPE_PARAM, filterType);
|
params.addProperty(ProtocolElements.FILTEREVENTLISTENER_FILTERTYPE_PARAM, filterType);
|
||||||
params.addProperty(ProtocolElements.FILTEREVENTLISTENER_EVENTTYPE_PARAM, eventType);
|
params.addProperty(ProtocolElements.FILTEREVENTLISTENER_EVENTTYPE_PARAM, event.getType());
|
||||||
params.addProperty(ProtocolElements.FILTEREVENTLISTENER_DATA_PARAM, data.toString());
|
params.addProperty(ProtocolElements.FILTEREVENTLISTENER_DATA_PARAM, event.getData().toString());
|
||||||
|
|
||||||
for (Participant p : participants) {
|
for (Participant p : participants) {
|
||||||
if (subscribedParticipants.contains(p.getParticipantPublicId())) {
|
if (subscribedParticipants.contains(p.getParticipantPublicId())) {
|
||||||
rpcNotificationService.sendNotification(p.getParticipantPrivateId(),
|
rpcNotificationService.sendNotification(p.getParticipantPrivateId(),
|
||||||
|
|
|
@ -34,8 +34,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
import com.google.gson.JsonSyntaxException;
|
|
||||||
|
|
||||||
import io.openvidu.client.OpenViduException;
|
import io.openvidu.client.OpenViduException;
|
||||||
import io.openvidu.client.OpenViduException.Code;
|
import io.openvidu.client.OpenViduException.Code;
|
||||||
|
@ -882,13 +880,14 @@ public class KurentoSessionManager extends SessionManager {
|
||||||
throws OpenViduException {
|
throws OpenViduException {
|
||||||
PublisherEndpoint pub = kParticipant.getPublisher();
|
PublisherEndpoint pub = kParticipant.getPublisher();
|
||||||
if (!pub.isListenerAddedToFilterEvent(eventType)) {
|
if (!pub.isListenerAddedToFilterEvent(eventType)) {
|
||||||
|
final String sessionId = kParticipant.getSessionId();
|
||||||
final String connectionId = kParticipant.getParticipantPublicId();
|
final String connectionId = kParticipant.getParticipantPublicId();
|
||||||
final String streamId = kParticipant.getPublisherStreamId();
|
final String streamId = kParticipant.getPublisherStreamId();
|
||||||
final String filterType = kParticipant.getPublisherMediaOptions().getFilter().getType();
|
final String filterType = kParticipant.getPublisherMediaOptions().getFilter().getType();
|
||||||
try {
|
try {
|
||||||
ListenerSubscription listener = pub.getFilter().addEventListener(eventType, event -> {
|
ListenerSubscription listener = pub.getFilter().addEventListener(eventType, event -> {
|
||||||
sessionEventsHandler.onFilterEventDispatched(connectionId, streamId, filterType, event.getType(),
|
sessionEventsHandler.onFilterEventDispatched(sessionId, connectionId, streamId, filterType, event,
|
||||||
event.getData(), kParticipant.getSession().getParticipants(),
|
kParticipant.getSession().getParticipants(),
|
||||||
kParticipant.getPublisher().getPartipantsListentingToFilterEvent(eventType));
|
kParticipant.getPublisher().getPartipantsListentingToFilterEvent(eventType));
|
||||||
});
|
});
|
||||||
pub.storeListener(eventType, listener);
|
pub.storeListener(eventType, listener);
|
||||||
|
|
|
@ -20,7 +20,7 @@ openvidu.cdr.path=log
|
||||||
openvidu.webhook=false
|
openvidu.webhook=false
|
||||||
openvidu.webhook.endpoint=
|
openvidu.webhook.endpoint=
|
||||||
openvidu.webhook.headers=[]
|
openvidu.webhook.headers=[]
|
||||||
openvidu.webhook.events=["sessionCreated","sessionDestroyed","participantJoined","participantLeft","webrtcConnectionCreated","webrtcConnectionDestroyed","recordingStatusChanged"]
|
openvidu.webhook.events=["sessionCreated","sessionDestroyed","participantJoined","participantLeft","webrtcConnectionCreated","webrtcConnectionDestroyed","recordingStatusChanged","filterEventDispatched"]
|
||||||
|
|
||||||
openvidu.recording=false
|
openvidu.recording=false
|
||||||
openvidu.recording.version=2.9.0
|
openvidu.recording.version=2.9.0
|
||||||
|
|
Loading…
Reference in New Issue