2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-01-24 17:16:59 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_RECEIVER_AUDIO_H_
|
|
|
|
|
#define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_RECEIVER_AUDIO_H_
|
|
|
|
|
|
2012-01-19 15:53:59 +00:00
|
|
|
#include <set>
|
|
|
|
|
|
2016-04-07 15:36:45 -07:00
|
|
|
#include "webrtc/base/onetimeevent.h"
|
2015-11-04 08:31:52 +01:00
|
|
|
#include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h"
|
|
|
|
|
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
2013-02-05 15:12:39 +00:00
|
|
|
#include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h"
|
|
|
|
|
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
|
|
|
|
|
#include "webrtc/typedefs.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2013-02-05 15:12:39 +00:00
|
|
|
|
2012-12-13 10:48:24 +00:00
|
|
|
// Handles audio RTP packets. This class is thread-safe.
|
2016-09-22 03:36:27 -07:00
|
|
|
class RTPReceiverAudio : public RTPReceiverStrategy,
|
|
|
|
|
public TelephoneEventHandler {
|
2013-02-05 15:12:39 +00:00
|
|
|
public:
|
2016-03-30 02:42:32 -07:00
|
|
|
explicit RTPReceiverAudio(RtpData* data_callback);
|
2013-08-15 23:38:54 +00:00
|
|
|
virtual ~RTPReceiverAudio() {}
|
2013-07-16 19:25:04 +00:00
|
|
|
|
2016-09-22 03:36:27 -07:00
|
|
|
// 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;
|
|
|
|
|
|
RTPReceiverAudio: Removed frequency from CNGPayloadType and cleaned up
CheckPayloadChanged.
Removed last_received_frequency_, cng_payload_type_,
g722_payload_type_ and last_received_g722_ from RTPReceiverAudio and
cleaned up most of the related, now dead code.
Since g722_payload_type_ was never set, neither was
last_received_g722_, which means the frequency change in
CNGPayloadType was never done. Setting the frequency to the standard
values also proved unnecessary, since they were already set before the
call. Even if frequency would have been changed by RTPReceiverAudio, I
was not able to find a place where that would actually have
mattered. The ACM and NetEq, for example, which eventually gets these
packages, don't care about that value.
Also, GetPayloadTypeFrequency was never called, so keeping track of
last_received_frequency_ proved unnecessary.
cng_payload_type_ was stored to be able to check in CNGPayloadType if
cng_payload_type_has_changed. This flag was also never read, so these
all disappear.
The main reason for starting this change was to root out any G722
specific code we have sprinkled around the code base (specifically
dealing with the fact that for G722 clock rate != sample rate). In
this case, once I started pulling at one end of the string, the whole
thing came unraveled.
BUG=webrtc:5805
Review-Url: https://codereview.webrtc.org/2383103002
Cr-Commit-Position: refs/heads/master@{#14530}
2016-10-05 08:44:22 -07:00
|
|
|
// Is TelephoneEvent configured with |payload_type|.
|
2016-09-22 03:36:27 -07:00
|
|
|
bool TelephoneEventPayloadType(const int8_t payload_type) const override;
|
|
|
|
|
|
|
|
|
|
TelephoneEventHandler* GetTelephoneEventHandler() override { return this; }
|
2013-08-15 23:38:54 +00:00
|
|
|
|
RTPReceiverAudio: Removed frequency from CNGPayloadType and cleaned up
CheckPayloadChanged.
Removed last_received_frequency_, cng_payload_type_,
g722_payload_type_ and last_received_g722_ from RTPReceiverAudio and
cleaned up most of the related, now dead code.
Since g722_payload_type_ was never set, neither was
last_received_g722_, which means the frequency change in
CNGPayloadType was never done. Setting the frequency to the standard
values also proved unnecessary, since they were already set before the
call. Even if frequency would have been changed by RTPReceiverAudio, I
was not able to find a place where that would actually have
mattered. The ACM and NetEq, for example, which eventually gets these
packages, don't care about that value.
Also, GetPayloadTypeFrequency was never called, so keeping track of
last_received_frequency_ proved unnecessary.
cng_payload_type_ was stored to be able to check in CNGPayloadType if
cng_payload_type_has_changed. This flag was also never read, so these
all disappear.
The main reason for starting this change was to root out any G722
specific code we have sprinkled around the code base (specifically
dealing with the fact that for G722 clock rate != sample rate). In
this case, once I started pulling at one end of the string, the whole
thing came unraveled.
BUG=webrtc:5805
Review-Url: https://codereview.webrtc.org/2383103002
Cr-Commit-Position: refs/heads/master@{#14530}
2016-10-05 08:44:22 -07:00
|
|
|
// Returns true if CNG is configured with |payload_type|.
|
|
|
|
|
bool CNGPayloadType(const int8_t payload_type);
|
2013-02-05 15:12:39 +00:00
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
int32_t ParseRtpPacket(WebRtcRTPHeader* rtp_header,
|
|
|
|
|
const PayloadUnion& specific_payload,
|
|
|
|
|
bool is_red,
|
|
|
|
|
const uint8_t* packet,
|
|
|
|
|
size_t payload_length,
|
|
|
|
|
int64_t timestamp_ms,
|
|
|
|
|
bool is_first_packet) override;
|
2013-02-05 15:12:39 +00:00
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
RTPAliveType ProcessDeadOrAlive(uint16_t last_payload_length) const override;
|
2013-02-05 15:12:39 +00:00
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
bool ShouldReportCsrcChanges(uint8_t payload_type) const override;
|
2013-02-05 15:12:39 +00:00
|
|
|
|
2016-11-24 09:34:46 -08:00
|
|
|
int32_t OnNewPayloadTypeCreated(const CodecInst& audio_codec) override;
|
2013-02-05 15:12:39 +00:00
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
int32_t InvokeOnInitializeDecoder(
|
2013-02-05 15:12:39 +00:00
|
|
|
RtpFeedback* callback,
|
2013-08-15 23:38:54 +00:00
|
|
|
int8_t payload_type,
|
2013-02-05 15:12:39 +00:00
|
|
|
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
2015-03-04 12:58:35 +00:00
|
|
|
const PayloadUnion& specific_payload) const override;
|
2013-02-05 15:12:39 +00:00
|
|
|
|
|
|
|
|
// We need to look out for special payload types here and sometimes reset
|
|
|
|
|
// statistics. In addition we sometimes need to tweak the frequency.
|
2013-08-15 23:38:54 +00:00
|
|
|
void CheckPayloadChanged(int8_t payload_type,
|
|
|
|
|
PayloadUnion* specific_payload,
|
2015-03-04 12:58:35 +00:00
|
|
|
bool* should_discard_changes) override;
|
2013-02-05 15:12:39 +00:00
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
int Energy(uint8_t array_of_energy[kRtpCsrcSize]) const override;
|
2013-08-15 23:38:54 +00:00
|
|
|
|
2013-02-05 15:12:39 +00:00
|
|
|
private:
|
2015-12-10 02:39:40 -08:00
|
|
|
int32_t ParseAudioCodecSpecific(WebRtcRTPHeader* rtp_header,
|
|
|
|
|
const uint8_t* payload_data,
|
|
|
|
|
size_t payload_length,
|
|
|
|
|
const AudioPayload& audio_specific,
|
|
|
|
|
bool is_red);
|
2013-02-05 15:12:39 +00:00
|
|
|
|
|
|
|
|
bool telephone_event_forward_to_decoder_;
|
2013-04-08 11:08:41 +00:00
|
|
|
int8_t telephone_event_payload_type_;
|
|
|
|
|
std::set<uint8_t> telephone_event_reported_;
|
2013-02-05 15:12:39 +00:00
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
int8_t cng_nb_payload_type_;
|
|
|
|
|
int8_t cng_wb_payload_type_;
|
|
|
|
|
int8_t cng_swb_payload_type_;
|
|
|
|
|
int8_t cng_fb_payload_type_;
|
2013-02-05 15:12:39 +00:00
|
|
|
|
2013-08-15 23:38:54 +00:00
|
|
|
uint8_t num_energy_;
|
|
|
|
|
uint8_t current_remote_energy_[kRtpCsrcSize];
|
2016-04-07 15:36:45 -07:00
|
|
|
|
|
|
|
|
ThreadUnsafeOneTimeEvent first_packet_received_;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
2013-02-05 15:12:39 +00:00
|
|
|
} // namespace webrtc
|
|
|
|
|
|
|
|
|
|
#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_RECEIVER_AUDIO_H_
|