OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_ |
12 #define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_ |
13 | 13 |
14 #include <map> | 14 #include <map> |
15 #include <memory> | 15 #include <memory> |
16 #include <set> | 16 #include <set> |
17 | 17 |
18 #include "webrtc/base/criticalsection.h" | 18 #include "webrtc/base/criticalsection.h" |
19 #include "webrtc/base/deprecation.h" | 19 #include "webrtc/base/deprecation.h" |
20 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h" | 20 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h" |
21 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" | 21 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
22 | 22 |
23 namespace webrtc { | 23 namespace webrtc { |
24 | 24 |
25 struct CodecInst; | |
26 class VideoCodec; | |
27 | |
25 // This strategy deals with the audio/video-specific aspects | 28 // This strategy deals with the audio/video-specific aspects |
26 // of payload handling. | 29 // of payload handling. |
27 class RTPPayloadStrategy { | 30 class RTPPayloadStrategy { |
28 public: | 31 public: |
29 virtual ~RTPPayloadStrategy() {} | 32 virtual ~RTPPayloadStrategy() {} |
30 | 33 |
31 virtual bool CodecsMustBeUnique() const = 0; | 34 virtual bool CodecsMustBeUnique() const = 0; |
32 | 35 |
33 virtual bool PayloadIsCompatible(const RtpUtility::Payload& payload, | 36 virtual bool PayloadIsCompatible(const RtpUtility::Payload& payload, |
34 uint32_t frequency, | 37 uint32_t frequency, |
(...skipping 17 matching lines...) Expand all Loading... | |
52 protected: | 55 protected: |
53 RTPPayloadStrategy() {} | 56 RTPPayloadStrategy() {} |
54 }; | 57 }; |
55 | 58 |
56 class RTPPayloadRegistry { | 59 class RTPPayloadRegistry { |
57 public: | 60 public: |
58 // The registry takes ownership of the strategy. | 61 // The registry takes ownership of the strategy. |
59 explicit RTPPayloadRegistry(RTPPayloadStrategy* rtp_payload_strategy); | 62 explicit RTPPayloadRegistry(RTPPayloadStrategy* rtp_payload_strategy); |
60 ~RTPPayloadRegistry(); | 63 ~RTPPayloadRegistry(); |
61 | 64 |
62 int32_t RegisterReceivePayload(const char* payload_name, | 65 // TODO(magjed): Split RTPPayloadRegistry into separate Audio and Video class |
63 int8_t payload_type, | 66 // and remove RTPPayloadStrategy, RTPPayloadVideoStrategy, |
64 uint32_t frequency, | 67 // RTPPayloadAudioStrategy, and simplify the code. http://crbug/webrtc/6743. |
65 size_t channels, | 68 int32_t RegisterReceivePayload(const CodecInst& audio_codec, |
66 uint32_t rate, | |
67 bool* created_new_payload_type); | 69 bool* created_new_payload_type); |
70 int32_t RegisterReceivePayload(const VideoCodec& video_codec); | |
the sun
2016/11/23 19:29:35
While I do agree that this CL is an improvement ov
magjed_webrtc
2016/11/24 09:39:40
The codec knowledge RTPPayloadRegistry needs to ha
| |
68 | 71 |
69 int32_t DeRegisterReceivePayload(int8_t payload_type); | 72 int32_t DeRegisterReceivePayload(int8_t payload_type); |
70 | 73 |
71 int32_t ReceivePayloadType(const char* payload_name, | 74 int32_t ReceivePayloadType(const CodecInst& audio_codec, |
72 uint32_t frequency, | 75 int8_t* payload_type) const; |
73 size_t channels, | 76 int32_t ReceivePayloadType(const VideoCodec& video_codec, |
74 uint32_t rate, | |
75 int8_t* payload_type) const; | 77 int8_t* payload_type) const; |
76 | 78 |
77 bool RtxEnabled() const; | 79 bool RtxEnabled() const; |
78 | 80 |
79 void SetRtxSsrc(uint32_t ssrc); | 81 void SetRtxSsrc(uint32_t ssrc); |
80 | 82 |
81 bool GetRtxSsrc(uint32_t* ssrc) const; | 83 bool GetRtxSsrc(uint32_t* ssrc) const; |
82 | 84 |
83 void SetRtxPayloadType(int payload_type, int associated_payload_type); | 85 void SetRtxPayloadType(int payload_type, int associated_payload_type); |
84 | 86 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 } | 136 } |
135 | 137 |
136 int8_t last_received_media_payload_type() const { | 138 int8_t last_received_media_payload_type() const { |
137 rtc::CritScope cs(&crit_sect_); | 139 rtc::CritScope cs(&crit_sect_); |
138 return last_received_media_payload_type_; | 140 return last_received_media_payload_type_; |
139 } | 141 } |
140 | 142 |
141 RTC_DEPRECATED void set_use_rtx_payload_mapping_on_restore(bool val) {} | 143 RTC_DEPRECATED void set_use_rtx_payload_mapping_on_restore(bool val) {} |
142 | 144 |
143 private: | 145 private: |
146 int32_t RegisterReceivePayload(const char* payload_name, | |
147 int8_t payload_type, | |
148 uint32_t frequency, | |
149 size_t channels, | |
150 uint32_t rate, | |
151 bool* created_new_payload_type); | |
152 | |
153 int32_t ReceivePayloadType(const char* payload_name, | |
154 uint32_t frequency, | |
155 size_t channels, | |
156 uint32_t rate, | |
157 int8_t* payload_type) const; | |
158 | |
144 // Prunes the payload type map of the specific payload type, if it exists. | 159 // Prunes the payload type map of the specific payload type, if it exists. |
145 void DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType( | 160 void DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType( |
146 const char* payload_name, | 161 const char* payload_name, |
147 size_t payload_name_length, | 162 size_t payload_name_length, |
148 uint32_t frequency, | 163 uint32_t frequency, |
149 size_t channels, | 164 size_t channels, |
150 uint32_t rate); | 165 uint32_t rate); |
151 | 166 |
152 bool IsRtxInternal(const RTPHeader& header) const; | 167 bool IsRtxInternal(const RTPHeader& header) const; |
153 | 168 |
(...skipping 10 matching lines...) Expand all Loading... | |
164 std::map<int, int> rtx_payload_type_map_; | 179 std::map<int, int> rtx_payload_type_map_; |
165 uint32_t ssrc_rtx_; | 180 uint32_t ssrc_rtx_; |
166 // Only warn once per payload type, if an RTX packet is received but | 181 // Only warn once per payload type, if an RTX packet is received but |
167 // no associated payload type found in |rtx_payload_type_map_|. | 182 // no associated payload type found in |rtx_payload_type_map_|. |
168 std::set<int> payload_types_with_suppressed_warnings_ GUARDED_BY(crit_sect_); | 183 std::set<int> payload_types_with_suppressed_warnings_ GUARDED_BY(crit_sect_); |
169 }; | 184 }; |
170 | 185 |
171 } // namespace webrtc | 186 } // namespace webrtc |
172 | 187 |
173 #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_ | 188 #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_ |
OLD | NEW |