Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h

Issue 2531043002: Reland of move RTPPayloadStrategy and simplify RTPPayloadRegistry (Closed)
Patch Set: Remove deprecated RegisterReceivePayload function in RtpReceiver Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/modules/rtp_rtcp/BUILD.gn ('k') | webrtc/modules/rtp_rtcp/include/rtp_receiver.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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; 25 struct CodecInst;
26 class VideoCodec; 26 class VideoCodec;
27 27
28 // This strategy deals with the audio/video-specific aspects 28 // TODO(magjed): Remove once external code is updated.
29 // of payload handling.
30 class RTPPayloadStrategy { 29 class RTPPayloadStrategy {
31 public: 30 public:
32 virtual ~RTPPayloadStrategy() {} 31 static RTPPayloadStrategy* CreateStrategy(bool handling_audio) {
33 32 return nullptr;
34 virtual bool CodecsMustBeUnique() const = 0; 33 }
35
36 virtual bool PayloadIsCompatible(const RtpUtility::Payload& payload,
37 uint32_t frequency,
38 size_t channels,
39 uint32_t rate) const = 0;
40
41 virtual void UpdatePayloadRate(RtpUtility::Payload* payload,
42 uint32_t rate) const = 0;
43
44 virtual RtpUtility::Payload* CreatePayloadType(const char* payload_name,
45 int8_t payload_type,
46 uint32_t frequency,
47 size_t channels,
48 uint32_t rate) const = 0;
49
50 virtual int GetPayloadTypeFrequency(
51 const RtpUtility::Payload& payload) const = 0;
52
53 static RTPPayloadStrategy* CreateStrategy(bool handling_audio);
54
55 protected:
56 RTPPayloadStrategy() {}
57 }; 34 };
58 35
59 class RTPPayloadRegistry { 36 class RTPPayloadRegistry {
60 public: 37 public:
61 // The registry takes ownership of the strategy. 38 RTPPayloadRegistry();
62 explicit RTPPayloadRegistry(RTPPayloadStrategy* rtp_payload_strategy);
63 ~RTPPayloadRegistry(); 39 ~RTPPayloadRegistry();
40 // TODO(magjed): Remove once external code is updated.
41 explicit RTPPayloadRegistry(RTPPayloadStrategy* rtp_payload_strategy)
42 : RTPPayloadRegistry() {}
64 43
65 // TODO(magjed): Split RTPPayloadRegistry into separate Audio and Video class 44 // TODO(magjed): Split RTPPayloadRegistry into separate Audio and Video class
66 // and remove RTPPayloadStrategy, RTPPayloadVideoStrategy, 45 // and simplify the code. http://crbug/webrtc/6743.
67 // RTPPayloadAudioStrategy, and simplify the code. http://crbug/webrtc/6743.
68 int32_t RegisterReceivePayload(const CodecInst& audio_codec, 46 int32_t RegisterReceivePayload(const CodecInst& audio_codec,
69 bool* created_new_payload_type); 47 bool* created_new_payload_type);
70 int32_t RegisterReceivePayload(const VideoCodec& video_codec); 48 int32_t RegisterReceivePayload(const VideoCodec& video_codec);
71 49
72 int32_t DeRegisterReceivePayload(int8_t payload_type); 50 int32_t DeRegisterReceivePayload(int8_t payload_type);
73 51
74 int32_t ReceivePayloadType(const CodecInst& audio_codec, 52 int32_t ReceivePayloadType(const CodecInst& audio_codec,
75 int8_t* payload_type) const; 53 int8_t* payload_type) const;
76 int32_t ReceivePayloadType(const VideoCodec& video_codec, 54 int32_t ReceivePayloadType(const VideoCodec& video_codec,
77 int8_t* payload_type) const; 55 int8_t* payload_type) const;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 89 }
112 90
113 // This sets the payload type of the packets being received from the network 91 // This sets the payload type of the packets being received from the network
114 // on the media SSRC. For instance if packets are encapsulated with RED, this 92 // on the media SSRC. For instance if packets are encapsulated with RED, this
115 // payload type will be the RED payload type. 93 // payload type will be the RED payload type.
116 void SetIncomingPayloadType(const RTPHeader& header); 94 void SetIncomingPayloadType(const RTPHeader& header);
117 95
118 // Returns true if the new media payload type has not changed. 96 // Returns true if the new media payload type has not changed.
119 bool ReportMediaPayloadType(uint8_t media_payload_type); 97 bool ReportMediaPayloadType(uint8_t media_payload_type);
120 98
121 int8_t red_payload_type() const { 99 int8_t red_payload_type() const { return GetPayloadTypeWithName("red"); }
122 rtc::CritScope cs(&crit_sect_);
123 return red_payload_type_;
124 }
125 int8_t ulpfec_payload_type() const { 100 int8_t ulpfec_payload_type() const {
126 rtc::CritScope cs(&crit_sect_); 101 return GetPayloadTypeWithName("ulpfec");
127 return ulpfec_payload_type_;
128 } 102 }
129 int8_t last_received_payload_type() const { 103 int8_t last_received_payload_type() const {
130 rtc::CritScope cs(&crit_sect_); 104 rtc::CritScope cs(&crit_sect_);
131 return last_received_payload_type_; 105 return last_received_payload_type_;
132 } 106 }
133 void set_last_received_payload_type(int8_t last_received_payload_type) { 107 void set_last_received_payload_type(int8_t last_received_payload_type) {
134 rtc::CritScope cs(&crit_sect_); 108 rtc::CritScope cs(&crit_sect_);
135 last_received_payload_type_ = last_received_payload_type; 109 last_received_payload_type_ = last_received_payload_type;
136 } 110 }
137 111
138 int8_t last_received_media_payload_type() const { 112 int8_t last_received_media_payload_type() const {
139 rtc::CritScope cs(&crit_sect_); 113 rtc::CritScope cs(&crit_sect_);
140 return last_received_media_payload_type_; 114 return last_received_media_payload_type_;
141 } 115 }
142 116
143 RTC_DEPRECATED void set_use_rtx_payload_mapping_on_restore(bool val) {} 117 RTC_DEPRECATED void set_use_rtx_payload_mapping_on_restore(bool val) {}
144 118
145 private: 119 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
159 // Prunes the payload type map of the specific payload type, if it exists. 120 // Prunes the payload type map of the specific payload type, if it exists.
160 void DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType( 121 void DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType(
161 const char* payload_name, 122 const CodecInst& audio_codec);
162 size_t payload_name_length,
163 uint32_t frequency,
164 size_t channels,
165 uint32_t rate);
166 123
167 bool IsRtxInternal(const RTPHeader& header) const; 124 bool IsRtxInternal(const RTPHeader& header) const;
125 // Returns the payload type for the payload with name |payload_name|, or -1 if
126 // no such payload is registered.
127 int8_t GetPayloadTypeWithName(const char* payload_name) const;
168 128
169 rtc::CriticalSection crit_sect_; 129 rtc::CriticalSection crit_sect_;
170 RtpUtility::PayloadTypeMap payload_type_map_; 130 std::map<int, RtpUtility::Payload> payload_type_map_;
171 std::unique_ptr<RTPPayloadStrategy> rtp_payload_strategy_;
172 int8_t red_payload_type_;
173 int8_t ulpfec_payload_type_;
174 int8_t incoming_payload_type_; 131 int8_t incoming_payload_type_;
175 int8_t last_received_payload_type_; 132 int8_t last_received_payload_type_;
176 int8_t last_received_media_payload_type_; 133 int8_t last_received_media_payload_type_;
177 bool rtx_; 134 bool rtx_;
178 // Mapping rtx_payload_type_map_[rtx] = associated. 135 // Mapping rtx_payload_type_map_[rtx] = associated.
179 std::map<int, int> rtx_payload_type_map_; 136 std::map<int, int> rtx_payload_type_map_;
180 uint32_t ssrc_rtx_; 137 uint32_t ssrc_rtx_;
181 // Only warn once per payload type, if an RTX packet is received but 138 // Only warn once per payload type, if an RTX packet is received but
182 // no associated payload type found in |rtx_payload_type_map_|. 139 // no associated payload type found in |rtx_payload_type_map_|.
183 std::set<int> payload_types_with_suppressed_warnings_ GUARDED_BY(crit_sect_); 140 std::set<int> payload_types_with_suppressed_warnings_ GUARDED_BY(crit_sect_);
184 }; 141 };
185 142
186 } // namespace webrtc 143 } // namespace webrtc
187 144
188 #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_ 145 #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/BUILD.gn ('k') | webrtc/modules/rtp_rtcp/include/rtp_receiver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698