Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright @ 2015 Atlassian Pty Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* global APP */
  17. /**
  18. * A module for sending DTMF tones.
  19. */
  20. var DTMFSender;
  21. var initDtmfSender = function() {
  22. // TODO: This needs to reset this if the peerconnection changes
  23. // (e.g. the call is re-made)
  24. if (DTMFSender)
  25. return;
  26. var localAudio = APP.RTC.localAudio;
  27. if (localAudio && localAudio.getTracks().length > 0)
  28. {
  29. var peerconnection
  30. = APP.xmpp.getConnection().jingle.activecall.peerconnection;
  31. if (peerconnection) {
  32. DTMFSender =
  33. peerconnection.peerconnection
  34. .createDTMFSender(localAudio.getTracks()[0]);
  35. console.log("Initialized DTMFSender");
  36. }
  37. else {
  38. console.log("Failed to initialize DTMFSender: no PeerConnection.");
  39. }
  40. }
  41. else {
  42. console.log("Failed to initialize DTMFSender: no audio track.");
  43. }
  44. };
  45. var DTMF = {
  46. sendTones: function (tones, duration, pause) {
  47. if (!DTMFSender)
  48. initDtmfSender();
  49. if (DTMFSender){
  50. DTMFSender.insertDTMF(tones,
  51. (duration || 200),
  52. (pause || 200));
  53. }
  54. }
  55. };
  56. module.exports = DTMF;