1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CONTENT_RENDERER_MEDIA_RTC_DTMF_SENDER_HANDLER_H_ 6 #define CONTENT_RENDERER_MEDIA_RTC_DTMF_SENDER_HANDLER_H_ 7 8 #include <string> 9 10 #include "base/memory/ref_counted.h" 11 #include "base/threading/non_thread_safe.h" 12 #include "content/common/content_export.h" 13 #include "third_party/WebKit/public/platform/WebRTCDTMFSenderHandler.h" 14 #include "third_party/WebKit/public/platform/WebRTCDTMFSenderHandlerClient.h" 15 #include "third_party/libjingle/source/talk/app/webrtc/dtmfsenderinterface.h" 16 17 namespace content { 18 19 // RtcDtmfSenderHandler is a delegate for the RTC DTMF Sender API messages 20 // going between WebKit and native DTMF Sender in libjingle. 21 // Instances of this class are owned by WebKit. 22 // WebKit call all of these methods on the main render thread. 23 // Callbacks to the webrtc::DtmfSenderObserverInterface implementation also 24 // occur on the main render thread. 25 class CONTENT_EXPORT RtcDtmfSenderHandler 26 : NON_EXPORTED_BASE(public WebKit::WebRTCDTMFSenderHandler), 27 NON_EXPORTED_BASE(public webrtc::DtmfSenderObserverInterface), 28 NON_EXPORTED_BASE(public base::NonThreadSafe) { 29 public: 30 explicit RtcDtmfSenderHandler(webrtc::DtmfSenderInterface* dtmf_sender); 31 virtual ~RtcDtmfSenderHandler(); 32 33 // WebKit::WebRTCDTMFSenderHandler implementation. 34 virtual void setClient( 35 WebKit::WebRTCDTMFSenderHandlerClient* client) OVERRIDE; 36 virtual WebKit::WebString currentToneBuffer() OVERRIDE; 37 virtual bool canInsertDTMF() OVERRIDE; 38 virtual bool insertDTMF(const WebKit::WebString& tones, long duration, 39 long interToneGap) OVERRIDE; 40 41 // webrtc::DtmfSenderObserverInterface implementation. 42 virtual void OnToneChange(const std::string& tone) OVERRIDE; 43 44 private: 45 scoped_refptr<webrtc::DtmfSenderInterface> dtmf_sender_; 46 WebKit::WebRTCDTMFSenderHandlerClient* webkit_client_; 47 }; 48 49 } // namespace content 50 51 #endif // CONTENT_RENDERER_MEDIA_RTC_DTMF_SENDER_HANDLER_H_ 52 53