Skip to content

Commit

Permalink
Remove support for v2 calling
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregor Herdmann committed Jun 7, 2017
1 parent 6ea1483 commit d7b224f
Show file tree
Hide file tree
Showing 67 changed files with 1,745 additions and 5,307 deletions.
39 changes: 8 additions & 31 deletions app/page/template/_dist/app.htm
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
<script src="/script/media/MediaError.js"></script>
<script src="/script/media/MediaParser.js"></script>
<script src="/script/media/MediaRepository.js"></script>
<script src="/script/media/MediaStreamError.js"></script>
<script src="/script/media/MediaStreamErrorTypes.js"></script>
<script src="/script/media/MediaStreamHandler.js"></script>
<script src="/script/media/MediaStreamSource.js"></script>
<script src="/script/media/MediaStreamInfo.js"></script>
Expand Down Expand Up @@ -317,58 +319,33 @@
<script src="/script/telemetry/calling/FlowTelemetry.js"></script>
<script src="/script/telemetry/calling/CallTelemetry.js"></script>
<!-- Calling/Enums -->
<script src="/script/calling/enum/CallAction.js"></script>
<script src="/script/calling/enum/CallMessageType.js"></script>
<script src="/script/calling/enum/CallState.js"></script>
<script src="/script/calling/enum/CallStateEventCause.js"></script>
<script src="/script/calling/enum/CallStateGroup.js"></script>
<script src="/script/calling/enum/ECallMessageType.js"></script>
<script src="/script/calling/enum/ParticipantState.js"></script>
<script src="/script/calling/enum/PropertyState.js"></script>
<script src="/script/calling/enum/Protocol.js"></script>
<script src="/script/calling/enum/SDPNegotiationMode.js"></script>
<script src="/script/calling/enum/SDPSource.js"></script>
<script src="/script/calling/enum/TerminationReason.js"></script>
<script src="/script/calling/enum/VideoOrientation.js"></script>
<!-- Calling/Payloads -->
<script src="/script/calling/payloads/FlowDeletionInfo.js"></script>
<script src="/script/calling/payloads/ICECandidateInfo.js"></script>
<script src="/script/calling/payloads/SDPInfo.js"></script>
<!-- Calling/Rtc -->
<script src="/script/calling/rtc/DataChannelState.js"></script>
<script src="/script/calling/rtc/ICEConnectionState.js"></script>
<script src="/script/calling/rtc/ICEGatheringState.js"></script>
<script src="/script/calling/rtc/MediaStreamError.js"></script>
<script src="/script/calling/rtc/MediaStreamErrorTypes.js"></script>
<script src="/script/calling/rtc/SDPType.js"></script>
<script src="/script/calling/rtc/SignalingState.js"></script>
<script src="/script/calling/rtc/StatsType.js"></script>
<!-- Calling/Handler -->
<script src="/script/calling/handler/CallSignalingHandler.js"></script>
<script src="/script/calling/handler/CallStateHandler.js"></script>
<!-- Calling/Mapper -->
<script src="/script/calling/mapper/ECallMessageMapper.js"></script>
<script src="/script/calling/mapper/ICECandidateMapper.js"></script>
<script src="/script/calling/mapper/SDPMapper.js"></script>
<!-- Calling/Entities -->
<script src="/script/calling/entities/Call.js"></script>
<script src="/script/calling/entities/ECall.js"></script>
<script src="/script/calling/entities/ECallMessage.js"></script>
<script src="/script/calling/entities/EFlow.js"></script>
<script src="/script/calling/entities/EParticipant.js"></script>
<script src="/script/calling/entities/CallMessage.js"></script>
<script src="/script/calling/entities/Flow.js"></script>
<script src="/script/calling/entities/FlowAudio.js"></script>
<script src="/script/calling/entities/Participant.js"></script>
<!-- Calling/v2 -->
<script src="/script/calling/v2/CallCenter.js"></script>
<script src="/script/calling/v2/CallError.js"></script>
<script src="/script/calling/v2/CallService.js"></script>
<script src="/script/calling/v2/CallTrackingInfo.js"></script>
<!-- Calling/v3 -->
<script src="/script/calling/v3/CallCenter.js"></script>
<script src="/script/calling/v3/CallError.js"></script>
<!-- Calling -->
<script src="/script/calling/CallError.js"></script>
<script src="/script/calling/CallingRepository.js"></script>
<script src="/script/calling/CallingService.js"></script>
<script src="/script/calling/CallMessageBuilder.js"></script>
<script src="/script/calling/CallMessageMapper.js"></script>
<script src="/script/calling/SDPMapper.js"></script>
<!-- View -->
<script src="/script/ui/ContextMenu.js"></script>
<script src="/script/ui/ShortcutType.js"></script>
Expand Down
22 changes: 0 additions & 22 deletions app/page/template/modals.htm
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,6 @@
</div>
</div>

