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 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" | 11 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" |
12 | 12 |
13 #include "webrtc/base/logging.h" | 13 #include "webrtc/base/logging.h" |
| 14 #include "webrtc/common_types.h" |
14 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 15 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
15 | 16 |
16 namespace webrtc { | 17 namespace webrtc { |
17 | 18 |
18 RTPPayloadRegistry::RTPPayloadRegistry(RTPPayloadStrategy* rtp_payload_strategy) | 19 RTPPayloadRegistry::RTPPayloadRegistry(RTPPayloadStrategy* rtp_payload_strategy) |
19 : rtp_payload_strategy_(rtp_payload_strategy), | 20 : rtp_payload_strategy_(rtp_payload_strategy), |
20 red_payload_type_(-1), | 21 red_payload_type_(-1), |
21 ulpfec_payload_type_(-1), | 22 ulpfec_payload_type_(-1), |
22 incoming_payload_type_(-1), | 23 incoming_payload_type_(-1), |
23 last_received_payload_type_(-1), | 24 last_received_payload_type_(-1), |
24 last_received_media_payload_type_(-1), | 25 last_received_media_payload_type_(-1), |
25 rtx_(false), | 26 rtx_(false), |
26 ssrc_rtx_(0) {} | 27 ssrc_rtx_(0) {} |
27 | 28 |
28 RTPPayloadRegistry::~RTPPayloadRegistry() { | 29 RTPPayloadRegistry::~RTPPayloadRegistry() { |
29 while (!payload_type_map_.empty()) { | 30 while (!payload_type_map_.empty()) { |
30 RtpUtility::PayloadTypeMap::iterator it = payload_type_map_.begin(); | 31 RtpUtility::PayloadTypeMap::iterator it = payload_type_map_.begin(); |
31 delete it->second; | 32 delete it->second; |
32 payload_type_map_.erase(it); | 33 payload_type_map_.erase(it); |
33 } | 34 } |
34 } | 35 } |
35 | 36 |
| 37 int32_t RTPPayloadRegistry::RegisterReceivePayload(const CodecInst& audio_codec, |
| 38 bool* created_new_payload) { |
| 39 return RegisterReceivePayload( |
| 40 audio_codec.plname, audio_codec.pltype, audio_codec.plfreq, |
| 41 audio_codec.channels, std::max(0, audio_codec.rate), created_new_payload); |
| 42 } |
| 43 |
| 44 int32_t RTPPayloadRegistry::RegisterReceivePayload( |
| 45 const VideoCodec& video_codec) { |
| 46 bool dummy_created_new_payload; |
| 47 return RegisterReceivePayload(video_codec.plName, video_codec.plType, |
| 48 kVideoPayloadTypeFrequency, 0 /* channels */, |
| 49 0 /* rate */, &dummy_created_new_payload); |
| 50 } |
| 51 |
36 int32_t RTPPayloadRegistry::RegisterReceivePayload( | 52 int32_t RTPPayloadRegistry::RegisterReceivePayload( |
37 const char* const payload_name, | 53 const char* const payload_name, |
38 const int8_t payload_type, | 54 const int8_t payload_type, |
39 const uint32_t frequency, | 55 const uint32_t frequency, |
40 const size_t channels, | 56 const size_t channels, |
41 const uint32_t rate, | 57 const uint32_t rate, |
42 bool* created_new_payload) { | 58 bool* created_new_payload) { |
43 assert(payload_type >= 0); | 59 assert(payload_type >= 0); |
44 assert(payload_name); | 60 assert(payload_name); |
45 *created_new_payload = false; | 61 *created_new_payload = false; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 174 } |
159 } else if (RtpUtility::StringCompare(payload_name, "red", 3)) { | 175 } else if (RtpUtility::StringCompare(payload_name, "red", 3)) { |
160 delete payload; | 176 delete payload; |
161 payload_type_map_.erase(iterator); | 177 payload_type_map_.erase(iterator); |
162 break; | 178 break; |
163 } | 179 } |
164 } | 180 } |
165 } | 181 } |
166 } | 182 } |
167 | 183 |
| 184 int32_t RTPPayloadRegistry::ReceivePayloadType(const CodecInst& audio_codec, |
| 185 int8_t* payload_type) const { |
| 186 return ReceivePayloadType(audio_codec.plname, audio_codec.plfreq, |
| 187 audio_codec.channels, std::max(0, audio_codec.rate), |
| 188 payload_type); |
| 189 } |
| 190 |
| 191 int32_t RTPPayloadRegistry::ReceivePayloadType(const VideoCodec& video_codec, |
| 192 int8_t* payload_type) const { |
| 193 return ReceivePayloadType(video_codec.plName, kVideoPayloadTypeFrequency, |
| 194 0 /* channels */, 0 /* rate */, payload_type); |
| 195 } |
| 196 |
168 int32_t RTPPayloadRegistry::ReceivePayloadType(const char* const payload_name, | 197 int32_t RTPPayloadRegistry::ReceivePayloadType(const char* const payload_name, |
169 const uint32_t frequency, | 198 const uint32_t frequency, |
170 const size_t channels, | 199 const size_t channels, |
171 const uint32_t rate, | 200 const uint32_t rate, |
172 int8_t* payload_type) const { | 201 int8_t* payload_type) const { |
173 assert(payload_type); | 202 assert(payload_type); |
174 size_t payload_name_length = strlen(payload_name); | 203 size_t payload_name_length = strlen(payload_name); |
175 | 204 |
176 rtc::CritScope cs(&crit_sect_); | 205 rtc::CritScope cs(&crit_sect_); |
177 | 206 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 RTPPayloadStrategy* RTPPayloadStrategy::CreateStrategy( | 491 RTPPayloadStrategy* RTPPayloadStrategy::CreateStrategy( |
463 const bool handling_audio) { | 492 const bool handling_audio) { |
464 if (handling_audio) { | 493 if (handling_audio) { |
465 return new RTPPayloadAudioStrategy(); | 494 return new RTPPayloadAudioStrategy(); |
466 } else { | 495 } else { |
467 return new RTPPayloadVideoStrategy(); | 496 return new RTPPayloadVideoStrategy(); |
468 } | 497 } |
469 } | 498 } |
470 | 499 |
471 } // namespace webrtc | 500 } // namespace webrtc |
OLD | NEW |