| 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 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 #include "bindings/core/v8/ExceptionMessages.h" | 28 #include "bindings/core/v8/ExceptionMessages.h" |
| 29 #include "bindings/core/v8/ExceptionState.h" | 29 #include "bindings/core/v8/ExceptionState.h" |
| 30 #include "core/dom/ExceptionCode.h" | 30 #include "core/dom/ExceptionCode.h" |
| 31 #include "core/dom/ExecutionContext.h" | 31 #include "core/dom/ExecutionContext.h" |
| 32 #include "modules/mediastream/MediaStreamTrack.h" | 32 #include "modules/mediastream/MediaStreamTrack.h" |
| 33 #include "modules/mediastream/RTCDTMFToneChangeEvent.h" | 33 #include "modules/mediastream/RTCDTMFToneChangeEvent.h" |
| 34 #include "public/platform/WebMediaStreamTrack.h" | 34 #include "public/platform/WebMediaStreamTrack.h" |
| 35 #include "public/platform/WebRTCDTMFSenderHandler.h" | 35 #include "public/platform/WebRTCDTMFSenderHandler.h" |
| 36 #include "public/platform/WebRTCPeerConnectionHandler.h" | 36 #include "public/platform/WebRTCPeerConnectionHandler.h" |
| 37 #include "wtf/PtrUtil.h" | |
| 38 #include <memory> | |
| 39 | 37 |
| 40 namespace blink { | 38 namespace blink { |
| 41 | 39 |
| 42 static const int minToneDurationMs = 70; | 40 static const int minToneDurationMs = 70; |
| 43 static const int defaultToneDurationMs = 100; | 41 static const int defaultToneDurationMs = 100; |
| 44 static const int maxToneDurationMs = 6000; | 42 static const int maxToneDurationMs = 6000; |
| 45 static const int minInterToneGapMs = 50; | 43 static const int minInterToneGapMs = 50; |
| 46 static const int defaultInterToneGapMs = 50; | 44 static const int defaultInterToneGapMs = 50; |
| 47 | 45 |
| 48 RTCDTMFSender* RTCDTMFSender::create(ExecutionContext* context, WebRTCPeerConnec
tionHandler* peerConnectionHandler, MediaStreamTrack* track, ExceptionState& exc
eptionState) | 46 RTCDTMFSender* RTCDTMFSender::create(ExecutionContext* context, WebRTCPeerConnec
tionHandler* peerConnectionHandler, MediaStreamTrack* track, ExceptionState& exc
eptionState) |
| 49 { | 47 { |
| 50 std::unique_ptr<WebRTCDTMFSenderHandler> handler = wrapUnique(peerConnection
Handler->createDTMFSender(track->component())); | 48 OwnPtr<WebRTCDTMFSenderHandler> handler = adoptPtr(peerConnectionHandler->cr
eateDTMFSender(track->component())); |
| 51 if (!handler) { | 49 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."); | 50 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 nullptr; | 51 return nullptr; |
| 54 } | 52 } |
| 55 | 53 |
| 56 RTCDTMFSender* dtmfSender = new RTCDTMFSender(context, track, std::move(hand
ler)); | 54 RTCDTMFSender* dtmfSender = new RTCDTMFSender(context, track, std::move(hand
ler)); |
| 57 dtmfSender->suspendIfNeeded(); | 55 dtmfSender->suspendIfNeeded(); |
| 58 return dtmfSender; | 56 return dtmfSender; |
| 59 } | 57 } |
| 60 | 58 |
| 61 RTCDTMFSender::RTCDTMFSender(ExecutionContext* context, MediaStreamTrack* track,
std::unique_ptr<WebRTCDTMFSenderHandler> handler) | 59 RTCDTMFSender::RTCDTMFSender(ExecutionContext* context, MediaStreamTrack* track,
PassOwnPtr<WebRTCDTMFSenderHandler> handler) |
| 62 : ActiveDOMObject(context) | 60 : ActiveDOMObject(context) |
| 63 , m_track(track) | 61 , m_track(track) |
| 64 , m_duration(defaultToneDurationMs) | 62 , m_duration(defaultToneDurationMs) |
| 65 , m_interToneGap(defaultInterToneGapMs) | 63 , m_interToneGap(defaultInterToneGapMs) |
| 66 , m_handler(std::move(handler)) | 64 , m_handler(std::move(handler)) |
| 67 , m_stopped(false) | 65 , m_stopped(false) |
| 68 , m_scheduledEventTimer(this, &RTCDTMFSender::scheduledEventTimerFired) | 66 , m_scheduledEventTimer(this, &RTCDTMFSender::scheduledEventTimerFired) |
| 69 { | 67 { |
| 70 ThreadState::current()->registerPreFinalizer(this); | 68 ThreadState::current()->registerPreFinalizer(this); |
| 71 m_handler->setClient(this); | 69 m_handler->setClient(this); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 | 174 |
| 177 DEFINE_TRACE(RTCDTMFSender) | 175 DEFINE_TRACE(RTCDTMFSender) |
| 178 { | 176 { |
| 179 visitor->trace(m_track); | 177 visitor->trace(m_track); |
| 180 visitor->trace(m_scheduledEvents); | 178 visitor->trace(m_scheduledEvents); |
| 181 EventTargetWithInlineData::trace(visitor); | 179 EventTargetWithInlineData::trace(visitor); |
| 182 ActiveDOMObject::trace(visitor); | 180 ActiveDOMObject::trace(visitor); |
| 183 } | 181 } |
| 184 | 182 |
| 185 } // namespace blink | 183 } // namespace blink |
| OLD | NEW |