| 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 20 matching lines...) Expand all  Loading... | 
| 31 #include "core/dom/ExceptionCode.h" | 31 #include "core/dom/ExceptionCode.h" | 
| 32 #include "core/dom/ExecutionContext.h" | 32 #include "core/dom/ExecutionContext.h" | 
| 33 #include "modules/mediastream/MediaStreamTrack.h" | 33 #include "modules/mediastream/MediaStreamTrack.h" | 
| 34 #include "modules/mediastream/RTCDTMFToneChangeEvent.h" | 34 #include "modules/mediastream/RTCDTMFToneChangeEvent.h" | 
| 35 #include "public/platform/WebMediaStreamTrack.h" | 35 #include "public/platform/WebMediaStreamTrack.h" | 
| 36 #include "public/platform/WebRTCDTMFSenderHandler.h" | 36 #include "public/platform/WebRTCDTMFSenderHandler.h" | 
| 37 #include "public/platform/WebRTCPeerConnectionHandler.h" | 37 #include "public/platform/WebRTCPeerConnectionHandler.h" | 
| 38 | 38 | 
| 39 namespace WebCore { | 39 namespace WebCore { | 
| 40 | 40 | 
|  | 41 DEFINE_GC_INFO(RTCDTMFSender); | 
|  | 42 | 
| 41 static const long minToneDurationMs = 70; | 43 static const long minToneDurationMs = 70; | 
| 42 static const long defaultToneDurationMs = 100; | 44 static const long defaultToneDurationMs = 100; | 
| 43 static const long maxToneDurationMs = 6000; | 45 static const long maxToneDurationMs = 6000; | 
| 44 static const long minInterToneGapMs = 50; | 46 static const long minInterToneGapMs = 50; | 
| 45 static const long defaultInterToneGapMs = 50; | 47 static const long defaultInterToneGapMs = 50; | 
| 46 | 48 | 
| 47 PassRefPtr<RTCDTMFSender> RTCDTMFSender::create(ExecutionContext* context, blink
     ::WebRTCPeerConnectionHandler* peerConnectionHandler, PassRefPtr<MediaStreamTrac
     k> prpTrack, ExceptionState& exceptionState) | 49 PassRefPtrWillBeRawPtr<RTCDTMFSender> RTCDTMFSender::create(ExecutionContext* co
     ntext, blink::WebRTCPeerConnectionHandler* peerConnectionHandler, PassRefPtrWill
     BeRawPtr<MediaStreamTrack> prpTrack, ExceptionState& exceptionState) | 
| 48 { | 50 { | 
| 49     RefPtr<MediaStreamTrack> track = prpTrack; | 51     RefPtrWillBeRawPtr<MediaStreamTrack> track = prpTrack; | 
| 50     OwnPtr<blink::WebRTCDTMFSenderHandler> handler = adoptPtr(peerConnectionHand
     ler->createDTMFSender(track->component())); | 52     OwnPtr<blink::WebRTCDTMFSenderHandler> handler = adoptPtr(peerConnectionHand
     ler->createDTMFSender(track->component())); | 
| 51     if (!handler) { | 53     if (!handler) { | 
| 52         exceptionState.throwDOMException(NotSupportedError, "The MediaStreamTrac
     k provided is not an element of a MediaStream that's currently in the local stre
     ams set."); | 54         exceptionState.throwDOMException(NotSupportedError, "The MediaStreamTrac
     k provided is not an element of a MediaStream that's currently in the local stre
     ams set."); | 
| 53         return 0; | 55         return 0; | 
| 54     } | 56     } | 
| 55 | 57 | 
| 56     RefPtr<RTCDTMFSender> dtmfSender = adoptRef(new RTCDTMFSender(context, track
     , handler.release())); | 58     RefPtrWillBeRawPtr<RTCDTMFSender> dtmfSender = adoptRefCountedWillBeRefCount
     edGarbageCollected(new RTCDTMFSender(context, track, handler.release())); | 
| 57     dtmfSender->suspendIfNeeded(); | 59     dtmfSender->suspendIfNeeded(); | 
| 58     return dtmfSender.release(); | 60     return dtmfSender.release(); | 
| 59 } | 61 } | 
| 60 | 62 | 
| 61 RTCDTMFSender::RTCDTMFSender(ExecutionContext* context, PassRefPtr<MediaStreamTr
     ack> track, PassOwnPtr<blink::WebRTCDTMFSenderHandler> handler) | 63 RTCDTMFSender::RTCDTMFSender(ExecutionContext* context, PassRefPtrWillBeRawPtr<M
     ediaStreamTrack> track, PassOwnPtr<blink::WebRTCDTMFSenderHandler> handler) | 
| 62     : ActiveDOMObject(context) | 64     : ActiveDOMObject(context) | 
| 63     , m_track(track) | 65     , m_track(track) | 
| 64     , m_duration(defaultToneDurationMs) | 66     , m_duration(defaultToneDurationMs) | 
| 65     , m_interToneGap(defaultInterToneGapMs) | 67     , m_interToneGap(defaultInterToneGapMs) | 
| 66     , m_handler(handler) | 68     , m_handler(handler) | 
| 67     , m_stopped(false) | 69     , m_stopped(false) | 
| 68     , m_scheduledEventTimer(this, &RTCDTMFSender::scheduledEventTimerFired) | 70     , m_scheduledEventTimer(this, &RTCDTMFSender::scheduledEventTimerFired) | 
| 69 { | 71 { | 
| 70     ScriptWrappable::init(this); | 72     ScriptWrappable::init(this); | 
| 71     m_handler->setClient(this); | 73     m_handler->setClient(this); | 
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 159         return; | 161         return; | 
| 160 | 162 | 
| 161     Vector<RefPtr<Event> > events; | 163     Vector<RefPtr<Event> > events; | 
| 162     events.swap(m_scheduledEvents); | 164     events.swap(m_scheduledEvents); | 
| 163 | 165 | 
| 164     Vector<RefPtr<Event> >::iterator it = events.begin(); | 166     Vector<RefPtr<Event> >::iterator it = events.begin(); | 
| 165     for (; it != events.end(); ++it) | 167     for (; it != events.end(); ++it) | 
| 166         dispatchEvent((*it).release()); | 168         dispatchEvent((*it).release()); | 
| 167 } | 169 } | 
| 168 | 170 | 
|  | 171 void RTCDTMFSender::trace(Visitor* visitor) | 
|  | 172 { | 
|  | 173     visitor->trace(m_track); | 
|  | 174 } | 
|  | 175 | 
| 169 } // namespace WebCore | 176 } // namespace WebCore | 
| OLD | NEW | 
|---|