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

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

Issue 2524923002: Remove RTPPayloadStrategy and simplify RTPPayloadRegistry (Closed)
Patch Set: Rebase 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
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
29 // of payload handling.
30 class RTPPayloadStrategy {
31 public:
32 virtual ~RTPPayloadStrategy() {}
33
34 virtual bool CodecsMustBeUnique() const = 0;
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 };
58
59 class RTPPayloadRegistry { 28 class RTPPayloadRegistry {
60 public: 29 public:
61 // The registry takes ownership of the strategy. 30 RTPPayloadRegistry();
62 explicit RTPPayloadRegistry(RTPPayloadStrategy* rtp_payload_strategy);
63 ~RTPPayloadRegistry();
danilchap 2016/11/23 19:06:17 restore destructor: it is default, but not trivial
magjed_webrtc 2016/11/24 12:20:39 True, done.
64 31
65 // TODO(magjed): Split RTPPayloadRegistry into separate Audio and Video class 32 // TODO(magjed): Split RTPPayloadRegistry into separate Audio and Video class
66 // and remove RTPPayloadStrategy, RTPPayloadVideoStrategy, 33 // 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, 34 int32_t RegisterReceivePayload(const CodecInst& audio_codec,
69 bool* created_new_payload_type); 35 bool* created_new_payload_type);
70 int32_t RegisterReceivePayload(const VideoCodec& video_codec); 36 int32_t RegisterReceivePayload(const VideoCodec& video_codec);
71 37
72 int32_t DeRegisterReceivePayload(int8_t payload_type); 38 int32_t DeRegisterReceivePayload(int8_t payload_type);
73 39
74 int32_t ReceivePayloadType(const CodecInst& audio_codec, 40 int32_t ReceivePayloadType(const CodecInst& audio_codec,
75 int8_t* payload_type) const; 41 int8_t* payload_type) const;
76 int32_t ReceivePayloadType(const VideoCodec& video_codec, 42 int32_t ReceivePayloadType(const VideoCodec& video_codec,
77 int8_t* payload_type) const; 43 int8_t* payload_type) const;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 77 }
112 78
113 // This sets the payload type of the packets being received from the network 79 // 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 80 // on the media SSRC. For instance if packets are encapsulated with RED, this
115 // payload type will be the RED payload type. 81 // payload type will be the RED payload type.
116 void SetIncomingPayloadType(const RTPHeader& header); 82 void SetIncomingPayloadType(const RTPHeader& header);
117 83
118 // Returns true if the new media payload type has not changed. 84 // Returns true if the new media payload type has not changed.
119 bool ReportMediaPayloadType(uint8_t media_payload_type); 85 bool ReportMediaPayloadType(uint8_t media_payload_type);
120 86
121 int8_t red_payload_type() const { 87 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 { 88 int8_t ulpfec_payload_type() const {
126 rtc::CritScope cs(&crit_sect_); 89 return GetPayloadTypeWithName("ulpfec");
127 return ulpfec_payload_type_;
128 } 90 }
129 int8_t last_received_payload_type() const { 91 int8_t last_received_payload_type() const {
130 rtc::CritScope cs(&crit_sect_); 92 rtc::CritScope cs(&crit_sect_);
131 return last_received_payload_type_; 93 return last_received_payload_type_;
132 } 94 }
133 void set_last_received_payload_type(int8_t last_received_payload_type) { 95 void set_last_received_payload_type(int8_t last_received_payload_type) {
134 rtc::CritScope cs(&crit_sect_); 96 rtc::CritScope cs(&crit_sect_);
135 last_received_payload_type_ = last_received_payload_type; 97 last_received_payload_type_ = last_received_payload_type;
136 } 98 }
137 99
138 int8_t last_received_media_payload_type() const { 100 int8_t last_received_media_payload_type() const {
139 rtc::CritScope cs(&crit_sect_); 101 rtc::CritScope cs(&crit_sect_);
140 return last_received_media_payload_type_; 102 return last_received_media_payload_type_;
141 } 103 }
142 104
143 RTC_DEPRECATED void set_use_rtx_payload_mapping_on_restore(bool val) {} 105 RTC_DEPRECATED void set_use_rtx_payload_mapping_on_restore(bool val) {}
144 106
145 private: 107 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. 108 // Prunes the payload type map of the specific payload type, if it exists.
160 void DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType( 109 void DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType(
161 const char* payload_name, 110 const CodecInst& audio_codec);
162 size_t payload_name_length,
163 uint32_t frequency,
164 size_t channels,
165 uint32_t rate);
166 111
167 bool IsRtxInternal(const RTPHeader& header) const; 112 bool IsRtxInternal(const RTPHeader& header) const;
113 // Returns the payload type for the payload with name |payload_name|, or -1 if
114 // no such payload is registered.
115 int8_t GetPayloadTypeWithName(const char* payload_name) const;
168 116
169 rtc::CriticalSection crit_sect_; 117 rtc::CriticalSection crit_sect_;
170 RtpUtility::PayloadTypeMap payload_type_map_; 118 std::map<int8_t, RtpUtility::Payload> payload_type_map_;
danilchap 2016/11/23 19:06:17 bette use int for the payload type
magjed_webrtc 2016/11/24 12:20:39 Done.
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_; 119 int8_t incoming_payload_type_;
175 int8_t last_received_payload_type_; 120 int8_t last_received_payload_type_;
176 int8_t last_received_media_payload_type_; 121 int8_t last_received_media_payload_type_;
177 bool rtx_; 122 bool rtx_;
178 // Mapping rtx_payload_type_map_[rtx] = associated. 123 // Mapping rtx_payload_type_map_[rtx] = associated.
179 std::map<int, int> rtx_payload_type_map_; 124 std::map<int, int> rtx_payload_type_map_;
180 uint32_t ssrc_rtx_; 125 uint32_t ssrc_rtx_;
181 // Only warn once per payload type, if an RTX packet is received but 126 // Only warn once per payload type, if an RTX packet is received but
182 // no associated payload type found in |rtx_payload_type_map_|. 127 // no associated payload type found in |rtx_payload_type_map_|.
183 std::set<int> payload_types_with_suppressed_warnings_ GUARDED_BY(crit_sect_); 128 std::set<int> payload_types_with_suppressed_warnings_ GUARDED_BY(crit_sect_);
184 }; 129 };
185 130
186 } // namespace webrtc 131 } // namespace webrtc
187 132
188 #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_ 133 #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698