<div class="modal modal-call-conversation-full" data-uie-name="modal-call-conversation-full">
<div class="modal-content">
<div class="modal-header">
<div class="modal-close icon-close icon-button pull-right"></div>
<div class="modal-title" data-bind="l10n_text: z.string.modal_call_conversation_full_headline"></div>
</div>
<div class="modal-text"></div>
<div class="modal-close button button-medium button-fluid" data-bind="l10n_text: z.string.modal_button_ok" data-uie-name="do-close"></div>
</div>
</div>

<div class="modal modal-call-no-video-in-group" data-uie-name="modal-call-no-video-in-group">
<div class="modal-content">
<div class="modal-header">
Expand All @@ -126,17 +115,6 @@
</div>
</div>

<div class="modal modal-call-voice-channel-full" data-uie-name="modal-call-voice-channel-full">
<div class="modal-content">
<div class="modal-header">
<div class="modal-close icon-close icon-button pull-right"></div>
<div class="modal-title" data-bind="l10n_text: z.string.modal_call_voice_channel_full_headline"></div>
</div>
<div class="modal-text"></div>
<div class="modal-close button button-medium button-fluid" data-bind="l10n_text: z.string.modal_button_ok" data-uie-name="do-close"></div>
</div>
</div>

<div class="modal modal-calling" data-uie-name="modal-calling">
<div class="modal-content">
<div class="modal-header">
Expand Down
95 changes: 95 additions & 0 deletions app/script/calling/CallError.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* Wire
* Copyright (C) 2017 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*/

'use strict';

window.z = window.z || {};
window.z.calling = z.calling || {};

z.calling.CallError = class CallError extends Error {
constructor(type, message) {
super();

this.name = this.constructor.name;
this.stack = (new Error()).stack;
this.type = type || CallError.TYPE.UNKNOWN;

switch (this.type) {
case CallError.TYPE.MISTARGETED_MESSAGE:
this.message = 'Message targeted at another client';
break;
case CallError.TYPE.NO_CONVERSATION_ID:
this.message = 'No conversation ID given';
break;
case CallError.TYPE.NO_DATA_CHANNEL:
this.message = 'No established data channel for call';
break;
case CallError.TYPE.NO_REPLACEABLE_TRACK:
this.message = 'No replaceable MediaStreamTrack found';
break;
case CallError.TYPE.NO_USER_ID:
this.message = 'User ID to target message not given';
break;
case CallError.TYPE.NOT_FOUND:
this.message = 'No call for conversation ID found';
break;
case CallError.TYPE.NOT_SUPPORTED:
this.message = 'Calling is not supported';
break;
case CallError.TYPE.RTP_SENDER_NOT_SUPPORTED:
this.message = 'PeerConnection does not support RtcRtpSender extension';
break;
case CallError.TYPE.SDP_STATE_COLLISION:
this.message = 'Unresolved SDP states collision of participants';
break;
case CallError.TYPE.UNSUPPORTED_VERSION:
this.message = 'Unsupported version of the call protocol';
break;
case CallError.TYPE.WRONG_CONVERSATION_TYPE:
this.message = 'Wrong conversation type for call message';
break;
case CallError.TYPE.WRONG_PAYLOAD_FORMAT:
this.message = 'Payload for an call message is in wrong format';
break;
case CallError.TYPE.WRONG_SENDER:
this.message = 'Call change from wrong sender';
break;
default:
this.message = 'Unknown CallError';
}
}

static get TYPE() {
return {
MISTARGETED_MESSAGE: 'z.calling.CallError.TYPE.MISTARGETED_MESSAGE',
NO_CONVERSATION_ID: 'z.calling.CallError.TYPE.NO_CONVERSATION_ID',
NO_DATA_CHANNEL: 'z.calling.CallError.TYPE.NO_DATA_CHANNEL',
NO_REPLACEABLE_TRACK: 'z.calling.CallError.TYPE.NO_REPLACEABLE_TRACK',
NO_USER_ID: 'z.calling.CallError.TYPE.NO_USER_ID',
NOT_FOUND: 'z.calling.CallError.TYPE.NOT_FOUND',
RTP_SENDER_NOT_SUPPORTED: 'z.calling.CallError.TYPE.RTP_SENDER_NOT_SUPPORTED',
SDP_STATE_COLLISION: 'z.calling.CallError.TYPE.SDP_STATE_COLLISION',
UNKNOWN: 'z.calling.CallError.TYPE.UNKNOWN',
UNSUPPORTED_VERSION: 'z.calling.CallError.TYPE.UNSUPPORTED_VERSION',
WRONG_CONVERSATION_TYPE: 'z.calling.CallError.TYPE.WRONG_CONVERSATION_TYPE',
WRONG_PAYLOAD_FORMAT: 'z.calling.CallError.TYPE.WRONG_PAYLOAD_FORMAT',
WRONG_SENDER: 'z.calling.CallError.TYPE.WRONG_SENDER',
};
}
};
185 changes: 185 additions & 0 deletions app/script/calling/CallMessageBuilder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
/*
* Wire
* Copyright (C) 2017 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*/

'use strict';

window.z = window.z || {};
window.z.calling = z.calling || {};

