mirror of https://github.com/OpenVidu/openvidu.git
Connections can be created to send only audio, only video or both
parent
cc135f4d8b
commit
93d21bfc42
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -57,16 +57,20 @@ export class OpenVidu {
|
||||||
if (this.checkSystemRequirements()) {
|
if (this.checkSystemRequirements()) {
|
||||||
if (cameraOptions != null) {
|
if (cameraOptions != null) {
|
||||||
let cameraOptionsAux = {
|
let cameraOptionsAux = {
|
||||||
audio: cameraOptions.audio != null ? cameraOptions.audio : true,
|
sendAudio: cameraOptions.audio != null ? cameraOptions.audio : true,
|
||||||
video: cameraOptions.video != null ? cameraOptions.video : true,
|
sendVideo: cameraOptions.video != null ? cameraOptions.video : true,
|
||||||
|
activeAudio: cameraOptions.activeAudio != null ? cameraOptions.activeAudio : true,
|
||||||
|
activeVideo: cameraOptions.activeVideo != null ? cameraOptions.activeVideo : true,
|
||||||
data: true,
|
data: true,
|
||||||
mediaConstraints: this.openVidu.generateMediaConstraints(cameraOptions.quality)
|
mediaConstraints: this.openVidu.generateMediaConstraints(cameraOptions)
|
||||||
};
|
};
|
||||||
cameraOptions = cameraOptionsAux;
|
cameraOptions = cameraOptionsAux;
|
||||||
} else {
|
} else {
|
||||||
cameraOptions = {
|
cameraOptions = {
|
||||||
audio: true,
|
sendAudio: true,
|
||||||
video: true,
|
sendVideo: true,
|
||||||
|
activeAudio: true,
|
||||||
|
activeVideo: true,
|
||||||
data: true,
|
data: true,
|
||||||
mediaConstraints: {
|
mediaConstraints: {
|
||||||
audio: true,
|
audio: true,
|
||||||
|
|
|
@ -8,7 +8,8 @@ export interface ConnectionOptions {
|
||||||
id: string;
|
id: string;
|
||||||
metadata: string;
|
metadata: string;
|
||||||
streams?: StreamOptions[];
|
streams?: StreamOptions[];
|
||||||
audioOnly: boolean;
|
audioActive: boolean;
|
||||||
|
videoActive: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Connection {
|
export class Connection {
|
||||||
|
@ -74,13 +75,14 @@ export class Connection {
|
||||||
let streamOpts = {
|
let streamOpts = {
|
||||||
id: streamOptions.id,
|
id: streamOptions.id,
|
||||||
connection: this,
|
connection: this,
|
||||||
recvVideo: ( streamOptions.recvVideo == undefined ? true : streamOptions.recvVideo ),
|
sendAudio: streamOptions.sendAudio,
|
||||||
recvAudio: ( streamOptions.recvAudio == undefined ? true : streamOptions.recvAudio ),
|
sendVideo: streamOptions.sendVideo,
|
||||||
audio: streamOptions.audio,
|
recvAudio: ( streamOptions.audioActive == undefined ? true : streamOptions.audioActive ),
|
||||||
video: streamOptions.video,
|
recvVideo: ( streamOptions.videoActive == undefined ? true : streamOptions.videoActive ),
|
||||||
|
activeAudio: streamOptions.activeAudio,
|
||||||
|
activeVideo: streamOptions.activeVideo,
|
||||||
data: streamOptions.data,
|
data: streamOptions.data,
|
||||||
mediaConstraints: streamOptions.mediaConstraints,
|
mediaConstraints: streamOptions.mediaConstraints
|
||||||
audioOnly: streamOptions.audioOnly,
|
|
||||||
}
|
}
|
||||||
let stream = new Stream(this.openVidu, false, this.room, streamOpts );
|
let stream = new Stream(this.openVidu, false, this.room, streamOpts );
|
||||||
|
|
||||||
|
|
|
@ -297,33 +297,22 @@ export class OpenViduInternal {
|
||||||
}
|
}
|
||||||
|
|
||||||
options = options || {
|
options = options || {
|
||||||
audio: true,
|
sendAudio: true,
|
||||||
video: true,
|
sendVideo: true,
|
||||||
|
activeAudio: true,
|
||||||
|
activeVideo: true,
|
||||||
data: true,
|
data: true,
|
||||||
mediaConstraints: {
|
mediaConstraints: {
|
||||||
audio: true,
|
audio: true,
|
||||||
video: { width: { ideal: 1280 } }
|
video: { width: { ideal: 1280 } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
options.connection = this.session.getLocalParticipant();
|
options.connection = this.session.getLocalParticipant();
|
||||||
|
|
||||||
this.camera = new Stream(this, true, this.session, options);
|
this.camera = new Stream(this, true, this.session, options);
|
||||||
return this.camera;
|
return this.camera;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*joinSession(options: SessionOptions, callback: Callback<Session>) {
|
|
||||||
|
|
||||||
this.session.configure(options);
|
|
||||||
|
|
||||||
this.session.connect2();
|
|
||||||
|
|
||||||
this.session.addEventListener('room-connected', roomEvent => callback(undefined,this.session));
|
|
||||||
|
|
||||||
this.session.addEventListener('error-room', error => callback(error));
|
|
||||||
|
|
||||||
return this.session;
|
|
||||||
};*/
|
|
||||||
|
|
||||||
//CHAT
|
//CHAT
|
||||||
sendMessage(room, user, message) {
|
sendMessage(room, user, message) {
|
||||||
this.sendRequest('sendMessage', {
|
this.sendRequest('sendMessage', {
|
||||||
|
@ -362,13 +351,16 @@ export class OpenViduInternal {
|
||||||
this.toggleLocalAudioTrack(false);
|
this.toggleLocalAudioTrack(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
generateMediaConstraints(quality: string) {
|
generateMediaConstraints(cameraOptions: any) {
|
||||||
let mediaConstraints = {
|
let mediaConstraints = {
|
||||||
audio: true,
|
audio: cameraOptions.audio,
|
||||||
video: {}
|
video: {}
|
||||||
}
|
}
|
||||||
|
if (!cameraOptions.video) {
|
||||||
|
mediaConstraints.video = false
|
||||||
|
} else {
|
||||||
let w, h;
|
let w, h;
|
||||||
switch (quality) {
|
switch (cameraOptions.quality) {
|
||||||
case 'LOW':
|
case 'LOW':
|
||||||
w = 320;
|
w = 320;
|
||||||
h = 240;
|
h = 240;
|
||||||
|
@ -388,7 +380,7 @@ export class OpenViduInternal {
|
||||||
mediaConstraints.video['width'] = { exact: w };
|
mediaConstraints.video['width'] = { exact: w };
|
||||||
mediaConstraints.video['height'] = { exact: h };
|
mediaConstraints.video['height'] = { exact: h };
|
||||||
//mediaConstraints.video['frameRate'] = { ideal: Number((<HTMLInputElement>document.getElementById('frameRate')).value) };
|
//mediaConstraints.video['frameRate'] = { ideal: Number((<HTMLInputElement>document.getElementById('frameRate')).value) };
|
||||||
|
}
|
||||||
return mediaConstraints;
|
return mediaConstraints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,13 +34,14 @@ function hide(id: string) {
|
||||||
export interface StreamOptions {
|
export interface StreamOptions {
|
||||||
id: string;
|
id: string;
|
||||||
connection: Connection;
|
connection: Connection;
|
||||||
recvVideo: any;
|
recvVideo: boolean;
|
||||||
recvAudio: any;
|
recvAudio: boolean;
|
||||||
video: boolean;
|
sendVideo: boolean;
|
||||||
audio: boolean;
|
sendAudio: boolean;
|
||||||
|
activeAudio: boolean;
|
||||||
|
activeVideo: boolean;
|
||||||
data: boolean;
|
data: boolean;
|
||||||
mediaConstraints: any;
|
mediaConstraints: any;
|
||||||
audioOnly: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface VideoOptions {
|
export interface VideoOptions {
|
||||||
|
@ -60,8 +61,8 @@ export class Stream {
|
||||||
private videoElements: VideoOptions[] = [];
|
private videoElements: VideoOptions[] = [];
|
||||||
private elements: HTMLDivElement[] = [];
|
private elements: HTMLDivElement[] = [];
|
||||||
private speechEvent: any;
|
private speechEvent: any;
|
||||||
private recvVideo: any;
|
private recvVideo: boolean;
|
||||||
private recvAudio: any;
|
private recvAudio: boolean;
|
||||||
private sendVideo: boolean;
|
private sendVideo: boolean;
|
||||||
private sendAudio: boolean;
|
private sendAudio: boolean;
|
||||||
private mediaConstraints: any;
|
private mediaConstraints: any;
|
||||||
|
@ -71,7 +72,8 @@ export class Stream {
|
||||||
private dataChannel: boolean;
|
private dataChannel: boolean;
|
||||||
private dataChannelOpened = false;
|
private dataChannelOpened = false;
|
||||||
|
|
||||||
private audioOnly = false;
|
private activeAudio = true;
|
||||||
|
private activeVideo = true;
|
||||||
|
|
||||||
private videoSrcObject: MediaStream | null;
|
private videoSrcObject: MediaStream | null;
|
||||||
private parentId: string;
|
private parentId: string;
|
||||||
|
@ -89,13 +91,14 @@ export class Stream {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.connection = options.connection;
|
this.connection = options.connection;
|
||||||
this.recvVideo = options.recvVideo;
|
this.recvVideo = options.recvVideo || false;
|
||||||
this.recvAudio = options.recvAudio;
|
this.recvAudio = options.recvAudio || false;
|
||||||
|
this.sendVideo = options.sendVideo;
|
||||||
|
this.sendAudio = options.sendAudio;
|
||||||
|
this.activeAudio = options.activeAudio;
|
||||||
|
this.activeVideo = options.activeVideo;
|
||||||
this.dataChannel = options.data || false;
|
this.dataChannel = options.data || false;
|
||||||
this.sendVideo = options.video;
|
|
||||||
this.sendAudio = options.audio;
|
|
||||||
this.mediaConstraints = options.mediaConstraints;
|
this.mediaConstraints = options.mediaConstraints;
|
||||||
this.audioOnly = options.audioOnly || false;
|
|
||||||
|
|
||||||
this.addEventListener('src-added', (srcEvent) => {
|
this.addEventListener('src-added', (srcEvent) => {
|
||||||
this.videoSrcObject = srcEvent.srcObject;
|
this.videoSrcObject = srcEvent.srcObject;
|
||||||
|
@ -365,7 +368,6 @@ export class Stream {
|
||||||
if (!hasVideo) {
|
if (!hasVideo) {
|
||||||
constraints.video = false;
|
constraints.video = false;
|
||||||
this.sendVideo = false;
|
this.sendVideo = false;
|
||||||
this.audioOnly = true;
|
|
||||||
this.requestCameraAccesAux(constraints, callback);
|
this.requestCameraAccesAux(constraints, callback);
|
||||||
} else {
|
} else {
|
||||||
this.requestCameraAccesAux(constraints, callback);
|
this.requestCameraAccesAux(constraints, callback);
|
||||||
|
@ -379,15 +381,15 @@ export class Stream {
|
||||||
this.cameraAccessSuccess(userStream, callback);
|
this.cameraAccessSuccess(userStream, callback);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
// Try to ask for microphone only
|
/*// Try to ask for microphone only
|
||||||
navigator.mediaDevices.getUserMedia({ audio: true, video: false })
|
navigator.mediaDevices.getUserMedia({ audio: true, video: false })
|
||||||
.then(userStream => {
|
.then(userStream => {
|
||||||
constraints.video = false;
|
constraints.video = false;
|
||||||
this.sendVideo = false;
|
this.sendVideo = false;
|
||||||
this.audioOnly = true;
|
this.sendAudio = true;
|
||||||
this.cameraAccessSuccess(userStream, callback);
|
this.cameraAccessSuccess(userStream, callback);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {*/
|
||||||
this.accessIsDenied = true;
|
this.accessIsDenied = true;
|
||||||
this.accessIsAllowed = false;
|
this.accessIsAllowed = false;
|
||||||
this.ee.emitEvent('access-denied-by-publisher');
|
this.ee.emitEvent('access-denied-by-publisher');
|
||||||
|
@ -395,7 +397,6 @@ export class Stream {
|
||||||
console.error("Access denied", error);
|
console.error("Access denied", error);
|
||||||
callback(error, this);
|
callback(error, this);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private cameraAccessSuccess(userStream, callback) {
|
private cameraAccessSuccess(userStream, callback) {
|
||||||
|
@ -404,10 +405,10 @@ export class Stream {
|
||||||
this.ee.emitEvent('access-allowed-by-publisher');
|
this.ee.emitEvent('access-allowed-by-publisher');
|
||||||
|
|
||||||
if (userStream.getAudioTracks()[0] != null) {
|
if (userStream.getAudioTracks()[0] != null) {
|
||||||
userStream.getAudioTracks()[0].enabled = this.sendAudio;
|
userStream.getAudioTracks()[0].enabled = this.activeAudio;
|
||||||
}
|
}
|
||||||
if (userStream.getVideoTracks()[0] != null) {
|
if (userStream.getVideoTracks()[0] != null) {
|
||||||
userStream.getVideoTracks()[0].enabled = this.sendVideo;
|
userStream.getVideoTracks()[0].enabled = this.activeVideo;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.wrStream = userStream;
|
this.wrStream = userStream;
|
||||||
|
@ -438,7 +439,8 @@ export class Stream {
|
||||||
this.openVidu.sendRequest("publishVideo", {
|
this.openVidu.sendRequest("publishVideo", {
|
||||||
sdpOffer: sdpOfferParam,
|
sdpOffer: sdpOfferParam,
|
||||||
doLoopback: this.displayMyRemote() || false,
|
doLoopback: this.displayMyRemote() || false,
|
||||||
audioOnly: this.audioOnly
|
audioActive: this.sendAudio,
|
||||||
|
videoActive: this.sendVideo
|
||||||
}, (error, response) => {
|
}, (error, response) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error("Error on publishVideo: " + JSON.stringify(error));
|
console.error("Error on publishVideo: " + JSON.stringify(error));
|
||||||
|
@ -509,7 +511,7 @@ export class Stream {
|
||||||
} else {
|
} else {
|
||||||
let offerConstraints = {
|
let offerConstraints = {
|
||||||
audio: this.recvAudio,
|
audio: this.recvAudio,
|
||||||
video: !this.audioOnly
|
video: this.recvVideo
|
||||||
};
|
};
|
||||||
console.debug("'Session.subscribe(Stream)' called. Constraints of generate SDP offer",
|
console.debug("'Session.subscribe(Stream)' called. Constraints of generate SDP offer",
|
||||||
offerConstraints);
|
offerConstraints);
|
||||||
|
|
|
@ -43,13 +43,15 @@ public class ProtocolElements {
|
||||||
public static final String JOINROOM_PEERID_PARAM = "id";
|
public static final String JOINROOM_PEERID_PARAM = "id";
|
||||||
public static final String JOINROOM_PEERSTREAMS_PARAM = "streams";
|
public static final String JOINROOM_PEERSTREAMS_PARAM = "streams";
|
||||||
public static final String JOINROOM_PEERSTREAMID_PARAM = "id";
|
public static final String JOINROOM_PEERSTREAMID_PARAM = "id";
|
||||||
public static final String JOINROOM_PEERSTREAMAUDIOONLY_PARAM = "audioOnly";
|
public static final String JOINROOM_PEERSTREAMAUDIOACTIVE_PARAM = "audioActive";
|
||||||
|
public static final String JOINROOM_PEERSTREAMVIDEOACTIVE_PARAM = "videoActive";
|
||||||
|
|
||||||
public static final String PUBLISHVIDEO_METHOD = "publishVideo";
|
public static final String PUBLISHVIDEO_METHOD = "publishVideo";
|
||||||
public static final String PUBLISHVIDEO_SDPOFFER_PARAM = "sdpOffer";
|
public static final String PUBLISHVIDEO_SDPOFFER_PARAM = "sdpOffer";
|
||||||
public static final String PUBLISHVIDEO_DOLOOPBACK_PARAM = "doLoopback";
|
public static final String PUBLISHVIDEO_DOLOOPBACK_PARAM = "doLoopback";
|
||||||
public static final String PUBLISHVIDEO_SDPANSWER_PARAM = "sdpAnswer";
|
public static final String PUBLISHVIDEO_SDPANSWER_PARAM = "sdpAnswer";
|
||||||
public static final String PUBLISHVIDEO_AUDIOONLY_PARAM = "audioOnly";
|
public static final String PUBLISHVIDEO_AUDIOACTIVE_PARAM = "audioActive";
|
||||||
|
public static final String PUBLISHVIDEO_VIDEOACTIVE_PARAM = "videoActive";
|
||||||
|
|
||||||
public static final String UNPUBLISHVIDEO_METHOD = "unpublishVideo";
|
public static final String UNPUBLISHVIDEO_METHOD = "unpublishVideo";
|
||||||
|
|
||||||
|
@ -84,7 +86,8 @@ public class ProtocolElements {
|
||||||
public static final String PARTICIPANTPUBLISHED_USER_PARAM = "id";
|
public static final String PARTICIPANTPUBLISHED_USER_PARAM = "id";
|
||||||
public static final String PARTICIPANTPUBLISHED_STREAMS_PARAM = "streams";
|
public static final String PARTICIPANTPUBLISHED_STREAMS_PARAM = "streams";
|
||||||
public static final String PARTICIPANTPUBLISHED_STREAMID_PARAM = "id";
|
public static final String PARTICIPANTPUBLISHED_STREAMID_PARAM = "id";
|
||||||
public static final String PARTICIPANTPUBLISHED_AUDIOONLY_PARAM = "audioOnly";
|
public static final String PARTICIPANTPUBLISHED_AUDIOACTIVE_PARAM = "audioActive";
|
||||||
|
public static final String PARTICIPANTPUBLISHED_VIDEOACTIVE_PARAM = "videoActive";
|
||||||
|
|
||||||
public static final String PARTICIPANTUNPUBLISHED_METHOD = "participantUnpublished";
|
public static final String PARTICIPANTUNPUBLISHED_METHOD = "participantUnpublished";
|
||||||
public static final String PARTICIPANTUNPUBLISHED_NAME_PARAM = "name";
|
public static final String PARTICIPANTUNPUBLISHED_NAME_PARAM = "name";
|
||||||
|
|
|
@ -128,7 +128,7 @@ public class NotificationRoomManager {
|
||||||
* MediaElement...)
|
* MediaElement...)
|
||||||
*/
|
*/
|
||||||
public void publishMedia(ParticipantRequest request, boolean isOffer, String sdp,
|
public void publishMedia(ParticipantRequest request, boolean isOffer, String sdp,
|
||||||
MediaElement loopbackAlternativeSrc, MediaType loopbackConnectionType, boolean audioOnly, boolean doLoopback,
|
MediaElement loopbackAlternativeSrc, MediaType loopbackConnectionType, boolean audioActive, boolean videoActive, boolean doLoopback,
|
||||||
MediaElement... mediaElements) {
|
MediaElement... mediaElements) {
|
||||||
String pid = request.getParticipantId();
|
String pid = request.getParticipantId();
|
||||||
String userName = null;
|
String userName = null;
|
||||||
|
@ -139,14 +139,14 @@ public class NotificationRoomManager {
|
||||||
sdpAnswer = internalManager
|
sdpAnswer = internalManager
|
||||||
.publishMedia(request.getParticipantId(), isOffer, sdp, loopbackAlternativeSrc,
|
.publishMedia(request.getParticipantId(), isOffer, sdp, loopbackAlternativeSrc,
|
||||||
loopbackConnectionType, doLoopback, mediaElements);
|
loopbackConnectionType, doLoopback, mediaElements);
|
||||||
internalManager.updateParticipantAudioOnly(pid, audioOnly);
|
internalManager.updateParticipantStreamsActive(pid, audioActive, videoActive);
|
||||||
participants = internalManager.getParticipants(internalManager.getRoomName(pid));
|
participants = internalManager.getParticipants(internalManager.getRoomName(pid));
|
||||||
} catch (OpenViduException e) {
|
} catch (OpenViduException e) {
|
||||||
log.warn("PARTICIPANT {}: Error publishing media", userName, e);
|
log.warn("PARTICIPANT {}: Error publishing media", userName, e);
|
||||||
notificationRoomHandler.onPublishMedia(request, null, null, false, null, e);
|
notificationRoomHandler.onPublishMedia(request, null, null, true, true, null, e);
|
||||||
}
|
}
|
||||||
if (sdpAnswer != null) {
|
if (sdpAnswer != null) {
|
||||||
notificationRoomHandler.onPublishMedia(request, userName, sdpAnswer, audioOnly, participants, null);
|
notificationRoomHandler.onPublishMedia(request, userName, sdpAnswer, audioActive, videoActive, participants, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,9 +154,9 @@ public class NotificationRoomManager {
|
||||||
* @param request instance of {@link ParticipantRequest} POJO
|
* @param request instance of {@link ParticipantRequest} POJO
|
||||||
* @see RoomManager#publishMedia(String, String, boolean, MediaElement...)
|
* @see RoomManager#publishMedia(String, String, boolean, MediaElement...)
|
||||||
*/
|
*/
|
||||||
public void publishMedia(ParticipantRequest request, String sdpOffer, boolean audioOnly, boolean doLoopback,
|
public void publishMedia(ParticipantRequest request, String sdpOffer, boolean audioActive, boolean videoActive, boolean doLoopback,
|
||||||
MediaElement... mediaElements) {
|
MediaElement... mediaElements) {
|
||||||
this.publishMedia(request, true, sdpOffer, null, null, audioOnly, doLoopback, mediaElements);
|
this.publishMedia(request, true, sdpOffer, null, null, audioActive, videoActive, doLoopback, mediaElements);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -682,7 +682,7 @@ public class RoomManager {
|
||||||
Set<UserParticipant> userParts = new HashSet<UserParticipant>();
|
Set<UserParticipant> userParts = new HashSet<UserParticipant>();
|
||||||
for (Participant p : participants) {
|
for (Participant p : participants) {
|
||||||
if (!p.isClosed()) {
|
if (!p.isClosed()) {
|
||||||
userParts.add(new UserParticipant(p.getId(), p.getName(), p.getClientMetadata(), p.getServerMetadata(), p.isStreaming(), p.isAudioOnly()));
|
userParts.add(new UserParticipant(p.getId(), p.getName(), p.getClientMetadata(), p.getServerMetadata(), p.isStreaming(), p.isAudioActive(), p.isVideoActive()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return userParts;
|
return userParts;
|
||||||
|
@ -962,9 +962,10 @@ public class RoomManager {
|
||||||
"No participant with id '" + pid + "' was found");
|
"No participant with id '" + pid + "' was found");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateParticipantAudioOnly(String pid, boolean audioOnly) {
|
public void updateParticipantStreamsActive(String pid, boolean audioActive, boolean videoActive) {
|
||||||
Participant p = this.getParticipant(pid);
|
Participant p = this.getParticipant(pid);
|
||||||
p.setAudioOnly(audioOnly);
|
p.setAudioActive(audioActive);
|
||||||
|
p.setVideoActive(videoActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateFilter(String roomId, String filterId) {
|
public void updateFilter(String roomId, String filterId) {
|
||||||
|
|
|
@ -117,7 +117,7 @@ public interface NotificationRoomHandler extends RoomHandler {
|
||||||
* accordingly.
|
* accordingly.
|
||||||
*/
|
*/
|
||||||
void onPublishMedia(ParticipantRequest request, String publisherName, String sdpAnswer,
|
void onPublishMedia(ParticipantRequest request, String publisherName, String sdpAnswer,
|
||||||
boolean audioOnly, Set<UserParticipant> participants, OpenViduException error);
|
boolean audioActive, boolean videoActive, Set<UserParticipant> participants, OpenViduException error);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called as a result of {@link NotificationRoomManager#unpublishMedia(ParticipantRequest)}. The
|
* Called as a result of {@link NotificationRoomManager#unpublishMedia(ParticipantRequest)}. The
|
||||||
|
|
|
@ -30,7 +30,8 @@ public class UserParticipant {
|
||||||
private String serverMetadata = "";
|
private String serverMetadata = "";
|
||||||
private boolean streaming = false;
|
private boolean streaming = false;
|
||||||
|
|
||||||
private boolean audioOnly = false;
|
private boolean audioActive = true;
|
||||||
|
private boolean videoActive = true;
|
||||||
|
|
||||||
private final String METADATA_SEPARATOR = "%/%";
|
private final String METADATA_SEPARATOR = "%/%";
|
||||||
|
|
||||||
|
@ -50,14 +51,15 @@ public class UserParticipant {
|
||||||
this.streaming = streaming;
|
this.streaming = streaming;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserParticipant(String participantId, String userName, String clientMetadata, String serverMetadata, boolean streaming, boolean audioOnly) {
|
public UserParticipant(String participantId, String userName, String clientMetadata, String serverMetadata, boolean streaming, boolean audioActive, boolean videoActive) {
|
||||||
super();
|
super();
|
||||||
this.participantId = participantId;
|
this.participantId = participantId;
|
||||||
this.userName = userName;
|
this.userName = userName;
|
||||||
this.clientMetadata = clientMetadata;
|
this.clientMetadata = clientMetadata;
|
||||||
this.serverMetadata = serverMetadata;
|
this.serverMetadata = serverMetadata;
|
||||||
this.streaming = streaming;
|
this.streaming = streaming;
|
||||||
this.audioOnly = audioOnly;
|
this.audioActive = audioActive;
|
||||||
|
this.videoActive = videoActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserParticipant(String participantId, String userName) {
|
public UserParticipant(String participantId, String userName) {
|
||||||
|
@ -106,12 +108,20 @@ public class UserParticipant {
|
||||||
this.streaming = streaming;
|
this.streaming = streaming;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAudioOnly() {
|
public boolean isAudioActive() {
|
||||||
return audioOnly;
|
return audioActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAudioOnly(boolean audioOnly) {
|
public void setAudioACtive(boolean active) {
|
||||||
this.audioOnly = audioOnly;
|
this.audioActive = active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVideoActive() {
|
||||||
|
return videoActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVideoACtive(boolean active) {
|
||||||
|
this.videoActive = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFullMetadata(){
|
public String getFullMetadata(){
|
||||||
|
|
|
@ -82,7 +82,8 @@ public class DefaultNotificationRoomHandler implements NotificationRoomHandler {
|
||||||
if (participant.isStreaming()) {
|
if (participant.isStreaming()) {
|
||||||
JsonObject stream = new JsonObject();
|
JsonObject stream = new JsonObject();
|
||||||
stream.addProperty(ProtocolElements.JOINROOM_PEERSTREAMID_PARAM, "webcam");
|
stream.addProperty(ProtocolElements.JOINROOM_PEERSTREAMID_PARAM, "webcam");
|
||||||
stream.addProperty(ProtocolElements.JOINROOM_PEERSTREAMAUDIOONLY_PARAM, participant.isAudioOnly());
|
stream.addProperty(ProtocolElements.JOINROOM_PEERSTREAMAUDIOACTIVE_PARAM, participant.isAudioActive());
|
||||||
|
stream.addProperty(ProtocolElements.JOINROOM_PEERSTREAMVIDEOACTIVE_PARAM, participant.isVideoActive());
|
||||||
JsonArray streamsArray = new JsonArray();
|
JsonArray streamsArray = new JsonArray();
|
||||||
streamsArray.add(stream);
|
streamsArray.add(stream);
|
||||||
participantJson.add(ProtocolElements.JOINROOM_PEERSTREAMS_PARAM, streamsArray);
|
participantJson.add(ProtocolElements.JOINROOM_PEERSTREAMS_PARAM, streamsArray);
|
||||||
|
@ -127,7 +128,7 @@ public class DefaultNotificationRoomHandler implements NotificationRoomHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPublishMedia(ParticipantRequest request, String publisherName, String sdpAnswer,
|
public void onPublishMedia(ParticipantRequest request, String publisherName, String sdpAnswer,
|
||||||
boolean audioOnly, Set<UserParticipant> participants, OpenViduException error) {
|
boolean audioActive, boolean videoActive, Set<UserParticipant> participants, OpenViduException error) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
notifService.sendErrorResponse(request, null, error);
|
notifService.sendErrorResponse(request, null, error);
|
||||||
return;
|
return;
|
||||||
|
@ -140,7 +141,8 @@ public class DefaultNotificationRoomHandler implements NotificationRoomHandler {
|
||||||
params.addProperty(ProtocolElements.PARTICIPANTPUBLISHED_USER_PARAM, publisherName);
|
params.addProperty(ProtocolElements.PARTICIPANTPUBLISHED_USER_PARAM, publisherName);
|
||||||
JsonObject stream = new JsonObject();
|
JsonObject stream = new JsonObject();
|
||||||
stream.addProperty(ProtocolElements.PARTICIPANTPUBLISHED_STREAMID_PARAM, "webcam");
|
stream.addProperty(ProtocolElements.PARTICIPANTPUBLISHED_STREAMID_PARAM, "webcam");
|
||||||
stream.addProperty(ProtocolElements.PARTICIPANTPUBLISHED_AUDIOONLY_PARAM, audioOnly);
|
stream.addProperty(ProtocolElements.PARTICIPANTPUBLISHED_AUDIOACTIVE_PARAM, audioActive);
|
||||||
|
stream.addProperty(ProtocolElements.PARTICIPANTPUBLISHED_VIDEOACTIVE_PARAM, videoActive);
|
||||||
JsonArray streamsArray = new JsonArray();
|
JsonArray streamsArray = new JsonArray();
|
||||||
streamsArray.add(stream);
|
streamsArray.add(stream);
|
||||||
params.add(ProtocolElements.PARTICIPANTPUBLISHED_STREAMS_PARAM, streamsArray);
|
params.add(ProtocolElements.PARTICIPANTPUBLISHED_STREAMS_PARAM, streamsArray);
|
||||||
|
|
|
@ -74,7 +74,8 @@ public class Participant {
|
||||||
new ConcurrentHashMap<String, SubscriberEndpoint>();
|
new ConcurrentHashMap<String, SubscriberEndpoint>();
|
||||||
|
|
||||||
private volatile boolean streaming = false;
|
private volatile boolean streaming = false;
|
||||||
private volatile boolean audioOnly = false;
|
private volatile boolean audioActive = true;
|
||||||
|
private volatile boolean videoActive = true;
|
||||||
private volatile boolean closed;
|
private volatile boolean closed;
|
||||||
|
|
||||||
private InfoHandler infoHandler;
|
private InfoHandler infoHandler;
|
||||||
|
@ -214,12 +215,20 @@ public class Participant {
|
||||||
return streaming;
|
return streaming;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAudioOnly() {
|
public boolean isAudioActive() {
|
||||||
return this.audioOnly;
|
return this.audioActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAudioOnly(boolean audioOnly) {
|
public void setAudioActive(boolean active) {
|
||||||
this.audioOnly = audioOnly;
|
this.audioActive = active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVideoActive() {
|
||||||
|
return this.videoActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVideoActive(boolean active) {
|
||||||
|
this.videoActive = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSubscribed() {
|
public boolean isSubscribed() {
|
||||||
|
|
|
@ -109,10 +109,11 @@ public class JsonRpcUserControl {
|
||||||
if (roomManager.getRoomManager().isPublisherInRoom(participantName, roomName, pid)) {
|
if (roomManager.getRoomManager().isPublisherInRoom(participantName, roomName, pid)) {
|
||||||
|
|
||||||
String sdpOffer = getStringParam(request, ProtocolElements.PUBLISHVIDEO_SDPOFFER_PARAM);
|
String sdpOffer = getStringParam(request, ProtocolElements.PUBLISHVIDEO_SDPOFFER_PARAM);
|
||||||
boolean audioOnly = getBooleanParam(request, ProtocolElements.PUBLISHVIDEO_AUDIOONLY_PARAM);
|
boolean audioActive = getBooleanParam(request, ProtocolElements.PUBLISHVIDEO_AUDIOACTIVE_PARAM);
|
||||||
|
boolean videoActive = getBooleanParam(request, ProtocolElements.PUBLISHVIDEO_VIDEOACTIVE_PARAM);
|
||||||
boolean doLoopback = getBooleanParam(request, ProtocolElements.PUBLISHVIDEO_DOLOOPBACK_PARAM);
|
boolean doLoopback = getBooleanParam(request, ProtocolElements.PUBLISHVIDEO_DOLOOPBACK_PARAM);
|
||||||
|
|
||||||
roomManager.publishMedia(participantRequest, sdpOffer, audioOnly, doLoopback);
|
roomManager.publishMedia(participantRequest, sdpOffer, audioActive, videoActive, doLoopback);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
System.out.println("Error: user is not a publisher");
|
System.out.println("Error: user is not a publisher");
|
||||||
|
|
Loading…
Reference in New Issue