| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 enable_rtx_ = enable; | 82 enable_rtx_ = enable; |
| 83 return true; | 83 return true; |
| 84 } else { | 84 } else { |
| 85 LOG(LS_WARNING) << "Cannot toggle rtx after initialization!"; | 85 LOG(LS_WARNING) << "Cannot toggle rtx after initialization!"; |
| 86 return false; | 86 return false; |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 void ChannelManager::GetSupportedAudioSendCodecs( | 90 void ChannelManager::GetSupportedAudioSendCodecs( |
| 91 std::vector<AudioCodec>* codecs) const { | 91 std::vector<AudioCodec>* codecs) const { |
| 92 if (!media_engine_) { |
| 93 LOG(LS_WARNING) << "Failed to get supported audio sending codecs because " |
| 94 "the media_engine_ is unset."; |
| 95 return; |
| 96 } |
| 92 *codecs = media_engine_->audio_send_codecs(); | 97 *codecs = media_engine_->audio_send_codecs(); |
| 93 } | 98 } |
| 94 | 99 |
| 95 void ChannelManager::GetSupportedAudioReceiveCodecs( | 100 void ChannelManager::GetSupportedAudioReceiveCodecs( |
| 96 std::vector<AudioCodec>* codecs) const { | 101 std::vector<AudioCodec>* codecs) const { |
| 102 if (!media_engine_) { |
| 103 LOG(LS_WARNING) << "Failed to get supported audio receiving codecs because " |
| 104 "the media_engine_ is unset."; |
| 105 return; |
| 106 } |
| 97 *codecs = media_engine_->audio_recv_codecs(); | 107 *codecs = media_engine_->audio_recv_codecs(); |
| 98 } | 108 } |
| 99 | 109 |
| 100 void ChannelManager::GetSupportedAudioRtpHeaderExtensions( | 110 void ChannelManager::GetSupportedAudioRtpHeaderExtensions( |
| 101 RtpHeaderExtensions* ext) const { | 111 RtpHeaderExtensions* ext) const { |
| 112 if (!media_engine_) { |
| 113 LOG(LS_WARNING) << "Failed to get audio RTP header extensions because the " |
| 114 "media_engine_ is unset."; |
| 115 return; |
| 116 } |
| 102 *ext = media_engine_->GetAudioCapabilities().header_extensions; | 117 *ext = media_engine_->GetAudioCapabilities().header_extensions; |
| 103 } | 118 } |
| 104 | 119 |
| 105 void ChannelManager::GetSupportedVideoCodecs( | 120 void ChannelManager::GetSupportedVideoCodecs( |
| 106 std::vector<VideoCodec>* codecs) const { | 121 std::vector<VideoCodec>* codecs) const { |
| 122 if (!media_engine_) { |
| 123 LOG(LS_WARNING) |
| 124 << "Failed to get video codecs because the media_engine_ is unset."; |
| 125 return; |
| 126 } |
| 107 codecs->clear(); | 127 codecs->clear(); |
| 108 | 128 |
| 109 std::vector<VideoCodec> video_codecs = media_engine_->video_codecs(); | 129 std::vector<VideoCodec> video_codecs = media_engine_->video_codecs(); |
| 110 for (const auto& video_codec : video_codecs) { | 130 for (const auto& video_codec : video_codecs) { |
| 111 if (!enable_rtx_ && | 131 if (!enable_rtx_ && |
| 112 _stricmp(kRtxCodecName, video_codec.name.c_str()) == 0) { | 132 _stricmp(kRtxCodecName, video_codec.name.c_str()) == 0) { |
| 113 continue; | 133 continue; |
| 114 } | 134 } |
| 115 codecs->push_back(video_codec); | 135 codecs->push_back(video_codec); |
| 116 } | 136 } |
| 117 } | 137 } |
| 118 | 138 |
| 119 void ChannelManager::GetSupportedVideoRtpHeaderExtensions( | 139 void ChannelManager::GetSupportedVideoRtpHeaderExtensions( |
| 120 RtpHeaderExtensions* ext) const { | 140 RtpHeaderExtensions* ext) const { |
| 141 if (!media_engine_) { |
| 142 LOG(LS_WARNING) << "Failed to get video RTP header extensions because the " |
| 143 "media_engine_ is unset."; |
| 144 return; |
| 145 } |
| 121 *ext = media_engine_->GetVideoCapabilities().header_extensions; | 146 *ext = media_engine_->GetVideoCapabilities().header_extensions; |
| 122 } | 147 } |
| 123 | 148 |
| 124 void ChannelManager::GetSupportedDataCodecs( | 149 void ChannelManager::GetSupportedDataCodecs( |
| 125 std::vector<DataCodec>* codecs) const { | 150 std::vector<DataCodec>* codecs) const { |
| 151 if (!data_media_engine_) { |
| 152 LOG(LS_WARNING) << "Failed to get supported data codecs because the " |
| 153 "data_media_engine_ is unset."; |
| 154 return; |
| 155 } |
| 126 *codecs = data_media_engine_->data_codecs(); | 156 *codecs = data_media_engine_->data_codecs(); |
| 127 } | 157 } |
| 128 | 158 |
| 129 bool ChannelManager::Init() { | 159 bool ChannelManager::Init() { |
| 130 RTC_DCHECK(!initialized_); | 160 RTC_DCHECK(!initialized_); |
| 131 if (initialized_) { | 161 if (initialized_) { |
| 132 return false; | 162 return false; |
| 133 } | 163 } |
| 134 RTC_DCHECK(network_thread_); | 164 RTC_DCHECK(network_thread_); |
| 135 RTC_DCHECK(worker_thread_); | 165 RTC_DCHECK(worker_thread_); |
| 136 if (!network_thread_->IsCurrent()) { | 166 if (!network_thread_->IsCurrent()) { |
| 137 // Do not allow invoking calls to other threads on the network thread. | 167 // Do not allow invoking calls to other threads on the network thread. |
| 138 network_thread_->Invoke<bool>( | 168 network_thread_->Invoke<bool>( |
| 139 RTC_FROM_HERE, | 169 RTC_FROM_HERE, |
| 140 rtc::Bind(&rtc::Thread::SetAllowBlockingCalls, network_thread_, false)); | 170 rtc::Bind(&rtc::Thread::SetAllowBlockingCalls, network_thread_, false)); |
| 141 } | 171 } |
| 142 | 172 |
| 143 initialized_ = worker_thread_->Invoke<bool>( | 173 initialized_ = worker_thread_->Invoke<bool>( |
| 144 RTC_FROM_HERE, Bind(&ChannelManager::InitMediaEngine_w, this)); | 174 RTC_FROM_HERE, Bind(&ChannelManager::InitMediaEngine_w, this)); |
| 145 RTC_DCHECK(initialized_); | 175 RTC_DCHECK(initialized_); |
| 146 return initialized_; | 176 return initialized_; |
| 147 } | 177 } |
| 148 | 178 |
| 149 bool ChannelManager::InitMediaEngine_w() { | 179 bool ChannelManager::InitMediaEngine_w() { |
| 150 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); | 180 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); |
| 151 return media_engine_->Init(); | 181 if (media_engine_) { |
| 182 return media_engine_->Init(); |
| 183 } |
| 184 return true; |
| 152 } | 185 } |
| 153 | 186 |
| 154 void ChannelManager::Terminate() { | 187 void ChannelManager::Terminate() { |
| 155 RTC_DCHECK(initialized_); | 188 RTC_DCHECK(initialized_); |
| 156 if (!initialized_) { | 189 if (!initialized_) { |
| 157 return; | 190 return; |
| 158 } | 191 } |
| 159 worker_thread_->Invoke<void>(RTC_FROM_HERE, | 192 worker_thread_->Invoke<void>(RTC_FROM_HERE, |
| 160 Bind(&ChannelManager::Terminate_w, this)); | 193 Bind(&ChannelManager::Terminate_w, this)); |
| 161 initialized_ = false; | 194 initialized_ = false; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 DtlsTransportInternal* rtcp_dtls_transport, | 249 DtlsTransportInternal* rtcp_dtls_transport, |
| 217 rtc::PacketTransportInternal* rtp_packet_transport, | 250 rtc::PacketTransportInternal* rtp_packet_transport, |
| 218 rtc::PacketTransportInternal* rtcp_packet_transport, | 251 rtc::PacketTransportInternal* rtcp_packet_transport, |
| 219 rtc::Thread* signaling_thread, | 252 rtc::Thread* signaling_thread, |
| 220 const std::string& content_name, | 253 const std::string& content_name, |
| 221 bool srtp_required, | 254 bool srtp_required, |
| 222 const AudioOptions& options) { | 255 const AudioOptions& options) { |
| 223 RTC_DCHECK(initialized_); | 256 RTC_DCHECK(initialized_); |
| 224 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); | 257 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); |
| 225 RTC_DCHECK(nullptr != call); | 258 RTC_DCHECK(nullptr != call); |
| 259 if (!media_engine_) { |
| 260 return nullptr; |
| 261 } |
| 226 | 262 |
| 227 VoiceMediaChannel* media_channel = media_engine_->CreateChannel( | 263 VoiceMediaChannel* media_channel = media_engine_->CreateChannel( |
| 228 call, media_config, options); | 264 call, media_config, options); |
| 229 if (!media_channel) | 265 if (!media_channel) |
| 230 return nullptr; | 266 return nullptr; |
| 231 | 267 |
| 232 VoiceChannel* voice_channel = | 268 VoiceChannel* voice_channel = |
| 233 new VoiceChannel(worker_thread_, network_thread_, signaling_thread, | 269 new VoiceChannel(worker_thread_, network_thread_, signaling_thread, |
| 234 media_engine_.get(), media_channel, content_name, | 270 media_engine_.get(), media_channel, content_name, |
| 235 rtcp_packet_transport == nullptr, srtp_required); | 271 rtcp_packet_transport == nullptr, srtp_required); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 media_engine_.get(), file, max_size_bytes)); | 462 media_engine_.get(), file, max_size_bytes)); |
| 427 } | 463 } |
| 428 | 464 |
| 429 void ChannelManager::StopAecDump() { | 465 void ChannelManager::StopAecDump() { |
| 430 worker_thread_->Invoke<void>( | 466 worker_thread_->Invoke<void>( |
| 431 RTC_FROM_HERE, | 467 RTC_FROM_HERE, |
| 432 Bind(&MediaEngineInterface::StopAecDump, media_engine_.get())); | 468 Bind(&MediaEngineInterface::StopAecDump, media_engine_.get())); |
| 433 } | 469 } |
| 434 | 470 |
| 435 } // namespace cricket | 471 } // namespace cricket |
| OLD | NEW |