Revert of Remove unnecessary interface TelephoneEventHandler (patchset #3 id:40001 of https://codereview.webrtc.org/2357583002/ )

Reason for revert:
breaks downstream code

Original issue's description:
> Remove unnecessary interface TelephoneEventHandler.
>
> BUG=webrtc:2795
>
> Committed: https://crrev.com/2beb42983ca24e1326a9a7f2c06b3ad740eea2c3
> Cr-Commit-Position: refs/heads/master@{#14346}

TBR=henrik.lundin@webrtc.org,solenberg@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:2795

Review-Url: https://codereview.webrtc.org/2362673002
Cr-Commit-Position: refs/heads/master@{#14348}
This commit is contained in:
danilchap
2016-09-22 03:36:27 -07:00
committed by Commit bot
parent a70695a3e1
commit 799a9d017a
10 changed files with 65 additions and 2 deletions

View File

@ -18,6 +18,21 @@ namespace webrtc {
class RTPPayloadRegistry;
class TelephoneEventHandler {
public:
virtual ~TelephoneEventHandler() {}
// The following three methods implement the TelephoneEventHandler interface.
// Forward DTMFs to decoder for playout.
virtual void SetTelephoneEventForwardToDecoder(bool forward_to_decoder) = 0;
// Is forwarding of outband telephone events turned on/off?
virtual bool TelephoneEventForwardToDecoder() const = 0;
// Is TelephoneEvent configured with payload type payload_type
virtual bool TelephoneEventPayloadType(const int8_t payload_type) const = 0;
};
class RtpReceiver {
public:
// Creates a video-enabled RTP receiver.
@ -36,6 +51,9 @@ class RtpReceiver {
virtual ~RtpReceiver() {}
// Returns a TelephoneEventHandler if available.
virtual TelephoneEventHandler* GetTelephoneEventHandler() = 0;
// Registers a receive payload in the payload registry and notifies the media
// receiver strategy.
virtual int32_t RegisterReceivePayload(

View File

@ -25,7 +25,9 @@ RTPReceiverStrategy* RTPReceiverStrategy::CreateAudioStrategy(
RTPReceiverAudio::RTPReceiverAudio(RtpData* data_callback)
: RTPReceiverStrategy(data_callback),
TelephoneEventHandler(),
last_received_frequency_(8000),
telephone_event_forward_to_decoder_(false),
telephone_event_payload_type_(-1),
cng_nb_payload_type_(-1),
cng_wb_payload_type_(-1),
@ -40,6 +42,19 @@ RTPReceiverAudio::RTPReceiverAudio(RtpData* data_callback)
memset(current_remote_energy_, 0, sizeof(current_remote_energy_));
}
// Outband TelephoneEvent(DTMF) detection
void RTPReceiverAudio::SetTelephoneEventForwardToDecoder(
bool forward_to_decoder) {
rtc::CritScope lock(&crit_sect_);
telephone_event_forward_to_decoder_ = forward_to_decoder;
}
// Is forwarding of outband telephone events turned on/off?
bool RTPReceiverAudio::TelephoneEventForwardToDecoder() const {
rtc::CritScope lock(&crit_sect_);
return telephone_event_forward_to_decoder_;
}
bool RTPReceiverAudio::TelephoneEventPayloadType(
int8_t payload_type) const {
rtc::CritScope lock(&crit_sect_);
@ -341,6 +356,10 @@ int32_t RTPReceiverAudio::ParseAudioCodecSpecific(
// check if it's a DTMF event, hence something we can playout
if (telephone_event_packet) {
if (!telephone_event_forward_to_decoder_) {
// don't forward event to decoder
return 0;
}
std::set<uint8_t>::iterator first =
telephone_event_reported_.begin();
if (first != telephone_event_reported_.end() && *first > 15) {

View File

@ -23,13 +23,23 @@
namespace webrtc {
// Handles audio RTP packets. This class is thread-safe.
class RTPReceiverAudio : public RTPReceiverStrategy {
class RTPReceiverAudio : public RTPReceiverStrategy,
public TelephoneEventHandler {
public:
explicit RTPReceiverAudio(RtpData* data_callback);
virtual ~RTPReceiverAudio() {}
// The following three methods implement the TelephoneEventHandler interface.
// Forward DTMFs to decoder for playout.
void SetTelephoneEventForwardToDecoder(bool forward_to_decoder) override;
// Is forwarding of outband telephone events turned on/off?
bool TelephoneEventForwardToDecoder() const override;
// Is TelephoneEvent configured with payload type payload_type
bool TelephoneEventPayloadType(const int8_t payload_type) const;
bool TelephoneEventPayloadType(const int8_t payload_type) const override;
TelephoneEventHandler* GetTelephoneEventHandler() override { return this; }
// Returns true if CNG is configured with payload type payload_type. If so,
// the frequency and cng_payload_type_has_changed are filled in.

View File

@ -200,6 +200,10 @@ bool RtpReceiverImpl::IncomingRtpPacket(
return true;
}
TelephoneEventHandler* RtpReceiverImpl::GetTelephoneEventHandler() {
return rtp_media_receiver_->GetTelephoneEventHandler();
}
bool RtpReceiverImpl::Timestamp(uint32_t* timestamp) const {
rtc::CritScope lock(&critical_section_rtp_receiver_);
if (!HaveReceivedFrame())

View File

@ -57,6 +57,8 @@ class RtpReceiverImpl : public RtpReceiver {
int32_t Energy(uint8_t array_of_energy[kRtpCsrcSize]) const override;
TelephoneEventHandler* GetTelephoneEventHandler() override;
private:
bool HaveReceivedFrame() const;

View File

@ -44,6 +44,8 @@ class RTPReceiverStrategy {
int64_t timestamp_ms,
bool is_first_packet) = 0;
virtual TelephoneEventHandler* GetTelephoneEventHandler() = 0;
// Retrieves the last known applicable frequency.
virtual int GetPayloadTypeFrequency() const = 0;

View File

@ -33,6 +33,8 @@ class RTPReceiverVideo : public RTPReceiverStrategy {
int64_t timestamp,
bool is_first_packet) override;
TelephoneEventHandler* GetTelephoneEventHandler() override { return NULL; }
int GetPayloadTypeFrequency() const override;
RTPAliveType ProcessDeadOrAlive(uint16_t last_payload_length) const override;

View File

@ -162,6 +162,9 @@ TEST_F(RtpRtcpAudioTest, Basic) {
module1->SetSSRC(test_ssrc);
module1->SetStartTimestamp(test_timestamp);
// Test detection at the end of a DTMF tone.
// EXPECT_EQ(0, module2->SetTelephoneEventForwardToDecoder(true));
EXPECT_EQ(0, module1->SetSendingStatus(true));
// Start basic RTP test.

View File

@ -809,6 +809,7 @@ Channel::Channel(int32_t channelId,
this,
this,
rtp_payload_registry_.get())),
telephone_event_handler_(rtp_receiver_->GetTelephoneEventHandler()),
_outputAudioLevel(),
_externalTransport(false),
// Avoid conflict with other channels by adding 1024 - 1026,
@ -978,6 +979,7 @@ int32_t Channel::Init() {
// disabled by the user.
// After StopListen (when no sockets exists), RTCP packets will no longer
// be transmitted since the Transport object will then be invalid.
telephone_event_handler_->SetTelephoneEventForwardToDecoder(true);
// RTCP is enabled by default.
_rtpRtcpModule->SetRTCPStatus(RtcpMode::kCompound);
// --- Register all permanent callbacks

View File

@ -458,6 +458,7 @@ class Channel
std::unique_ptr<ReceiveStatistics> rtp_receive_statistics_;
std::unique_ptr<StatisticsProxy> statistics_proxy_;
std::unique_ptr<RtpReceiver> rtp_receiver_;
TelephoneEventHandler* telephone_event_handler_;
std::unique_ptr<RtpRtcp> _rtpRtcpModule;
std::unique_ptr<AudioCodingModule> audio_coding_;
acm2::CodecManager codec_manager_;