Commit 3dbbd139 authored by tommyw@google.com's avatar tommyw@google.com

MediaStream API: Implement DTMF support in RTCPeerConnection

https://bugs.webkit.org/show_bug.cgi?id=106782

Reviewed by Adam Barth.

Source/Platform:

The WebRTC specification have added support for DTMF:
http://dev.w3.org/2011/webrtc/editor/webrtc.html#peer-to-peer-dtmf

Implementation wise this is implemented using the same pattern as RTCDataChannel;
where a RTCDTMFSenderHandler is created by the UA through a new method on
RTCPeerConnectionHandler.

* Platform.gypi:
* chromium/public/WebMediaStreamTrack.h:
(WebMediaStreamTrack):
* chromium/public/WebRTCDTMFSenderHandler.h: Copied from Source/Platform/chromium/public/WebMediaStreamTrack.h.
(WebKit):
(WebRTCDTMFSenderHandler):
(WebKit::WebRTCDTMFSenderHandler::~WebRTCDTMFSenderHandler):
* chromium/public/WebRTCDTMFSenderHandlerClient.h: Copied from Source/Platform/chromium/public/WebMediaStreamTrack.h.
(WebKit):
(WebRTCDTMFSenderHandlerClient):
(WebKit::WebRTCDTMFSenderHandlerClient::~WebRTCDTMFSenderHandlerClient):
* chromium/public/WebRTCPeerConnectionHandler.h:
(WebKit):
(WebKit::WebRTCPeerConnectionHandler::createDTMFSender):

Source/WebCore:

The WebRTC specification have added support for DTMF:
http://dev.w3.org/2011/webrtc/editor/webrtc.html#peer-to-peer-dtmf

Implementation wise this is implemented using the same pattern as RTCDataChannel;
where a RTCDTMFSenderHandler is created by the UA through a new method on
RTCPeerConnectionHandler.

Test: fast/mediastream/RTCPeerConnection-dtmf.html

