2013-07-10 00:45:36 +00:00
|
|
|
/*
|
2016-02-12 00:05:01 -08:00
|
|
|
* Copyright 2004 The WebRTC project authors. All Rights Reserved.
|
2013-07-10 00:45:36 +00:00
|
|
|
*
|
2016-02-12 00:05:01 -08:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2013-07-10 00:45:36 +00:00
|
|
|
*/
|
|
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "pc/channel_manager.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2017-10-30 09:57:42 -07:00
|
|
|
#include <utility>
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2019-01-28 17:25:26 -08:00
|
|
|
#include "absl/algorithm/container.h"
|
Use absl::make_unique and absl::WrapUnique directly
Instead of going through our wrappers in ptr_util.h.
This CL was generated by the following script:
git grep -l ptr_util | xargs perl -pi -e 's,#include "rtc_base/ptr_util.h",#include "absl/memory/memory.h",'
git grep -l MakeUnique | xargs perl -pi -e 's,\b(rtc::)?MakeUnique\b,absl::make_unique,g'
git grep -l WrapUnique | xargs perl -pi -e 's,\b(rtc::)?WrapUnique\b,absl::WrapUnique,g'
git checkout -- rtc_base/ptr_util{.h,_unittest.cc}
git cl format
Followed by manually adding dependencies on
//third_party/abseil-cpp/absl/memory until `gn check` stopped
complaining.
Bug: webrtc:9473
Change-Id: I89ccd363f070479b8c431eb2c3d404a46eaacc1c
Reviewed-on: https://webrtc-review.googlesource.com/86600
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23850}
2018-07-05 11:40:33 +02:00
|
|
|
#include "absl/memory/memory.h"
|
2018-10-19 15:29:54 +02:00
|
|
|
#include "absl/strings/match.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "media/base/media_constants.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/checks.h"
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "rtc_base/location.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/logging.h"
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "rtc_base/thread_checker.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/trace_event.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
namespace cricket {
|
|
|
|
|
|
2017-11-06 15:40:09 -08:00
|
|
|
ChannelManager::ChannelManager(
|
|
|
|
|
std::unique_ptr<MediaEngineInterface> media_engine,
|
|
|
|
|
std::unique_ptr<DataEngineInterface> data_engine,
|
|
|
|
|
rtc::Thread* worker_thread,
|
|
|
|
|
rtc::Thread* network_thread)
|
|
|
|
|
: media_engine_(std::move(media_engine)),
|
|
|
|
|
data_engine_(std::move(data_engine)),
|
|
|
|
|
main_thread_(rtc::Thread::Current()),
|
|
|
|
|
worker_thread_(worker_thread),
|
|
|
|
|
network_thread_(network_thread) {
|
|
|
|
|
RTC_DCHECK(data_engine_);
|
|
|
|
|
RTC_DCHECK(worker_thread_);
|
|
|
|
|
RTC_DCHECK(network_thread_);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ChannelManager::~ChannelManager() {
|
2013-08-05 20:36:57 +00:00
|
|
|
if (initialized_) {
|
2013-07-10 00:45:36 +00:00
|
|
|
Terminate();
|
2013-08-05 20:36:57 +00:00
|
|
|
}
|
2016-03-07 17:34:13 -08:00
|
|
|
// The media engine needs to be deleted on the worker thread for thread safe
|
|
|
|
|
// destruction,
|
2017-11-06 15:40:09 -08:00
|
|
|
worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] { media_engine_.reset(); });
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ChannelManager::SetVideoRtxEnabled(bool enable) {
|
|
|
|
|
// To be safe, this call is only allowed before initialization. Apps like
|
|
|
|
|
// Flute only have a singleton ChannelManager and we don't want this flag to
|
|
|
|
|
// be toggled between calls or when there's concurrent calls. We expect apps
|
|
|
|
|
// to enable this at startup and retain that setting for the lifetime of the
|
|
|
|
|
// app.
|
|
|
|
|
if (!initialized_) {
|
|
|
|
|
enable_rtx_ = enable;
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
2017-11-09 11:09:25 +01:00
|
|
|
RTC_LOG(LS_WARNING) << "Cannot toggle rtx after initialization!";
|
2013-07-10 00:45:36 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-14 07:12:39 -07:00
|
|
|
void ChannelManager::GetSupportedAudioSendCodecs(
|
2013-07-10 00:45:36 +00:00
|
|
|
std::vector<AudioCodec>* codecs) const {
|
2017-06-15 12:52:32 -07:00
|
|
|
if (!media_engine_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-11-16 11:29:55 +01:00
|
|
|
*codecs = media_engine_->voice().send_codecs();
|
2016-06-14 07:12:39 -07:00
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-06-14 07:12:39 -07:00
|
|
|
void ChannelManager::GetSupportedAudioReceiveCodecs(
|
|
|
|
|
std::vector<AudioCodec>* codecs) const {
|
2017-06-15 12:52:32 -07:00
|
|
|
if (!media_engine_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-11-16 11:29:55 +01:00
|
|
|
*codecs = media_engine_->voice().recv_codecs();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-29 22:17:00 +02:00
|
|
|
void ChannelManager::GetSupportedVideoSendCodecs(
|
2016-11-10 03:36:53 -08:00
|
|
|
std::vector<VideoCodec>* codecs) const {
|
2017-06-15 12:52:32 -07:00
|
|
|
if (!media_engine_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-11-10 03:36:53 -08:00
|
|
|
codecs->clear();
|
|
|
|
|
|
2020-03-29 22:17:00 +02:00
|
|
|
std::vector<VideoCodec> video_codecs = media_engine_->video().send_codecs();
|
|
|
|
|
for (const auto& video_codec : video_codecs) {
|
|
|
|
|
if (!enable_rtx_ &&
|
|
|
|
|
absl::EqualsIgnoreCase(kRtxCodecName, video_codec.name)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
codecs->push_back(video_codec);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ChannelManager::GetSupportedVideoReceiveCodecs(
|
|
|
|
|
std::vector<VideoCodec>* codecs) const {
|
|
|
|
|
if (!media_engine_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
codecs->clear();
|
|
|
|
|
|
|
|
|
|
std::vector<VideoCodec> video_codecs = media_engine_->video().recv_codecs();
|
2016-11-28 06:02:22 -08:00
|
|
|
for (const auto& video_codec : video_codecs) {
|
|
|
|
|
if (!enable_rtx_ &&
|
2018-10-19 15:29:54 +02:00
|
|
|
absl::EqualsIgnoreCase(kRtxCodecName, video_codec.name)) {
|
2016-11-10 03:36:53 -08:00
|
|
|
continue;
|
|
|
|
|
}
|
2016-11-28 06:02:22 -08:00
|
|
|
codecs->push_back(video_codec);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ChannelManager::GetSupportedDataCodecs(
|
|
|
|
|
std::vector<DataCodec>* codecs) const {
|
2017-11-06 15:40:09 -08:00
|
|
|
*codecs = data_engine_->data_codecs();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ChannelManager::Init() {
|
2017-01-12 05:15:36 -08:00
|
|
|
RTC_DCHECK(!initialized_);
|
2013-07-10 00:45:36 +00:00
|
|
|
if (initialized_) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2016-05-11 19:55:27 +02:00
|
|
|
RTC_DCHECK(network_thread_);
|
|
|
|
|
RTC_DCHECK(worker_thread_);
|
|
|
|
|
if (!network_thread_->IsCurrent()) {
|
|
|
|
|
// Do not allow invoking calls to other threads on the network thread.
|
2017-11-06 15:40:09 -08:00
|
|
|
network_thread_->Invoke<void>(
|
2019-02-21 13:38:30 +01:00
|
|
|
RTC_FROM_HERE, [&] { network_thread_->DisallowBlockingCalls(); });
|
2015-02-11 08:38:35 +00:00
|
|
|
}
|
2014-09-29 22:45:55 +00:00
|
|
|
|
2017-06-15 12:52:32 -07:00
|
|
|
if (media_engine_) {
|
2017-11-06 15:40:09 -08:00
|
|
|
initialized_ = worker_thread_->Invoke<bool>(
|
|
|
|
|
RTC_FROM_HERE, [&] { return media_engine_->Init(); });
|
|
|
|
|
RTC_DCHECK(initialized_);
|
|
|
|
|
} else {
|
|
|
|
|
initialized_ = true;
|
2017-06-15 12:52:32 -07:00
|
|
|
}
|
2017-11-06 15:40:09 -08:00
|
|
|
return initialized_;
|
2015-02-11 08:38:35 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-16 13:40:51 +01:00
|
|
|
RtpHeaderExtensions ChannelManager::GetDefaultEnabledAudioRtpHeaderExtensions()
|
|
|
|
|
const {
|
|
|
|
|
if (!media_engine_)
|
|
|
|
|
return {};
|
|
|
|
|
return GetDefaultEnabledRtpHeaderExtensions(media_engine_->voice());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<webrtc::RtpHeaderExtensionCapability>
|
|
|
|
|
ChannelManager::GetSupportedAudioRtpHeaderExtensions() const {
|
|
|
|
|
if (!media_engine_)
|
|
|
|
|
return {};
|
|
|
|
|
return media_engine_->voice().GetRtpHeaderExtensions();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RtpHeaderExtensions ChannelManager::GetDefaultEnabledVideoRtpHeaderExtensions()
|
|
|
|
|
const {
|
|
|
|
|
if (!media_engine_)
|
|
|
|
|
return {};
|
|
|
|
|
return GetDefaultEnabledRtpHeaderExtensions(media_engine_->video());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<webrtc::RtpHeaderExtensionCapability>
|
|
|
|
|
ChannelManager::GetSupportedVideoRtpHeaderExtensions() const {
|
|
|
|
|
if (!media_engine_)
|
|
|
|
|
return {};
|
|
|
|
|
return media_engine_->video().GetRtpHeaderExtensions();
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
void ChannelManager::Terminate() {
|
2017-01-12 05:15:36 -08:00
|
|
|
RTC_DCHECK(initialized_);
|
2013-07-10 00:45:36 +00:00
|
|
|
if (!initialized_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2017-11-06 15:40:09 -08:00
|
|
|
// Need to destroy the channels on the worker thread.
|
|
|
|
|
worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] {
|
|
|
|
|
video_channels_.clear();
|
|
|
|
|
voice_channels_.clear();
|
|
|
|
|
data_channels_.clear();
|
|
|
|
|
});
|
2013-07-10 00:45:36 +00:00
|
|
|
initialized_ = false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-04 13:38:48 -08:00
|
|
|
VoiceChannel* ChannelManager::CreateVoiceChannel(
|
|
|
|
|
webrtc::Call* call,
|
|
|
|
|
const cricket::MediaConfig& media_config,
|
|
|
|
|
webrtc::RtpTransportInternal* rtp_transport,
|
|
|
|
|
rtc::Thread* signaling_thread,
|
|
|
|
|
const std::string& content_name,
|
|
|
|
|
bool srtp_required,
|
2018-10-11 15:33:17 -07:00
|
|
|
const webrtc::CryptoOptions& crypto_options,
|
2019-01-25 17:13:56 -08:00
|
|
|
rtc::UniqueRandomIdGenerator* ssrc_generator,
|
2017-12-04 13:38:48 -08:00
|
|
|
const AudioOptions& options) {
|
|
|
|
|
if (!worker_thread_->IsCurrent()) {
|
|
|
|
|
return worker_thread_->Invoke<VoiceChannel*>(RTC_FROM_HERE, [&] {
|
2019-05-21 11:12:57 -07:00
|
|
|
return CreateVoiceChannel(call, media_config, rtp_transport,
|
2020-06-16 16:39:13 +02:00
|
|
|
signaling_thread, content_name, srtp_required,
|
|
|
|
|
crypto_options, ssrc_generator, options);
|
2017-12-04 13:38:48 -08:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RTC_DCHECK_RUN_ON(worker_thread_);
|
|
|
|
|
RTC_DCHECK(initialized_);
|
|
|
|
|
RTC_DCHECK(call);
|
|
|
|
|
if (!media_engine_) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-16 11:29:55 +01:00
|
|
|
VoiceMediaChannel* media_channel = media_engine_->voice().CreateMediaChannel(
|
|
|
|
|
call, media_config, options, crypto_options);
|
2017-12-04 13:38:48 -08:00
|
|
|
if (!media_channel) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-17 17:06:18 +02:00
|
|
|
auto voice_channel = std::make_unique<VoiceChannel>(
|
2019-01-25 17:13:56 -08:00
|
|
|
worker_thread_, network_thread_, signaling_thread,
|
Use absl::make_unique and absl::WrapUnique directly
Instead of going through our wrappers in ptr_util.h.
This CL was generated by the following script:
git grep -l ptr_util | xargs perl -pi -e 's,#include "rtc_base/ptr_util.h",#include "absl/memory/memory.h",'
git grep -l MakeUnique | xargs perl -pi -e 's,\b(rtc::)?MakeUnique\b,absl::make_unique,g'
git grep -l WrapUnique | xargs perl -pi -e 's,\b(rtc::)?WrapUnique\b,absl::WrapUnique,g'
git checkout -- rtc_base/ptr_util{.h,_unittest.cc}
git cl format
Followed by manually adding dependencies on
//third_party/abseil-cpp/absl/memory until `gn check` stopped
complaining.
Bug: webrtc:9473
Change-Id: I89ccd363f070479b8c431eb2c3d404a46eaacc1c
Reviewed-on: https://webrtc-review.googlesource.com/86600
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23850}
2018-07-05 11:40:33 +02:00
|
|
|
absl::WrapUnique(media_channel), content_name, srtp_required,
|
2019-01-25 17:13:56 -08:00
|
|
|
crypto_options, ssrc_generator);
|
2017-12-04 13:38:48 -08:00
|
|
|
|
2020-06-16 16:39:13 +02:00
|
|
|
voice_channel->Init_w(rtp_transport);
|
2017-12-04 13:38:48 -08:00
|
|
|
|
|
|
|
|
VoiceChannel* voice_channel_ptr = voice_channel.get();
|
|
|
|
|
voice_channels_.push_back(std::move(voice_channel));
|
|
|
|
|
return voice_channel_ptr;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-15 12:26:33 +02:00
|
|
|
void ChannelManager::DestroyVoiceChannel(VoiceChannel* voice_channel) {
|
2015-12-08 22:15:17 +01:00
|
|
|
TRACE_EVENT0("webrtc", "ChannelManager::DestroyVoiceChannel");
|
2017-11-06 15:40:09 -08:00
|
|
|
if (!voice_channel) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!worker_thread_->IsCurrent()) {
|
|
|
|
|
worker_thread_->Invoke<void>(RTC_FROM_HERE,
|
|
|
|
|
[&] { DestroyVoiceChannel(voice_channel); });
|
|
|
|
|
return;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2017-01-12 05:15:36 -08:00
|
|
|
RTC_DCHECK(initialized_);
|
2017-08-30 10:48:46 -07:00
|
|
|
|
2019-01-28 17:25:26 -08:00
|
|
|
auto it = absl::c_find_if(voice_channels_,
|
|
|
|
|
[&](const std::unique_ptr<VoiceChannel>& p) {
|
|
|
|
|
return p.get() == voice_channel;
|
|
|
|
|
});
|
2017-01-12 05:15:36 -08:00
|
|
|
RTC_DCHECK(it != voice_channels_.end());
|
2017-11-06 15:40:09 -08:00
|
|
|
if (it == voice_channels_.end()) {
|
2013-07-10 00:45:36 +00:00
|
|
|
return;
|
2017-11-06 15:40:09 -08:00
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
voice_channels_.erase(it);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-04 13:38:48 -08:00
|
|
|
VideoChannel* ChannelManager::CreateVideoChannel(
|
|
|
|
|
webrtc::Call* call,
|
|
|
|
|
const cricket::MediaConfig& media_config,
|
|
|
|
|
webrtc::RtpTransportInternal* rtp_transport,
|
|
|
|
|
rtc::Thread* signaling_thread,
|
|
|
|
|
const std::string& content_name,
|
|
|
|
|
bool srtp_required,
|
2018-10-11 15:33:17 -07:00
|
|
|
const webrtc::CryptoOptions& crypto_options,
|
2019-01-25 17:13:56 -08:00
|
|
|
rtc::UniqueRandomIdGenerator* ssrc_generator,
|
2019-04-17 07:38:40 +02:00
|
|
|
const VideoOptions& options,
|
|
|
|
|
webrtc::VideoBitrateAllocatorFactory* video_bitrate_allocator_factory) {
|
2017-12-04 13:38:48 -08:00
|
|
|
if (!worker_thread_->IsCurrent()) {
|
|
|
|
|
return worker_thread_->Invoke<VideoChannel*>(RTC_FROM_HERE, [&] {
|
2020-06-16 16:39:13 +02:00
|
|
|
return CreateVideoChannel(call, media_config, rtp_transport,
|
|
|
|
|
signaling_thread, content_name, srtp_required,
|
|
|
|
|
crypto_options, ssrc_generator, options,
|
|
|
|
|
video_bitrate_allocator_factory);
|
2017-12-04 13:38:48 -08:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RTC_DCHECK_RUN_ON(worker_thread_);
|
|
|
|
|
RTC_DCHECK(initialized_);
|
|
|
|
|
RTC_DCHECK(call);
|
|
|
|
|
if (!media_engine_) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-16 11:29:55 +01:00
|
|
|
VideoMediaChannel* media_channel = media_engine_->video().CreateMediaChannel(
|
2019-04-17 07:38:40 +02:00
|
|
|
call, media_config, options, crypto_options,
|
|
|
|
|
video_bitrate_allocator_factory);
|
2017-12-04 13:38:48 -08:00
|
|
|
if (!media_channel) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-17 17:06:18 +02:00
|
|
|
auto video_channel = std::make_unique<VideoChannel>(
|
2017-12-04 13:38:48 -08:00
|
|
|
worker_thread_, network_thread_, signaling_thread,
|
Use absl::make_unique and absl::WrapUnique directly
Instead of going through our wrappers in ptr_util.h.
This CL was generated by the following script:
git grep -l ptr_util | xargs perl -pi -e 's,#include "rtc_base/ptr_util.h",#include "absl/memory/memory.h",'
git grep -l MakeUnique | xargs perl -pi -e 's,\b(rtc::)?MakeUnique\b,absl::make_unique,g'
git grep -l WrapUnique | xargs perl -pi -e 's,\b(rtc::)?WrapUnique\b,absl::WrapUnique,g'
git checkout -- rtc_base/ptr_util{.h,_unittest.cc}
git cl format
Followed by manually adding dependencies on
//third_party/abseil-cpp/absl/memory until `gn check` stopped
complaining.
Bug: webrtc:9473
Change-Id: I89ccd363f070479b8c431eb2c3d404a46eaacc1c
Reviewed-on: https://webrtc-review.googlesource.com/86600
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23850}
2018-07-05 11:40:33 +02:00
|
|
|
absl::WrapUnique(media_channel), content_name, srtp_required,
|
2019-01-25 17:13:56 -08:00
|
|
|
crypto_options, ssrc_generator);
|
2018-10-17 13:15:42 -07:00
|
|
|
|
2020-06-16 16:39:13 +02:00
|
|
|
video_channel->Init_w(rtp_transport);
|
2017-12-04 13:38:48 -08:00
|
|
|
|
|
|
|
|
VideoChannel* video_channel_ptr = video_channel.get();
|
|
|
|
|
video_channels_.push_back(std::move(video_channel));
|
|
|
|
|
return video_channel_ptr;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
void ChannelManager::DestroyVideoChannel(VideoChannel* video_channel) {
|
2015-12-08 22:15:17 +01:00
|
|
|
TRACE_EVENT0("webrtc", "ChannelManager::DestroyVideoChannel");
|
2017-11-06 15:40:09 -08:00
|
|
|
if (!video_channel) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!worker_thread_->IsCurrent()) {
|
|
|
|
|
worker_thread_->Invoke<void>(RTC_FROM_HERE,
|
|
|
|
|
[&] { DestroyVideoChannel(video_channel); });
|
|
|
|
|
return;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2017-01-12 05:15:36 -08:00
|
|
|
RTC_DCHECK(initialized_);
|
2017-08-30 10:48:46 -07:00
|
|
|
|
2019-01-28 17:25:26 -08:00
|
|
|
auto it = absl::c_find_if(video_channels_,
|
|
|
|
|
[&](const std::unique_ptr<VideoChannel>& p) {
|
|
|
|
|
return p.get() == video_channel;
|
|
|
|
|
});
|
2017-01-12 05:15:36 -08:00
|
|
|
RTC_DCHECK(it != video_channels_.end());
|
2017-11-06 15:40:09 -08:00
|
|
|
if (it == video_channels_.end()) {
|
2013-07-10 00:45:36 +00:00
|
|
|
return;
|
2017-11-06 15:40:09 -08:00
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
video_channels_.erase(it);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-04 13:38:48 -08:00
|
|
|
RtpDataChannel* ChannelManager::CreateRtpDataChannel(
|
|
|
|
|
const cricket::MediaConfig& media_config,
|
|
|
|
|
webrtc::RtpTransportInternal* rtp_transport,
|
|
|
|
|
rtc::Thread* signaling_thread,
|
|
|
|
|
const std::string& content_name,
|
2018-03-30 10:48:35 -07:00
|
|
|
bool srtp_required,
|
2019-01-25 17:13:56 -08:00
|
|
|
const webrtc::CryptoOptions& crypto_options,
|
|
|
|
|
rtc::UniqueRandomIdGenerator* ssrc_generator) {
|
2017-12-04 13:38:48 -08:00
|
|
|
if (!worker_thread_->IsCurrent()) {
|
|
|
|
|
return worker_thread_->Invoke<RtpDataChannel*>(RTC_FROM_HERE, [&] {
|
|
|
|
|
return CreateRtpDataChannel(media_config, rtp_transport, signaling_thread,
|
2019-01-25 17:13:56 -08:00
|
|
|
content_name, srtp_required, crypto_options,
|
|
|
|
|
ssrc_generator);
|
2017-12-04 13:38:48 -08:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This is ok to alloc from a thread other than the worker thread.
|
|
|
|
|
RTC_DCHECK(initialized_);
|
|
|
|
|
DataMediaChannel* media_channel = data_engine_->CreateChannel(media_config);
|
|
|
|
|
if (!media_channel) {
|
|
|
|
|
RTC_LOG(LS_WARNING) << "Failed to create RTP data channel.";
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-17 17:06:18 +02:00
|
|
|
auto data_channel = std::make_unique<RtpDataChannel>(
|
2017-12-04 13:38:48 -08:00
|
|
|
worker_thread_, network_thread_, signaling_thread,
|
Use absl::make_unique and absl::WrapUnique directly
Instead of going through our wrappers in ptr_util.h.
This CL was generated by the following script:
git grep -l ptr_util | xargs perl -pi -e 's,#include "rtc_base/ptr_util.h",#include "absl/memory/memory.h",'
git grep -l MakeUnique | xargs perl -pi -e 's,\b(rtc::)?MakeUnique\b,absl::make_unique,g'
git grep -l WrapUnique | xargs perl -pi -e 's,\b(rtc::)?WrapUnique\b,absl::WrapUnique,g'
git checkout -- rtc_base/ptr_util{.h,_unittest.cc}
git cl format
Followed by manually adding dependencies on
//third_party/abseil-cpp/absl/memory until `gn check` stopped
complaining.
Bug: webrtc:9473
Change-Id: I89ccd363f070479b8c431eb2c3d404a46eaacc1c
Reviewed-on: https://webrtc-review.googlesource.com/86600
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23850}
2018-07-05 11:40:33 +02:00
|
|
|
absl::WrapUnique(media_channel), content_name, srtp_required,
|
2019-01-25 17:13:56 -08:00
|
|
|
crypto_options, ssrc_generator);
|
2019-05-21 11:12:57 -07:00
|
|
|
|
|
|
|
|
// Media Transports are not supported with Rtp Data Channel.
|
2020-06-16 16:39:13 +02:00
|
|
|
data_channel->Init_w(rtp_transport);
|
2017-12-04 13:38:48 -08:00
|
|
|
|
|
|
|
|
RtpDataChannel* data_channel_ptr = data_channel.get();
|
|
|
|
|
data_channels_.push_back(std::move(data_channel));
|
|
|
|
|
return data_channel_ptr;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-09 14:53:41 -08:00
|
|
|
void ChannelManager::DestroyRtpDataChannel(RtpDataChannel* data_channel) {
|
|
|
|
|
TRACE_EVENT0("webrtc", "ChannelManager::DestroyRtpDataChannel");
|
2017-11-06 15:40:09 -08:00
|
|
|
if (!data_channel) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!worker_thread_->IsCurrent()) {
|
2013-07-10 00:45:36 +00:00
|
|
|
worker_thread_->Invoke<void>(
|
2017-11-06 15:40:09 -08:00
|
|
|
RTC_FROM_HERE, [&] { return DestroyRtpDataChannel(data_channel); });
|
|
|
|
|
return;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2017-01-12 05:15:36 -08:00
|
|
|
RTC_DCHECK(initialized_);
|
2017-08-30 10:48:46 -07:00
|
|
|
|
2019-01-28 17:25:26 -08:00
|
|
|
auto it = absl::c_find_if(data_channels_,
|
|
|
|
|
[&](const std::unique_ptr<RtpDataChannel>& p) {
|
|
|
|
|
return p.get() == data_channel;
|
|
|
|
|
});
|
2017-01-12 05:15:36 -08:00
|
|
|
RTC_DCHECK(it != data_channels_.end());
|
2017-11-06 15:40:09 -08:00
|
|
|
if (it == data_channels_.end()) {
|
2013-07-10 00:45:36 +00:00
|
|
|
return;
|
2017-11-06 15:40:09 -08:00
|
|
|
}
|
2018-03-29 00:08:03 +00:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
data_channels_.erase(it);
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-11 14:04:16 +02:00
|
|
|
bool ChannelManager::StartAecDump(webrtc::FileWrapper file,
|
2016-01-15 03:06:36 -08:00
|
|
|
int64_t max_size_bytes) {
|
2017-11-06 15:40:09 -08:00
|
|
|
return worker_thread_->Invoke<bool>(RTC_FROM_HERE, [&] {
|
2019-06-11 14:04:16 +02:00
|
|
|
return media_engine_->voice().StartAecDump(std::move(file), max_size_bytes);
|
2017-11-06 15:40:09 -08:00
|
|
|
});
|
2013-12-13 00:21:03 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-22 03:25:41 -07:00
|
|
|
void ChannelManager::StopAecDump() {
|
2017-11-06 15:40:09 -08:00
|
|
|
worker_thread_->Invoke<void>(RTC_FROM_HERE,
|
2018-11-16 11:29:55 +01:00
|
|
|
[&] { media_engine_->voice().StopAecDump(); });
|
2015-10-22 03:25:41 -07:00
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
} // namespace cricket
|