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.
5 #ifndef CONTENT_RENDERER_MEDIA_RTC_DTMF_SENDER_HANDLER_H_
6 #define CONTENT_RENDERER_MEDIA_RTC_DTMF_SENDER_HANDLER_H_
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/threading/non_thread_safe.h"
13 #include "content/common/content_export.h"
14 #include "third_party/WebKit/public/platform/WebRTCDTMFSenderHandler.h"
15 #include "third_party/WebKit/public/platform/WebRTCDTMFSenderHandlerClient.h"
16 #include "third_party/libjingle/source/talk/app/webrtc/dtmfsenderinterface.h"
20 // RtcDtmfSenderHandler is a delegate for the RTC DTMF Sender API messages
21 // going between WebKit and native DTMF Sender in libjingle.
22 // Instances of this class are owned by WebKit.
23 // WebKit call all of these methods on the main render thread.
24 // Callbacks to the webrtc::DtmfSenderObserverInterface implementation also
25 // occur on the main render thread.
26 class CONTENT_EXPORT RtcDtmfSenderHandler
27 : NON_EXPORTED_BASE(public blink::WebRTCDTMFSenderHandler
),
28 NON_EXPORTED_BASE(public base::NonThreadSafe
) {
30 explicit RtcDtmfSenderHandler(webrtc::DtmfSenderInterface
* dtmf_sender
);
31 virtual ~RtcDtmfSenderHandler();
33 // blink::WebRTCDTMFSenderHandler implementation.
35 blink::WebRTCDTMFSenderHandlerClient
* client
) override
;
36 blink::WebString
currentToneBuffer() override
;
37 bool canInsertDTMF() override
;
38 bool insertDTMF(const blink::WebString
& tones
, long duration
,
39 long interToneGap
) override
;
41 void OnToneChange(const std::string
& tone
);
44 scoped_refptr
<webrtc::DtmfSenderInterface
> dtmf_sender_
;
45 blink::WebRTCDTMFSenderHandlerClient
* webkit_client_
;
47 scoped_refptr
<Observer
> observer_
;
49 // |weak_factory_| must be the last member.
50 base::WeakPtrFactory
<RtcDtmfSenderHandler
> weak_factory_
;
52 DISALLOW_COPY_AND_ASSIGN(RtcDtmfSenderHandler
);
55 } // namespace content
57 #endif // CONTENT_RENDERER_MEDIA_RTC_DTMF_SENDER_HANDLER_H_