Line data Source code
1 : /*
2 : * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
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 :
11 : #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_RECEIVER_AUDIO_H_
12 : #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_RECEIVER_AUDIO_H_
13 :
14 : #include <set>
15 :
16 : #include "webrtc/base/onetimeevent.h"
17 : #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h"
18 : #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
19 : #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h"
20 : #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
21 : #include "webrtc/typedefs.h"
22 :
23 : namespace webrtc {
24 :
25 : // Handles audio RTP packets. This class is thread-safe.
26 : class RTPReceiverAudio : public RTPReceiverStrategy,
27 : public TelephoneEventHandler {
28 : public:
29 : explicit RTPReceiverAudio(RtpData* data_callback);
30 0 : virtual ~RTPReceiverAudio() {}
31 :
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 :
39 : // Is TelephoneEvent configured with |payload_type|.
40 : bool TelephoneEventPayloadType(const int8_t payload_type) const override;
41 :
42 0 : TelephoneEventHandler* GetTelephoneEventHandler() override { return this; }
43 :
44 : // Returns true if CNG is configured with |payload_type|.
45 : bool CNGPayloadType(const int8_t payload_type);
46 :
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,
52 : int64_t timestamp_ms,
53 : bool is_first_packet) override;
54 :
55 : RTPAliveType ProcessDeadOrAlive(uint16_t last_payload_length) const override;
56 :
57 : bool ShouldReportCsrcChanges(uint8_t payload_type) const override;
58 :
59 : int32_t OnNewPayloadTypeCreated(const CodecInst& audio_codec) override;
60 :
61 : int32_t InvokeOnInitializeDecoder(
62 : RtpFeedback* callback,
63 : int8_t payload_type,
64 : const char payload_name[RTP_PAYLOAD_NAME_SIZE],
65 : const PayloadUnion& specific_payload) const override;
66 :
67 : // We need to look out for special payload types here and sometimes reset
68 : // statistics. In addition we sometimes need to tweak the frequency.
69 : void CheckPayloadChanged(int8_t payload_type,
70 : PayloadUnion* specific_payload,
71 : bool* should_discard_changes) override;
72 :
73 : int Energy(uint8_t array_of_energy[kRtpCsrcSize]) const override;
74 :
75 : private:
76 : int32_t ParseAudioCodecSpecific(WebRtcRTPHeader* rtp_header,
77 : const uint8_t* payload_data,
78 : size_t payload_length,
79 : const AudioPayload& audio_specific,
80 : bool is_red);
81 :
82 : bool telephone_event_forward_to_decoder_;
83 : int8_t telephone_event_payload_type_;
84 : std::set<uint8_t> telephone_event_reported_;
85 :
86 : int8_t cng_nb_payload_type_;
87 : int8_t cng_wb_payload_type_;
88 : int8_t cng_swb_payload_type_;
89 : int8_t cng_fb_payload_type_;
90 :
91 : uint8_t num_energy_;
92 : uint8_t current_remote_energy_[kRtpCsrcSize];
93 :
94 : ThreadUnsafeOneTimeEvent first_packet_received_;
95 : };
96 : } // namespace webrtc
97 :
98 : #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_RECEIVER_AUDIO_H_
|