niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
pwestin@webrtc.org | f6bb77a | 2012-01-24 17:16:59 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_RTP_RTCP_SOURCE_RTP_RECEIVER_AUDIO_H_ |
| 12 | #define MODULES_RTP_RTCP_SOURCE_RTP_RECEIVER_AUDIO_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
pwestin@webrtc.org | af6f15c | 2012-01-19 15:53:59 +0000 | [diff] [blame] | 14 | #include <set> |
| 15 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 16 | #include "modules/rtp_rtcp/include/rtp_receiver.h" |
| 17 | #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 18 | #include "modules/rtp_rtcp/source/rtp_receiver_strategy.h" |
| 19 | #include "modules/rtp_rtcp/source/rtp_utility.h" |
| 20 | #include "rtc_base/onetimeevent.h" |
Mirko Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame] | 21 | #include "typedefs.h" // NOLINT(build/include) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 22 | |
| 23 | namespace webrtc { |
phoglund@webrtc.org | a7303bd | 2013-02-05 15:12:39 +0000 | [diff] [blame] | 24 | |
phoglund@webrtc.org | 92bb417 | 2012-12-13 10:48:24 +0000 | [diff] [blame] | 25 | // Handles audio RTP packets. This class is thread-safe. |
danilchap | 799a9d0 | 2016-09-22 03:36:27 -0700 | [diff] [blame] | 26 | class RTPReceiverAudio : public RTPReceiverStrategy, |
| 27 | public TelephoneEventHandler { |
phoglund@webrtc.org | a7303bd | 2013-02-05 15:12:39 +0000 | [diff] [blame] | 28 | public: |
solenberg | 1d03139 | 2016-03-30 02:42:32 -0700 | [diff] [blame] | 29 | explicit RTPReceiverAudio(RtpData* data_callback); |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 30 | virtual ~RTPReceiverAudio() {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 31 | |
danilchap | 799a9d0 | 2016-09-22 03:36:27 -0700 | [diff] [blame] | 32 | // The following three methods implement the TelephoneEventHandler interface. |
| 33 | // Forward DTMFs to decoder for playout. |
| 34 | void SetTelephoneEventForwardToDecoder(bool forward_to_decoder) override; |
| 35 | |
| 36 | // Is forwarding of outband telephone events turned on/off? |
| 37 | bool TelephoneEventForwardToDecoder() const override; |
| 38 | |
ossu | 425a6cc | 2016-10-05 08:44:22 -0700 | [diff] [blame] | 39 | // Is TelephoneEvent configured with |payload_type|. |
danilchap | 799a9d0 | 2016-09-22 03:36:27 -0700 | [diff] [blame] | 40 | bool TelephoneEventPayloadType(const int8_t payload_type) const override; |
| 41 | |
| 42 | TelephoneEventHandler* GetTelephoneEventHandler() override { return this; } |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 43 | |
ossu | 425a6cc | 2016-10-05 08:44:22 -0700 | [diff] [blame] | 44 | // Returns true if CNG is configured with |payload_type|. |
| 45 | bool CNGPayloadType(const int8_t payload_type); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 46 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 47 | int32_t ParseRtpPacket(WebRtcRTPHeader* rtp_header, |
| 48 | const PayloadUnion& specific_payload, |
| 49 | bool is_red, |
| 50 | const uint8_t* packet, |
| 51 | size_t payload_length, |
Niels Möller | bbf389c | 2017-09-26 14:05:05 +0200 | [diff] [blame^] | 52 | int64_t timestamp_ms) override; |
phoglund@webrtc.org | 07bf43c | 2012-12-18 15:40:53 +0000 | [diff] [blame] | 53 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 54 | RTPAliveType ProcessDeadOrAlive(uint16_t last_payload_length) const override; |
phoglund@webrtc.org | 07bf43c | 2012-12-18 15:40:53 +0000 | [diff] [blame] | 55 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 56 | bool ShouldReportCsrcChanges(uint8_t payload_type) const override; |
phoglund@webrtc.org | 5accd37 | 2013-01-22 12:31:01 +0000 | [diff] [blame] | 57 | |
magjed | 56124bd | 2016-11-24 09:34:46 -0800 | [diff] [blame] | 58 | int32_t OnNewPayloadTypeCreated(const CodecInst& audio_codec) override; |
phoglund@webrtc.org | 07bf43c | 2012-12-18 15:40:53 +0000 | [diff] [blame] | 59 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 60 | int32_t InvokeOnInitializeDecoder( |
phoglund@webrtc.org | a7303bd | 2013-02-05 15:12:39 +0000 | [diff] [blame] | 61 | RtpFeedback* callback, |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 62 | int8_t payload_type, |
phoglund@webrtc.org | a7303bd | 2013-02-05 15:12:39 +0000 | [diff] [blame] | 63 | const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 64 | const PayloadUnion& specific_payload) const override; |
phoglund@webrtc.org | 07bf43c | 2012-12-18 15:40:53 +0000 | [diff] [blame] | 65 | |
phoglund@webrtc.org | a7303bd | 2013-02-05 15:12:39 +0000 | [diff] [blame] | 66 | // We need to look out for special payload types here and sometimes reset |
| 67 | // statistics. In addition we sometimes need to tweak the frequency. |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 68 | void CheckPayloadChanged(int8_t payload_type, |
| 69 | PayloadUnion* specific_payload, |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 70 | bool* should_discard_changes) override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 71 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 72 | int Energy(uint8_t array_of_energy[kRtpCsrcSize]) const override; |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 73 | |
phoglund@webrtc.org | a7303bd | 2013-02-05 15:12:39 +0000 | [diff] [blame] | 74 | private: |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 75 | int32_t ParseAudioCodecSpecific(WebRtcRTPHeader* rtp_header, |
| 76 | const uint8_t* payload_data, |
| 77 | size_t payload_length, |
| 78 | const AudioPayload& audio_specific, |
| 79 | bool is_red); |
phoglund@webrtc.org | 92bb417 | 2012-12-13 10:48:24 +0000 | [diff] [blame] | 80 | |
phoglund@webrtc.org | a7303bd | 2013-02-05 15:12:39 +0000 | [diff] [blame] | 81 | bool telephone_event_forward_to_decoder_; |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 82 | int8_t telephone_event_payload_type_; |
| 83 | std::set<uint8_t> telephone_event_reported_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 84 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 85 | int8_t cng_nb_payload_type_; |
| 86 | int8_t cng_wb_payload_type_; |
| 87 | int8_t cng_swb_payload_type_; |
| 88 | int8_t cng_fb_payload_type_; |
phoglund@webrtc.org | a7303bd | 2013-02-05 15:12:39 +0000 | [diff] [blame] | 89 | |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 90 | uint8_t num_energy_; |
| 91 | uint8_t current_remote_energy_[kRtpCsrcSize]; |
skvlad | 98bb664 | 2016-04-07 15:36:45 -0700 | [diff] [blame] | 92 | |
| 93 | ThreadUnsafeOneTimeEvent first_packet_received_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 94 | }; |
phoglund@webrtc.org | a7303bd | 2013-02-05 15:12:39 +0000 | [diff] [blame] | 95 | } // namespace webrtc |
| 96 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 97 | #endif // MODULES_RTP_RTCP_SOURCE_RTP_RECEIVER_AUDIO_H_ |