* CMakeLists.txt:
* GNUmakefile.list.am:
* Modules/mediastream/RTCDTMFSender.cpp: Added.
(WebCore):
(WebCore::RTCDTMFSender::create):
(WebCore::RTCDTMFSender::RTCDTMFSender):
(WebCore::RTCDTMFSender::~RTCDTMFSender):
(WebCore::RTCDTMFSender::canInsertDTMF):
(WebCore::RTCDTMFSender::track):
(WebCore::RTCDTMFSender::toneBuffer):
(WebCore::RTCDTMFSender::insertDTMF):
(WebCore::RTCDTMFSender::didPlayTone):
(WebCore::RTCDTMFSender::interfaceName):
(WebCore::RTCDTMFSender::scriptExecutionContext):
(WebCore::RTCDTMFSender::stop):
(WebCore::RTCDTMFSender::eventTargetData):
(WebCore::RTCDTMFSender::ensureEventTargetData):
(WebCore::RTCDTMFSender::scheduleDispatchEvent):
(WebCore::RTCDTMFSender::scheduledEventTimerFired):
* Modules/mediastream/RTCDTMFSender.h: Added.
(WebCore):
(RTCDTMFSender):
(WebCore::RTCDTMFSender::duration):
(WebCore::RTCDTMFSender::interToneGap):
* Modules/mediastream/RTCDTMFSender.idl: Added.
* Modules/mediastream/RTCDTMFToneChangeEvent.cpp: Copied from Source/Platform/chromium/public/WebMediaStreamTrack.h.
(WebCore):
(WebCore::RTCDTMFToneChangeEvent::create):
(WebCore::RTCDTMFToneChangeEvent::RTCDTMFToneChangeEvent):
(WebCore::RTCDTMFToneChangeEvent::~RTCDTMFToneChangeEvent):
(WebCore::RTCDTMFToneChangeEvent::tone):
(WebCore::RTCDTMFToneChangeEvent::interfaceName):
* Modules/mediastream/RTCDTMFToneChangeEvent.h: Copied from Source/Platform/chromium/public/WebMediaStreamTrack.h.
(WebCore):
(RTCDTMFToneChangeEventInit):
(RTCDTMFToneChangeEvent):
* Modules/mediastream/RTCDTMFToneChangeEvent.idl: Added.
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::createDataChannel):
(WebCore):
(WebCore::RTCPeerConnection::getStreamByTrackId):
(WebCore::RTCPeerConnection::createDTMFSender):
* Modules/mediastream/RTCPeerConnection.h:
(WebCore):
(RTCPeerConnection):
* Modules/mediastream/RTCPeerConnection.idl:
* WebCore.gypi:
* dom/EventNames.h:
(WebCore):
* dom/EventNames.in:
* dom/EventTargetFactory.in:
* platform/chromium/support/WebMediaStreamTrack.cpp:
(WebKit::WebMediaStreamTrack::WebMediaStreamTrack):
(WebKit):
* platform/mediastream/RTCDTMFSenderHandler.h: Copied from Source/Platform/chromium/public/WebMediaStreamTrack.h.
(WebCore):
(RTCDTMFSenderHandler):
(WebCore::RTCDTMFSenderHandler::~RTCDTMFSenderHandler):
* platform/mediastream/RTCDTMFSenderHandlerClient.h: Copied from Source/Platform/chromium/public/WebMediaStreamTrack.h.
(WebCore):
(RTCDTMFSenderHandlerClient):
(WebCore::RTCDTMFSenderHandlerClient::~RTCDTMFSenderHandlerClient):
* platform/mediastream/RTCPeerConnectionHandler.h:
(WebCore):
(RTCPeerConnectionHandler):
* platform/mediastream/chromium/RTCDTMFSenderHandlerChromium.cpp: Copied from Source/Platform/chromium/public/WebMediaStreamTrack.h.
(WebCore):
(WebCore::RTCDTMFSenderHandlerChromium::create):
(WebCore::RTCDTMFSenderHandlerChromium::RTCDTMFSenderHandlerChromium):
(WebCore::RTCDTMFSenderHandlerChromium::~RTCDTMFSenderHandlerChromium):
(WebCore::RTCDTMFSenderHandlerChromium::setClient):
(WebCore::RTCDTMFSenderHandlerChromium::currentToneBuffer):
(WebCore::RTCDTMFSenderHandlerChromium::canInsertDTMF):
(WebCore::RTCDTMFSenderHandlerChromium::insertDTMF):
(WebCore::RTCDTMFSenderHandlerChromium::didPlayTone):
* platform/mediastream/chromium/RTCDTMFSenderHandlerChromium.h: Copied from Source/Platform/chromium/public/WebMediaStreamTrack.h.
(WebCore):
(RTCDTMFSenderHandlerChromium):
* platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp:
(WebCore::RTCPeerConnectionHandlerChromium::createDTMFSender):
(WebCore):
* platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h:
(RTCPeerConnectionHandlerChromium):

Tools:

Adding Mock functionality for the DTMFSender.

* DumpRenderTree/DumpRenderTree.gypi:
* DumpRenderTree/chromium/MockWebRTCDTMFSenderHandler.cpp: Added.
(DTMFSenderToneTask):
(DTMFSenderToneTask::DTMFSenderToneTask):
(MockWebRTCDTMFSenderHandler::MockWebRTCDTMFSenderHandler):
(MockWebRTCDTMFSenderHandler::setClient):
(MockWebRTCDTMFSenderHandler::currentToneBuffer):
(MockWebRTCDTMFSenderHandler::canInsertDTMF):
(MockWebRTCDTMFSenderHandler::insertDTMF):
* DumpRenderTree/chromium/MockWebRTCDTMFSenderHandler.h: Copied from Source/Platform/chromium/public/WebMediaStreamTrack.h.
(MockWebRTCDTMFSenderHandler):
(MockWebRTCDTMFSenderHandler::taskList):
(MockWebRTCDTMFSenderHandler::clearToneBuffer):
* DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.cpp:
(MockWebRTCPeerConnectionHandler::createDTMFSender):
* DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.h:
(MockWebRTCPeerConnectionHandler):

LayoutTests:

* fast/mediastream/RTCPeerConnection-dtmf-expected.txt: Added.
* fast/mediastream/RTCPeerConnection-dtmf.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@141984 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8e6574a7
2013-02-06 Tommy Widenflycht <tommyw@google.com>
MediaStream API: Implement DTMF support in RTCPeerConnection
https://bugs.webkit.org/show_bug.cgi?id=106782
Reviewed by Adam Barth.
* fast/mediastream/RTCPeerConnection-dtmf-expected.txt: Added.
* fast/mediastream/RTCPeerConnection-dtmf.html: Added.
2013-02-06 Mihai Maerean <mmaerean@adobe.com>
[CSSRegions] Assertion failure in Node::detach (!renderer || renderer->inRenderFlowThread())
Tests RTCDTMFSender.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS navigator.webkitGetUserMedia({audio:true}, gotStream, error); did not throw exception.
PASS Stream generated.
PASS stream.getAudioTracks().length is 1
PASS stream.getVideoTracks().length is 0
PASS pc is connected
PASS dtmfsender = pc.createDTMFSender(track); threw exception Error: SyntaxError: DOM Exception 12.
PASS dtmfsender = pc.createDTMFSender(track); did not throw exception.
PASS dtmfsender.canInsertDTMF is true
PASS dtmfsender.toneBuffer is "1"
PASS ontonechange was called.
PASS event.tone is "1"
PASS ontonechange was called.
PASS event.tone is ""
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../js/resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("Tests RTCDTMFSender.");
var pc = null;
var stream = null;
var dtmfsender = null;
function error() {
testFailed('Error callback called.');
finishJSTest();
}
var firstCall = true;
function ontonechange(e) {
testPassed("ontonechange was called.");
event = e;
if (firstCall) {
shouldBeEqualToString('event.tone', "1");
firstCall = false;
} else {
shouldBeEqualToString('event.tone', "");
finishJSTest();
}
}
function pc_onicechange() {
if (pc.iceConnectionState === "completed") {
testPassed("pc is connected");
track = stream.getAudioTracks()[0];
shouldThrow('dtmfsender = pc.createDTMFSender(track);');
pc.addStream(stream);
shouldNotThrow('dtmfsender = pc.createDTMFSender(track);');
shouldBeTrue('dtmfsender.canInsertDTMF');
dtmfsender.ontonechange = ontonechange;
dtmfsender.insertDTMF("1");
shouldBeEqualToString('dtmfsender.toneBuffer', "1");
}
}
function gotStream(s) {
stream = s;
testPassed('Stream generated.');
shouldBe('stream.getAudioTracks().length', '1');
shouldBe('stream.getVideoTracks().length', '0');
pc = new webkitRTCPeerConnection(null, null);
pc.onicechange = pc_onicechange;
}
shouldNotThrow("navigator.webkitGetUserMedia({audio:true}, gotStream, error);");
window.jsTestIsAsync = true;
window.successfullyParsed = true;
</script>
<script src="../js/resources/js-test-post.js"></script>
</body>
</html>
2013-02-06 Tommy Widenflycht <tommyw@google.com>
MediaStream API: Implement DTMF support in RTCPeerConnection
https://bugs.webkit.org/show_bug.cgi?id=106782
Reviewed by Adam Barth.
The WebRTC specification have added support for DTMF:
http://dev.w3.org/2011/webrtc/editor/webrtc.html#peer-to-peer-dtmf
Implementation wise this is implemented using the same pattern as RTCDataChannel;
where a RTCDTMFSenderHandler is created by the UA through a new method on
RTCPeerConnectionHandler.
* Platform.gypi:
* chromium/public/WebMediaStreamTrack.h:
(WebMediaStreamTrack):
* chromium/public/WebRTCDTMFSenderHandler.h: Copied from Source/Platform/chromium/public/WebMediaStreamTrack.h.
(WebKit):
(WebRTCDTMFSenderHandler):
(WebKit::WebRTCDTMFSenderHandler::~WebRTCDTMFSenderHandler):
* chromium/public/WebRTCDTMFSenderHandlerClient.h: Copied from Source/Platform/chromium/public/WebMediaStreamTrack.h.
(WebKit):
(WebRTCDTMFSenderHandlerClient):
(WebKit::WebRTCDTMFSenderHandlerClient::~WebRTCDTMFSenderHandlerClient):
* chromium/public/WebRTCPeerConnectionHandler.h:
(WebKit):
(WebKit::WebRTCPeerConnectionHandler::createDTMFSender):
2013-02-05 Dana Jansens <danakj@chromium.org>
[chromium] Provide compositor offscreen context through the WebLayerTreeViewClient interface
......
......@@ -102,6 +102,8 @@
'chromium/public/WebPrivateOwnPtr.h',
'chromium/public/WebPrivatePtr.h',
'chromium/public/WebRTCConfiguration.h',
'chromium/public/WebRTCDTMFSenderHandler.h',
'chromium/public/WebRTCDTMFSenderHandlerClient.h',
'chromium/public/WebRTCDataChannelHandler.h',
'chromium/public/WebRTCDataChannelHandlerClient.h',
'chromium/public/WebRTCICECandidate.h',
......
......@@ -61,6 +61,7 @@ public:
WEBKIT_EXPORT bool isEnabled() const;
#if WEBKIT_IMPLEMENTATION
WebMediaStreamTrack(PassRefPtr<WebCore::MediaStreamComponent>);
WebMediaStreamTrack(WebCore::MediaStreamComponent*);
WebMediaStreamTrack& operator=(WebCore::MediaStreamComponent*);
operator WTF::PassRefPtr<WebCore::MediaStreamComponent>() const;
......
/*
* Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WebRTCDTMFSenderHandler_h
#define WebRTCDTMFSenderHandler_h
#include "WebCommon.h"
#include "WebString.h"
namespace WebKit {
class WebRTCDTMFSenderHandlerClient;
class WebRTCDTMFSenderHandler {
public:
virtual ~WebRTCDTMFSenderHandler() { }
virtual void setClient(WebRTCDTMFSenderHandlerClient*) = 0;
virtual WebString currentToneBuffer() = 0;
virtual bool canInsertDTMF() = 0;
virtual bool insertDTMF(const WebString& tones, long duration, long interToneGap) = 0;
};
} // namespace WebKit
#endif // WebRTCDTMFSenderHandler_h
/*
* Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WebRTCDTMFSenderHandlerClient_h
#define WebRTCDTMFSenderHandlerClient_h
#include "WebCommon.h"
namespace WebKit {
class WebRTCDTMFSenderHandlerClient {
public:
virtual ~WebRTCDTMFSenderHandlerClient() { }
virtual void didPlayTone(const WebString& tone) const = 0;
};
} // namespace WebKit
#endif // WebRTCDTMFSenderHandlerClient_h
......@@ -34,7 +34,9 @@
namespace WebKit {
class WebMediaConstraints;
class WebMediaStream;
class WebMediaStreamTrack;
class WebRTCConfiguration;
class WebRTCDTMFSenderHandler;
class WebRTCDataChannelHandler;
class WebRTCICECandidate;
class WebRTCPeerConnectionHandlerClient;
......@@ -63,6 +65,7 @@ public:
// FIXME: Remove default implementation when clients have changed.
virtual void getStats(const WebRTCStatsRequest&) { }
virtual WebRTCDataChannelHandler* createDataChannel(const WebString& label, bool reliable) { return 0; }
virtual WebRTCDTMFSenderHandler* createDTMFSender(const WebMediaStreamTrack& track) { return 0; }
virtual void stop() = 0;
};
......
......@@ -222,6 +222,8 @@ set(WebCore_IDL_FILES
Modules/mediastream/NavigatorUserMediaError.idl
Modules/mediastream/NavigatorUserMediaErrorCallback.idl
Modules/mediastream/NavigatorUserMediaSuccessCallback.idl
Modules/mediastream/RTCDTMFSender.idl
Modules/mediastream/RTCDTMFToneChangeEvent.idl
Modules/mediastream/RTCDataChannel.idl
Modules/mediastream/RTCDataChannelEvent.idl
Modules/mediastream/RTCErrorCallback.idl
......@@ -863,6 +865,8 @@ set(WebCore_SOURCES
Modules/mediastream/MediaStreamTrack.cpp
Modules/mediastream/MediaStreamTrackEvent.cpp
Modules/mediastream/NavigatorMediaStream.cpp
Modules/mediastream/RTCDTMFSender.cpp
Modules/mediastream/RTCDTMFToneChangeEvent.cpp
Modules/mediastream/RTCDataChannel.cpp
Modules/mediastream/RTCDataChannelEvent.cpp
Modules/mediastream/RTCIceCandidate.cpp
......
2013-02-06 Tommy Widenflycht <tommyw@google.com>
MediaStream API: Implement DTMF support in RTCPeerConnection
https://bugs.webkit.org/show_bug.cgi?id=106782
Reviewed by Adam Barth.
The WebRTC specification have added support for DTMF:
http://dev.w3.org/2011/webrtc/editor/webrtc.html#peer-to-peer-dtmf
Implementation wise this is implemented using the same pattern as RTCDataChannel;
where a RTCDTMFSenderHandler is created by the UA through a new method on
RTCPeerConnectionHandler.
Test: fast/mediastream/RTCPeerConnection-dtmf.html
* CMakeLists.txt:
* GNUmakefile.list.am:
* Modules/mediastream/RTCDTMFSender.cpp: Added.
(WebCore):
(WebCore::RTCDTMFSender::create):
(WebCore::RTCDTMFSender::RTCDTMFSender):
(WebCore::RTCDTMFSender::~RTCDTMFSender):
(WebCore::RTCDTMFSender::canInsertDTMF):
(WebCore::RTCDTMFSender::track):
(WebCore::RTCDTMFSender::toneBuffer):
(WebCore::RTCDTMFSender::insertDTMF):
(WebCore::RTCDTMFSender::didPlayTone):
(WebCore::RTCDTMFSender::interfaceName):
(WebCore::RTCDTMFSender::scriptExecutionContext):
(WebCore::RTCDTMFSender::stop):
(WebCore::RTCDTMFSender::eventTargetData):
(WebCore::RTCDTMFSender::ensureEventTargetData):
(WebCore::RTCDTMFSender::scheduleDispatchEvent):
(WebCore::RTCDTMFSender::scheduledEventTimerFired):
* Modules/mediastream/RTCDTMFSender.h: Added.
(WebCore):
(RTCDTMFSender):
(WebCore::RTCDTMFSender::duration):
(WebCore::RTCDTMFSender::interToneGap):
* Modules/mediastream/RTCDTMFSender.idl: Added.
* Modules/mediastream/RTCDTMFToneChangeEvent.cpp: Copied from Source/Platform/chromium/public/WebMediaStreamTrack.h.
(WebCore):
(WebCore::RTCDTMFToneChangeEvent::create):
(WebCore::RTCDTMFToneChangeEvent::RTCDTMFToneChangeEvent):
(WebCore::RTCDTMFToneChangeEvent::~RTCDTMFToneChangeEvent):
(WebCore::RTCDTMFToneChangeEvent::tone):
(WebCore::RTCDTMFToneChangeEvent::interfaceName):
* Modules/mediastream/RTCDTMFToneChangeEvent.h: Copied from Source/Platform/chromium/public/WebMediaStreamTrack.h.
(WebCore):
(RTCDTMFToneChangeEventInit):
(RTCDTMFToneChangeEvent):
* Modules/mediastream/RTCDTMFToneChangeEvent.idl: Added.
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::createDataChannel):
(WebCore):
(WebCore::RTCPeerConnection::getStreamByTrackId):
(WebCore::RTCPeerConnection::createDTMFSender):
* Modules/mediastream/RTCPeerConnection.h:
(WebCore):
(RTCPeerConnection):
* Modules/mediastream/RTCPeerConnection.idl:
* WebCore.gypi:
* dom/EventNames.h:
(WebCore):
* dom/EventNames.in:
* dom/EventTargetFactory.in:
* platform/chromium/support/WebMediaStreamTrack.cpp:
(WebKit::WebMediaStreamTrack::WebMediaStreamTrack):
(WebKit):
* platform/mediastream/RTCDTMFSenderHandler.h: Copied from Source/Platform/chromium/public/WebMediaStreamTrack.h.
(WebCore):
(RTCDTMFSenderHandler):
(WebCore::RTCDTMFSenderHandler::~RTCDTMFSenderHandler):
* platform/mediastream/RTCDTMFSenderHandlerClient.h: Copied from Source/Platform/chromium/public/WebMediaStreamTrack.h.
(WebCore):
(RTCDTMFSenderHandlerClient):
(WebCore::RTCDTMFSenderHandlerClient::~RTCDTMFSenderHandlerClient):
* platform/mediastream/RTCPeerConnectionHandler.h:
(WebCore):
(RTCPeerConnectionHandler):
* platform/mediastream/chromium/RTCDTMFSenderHandlerChromium.cpp: Copied from Source/Platform/chromium/public/WebMediaStreamTrack.h.
(WebCore):
(WebCore::RTCDTMFSenderHandlerChromium::create):
(WebCore::RTCDTMFSenderHandlerChromium::RTCDTMFSenderHandlerChromium):
(WebCore::RTCDTMFSenderHandlerChromium::~RTCDTMFSenderHandlerChromium):
(WebCore::RTCDTMFSenderHandlerChromium::setClient):
(WebCore::RTCDTMFSenderHandlerChromium::currentToneBuffer):
(WebCore::RTCDTMFSenderHandlerChromium::canInsertDTMF):
(WebCore::RTCDTMFSenderHandlerChromium::insertDTMF):
(WebCore::RTCDTMFSenderHandlerChromium::didPlayTone):
* platform/mediastream/chromium/RTCDTMFSenderHandlerChromium.h: Copied from Source/Platform/chromium/public/WebMediaStreamTrack.h.
(WebCore):
(RTCDTMFSenderHandlerChromium):
* platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp:
(WebCore::RTCPeerConnectionHandlerChromium::createDTMFSender):
(WebCore):
* platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h:
(RTCPeerConnectionHandlerChromium):
2013-02-04 Kentaro Hara <haraken@chromium.org>
[V8] Remove V8GCController::m_edenNodes and make minor DOM GC more precise
......@@ -631,6 +631,10 @@ webcore_built_sources += \
DerivedSources/WebCore/JSRequestAnimationFrameCallback.h \
DerivedSources/WebCore/JSRGBColor.cpp \
DerivedSources/WebCore/JSRGBColor.h \
DerivedSources/WebCore/JSRTCDTMFSender.cpp \
DerivedSources/WebCore/JSRTCDTMFSender.h \
DerivedSources/WebCore/JSRTCDTMFToneChangeEvent.cpp \
DerivedSources/WebCore/JSRTCDTMFToneChangeEvent.h \
DerivedSources/WebCore/JSRTCDataChannel.cpp \
DerivedSources/WebCore/JSRTCDataChannel.h \
DerivedSources/WebCore/JSRTCDataChannelEvent.cpp \
......@@ -1243,6 +1247,8 @@ dom_binding_idls += \
$(WebCore)/Modules/mediastream/NavigatorUserMediaError.idl \
$(WebCore)/Modules/mediastream/NavigatorUserMediaErrorCallback.idl \
$(WebCore)/Modules/mediastream/NavigatorUserMediaSuccessCallback.idl \
$(WebCore)/Modules/mediastream/RTCDTMFSender.idl \
$(WebCore)/Modules/mediastream/RTCDTMFToneChangeEvent.idl \
$(WebCore)/Modules/mediastream/RTCDataChannel.idl \
$(WebCore)/Modules/mediastream/RTCDataChannelEvent.idl \
$(WebCore)/Modules/mediastream/RTCErrorCallback.idl \
......@@ -1937,6 +1943,10 @@ webcore_modules_sources += \
Source/WebCore/Modules/mediastream/NavigatorUserMediaError.h \
Source/WebCore/Modules/mediastream/NavigatorUserMediaErrorCallback.h \
Source/WebCore/Modules/mediastream/NavigatorUserMediaSuccessCallback.h \
Source/WebCore/Modules/mediastream/RTCDTMFSender.cpp \
Source/WebCore/Modules/mediastream/RTCDTMFSender.h \
Source/WebCore/Modules/mediastream/RTCDTMFToneChangeEvent.cpp \
Source/WebCore/Modules/mediastream/RTCDTMFToneChangeEvent.h \
Source/WebCore/Modules/mediastream/RTCDataChannel.cpp \
Source/WebCore/Modules/mediastream/RTCDataChannel.h \
Source/WebCore/Modules/mediastream/RTCDataChannelEvent.cpp \
......@@ -5762,6 +5772,8 @@ webcore_platform_sources += \
Source/WebCore/platform/mediastream/MediaStreamSource.h \
Source/WebCore/platform/mediastream/MediaStreamSourcesQueryClient.h \
Source/WebCore/platform/mediastream/RTCConfiguration.h \
Source/WebCore/platform/mediastream/RTCDTMFSenderHandler.h \
Source/WebCore/platform/mediastream/RTCDTMFSenderHandlerClient.h \
Source/WebCore/platform/mediastream/RTCDataChannelHandler.h \
Source/WebCore/platform/mediastream/RTCDataChannelHandlerClient.h \
Source/WebCore/platform/mediastream/RTCIceCandidateDescriptor.cpp \
......
/*
* Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#if ENABLE(MEDIA_STREAM)
#include "RTCDTMFSender.h"
#include "ExceptionCode.h"
#include "MediaStreamTrack.h"
#include "RTCDTMFSenderHandler.h"
#include "RTCDTMFToneChangeEvent.h"
#include "RTCPeerConnectionHandler.h"
#include "ScriptExecutionContext.h"
namespace WebCore {
static const long minToneDurationMs = 70;
static const long defaultToneDurationMs = 100;
static const long maxToneDurationMs = 6000;
static const long minInterToneGapMs = 50;
static const long defaultInterToneGapMs = 50;
PassRefPtr<RTCDTMFSender> RTCDTMFSender::create(ScriptExecutionContext* context, RTCPeerConnectionHandler* peerConnectionHandler, PassRefPtr<MediaStreamTrack> prpTrack, ExceptionCode& ec)
{
RefPtr<MediaStreamTrack> track = prpTrack;
OwnPtr<RTCDTMFSenderHandler> handler = peerConnectionHandler->createDTMFSender(track->component());
if (!handler) {
ec = NOT_SUPPORTED_ERR;
return 0;
}
RefPtr<RTCDTMFSender> dtmfSender = adoptRef(new RTCDTMFSender(context, track, handler.release()));
dtmfSender->suspendIfNeeded();
return dtmfSender.release();
}
RTCDTMFSender::RTCDTMFSender(ScriptExecutionContext* context, PassRefPtr<MediaStreamTrack> track, PassOwnPtr<RTCDTMFSenderHandler> handler)
: ActiveDOMObject(context, this)
, m_track(track)
, m_duration(defaultToneDurationMs)
, m_interToneGap(defaultInterToneGapMs)
, m_handler(handler)
, m_stopped(false)
, m_scheduledEventTimer(this, &RTCDTMFSender::scheduledEventTimerFired)
{
m_handler->setClient(this);
}
RTCDTMFSender::~RTCDTMFSender()
{
}
bool RTCDTMFSender::canInsertDTMF() const
{
return m_handler->canInsertDTMF();
}
MediaStreamTrack* RTCDTMFSender::track() const
{
return m_track.get();
}
String RTCDTMFSender::toneBuffer() const
{
return m_handler->currentToneBuffer();
}
void RTCDTMFSender::insertDTMF(const String& tones, ExceptionCode& ec)
{
insertDTMF(tones, defaultToneDurationMs, defaultInterToneGapMs, ec);
}
void RTCDTMFSender::insertDTMF(const String& tones, long duration, ExceptionCode& ec)
{
insertDTMF(tones, duration, defaultInterToneGapMs, ec);
}
void RTCDTMFSender::insertDTMF(const String& tones, long duration, long interToneGap, ExceptionCode& ec)
{
if (!canInsertDTMF()) {
ec = NOT_SUPPORTED_ERR;
return;
}
if (duration > maxToneDurationMs || duration < minToneDurationMs) {
ec = SYNTAX_ERR;
return;
}
if (interToneGap < minInterToneGapMs) {
ec = SYNTAX_ERR;
return;
}
m_duration = duration;
m_interToneGap = interToneGap;
if (!m_handler->insertDTMF(tones, m_duration, m_interToneGap))
ec = SYNTAX_ERR;
}
void RTCDTMFSender::didPlayTone(const String& tone)
{
scheduleDispatchEvent(RTCDTMFToneChangeEvent::create(tone));
}
const AtomicString& RTCDTMFSender::interfaceName() const
{
return eventNames().interfaceForRTCDTMFSender;
}
ScriptExecutionContext* RTCDTMFSender::scriptExecutionContext() const
{
return ActiveDOMObject::scriptExecutionContext();
}
void RTCDTMFSender::stop()
{
m_stopped = true;
m_handler->setClient(0);
}
EventTargetData* RTCDTMFSender::eventTargetData()
{
return &m_eventTargetData;
}
EventTargetData* RTCDTMFSender::ensureEventTargetData()
{
return &m_eventTargetData;
}
void RTCDTMFSender::scheduleDispatchEvent(PassRefPtr<Event> event)
{
m_scheduledEvents.append(event);
if (!m_scheduledEventTimer.isActive())
m_scheduledEventTimer.startOneShot(0);
}
void RTCDTMFSender::scheduledEventTimerFired(Timer<RTCDTMFSender>*)
{
if (m_stopped)
return;
Vector<RefPtr<Event> > events;
events.swap(m_scheduledEvents);
Vector<RefPtr<Event> >::iterator it = events.begin();
for (; it != events.end(); ++it)
dispatchEvent((*it).release());
}
} // namespace WebCore
#endif // ENABLE(MEDIA_STREAM)
/*
* Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.