mirror of https://github.com/OpenVidu/openvidu.git
openvidu-browser Connection object creationTime real value. Stream objects creationTime property addded
parent
b620cc0fa8
commit
e001b2dbc9
|
@ -34,7 +34,7 @@ export class Connection {
|
||||||
connectionId: string;
|
connectionId: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Time when this connection was created (UTC milliseconds)
|
* Time when this connection was created in OpenVidu Server (UTC milliseconds)
|
||||||
*/
|
*/
|
||||||
creationTime: number;
|
creationTime: number;
|
||||||
|
|
||||||
|
@ -77,6 +77,7 @@ export class Connection {
|
||||||
if (!!opts) {
|
if (!!opts) {
|
||||||
// Connection is remote
|
// Connection is remote
|
||||||
this.connectionId = opts.id;
|
this.connectionId = opts.id;
|
||||||
|
this.creationTime = opts.createdAt;
|
||||||
if (opts.metadata) {
|
if (opts.metadata) {
|
||||||
this.data = opts.metadata;
|
this.data = opts.metadata;
|
||||||
}
|
}
|
||||||
|
@ -84,8 +85,6 @@ export class Connection {
|
||||||
this.initRemoteStreams(opts.streams);
|
this.initRemoteStreams(opts.streams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.creationTime = new Date().getTime();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,6 +121,7 @@ export class Connection {
|
||||||
options.forEach(opts => {
|
options.forEach(opts => {
|
||||||
const streamOptions: InboundStreamOptions = {
|
const streamOptions: InboundStreamOptions = {
|
||||||
id: opts.id,
|
id: opts.id,
|
||||||
|
createdAt: opts.createdAt,
|
||||||
connection: this,
|
connection: this,
|
||||||
hasAudio: opts.hasAudio,
|
hasAudio: opts.hasAudio,
|
||||||
hasVideo: opts.hasVideo,
|
hasVideo: opts.hasVideo,
|
||||||
|
|
|
@ -1046,6 +1046,7 @@ export class Session implements EventDispatcher {
|
||||||
// Initialize local Connection object with values returned by openvidu-server
|
// Initialize local Connection object with values returned by openvidu-server
|
||||||
this.connection = new Connection(this);
|
this.connection = new Connection(this);
|
||||||
this.connection.connectionId = response.id;
|
this.connection.connectionId = response.id;
|
||||||
|
this.connection.creationTime = response.createdAt;
|
||||||
this.connection.data = response.metadata;
|
this.connection.data = response.metadata;
|
||||||
|
|
||||||
// Initialize remote Connections with value returned by openvidu-server
|
// Initialize remote Connections with value returned by openvidu-server
|
||||||
|
|
|
@ -87,6 +87,13 @@ export class Stream implements EventDispatcher {
|
||||||
*/
|
*/
|
||||||
streamId: string;
|
streamId: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time when this stream was created in OpenVidu Server (UTC milliseconds). Depending on the owner of this stream:
|
||||||
|
* - Subscriber object: property `creationTime` is always defined
|
||||||
|
* - Publisher object: property `creationTime` is only defined after successful execution of [[Session.publish]]
|
||||||
|
*/
|
||||||
|
creationTime: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `"CAMERA"`, `"SCREEN"` or `"CUSTOM"` (the latter when [[PublisherProperties.videoSource]] is a MediaStreamTrack when calling [[OpenVidu.initPublisher]]).
|
* `"CAMERA"`, `"SCREEN"` or `"CUSTOM"` (the latter when [[PublisherProperties.videoSource]] is a MediaStreamTrack when calling [[OpenVidu.initPublisher]]).
|
||||||
* If [[hasVideo]] is false, this property is undefined
|
* If [[hasVideo]] is false, this property is undefined
|
||||||
|
@ -182,6 +189,7 @@ export class Stream implements EventDispatcher {
|
||||||
// InboundStreamOptions: stream belongs to a Subscriber
|
// InboundStreamOptions: stream belongs to a Subscriber
|
||||||
this.inboundStreamOpts = <InboundStreamOptions>options;
|
this.inboundStreamOpts = <InboundStreamOptions>options;
|
||||||
this.streamId = this.inboundStreamOpts.id;
|
this.streamId = this.inboundStreamOpts.id;
|
||||||
|
this.creationTime = this.inboundStreamOpts.createdAt;
|
||||||
this.hasAudio = this.inboundStreamOpts.hasAudio;
|
this.hasAudio = this.inboundStreamOpts.hasAudio;
|
||||||
this.hasVideo = this.inboundStreamOpts.hasVideo;
|
this.hasVideo = this.inboundStreamOpts.hasVideo;
|
||||||
if (this.hasAudio) {
|
if (this.hasAudio) {
|
||||||
|
@ -709,6 +717,7 @@ export class Stream implements EventDispatcher {
|
||||||
this.webRtcPeer.processAnswer(response.sdpAnswer, false)
|
this.webRtcPeer.processAnswer(response.sdpAnswer, false)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.streamId = response.id;
|
this.streamId = response.id;
|
||||||
|
this.creationTime = response.createdAt;
|
||||||
this.isLocalStreamPublished = true;
|
this.isLocalStreamPublished = true;
|
||||||
this.publishedOnce = true;
|
this.publishedOnce = true;
|
||||||
if (this.displayMyRemote()) {
|
if (this.displayMyRemote()) {
|
||||||
|
|
|
@ -19,6 +19,7 @@ import { StreamOptionsServer } from './StreamOptionsServer';
|
||||||
|
|
||||||
export interface ConnectionOptions {
|
export interface ConnectionOptions {
|
||||||
id: string;
|
id: string;
|
||||||
|
createdAt: number;
|
||||||
metadata: string;
|
metadata: string;
|
||||||
streams: StreamOptionsServer[];
|
streams: StreamOptionsServer[];
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import { Filter } from '../../../OpenVidu/Filter';
|
||||||
|
|
||||||
export interface InboundStreamOptions {
|
export interface InboundStreamOptions {
|
||||||
id: string;
|
id: string;
|
||||||
|
createdAt: number;
|
||||||
connection: Connection;
|
connection: Connection;
|
||||||
hasAudio: boolean;
|
hasAudio: boolean;
|
||||||
hasVideo: boolean;
|
hasVideo: boolean;
|
||||||
|
|
|
@ -19,6 +19,7 @@ import { Filter } from '../../../OpenVidu/Filter';
|
||||||
|
|
||||||
export interface StreamOptionsServer {
|
export interface StreamOptionsServer {
|
||||||
id: string;
|
id: string;
|
||||||
|
createdAt: number;
|
||||||
hasAudio: boolean;
|
hasAudio: boolean;
|
||||||
hasVideo: boolean;
|
hasVideo: boolean;
|
||||||
audioActive: boolean;
|
audioActive: boolean;
|
||||||
|
|
|
@ -41,6 +41,7 @@ public class ProtocolElements {
|
||||||
public static final String JOINROOM_RECORDER_PARAM = "recorder";
|
public static final String JOINROOM_RECORDER_PARAM = "recorder";
|
||||||
|
|
||||||
public static final String JOINROOM_PEERID_PARAM = "id";
|
public static final String JOINROOM_PEERID_PARAM = "id";
|
||||||
|
public static final String JOINROOM_PEERCREATEDAT_PARAM = "createdAt";
|
||||||
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_PEERSTREAMHASAUDIO_PARAM = "hasAudio";
|
public static final String JOINROOM_PEERSTREAMHASAUDIO_PARAM = "hasAudio";
|
||||||
|
@ -57,6 +58,7 @@ public class ProtocolElements {
|
||||||
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_STREAMID_PARAM = "id";
|
public static final String PUBLISHVIDEO_STREAMID_PARAM = "id";
|
||||||
|
public static final String PUBLISHVIDEO_CREATEDAT_PARAM = "createdAt";
|
||||||
public static final String PUBLISHVIDEO_HASAUDIO_PARAM = "hasAudio";
|
public static final String PUBLISHVIDEO_HASAUDIO_PARAM = "hasAudio";
|
||||||
public static final String PUBLISHVIDEO_HASVIDEO_PARAM = "hasVideo";
|
public static final String PUBLISHVIDEO_HASVIDEO_PARAM = "hasVideo";
|
||||||
public static final String PUBLISHVIDEO_AUDIOACTIVE_PARAM = "audioActive";
|
public static final String PUBLISHVIDEO_AUDIOACTIVE_PARAM = "audioActive";
|
||||||
|
@ -120,6 +122,7 @@ public class ProtocolElements {
|
||||||
|
|
||||||
public static final String PARTICIPANTJOINED_METHOD = "participantJoined";
|
public static final String PARTICIPANTJOINED_METHOD = "participantJoined";
|
||||||
public static final String PARTICIPANTJOINED_USER_PARAM = "id";
|
public static final String PARTICIPANTJOINED_USER_PARAM = "id";
|
||||||
|
public static final String PARTICIPANTJOINED_CREATEDAT_PARAM = "createdAt";
|
||||||
public static final String PARTICIPANTJOINED_METADATA_PARAM = "metadata";
|
public static final String PARTICIPANTJOINED_METADATA_PARAM = "metadata";
|
||||||
|
|
||||||
public static final String PARTICIPANTLEFT_METHOD = "participantLeft";
|
public static final String PARTICIPANTLEFT_METHOD = "participantLeft";
|
||||||
|
@ -134,6 +137,7 @@ 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_CREATEDAT_PARAM = "createdAt";
|
||||||
public static final String PARTICIPANTPUBLISHED_HASAUDIO_PARAM = "hasAudio";
|
public static final String PARTICIPANTPUBLISHED_HASAUDIO_PARAM = "hasAudio";
|
||||||
public static final String PARTICIPANTPUBLISHED_HASVIDEO_PARAM = "hasVideo";
|
public static final String PARTICIPANTPUBLISHED_HASVIDEO_PARAM = "hasVideo";
|
||||||
public static final String PARTICIPANTPUBLISHED_AUDIOACTIVE_PARAM = "audioActive";
|
public static final String PARTICIPANTPUBLISHED_AUDIOACTIVE_PARAM = "audioActive";
|
||||||
|
|
|
@ -86,6 +86,8 @@ public class SessionEventsHandler {
|
||||||
JsonObject participantJson = new JsonObject();
|
JsonObject participantJson = new JsonObject();
|
||||||
participantJson.addProperty(ProtocolElements.JOINROOM_PEERID_PARAM,
|
participantJson.addProperty(ProtocolElements.JOINROOM_PEERID_PARAM,
|
||||||
existingParticipant.getParticipantPublicId());
|
existingParticipant.getParticipantPublicId());
|
||||||
|
participantJson.addProperty(ProtocolElements.JOINROOM_PEERCREATEDAT_PARAM,
|
||||||
|
existingParticipant.getCreatedAt());
|
||||||
|
|
||||||
// Metadata associated to each existing participant
|
// Metadata associated to each existing participant
|
||||||
participantJson.addProperty(ProtocolElements.JOINROOM_METADATA_PARAM,
|
participantJson.addProperty(ProtocolElements.JOINROOM_METADATA_PARAM,
|
||||||
|
@ -98,6 +100,8 @@ public class SessionEventsHandler {
|
||||||
JsonObject stream = new JsonObject();
|
JsonObject stream = new JsonObject();
|
||||||
stream.addProperty(ProtocolElements.JOINROOM_PEERSTREAMID_PARAM,
|
stream.addProperty(ProtocolElements.JOINROOM_PEERSTREAMID_PARAM,
|
||||||
existingParticipant.getPublisherStreamId());
|
existingParticipant.getPublisherStreamId());
|
||||||
|
stream.addProperty(ProtocolElements.JOINROOM_PEERCREATEDAT_PARAM,
|
||||||
|
kParticipant.getPublisher().createdAt());
|
||||||
stream.addProperty(ProtocolElements.JOINROOM_PEERSTREAMHASAUDIO_PARAM,
|
stream.addProperty(ProtocolElements.JOINROOM_PEERSTREAMHASAUDIO_PARAM,
|
||||||
kParticipant.getPublisherMediaOptions().hasAudio);
|
kParticipant.getPublisherMediaOptions().hasAudio);
|
||||||
stream.addProperty(ProtocolElements.JOINROOM_PEERSTREAMHASVIDEO_PARAM,
|
stream.addProperty(ProtocolElements.JOINROOM_PEERSTREAMHASVIDEO_PARAM,
|
||||||
|
@ -139,6 +143,8 @@ public class SessionEventsHandler {
|
||||||
// Metadata associated to new participant
|
// Metadata associated to new participant
|
||||||
notifParams.addProperty(ProtocolElements.PARTICIPANTJOINED_USER_PARAM,
|
notifParams.addProperty(ProtocolElements.PARTICIPANTJOINED_USER_PARAM,
|
||||||
participant.getParticipantPublicId());
|
participant.getParticipantPublicId());
|
||||||
|
notifParams.addProperty(ProtocolElements.PARTICIPANTJOINED_CREATEDAT_PARAM,
|
||||||
|
participant.getCreatedAt());
|
||||||
notifParams.addProperty(ProtocolElements.PARTICIPANTJOINED_METADATA_PARAM,
|
notifParams.addProperty(ProtocolElements.PARTICIPANTJOINED_METADATA_PARAM,
|
||||||
participant.getFullMetadata());
|
participant.getFullMetadata());
|
||||||
|
|
||||||
|
@ -147,6 +153,7 @@ public class SessionEventsHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result.addProperty(ProtocolElements.PARTICIPANTJOINED_USER_PARAM, participant.getParticipantPublicId());
|
result.addProperty(ProtocolElements.PARTICIPANTJOINED_USER_PARAM, participant.getParticipantPublicId());
|
||||||
|
result.addProperty(ProtocolElements.PARTICIPANTJOINED_CREATEDAT_PARAM, participant.getCreatedAt());
|
||||||
result.addProperty(ProtocolElements.PARTICIPANTJOINED_METADATA_PARAM, participant.getFullMetadata());
|
result.addProperty(ProtocolElements.PARTICIPANTJOINED_METADATA_PARAM, participant.getFullMetadata());
|
||||||
result.add("value", resultArray);
|
result.add("value", resultArray);
|
||||||
|
|
||||||
|
@ -181,8 +188,9 @@ public class SessionEventsHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPublishMedia(Participant participant, String streamId, String sessionId, MediaOptions mediaOptions,
|
public void onPublishMedia(Participant participant, String streamId, Long createdAt, String sessionId,
|
||||||
String sdpAnswer, Set<Participant> participants, Integer transactionId, OpenViduException error) {
|
MediaOptions mediaOptions, String sdpAnswer, Set<Participant> participants, Integer transactionId,
|
||||||
|
OpenViduException error) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
rpcNotificationService.sendErrorResponse(participant.getParticipantPrivateId(), transactionId, null, error);
|
rpcNotificationService.sendErrorResponse(participant.getParticipantPrivateId(), transactionId, null, error);
|
||||||
return;
|
return;
|
||||||
|
@ -190,6 +198,7 @@ public class SessionEventsHandler {
|
||||||
JsonObject result = new JsonObject();
|
JsonObject result = new JsonObject();
|
||||||
result.addProperty(ProtocolElements.PUBLISHVIDEO_SDPANSWER_PARAM, sdpAnswer);
|
result.addProperty(ProtocolElements.PUBLISHVIDEO_SDPANSWER_PARAM, sdpAnswer);
|
||||||
result.addProperty(ProtocolElements.PUBLISHVIDEO_STREAMID_PARAM, streamId);
|
result.addProperty(ProtocolElements.PUBLISHVIDEO_STREAMID_PARAM, streamId);
|
||||||
|
result.addProperty(ProtocolElements.PUBLISHVIDEO_CREATEDAT_PARAM, createdAt);
|
||||||
rpcNotificationService.sendResponse(participant.getParticipantPrivateId(), transactionId, result);
|
rpcNotificationService.sendResponse(participant.getParticipantPrivateId(), transactionId, result);
|
||||||
|
|
||||||
JsonObject params = new JsonObject();
|
JsonObject params = new JsonObject();
|
||||||
|
@ -197,6 +206,7 @@ public class SessionEventsHandler {
|
||||||
JsonObject stream = new JsonObject();
|
JsonObject stream = new JsonObject();
|
||||||
|
|
||||||
stream.addProperty(ProtocolElements.PARTICIPANTPUBLISHED_STREAMID_PARAM, streamId);
|
stream.addProperty(ProtocolElements.PARTICIPANTPUBLISHED_STREAMID_PARAM, streamId);
|
||||||
|
stream.addProperty(ProtocolElements.PARTICIPANTPUBLISHED_CREATEDAT_PARAM, createdAt);
|
||||||
stream.addProperty(ProtocolElements.PARTICIPANTPUBLISHED_HASAUDIO_PARAM, mediaOptions.hasAudio);
|
stream.addProperty(ProtocolElements.PARTICIPANTPUBLISHED_HASAUDIO_PARAM, mediaOptions.hasAudio);
|
||||||
stream.addProperty(ProtocolElements.PARTICIPANTPUBLISHED_HASVIDEO_PARAM, mediaOptions.hasVideo);
|
stream.addProperty(ProtocolElements.PARTICIPANTPUBLISHED_HASVIDEO_PARAM, mediaOptions.hasVideo);
|
||||||
stream.addProperty(ProtocolElements.PARTICIPANTPUBLISHED_AUDIOACTIVE_PARAM, mediaOptions.audioActive);
|
stream.addProperty(ProtocolElements.PARTICIPANTPUBLISHED_AUDIOACTIVE_PARAM, mediaOptions.audioActive);
|
||||||
|
|
|
@ -256,8 +256,8 @@ public class KurentoSessionManager extends SessionManager {
|
||||||
+ kurentoOptions.getFilter().getType());
|
+ kurentoOptions.getFilter().getType());
|
||||||
log.error("PARTICIPANT {}: Error applying filter. The token has no permissions to apply filter {}",
|
log.error("PARTICIPANT {}: Error applying filter. The token has no permissions to apply filter {}",
|
||||||
participant.getParticipantPublicId(), kurentoOptions.getFilter().getType(), e);
|
participant.getParticipantPublicId(), kurentoOptions.getFilter().getType(), e);
|
||||||
sessionEventsHandler.onPublishMedia(participant, null, session.getSessionId(), mediaOptions, sdpAnswer,
|
sessionEventsHandler.onPublishMedia(participant, null, kParticipant.getPublisher().createdAt(),
|
||||||
participants, transactionId, e);
|
session.getSessionId(), mediaOptions, sdpAnswer, participants, transactionId, e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,8 +269,8 @@ public class KurentoSessionManager extends SessionManager {
|
||||||
OpenViduException e = new OpenViduException(Code.MEDIA_SDP_ERROR_CODE,
|
OpenViduException e = new OpenViduException(Code.MEDIA_SDP_ERROR_CODE,
|
||||||
"Error generating SDP response for publishing user " + participant.getParticipantPublicId());
|
"Error generating SDP response for publishing user " + participant.getParticipantPublicId());
|
||||||
log.error("PARTICIPANT {}: Error publishing media", participant.getParticipantPublicId(), e);
|
log.error("PARTICIPANT {}: Error publishing media", participant.getParticipantPublicId(), e);
|
||||||
sessionEventsHandler.onPublishMedia(participant, null, session.getSessionId(), mediaOptions, sdpAnswer,
|
sessionEventsHandler.onPublishMedia(participant, null, kParticipant.getPublisher().createdAt(),
|
||||||
participants, transactionId, e);
|
session.getSessionId(), mediaOptions, sdpAnswer, participants, transactionId, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.openviduConfig.isRecordingModuleEnabled()
|
if (this.openviduConfig.isRecordingModuleEnabled()
|
||||||
|
@ -305,8 +305,9 @@ public class KurentoSessionManager extends SessionManager {
|
||||||
participants = kParticipant.getSession().getParticipants();
|
participants = kParticipant.getSession().getParticipants();
|
||||||
|
|
||||||
if (sdpAnswer != null) {
|
if (sdpAnswer != null) {
|
||||||
sessionEventsHandler.onPublishMedia(participant, participant.getPublisherStreamId(), session.getSessionId(),
|
sessionEventsHandler.onPublishMedia(participant, participant.getPublisherStreamId(),
|
||||||
mediaOptions, sdpAnswer, participants, transactionId, null);
|
kParticipant.getPublisher().createdAt(), session.getSessionId(), mediaOptions, sdpAnswer,
|
||||||
|
participants, transactionId, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue