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 |
(...skipping 22 matching lines...) Expand all Loading... |
33 RtpUtility::PayloadTypeMap::iterator it = payload_type_map_.begin(); | 33 RtpUtility::PayloadTypeMap::iterator it = payload_type_map_.begin(); |
34 delete it->second; | 34 delete it->second; |
35 payload_type_map_.erase(it); | 35 payload_type_map_.erase(it); |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 int32_t RTPPayloadRegistry::RegisterReceivePayload( | 39 int32_t RTPPayloadRegistry::RegisterReceivePayload( |
40 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | 40 const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
41 const int8_t payload_type, | 41 const int8_t payload_type, |
42 const uint32_t frequency, | 42 const uint32_t frequency, |
43 const uint8_t channels, | 43 const size_t channels, |
44 const uint32_t rate, | 44 const uint32_t rate, |
45 bool* created_new_payload) { | 45 bool* created_new_payload) { |
46 assert(payload_type >= 0); | 46 assert(payload_type >= 0); |
47 assert(payload_name); | 47 assert(payload_name); |
48 *created_new_payload = false; | 48 *created_new_payload = false; |
49 | 49 |
50 // Sanity check. | 50 // Sanity check. |
51 switch (payload_type) { | 51 switch (payload_type) { |
52 // Reserved payload types to avoid RTCP conflicts when marker bit is set. | 52 // Reserved payload types to avoid RTCP conflicts when marker bit is set. |
53 case 64: // 192 Full INTRA-frame request. | 53 case 64: // 192 Full INTRA-frame request. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 return 0; | 132 return 0; |
133 } | 133 } |
134 | 134 |
135 // There can't be several codecs with the same rate, frequency and channels | 135 // There can't be several codecs with the same rate, frequency and channels |
136 // for audio codecs, but there can for video. | 136 // for audio codecs, but there can for video. |
137 // Always called from within a critical section. | 137 // Always called from within a critical section. |
138 void RTPPayloadRegistry::DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType( | 138 void RTPPayloadRegistry::DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType( |
139 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | 139 const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
140 const size_t payload_name_length, | 140 const size_t payload_name_length, |
141 const uint32_t frequency, | 141 const uint32_t frequency, |
142 const uint8_t channels, | 142 const size_t channels, |
143 const uint32_t rate) { | 143 const uint32_t rate) { |
144 RtpUtility::PayloadTypeMap::iterator iterator = payload_type_map_.begin(); | 144 RtpUtility::PayloadTypeMap::iterator iterator = payload_type_map_.begin(); |
145 for (; iterator != payload_type_map_.end(); ++iterator) { | 145 for (; iterator != payload_type_map_.end(); ++iterator) { |
146 RtpUtility::Payload* payload = iterator->second; | 146 RtpUtility::Payload* payload = iterator->second; |
147 size_t name_length = strlen(payload->name); | 147 size_t name_length = strlen(payload->name); |
148 | 148 |
149 if (payload_name_length == name_length && | 149 if (payload_name_length == name_length && |
150 RtpUtility::StringCompare( | 150 RtpUtility::StringCompare( |
151 payload->name, payload_name, payload_name_length)) { | 151 payload->name, payload_name, payload_name_length)) { |
152 // We found the payload name in the list. | 152 // We found the payload name in the list. |
(...skipping 11 matching lines...) Expand all Loading... |
164 payload_type_map_.erase(iterator); | 164 payload_type_map_.erase(iterator); |
165 break; | 165 break; |
166 } | 166 } |
167 } | 167 } |
168 } | 168 } |
169 } | 169 } |
170 | 170 |
171 int32_t RTPPayloadRegistry::ReceivePayloadType( | 171 int32_t RTPPayloadRegistry::ReceivePayloadType( |
172 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | 172 const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
173 const uint32_t frequency, | 173 const uint32_t frequency, |
174 const uint8_t channels, | 174 const size_t channels, |
175 const uint32_t rate, | 175 const uint32_t rate, |
176 int8_t* payload_type) const { | 176 int8_t* payload_type) const { |
177 assert(payload_type); | 177 assert(payload_type); |
178 size_t payload_name_length = strlen(payload_name); | 178 size_t payload_name_length = strlen(payload_name); |
179 | 179 |
180 CriticalSectionScoped cs(crit_sect_.get()); | 180 CriticalSectionScoped cs(crit_sect_.get()); |
181 | 181 |
182 RtpUtility::PayloadTypeMap::const_iterator it = payload_type_map_.begin(); | 182 RtpUtility::PayloadTypeMap::const_iterator it = payload_type_map_.begin(); |
183 | 183 |
184 for (; it != payload_type_map_.end(); ++it) { | 184 for (; it != payload_type_map_.end(); ++it) { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 last_received_media_payload_type_ = media_payload_type; | 363 last_received_media_payload_type_ = media_payload_type; |
364 return false; | 364 return false; |
365 } | 365 } |
366 | 366 |
367 class RTPPayloadAudioStrategy : public RTPPayloadStrategy { | 367 class RTPPayloadAudioStrategy : public RTPPayloadStrategy { |
368 public: | 368 public: |
369 bool CodecsMustBeUnique() const override { return true; } | 369 bool CodecsMustBeUnique() const override { return true; } |
370 | 370 |
371 bool PayloadIsCompatible(const RtpUtility::Payload& payload, | 371 bool PayloadIsCompatible(const RtpUtility::Payload& payload, |
372 const uint32_t frequency, | 372 const uint32_t frequency, |
373 const uint8_t channels, | 373 const size_t channels, |
374 const uint32_t rate) const override { | 374 const uint32_t rate) const override { |
375 return | 375 return |
376 payload.audio && | 376 payload.audio && |
377 payload.typeSpecific.Audio.frequency == frequency && | 377 payload.typeSpecific.Audio.frequency == frequency && |
378 payload.typeSpecific.Audio.channels == channels && | 378 payload.typeSpecific.Audio.channels == channels && |
379 (payload.typeSpecific.Audio.rate == rate || | 379 (payload.typeSpecific.Audio.rate == rate || |
380 payload.typeSpecific.Audio.rate == 0 || rate == 0); | 380 payload.typeSpecific.Audio.rate == 0 || rate == 0); |
381 } | 381 } |
382 | 382 |
383 void UpdatePayloadRate(RtpUtility::Payload* payload, | 383 void UpdatePayloadRate(RtpUtility::Payload* payload, |
384 const uint32_t rate) const override { | 384 const uint32_t rate) const override { |
385 payload->typeSpecific.Audio.rate = rate; | 385 payload->typeSpecific.Audio.rate = rate; |
386 } | 386 } |
387 | 387 |
388 RtpUtility::Payload* CreatePayloadType( | 388 RtpUtility::Payload* CreatePayloadType( |
389 const char payloadName[RTP_PAYLOAD_NAME_SIZE], | 389 const char payloadName[RTP_PAYLOAD_NAME_SIZE], |
390 const int8_t payloadType, | 390 const int8_t payloadType, |
391 const uint32_t frequency, | 391 const uint32_t frequency, |
392 const uint8_t channels, | 392 const size_t channels, |
393 const uint32_t rate) const override { | 393 const uint32_t rate) const override { |
394 RtpUtility::Payload* payload = new RtpUtility::Payload; | 394 RtpUtility::Payload* payload = new RtpUtility::Payload; |
395 payload->name[RTP_PAYLOAD_NAME_SIZE - 1] = 0; | 395 payload->name[RTP_PAYLOAD_NAME_SIZE - 1] = 0; |
396 strncpy(payload->name, payloadName, RTP_PAYLOAD_NAME_SIZE - 1); | 396 strncpy(payload->name, payloadName, RTP_PAYLOAD_NAME_SIZE - 1); |
397 assert(frequency >= 1000); | 397 assert(frequency >= 1000); |
398 payload->typeSpecific.Audio.frequency = frequency; | 398 payload->typeSpecific.Audio.frequency = frequency; |
399 payload->typeSpecific.Audio.channels = channels; | 399 payload->typeSpecific.Audio.channels = channels; |
400 payload->typeSpecific.Audio.rate = rate; | 400 payload->typeSpecific.Audio.rate = rate; |
401 payload->audio = true; | 401 payload->audio = true; |
402 return payload; | 402 return payload; |
403 } | 403 } |
404 | 404 |
405 int GetPayloadTypeFrequency(const RtpUtility::Payload& payload) const { | 405 int GetPayloadTypeFrequency(const RtpUtility::Payload& payload) const { |
406 return payload.typeSpecific.Audio.frequency; | 406 return payload.typeSpecific.Audio.frequency; |
407 } | 407 } |
408 }; | 408 }; |
409 | 409 |
410 class RTPPayloadVideoStrategy : public RTPPayloadStrategy { | 410 class RTPPayloadVideoStrategy : public RTPPayloadStrategy { |
411 public: | 411 public: |
412 bool CodecsMustBeUnique() const override { return false; } | 412 bool CodecsMustBeUnique() const override { return false; } |
413 | 413 |
414 bool PayloadIsCompatible(const RtpUtility::Payload& payload, | 414 bool PayloadIsCompatible(const RtpUtility::Payload& payload, |
415 const uint32_t frequency, | 415 const uint32_t frequency, |
416 const uint8_t channels, | 416 const size_t channels, |
417 const uint32_t rate) const override { | 417 const uint32_t rate) const override { |
418 return !payload.audio; | 418 return !payload.audio; |
419 } | 419 } |
420 | 420 |
421 void UpdatePayloadRate(RtpUtility::Payload* payload, | 421 void UpdatePayloadRate(RtpUtility::Payload* payload, |
422 const uint32_t rate) const override { | 422 const uint32_t rate) const override { |
423 payload->typeSpecific.Video.maxRate = rate; | 423 payload->typeSpecific.Video.maxRate = rate; |
424 } | 424 } |
425 | 425 |
426 RtpUtility::Payload* CreatePayloadType( | 426 RtpUtility::Payload* CreatePayloadType( |
427 const char payloadName[RTP_PAYLOAD_NAME_SIZE], | 427 const char payloadName[RTP_PAYLOAD_NAME_SIZE], |
428 const int8_t payloadType, | 428 const int8_t payloadType, |
429 const uint32_t frequency, | 429 const uint32_t frequency, |
430 const uint8_t channels, | 430 const size_t channels, |
431 const uint32_t rate) const override { | 431 const uint32_t rate) const override { |
432 RtpVideoCodecTypes videoType = kRtpVideoGeneric; | 432 RtpVideoCodecTypes videoType = kRtpVideoGeneric; |
433 | 433 |
434 if (RtpUtility::StringCompare(payloadName, "VP8", 3)) { | 434 if (RtpUtility::StringCompare(payloadName, "VP8", 3)) { |
435 videoType = kRtpVideoVp8; | 435 videoType = kRtpVideoVp8; |
436 } else if (RtpUtility::StringCompare(payloadName, "H264", 4)) { | 436 } else if (RtpUtility::StringCompare(payloadName, "H264", 4)) { |
437 videoType = kRtpVideoH264; | 437 videoType = kRtpVideoH264; |
438 } else if (RtpUtility::StringCompare(payloadName, "I420", 4)) { | 438 } else if (RtpUtility::StringCompare(payloadName, "I420", 4)) { |
439 videoType = kRtpVideoGeneric; | 439 videoType = kRtpVideoGeneric; |
440 } else if (RtpUtility::StringCompare(payloadName, "ULPFEC", 6) || | 440 } else if (RtpUtility::StringCompare(payloadName, "ULPFEC", 6) || |
(...skipping 20 matching lines...) Expand all Loading... |
461 RTPPayloadStrategy* RTPPayloadStrategy::CreateStrategy( | 461 RTPPayloadStrategy* RTPPayloadStrategy::CreateStrategy( |
462 const bool handling_audio) { | 462 const bool handling_audio) { |
463 if (handling_audio) { | 463 if (handling_audio) { |
464 return new RTPPayloadAudioStrategy(); | 464 return new RTPPayloadAudioStrategy(); |
465 } else { | 465 } else { |
466 return new RTPPayloadVideoStrategy(); | 466 return new RTPPayloadVideoStrategy(); |
467 } | 467 } |
468 } | 468 } |
469 | 469 |
470 } // namespace webrtc | 470 } // namespace webrtc |
OLD | NEW |