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

Side by Side Diff: webrtc/media/base/codec.h

Issue 1845673002: Removing `preference` field from `cricket::Codec`. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing sort order (got reversed when optimizations were made) Created 4 years, 8 months 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/api/webrtcsession_unittest.cc ('k') | webrtc/media/base/codec.cc » ('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) 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2004 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
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 private: 57 private:
58 bool HasDuplicateEntries() const; 58 bool HasDuplicateEntries() const;
59 59
60 std::vector<FeedbackParam> params_; 60 std::vector<FeedbackParam> params_;
61 }; 61 };
62 62
63 struct Codec { 63 struct Codec {
64 int id; 64 int id;
65 std::string name; 65 std::string name;
66 int clockrate; 66 int clockrate;
67 int preference;
68 CodecParameterMap params; 67 CodecParameterMap params;
69 FeedbackParams feedback_params; 68 FeedbackParams feedback_params;
70 69
71 // Creates a codec with the given parameters. 70 // Creates a codec with the given parameters.
72 Codec(int id, const std::string& name, int clockrate, int preference); 71 Codec(int id, const std::string& name, int clockrate);
73 // Creates an empty codec. 72 // Creates an empty codec.
74 Codec(); 73 Codec();
75 Codec(const Codec& c); 74 Codec(const Codec& c);
76 ~Codec(); 75 ~Codec();
77 76
78 // Indicates if this codec is compatible with the specified codec. 77 // Indicates if this codec is compatible with the specified codec.
79 bool Matches(const Codec& codec) const; 78 bool Matches(const Codec& codec) const;
80 79
81 // Find the parameter for |name| and write the value to |out|. 80 // Find the parameter for |name| and write the value to |out|.
82 bool GetParam(const std::string& name, std::string* out) const; 81 bool GetParam(const std::string& name, std::string* out) const;
83 bool GetParam(const std::string& name, int* out) const; 82 bool GetParam(const std::string& name, int* out) const;
84 83
85 void SetParam(const std::string& name, const std::string& value); 84 void SetParam(const std::string& name, const std::string& value);
86 void SetParam(const std::string& name, int value); 85 void SetParam(const std::string& name, int value);
87 86
88 // It is safe to input a non-existent parameter. 87 // It is safe to input a non-existent parameter.
89 // Returns true if the parameter existed, false if it did not exist. 88 // Returns true if the parameter existed, false if it did not exist.
90 bool RemoveParam(const std::string& name); 89 bool RemoveParam(const std::string& name);
91 90
92 bool HasFeedbackParam(const FeedbackParam& param) const; 91 bool HasFeedbackParam(const FeedbackParam& param) const;
93 void AddFeedbackParam(const FeedbackParam& param); 92 void AddFeedbackParam(const FeedbackParam& param);
94 93
95 static bool Preferable(const Codec& first, const Codec& other) {
96 return first.preference > other.preference;
97 }
98
99 // Filter |this| feedbacks params such that only those shared by both |this| 94 // Filter |this| feedbacks params such that only those shared by both |this|
100 // and |other| are kept. 95 // and |other| are kept.
101 void IntersectFeedbackParams(const Codec& other); 96 void IntersectFeedbackParams(const Codec& other);
102 97
103 Codec& operator=(const Codec& c); 98 Codec& operator=(const Codec& c);
104 99
105 bool operator==(const Codec& c) const; 100 bool operator==(const Codec& c) const;
106 101
107 bool operator!=(const Codec& c) const { 102 bool operator!=(const Codec& c) const {
108 return !(*this == c); 103 return !(*this == c);
109 } 104 }
110 }; 105 };
111 106
112 struct AudioCodec : public Codec { 107 struct AudioCodec : public Codec {
113 int bitrate; 108 int bitrate;
114 size_t channels; 109 size_t channels;
115 110
116 // Creates a codec with the given parameters. 111 // Creates a codec with the given parameters.
117 AudioCodec(int id, 112 AudioCodec(int id,
118 const std::string& name, 113 const std::string& name,
119 int clockrate, 114 int clockrate,
120 int bitrate, 115 int bitrate,
121 size_t channels, 116 size_t channels);
122 int preference);
123 // Creates an empty codec. 117 // Creates an empty codec.
124 AudioCodec(); 118 AudioCodec();
125 AudioCodec(const AudioCodec& c); 119 AudioCodec(const AudioCodec& c);
126 ~AudioCodec() = default; 120 ~AudioCodec() = default;
127 121
128 // Indicates if this codec is compatible with the specified codec. 122 // Indicates if this codec is compatible with the specified codec.
129 bool Matches(const AudioCodec& codec) const; 123 bool Matches(const AudioCodec& codec) const;
130 124
131 static bool Preferable(const AudioCodec& first, const AudioCodec& other) {
132 return first.preference > other.preference;
133 }
134
135 std::string ToString() const; 125 std::string ToString() const;
136 126
137 AudioCodec& operator=(const AudioCodec& c); 127 AudioCodec& operator=(const AudioCodec& c);
138 128
139 bool operator==(const AudioCodec& c) const; 129 bool operator==(const AudioCodec& c) const;
140 130
141 bool operator!=(const AudioCodec& c) const { 131 bool operator!=(const AudioCodec& c) const {
142 return !(*this == c); 132 return !(*this == c);
143 } 133 }
144 }; 134 };
145 135
146 struct VideoCodec : public Codec { 136 struct VideoCodec : public Codec {
147 int width; 137 int width;
148 int height; 138 int height;
149 int framerate; 139 int framerate;
150 140
151 // Creates a codec with the given parameters. 141 // Creates a codec with the given parameters.
152 VideoCodec(int id, 142 VideoCodec(int id,
153 const std::string& name, 143 const std::string& name,
154 int width, 144 int width,
155 int height, 145 int height,
156 int framerate, 146 int framerate);
157 int preference);
158 VideoCodec(int id, const std::string& name); 147 VideoCodec(int id, const std::string& name);
159 // Creates an empty codec. 148 // Creates an empty codec.
160 VideoCodec(); 149 VideoCodec();
161 VideoCodec(const VideoCodec& c); 150 VideoCodec(const VideoCodec& c);
162 ~VideoCodec() = default; 151 ~VideoCodec() = default;
163 152
164 static bool Preferable(const VideoCodec& first, const VideoCodec& other) {
165 return first.preference > other.preference;
166 }
167
168 std::string ToString() const; 153 std::string ToString() const;
169 154
170 VideoCodec& operator=(const VideoCodec& c); 155 VideoCodec& operator=(const VideoCodec& c);
171 156
172 bool operator==(const VideoCodec& c) const; 157 bool operator==(const VideoCodec& c) const;
173 158
174 bool operator!=(const VideoCodec& c) const { 159 bool operator!=(const VideoCodec& c) const {
175 return !(*this == c); 160 return !(*this == c);
176 } 161 }
177 162
178 static VideoCodec CreateRtxCodec(int rtx_payload_type, 163 static VideoCodec CreateRtxCodec(int rtx_payload_type,
179 int associated_payload_type); 164 int associated_payload_type);
180 165
181 enum CodecType { 166 enum CodecType {
182 CODEC_VIDEO, 167 CODEC_VIDEO,
183 CODEC_RED, 168 CODEC_RED,
184 CODEC_ULPFEC, 169 CODEC_ULPFEC,
185 CODEC_RTX, 170 CODEC_RTX,
186 }; 171 };
187 172
188 CodecType GetCodecType() const; 173 CodecType GetCodecType() const;
189 // Validates a VideoCodec's payload type, dimensions and bitrates etc. If they 174 // Validates a VideoCodec's payload type, dimensions and bitrates etc. If they
190 // don't make sense (such as max < min bitrate), and error is logged and 175 // don't make sense (such as max < min bitrate), and error is logged and
191 // ValidateCodecFormat returns false. 176 // ValidateCodecFormat returns false.
192 bool ValidateCodecFormat() const; 177 bool ValidateCodecFormat() const;
193 }; 178 };
194 179
195 struct DataCodec : public Codec { 180 struct DataCodec : public Codec {
196 DataCodec(int id, const std::string& name, int preference); 181 DataCodec(int id, const std::string& name);
197 DataCodec(); 182 DataCodec();
198 DataCodec(const DataCodec& c); 183 DataCodec(const DataCodec& c);
199 184
200 DataCodec& operator=(const DataCodec& c); 185 DataCodec& operator=(const DataCodec& c);
201 186
202 std::string ToString() const; 187 std::string ToString() const;
203 }; 188 };
204 189
205 // Get the codec setting associated with |payload_type|. If there 190 // Get the codec setting associated with |payload_type|. If there
206 // is no codec associated with that payload type it returns false. 191 // is no codec associated with that payload type it returns false.
(...skipping 11 matching lines...) Expand all
218 } 203 }
219 204
220 bool CodecNamesEq(const std::string& name1, const std::string& name2); 205 bool CodecNamesEq(const std::string& name1, const std::string& name2);
221 bool HasNack(const Codec& codec); 206 bool HasNack(const Codec& codec);
222 bool HasRemb(const Codec& codec); 207 bool HasRemb(const Codec& codec);
223 bool HasTransportCc(const Codec& codec); 208 bool HasTransportCc(const Codec& codec);
224 209
225 } // namespace cricket 210 } // namespace cricket
226 211
227 #endif // WEBRTC_MEDIA_BASE_CODEC_H_ 212 #endif // WEBRTC_MEDIA_BASE_CODEC_H_
OLDNEW
« no previous file with comments | « webrtc/api/webrtcsession_unittest.cc ('k') | webrtc/media/base/codec.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698