You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Recorder.js 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. * @param UI the {UI} which is the source (model/state) to be sent to
  29. * remote participants if the local participant is the moderator or the
  30. * destination (model/state) to receive from the remote moderator if the
  31. * local participant is not the moderator
  32. */
  33. constructor (conference, UI) {
  34. var self = this;
  35. this._conference = conference;
  36. this._UI = UI;
  37. // If I am a recorder then I publish my recorder custom role to notify
  38. // everyone.
  39. if (config.iAmRecorder) {
  40. VideoLayout.enableDeviceAvailabilityIcons(conference.localId, true);
  41. this._publishMyRecorderRole();
  42. Feedback.enableFeedback(false);
  43. Toolbar.enable(false);
  44. BottomToolbar.enable(false);
  45. }
  46. // Listen to "CUSTOM_ROLE" commands.
  47. this._conference.commands.addCommandListener(
  48. this._conference.commands.defaults.CUSTOM_ROLE,
  49. this._onCustomRoleCommand.bind(this));
  50. }
  51. /**
  52. * Publish the recorder custom role.
  53. * @private
  54. */
  55. _publishMyRecorderRole () {
  56. var conference = this._conference;
  57. var commands = conference.commands;
  58. commands.removeCommand(commands.defaults.CUSTOM_ROLE);
  59. var self = this;
  60. commands.sendCommandOnce(
  61. commands.defaults.CUSTOM_ROLE,
  62. {
  63. attributes: {
  64. recorderRole: true
  65. }
  66. });
  67. }
  68. /**
  69. * Notifies this instance about a &qout;Custom Role&qout; command (delivered
  70. * by the Command(s) API of {this._conference}).
  71. *
  72. * @param attributes the attributes {Object} carried by the command
  73. * @param id the identifier of the participant who issued the command. A
  74. * notable idiosyncrasy of the Command(s) API to be mindful of here is that
  75. * the command may be issued by the local participant.
  76. */
  77. _onCustomRoleCommand ({ attributes }, id) {
  78. // We require to know who issued the command because (1) only a
  79. // moderator is allowed to send commands and (2) a command MUST be
  80. // issued by a defined commander.
  81. if (typeof id === 'undefined'
  82. || this._conference.isLocalId(id)
  83. || !attributes.recorderRole)
  84. return;
  85. var isRecorder = (attributes.recorderRole == 'true');
  86. if (isRecorder)
  87. VideoLayout.enableDeviceAvailabilityIcons(id, isRecorder);
  88. }
  89. }
  90. export default Recorder;