123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- #ifndef PC_DTMF_SENDER_H_
- #define PC_DTMF_SENDER_H_
- #include <string>
- #include "api/dtmf_sender_interface.h"
- #include "api/proxy.h"
- #include "rtc_base/async_invoker.h"
- #include "rtc_base/constructor_magic.h"
- #include "rtc_base/ref_count.h"
- #include "rtc_base/thread.h"
- namespace webrtc {
- class DtmfProviderInterface {
- public:
-
-
- virtual bool CanInsertDtmf() = 0;
-
-
-
- virtual bool InsertDtmf(int code, int duration) = 0;
-
-
- virtual sigslot::signal0<>* GetOnDestroyedSignal() = 0;
- protected:
- virtual ~DtmfProviderInterface() {}
- };
- class DtmfSender : public DtmfSenderInterface, public sigslot::has_slots<> {
- public:
- static rtc::scoped_refptr<DtmfSender> Create(rtc::Thread* signaling_thread,
- DtmfProviderInterface* provider);
-
- void RegisterObserver(DtmfSenderObserverInterface* observer) override;
- void UnregisterObserver() override;
- bool CanInsertDtmf() override;
- bool InsertDtmf(const std::string& tones,
- int duration,
- int inter_tone_gap,
- int comma_delay = kDtmfDefaultCommaDelayMs) override;
- std::string tones() const override;
- int duration() const override;
- int inter_tone_gap() const override;
- int comma_delay() const override;
- protected:
- DtmfSender(rtc::Thread* signaling_thread, DtmfProviderInterface* provider);
- virtual ~DtmfSender();
- private:
- DtmfSender();
- void QueueInsertDtmf(const rtc::Location& posted_from, uint32_t delay_ms);
-
- void DoInsertDtmf();
- void OnProviderDestroyed();
- void StopSending();
- DtmfSenderObserverInterface* observer_;
- rtc::Thread* signaling_thread_;
- DtmfProviderInterface* provider_;
- std::string tones_;
- int duration_;
- int inter_tone_gap_;
- int comma_delay_;
-
-
- rtc::AsyncInvoker dtmf_driver_;
- RTC_DISALLOW_COPY_AND_ASSIGN(DtmfSender);
- };
- BEGIN_SIGNALING_PROXY_MAP(DtmfSender)
- PROXY_SIGNALING_THREAD_DESTRUCTOR()
- PROXY_METHOD1(void, RegisterObserver, DtmfSenderObserverInterface*)
- PROXY_METHOD0(void, UnregisterObserver)
- PROXY_METHOD0(bool, CanInsertDtmf)
- PROXY_METHOD4(bool, InsertDtmf, const std::string&, int, int, int)
- PROXY_CONSTMETHOD0(std::string, tones)
- PROXY_CONSTMETHOD0(int, duration)
- PROXY_CONSTMETHOD0(int, inter_tone_gap)
- PROXY_CONSTMETHOD0(int, comma_delay)
- END_PROXY_MAP()
- bool GetDtmfCode(char tone, int* code);
- }
- #endif
|