z.calling.CallMessageBuilder = (function() {

const _build_call_message = function(type, response, session_id, additional_payload) {
const call_message_et = new z.calling.entities.CallMessage(type, response, session_id);

if (additional_payload) {
call_message_et.add_properties(additional_payload);
}

return call_message_et;
};

const _build_cancel = function(response, session_id, additional_payload) {
return _build_call_message(z.calling.enum.CALL_MESSAGE_TYPE.CANCEL, response, session_id, additional_payload);
};

const _build_group_check = function(response, session_id, additional_payload) {
return _build_call_message(z.calling.enum.CALL_MESSAGE_TYPE.GROUP_CHECK, response, session_id, additional_payload);
};

const _build_group_leave = function(response, session_id, additional_payload) {
return _build_call_message(z.calling.enum.CALL_MESSAGE_TYPE.GROUP_LEAVE, response, session_id, additional_payload);
};

const _build_group_setup = function(response, session_id, additional_payload) {
return _build_call_message(z.calling.enum.CALL_MESSAGE_TYPE.GROUP_SETUP, response, session_id, additional_payload);
};

const _build_group_start = function(response, session_id, additional_payload) {
return _build_call_message(z.calling.enum.CALL_MESSAGE_TYPE.GROUP_START, response, session_id, additional_payload);
};

const _build_hangup = function(response, session_id, additional_payload) {
return _build_call_message(z.calling.enum.CALL_MESSAGE_TYPE.HANGUP, response, session_id, additional_payload);
};

const _build_prop_sync = function(response, session_id, additional_payload) {
return _build_call_message(z.calling.enum.CALL_MESSAGE_TYPE.PROP_SYNC, response, session_id, additional_payload);
};

const _build_reject = function(response, session_id, additional_payload) {
return _build_call_message(z.calling.enum.CALL_MESSAGE_TYPE.REJECT, response, session_id, additional_payload);
};

const _build_setup = function(response, session_id, additional_payload) {
return _build_call_message(z.calling.enum.CALL_MESSAGE_TYPE.SETUP, response, session_id, additional_payload);
};

const _build_update = function(response, session_id, additional_payload) {
return _build_call_message(z.calling.enum.CALL_MESSAGE_TYPE.UPDATE, response, session_id, additional_payload);
};

/**
* Create additional payload.
*
* @param {string} conversation_id - ID of conversation
* @param {string} self_user_id - ID of self user
* @param {string} [remote_user_id] - Optional ID of remote user
* @param {string} [remote_client_id] - Optional ID of remote client
* @returns {{conversation_id: string, remote_client_id: string, remote_user_id: *, time: string, user_id: string}} Additional payload
*/
const _create_payload = function(conversation_id, self_user_id, remote_user_id, remote_client_id) {
return {
conversation_id: conversation_id,
remote_client_id: remote_client_id,
remote_user_id: remote_user_id,
time: new Date().toISOString(),
user_id: self_user_id,
};
};

/**
* Create properties payload for call events.
*
* @param {Object} self_state - Current self state
* @param {z.media.MediaType|boolean} payload_type - Media type of property change or forced videosend state
* @param {boolean} [invert=false] - Invert state
* @param {Object} additional_payload - Optional additional payload to be added
* @returns {Object} call message props object
*/
const _create_payload_prop_sync = function(self_state, payload_type, invert, additional_payload) {
let payload;

if (_.isBoolean(payload_type)) {
payload = {
props: {
videosend: `${payload_type}`,
},
};
} else {
let audio_send_state, screen_send_state, video_send_state = undefined;

switch (payload_type) {
case z.media.MediaType.AUDIO: {
const {audio_send: audio_self_state} = self_state;

audio_send_state = invert ? !audio_self_state() : audio_self_state();

payload = {
props: {
audiosend: `${audio_send_state}`},
};
break;
}

case z.media.MediaType.SCREEN: {
const {screen_send: screen_self_state, video_send: video_self_state} = self_state;

screen_send_state = invert ? !screen_self_state() : screen_self_state();
video_send_state = invert ? z.calling.enum.PROPERTY_STATE.FALSE : video_self_state();

payload = {
props: {
screensend: `${screen_send_state}`,
videosend: `${video_send_state}`,
},
};
break;
}

case z.media.MediaType.VIDEO: {
const {screen_send: screen_self_state, video_send: video_self_state} = self_state;

screen_send_state = invert ? z.calling.enum.PROPERTY_STATE.FALSE : screen_self_state();
video_send_state = invert ? !video_self_state() : video_self_state();

payload = {
props: {
screensend: `${screen_send_state}`,
videosend: `${video_send_state}`,
},
};
break;
}

default:
throw new z.media.MediaError(z.media.MediaError.TYPE.UNHANDLED_MEDIA_TYPE);
}
}

if (additional_payload) {
payload = $.extend(payload, additional_payload);
}
return payload;
};

return {
build_cancel: _build_cancel,
build_group_check: _build_group_check,
build_group_leave: _build_group_leave,
build_group_setup: _build_group_setup,
build_group_start: _build_group_start,
build_hangup: _build_hangup,
build_prop_sync: _build_prop_sync,
build_reject: _build_reject,
build_setup: _build_setup,
build_update: _build_update,
create_payload: _create_payload,
create_payload_prop_sync: _create_payload_prop_sync,
};
})();
Loading

0 comments on commit d7b224f

Please sign in to comment.