| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "platform/mediastream/RTCDTMFSenderHandler.h" | 35 #include "platform/mediastream/RTCDTMFSenderHandler.h" |
| 36 | 36 |
| 37 namespace WebCore { | 37 namespace WebCore { |
| 38 | 38 |
| 39 static const long minToneDurationMs = 70; | 39 static const long minToneDurationMs = 70; |
| 40 static const long defaultToneDurationMs = 100; | 40 static const long defaultToneDurationMs = 100; |
| 41 static const long maxToneDurationMs = 6000; | 41 static const long maxToneDurationMs = 6000; |
| 42 static const long minInterToneGapMs = 50; | 42 static const long minInterToneGapMs = 50; |
| 43 static const long defaultInterToneGapMs = 50; | 43 static const long defaultInterToneGapMs = 50; |
| 44 | 44 |
| 45 PassRefPtr<RTCDTMFSender> RTCDTMFSender::create(ExecutionContext* context, RTCPe
erConnectionHandler* peerConnectionHandler, PassRefPtr<MediaStreamTrack> prpTrac
k, ExceptionState& es) | 45 PassRefPtr<RTCDTMFSender> RTCDTMFSender::create(ExecutionContext* context, RTCPe
erConnectionHandler* peerConnectionHandler, PassRefPtr<MediaStreamTrack> prpTrac
k, ExceptionState& exceptionState) |
| 46 { | 46 { |
| 47 RefPtr<MediaStreamTrack> track = prpTrack; | 47 RefPtr<MediaStreamTrack> track = prpTrack; |
| 48 OwnPtr<RTCDTMFSenderHandler> handler = peerConnectionHandler->createDTMFSend
er(track->component()); | 48 OwnPtr<RTCDTMFSenderHandler> handler = peerConnectionHandler->createDTMFSend
er(track->component()); |
| 49 if (!handler) { | 49 if (!handler) { |
| 50 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 50 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); |
| 51 return 0; | 51 return 0; |
| 52 } | 52 } |
| 53 | 53 |
| 54 RefPtr<RTCDTMFSender> dtmfSender = adoptRef(new RTCDTMFSender(context, track
, handler.release())); | 54 RefPtr<RTCDTMFSender> dtmfSender = adoptRef(new RTCDTMFSender(context, track
, handler.release())); |
| 55 dtmfSender->suspendIfNeeded(); | 55 dtmfSender->suspendIfNeeded(); |
| 56 return dtmfSender.release(); | 56 return dtmfSender.release(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 RTCDTMFSender::RTCDTMFSender(ExecutionContext* context, PassRefPtr<MediaStreamTr
ack> track, PassOwnPtr<RTCDTMFSenderHandler> handler) | 59 RTCDTMFSender::RTCDTMFSender(ExecutionContext* context, PassRefPtr<MediaStreamTr
ack> track, PassOwnPtr<RTCDTMFSenderHandler> handler) |
| 60 : ActiveDOMObject(context) | 60 : ActiveDOMObject(context) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 81 MediaStreamTrack* RTCDTMFSender::track() const | 81 MediaStreamTrack* RTCDTMFSender::track() const |
| 82 { | 82 { |
| 83 return m_track.get(); | 83 return m_track.get(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 String RTCDTMFSender::toneBuffer() const | 86 String RTCDTMFSender::toneBuffer() const |
| 87 { | 87 { |
| 88 return m_handler->currentToneBuffer(); | 88 return m_handler->currentToneBuffer(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void RTCDTMFSender::insertDTMF(const String& tones, ExceptionState& es) | 91 void RTCDTMFSender::insertDTMF(const String& tones, ExceptionState& exceptionSta
te) |
| 92 { | 92 { |
| 93 insertDTMF(tones, defaultToneDurationMs, defaultInterToneGapMs, es); | 93 insertDTMF(tones, defaultToneDurationMs, defaultInterToneGapMs, exceptionSta
te); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void RTCDTMFSender::insertDTMF(const String& tones, long duration, ExceptionStat
e& es) | 96 void RTCDTMFSender::insertDTMF(const String& tones, long duration, ExceptionStat
e& exceptionState) |
| 97 { | 97 { |
| 98 insertDTMF(tones, duration, defaultInterToneGapMs, es); | 98 insertDTMF(tones, duration, defaultInterToneGapMs, exceptionState); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void RTCDTMFSender::insertDTMF(const String& tones, long duration, long interTon
eGap, ExceptionState& es) | 101 void RTCDTMFSender::insertDTMF(const String& tones, long duration, long interTon
eGap, ExceptionState& exceptionState) |
| 102 { | 102 { |
| 103 if (!canInsertDTMF()) { | 103 if (!canInsertDTMF()) { |
| 104 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 104 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); |
| 105 return; | 105 return; |
| 106 } | 106 } |
| 107 | 107 |
| 108 if (duration > maxToneDurationMs || duration < minToneDurationMs) { | 108 if (duration > maxToneDurationMs || duration < minToneDurationMs) { |
| 109 es.throwUninformativeAndGenericDOMException(SyntaxError); | 109 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); |
| 110 return; | 110 return; |
| 111 } | 111 } |
| 112 | 112 |
| 113 if (interToneGap < minInterToneGapMs) { | 113 if (interToneGap < minInterToneGapMs) { |
| 114 es.throwUninformativeAndGenericDOMException(SyntaxError); | 114 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); |
| 115 return; | 115 return; |
| 116 } | 116 } |
| 117 | 117 |
| 118 m_duration = duration; | 118 m_duration = duration; |
| 119 m_interToneGap = interToneGap; | 119 m_interToneGap = interToneGap; |
| 120 | 120 |
| 121 if (!m_handler->insertDTMF(tones, m_duration, m_interToneGap)) | 121 if (!m_handler->insertDTMF(tones, m_duration, m_interToneGap)) |
| 122 es.throwUninformativeAndGenericDOMException(SyntaxError); | 122 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void RTCDTMFSender::didPlayTone(const String& tone) | 125 void RTCDTMFSender::didPlayTone(const String& tone) |
| 126 { | 126 { |
| 127 scheduleDispatchEvent(RTCDTMFToneChangeEvent::create(tone)); | 127 scheduleDispatchEvent(RTCDTMFToneChangeEvent::create(tone)); |
| 128 } | 128 } |
| 129 | 129 |
| 130 const AtomicString& RTCDTMFSender::interfaceName() const | 130 const AtomicString& RTCDTMFSender::interfaceName() const |
| 131 { | 131 { |
| 132 return EventTargetNames::RTCDTMFSender; | 132 return EventTargetNames::RTCDTMFSender; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 158 | 158 |
| 159 Vector<RefPtr<Event> > events; | 159 Vector<RefPtr<Event> > events; |
| 160 events.swap(m_scheduledEvents); | 160 events.swap(m_scheduledEvents); |
| 161 | 161 |
| 162 Vector<RefPtr<Event> >::iterator it = events.begin(); | 162 Vector<RefPtr<Event> >::iterator it = events.begin(); |
| 163 for (; it != events.end(); ++it) | 163 for (; it != events.end(); ++it) |
| 164 dispatchEvent((*it).release()); | 164 dispatchEvent((*it).release()); |
| 165 } | 165 } |
| 166 | 166 |
| 167 } // namespace WebCore | 167 } // namespace WebCore |
| OLD | NEW |