Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* global config, APP */
  2. /*
  3. * Copyright @ 2015 Atlassian Pty Ltd
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. import VideoLayout from '../UI/videolayout/VideoLayout';
  18. import Feedback from '../UI/Feedback.js';
  19. import Toolbar from '../UI/toolbars/Toolbar';
  20. import BottomToolbar from '../UI/toolbars/BottomToolbar';
  21. const _RECORDER_CUSTOM_ROLE = "recorder-role";
  22. class Recorder {
  23. /**
  24. * Initializes a new {Recorder} instance.
  25. *
  26. * @param conference the {conference} which is to transport
  27. * {Recorder}-related information between participants
  28. */
  29. constructor (conference) {
  30. this._conference = conference;
  31. // If I am a recorder then I publish my recorder custom role to notify
  32. // everyone.
  33. if (config.iAmRecorder) {
  34. VideoLayout.enableDeviceAvailabilityIcons(conference.localId, true);
  35. this._publishMyRecorderRole();
  36. Feedback.enableFeedback(false);
  37. Toolbar.enable(false);
  38. BottomToolbar.enable(false);
  39. }
  40. // Listen to "CUSTOM_ROLE" commands.
  41. this._conference.commands.addCommandListener(
  42. this._conference.commands.defaults.CUSTOM_ROLE,
  43. this._onCustomRoleCommand.bind(this));
  44. }
  45. /**
  46. * Publish the recorder custom role.
  47. * @private
  48. */
  49. _publishMyRecorderRole () {
  50. var conference = this._conference;
  51. var commands = conference.commands;
  52. commands.removeCommand(commands.defaults.CUSTOM_ROLE);
  53. var self = this;
  54. commands.sendCommandOnce(
  55. commands.defaults.CUSTOM_ROLE,
  56. {
  57. attributes: {
  58. recorderRole: true
  59. }
  60. });
  61. }
  62. /**
  63. * Notifies this instance about a &qout;Custom Role&qout; command (delivered
  64. * by the Command(s) API of {this._conference}).
  65. *
  66. * @param attributes the attributes {Object} carried by the command
  67. * @param id the identifier of the participant who issued the command. A
  68. * notable idiosyncrasy of the Command(s) API to be mindful of here is that
  69. * the command may be issued by the local participant.
  70. */
  71. _onCustomRoleCommand ({ attributes }, id) {
  72. // We require to know who issued the command because (1) only a
  73. // moderator is allowed to send commands and (2) a command MUST be
  74. // issued by a defined commander.
  75. if (typeof id === 'undefined'
  76. || this._conference.isLocalId(id)
  77. || !attributes.recorderRole)
  78. return;
  79. var isRecorder = (attributes.recorderRole == 'true');
  80. if (isRecorder)
  81. VideoLayout.enableDeviceAvailabilityIcons(id, isRecorder);
  82. }
  83. }
  84. export default Recorder;