summaryrefslogtreecommitdiffstats
path: root/content/renderer/media/rtc_dtmf_sender_handler.h
blob: 397f4d9cd4c0de463f6b658377ae916caf88da30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_RENDERER_MEDIA_RTC_DTMF_SENDER_HANDLER_H_
#define CONTENT_RENDERER_MEDIA_RTC_DTMF_SENDER_HANDLER_H_

#include <string>

#include "base/memory/ref_counted.h"
#include "base/threading/non_thread_safe.h"
#include "content/common/content_export.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebRTCDTMFSenderHandler.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebRTCDTMFSenderHandlerClient.h"
#include "third_party/libjingle/source/talk/app/webrtc/dtmfsenderinterface.h"

namespace content {

// RtcDtmfSenderHandler is a delegate for the RTC DTMF Sender API messages
// going between WebKit and native DTMF Sender in libjingle.
// Instances of this class are owned by WebKit.
// WebKit call all of these methods on the main render thread.
// Callbacks to the webrtc::DtmfSenderObserverInterface implementation also
// occur on the main render thread.
class CONTENT_EXPORT RtcDtmfSenderHandler
    : NON_EXPORTED_BASE(public WebKit::WebRTCDTMFSenderHandler),
      NON_EXPORTED_BASE(public webrtc::DtmfSenderObserverInterface),
      NON_EXPORTED_BASE(public base::NonThreadSafe) {
 public:
  explicit RtcDtmfSenderHandler(webrtc::DtmfSenderInterface* dtmf_sender);
  virtual ~RtcDtmfSenderHandler();

  // WebKit::WebRTCDTMFSenderHandler implementation.
  virtual void setClient(
      WebKit::WebRTCDTMFSenderHandlerClient* client) OVERRIDE;
  virtual WebKit::WebString currentToneBuffer() OVERRIDE;
  virtual bool canInsertDTMF() OVERRIDE;
  virtual bool insertDTMF(const WebKit::WebString& tones, long duration,
                          long interToneGap) OVERRIDE;

  // webrtc::DtmfSenderObserverInterface implementation.
  virtual void OnToneChange(const std::string& tone) OVERRIDE;

 private:
  scoped_refptr<webrtc::DtmfSenderInterface> dtmf_sender_;
  WebKit::WebRTCDTMFSenderHandlerClient* webkit_client_;
};

}  // namespace content

#endif  // CONTENT_RENDERER_MEDIA_RTC_DTMF_SENDER_HANDLER_H_