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>
|
|
|
|
|
|
2015-02-26 14:34:55 +00:00
|
|
|
#include "webrtc/base/scoped_ptr.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
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
class CriticalSectionWrapper;
|
|
|
|
|
|
2012-12-13 10:48:24 +00:00
|
|
|
// Handles audio RTP packets. This class is thread-safe.
|
2013-08-15 23:38:54 +00: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
|
|
|
|
2013-08-15 23:38:54 +00:00
|
|
|
// The following three methods implement the TelephoneEventHandler interface.
|
2013-03-12 22:27:27 +00:00
|
|
|
// Forward DTMFs to decoder for playout.
|
2013-08-15 23:38:54 +00:00
|
|
|
void SetTelephoneEventForwardToDecoder(bool forward_to_decoder);
|
2013-02-05 15:12:39 +00:00
|
|
|
|
|
|
|
|
// Is forwarding of outband telephone events turned on/off?
|
|
|
|
|
bool TelephoneEventForwardToDecoder() const;
|
|
|
|
|
|
|
|
|
|
// Is TelephoneEvent configured with payload type payload_type
|
2013-04-08 11:08:41 +00:00
|
|
|
bool TelephoneEventPayloadType(const int8_t payload_type) const;
|
2013-02-05 15:12:39 +00:00
|
|
|
|
2015-12-10 02:39:40 -08:00
|
|
|
TelephoneEventHandler* GetTelephoneEventHandler() { return this; }
|
2013-08-15 23:38:54 +00:00
|
|
|
|
2013-02-05 15:12:39 +00:00
|
|
|
// Returns true if CNG is configured with payload type payload_type. If so,
|
|
|
|
|
// the frequency and cng_payload_type_has_changed are filled in.
|
2013-04-08 11:08:41 +00:00
|
|
|
bool CNGPayloadType(const int8_t payload_type,
|
|
|
|
|
uint32_t* frequency,
|
2013-02-05 15:12:39 +00:00
|
|
|
bool* cng_payload_type_has_changed);
|
|
|
|
|
|
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
|
|
|
int GetPayloadTypeFrequency() const 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
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
int32_t OnNewPayloadTypeCreated(
|
2013-02-05 15:12:39 +00:00
|
|
|
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
2013-08-15 23:38:54 +00:00
|
|
|
int8_t payload_type,
|
2015-03-04 12:58:35 +00:00
|
|
|
uint32_t frequency) 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 do not allow codecs to have multiple payload types for audio, so we
|
|
|
|
|
// need to override the default behavior (which is to do nothing).
|
|
|
|
|
void PossiblyRemoveExistingPayloadType(
|
2014-07-08 12:10:51 +00:00
|
|
|
RtpUtility::PayloadTypeMap* payload_type_map,
|
2013-02-05 15:12:39 +00:00
|
|
|
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
2013-08-15 23:38:54 +00:00
|
|
|
size_t payload_name_length,
|
|
|
|
|
uint32_t frequency,
|
|
|
|
|
uint8_t channels,
|
|
|
|
|
uint32_t rate) const;
|
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
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
uint32_t last_received_frequency_;
|
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_;
|
|
|
|
|
int8_t cng_payload_type_;
|
2013-02-05 15:12:39 +00:00
|
|
|
|
|
|
|
|
// G722 is special since it use the wrong number of RTP samples in timestamp
|
|
|
|
|
// VS. number of samples in the frame
|
2013-04-08 11:08:41 +00:00
|
|
|
int8_t g722_payload_type_;
|
2013-02-05 15:12:39 +00:00
|
|
|
bool last_received_g722_;
|
|
|
|
|
|
2013-08-15 23:38:54 +00:00
|
|
|
uint8_t num_energy_;
|
|
|
|
|
uint8_t current_remote_energy_[kRtpCsrcSize];
|
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_
|