| 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 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 DCHECK(channel_map_.empty()); | 186 DCHECK(channel_map_.empty()); |
| 187 DCHECK(!remb_->InUse()); | 187 DCHECK(!remb_->InUse()); |
| 188 DCHECK(vie_encoder_map_.empty()); | 188 DCHECK(vie_encoder_map_.empty()); |
| 189 DCHECK(send_encoders_.empty()); | 189 DCHECK(send_encoders_.empty()); |
| 190 } | 190 } |
| 191 | 191 |
| 192 bool ChannelGroup::CreateSendChannel(int channel_id, | 192 bool ChannelGroup::CreateSendChannel(int channel_id, |
| 193 int engine_id, | 193 int engine_id, |
| 194 Transport* transport, | 194 Transport* transport, |
| 195 int number_of_cores, | 195 int number_of_cores, |
| 196 size_t max_rtp_streams, | 196 const std::vector<uint32_t>& ssrcs, |
| 197 bool disable_default_encoder) { | 197 bool disable_default_encoder) { |
| 198 DCHECK_GT(max_rtp_streams, 0u); | 198 // TODO(pbos): Remove checks for empty ssrcs and add this check when there's |
| 199 // no base channel. |
| 200 // DCHECK(!ssrcs.empty()); |
| 199 rtc::scoped_ptr<ViEEncoder> vie_encoder( | 201 rtc::scoped_ptr<ViEEncoder> vie_encoder( |
| 200 new ViEEncoder(channel_id, number_of_cores, *config_.get(), | 202 new ViEEncoder(channel_id, number_of_cores, *config_.get(), |
| 201 *process_thread_, pacer_.get(), bitrate_allocator_.get(), | 203 *process_thread_, pacer_.get(), bitrate_allocator_.get(), |
| 202 bitrate_controller_.get(), false)); | 204 bitrate_controller_.get(), false)); |
| 203 if (!vie_encoder->Init()) { | 205 if (!vie_encoder->Init()) { |
| 204 return false; | 206 return false; |
| 205 } | 207 } |
| 206 ViEEncoder* encoder = vie_encoder.get(); | 208 ViEEncoder* encoder = vie_encoder.get(); |
| 207 if (!CreateChannel(channel_id, engine_id, transport, number_of_cores, | 209 if (!CreateChannel(channel_id, engine_id, transport, number_of_cores, |
| 208 vie_encoder.release(), max_rtp_streams, true, | 210 vie_encoder.release(), ssrcs.empty() ? 1 : ssrcs.size(), |
| 209 disable_default_encoder)) { | 211 true, disable_default_encoder)) { |
| 210 return false; | 212 return false; |
| 211 } | 213 } |
| 212 ViEChannel* channel = channel_map_[channel_id]; | 214 ViEChannel* channel = channel_map_[channel_id]; |
| 213 // Connect the encoder with the send packet router, to enable sending. | 215 // Connect the encoder with the send packet router, to enable sending. |
| 214 encoder->StartThreadsAndSetSharedMembers(channel->send_payload_router(), | 216 encoder->StartThreadsAndSetSharedMembers(channel->send_payload_router(), |
| 215 channel->vcm_protection_callback()); | 217 channel->vcm_protection_callback()); |
| 216 | 218 |
| 217 // Register the ViEEncoder to get key frame requests for this channel. | 219 if (!ssrcs.empty()) { |
| 218 unsigned int ssrc = 0; | 220 encoder_state_feedback_->AddEncoder(ssrcs, encoder); |
| 219 int stream_idx = 0; | 221 std::vector<uint32_t> first_ssrc(1, ssrcs[0]); |
| 220 channel->GetLocalSSRC(stream_idx, &ssrc); | 222 encoder->SetSsrcs(first_ssrc); |
| 221 encoder_state_feedback_->AddEncoder(ssrc, encoder); | 223 } |
| 222 std::vector<uint32_t> ssrcs; | |
| 223 ssrcs.push_back(ssrc); | |
| 224 encoder->SetSsrcs(ssrcs); | |
| 225 return true; | 224 return true; |
| 226 } | 225 } |
| 227 | 226 |
| 228 bool ChannelGroup::CreateReceiveChannel(int channel_id, | 227 bool ChannelGroup::CreateReceiveChannel(int channel_id, |
| 229 int engine_id, | 228 int engine_id, |
| 230 int base_channel_id, | 229 int base_channel_id, |
| 231 Transport* transport, | 230 Transport* transport, |
| 232 int number_of_cores, | 231 int number_of_cores, |
| 233 bool disable_default_encoder) { | 232 bool disable_default_encoder) { |
| 234 ViEEncoder* encoder = GetEncoder(base_channel_id); | 233 ViEEncoder* encoder = GetEncoder(base_channel_id); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 CriticalSectionScoped lock(encoder_map_cs_.get()); | 480 CriticalSectionScoped lock(encoder_map_cs_.get()); |
| 482 for (const auto& encoder : send_encoders_) | 481 for (const auto& encoder : send_encoders_) |
| 483 pad_up_to_bitrate_bps += encoder.second->GetPaddingNeededBps(); | 482 pad_up_to_bitrate_bps += encoder.second->GetPaddingNeededBps(); |
| 484 } | 483 } |
| 485 pacer_->UpdateBitrate( | 484 pacer_->UpdateBitrate( |
| 486 target_bitrate_bps / 1000, | 485 target_bitrate_bps / 1000, |
| 487 PacedSender::kDefaultPaceMultiplier * target_bitrate_bps / 1000, | 486 PacedSender::kDefaultPaceMultiplier * target_bitrate_bps / 1000, |
| 488 pad_up_to_bitrate_bps / 1000); | 487 pad_up_to_bitrate_bps / 1000); |
| 489 } | 488 } |
| 490 } // namespace webrtc | 489 } // namespace webrtc |
| OLD | NEW |