OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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/source/rtp_receiver_impl.h" | 11 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_impl.h" |
12 | 12 |
13 #include <assert.h> | 13 #include <assert.h> |
14 #include <math.h> | 14 #include <math.h> |
15 #include <stdlib.h> | 15 #include <stdlib.h> |
16 #include <string.h> | 16 #include <string.h> |
17 | 17 |
18 #include "webrtc/base/logging.h" | 18 #include "webrtc/base/logging.h" |
| 19 #include "webrtc/common_types.h" |
19 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" | 20 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" |
20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 21 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
21 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h" | 22 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h" |
22 | 23 |
23 namespace webrtc { | 24 namespace webrtc { |
24 | 25 |
25 using RtpUtility::Payload; | 26 using RtpUtility::Payload; |
26 | 27 |
27 RtpReceiver* RtpReceiver::CreateVideoReceiver( | 28 RtpReceiver* RtpReceiver::CreateVideoReceiver( |
28 Clock* clock, | 29 Clock* clock, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 74 |
74 memset(current_remote_csrc_, 0, sizeof(current_remote_csrc_)); | 75 memset(current_remote_csrc_, 0, sizeof(current_remote_csrc_)); |
75 } | 76 } |
76 | 77 |
77 RtpReceiverImpl::~RtpReceiverImpl() { | 78 RtpReceiverImpl::~RtpReceiverImpl() { |
78 for (int i = 0; i < num_csrcs_; ++i) { | 79 for (int i = 0; i < num_csrcs_; ++i) { |
79 cb_rtp_feedback_->OnIncomingCSRCChanged(current_remote_csrc_[i], false); | 80 cb_rtp_feedback_->OnIncomingCSRCChanged(current_remote_csrc_[i], false); |
80 } | 81 } |
81 } | 82 } |
82 | 83 |
83 int32_t RtpReceiverImpl::RegisterReceivePayload( | 84 int32_t RtpReceiverImpl::RegisterReceivePayload(const CodecInst& audio_codec) { |
84 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | |
85 const int8_t payload_type, | |
86 const uint32_t frequency, | |
87 const size_t channels, | |
88 const uint32_t rate) { | |
89 rtc::CritScope lock(&critical_section_rtp_receiver_); | 85 rtc::CritScope lock(&critical_section_rtp_receiver_); |
90 | 86 |
91 // TODO(phoglund): Try to streamline handling of the RED codec and some other | 87 // TODO(phoglund): Try to streamline handling of the RED codec and some other |
92 // cases which makes it necessary to keep track of whether we created a | 88 // cases which makes it necessary to keep track of whether we created a |
93 // payload or not. | 89 // payload or not. |
94 bool created_new_payload = false; | 90 bool created_new_payload = false; |
95 int32_t result = rtp_payload_registry_->RegisterReceivePayload( | 91 int32_t result = rtp_payload_registry_->RegisterReceivePayload( |
96 payload_name, payload_type, frequency, channels, rate, | 92 audio_codec, &created_new_payload); |
97 &created_new_payload); | |
98 if (created_new_payload) { | 93 if (created_new_payload) { |
99 if (rtp_media_receiver_->OnNewPayloadTypeCreated(payload_name, payload_type, | 94 if (rtp_media_receiver_->OnNewPayloadTypeCreated(audio_codec) != 0) { |
100 frequency) != 0) { | 95 LOG(LS_ERROR) << "Failed to register payload: " << audio_codec.plname |
101 LOG(LS_ERROR) << "Failed to register payload: " << payload_name << "/" | 96 << "/" << static_cast<int>(audio_codec.pltype); |
102 << static_cast<int>(payload_type); | |
103 return -1; | 97 return -1; |
104 } | 98 } |
105 } | 99 } |
106 return result; | 100 return result; |
107 } | 101 } |
108 | 102 |
109 int32_t RtpReceiverImpl::DeRegisterReceivePayload( | 103 int32_t RtpReceiverImpl::DeRegisterReceivePayload( |
110 const int8_t payload_type) { | 104 const int8_t payload_type) { |
111 rtc::CritScope lock(&critical_section_rtp_receiver_); | 105 rtc::CritScope lock(&critical_section_rtp_receiver_); |
112 return rtp_payload_registry_->DeRegisterReceivePayload(payload_type); | 106 return rtp_payload_registry_->DeRegisterReceivePayload(payload_type); |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 // implementations might have CSRC 0 as a valid value. | 450 // implementations might have CSRC 0 as a valid value. |
457 if (num_csrcs_diff > 0) { | 451 if (num_csrcs_diff > 0) { |
458 cb_rtp_feedback_->OnIncomingCSRCChanged(0, true); | 452 cb_rtp_feedback_->OnIncomingCSRCChanged(0, true); |
459 } else if (num_csrcs_diff < 0) { | 453 } else if (num_csrcs_diff < 0) { |
460 cb_rtp_feedback_->OnIncomingCSRCChanged(0, false); | 454 cb_rtp_feedback_->OnIncomingCSRCChanged(0, false); |
461 } | 455 } |
462 } | 456 } |
463 } | 457 } |
464 | 458 |
465 } // namespace webrtc | 459 } // namespace webrtc |
OLD | NEW |