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
|
|
|
*/
|
|
|
|
|
|
2015-12-17 03:04:15 -08:00
|
|
|
#include <utility>
|
|
|
|
|
|
2016-02-12 06:47:59 +01:00
|
|
|
#include "webrtc/pc/channel.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-08-31 07:33:05 -07:00
|
|
|
#include "webrtc/api/call/audio_sink.h"
|
2014-08-07 22:09:08 +00:00
|
|
|
#include "webrtc/base/bind.h"
|
|
|
|
|
#include "webrtc/base/byteorder.h"
|
2016-08-25 13:31:14 -07:00
|
|
|
#include "webrtc/base/checks.h"
|
2014-08-07 22:09:08 +00:00
|
|
|
#include "webrtc/base/common.h"
|
2016-03-20 06:15:43 -07:00
|
|
|
#include "webrtc/base/copyonwritebuffer.h"
|
2014-08-07 22:09:08 +00:00
|
|
|
#include "webrtc/base/dscp.h"
|
|
|
|
|
#include "webrtc/base/logging.h"
|
2016-03-29 17:27:21 -07:00
|
|
|
#include "webrtc/base/networkroute.h"
|
2015-12-07 23:17:15 +01:00
|
|
|
#include "webrtc/base/trace_event.h"
|
2016-03-02 05:42:30 -08:00
|
|
|
#include "webrtc/media/base/mediaconstants.h"
|
Move talk/media to webrtc/media
I removed the 'libjingle' target in talk/libjingle.gyp and replaced
all users of it with base/base.gyp:rtc_base. It seems the jsoncpp
and expat dependencies were not used by it's previous references.
The files in talk/media/testdata were uploaded to Google Storage and
added .sha1 files in resources/media instead of simply moving them.
The previously disabled warnings that were inherited from
talk/build/common.gypi are now replaced by target-specific disabling
of only the failing warnings. Additional disabling was needed since the stricter
compilation warnings that applies to code in webrtc/.
License headers will be updated in a follow-up CL in order to not
break Git history.
Other modifications:
* Updated the header guards.
* Sorted the includes using chromium/src/tools/sort-headers.py
except for these files:
talk/app/webrtc/peerconnectionendtoend_unittest.cc
talk/app/webrtc/java/jni/androidmediadecoder_jni.cc
talk/app/webrtc/java/jni/androidmediaencoder_jni.cc
webrtc/media/devices/win32devicemanager.cc.
* Unused GYP reference to libjingle_tests_additional_deps was removed.
* Removed duplicated GYP entries of
webrtc/base/testutils.cc
webrtc/base/testutils.h
The HAVE_WEBRTC_VIDEO and HAVE_WEBRTC_VOICE defines were used by only talk/media,
so they were moved to the media.gyp.
I also checked that none of
EXPAT_RELATIVE_PATH,
FEATURE_ENABLE_VOICEMAIL,
GTEST_RELATIVE_PATH,
JSONCPP_RELATIVE_PATH,
LOGGING=1,
SRTP_RELATIVE_PATH,
FEATURE_ENABLE_SSL,
FEATURE_ENABLE_VOICEMAIL,
FEATURE_ENABLE_PSTN,
HAVE_SCTP,
HAVE_SRTP,
are used by the talk/media code.
For Chromium, the following changes will need to be applied to the roll CL that updates the
DEPS for WebRTC and libjingle: https://codereview.chromium.org/1604303002/
BUG=webrtc:5420
NOPRESUBMIT=True
TBR=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/1587193006
Cr-Commit-Position: refs/heads/master@{#11495}
2016-02-04 23:52:28 -08:00
|
|
|
#include "webrtc/media/base/rtputils.h"
|
2016-10-25 10:50:32 -07:00
|
|
|
#include "webrtc/p2p/base/packettransportinterface.h"
|
2015-12-07 23:17:15 +01:00
|
|
|
#include "webrtc/p2p/base/transportchannel.h"
|
2016-02-12 06:47:59 +01:00
|
|
|
#include "webrtc/pc/channelmanager.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
namespace cricket {
|
2014-07-29 17:36:52 +00:00
|
|
|
using rtc::Bind;
|
2014-02-07 19:03:26 +00:00
|
|
|
|
2016-01-13 12:00:26 -08:00
|
|
|
namespace {
|
2016-03-11 14:18:21 -08:00
|
|
|
// See comment below for why we need to use a pointer to a unique_ptr.
|
2016-01-13 12:00:26 -08:00
|
|
|
bool SetRawAudioSink_w(VoiceMediaChannel* channel,
|
|
|
|
|
uint32_t ssrc,
|
2016-03-11 14:18:21 -08:00
|
|
|
std::unique_ptr<webrtc::AudioSinkInterface>* sink) {
|
|
|
|
|
channel->SetRawAudioSink(ssrc, std::move(*sink));
|
2016-01-13 12:00:26 -08:00
|
|
|
return true;
|
|
|
|
|
}
|
2016-05-11 19:55:27 +02:00
|
|
|
|
|
|
|
|
struct SendPacketMessageData : public rtc::MessageData {
|
|
|
|
|
rtc::CopyOnWriteBuffer packet;
|
|
|
|
|
rtc::PacketOptions options;
|
|
|
|
|
};
|
|
|
|
|
|
2016-05-26 11:24:55 -07:00
|
|
|
#if defined(ENABLE_EXTERNAL_AUTH)
|
|
|
|
|
// Returns the named header extension if found among all extensions,
|
|
|
|
|
// nullptr otherwise.
|
|
|
|
|
const webrtc::RtpExtension* FindHeaderExtension(
|
|
|
|
|
const std::vector<webrtc::RtpExtension>& extensions,
|
|
|
|
|
const std::string& uri) {
|
|
|
|
|
for (const auto& extension : extensions) {
|
|
|
|
|
if (extension.uri == uri)
|
|
|
|
|
return &extension;
|
|
|
|
|
}
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-01-13 12:00:26 -08:00
|
|
|
} // namespace
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
enum {
|
2014-02-07 19:03:26 +00:00
|
|
|
MSG_EARLYMEDIATIMEOUT = 1,
|
2016-05-11 19:55:27 +02:00
|
|
|
MSG_SEND_RTP_PACKET,
|
|
|
|
|
MSG_SEND_RTCP_PACKET,
|
2013-07-10 00:45:36 +00:00
|
|
|
MSG_CHANNEL_ERROR,
|
|
|
|
|
MSG_READYTOSENDDATA,
|
|
|
|
|
MSG_DATARECEIVED,
|
|
|
|
|
MSG_FIRSTPACKETRECEIVED,
|
2014-05-29 22:54:24 +00:00
|
|
|
MSG_STREAMCLOSEDREMOTELY,
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Value specified in RFC 5764.
|
|
|
|
|
static const char kDtlsSrtpExporterLabel[] = "EXTRACTOR-dtls_srtp";
|
|
|
|
|
|
|
|
|
|
static const int kAgcMinus10db = -10;
|
|
|
|
|
|
2014-01-15 23:15:54 +00:00
|
|
|
static void SafeSetError(const std::string& message, std::string* error_desc) {
|
|
|
|
|
if (error_desc) {
|
|
|
|
|
*error_desc = message;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
struct VoiceChannelErrorMessageData : public rtc::MessageData {
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
VoiceChannelErrorMessageData(uint32_t in_ssrc,
|
2013-07-10 00:45:36 +00:00
|
|
|
VoiceMediaChannel::Error in_error)
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
: ssrc(in_ssrc), error(in_error) {}
|
|
|
|
|
uint32_t ssrc;
|
2013-07-10 00:45:36 +00:00
|
|
|
VoiceMediaChannel::Error error;
|
|
|
|
|
};
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
struct VideoChannelErrorMessageData : public rtc::MessageData {
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
VideoChannelErrorMessageData(uint32_t in_ssrc,
|
2013-07-10 00:45:36 +00:00
|
|
|
VideoMediaChannel::Error in_error)
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
: ssrc(in_ssrc), error(in_error) {}
|
|
|
|
|
uint32_t ssrc;
|
2013-07-10 00:45:36 +00:00
|
|
|
VideoMediaChannel::Error error;
|
|
|
|
|
};
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
struct DataChannelErrorMessageData : public rtc::MessageData {
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
DataChannelErrorMessageData(uint32_t in_ssrc,
|
2013-07-10 00:45:36 +00:00
|
|
|
DataMediaChannel::Error in_error)
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
: ssrc(in_ssrc), error(in_error) {}
|
|
|
|
|
uint32_t ssrc;
|
2013-07-10 00:45:36 +00:00
|
|
|
DataMediaChannel::Error error;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const char* PacketType(bool rtcp) {
|
|
|
|
|
return (!rtcp) ? "RTP" : "RTCP";
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-20 06:15:43 -07:00
|
|
|
static bool ValidPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet) {
|
2013-07-10 00:45:36 +00:00
|
|
|
// Check the packet size. We could check the header too if needed.
|
|
|
|
|
return (packet &&
|
2015-03-24 09:19:06 +00:00
|
|
|
packet->size() >= (!rtcp ? kMinRtpPacketLen : kMinRtcpPacketLen) &&
|
|
|
|
|
packet->size() <= kMaxRtpPacketLen);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool IsReceiveContentDirection(MediaContentDirection direction) {
|
|
|
|
|
return direction == MD_SENDRECV || direction == MD_RECVONLY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool IsSendContentDirection(MediaContentDirection direction) {
|
|
|
|
|
return direction == MD_SENDRECV || direction == MD_SENDONLY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const MediaContentDescription* GetContentDescription(
|
|
|
|
|
const ContentInfo* cinfo) {
|
|
|
|
|
if (cinfo == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
return static_cast<const MediaContentDescription*>(cinfo->description);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
template <class Codec>
|
|
|
|
|
void RtpParametersFromMediaDescription(
|
|
|
|
|
const MediaContentDescriptionImpl<Codec>* desc,
|
|
|
|
|
RtpParameters<Codec>* params) {
|
|
|
|
|
// TODO(pthatcher): Remove this once we're sure no one will give us
|
|
|
|
|
// a description without codecs (currently a CA_UPDATE with just
|
|
|
|
|
// streams can).
|
|
|
|
|
if (desc->has_codecs()) {
|
|
|
|
|
params->codecs = desc->codecs();
|
|
|
|
|
}
|
|
|
|
|
// TODO(pthatcher): See if we really need
|
|
|
|
|
// rtp_header_extensions_set() and remove it if we don't.
|
|
|
|
|
if (desc->rtp_header_extensions_set()) {
|
|
|
|
|
params->extensions = desc->rtp_header_extensions();
|
|
|
|
|
}
|
2015-12-09 12:37:51 -08:00
|
|
|
params->rtcp.reduced_size = desc->rtcp_reduced_size();
|
2015-08-07 16:05:34 -07:00
|
|
|
}
|
|
|
|
|
|
2016-03-16 02:22:50 -07:00
|
|
|
template <class Codec>
|
2015-08-07 16:05:34 -07:00
|
|
|
void RtpSendParametersFromMediaDescription(
|
|
|
|
|
const MediaContentDescriptionImpl<Codec>* desc,
|
2016-03-16 02:22:50 -07:00
|
|
|
RtpSendParameters<Codec>* send_params) {
|
2015-08-07 16:05:34 -07:00
|
|
|
RtpParametersFromMediaDescription(desc, send_params);
|
|
|
|
|
send_params->max_bandwidth_bps = desc->bandwidth();
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
BaseChannel::BaseChannel(rtc::Thread* worker_thread,
|
|
|
|
|
rtc::Thread* network_thread,
|
2015-09-23 11:50:27 -07:00
|
|
|
MediaChannel* media_channel,
|
|
|
|
|
TransportController* transport_controller,
|
|
|
|
|
const std::string& content_name,
|
|
|
|
|
bool rtcp)
|
2016-05-11 19:55:27 +02:00
|
|
|
: worker_thread_(worker_thread),
|
|
|
|
|
network_thread_(network_thread),
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
content_name_(content_name),
|
2016-05-11 19:55:27 +02:00
|
|
|
|
|
|
|
|
transport_controller_(transport_controller),
|
2016-08-22 16:00:30 -07:00
|
|
|
rtcp_enabled_(rtcp),
|
2016-11-08 02:50:09 -08:00
|
|
|
media_channel_(media_channel),
|
|
|
|
|
selected_candidate_pair_(nullptr) {
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
|
2016-05-11 19:55:27 +02:00
|
|
|
if (transport_controller) {
|
2016-05-12 09:20:31 +02:00
|
|
|
RTC_DCHECK_EQ(network_thread, transport_controller->network_thread());
|
2016-05-11 19:55:27 +02:00
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
LOG(LS_INFO) << "Created channel for " << content_name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BaseChannel::~BaseChannel() {
|
2016-03-08 14:24:13 -08:00
|
|
|
TRACE_EVENT0("webrtc", "BaseChannel::~BaseChannel");
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
|
2013-10-07 23:32:02 +00:00
|
|
|
Deinit();
|
2013-07-10 00:45:36 +00:00
|
|
|
StopConnectionMonitor();
|
2016-05-11 19:55:27 +02:00
|
|
|
// Eats any outstanding messages or packets.
|
|
|
|
|
worker_thread_->Clear(&invoker_);
|
|
|
|
|
worker_thread_->Clear(this);
|
2013-07-10 00:45:36 +00:00
|
|
|
// We must destroy the media channel before the transport channel, otherwise
|
|
|
|
|
// the media channel may try to send on the dead transport channel. NULLing
|
|
|
|
|
// is not an effective strategy since the sends will come on another thread.
|
|
|
|
|
delete media_channel_;
|
2016-05-11 19:55:27 +02:00
|
|
|
// Note that we don't just call SetTransportChannel_n(nullptr) because that
|
2015-09-23 11:50:27 -07:00
|
|
|
// would call a pure virtual method which we can't do from a destructor.
|
2016-05-14 01:43:50 +02:00
|
|
|
network_thread_->Invoke<void>(
|
2016-06-10 14:17:27 -07:00
|
|
|
RTC_FROM_HERE, Bind(&BaseChannel::DestroyTransportChannels_n, this));
|
2016-05-11 19:55:27 +02:00
|
|
|
LOG(LS_INFO) << "Destroyed channel";
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-14 01:43:50 +02:00
|
|
|
void BaseChannel::DisconnectTransportChannels_n() {
|
|
|
|
|
// Send any outstanding RTCP packets.
|
|
|
|
|
FlushRtcpMessages_n();
|
|
|
|
|
|
|
|
|
|
// Stop signals from transport channels, but keep them alive because
|
|
|
|
|
// media_channel may use them from a different thread.
|
2015-09-23 11:50:27 -07:00
|
|
|
if (transport_channel_) {
|
|
|
|
|
DisconnectFromTransportChannel(transport_channel_);
|
2016-05-14 01:43:50 +02:00
|
|
|
}
|
|
|
|
|
if (rtcp_transport_channel_) {
|
|
|
|
|
DisconnectFromTransportChannel(rtcp_transport_channel_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Clear pending read packets/messages.
|
|
|
|
|
network_thread_->Clear(&invoker_);
|
|
|
|
|
network_thread_->Clear(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::DestroyTransportChannels_n() {
|
|
|
|
|
if (transport_channel_) {
|
2016-05-12 09:20:31 +02:00
|
|
|
transport_controller_->DestroyTransportChannel_n(
|
2015-09-23 11:50:27 -07:00
|
|
|
transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTP);
|
|
|
|
|
}
|
|
|
|
|
if (rtcp_transport_channel_) {
|
2016-05-12 09:20:31 +02:00
|
|
|
transport_controller_->DestroyTransportChannel_n(
|
2015-09-23 11:50:27 -07:00
|
|
|
transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
|
|
|
|
|
}
|
2016-05-14 01:43:50 +02:00
|
|
|
// Clear pending send packets/messages.
|
|
|
|
|
network_thread_->Clear(&invoker_);
|
2016-05-11 19:55:27 +02:00
|
|
|
network_thread_->Clear(this);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-17 17:49:52 -07:00
|
|
|
bool BaseChannel::Init_w(const std::string* bundle_transport_name) {
|
|
|
|
|
if (!network_thread_->Invoke<bool>(
|
2016-06-10 14:17:27 -07:00
|
|
|
RTC_FROM_HERE,
|
2016-05-17 17:49:52 -07:00
|
|
|
Bind(&BaseChannel::InitNetwork_n, this, bundle_transport_name))) {
|
2016-05-11 19:55:27 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Both RTP and RTCP channels are set, we can call SetInterface on
|
|
|
|
|
// media channel and it can set network options.
|
|
|
|
|
RTC_DCHECK(worker_thread_->IsCurrent());
|
|
|
|
|
media_channel_->SetInterface(this);
|
|
|
|
|
return true;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-05-17 17:49:52 -07:00
|
|
|
bool BaseChannel::InitNetwork_n(const std::string* bundle_transport_name) {
|
2016-05-11 19:55:27 +02:00
|
|
|
RTC_DCHECK(network_thread_->IsCurrent());
|
2016-05-17 17:49:52 -07:00
|
|
|
const std::string& transport_name =
|
|
|
|
|
(bundle_transport_name ? *bundle_transport_name : content_name());
|
|
|
|
|
if (!SetTransport_n(transport_name)) {
|
2013-07-10 00:45:36 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2015-03-16 20:19:12 +00:00
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
if (!SetDtlsSrtpCryptoSuites_n(transport_channel_, false)) {
|
2013-07-10 00:45:36 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2016-08-22 16:00:30 -07:00
|
|
|
if (rtcp_transport_channel_ &&
|
2016-05-11 19:55:27 +02:00
|
|
|
!SetDtlsSrtpCryptoSuites_n(rtcp_transport_channel_, true)) {
|
2013-07-10 00:45:36 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-07 23:32:02 +00:00
|
|
|
void BaseChannel::Deinit() {
|
2016-05-11 19:55:27 +02:00
|
|
|
RTC_DCHECK(worker_thread_->IsCurrent());
|
2013-10-07 23:32:02 +00:00
|
|
|
media_channel_->SetInterface(NULL);
|
2016-05-14 01:43:50 +02:00
|
|
|
// Packets arrive on the network thread, processing packets calls virtual
|
|
|
|
|
// functions, so need to stop this process in Deinit that is called in
|
|
|
|
|
// derived classes destructor.
|
|
|
|
|
network_thread_->Invoke<void>(
|
2016-06-10 14:17:27 -07:00
|
|
|
RTC_FROM_HERE, Bind(&BaseChannel::DisconnectTransportChannels_n, this));
|
2013-10-07 23:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
2015-09-23 11:50:27 -07:00
|
|
|
bool BaseChannel::SetTransport(const std::string& transport_name) {
|
2016-05-11 19:55:27 +02:00
|
|
|
return network_thread_->Invoke<bool>(
|
2016-06-10 14:17:27 -07:00
|
|
|
RTC_FROM_HERE, Bind(&BaseChannel::SetTransport_n, this, transport_name));
|
2015-03-16 20:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
bool BaseChannel::SetTransport_n(const std::string& transport_name) {
|
|
|
|
|
RTC_DCHECK(network_thread_->IsCurrent());
|
2015-03-16 20:19:12 +00:00
|
|
|
|
2015-09-23 11:50:27 -07:00
|
|
|
if (transport_name == transport_name_) {
|
2016-08-25 13:31:14 -07:00
|
|
|
// Nothing to do if transport name isn't changing.
|
2015-09-23 11:50:27 -07:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-05 09:59:56 -08:00
|
|
|
// When using DTLS-SRTP, we must reset the SrtpFilter every time the transport
|
|
|
|
|
// changes and wait until the DTLS handshake is complete to set the newly
|
|
|
|
|
// negotiated parameters.
|
2016-05-11 19:55:27 +02:00
|
|
|
if (ShouldSetupDtlsSrtp_n()) {
|
2015-12-17 16:45:59 -08:00
|
|
|
// Set |writable_| to false such that UpdateWritableState_w can set up
|
2016-08-25 13:31:14 -07:00
|
|
|
// DTLS-SRTP when |writable_| becomes true again.
|
2015-12-17 16:45:59 -08:00
|
|
|
writable_ = false;
|
2015-12-05 09:59:56 -08:00
|
|
|
srtp_filter_.ResetParams();
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-22 16:00:30 -07:00
|
|
|
// If this BaseChannel uses RTCP and we haven't fully negotiated RTCP mux,
|
|
|
|
|
// we need an RTCP channel.
|
|
|
|
|
if (rtcp_enabled_ && !rtcp_mux_filter_.IsFullyActive()) {
|
2015-09-23 11:50:27 -07:00
|
|
|
LOG(LS_INFO) << "Create RTCP TransportChannel for " << content_name()
|
|
|
|
|
<< " on " << transport_name << " transport ";
|
2016-08-26 21:42:15 -07:00
|
|
|
SetTransportChannel_n(
|
|
|
|
|
true, transport_controller_->CreateTransportChannel_n(
|
|
|
|
|
transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP));
|
2016-05-11 19:55:27 +02:00
|
|
|
if (!rtcp_transport_channel_) {
|
2015-03-16 20:19:12 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-26 21:42:15 -07:00
|
|
|
LOG(LS_INFO) << "Create non-RTCP TransportChannel for " << content_name()
|
|
|
|
|
<< " on " << transport_name << " transport ";
|
|
|
|
|
SetTransportChannel_n(
|
|
|
|
|
false, transport_controller_->CreateTransportChannel_n(
|
|
|
|
|
transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP));
|
2016-05-11 19:55:27 +02:00
|
|
|
if (!transport_channel_) {
|
2015-12-17 16:45:59 -08:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-23 11:50:27 -07:00
|
|
|
transport_name_ = transport_name;
|
|
|
|
|
|
|
|
|
|
// Update aggregate writable/ready-to-send state between RTP and RTCP upon
|
2016-08-25 13:31:14 -07:00
|
|
|
// setting new transport channels.
|
2016-05-11 19:55:27 +02:00
|
|
|
UpdateWritableState_n();
|
2016-08-26 21:42:15 -07:00
|
|
|
// We can only update ready-to-send after updating writability.
|
|
|
|
|
//
|
2016-08-25 13:31:14 -07:00
|
|
|
// On setting a new channel, assume it's ready to send if it's writable,
|
|
|
|
|
// because we have no way of knowing otherwise (the channel doesn't give us
|
|
|
|
|
// "was last send successful?").
|
|
|
|
|
//
|
|
|
|
|
// This won't always be accurate (the last SendPacket call from another
|
|
|
|
|
// BaseChannel could have resulted in an error), but even so, we'll just
|
|
|
|
|
// encounter the error again and update "ready to send" accordingly.
|
2016-08-26 21:42:15 -07:00
|
|
|
SetTransportChannelReadyToSend(
|
|
|
|
|
false, transport_channel_ && transport_channel_->writable());
|
|
|
|
|
SetTransportChannelReadyToSend(
|
|
|
|
|
true, rtcp_transport_channel_ && rtcp_transport_channel_->writable());
|
|
|
|
|
return true;
|
2015-03-16 20:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
2016-08-26 21:42:15 -07:00
|
|
|
void BaseChannel::SetTransportChannel_n(bool rtcp,
|
|
|
|
|
TransportChannel* new_channel) {
|
2016-05-11 19:55:27 +02:00
|
|
|
RTC_DCHECK(network_thread_->IsCurrent());
|
2016-08-26 21:42:15 -07:00
|
|
|
TransportChannel*& old_channel =
|
|
|
|
|
rtcp ? rtcp_transport_channel_ : transport_channel_;
|
2015-03-16 20:19:12 +00:00
|
|
|
|
2016-08-26 21:42:15 -07:00
|
|
|
if (!old_channel && !new_channel) {
|
2016-08-25 13:31:14 -07:00
|
|
|
// Nothing to do.
|
2015-03-16 20:19:12 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2016-08-26 21:42:15 -07:00
|
|
|
RTC_DCHECK(old_channel != new_channel);
|
2015-09-23 11:50:27 -07:00
|
|
|
|
2016-08-26 21:42:15 -07:00
|
|
|
if (old_channel) {
|
|
|
|
|
DisconnectFromTransportChannel(old_channel);
|
2016-05-12 09:20:31 +02:00
|
|
|
transport_controller_->DestroyTransportChannel_n(
|
2016-08-26 21:42:15 -07:00
|
|
|
transport_name_, rtcp ? cricket::ICE_CANDIDATE_COMPONENT_RTCP
|
|
|
|
|
: cricket::ICE_CANDIDATE_COMPONENT_RTP);
|
2015-03-16 20:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
2016-08-26 21:42:15 -07:00
|
|
|
old_channel = new_channel;
|
2015-03-16 20:19:12 +00:00
|
|
|
|
2016-08-26 21:42:15 -07:00
|
|
|
if (new_channel) {
|
|
|
|
|
if (rtcp) {
|
|
|
|
|
RTC_CHECK(!(ShouldSetupDtlsSrtp_n() && srtp_filter_.IsActive()))
|
|
|
|
|
<< "Setting RTCP for DTLS/SRTP after SrtpFilter is active "
|
|
|
|
|
<< "should never happen.";
|
|
|
|
|
}
|
|
|
|
|
ConnectToTransportChannel(new_channel);
|
|
|
|
|
auto& socket_options = rtcp ? rtcp_socket_options_ : socket_options_;
|
|
|
|
|
for (const auto& pair : socket_options) {
|
|
|
|
|
new_channel->SetOption(pair.first, pair.second);
|
2015-09-23 11:50:27 -07:00
|
|
|
}
|
2015-12-17 16:45:59 -08:00
|
|
|
}
|
2015-03-16 20:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::ConnectToTransportChannel(TransportChannel* tc) {
|
2016-05-11 19:55:27 +02:00
|
|
|
RTC_DCHECK(network_thread_->IsCurrent());
|
2015-03-16 20:19:12 +00:00
|
|
|
|
|
|
|
|
tc->SignalWritableState.connect(this, &BaseChannel::OnWritableState);
|
2016-10-25 10:50:32 -07:00
|
|
|
tc->SignalReadPacket.connect(this, &BaseChannel::OnPacketRead);
|
2015-03-16 20:19:12 +00:00
|
|
|
tc->SignalReadyToSend.connect(this, &BaseChannel::OnReadyToSend);
|
2015-12-05 09:59:56 -08:00
|
|
|
tc->SignalDtlsState.connect(this, &BaseChannel::OnDtlsState);
|
2016-03-29 17:27:21 -07:00
|
|
|
tc->SignalSelectedCandidatePairChanged.connect(
|
|
|
|
|
this, &BaseChannel::OnSelectedCandidatePairChanged);
|
2016-05-11 19:55:27 +02:00
|
|
|
tc->SignalSentPacket.connect(this, &BaseChannel::SignalSentPacket_n);
|
2015-03-16 20:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::DisconnectFromTransportChannel(TransportChannel* tc) {
|
2016-05-11 19:55:27 +02:00
|
|
|
RTC_DCHECK(network_thread_->IsCurrent());
|
2016-11-08 02:50:09 -08:00
|
|
|
OnSelectedCandidatePairChanged(tc, nullptr, -1, false);
|
2015-03-16 20:19:12 +00:00
|
|
|
|
|
|
|
|
tc->SignalWritableState.disconnect(this);
|
|
|
|
|
tc->SignalReadPacket.disconnect(this);
|
|
|
|
|
tc->SignalReadyToSend.disconnect(this);
|
2015-12-05 09:59:56 -08:00
|
|
|
tc->SignalDtlsState.disconnect(this);
|
2016-05-11 19:55:27 +02:00
|
|
|
tc->SignalSelectedCandidatePairChanged.disconnect(this);
|
|
|
|
|
tc->SignalSentPacket.disconnect(this);
|
2015-03-16 20:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
bool BaseChannel::Enable(bool enable) {
|
2016-06-10 14:17:27 -07:00
|
|
|
worker_thread_->Invoke<void>(
|
|
|
|
|
RTC_FROM_HERE,
|
|
|
|
|
Bind(enable ? &BaseChannel::EnableMedia_w : &BaseChannel::DisableMedia_w,
|
|
|
|
|
this));
|
2013-07-10 00:45:36 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BaseChannel::AddRecvStream(const StreamParams& sp) {
|
2016-06-10 14:17:27 -07:00
|
|
|
return InvokeOnWorker(RTC_FROM_HERE,
|
|
|
|
|
Bind(&BaseChannel::AddRecvStream_w, this, sp));
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
bool BaseChannel::RemoveRecvStream(uint32_t ssrc) {
|
2016-06-10 14:17:27 -07:00
|
|
|
return InvokeOnWorker(RTC_FROM_HERE,
|
|
|
|
|
Bind(&BaseChannel::RemoveRecvStream_w, this, ssrc));
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2013-08-30 21:24:16 +00:00
|
|
|
bool BaseChannel::AddSendStream(const StreamParams& sp) {
|
2014-02-07 19:03:26 +00:00
|
|
|
return InvokeOnWorker(
|
2016-06-10 14:17:27 -07:00
|
|
|
RTC_FROM_HERE, Bind(&MediaChannel::AddSendStream, media_channel(), sp));
|
2013-08-30 21:24:16 +00:00
|
|
|
}
|
|
|
|
|
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
bool BaseChannel::RemoveSendStream(uint32_t ssrc) {
|
2016-06-10 14:17:27 -07:00
|
|
|
return InvokeOnWorker(RTC_FROM_HERE, Bind(&MediaChannel::RemoveSendStream,
|
|
|
|
|
media_channel(), ssrc));
|
2013-08-30 21:24:16 +00:00
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
bool BaseChannel::SetLocalContent(const MediaContentDescription* content,
|
2014-01-15 23:15:54 +00:00
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc) {
|
2015-12-08 13:25:57 +01:00
|
|
|
TRACE_EVENT0("webrtc", "BaseChannel::SetLocalContent");
|
2016-06-10 14:17:27 -07:00
|
|
|
return InvokeOnWorker(RTC_FROM_HERE, Bind(&BaseChannel::SetLocalContent_w,
|
|
|
|
|
this, content, action, error_desc));
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BaseChannel::SetRemoteContent(const MediaContentDescription* content,
|
2014-01-15 23:15:54 +00:00
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc) {
|
2015-12-08 13:25:57 +01:00
|
|
|
TRACE_EVENT0("webrtc", "BaseChannel::SetRemoteContent");
|
2016-06-10 14:17:27 -07:00
|
|
|
return InvokeOnWorker(RTC_FROM_HERE, Bind(&BaseChannel::SetRemoteContent_w,
|
|
|
|
|
this, content, action, error_desc));
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::StartConnectionMonitor(int cms) {
|
2015-03-13 18:25:21 +00:00
|
|
|
// We pass in the BaseChannel instead of the transport_channel_
|
|
|
|
|
// because if the transport_channel_ changes, the ConnectionMonitor
|
|
|
|
|
// would be pointing to the wrong TransportChannel.
|
2016-05-11 19:55:27 +02:00
|
|
|
// We pass in the network thread because on that thread connection monitor
|
|
|
|
|
// will call BaseChannel::GetConnectionStats which must be called on the
|
|
|
|
|
// network thread.
|
|
|
|
|
connection_monitor_.reset(
|
|
|
|
|
new ConnectionMonitor(this, network_thread(), rtc::Thread::Current()));
|
2015-03-13 18:25:21 +00:00
|
|
|
connection_monitor_->SignalUpdate.connect(
|
2013-07-10 00:45:36 +00:00
|
|
|
this, &BaseChannel::OnConnectionMonitorUpdate);
|
2015-03-13 18:25:21 +00:00
|
|
|
connection_monitor_->Start(cms);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::StopConnectionMonitor() {
|
2015-03-13 18:25:21 +00:00
|
|
|
if (connection_monitor_) {
|
|
|
|
|
connection_monitor_->Stop();
|
|
|
|
|
connection_monitor_.reset();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-13 18:25:21 +00:00
|
|
|
bool BaseChannel::GetConnectionStats(ConnectionInfos* infos) {
|
2016-05-11 19:55:27 +02:00
|
|
|
RTC_DCHECK(network_thread_->IsCurrent());
|
2015-03-13 18:25:21 +00:00
|
|
|
return transport_channel_->GetStats(infos);
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-25 13:31:14 -07:00
|
|
|
bool BaseChannel::IsReadyToReceiveMedia_w() const {
|
2013-07-10 00:45:36 +00:00
|
|
|
// Receive data if we are enabled and have local content,
|
|
|
|
|
return enabled() && IsReceiveContentDirection(local_content_direction_);
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-25 13:31:14 -07:00
|
|
|
bool BaseChannel::IsReadyToSendMedia_w() const {
|
|
|
|
|
// Need to access some state updated on the network thread.
|
|
|
|
|
return network_thread_->Invoke<bool>(
|
|
|
|
|
RTC_FROM_HERE, Bind(&BaseChannel::IsReadyToSendMedia_n, this));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BaseChannel::IsReadyToSendMedia_n() const {
|
2013-07-10 00:45:36 +00:00
|
|
|
// Send outgoing data if we are enabled, have local and remote content,
|
|
|
|
|
// and we have had some form of connectivity.
|
2015-12-05 09:59:56 -08:00
|
|
|
return enabled() && IsReceiveContentDirection(remote_content_direction_) &&
|
2013-07-10 00:45:36 +00:00
|
|
|
IsSendContentDirection(local_content_direction_) &&
|
2016-08-25 13:31:14 -07:00
|
|
|
was_ever_writable() &&
|
2016-05-11 19:55:27 +02:00
|
|
|
(srtp_filter_.IsActive() || !ShouldSetupDtlsSrtp_n());
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-20 06:15:43 -07:00
|
|
|
bool BaseChannel::SendPacket(rtc::CopyOnWriteBuffer* packet,
|
2015-10-15 07:26:07 -07:00
|
|
|
const rtc::PacketOptions& options) {
|
|
|
|
|
return SendPacket(false, packet, options);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-20 06:15:43 -07:00
|
|
|
bool BaseChannel::SendRtcp(rtc::CopyOnWriteBuffer* packet,
|
2015-10-15 07:26:07 -07:00
|
|
|
const rtc::PacketOptions& options) {
|
|
|
|
|
return SendPacket(true, packet, options);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
int BaseChannel::SetOption(SocketType type, rtc::Socket::Option opt,
|
2013-07-10 00:45:36 +00:00
|
|
|
int value) {
|
2016-05-11 19:55:27 +02:00
|
|
|
return network_thread_->Invoke<int>(
|
2016-06-10 14:17:27 -07:00
|
|
|
RTC_FROM_HERE, Bind(&BaseChannel::SetOption_n, this, type, opt, value));
|
2016-05-11 19:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int BaseChannel::SetOption_n(SocketType type,
|
|
|
|
|
rtc::Socket::Option opt,
|
|
|
|
|
int value) {
|
|
|
|
|
RTC_DCHECK(network_thread_->IsCurrent());
|
|
|
|
|
TransportChannel* channel = nullptr;
|
2013-07-10 00:45:36 +00:00
|
|
|
switch (type) {
|
2013-12-11 18:25:07 +00:00
|
|
|
case ST_RTP:
|
|
|
|
|
channel = transport_channel_;
|
2015-09-23 11:50:27 -07:00
|
|
|
socket_options_.push_back(
|
|
|
|
|
std::pair<rtc::Socket::Option, int>(opt, value));
|
2013-12-11 18:25:07 +00:00
|
|
|
break;
|
|
|
|
|
case ST_RTCP:
|
|
|
|
|
channel = rtcp_transport_channel_;
|
2015-09-23 11:50:27 -07:00
|
|
|
rtcp_socket_options_.push_back(
|
|
|
|
|
std::pair<rtc::Socket::Option, int>(opt, value));
|
2013-12-11 18:25:07 +00:00
|
|
|
break;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
2013-12-11 18:25:07 +00:00
|
|
|
return channel ? channel->SetOption(opt, value) : -1;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-08-04 05:20:32 -07:00
|
|
|
bool BaseChannel::SetCryptoOptions(const rtc::CryptoOptions& crypto_options) {
|
|
|
|
|
crypto_options_ = crypto_options;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-25 10:50:32 -07:00
|
|
|
void BaseChannel::OnWritableState(rtc::PacketTransportInterface* transport) {
|
|
|
|
|
RTC_DCHECK(transport == transport_channel_ ||
|
|
|
|
|
transport == rtcp_transport_channel_);
|
2016-05-11 19:55:27 +02:00
|
|
|
RTC_DCHECK(network_thread_->IsCurrent());
|
|
|
|
|
UpdateWritableState_n();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-10-25 10:50:32 -07:00
|
|
|
void BaseChannel::OnPacketRead(rtc::PacketTransportInterface* transport,
|
|
|
|
|
const char* data,
|
|
|
|
|
size_t len,
|
|
|
|
|
const rtc::PacketTime& packet_time,
|
|
|
|
|
int flags) {
|
|
|
|
|
TRACE_EVENT0("webrtc", "BaseChannel::OnPacketRead");
|
|
|
|
|
// OnPacketRead gets called from P2PSocket; now pass data to MediaEngine
|
2016-05-11 19:55:27 +02:00
|
|
|
RTC_DCHECK(network_thread_->IsCurrent());
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// When using RTCP multiplexing we might get RTCP packets on the RTP
|
|
|
|
|
// transport. We feed RTP traffic into the demuxer to determine if it is RTCP.
|
2016-10-25 10:50:32 -07:00
|
|
|
bool rtcp = PacketIsRtcp(transport, data, len);
|
2016-03-20 06:15:43 -07:00
|
|
|
rtc::CopyOnWriteBuffer packet(data, len);
|
2013-12-13 00:21:03 +00:00
|
|
|
HandlePacket(rtcp, &packet, packet_time);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-10-25 10:50:32 -07:00
|
|
|
void BaseChannel::OnReadyToSend(rtc::PacketTransportInterface* transport) {
|
|
|
|
|
RTC_DCHECK(transport == transport_channel_ ||
|
|
|
|
|
transport == rtcp_transport_channel_);
|
|
|
|
|
SetTransportChannelReadyToSend(transport == rtcp_transport_channel_, true);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-12-05 09:59:56 -08:00
|
|
|
void BaseChannel::OnDtlsState(TransportChannel* channel,
|
|
|
|
|
DtlsTransportState state) {
|
2016-05-11 19:55:27 +02:00
|
|
|
if (!ShouldSetupDtlsSrtp_n()) {
|
2015-12-05 09:59:56 -08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reset the srtp filter if it's not the CONNECTED state. For the CONNECTED
|
|
|
|
|
// state, setting up DTLS-SRTP context is deferred to ChannelWritable_w to
|
|
|
|
|
// cover other scenarios like the whole channel is writable (not just this
|
|
|
|
|
// TransportChannel) or when TransportChannel is attached after DTLS is
|
|
|
|
|
// negotiated.
|
|
|
|
|
if (state != DTLS_TRANSPORT_CONNECTED) {
|
|
|
|
|
srtp_filter_.ResetParams();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-29 17:27:21 -07:00
|
|
|
void BaseChannel::OnSelectedCandidatePairChanged(
|
|
|
|
|
TransportChannel* channel,
|
2016-03-31 12:37:31 -07:00
|
|
|
CandidatePairInterface* selected_candidate_pair,
|
2016-06-27 18:09:03 -07:00
|
|
|
int last_sent_packet_id,
|
|
|
|
|
bool ready_to_send) {
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(channel == transport_channel_ ||
|
|
|
|
|
channel == rtcp_transport_channel_);
|
2016-05-11 19:55:27 +02:00
|
|
|
RTC_DCHECK(network_thread_->IsCurrent());
|
2016-11-08 02:50:09 -08:00
|
|
|
selected_candidate_pair_ = selected_candidate_pair;
|
2016-05-11 19:55:27 +02:00
|
|
|
std::string transport_name = channel->transport_name();
|
2016-04-19 15:41:36 -07:00
|
|
|
rtc::NetworkRoute network_route;
|
2016-03-29 17:27:21 -07:00
|
|
|
if (selected_candidate_pair) {
|
2016-04-19 15:41:36 -07:00
|
|
|
network_route = rtc::NetworkRoute(
|
2016-06-27 18:09:03 -07:00
|
|
|
ready_to_send, selected_candidate_pair->local_candidate().network_id(),
|
2016-04-19 15:41:36 -07:00
|
|
|
selected_candidate_pair->remote_candidate().network_id(),
|
|
|
|
|
last_sent_packet_id);
|
2016-11-08 02:50:09 -08:00
|
|
|
|
|
|
|
|
UpdateTransportOverhead();
|
2016-03-29 17:27:21 -07:00
|
|
|
}
|
2016-05-11 19:55:27 +02:00
|
|
|
invoker_.AsyncInvoke<void>(
|
2016-06-10 14:17:27 -07:00
|
|
|
RTC_FROM_HERE, worker_thread_,
|
|
|
|
|
Bind(&MediaChannel::OnNetworkRouteChanged, media_channel_, transport_name,
|
|
|
|
|
network_route));
|
2016-03-29 17:27:21 -07:00
|
|
|
}
|
|
|
|
|
|
2016-08-25 13:31:14 -07:00
|
|
|
void BaseChannel::SetTransportChannelReadyToSend(bool rtcp, bool ready) {
|
2016-05-11 19:55:27 +02:00
|
|
|
RTC_DCHECK(network_thread_->IsCurrent());
|
2015-09-23 11:50:27 -07:00
|
|
|
if (rtcp) {
|
2015-09-23 02:16:58 -07:00
|
|
|
rtcp_ready_to_send_ = ready;
|
2015-09-23 11:50:27 -07:00
|
|
|
} else {
|
|
|
|
|
rtp_ready_to_send_ = ready;
|
2015-09-23 02:16:58 -07:00
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
bool ready_to_send =
|
|
|
|
|
(rtp_ready_to_send_ &&
|
|
|
|
|
// In the case of rtcp mux |rtcp_transport_channel_| will be null.
|
|
|
|
|
(rtcp_ready_to_send_ || !rtcp_transport_channel_));
|
|
|
|
|
|
|
|
|
|
invoker_.AsyncInvoke<void>(
|
2016-06-10 14:17:27 -07:00
|
|
|
RTC_FROM_HERE, worker_thread_,
|
2016-05-11 19:55:27 +02:00
|
|
|
Bind(&MediaChannel::OnReadyToSend, media_channel_, ready_to_send));
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-10-25 10:50:32 -07:00
|
|
|
bool BaseChannel::PacketIsRtcp(const rtc::PacketTransportInterface* transport,
|
|
|
|
|
const char* data,
|
|
|
|
|
size_t len) {
|
|
|
|
|
return (transport == rtcp_transport_channel_ ||
|
2013-07-22 21:07:49 +00:00
|
|
|
rtcp_mux_filter_.DemuxRtcp(data, static_cast<int>(len)));
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-15 07:26:07 -07:00
|
|
|
bool BaseChannel::SendPacket(bool rtcp,
|
2016-03-20 06:15:43 -07:00
|
|
|
rtc::CopyOnWriteBuffer* packet,
|
2015-10-15 07:26:07 -07:00
|
|
|
const rtc::PacketOptions& options) {
|
2016-05-11 19:55:27 +02:00
|
|
|
// SendPacket gets called from MediaEngine, on a pacer or an encoder thread.
|
|
|
|
|
// If the thread is not our network thread, we will post to our network
|
|
|
|
|
// so that the real work happens on our network. This avoids us having to
|
2013-07-10 00:45:36 +00:00
|
|
|
// synchronize access to all the pieces of the send path, including
|
|
|
|
|
// SRTP and the inner workings of the transport channels.
|
|
|
|
|
// The only downside is that we can't return a proper failure code if
|
|
|
|
|
// needed. Since UDP is unreliable anyway, this should be a non-issue.
|
2016-05-11 19:55:27 +02:00
|
|
|
if (!network_thread_->IsCurrent()) {
|
2013-07-10 00:45:36 +00:00
|
|
|
// Avoid a copy by transferring the ownership of the packet data.
|
2016-05-11 19:55:27 +02:00
|
|
|
int message_id = rtcp ? MSG_SEND_RTCP_PACKET : MSG_SEND_RTP_PACKET;
|
|
|
|
|
SendPacketMessageData* data = new SendPacketMessageData;
|
2015-12-17 03:04:15 -08:00
|
|
|
data->packet = std::move(*packet);
|
2015-10-15 07:26:07 -07:00
|
|
|
data->options = options;
|
2016-06-10 14:17:27 -07:00
|
|
|
network_thread_->Post(RTC_FROM_HERE, this, message_id, data);
|
2013-07-10 00:45:36 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
2016-05-11 19:55:27 +02:00
|
|
|
TRACE_EVENT0("webrtc", "BaseChannel::SendPacket");
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// Now that we are on the correct thread, ensure we have a place to send this
|
|
|
|
|
// packet before doing anything. (We might get RTCP packets that we don't
|
|
|
|
|
// intend to send.) If we've negotiated RTCP mux, send RTCP over the RTP
|
|
|
|
|
// transport.
|
|
|
|
|
TransportChannel* channel = (!rtcp || rtcp_mux_filter_.IsActive()) ?
|
|
|
|
|
transport_channel_ : rtcp_transport_channel_;
|
2013-10-25 21:18:33 +00:00
|
|
|
if (!channel || !channel->writable()) {
|
2013-07-10 00:45:36 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Protect ourselves against crazy data.
|
|
|
|
|
if (!ValidPacket(rtcp, packet)) {
|
|
|
|
|
LOG(LS_ERROR) << "Dropping outgoing " << content_name_ << " "
|
2015-03-24 09:19:06 +00:00
|
|
|
<< PacketType(rtcp)
|
|
|
|
|
<< " packet: wrong size=" << packet->size();
|
2013-07-10 00:45:36 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-15 07:26:07 -07:00
|
|
|
rtc::PacketOptions updated_options;
|
|
|
|
|
updated_options = options;
|
2013-07-10 00:45:36 +00:00
|
|
|
// Protect if needed.
|
|
|
|
|
if (srtp_filter_.IsActive()) {
|
2016-05-11 19:55:27 +02:00
|
|
|
TRACE_EVENT0("webrtc", "SRTP Encode");
|
2013-07-10 00:45:36 +00:00
|
|
|
bool res;
|
2015-05-04 14:54:55 +02:00
|
|
|
uint8_t* data = packet->data();
|
2015-03-24 09:19:06 +00:00
|
|
|
int len = static_cast<int>(packet->size());
|
2013-07-10 00:45:36 +00:00
|
|
|
if (!rtcp) {
|
2014-02-21 23:43:24 +00:00
|
|
|
// If ENABLE_EXTERNAL_AUTH flag is on then packet authentication is not done
|
|
|
|
|
// inside libsrtp for a RTP packet. A external HMAC module will be writing
|
|
|
|
|
// a fake HMAC value. This is ONLY done for a RTP packet.
|
|
|
|
|
// Socket layer will update rtp sendtime extension header if present in
|
|
|
|
|
// packet with current time before updating the HMAC.
|
|
|
|
|
#if !defined(ENABLE_EXTERNAL_AUTH)
|
|
|
|
|
res = srtp_filter_.ProtectRtp(
|
|
|
|
|
data, len, static_cast<int>(packet->capacity()), &len);
|
|
|
|
|
#else
|
2015-10-15 07:26:07 -07:00
|
|
|
updated_options.packet_time_params.rtp_sendtime_extension_id =
|
2014-03-10 15:53:12 +00:00
|
|
|
rtp_abs_sendtime_extn_id_;
|
2014-02-21 23:43:24 +00:00
|
|
|
res = srtp_filter_.ProtectRtp(
|
|
|
|
|
data, len, static_cast<int>(packet->capacity()), &len,
|
2015-10-15 07:26:07 -07:00
|
|
|
&updated_options.packet_time_params.srtp_packet_index);
|
2014-02-21 23:43:24 +00:00
|
|
|
// If protection succeeds, let's get auth params from srtp.
|
|
|
|
|
if (res) {
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
uint8_t* auth_key = NULL;
|
2014-02-21 23:43:24 +00:00
|
|
|
int key_len;
|
|
|
|
|
res = srtp_filter_.GetRtpAuthParams(
|
2015-10-15 07:26:07 -07:00
|
|
|
&auth_key, &key_len,
|
|
|
|
|
&updated_options.packet_time_params.srtp_auth_tag_len);
|
2014-02-21 23:43:24 +00:00
|
|
|
if (res) {
|
2015-10-15 07:26:07 -07:00
|
|
|
updated_options.packet_time_params.srtp_auth_key.resize(key_len);
|
|
|
|
|
updated_options.packet_time_params.srtp_auth_key.assign(
|
|
|
|
|
auth_key, auth_key + key_len);
|
2014-02-21 23:43:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2013-07-10 00:45:36 +00:00
|
|
|
if (!res) {
|
|
|
|
|
int seq_num = -1;
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
uint32_t ssrc = 0;
|
2013-07-10 00:45:36 +00:00
|
|
|
GetRtpSeqNum(data, len, &seq_num);
|
|
|
|
|
GetRtpSsrc(data, len, &ssrc);
|
|
|
|
|
LOG(LS_ERROR) << "Failed to protect " << content_name_
|
|
|
|
|
<< " RTP packet: size=" << len
|
|
|
|
|
<< ", seqnum=" << seq_num << ", SSRC=" << ssrc;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2013-07-22 21:07:49 +00:00
|
|
|
res = srtp_filter_.ProtectRtcp(data, len,
|
|
|
|
|
static_cast<int>(packet->capacity()),
|
|
|
|
|
&len);
|
2013-07-10 00:45:36 +00:00
|
|
|
if (!res) {
|
|
|
|
|
int type = -1;
|
|
|
|
|
GetRtcpType(data, len, &type);
|
|
|
|
|
LOG(LS_ERROR) << "Failed to protect " << content_name_
|
|
|
|
|
<< " RTCP packet: size=" << len << ", type=" << type;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update the length of the packet now that we've added the auth tag.
|
2015-03-24 09:19:06 +00:00
|
|
|
packet->SetSize(len);
|
2013-07-10 00:45:36 +00:00
|
|
|
} else if (secure_required_) {
|
|
|
|
|
// This is a double check for something that supposedly can't happen.
|
|
|
|
|
LOG(LS_ERROR) << "Can't send outgoing " << PacketType(rtcp)
|
|
|
|
|
<< " packet when SRTP is inactive and crypto is required";
|
|
|
|
|
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(false);
|
2013-07-10 00:45:36 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Bon voyage.
|
2016-05-11 19:55:27 +02:00
|
|
|
int flags = (secure() && secure_dtls()) ? PF_SRTP_BYPASS : PF_NORMAL;
|
|
|
|
|
int ret = channel->SendPacket(packet->data<char>(), packet->size(),
|
|
|
|
|
updated_options, flags);
|
2015-03-24 09:19:06 +00:00
|
|
|
if (ret != static_cast<int>(packet->size())) {
|
2016-07-28 17:15:20 -07:00
|
|
|
if (channel->GetError() == ENOTCONN) {
|
|
|
|
|
LOG(LS_WARNING) << "Got ENOTCONN from transport.";
|
2016-08-25 13:31:14 -07:00
|
|
|
SetTransportChannelReadyToSend(rtcp, false);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-20 06:15:43 -07:00
|
|
|
bool BaseChannel::WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet) {
|
2013-07-10 00:45:36 +00:00
|
|
|
// Protect ourselves against crazy data.
|
|
|
|
|
if (!ValidPacket(rtcp, packet)) {
|
|
|
|
|
LOG(LS_ERROR) << "Dropping incoming " << content_name_ << " "
|
2015-03-24 09:19:06 +00:00
|
|
|
<< PacketType(rtcp)
|
|
|
|
|
<< " packet: wrong size=" << packet->size();
|
2013-07-10 00:45:36 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2015-11-16 10:19:58 -08:00
|
|
|
if (rtcp) {
|
|
|
|
|
// Permit all (seemingly valid) RTCP packets.
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
// Check whether we handle this payload.
|
2016-03-20 06:15:43 -07:00
|
|
|
return bundle_filter_.DemuxPacket(packet->data(), packet->size());
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-20 06:15:43 -07:00
|
|
|
void BaseChannel::HandlePacket(bool rtcp, rtc::CopyOnWriteBuffer* packet,
|
2014-07-29 17:36:52 +00:00
|
|
|
const rtc::PacketTime& packet_time) {
|
2016-05-11 19:55:27 +02:00
|
|
|
RTC_DCHECK(network_thread_->IsCurrent());
|
2013-07-10 00:45:36 +00:00
|
|
|
if (!WantsPacket(rtcp, packet)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-28 19:48:33 +00:00
|
|
|
// We are only interested in the first rtp packet because that
|
|
|
|
|
// indicates the media has started flowing.
|
|
|
|
|
if (!has_received_packet_ && !rtcp) {
|
2013-07-10 00:45:36 +00:00
|
|
|
has_received_packet_ = true;
|
2016-06-10 14:17:27 -07:00
|
|
|
signaling_thread()->Post(RTC_FROM_HERE, this, MSG_FIRSTPACKETRECEIVED);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Unprotect the packet, if needed.
|
|
|
|
|
if (srtp_filter_.IsActive()) {
|
2016-05-11 19:55:27 +02:00
|
|
|
TRACE_EVENT0("webrtc", "SRTP Decode");
|
rtc::Buffer improvements
1. Constructors, SetData(), and AppendData() now accept uint8_t*,
int8_t*, and char*. Previously, they accepted void*, meaning that
any kind of pointer was accepted. I think requiring an explicit
cast in cases where the input array isn't already of a byte-sized
type is a better compromise between convenience and safety.
2. data() can now return a uint8_t* instead of a char*, which seems
more appropriate for a byte array, and is harder to mix up with
zero-terminated C strings. data<int8_t>() is also available so
that callers that want that type instead won't have to cast, as
is data<char>() (which remains the default until all existing
callers have been fixed).
3. Constructors, SetData(), and AppendData() now accept arrays
natively, not just decayed to pointers. The advantage of this is
that callers don't have to pass the size separately.
4. There are new constructors that allow setting size and capacity
without initializing the array. Previously, this had to be done
separately after construction.
5. Instead of TransferTo(), Buffer now supports swap(), and move
construction and assignment, and has a Pass() method that works
just like std::move(). (The Pass method is modeled after
scoped_ptr::Pass().)
R=jmarusic@webrtc.org, tommi@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/42989004
Cr-Commit-Position: refs/heads/master@{#9033}
2015-04-20 14:03:07 +02:00
|
|
|
char* data = packet->data<char>();
|
2015-03-24 09:19:06 +00:00
|
|
|
int len = static_cast<int>(packet->size());
|
2013-07-10 00:45:36 +00:00
|
|
|
bool res;
|
|
|
|
|
if (!rtcp) {
|
|
|
|
|
res = srtp_filter_.UnprotectRtp(data, len, &len);
|
|
|
|
|
if (!res) {
|
|
|
|
|
int seq_num = -1;
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
uint32_t ssrc = 0;
|
2013-07-10 00:45:36 +00:00
|
|
|
GetRtpSeqNum(data, len, &seq_num);
|
|
|
|
|
GetRtpSsrc(data, len, &ssrc);
|
|
|
|
|
LOG(LS_ERROR) << "Failed to unprotect " << content_name_
|
|
|
|
|
<< " RTP packet: size=" << len
|
|
|
|
|
<< ", seqnum=" << seq_num << ", SSRC=" << ssrc;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
res = srtp_filter_.UnprotectRtcp(data, len, &len);
|
|
|
|
|
if (!res) {
|
|
|
|
|
int type = -1;
|
|
|
|
|
GetRtcpType(data, len, &type);
|
|
|
|
|
LOG(LS_ERROR) << "Failed to unprotect " << content_name_
|
|
|
|
|
<< " RTCP packet: size=" << len << ", type=" << type;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-24 09:19:06 +00:00
|
|
|
packet->SetSize(len);
|
2013-07-10 00:45:36 +00:00
|
|
|
} else if (secure_required_) {
|
|
|
|
|
// Our session description indicates that SRTP is required, but we got a
|
|
|
|
|
// packet before our SRTP filter is active. This means either that
|
|
|
|
|
// a) we got SRTP packets before we received the SDES keys, in which case
|
|
|
|
|
// we can't decrypt it anyway, or
|
|
|
|
|
// b) we got SRTP packets before DTLS completed on both the RTP and RTCP
|
|
|
|
|
// channels, so we haven't yet extracted keys, even if DTLS did complete
|
|
|
|
|
// on the channel that the packets are being sent on. It's really good
|
|
|
|
|
// practice to wait for both RTP and RTCP to be good to go before sending
|
|
|
|
|
// media, to prevent weird failure modes, so it's fine for us to just eat
|
|
|
|
|
// packets here. This is all sidestepped if RTCP mux is used anyway.
|
|
|
|
|
LOG(LS_WARNING) << "Can't process incoming " << PacketType(rtcp)
|
|
|
|
|
<< " packet when SRTP is inactive and crypto is required";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
invoker_.AsyncInvoke<void>(
|
2016-06-10 14:17:27 -07:00
|
|
|
RTC_FROM_HERE, worker_thread_,
|
2016-05-11 19:55:27 +02:00
|
|
|
Bind(&BaseChannel::OnPacketReceived, this, rtcp, *packet, packet_time));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::OnPacketReceived(bool rtcp,
|
|
|
|
|
const rtc::CopyOnWriteBuffer& packet,
|
|
|
|
|
const rtc::PacketTime& packet_time) {
|
|
|
|
|
RTC_DCHECK(worker_thread_->IsCurrent());
|
|
|
|
|
// Need to copy variable because OnRtcpReceived/OnPacketReceived
|
|
|
|
|
// requires non-const pointer to buffer. This doesn't memcpy the actual data.
|
|
|
|
|
rtc::CopyOnWriteBuffer data(packet);
|
|
|
|
|
if (rtcp) {
|
|
|
|
|
media_channel_->OnRtcpReceived(&data, packet_time);
|
2013-07-10 00:45:36 +00:00
|
|
|
} else {
|
2016-05-11 19:55:27 +02:00
|
|
|
media_channel_->OnPacketReceived(&data, packet_time);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-16 21:15:37 +00:00
|
|
|
bool BaseChannel::PushdownLocalDescription(
|
|
|
|
|
const SessionDescription* local_desc, ContentAction action,
|
|
|
|
|
std::string* error_desc) {
|
|
|
|
|
const ContentInfo* content_info = GetFirstContent(local_desc);
|
2013-07-10 00:45:36 +00:00
|
|
|
const MediaContentDescription* content_desc =
|
|
|
|
|
GetContentDescription(content_info);
|
|
|
|
|
if (content_desc && content_info && !content_info->rejected &&
|
2015-03-16 21:15:37 +00:00
|
|
|
!SetLocalContent(content_desc, action, error_desc)) {
|
|
|
|
|
LOG(LS_ERROR) << "Failure in SetLocalContent with action " << action;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BaseChannel::PushdownRemoteDescription(
|
|
|
|
|
const SessionDescription* remote_desc, ContentAction action,
|
|
|
|
|
std::string* error_desc) {
|
|
|
|
|
const ContentInfo* content_info = GetFirstContent(remote_desc);
|
|
|
|
|
const MediaContentDescription* content_desc =
|
|
|
|
|
GetContentDescription(content_info);
|
|
|
|
|
if (content_desc && content_info && !content_info->rejected &&
|
|
|
|
|
!SetRemoteContent(content_desc, action, error_desc)) {
|
2014-01-15 23:15:54 +00:00
|
|
|
LOG(LS_ERROR) << "Failure in SetRemoteContent with action " << action;
|
2015-03-16 21:15:37 +00:00
|
|
|
return false;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
2015-03-16 21:15:37 +00:00
|
|
|
return true;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::EnableMedia_w() {
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
|
2013-07-10 00:45:36 +00:00
|
|
|
if (enabled_)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
LOG(LS_INFO) << "Channel enabled";
|
|
|
|
|
enabled_ = true;
|
2016-08-25 13:31:14 -07:00
|
|
|
UpdateMediaSendRecvState_w();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::DisableMedia_w() {
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
|
2013-07-10 00:45:36 +00:00
|
|
|
if (!enabled_)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
LOG(LS_INFO) << "Channel disabled";
|
|
|
|
|
enabled_ = false;
|
2016-08-25 13:31:14 -07:00
|
|
|
UpdateMediaSendRecvState_w();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
void BaseChannel::UpdateWritableState_n() {
|
2015-09-23 11:50:27 -07:00
|
|
|
if (transport_channel_ && transport_channel_->writable() &&
|
|
|
|
|
(!rtcp_transport_channel_ || rtcp_transport_channel_->writable())) {
|
2016-05-11 19:55:27 +02:00
|
|
|
ChannelWritable_n();
|
2015-09-23 11:50:27 -07:00
|
|
|
} else {
|
2016-05-11 19:55:27 +02:00
|
|
|
ChannelNotWritable_n();
|
2015-09-23 11:50:27 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
void BaseChannel::ChannelWritable_n() {
|
|
|
|
|
RTC_DCHECK(network_thread_->IsCurrent());
|
2015-12-05 09:59:56 -08:00
|
|
|
if (writable_) {
|
2013-07-10 00:45:36 +00:00
|
|
|
return;
|
2015-12-05 09:59:56 -08:00
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-09-23 11:50:27 -07:00
|
|
|
LOG(LS_INFO) << "Channel writable (" << content_name_ << ")"
|
2013-07-10 00:45:36 +00:00
|
|
|
<< (was_ever_writable_ ? "" : " for the first time");
|
|
|
|
|
|
2016-11-08 02:50:09 -08:00
|
|
|
if (selected_candidate_pair_)
|
|
|
|
|
LOG(LS_INFO)
|
|
|
|
|
<< "Using "
|
|
|
|
|
<< selected_candidate_pair_->local_candidate().ToSensitiveString()
|
|
|
|
|
<< "->"
|
|
|
|
|
<< selected_candidate_pair_->remote_candidate().ToSensitiveString();
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
was_ever_writable_ = true;
|
2016-05-11 19:55:27 +02:00
|
|
|
MaybeSetupDtlsSrtp_n();
|
2013-07-10 00:45:36 +00:00
|
|
|
writable_ = true;
|
2016-08-25 13:31:14 -07:00
|
|
|
UpdateMediaSendRecvState();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
void BaseChannel::SignalDtlsSetupFailure_n(bool rtcp) {
|
|
|
|
|
RTC_DCHECK(network_thread_->IsCurrent());
|
|
|
|
|
invoker_.AsyncInvoke<void>(
|
2016-06-10 14:17:27 -07:00
|
|
|
RTC_FROM_HERE, signaling_thread(),
|
2016-05-11 19:55:27 +02:00
|
|
|
Bind(&BaseChannel::SignalDtlsSetupFailure_s, this, rtcp));
|
2015-03-16 19:34:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::SignalDtlsSetupFailure_s(bool rtcp) {
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(signaling_thread() == rtc::Thread::Current());
|
2015-03-16 19:34:23 +00:00
|
|
|
SignalDtlsSetupFailure(this, rtcp);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
bool BaseChannel::SetDtlsSrtpCryptoSuites_n(TransportChannel* tc, bool rtcp) {
|
2015-11-18 19:41:53 -08:00
|
|
|
std::vector<int> crypto_suites;
|
|
|
|
|
// We always use the default SRTP crypto suites for RTCP, but we may use
|
|
|
|
|
// different crypto suites for RTP depending on the media type.
|
2013-07-10 00:45:36 +00:00
|
|
|
if (!rtcp) {
|
2016-05-11 19:55:27 +02:00
|
|
|
GetSrtpCryptoSuites_n(&crypto_suites);
|
2013-07-10 00:45:36 +00:00
|
|
|
} else {
|
2016-08-04 05:20:32 -07:00
|
|
|
GetDefaultSrtpCryptoSuites(crypto_options(), &crypto_suites);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
2015-11-18 19:41:53 -08:00
|
|
|
return tc->SetSrtpCryptoSuites(crypto_suites);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
bool BaseChannel::ShouldSetupDtlsSrtp_n() const {
|
2015-12-05 09:59:56 -08:00
|
|
|
// Since DTLS is applied to all channels, checking RTP should be enough.
|
|
|
|
|
return transport_channel_ && transport_channel_->IsDtlsActive();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This function returns true if either DTLS-SRTP is not in use
|
|
|
|
|
// *or* DTLS-SRTP is successfully set up.
|
2016-05-11 19:55:27 +02:00
|
|
|
bool BaseChannel::SetupDtlsSrtp_n(bool rtcp_channel) {
|
|
|
|
|
RTC_DCHECK(network_thread_->IsCurrent());
|
2013-07-10 00:45:36 +00:00
|
|
|
bool ret = false;
|
|
|
|
|
|
2015-09-23 11:50:27 -07:00
|
|
|
TransportChannel* channel =
|
|
|
|
|
rtcp_channel ? rtcp_transport_channel_ : transport_channel_;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-12-05 09:59:56 -08:00
|
|
|
RTC_DCHECK(channel->IsDtlsActive());
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-11-18 19:41:53 -08:00
|
|
|
int selected_crypto_suite;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-11-18 19:41:53 -08:00
|
|
|
if (!channel->GetSrtpCryptoSuite(&selected_crypto_suite)) {
|
|
|
|
|
LOG(LS_ERROR) << "No DTLS-SRTP selected crypto suite";
|
2013-07-10 00:45:36 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LOG(LS_INFO) << "Installing keys from DTLS-SRTP on "
|
|
|
|
|
<< content_name() << " "
|
|
|
|
|
<< PacketType(rtcp_channel);
|
|
|
|
|
|
2016-08-04 05:20:32 -07:00
|
|
|
int key_len;
|
|
|
|
|
int salt_len;
|
|
|
|
|
if (!rtc::GetSrtpKeyAndSaltLengths(selected_crypto_suite, &key_len,
|
|
|
|
|
&salt_len)) {
|
|
|
|
|
LOG(LS_ERROR) << "Unknown DTLS-SRTP crypto suite" << selected_crypto_suite;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// OK, we're now doing DTLS (RFC 5764)
|
2016-08-04 05:20:32 -07:00
|
|
|
std::vector<unsigned char> dtls_buffer(key_len * 2 + salt_len * 2);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// RFC 5705 exporter using the RFC 5764 parameters
|
|
|
|
|
if (!channel->ExportKeyingMaterial(
|
|
|
|
|
kDtlsSrtpExporterLabel,
|
|
|
|
|
NULL, 0, false,
|
|
|
|
|
&dtls_buffer[0], dtls_buffer.size())) {
|
|
|
|
|
LOG(LS_WARNING) << "DTLS-SRTP key export failed";
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(false); // This should never happen
|
2013-07-10 00:45:36 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Sync up the keys with the DTLS-SRTP interface
|
2016-08-04 05:20:32 -07:00
|
|
|
std::vector<unsigned char> client_write_key(key_len + salt_len);
|
|
|
|
|
std::vector<unsigned char> server_write_key(key_len + salt_len);
|
2013-07-10 00:45:36 +00:00
|
|
|
size_t offset = 0;
|
2016-08-04 05:20:32 -07:00
|
|
|
memcpy(&client_write_key[0], &dtls_buffer[offset], key_len);
|
|
|
|
|
offset += key_len;
|
|
|
|
|
memcpy(&server_write_key[0], &dtls_buffer[offset], key_len);
|
|
|
|
|
offset += key_len;
|
|
|
|
|
memcpy(&client_write_key[key_len], &dtls_buffer[offset], salt_len);
|
|
|
|
|
offset += salt_len;
|
|
|
|
|
memcpy(&server_write_key[key_len], &dtls_buffer[offset], salt_len);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
std::vector<unsigned char> *send_key, *recv_key;
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::SSLRole role;
|
2013-08-23 23:21:25 +00:00
|
|
|
if (!channel->GetSslRole(&role)) {
|
|
|
|
|
LOG(LS_WARNING) << "GetSslRole failed";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
if (role == rtc::SSL_SERVER) {
|
2013-07-10 00:45:36 +00:00
|
|
|
send_key = &server_write_key;
|
|
|
|
|
recv_key = &client_write_key;
|
|
|
|
|
} else {
|
|
|
|
|
send_key = &client_write_key;
|
|
|
|
|
recv_key = &server_write_key;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rtcp_channel) {
|
2015-11-18 19:41:53 -08:00
|
|
|
ret = srtp_filter_.SetRtcpParams(selected_crypto_suite, &(*send_key)[0],
|
|
|
|
|
static_cast<int>(send_key->size()),
|
|
|
|
|
selected_crypto_suite, &(*recv_key)[0],
|
|
|
|
|
static_cast<int>(recv_key->size()));
|
2013-07-10 00:45:36 +00:00
|
|
|
} else {
|
2015-11-18 19:41:53 -08:00
|
|
|
ret = srtp_filter_.SetRtpParams(selected_crypto_suite, &(*send_key)[0],
|
|
|
|
|
static_cast<int>(send_key->size()),
|
|
|
|
|
selected_crypto_suite, &(*recv_key)[0],
|
|
|
|
|
static_cast<int>(recv_key->size()));
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-11-08 02:50:09 -08:00
|
|
|
if (!ret) {
|
2013-07-10 00:45:36 +00:00
|
|
|
LOG(LS_WARNING) << "DTLS-SRTP key installation failed";
|
2016-11-08 02:50:09 -08:00
|
|
|
} else {
|
2013-07-10 00:45:36 +00:00
|
|
|
dtls_keyed_ = true;
|
2016-11-08 02:50:09 -08:00
|
|
|
UpdateTransportOverhead();
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
void BaseChannel::MaybeSetupDtlsSrtp_n() {
|
2015-12-05 09:59:56 -08:00
|
|
|
if (srtp_filter_.IsActive()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
if (!ShouldSetupDtlsSrtp_n()) {
|
2015-12-05 09:59:56 -08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
if (!SetupDtlsSrtp_n(false)) {
|
|
|
|
|
SignalDtlsSetupFailure_n(false);
|
2015-12-05 09:59:56 -08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rtcp_transport_channel_) {
|
2016-05-11 19:55:27 +02:00
|
|
|
if (!SetupDtlsSrtp_n(true)) {
|
|
|
|
|
SignalDtlsSetupFailure_n(true);
|
2015-12-05 09:59:56 -08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
void BaseChannel::ChannelNotWritable_n() {
|
|
|
|
|
RTC_DCHECK(network_thread_->IsCurrent());
|
2013-07-10 00:45:36 +00:00
|
|
|
if (!writable_)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-09-23 11:50:27 -07:00
|
|
|
LOG(LS_INFO) << "Channel not writable (" << content_name_ << ")";
|
2013-07-10 00:45:36 +00:00
|
|
|
writable_ = false;
|
2016-08-25 13:31:14 -07:00
|
|
|
UpdateMediaSendRecvState();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
bool BaseChannel::SetRtpTransportParameters(
|
2015-08-07 16:05:34 -07:00
|
|
|
const MediaContentDescription* content,
|
|
|
|
|
ContentAction action,
|
|
|
|
|
ContentSource src,
|
|
|
|
|
std::string* error_desc) {
|
|
|
|
|
if (action == CA_UPDATE) {
|
|
|
|
|
// These parameters never get changed by a CA_UDPATE.
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Cache secure_required_ for belt and suspenders check on SendPacket
|
2016-05-11 19:55:27 +02:00
|
|
|
return network_thread_->Invoke<bool>(
|
2016-06-10 14:17:27 -07:00
|
|
|
RTC_FROM_HERE, Bind(&BaseChannel::SetRtpTransportParameters_n, this,
|
|
|
|
|
content, action, src, error_desc));
|
2016-05-11 19:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BaseChannel::SetRtpTransportParameters_n(
|
|
|
|
|
const MediaContentDescription* content,
|
|
|
|
|
ContentAction action,
|
|
|
|
|
ContentSource src,
|
|
|
|
|
std::string* error_desc) {
|
|
|
|
|
RTC_DCHECK(network_thread_->IsCurrent());
|
|
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
if (src == CS_LOCAL) {
|
|
|
|
|
set_secure_required(content->crypto_required() != CT_NONE);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
if (!SetSrtp_n(content->cryptos(), action, src, error_desc)) {
|
2015-08-07 16:05:34 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
if (!SetRtcpMux_n(content->rtcp_mux(), action, src, error_desc)) {
|
2015-08-07 16:05:34 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-13 17:18:27 +00:00
|
|
|
// |dtls| will be set to true if DTLS is active for transport channel and
|
|
|
|
|
// crypto is empty.
|
2016-05-11 19:55:27 +02:00
|
|
|
bool BaseChannel::CheckSrtpConfig_n(const std::vector<CryptoParams>& cryptos,
|
|
|
|
|
bool* dtls,
|
|
|
|
|
std::string* error_desc) {
|
2013-10-13 17:18:27 +00:00
|
|
|
*dtls = transport_channel_->IsDtlsActive();
|
|
|
|
|
if (*dtls && !cryptos.empty()) {
|
2016-05-11 19:55:27 +02:00
|
|
|
SafeSetError("Cryptos must be empty when DTLS is active.", error_desc);
|
2013-10-13 17:18:27 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
bool BaseChannel::SetSrtp_n(const std::vector<CryptoParams>& cryptos,
|
2014-01-15 23:15:54 +00:00
|
|
|
ContentAction action,
|
|
|
|
|
ContentSource src,
|
|
|
|
|
std::string* error_desc) {
|
2016-03-08 14:24:13 -08:00
|
|
|
TRACE_EVENT0("webrtc", "BaseChannel::SetSrtp_w");
|
2014-01-15 23:15:54 +00:00
|
|
|
if (action == CA_UPDATE) {
|
|
|
|
|
// no crypto params.
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
bool ret = false;
|
2013-10-13 17:18:27 +00:00
|
|
|
bool dtls = false;
|
2016-05-11 19:55:27 +02:00
|
|
|
ret = CheckSrtpConfig_n(cryptos, &dtls, error_desc);
|
2014-01-15 23:15:54 +00:00
|
|
|
if (!ret) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
switch (action) {
|
|
|
|
|
case CA_OFFER:
|
2013-10-13 17:18:27 +00:00
|
|
|
// If DTLS is already active on the channel, we could be renegotiating
|
|
|
|
|
// here. We don't update the srtp filter.
|
2014-01-15 23:15:54 +00:00
|
|
|
if (!dtls) {
|
2013-10-13 17:18:27 +00:00
|
|
|
ret = srtp_filter_.SetOffer(cryptos, src);
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
break;
|
|
|
|
|
case CA_PRANSWER:
|
|
|
|
|
// If we're doing DTLS-SRTP, we don't want to update the filter
|
|
|
|
|
// with an answer, because we already have SRTP parameters.
|
2014-01-15 23:15:54 +00:00
|
|
|
if (!dtls) {
|
2013-07-10 00:45:36 +00:00
|
|
|
ret = srtp_filter_.SetProvisionalAnswer(cryptos, src);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case CA_ANSWER:
|
|
|
|
|
// If we're doing DTLS-SRTP, we don't want to update the filter
|
|
|
|
|
// with an answer, because we already have SRTP parameters.
|
2014-01-15 23:15:54 +00:00
|
|
|
if (!dtls) {
|
2013-07-10 00:45:36 +00:00
|
|
|
ret = srtp_filter_.SetAnswer(cryptos, src);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-01-15 23:15:54 +00:00
|
|
|
if (!ret) {
|
|
|
|
|
SafeSetError("Failed to setup SRTP filter.", error_desc);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-05-21 07:48:41 -07:00
|
|
|
void BaseChannel::ActivateRtcpMux() {
|
2016-06-10 14:17:27 -07:00
|
|
|
network_thread_->Invoke<void>(RTC_FROM_HERE,
|
|
|
|
|
Bind(&BaseChannel::ActivateRtcpMux_n, this));
|
2015-05-21 07:48:41 -07:00
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
void BaseChannel::ActivateRtcpMux_n() {
|
2015-05-21 07:48:41 -07:00
|
|
|
if (!rtcp_mux_filter_.IsActive()) {
|
|
|
|
|
rtcp_mux_filter_.SetActive();
|
2016-08-26 21:42:15 -07:00
|
|
|
SetTransportChannel_n(true, nullptr);
|
|
|
|
|
// Update aggregate writable/ready-to-send state between RTP and RTCP upon
|
|
|
|
|
// removing channel.
|
|
|
|
|
UpdateWritableState_n();
|
|
|
|
|
SetTransportChannelReadyToSend(true, false);
|
2015-05-21 07:48:41 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
bool BaseChannel::SetRtcpMux_n(bool enable,
|
|
|
|
|
ContentAction action,
|
2014-01-15 23:15:54 +00:00
|
|
|
ContentSource src,
|
|
|
|
|
std::string* error_desc) {
|
2013-07-10 00:45:36 +00:00
|
|
|
bool ret = false;
|
|
|
|
|
switch (action) {
|
|
|
|
|
case CA_OFFER:
|
|
|
|
|
ret = rtcp_mux_filter_.SetOffer(enable, src);
|
|
|
|
|
break;
|
|
|
|
|
case CA_PRANSWER:
|
2016-08-25 13:31:14 -07:00
|
|
|
// This may activate RTCP muxing, but we don't yet destroy the channel
|
|
|
|
|
// because the final answer may deactivate it.
|
2013-07-10 00:45:36 +00:00
|
|
|
ret = rtcp_mux_filter_.SetProvisionalAnswer(enable, src);
|
|
|
|
|
break;
|
|
|
|
|
case CA_ANSWER:
|
|
|
|
|
ret = rtcp_mux_filter_.SetAnswer(enable, src);
|
|
|
|
|
if (ret && rtcp_mux_filter_.IsActive()) {
|
|
|
|
|
// We activated RTCP mux, close down the RTCP transport.
|
2015-09-23 11:50:27 -07:00
|
|
|
LOG(LS_INFO) << "Enabling rtcp-mux for " << content_name()
|
|
|
|
|
<< " by destroying RTCP transport channel for "
|
|
|
|
|
<< transport_name();
|
2016-08-26 21:42:15 -07:00
|
|
|
SetTransportChannel_n(true, nullptr);
|
|
|
|
|
UpdateWritableState_n();
|
|
|
|
|
SetTransportChannelReadyToSend(true, false);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case CA_UPDATE:
|
|
|
|
|
// No RTCP mux info.
|
|
|
|
|
ret = true;
|
2015-04-22 13:21:30 +02:00
|
|
|
break;
|
2013-07-10 00:45:36 +00:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-01-15 23:15:54 +00:00
|
|
|
if (!ret) {
|
|
|
|
|
SafeSetError("Failed to setup RTCP mux filter.", error_desc);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
// |rtcp_mux_filter_| can be active if |action| is CA_PRANSWER or
|
|
|
|
|
// CA_ANSWER, but we only want to tear down the RTCP transport channel if we
|
|
|
|
|
// received a final answer.
|
2014-01-15 23:15:54 +00:00
|
|
|
if (rtcp_mux_filter_.IsActive()) {
|
2013-07-10 00:45:36 +00:00
|
|
|
// If the RTP transport is already writable, then so are we.
|
|
|
|
|
if (transport_channel_->writable()) {
|
2016-05-11 19:55:27 +02:00
|
|
|
ChannelWritable_n();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-15 23:15:54 +00:00
|
|
|
return true;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BaseChannel::AddRecvStream_w(const StreamParams& sp) {
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(worker_thread() == rtc::Thread::Current());
|
2015-11-16 10:19:58 -08:00
|
|
|
return media_channel()->AddRecvStream(sp);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
bool BaseChannel::RemoveRecvStream_w(uint32_t ssrc) {
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(worker_thread() == rtc::Thread::Current());
|
2013-07-10 00:45:36 +00:00
|
|
|
return media_channel()->RemoveRecvStream(ssrc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BaseChannel::UpdateLocalStreams_w(const std::vector<StreamParams>& streams,
|
2014-01-15 23:15:54 +00:00
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc) {
|
2013-07-10 00:45:36 +00:00
|
|
|
if (!VERIFY(action == CA_OFFER || action == CA_ANSWER ||
|
|
|
|
|
action == CA_PRANSWER || action == CA_UPDATE))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// If this is an update, streams only contain streams that have changed.
|
|
|
|
|
if (action == CA_UPDATE) {
|
|
|
|
|
for (StreamParamsVec::const_iterator it = streams.begin();
|
|
|
|
|
it != streams.end(); ++it) {
|
2015-01-22 23:00:41 +00:00
|
|
|
const StreamParams* existing_stream =
|
|
|
|
|
GetStreamByIds(local_streams_, it->groupid, it->id);
|
|
|
|
|
if (!existing_stream && it->has_ssrcs()) {
|
2013-07-10 00:45:36 +00:00
|
|
|
if (media_channel()->AddSendStream(*it)) {
|
|
|
|
|
local_streams_.push_back(*it);
|
|
|
|
|
LOG(LS_INFO) << "Add send stream ssrc: " << it->first_ssrc();
|
|
|
|
|
} else {
|
2014-01-15 23:15:54 +00:00
|
|
|
std::ostringstream desc;
|
|
|
|
|
desc << "Failed to add send stream ssrc: " << it->first_ssrc();
|
|
|
|
|
SafeSetError(desc.str(), error_desc);
|
2013-07-10 00:45:36 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2015-01-22 23:00:41 +00:00
|
|
|
} else if (existing_stream && !it->has_ssrcs()) {
|
|
|
|
|
if (!media_channel()->RemoveSendStream(existing_stream->first_ssrc())) {
|
2014-01-15 23:15:54 +00:00
|
|
|
std::ostringstream desc;
|
|
|
|
|
desc << "Failed to remove send stream with ssrc "
|
|
|
|
|
<< it->first_ssrc() << ".";
|
|
|
|
|
SafeSetError(desc.str(), error_desc);
|
|
|
|
|
return false;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
2015-01-22 23:00:41 +00:00
|
|
|
RemoveStreamBySsrc(&local_streams_, existing_stream->first_ssrc());
|
2013-07-10 00:45:36 +00:00
|
|
|
} else {
|
|
|
|
|
LOG(LS_WARNING) << "Ignore unsupported stream update";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
// Else streams are all the streams we want to send.
|
|
|
|
|
|
|
|
|
|
// Check for streams that have been removed.
|
|
|
|
|
bool ret = true;
|
|
|
|
|
for (StreamParamsVec::const_iterator it = local_streams_.begin();
|
|
|
|
|
it != local_streams_.end(); ++it) {
|
2015-01-22 23:00:41 +00:00
|
|
|
if (!GetStreamBySsrc(streams, it->first_ssrc())) {
|
2013-07-10 00:45:36 +00:00
|
|
|
if (!media_channel()->RemoveSendStream(it->first_ssrc())) {
|
2014-01-15 23:15:54 +00:00
|
|
|
std::ostringstream desc;
|
|
|
|
|
desc << "Failed to remove send stream with ssrc "
|
|
|
|
|
<< it->first_ssrc() << ".";
|
|
|
|
|
SafeSetError(desc.str(), error_desc);
|
2013-07-10 00:45:36 +00:00
|
|
|
ret = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Check for new streams.
|
|
|
|
|
for (StreamParamsVec::const_iterator it = streams.begin();
|
|
|
|
|
it != streams.end(); ++it) {
|
2015-01-22 23:00:41 +00:00
|
|
|
if (!GetStreamBySsrc(local_streams_, it->first_ssrc())) {
|
2013-07-10 00:45:36 +00:00
|
|
|
if (media_channel()->AddSendStream(*it)) {
|
2015-10-15 07:26:07 -07:00
|
|
|
LOG(LS_INFO) << "Add send stream ssrc: " << it->ssrcs[0];
|
2013-07-10 00:45:36 +00:00
|
|
|
} else {
|
2014-01-15 23:15:54 +00:00
|
|
|
std::ostringstream desc;
|
|
|
|
|
desc << "Failed to add send stream ssrc: " << it->first_ssrc();
|
|
|
|
|
SafeSetError(desc.str(), error_desc);
|
2013-07-10 00:45:36 +00:00
|
|
|
ret = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
local_streams_ = streams;
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BaseChannel::UpdateRemoteStreams_w(
|
|
|
|
|
const std::vector<StreamParams>& streams,
|
2014-01-15 23:15:54 +00:00
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc) {
|
2013-07-10 00:45:36 +00:00
|
|
|
if (!VERIFY(action == CA_OFFER || action == CA_ANSWER ||
|
|
|
|
|
action == CA_PRANSWER || action == CA_UPDATE))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// If this is an update, streams only contain streams that have changed.
|
|
|
|
|
if (action == CA_UPDATE) {
|
|
|
|
|
for (StreamParamsVec::const_iterator it = streams.begin();
|
|
|
|
|
it != streams.end(); ++it) {
|
2015-01-22 23:00:41 +00:00
|
|
|
const StreamParams* existing_stream =
|
|
|
|
|
GetStreamByIds(remote_streams_, it->groupid, it->id);
|
|
|
|
|
if (!existing_stream && it->has_ssrcs()) {
|
2013-07-10 00:45:36 +00:00
|
|
|
if (AddRecvStream_w(*it)) {
|
|
|
|
|
remote_streams_.push_back(*it);
|
|
|
|
|
LOG(LS_INFO) << "Add remote stream ssrc: " << it->first_ssrc();
|
|
|
|
|
} else {
|
2014-01-15 23:15:54 +00:00
|
|
|
std::ostringstream desc;
|
|
|
|
|
desc << "Failed to add remote stream ssrc: " << it->first_ssrc();
|
|
|
|
|
SafeSetError(desc.str(), error_desc);
|
2013-07-10 00:45:36 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2015-01-22 23:00:41 +00:00
|
|
|
} else if (existing_stream && !it->has_ssrcs()) {
|
|
|
|
|
if (!RemoveRecvStream_w(existing_stream->first_ssrc())) {
|
2014-01-15 23:15:54 +00:00
|
|
|
std::ostringstream desc;
|
|
|
|
|
desc << "Failed to remove remote stream with ssrc "
|
|
|
|
|
<< it->first_ssrc() << ".";
|
|
|
|
|
SafeSetError(desc.str(), error_desc);
|
|
|
|
|
return false;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
2015-01-22 23:00:41 +00:00
|
|
|
RemoveStreamBySsrc(&remote_streams_, existing_stream->first_ssrc());
|
2013-07-10 00:45:36 +00:00
|
|
|
} else {
|
|
|
|
|
LOG(LS_WARNING) << "Ignore unsupported stream update."
|
2015-01-22 23:00:41 +00:00
|
|
|
<< " Stream exists? " << (existing_stream != nullptr)
|
2013-07-10 00:45:36 +00:00
|
|
|
<< " new stream = " << it->ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
// Else streams are all the streams we want to receive.
|
|
|
|
|
|
|
|
|
|
// Check for streams that have been removed.
|
|
|
|
|
bool ret = true;
|
|
|
|
|
for (StreamParamsVec::const_iterator it = remote_streams_.begin();
|
|
|
|
|
it != remote_streams_.end(); ++it) {
|
2015-01-22 23:00:41 +00:00
|
|
|
if (!GetStreamBySsrc(streams, it->first_ssrc())) {
|
2013-07-10 00:45:36 +00:00
|
|
|
if (!RemoveRecvStream_w(it->first_ssrc())) {
|
2014-01-15 23:15:54 +00:00
|
|
|
std::ostringstream desc;
|
|
|
|
|
desc << "Failed to remove remote stream with ssrc "
|
|
|
|
|
<< it->first_ssrc() << ".";
|
|
|
|
|
SafeSetError(desc.str(), error_desc);
|
2013-07-10 00:45:36 +00:00
|
|
|
ret = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Check for new streams.
|
|
|
|
|
for (StreamParamsVec::const_iterator it = streams.begin();
|
|
|
|
|
it != streams.end(); ++it) {
|
2015-01-22 23:00:41 +00:00
|
|
|
if (!GetStreamBySsrc(remote_streams_, it->first_ssrc())) {
|
2013-07-10 00:45:36 +00:00
|
|
|
if (AddRecvStream_w(*it)) {
|
|
|
|
|
LOG(LS_INFO) << "Add remote ssrc: " << it->ssrcs[0];
|
|
|
|
|
} else {
|
2014-01-15 23:15:54 +00:00
|
|
|
std::ostringstream desc;
|
|
|
|
|
desc << "Failed to add remote stream ssrc: " << it->first_ssrc();
|
|
|
|
|
SafeSetError(desc.str(), error_desc);
|
2013-07-10 00:45:36 +00:00
|
|
|
ret = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
remote_streams_ = streams;
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
void BaseChannel::MaybeCacheRtpAbsSendTimeHeaderExtension_w(
|
2016-05-26 11:24:55 -07:00
|
|
|
const std::vector<webrtc::RtpExtension>& extensions) {
|
2016-05-11 19:55:27 +02:00
|
|
|
// Absolute Send Time extension id is used only with external auth,
|
|
|
|
|
// so do not bother searching for it and making asyncronious call to set
|
|
|
|
|
// something that is not used.
|
|
|
|
|
#if defined(ENABLE_EXTERNAL_AUTH)
|
2016-05-26 11:24:55 -07:00
|
|
|
const webrtc::RtpExtension* send_time_extension =
|
|
|
|
|
FindHeaderExtension(extensions, webrtc::RtpExtension::kAbsSendTimeUri);
|
2016-05-11 19:55:27 +02:00
|
|
|
int rtp_abs_sendtime_extn_id =
|
2014-02-21 23:43:24 +00:00
|
|
|
send_time_extension ? send_time_extension->id : -1;
|
2016-05-11 19:55:27 +02:00
|
|
|
invoker_.AsyncInvoke<void>(
|
2016-06-10 14:17:27 -07:00
|
|
|
RTC_FROM_HERE, network_thread_,
|
|
|
|
|
Bind(&BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n, this,
|
|
|
|
|
rtp_abs_sendtime_extn_id));
|
2016-05-11 19:55:27 +02:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n(
|
|
|
|
|
int rtp_abs_sendtime_extn_id) {
|
|
|
|
|
rtp_abs_sendtime_extn_id_ = rtp_abs_sendtime_extn_id;
|
2014-02-21 23:43:24 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
void BaseChannel::OnMessage(rtc::Message *pmsg) {
|
2015-12-07 23:17:15 +01:00
|
|
|
TRACE_EVENT0("webrtc", "BaseChannel::OnMessage");
|
2013-07-10 00:45:36 +00:00
|
|
|
switch (pmsg->message_id) {
|
2016-05-11 19:55:27 +02:00
|
|
|
case MSG_SEND_RTP_PACKET:
|
|
|
|
|
case MSG_SEND_RTCP_PACKET: {
|
|
|
|
|
RTC_DCHECK(network_thread_->IsCurrent());
|
|
|
|
|
SendPacketMessageData* data =
|
|
|
|
|
static_cast<SendPacketMessageData*>(pmsg->pdata);
|
|
|
|
|
bool rtcp = pmsg->message_id == MSG_SEND_RTCP_PACKET;
|
|
|
|
|
SendPacket(rtcp, &data->packet, data->options);
|
|
|
|
|
delete data;
|
2013-07-10 00:45:36 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case MSG_FIRSTPACKETRECEIVED: {
|
|
|
|
|
SignalFirstPacketReceived(this);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
void BaseChannel::FlushRtcpMessages_n() {
|
2013-07-10 00:45:36 +00:00
|
|
|
// Flush all remaining RTCP messages. This should only be called in
|
|
|
|
|
// destructor.
|
2016-05-11 19:55:27 +02:00
|
|
|
RTC_DCHECK(network_thread_->IsCurrent());
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::MessageList rtcp_messages;
|
2016-05-11 19:55:27 +02:00
|
|
|
network_thread_->Clear(this, MSG_SEND_RTCP_PACKET, &rtcp_messages);
|
|
|
|
|
for (const auto& message : rtcp_messages) {
|
2016-06-10 14:17:27 -07:00
|
|
|
network_thread_->Send(RTC_FROM_HERE, this, MSG_SEND_RTCP_PACKET,
|
|
|
|
|
message.pdata);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-25 10:50:32 -07:00
|
|
|
void BaseChannel::SignalSentPacket_n(
|
|
|
|
|
rtc::PacketTransportInterface* /* transport */,
|
|
|
|
|
const rtc::SentPacket& sent_packet) {
|
2016-05-11 19:55:27 +02:00
|
|
|
RTC_DCHECK(network_thread_->IsCurrent());
|
|
|
|
|
invoker_.AsyncInvoke<void>(
|
2016-06-10 14:17:27 -07:00
|
|
|
RTC_FROM_HERE, worker_thread_,
|
2016-05-11 19:55:27 +02:00
|
|
|
rtc::Bind(&BaseChannel::SignalSentPacket_w, this, sent_packet));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::SignalSentPacket_w(const rtc::SentPacket& sent_packet) {
|
|
|
|
|
RTC_DCHECK(worker_thread_->IsCurrent());
|
|
|
|
|
SignalSentPacket(sent_packet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VoiceChannel::VoiceChannel(rtc::Thread* worker_thread,
|
|
|
|
|
rtc::Thread* network_thread,
|
2013-07-10 00:45:36 +00:00
|
|
|
MediaEngineInterface* media_engine,
|
|
|
|
|
VoiceMediaChannel* media_channel,
|
2015-09-23 11:50:27 -07:00
|
|
|
TransportController* transport_controller,
|
2013-07-10 00:45:36 +00:00
|
|
|
const std::string& content_name,
|
|
|
|
|
bool rtcp)
|
2016-05-11 19:55:27 +02:00
|
|
|
: BaseChannel(worker_thread,
|
|
|
|
|
network_thread,
|
2015-09-23 11:50:27 -07:00
|
|
|
media_channel,
|
|
|
|
|
transport_controller,
|
|
|
|
|
content_name,
|
2013-07-10 00:45:36 +00:00
|
|
|
rtcp),
|
2015-08-05 12:25:22 +02:00
|
|
|
media_engine_(media_engine),
|
2015-09-23 11:50:27 -07:00
|
|
|
received_media_(false) {}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
VoiceChannel::~VoiceChannel() {
|
2016-03-08 14:24:13 -08:00
|
|
|
TRACE_EVENT0("webrtc", "VoiceChannel::~VoiceChannel");
|
2013-07-10 00:45:36 +00:00
|
|
|
StopAudioMonitor();
|
|
|
|
|
StopMediaMonitor();
|
|
|
|
|
// this can't be done in the base class, since it calls a virtual
|
|
|
|
|
DisableMedia_w();
|
2013-10-07 23:32:02 +00:00
|
|
|
Deinit();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-05-17 17:49:52 -07:00
|
|
|
bool VoiceChannel::Init_w(const std::string* bundle_transport_name) {
|
|
|
|
|
if (!BaseChannel::Init_w(bundle_transport_name)) {
|
2013-07-10 00:45:36 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
bool VoiceChannel::SetAudioSend(uint32_t ssrc,
|
2015-10-01 02:31:10 -07:00
|
|
|
bool enable,
|
2015-09-10 01:57:14 -07:00
|
|
|
const AudioOptions* options,
|
2016-03-08 12:37:39 -08:00
|
|
|
AudioSource* source) {
|
2016-06-10 14:17:27 -07:00
|
|
|
return InvokeOnWorker(RTC_FROM_HERE,
|
|
|
|
|
Bind(&VoiceMediaChannel::SetAudioSend, media_channel(),
|
2016-03-08 12:37:39 -08:00
|
|
|
ssrc, enable, options, source));
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO(juberti): Handle early media the right way. We should get an explicit
|
|
|
|
|
// ringing message telling us to start playing local ringback, which we cancel
|
|
|
|
|
// if any early media actually arrives. For now, we do the opposite, which is
|
|
|
|
|
// to wait 1 second for early media, and start playing local ringback if none
|
|
|
|
|
// arrives.
|
|
|
|
|
void VoiceChannel::SetEarlyMedia(bool enable) {
|
|
|
|
|
if (enable) {
|
|
|
|
|
// Start the early media timeout
|
2016-06-10 14:17:27 -07:00
|
|
|
worker_thread()->PostDelayed(RTC_FROM_HERE, kEarlyMediaTimeout, this,
|
|
|
|
|
MSG_EARLYMEDIATIMEOUT);
|
2013-07-10 00:45:36 +00:00
|
|
|
} else {
|
|
|
|
|
// Stop the timeout if currently going.
|
2014-02-07 19:03:26 +00:00
|
|
|
worker_thread()->Clear(this, MSG_EARLYMEDIATIMEOUT);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool VoiceChannel::CanInsertDtmf() {
|
2016-06-10 14:17:27 -07:00
|
|
|
return InvokeOnWorker(
|
|
|
|
|
RTC_FROM_HERE, Bind(&VoiceMediaChannel::CanInsertDtmf, media_channel()));
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
bool VoiceChannel::InsertDtmf(uint32_t ssrc,
|
|
|
|
|
int event_code,
|
2015-12-02 12:35:09 -08:00
|
|
|
int duration) {
|
2016-06-10 14:17:27 -07:00
|
|
|
return InvokeOnWorker(RTC_FROM_HERE, Bind(&VoiceChannel::InsertDtmf_w, this,
|
|
|
|
|
ssrc, event_code, duration));
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-09 02:32:53 -07:00
|
|
|
bool VoiceChannel::SetOutputVolume(uint32_t ssrc, double volume) {
|
2016-06-10 14:17:27 -07:00
|
|
|
return InvokeOnWorker(RTC_FROM_HERE, Bind(&VoiceMediaChannel::SetOutputVolume,
|
|
|
|
|
media_channel(), ssrc, volume));
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
2014-02-07 19:03:26 +00:00
|
|
|
|
2015-12-12 01:37:01 +01:00
|
|
|
void VoiceChannel::SetRawAudioSink(
|
|
|
|
|
uint32_t ssrc,
|
2016-03-11 14:18:21 -08:00
|
|
|
std::unique_ptr<webrtc::AudioSinkInterface> sink) {
|
|
|
|
|
// We need to work around Bind's lack of support for unique_ptr and ownership
|
2016-01-13 12:00:26 -08:00
|
|
|
// passing. So we invoke to our own little routine that gets a pointer to
|
|
|
|
|
// our local variable. This is OK since we're synchronously invoking.
|
2016-06-10 14:17:27 -07:00
|
|
|
InvokeOnWorker(RTC_FROM_HERE,
|
|
|
|
|
Bind(&SetRawAudioSink_w, media_channel(), ssrc, &sink));
|
2015-12-12 01:37:01 +01:00
|
|
|
}
|
|
|
|
|
|
2016-05-16 11:40:30 -07:00
|
|
|
webrtc::RtpParameters VoiceChannel::GetRtpSendParameters(uint32_t ssrc) const {
|
2016-03-16 19:07:43 -07:00
|
|
|
return worker_thread()->Invoke<webrtc::RtpParameters>(
|
2016-06-10 14:17:27 -07:00
|
|
|
RTC_FROM_HERE, Bind(&VoiceChannel::GetRtpSendParameters_w, this, ssrc));
|
2016-03-16 19:07:43 -07:00
|
|
|
}
|
|
|
|
|
|
2016-05-16 11:40:30 -07:00
|
|
|
webrtc::RtpParameters VoiceChannel::GetRtpSendParameters_w(
|
|
|
|
|
uint32_t ssrc) const {
|
|
|
|
|
return media_channel()->GetRtpSendParameters(ssrc);
|
2016-03-16 19:07:43 -07:00
|
|
|
}
|
|
|
|
|
|
2016-05-16 11:40:30 -07:00
|
|
|
bool VoiceChannel::SetRtpSendParameters(
|
|
|
|
|
uint32_t ssrc,
|
|
|
|
|
const webrtc::RtpParameters& parameters) {
|
|
|
|
|
return InvokeOnWorker(
|
2016-06-10 14:17:27 -07:00
|
|
|
RTC_FROM_HERE,
|
2016-05-16 11:40:30 -07:00
|
|
|
Bind(&VoiceChannel::SetRtpSendParameters_w, this, ssrc, parameters));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool VoiceChannel::SetRtpSendParameters_w(uint32_t ssrc,
|
|
|
|
|
webrtc::RtpParameters parameters) {
|
|
|
|
|
return media_channel()->SetRtpSendParameters(ssrc, parameters);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
webrtc::RtpParameters VoiceChannel::GetRtpReceiveParameters(
|
|
|
|
|
uint32_t ssrc) const {
|
|
|
|
|
return worker_thread()->Invoke<webrtc::RtpParameters>(
|
2016-06-10 14:17:27 -07:00
|
|
|
RTC_FROM_HERE,
|
2016-05-16 11:40:30 -07:00
|
|
|
Bind(&VoiceChannel::GetRtpReceiveParameters_w, this, ssrc));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
webrtc::RtpParameters VoiceChannel::GetRtpReceiveParameters_w(
|
|
|
|
|
uint32_t ssrc) const {
|
|
|
|
|
return media_channel()->GetRtpReceiveParameters(ssrc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool VoiceChannel::SetRtpReceiveParameters(
|
|
|
|
|
uint32_t ssrc,
|
|
|
|
|
const webrtc::RtpParameters& parameters) {
|
2016-03-16 19:07:43 -07:00
|
|
|
return InvokeOnWorker(
|
2016-06-10 14:17:27 -07:00
|
|
|
RTC_FROM_HERE,
|
2016-05-16 11:40:30 -07:00
|
|
|
Bind(&VoiceChannel::SetRtpReceiveParameters_w, this, ssrc, parameters));
|
2016-03-16 19:07:43 -07:00
|
|
|
}
|
|
|
|
|
|
2016-05-16 11:40:30 -07:00
|
|
|
bool VoiceChannel::SetRtpReceiveParameters_w(uint32_t ssrc,
|
|
|
|
|
webrtc::RtpParameters parameters) {
|
|
|
|
|
return media_channel()->SetRtpReceiveParameters(ssrc, parameters);
|
2016-03-16 19:07:43 -07:00
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
bool VoiceChannel::GetStats(VoiceMediaInfo* stats) {
|
2016-06-10 14:17:27 -07:00
|
|
|
return InvokeOnWorker(RTC_FROM_HERE, Bind(&VoiceMediaChannel::GetStats,
|
|
|
|
|
media_channel(), stats));
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VoiceChannel::StartMediaMonitor(int cms) {
|
|
|
|
|
media_monitor_.reset(new VoiceMediaMonitor(media_channel(), worker_thread(),
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::Thread::Current()));
|
2013-07-10 00:45:36 +00:00
|
|
|
media_monitor_->SignalUpdate.connect(
|
|
|
|
|
this, &VoiceChannel::OnMediaMonitorUpdate);
|
|
|
|
|
media_monitor_->Start(cms);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VoiceChannel::StopMediaMonitor() {
|
|
|
|
|
if (media_monitor_) {
|
|
|
|
|
media_monitor_->Stop();
|
|
|
|
|
media_monitor_->SignalUpdate.disconnect(this);
|
|
|
|
|
media_monitor_.reset();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VoiceChannel::StartAudioMonitor(int cms) {
|
2014-07-29 17:36:52 +00:00
|
|
|
audio_monitor_.reset(new AudioMonitor(this, rtc::Thread::Current()));
|
2013-07-10 00:45:36 +00:00
|
|
|
audio_monitor_
|
|
|
|
|
->SignalUpdate.connect(this, &VoiceChannel::OnAudioMonitorUpdate);
|
|
|
|
|
audio_monitor_->Start(cms);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VoiceChannel::StopAudioMonitor() {
|
|
|
|
|
if (audio_monitor_) {
|
|
|
|
|
audio_monitor_->Stop();
|
|
|
|
|
audio_monitor_.reset();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool VoiceChannel::IsAudioMonitorRunning() const {
|
|
|
|
|
return (audio_monitor_.get() != NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int VoiceChannel::GetInputLevel_w() {
|
2015-08-05 12:25:22 +02:00
|
|
|
return media_engine_->GetInputLevel();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int VoiceChannel::GetOutputLevel_w() {
|
|
|
|
|
return media_channel()->GetOutputLevel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VoiceChannel::GetActiveStreams_w(AudioInfo::StreamList* actives) {
|
|
|
|
|
media_channel()->GetActiveStreams(actives);
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-25 10:50:32 -07:00
|
|
|
void VoiceChannel::OnPacketRead(rtc::PacketTransportInterface* transport,
|
|
|
|
|
const char* data,
|
|
|
|
|
size_t len,
|
|
|
|
|
const rtc::PacketTime& packet_time,
|
2013-12-13 00:21:03 +00:00
|
|
|
int flags) {
|
2016-10-25 10:50:32 -07:00
|
|
|
BaseChannel::OnPacketRead(transport, data, len, packet_time, flags);
|
2013-07-10 00:45:36 +00:00
|
|
|
// Set a flag when we've received an RTP packet. If we're waiting for early
|
|
|
|
|
// media, this will disable the timeout.
|
2016-10-25 10:50:32 -07:00
|
|
|
if (!received_media_ && !PacketIsRtcp(transport, data, len)) {
|
2013-07-10 00:45:36 +00:00
|
|
|
received_media_ = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-25 13:31:14 -07:00
|
|
|
void BaseChannel::UpdateMediaSendRecvState() {
|
2016-05-11 19:55:27 +02:00
|
|
|
RTC_DCHECK(network_thread_->IsCurrent());
|
2016-08-25 13:31:14 -07:00
|
|
|
invoker_.AsyncInvoke<void>(
|
|
|
|
|
RTC_FROM_HERE, worker_thread_,
|
|
|
|
|
Bind(&BaseChannel::UpdateMediaSendRecvState_w, this));
|
2016-05-11 19:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
2016-11-08 02:50:09 -08:00
|
|
|
int BaseChannel::GetTransportOverheadPerPacket() const {
|
|
|
|
|
RTC_DCHECK(network_thread_->IsCurrent());
|
|
|
|
|
|
|
|
|
|
if (!selected_candidate_pair_)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
int transport_overhead_per_packet = 0;
|
|
|
|
|
|
|
|
|
|
constexpr int kIpv4Overhaed = 20;
|
|
|
|
|
constexpr int kIpv6Overhaed = 40;
|
|
|
|
|
transport_overhead_per_packet +=
|
|
|
|
|
selected_candidate_pair_->local_candidate().address().family() == AF_INET
|
|
|
|
|
? kIpv4Overhaed
|
|
|
|
|
: kIpv6Overhaed;
|
|
|
|
|
|
|
|
|
|
constexpr int kUdpOverhaed = 8;
|
|
|
|
|
constexpr int kTcpOverhaed = 20;
|
|
|
|
|
transport_overhead_per_packet +=
|
|
|
|
|
selected_candidate_pair_->local_candidate().protocol() ==
|
|
|
|
|
TCP_PROTOCOL_NAME
|
|
|
|
|
? kTcpOverhaed
|
|
|
|
|
: kUdpOverhaed;
|
|
|
|
|
|
|
|
|
|
if (secure()) {
|
|
|
|
|
int srtp_overhead = 0;
|
|
|
|
|
if (srtp_filter_.GetSrtpOverhead(&srtp_overhead))
|
|
|
|
|
transport_overhead_per_packet += srtp_overhead;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return transport_overhead_per_packet;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::UpdateTransportOverhead() {
|
|
|
|
|
int transport_overhead_per_packet = GetTransportOverheadPerPacket();
|
|
|
|
|
if (transport_overhead_per_packet)
|
|
|
|
|
invoker_.AsyncInvoke<void>(
|
|
|
|
|
RTC_FROM_HERE, worker_thread_,
|
|
|
|
|
Bind(&MediaChannel::OnTransportOverheadChanged, media_channel_,
|
|
|
|
|
transport_overhead_per_packet));
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-25 13:31:14 -07:00
|
|
|
void VoiceChannel::UpdateMediaSendRecvState_w() {
|
2013-07-10 00:45:36 +00:00
|
|
|
// Render incoming data if we're the active call, and we have the local
|
|
|
|
|
// content. We receive data on the default channel and multiplexed streams.
|
2016-08-25 13:31:14 -07:00
|
|
|
bool recv = IsReadyToReceiveMedia_w();
|
2015-10-01 04:10:31 -07:00
|
|
|
media_channel()->SetPlayout(recv);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// Send outgoing data if we're the active call, we have the remote content,
|
|
|
|
|
// and we have had some form of connectivity.
|
2016-08-25 13:31:14 -07:00
|
|
|
bool send = IsReadyToSendMedia_w();
|
2016-03-08 12:37:39 -08:00
|
|
|
media_channel()->SetSend(send);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
LOG(LS_INFO) << "Changing voice state, recv=" << recv << " send=" << send;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ContentInfo* VoiceChannel::GetFirstContent(
|
|
|
|
|
const SessionDescription* sdesc) {
|
|
|
|
|
return GetFirstAudioContent(sdesc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool VoiceChannel::SetLocalContent_w(const MediaContentDescription* content,
|
2014-01-15 23:15:54 +00:00
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc) {
|
2015-12-08 13:25:57 +01:00
|
|
|
TRACE_EVENT0("webrtc", "VoiceChannel::SetLocalContent_w");
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(worker_thread() == rtc::Thread::Current());
|
2013-07-10 00:45:36 +00:00
|
|
|
LOG(LS_INFO) << "Setting local voice description";
|
|
|
|
|
|
|
|
|
|
const AudioContentDescription* audio =
|
|
|
|
|
static_cast<const AudioContentDescription*>(content);
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(audio != NULL);
|
2014-01-15 23:15:54 +00:00
|
|
|
if (!audio) {
|
|
|
|
|
SafeSetError("Can't find audio content in local description.", error_desc);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) {
|
2015-08-07 16:05:34 -07:00
|
|
|
return false;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
AudioRecvParameters recv_params = last_recv_params_;
|
|
|
|
|
RtpParametersFromMediaDescription(audio, &recv_params);
|
|
|
|
|
if (!media_channel()->SetRecvParameters(recv_params)) {
|
2015-08-20 17:40:24 -07:00
|
|
|
SafeSetError("Failed to set local audio description recv parameters.",
|
2015-08-07 16:05:34 -07:00
|
|
|
error_desc);
|
|
|
|
|
return false;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
2015-08-07 16:05:34 -07:00
|
|
|
for (const AudioCodec& codec : audio->codecs()) {
|
|
|
|
|
bundle_filter()->AddPayloadType(codec.id);
|
|
|
|
|
}
|
|
|
|
|
last_recv_params_ = recv_params;
|
|
|
|
|
|
|
|
|
|
// TODO(pthatcher): Move local streams into AudioSendParameters, and
|
|
|
|
|
// only give it to the media channel once we have a remote
|
|
|
|
|
// description too (without a remote description, we won't be able
|
|
|
|
|
// to send them anyway).
|
|
|
|
|
if (!UpdateLocalStreams_w(audio->streams(), action, error_desc)) {
|
|
|
|
|
SafeSetError("Failed to set local audio description streams.", error_desc);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set_local_content_direction(content->direction());
|
2016-08-25 13:31:14 -07:00
|
|
|
UpdateMediaSendRecvState_w();
|
2015-08-07 16:05:34 -07:00
|
|
|
return true;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool VoiceChannel::SetRemoteContent_w(const MediaContentDescription* content,
|
2014-01-15 23:15:54 +00:00
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc) {
|
2015-12-08 13:25:57 +01:00
|
|
|
TRACE_EVENT0("webrtc", "VoiceChannel::SetRemoteContent_w");
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(worker_thread() == rtc::Thread::Current());
|
2013-07-10 00:45:36 +00:00
|
|
|
LOG(LS_INFO) << "Setting remote voice description";
|
|
|
|
|
|
|
|
|
|
const AudioContentDescription* audio =
|
|
|
|
|
static_cast<const AudioContentDescription*>(content);
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(audio != NULL);
|
2014-01-15 23:15:54 +00:00
|
|
|
if (!audio) {
|
|
|
|
|
SafeSetError("Can't find audio content in remote description.", error_desc);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) {
|
2015-08-07 16:05:34 -07:00
|
|
|
return false;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
AudioSendParameters send_params = last_send_params_;
|
|
|
|
|
RtpSendParametersFromMediaDescription(audio, &send_params);
|
|
|
|
|
if (audio->agc_minus_10db()) {
|
2015-11-10 22:34:18 +01:00
|
|
|
send_params.options.adjust_agc_delta = rtc::Optional<int>(kAgcMinus10db);
|
2015-08-07 16:05:34 -07:00
|
|
|
}
|
2016-03-16 19:07:43 -07:00
|
|
|
|
|
|
|
|
bool parameters_applied = media_channel()->SetSendParameters(send_params);
|
|
|
|
|
if (!parameters_applied) {
|
2015-08-07 16:05:34 -07:00
|
|
|
SafeSetError("Failed to set remote audio description send parameters.",
|
|
|
|
|
error_desc);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
last_send_params_ = send_params;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
// TODO(pthatcher): Move remote streams into AudioRecvParameters,
|
|
|
|
|
// and only give it to the media channel once we have a local
|
|
|
|
|
// description too (without a local description, we won't be able to
|
|
|
|
|
// recv them anyway).
|
|
|
|
|
if (!UpdateRemoteStreams_w(audio->streams(), action, error_desc)) {
|
|
|
|
|
SafeSetError("Failed to set remote audio description streams.", error_desc);
|
|
|
|
|
return false;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
2015-08-07 16:05:34 -07:00
|
|
|
|
2015-08-20 17:40:24 -07:00
|
|
|
if (audio->rtp_header_extensions_set()) {
|
2016-05-11 19:55:27 +02:00
|
|
|
MaybeCacheRtpAbsSendTimeHeaderExtension_w(audio->rtp_header_extensions());
|
2015-08-20 17:40:24 -07:00
|
|
|
}
|
|
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
set_remote_content_direction(content->direction());
|
2016-08-25 13:31:14 -07:00
|
|
|
UpdateMediaSendRecvState_w();
|
2015-08-07 16:05:34 -07:00
|
|
|
return true;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VoiceChannel::HandleEarlyMediaTimeout() {
|
|
|
|
|
// This occurs on the main thread, not the worker thread.
|
|
|
|
|
if (!received_media_) {
|
|
|
|
|
LOG(LS_INFO) << "No early media received before timeout";
|
|
|
|
|
SignalEarlyMediaTimeout(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
bool VoiceChannel::InsertDtmf_w(uint32_t ssrc,
|
|
|
|
|
int event,
|
2015-12-02 12:35:09 -08:00
|
|
|
int duration) {
|
2013-07-10 00:45:36 +00:00
|
|
|
if (!enabled()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-12-02 12:35:09 -08:00
|
|
|
return media_channel()->InsertDtmf(ssrc, event, duration);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
void VoiceChannel::OnMessage(rtc::Message *pmsg) {
|
2013-07-10 00:45:36 +00:00
|
|
|
switch (pmsg->message_id) {
|
|
|
|
|
case MSG_EARLYMEDIATIMEOUT:
|
|
|
|
|
HandleEarlyMediaTimeout();
|
|
|
|
|
break;
|
|
|
|
|
case MSG_CHANNEL_ERROR: {
|
|
|
|
|
VoiceChannelErrorMessageData* data =
|
|
|
|
|
static_cast<VoiceChannelErrorMessageData*>(pmsg->pdata);
|
|
|
|
|
delete data;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
BaseChannel::OnMessage(pmsg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VoiceChannel::OnConnectionMonitorUpdate(
|
2015-03-13 18:25:21 +00:00
|
|
|
ConnectionMonitor* monitor, const std::vector<ConnectionInfo>& infos) {
|
2013-07-10 00:45:36 +00:00
|
|
|
SignalConnectionMonitor(this, infos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VoiceChannel::OnMediaMonitorUpdate(
|
|
|
|
|
VoiceMediaChannel* media_channel, const VoiceMediaInfo& info) {
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(media_channel == this->media_channel());
|
2013-07-10 00:45:36 +00:00
|
|
|
SignalMediaMonitor(this, info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VoiceChannel::OnAudioMonitorUpdate(AudioMonitor* monitor,
|
|
|
|
|
const AudioInfo& info) {
|
|
|
|
|
SignalAudioMonitor(this, info);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
void VoiceChannel::GetSrtpCryptoSuites_n(
|
|
|
|
|
std::vector<int>* crypto_suites) const {
|
2016-08-04 05:20:32 -07:00
|
|
|
GetSupportedAudioCryptoSuites(crypto_options(), crypto_suites);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
VideoChannel::VideoChannel(rtc::Thread* worker_thread,
|
|
|
|
|
rtc::Thread* network_thread,
|
2013-07-10 00:45:36 +00:00
|
|
|
VideoMediaChannel* media_channel,
|
2015-09-23 11:50:27 -07:00
|
|
|
TransportController* transport_controller,
|
2013-07-10 00:45:36 +00:00
|
|
|
const std::string& content_name,
|
2015-04-22 15:30:51 +02:00
|
|
|
bool rtcp)
|
2016-05-11 19:55:27 +02:00
|
|
|
: BaseChannel(worker_thread,
|
|
|
|
|
network_thread,
|
2015-09-23 11:50:27 -07:00
|
|
|
media_channel,
|
|
|
|
|
transport_controller,
|
|
|
|
|
content_name,
|
2016-03-07 17:34:13 -08:00
|
|
|
rtcp) {}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-05-17 17:49:52 -07:00
|
|
|
bool VideoChannel::Init_w(const std::string* bundle_transport_name) {
|
|
|
|
|
if (!BaseChannel::Init_w(bundle_transport_name)) {
|
2013-07-10 00:45:36 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VideoChannel::~VideoChannel() {
|
2016-03-08 14:24:13 -08:00
|
|
|
TRACE_EVENT0("webrtc", "VideoChannel::~VideoChannel");
|
2013-07-10 00:45:36 +00:00
|
|
|
StopMediaMonitor();
|
|
|
|
|
// this can't be done in the base class, since it calls a virtual
|
|
|
|
|
DisableMedia_w();
|
2013-10-07 23:32:02 +00:00
|
|
|
|
|
|
|
|
Deinit();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-02-04 01:24:52 -08:00
|
|
|
bool VideoChannel::SetSink(uint32_t ssrc,
|
Reland of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #1 id:1 of https://codereview.webrtc.org/2471783002/ )
Reason for revert:
Relanding after known downstream breakages have been fixed.
Original issue's description:
> Revert of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #7 id:120001 of https://codereview.webrtc.org/2383093002/ )
>
> Reason for revert:
> Breaks chrome, see https://build.chromium.org/p/chromium.webrtc.fyi/builders/Mac%20Builder/builds/19019/steps/compile/logs/stdio
>
> Analysis: Chrome uses cricket::VideoFrame, without explicitly including webrtc/media/base/videoframe.h, and breaks when that file is no longer included by any other webrtc headers. Will reland after updating Chrome.
>
> Original issue's description:
> > Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame.
> >
> > Replaced with webrtc::VideoFrame.
> >
> > TBR=mflodman@webrtc.org
> > BUG=webrtc:5682
> >
> > Committed: https://crrev.com/45c8b8940042bd2574c39920804ade8343cefdba
> > Cr-Commit-Position: refs/heads/master@{#14885}
>
> TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5682
>
> Committed: https://crrev.com/7341ab8e2505c9763d208e069bda269018357e7d
> Cr-Commit-Position: refs/heads/master@{#14886}
TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:5682
Review-Url: https://codereview.webrtc.org/2487633002
Cr-Commit-Position: refs/heads/master@{#15039}
2016-11-11 03:55:13 -08:00
|
|
|
rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) {
|
2016-02-04 01:24:52 -08:00
|
|
|
worker_thread()->Invoke<void>(
|
2016-06-10 14:17:27 -07:00
|
|
|
RTC_FROM_HERE,
|
2016-02-04 01:24:52 -08:00
|
|
|
Bind(&VideoMediaChannel::SetSink, media_channel(), ssrc, sink));
|
2013-07-10 00:45:36 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-02 16:23:38 -07:00
|
|
|
bool VideoChannel::SetVideoSend(
|
2016-04-08 02:23:55 -07:00
|
|
|
uint32_t ssrc,
|
2016-06-02 16:23:38 -07:00
|
|
|
bool mute,
|
|
|
|
|
const VideoOptions* options,
|
Reland of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #1 id:1 of https://codereview.webrtc.org/2471783002/ )
Reason for revert:
Relanding after known downstream breakages have been fixed.
Original issue's description:
> Revert of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #7 id:120001 of https://codereview.webrtc.org/2383093002/ )
>
> Reason for revert:
> Breaks chrome, see https://build.chromium.org/p/chromium.webrtc.fyi/builders/Mac%20Builder/builds/19019/steps/compile/logs/stdio
>
> Analysis: Chrome uses cricket::VideoFrame, without explicitly including webrtc/media/base/videoframe.h, and breaks when that file is no longer included by any other webrtc headers. Will reland after updating Chrome.
>
> Original issue's description:
> > Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame.
> >
> > Replaced with webrtc::VideoFrame.
> >
> > TBR=mflodman@webrtc.org
> > BUG=webrtc:5682
> >
> > Committed: https://crrev.com/45c8b8940042bd2574c39920804ade8343cefdba
> > Cr-Commit-Position: refs/heads/master@{#14885}
>
> TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5682
>
> Committed: https://crrev.com/7341ab8e2505c9763d208e069bda269018357e7d
> Cr-Commit-Position: refs/heads/master@{#14886}
TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:5682
Review-Url: https://codereview.webrtc.org/2487633002
Cr-Commit-Position: refs/heads/master@{#15039}
2016-11-11 03:55:13 -08:00
|
|
|
rtc::VideoSourceInterface<webrtc::VideoFrame>* source) {
|
2016-06-10 14:17:27 -07:00
|
|
|
return InvokeOnWorker(RTC_FROM_HERE,
|
|
|
|
|
Bind(&VideoMediaChannel::SetVideoSend, media_channel(),
|
2016-06-02 16:23:38 -07:00
|
|
|
ssrc, mute, options, source));
|
2015-09-10 01:57:14 -07:00
|
|
|
}
|
|
|
|
|
|
2016-05-16 11:40:30 -07:00
|
|
|
webrtc::RtpParameters VideoChannel::GetRtpSendParameters(uint32_t ssrc) const {
|
2016-03-16 19:07:43 -07:00
|
|
|
return worker_thread()->Invoke<webrtc::RtpParameters>(
|
2016-06-10 14:17:27 -07:00
|
|
|
RTC_FROM_HERE, Bind(&VideoChannel::GetRtpSendParameters_w, this, ssrc));
|
2016-03-16 19:07:43 -07:00
|
|
|
}
|
|
|
|
|
|
2016-05-16 11:40:30 -07:00
|
|
|
webrtc::RtpParameters VideoChannel::GetRtpSendParameters_w(
|
|
|
|
|
uint32_t ssrc) const {
|
|
|
|
|
return media_channel()->GetRtpSendParameters(ssrc);
|
2016-03-16 19:07:43 -07:00
|
|
|
}
|
|
|
|
|
|
2016-05-16 11:40:30 -07:00
|
|
|
bool VideoChannel::SetRtpSendParameters(
|
|
|
|
|
uint32_t ssrc,
|
|
|
|
|
const webrtc::RtpParameters& parameters) {
|
|
|
|
|
return InvokeOnWorker(
|
2016-06-10 14:17:27 -07:00
|
|
|
RTC_FROM_HERE,
|
2016-05-16 11:40:30 -07:00
|
|
|
Bind(&VideoChannel::SetRtpSendParameters_w, this, ssrc, parameters));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool VideoChannel::SetRtpSendParameters_w(uint32_t ssrc,
|
|
|
|
|
webrtc::RtpParameters parameters) {
|
|
|
|
|
return media_channel()->SetRtpSendParameters(ssrc, parameters);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
webrtc::RtpParameters VideoChannel::GetRtpReceiveParameters(
|
|
|
|
|
uint32_t ssrc) const {
|
|
|
|
|
return worker_thread()->Invoke<webrtc::RtpParameters>(
|
2016-06-10 14:17:27 -07:00
|
|
|
RTC_FROM_HERE,
|
2016-05-16 11:40:30 -07:00
|
|
|
Bind(&VideoChannel::GetRtpReceiveParameters_w, this, ssrc));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
webrtc::RtpParameters VideoChannel::GetRtpReceiveParameters_w(
|
|
|
|
|
uint32_t ssrc) const {
|
|
|
|
|
return media_channel()->GetRtpReceiveParameters(ssrc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool VideoChannel::SetRtpReceiveParameters(
|
|
|
|
|
uint32_t ssrc,
|
|
|
|
|
const webrtc::RtpParameters& parameters) {
|
2016-03-16 19:07:43 -07:00
|
|
|
return InvokeOnWorker(
|
2016-06-10 14:17:27 -07:00
|
|
|
RTC_FROM_HERE,
|
2016-05-16 11:40:30 -07:00
|
|
|
Bind(&VideoChannel::SetRtpReceiveParameters_w, this, ssrc, parameters));
|
2016-03-16 19:07:43 -07:00
|
|
|
}
|
|
|
|
|
|
2016-05-16 11:40:30 -07:00
|
|
|
bool VideoChannel::SetRtpReceiveParameters_w(uint32_t ssrc,
|
|
|
|
|
webrtc::RtpParameters parameters) {
|
|
|
|
|
return media_channel()->SetRtpReceiveParameters(ssrc, parameters);
|
2016-03-16 19:07:43 -07:00
|
|
|
}
|
2016-05-11 19:55:27 +02:00
|
|
|
|
2016-08-25 13:31:14 -07:00
|
|
|
void VideoChannel::UpdateMediaSendRecvState_w() {
|
2013-07-10 00:45:36 +00:00
|
|
|
// Send outgoing data if we're the active call, we have the remote content,
|
|
|
|
|
// and we have had some form of connectivity.
|
2016-08-25 13:31:14 -07:00
|
|
|
bool send = IsReadyToSendMedia_w();
|
2013-07-10 00:45:36 +00:00
|
|
|
if (!media_channel()->SetSend(send)) {
|
|
|
|
|
LOG(LS_ERROR) << "Failed to SetSend on video channel";
|
|
|
|
|
// TODO(gangji): Report error back to server.
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-24 19:20:30 +02:00
|
|
|
LOG(LS_INFO) << "Changing video state, send=" << send;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-03-04 08:54:32 +00:00
|
|
|
bool VideoChannel::GetStats(VideoMediaInfo* stats) {
|
2016-06-10 14:17:27 -07:00
|
|
|
return InvokeOnWorker(RTC_FROM_HERE, Bind(&VideoMediaChannel::GetStats,
|
|
|
|
|
media_channel(), stats));
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VideoChannel::StartMediaMonitor(int cms) {
|
|
|
|
|
media_monitor_.reset(new VideoMediaMonitor(media_channel(), worker_thread(),
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::Thread::Current()));
|
2013-07-10 00:45:36 +00:00
|
|
|
media_monitor_->SignalUpdate.connect(
|
|
|
|
|
this, &VideoChannel::OnMediaMonitorUpdate);
|
|
|
|
|
media_monitor_->Start(cms);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VideoChannel::StopMediaMonitor() {
|
|
|
|
|
if (media_monitor_) {
|
|
|
|
|
media_monitor_->Stop();
|
|
|
|
|
media_monitor_.reset();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ContentInfo* VideoChannel::GetFirstContent(
|
|
|
|
|
const SessionDescription* sdesc) {
|
|
|
|
|
return GetFirstVideoContent(sdesc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content,
|
2014-01-15 23:15:54 +00:00
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc) {
|
2015-12-08 13:25:57 +01:00
|
|
|
TRACE_EVENT0("webrtc", "VideoChannel::SetLocalContent_w");
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(worker_thread() == rtc::Thread::Current());
|
2013-07-10 00:45:36 +00:00
|
|
|
LOG(LS_INFO) << "Setting local video description";
|
|
|
|
|
|
|
|
|
|
const VideoContentDescription* video =
|
|
|
|
|
static_cast<const VideoContentDescription*>(content);
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(video != NULL);
|
2014-01-15 23:15:54 +00:00
|
|
|
if (!video) {
|
|
|
|
|
SafeSetError("Can't find video content in local description.", error_desc);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) {
|
2015-08-07 16:05:34 -07:00
|
|
|
return false;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
VideoRecvParameters recv_params = last_recv_params_;
|
|
|
|
|
RtpParametersFromMediaDescription(video, &recv_params);
|
|
|
|
|
if (!media_channel()->SetRecvParameters(recv_params)) {
|
|
|
|
|
SafeSetError("Failed to set local video description recv parameters.",
|
|
|
|
|
error_desc);
|
|
|
|
|
return false;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
2015-08-07 16:05:34 -07:00
|
|
|
for (const VideoCodec& codec : video->codecs()) {
|
|
|
|
|
bundle_filter()->AddPayloadType(codec.id);
|
|
|
|
|
}
|
|
|
|
|
last_recv_params_ = recv_params;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
// TODO(pthatcher): Move local streams into VideoSendParameters, and
|
|
|
|
|
// only give it to the media channel once we have a remote
|
|
|
|
|
// description too (without a remote description, we won't be able
|
|
|
|
|
// to send them anyway).
|
|
|
|
|
if (!UpdateLocalStreams_w(video->streams(), action, error_desc)) {
|
|
|
|
|
SafeSetError("Failed to set local video description streams.", error_desc);
|
|
|
|
|
return false;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
2015-08-07 16:05:34 -07:00
|
|
|
|
|
|
|
|
set_local_content_direction(content->direction());
|
2016-08-25 13:31:14 -07:00
|
|
|
UpdateMediaSendRecvState_w();
|
2015-08-07 16:05:34 -07:00
|
|
|
return true;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool VideoChannel::SetRemoteContent_w(const MediaContentDescription* content,
|
2014-01-15 23:15:54 +00:00
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc) {
|
2015-12-08 13:25:57 +01:00
|
|
|
TRACE_EVENT0("webrtc", "VideoChannel::SetRemoteContent_w");
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(worker_thread() == rtc::Thread::Current());
|
2013-07-10 00:45:36 +00:00
|
|
|
LOG(LS_INFO) << "Setting remote video description";
|
|
|
|
|
|
|
|
|
|
const VideoContentDescription* video =
|
|
|
|
|
static_cast<const VideoContentDescription*>(content);
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(video != NULL);
|
2014-01-15 23:15:54 +00:00
|
|
|
if (!video) {
|
|
|
|
|
SafeSetError("Can't find video content in remote description.", error_desc);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) {
|
2015-08-07 16:05:34 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
VideoSendParameters send_params = last_send_params_;
|
|
|
|
|
RtpSendParametersFromMediaDescription(video, &send_params);
|
|
|
|
|
if (video->conference_mode()) {
|
2016-02-17 05:25:36 -08:00
|
|
|
send_params.conference_mode = true;
|
2015-08-07 16:05:34 -07:00
|
|
|
}
|
2016-03-16 19:07:43 -07:00
|
|
|
|
|
|
|
|
bool parameters_applied = media_channel()->SetSendParameters(send_params);
|
|
|
|
|
|
|
|
|
|
if (!parameters_applied) {
|
2015-08-07 16:05:34 -07:00
|
|
|
SafeSetError("Failed to set remote video description send parameters.",
|
|
|
|
|
error_desc);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
last_send_params_ = send_params;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
// TODO(pthatcher): Move remote streams into VideoRecvParameters,
|
|
|
|
|
// and only give it to the media channel once we have a local
|
|
|
|
|
// description too (without a local description, we won't be able to
|
|
|
|
|
// recv them anyway).
|
|
|
|
|
if (!UpdateRemoteStreams_w(video->streams(), action, error_desc)) {
|
|
|
|
|
SafeSetError("Failed to set remote video description streams.", error_desc);
|
|
|
|
|
return false;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
if (video->rtp_header_extensions_set()) {
|
2016-05-11 19:55:27 +02:00
|
|
|
MaybeCacheRtpAbsSendTimeHeaderExtension_w(video->rtp_header_extensions());
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
2015-08-07 16:05:34 -07:00
|
|
|
|
|
|
|
|
set_remote_content_direction(content->direction());
|
2016-08-25 13:31:14 -07:00
|
|
|
UpdateMediaSendRecvState_w();
|
2015-08-07 16:05:34 -07:00
|
|
|
return true;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
void VideoChannel::OnMessage(rtc::Message *pmsg) {
|
2013-07-10 00:45:36 +00:00
|
|
|
switch (pmsg->message_id) {
|
|
|
|
|
case MSG_CHANNEL_ERROR: {
|
|
|
|
|
const VideoChannelErrorMessageData* data =
|
|
|
|
|
static_cast<VideoChannelErrorMessageData*>(pmsg->pdata);
|
|
|
|
|
delete data;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
BaseChannel::OnMessage(pmsg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VideoChannel::OnConnectionMonitorUpdate(
|
2015-03-13 18:25:21 +00:00
|
|
|
ConnectionMonitor* monitor, const std::vector<ConnectionInfo> &infos) {
|
2013-07-10 00:45:36 +00:00
|
|
|
SignalConnectionMonitor(this, infos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO(pthatcher): Look into removing duplicate code between
|
|
|
|
|
// audio, video, and data, perhaps by using templates.
|
|
|
|
|
void VideoChannel::OnMediaMonitorUpdate(
|
|
|
|
|
VideoMediaChannel* media_channel, const VideoMediaInfo &info) {
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(media_channel == this->media_channel());
|
2013-07-10 00:45:36 +00:00
|
|
|
SignalMediaMonitor(this, info);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
void VideoChannel::GetSrtpCryptoSuites_n(
|
|
|
|
|
std::vector<int>* crypto_suites) const {
|
2016-08-04 05:20:32 -07:00
|
|
|
GetSupportedVideoCryptoSuites(crypto_options(), crypto_suites);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
DataChannel::DataChannel(rtc::Thread* worker_thread,
|
|
|
|
|
rtc::Thread* network_thread,
|
2013-07-10 00:45:36 +00:00
|
|
|
DataMediaChannel* media_channel,
|
2015-09-23 11:50:27 -07:00
|
|
|
TransportController* transport_controller,
|
2013-07-10 00:45:36 +00:00
|
|
|
const std::string& content_name,
|
|
|
|
|
bool rtcp)
|
2016-05-11 19:55:27 +02:00
|
|
|
: BaseChannel(worker_thread,
|
|
|
|
|
network_thread,
|
2015-09-23 11:50:27 -07:00
|
|
|
media_channel,
|
|
|
|
|
transport_controller,
|
|
|
|
|
content_name,
|
|
|
|
|
rtcp),
|
2013-11-04 18:41:34 +00:00
|
|
|
data_channel_type_(cricket::DCT_NONE),
|
2015-09-23 11:50:27 -07:00
|
|
|
ready_to_send_data_(false) {}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
DataChannel::~DataChannel() {
|
2016-03-08 14:24:13 -08:00
|
|
|
TRACE_EVENT0("webrtc", "DataChannel::~DataChannel");
|
2013-07-10 00:45:36 +00:00
|
|
|
StopMediaMonitor();
|
|
|
|
|
// this can't be done in the base class, since it calls a virtual
|
|
|
|
|
DisableMedia_w();
|
2013-10-07 23:32:02 +00:00
|
|
|
|
|
|
|
|
Deinit();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-05-17 17:49:52 -07:00
|
|
|
bool DataChannel::Init_w(const std::string* bundle_transport_name) {
|
|
|
|
|
if (!BaseChannel::Init_w(bundle_transport_name)) {
|
2013-07-10 00:45:36 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
media_channel()->SignalDataReceived.connect(
|
|
|
|
|
this, &DataChannel::OnDataReceived);
|
2013-08-01 00:00:07 +00:00
|
|
|
media_channel()->SignalReadyToSend.connect(
|
|
|
|
|
this, &DataChannel::OnDataChannelReadyToSend);
|
2014-05-29 22:54:24 +00:00
|
|
|
media_channel()->SignalStreamClosedRemotely.connect(
|
|
|
|
|
this, &DataChannel::OnStreamClosedRemotely);
|
2013-07-10 00:45:36 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DataChannel::SendData(const SendDataParams& params,
|
2016-03-20 06:15:43 -07:00
|
|
|
const rtc::CopyOnWriteBuffer& payload,
|
2013-07-10 00:45:36 +00:00
|
|
|
SendDataResult* result) {
|
2016-06-10 14:17:27 -07:00
|
|
|
return InvokeOnWorker(
|
|
|
|
|
RTC_FROM_HERE, Bind(&DataMediaChannel::SendData, media_channel(), params,
|
|
|
|
|
payload, result));
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ContentInfo* DataChannel::GetFirstContent(
|
|
|
|
|
const SessionDescription* sdesc) {
|
|
|
|
|
return GetFirstDataContent(sdesc);
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-20 06:15:43 -07:00
|
|
|
bool DataChannel::WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet) {
|
2013-07-10 00:45:36 +00:00
|
|
|
if (data_channel_type_ == DCT_SCTP) {
|
|
|
|
|
// TODO(pthatcher): Do this in a more robust way by checking for
|
|
|
|
|
// SCTP or DTLS.
|
2015-03-24 09:19:06 +00:00
|
|
|
return !IsRtpPacket(packet->data(), packet->size());
|
2013-07-10 00:45:36 +00:00
|
|
|
} else if (data_channel_type_ == DCT_RTP) {
|
|
|
|
|
return BaseChannel::WantsPacket(rtcp, packet);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-15 23:15:54 +00:00
|
|
|
bool DataChannel::SetDataChannelType(DataChannelType new_data_channel_type,
|
|
|
|
|
std::string* error_desc) {
|
2013-07-10 00:45:36 +00:00
|
|
|
// It hasn't been set before, so set it now.
|
|
|
|
|
if (data_channel_type_ == DCT_NONE) {
|
|
|
|
|
data_channel_type_ = new_data_channel_type;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// It's been set before, but doesn't match. That's bad.
|
|
|
|
|
if (data_channel_type_ != new_data_channel_type) {
|
2014-01-15 23:15:54 +00:00
|
|
|
std::ostringstream desc;
|
|
|
|
|
desc << "Data channel type mismatch."
|
|
|
|
|
<< " Expected " << data_channel_type_
|
|
|
|
|
<< " Got " << new_data_channel_type;
|
|
|
|
|
SafeSetError(desc.str(), error_desc);
|
2013-07-10 00:45:36 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// It's hasn't changed. Nothing to do.
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DataChannel::SetDataChannelTypeFromContent(
|
2014-01-15 23:15:54 +00:00
|
|
|
const DataContentDescription* content,
|
|
|
|
|
std::string* error_desc) {
|
2013-07-10 00:45:36 +00:00
|
|
|
bool is_sctp = ((content->protocol() == kMediaProtocolSctp) ||
|
|
|
|
|
(content->protocol() == kMediaProtocolDtlsSctp));
|
|
|
|
|
DataChannelType data_channel_type = is_sctp ? DCT_SCTP : DCT_RTP;
|
2014-01-15 23:15:54 +00:00
|
|
|
return SetDataChannelType(data_channel_type, error_desc);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DataChannel::SetLocalContent_w(const MediaContentDescription* content,
|
2014-01-15 23:15:54 +00:00
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc) {
|
2015-12-08 13:25:57 +01:00
|
|
|
TRACE_EVENT0("webrtc", "DataChannel::SetLocalContent_w");
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(worker_thread() == rtc::Thread::Current());
|
2013-07-10 00:45:36 +00:00
|
|
|
LOG(LS_INFO) << "Setting local data description";
|
|
|
|
|
|
|
|
|
|
const DataContentDescription* data =
|
|
|
|
|
static_cast<const DataContentDescription*>(content);
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(data != NULL);
|
2014-01-15 23:15:54 +00:00
|
|
|
if (!data) {
|
|
|
|
|
SafeSetError("Can't find data content in local description.", error_desc);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2014-01-15 23:15:54 +00:00
|
|
|
if (!SetDataChannelTypeFromContent(data, error_desc)) {
|
2013-07-10 00:45:36 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
if (data_channel_type_ == DCT_RTP) {
|
2016-05-11 19:55:27 +02:00
|
|
|
if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) {
|
2015-08-07 16:05:34 -07:00
|
|
|
return false;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
// FYI: We send the SCTP port number (not to be confused with the
|
|
|
|
|
// underlying UDP port number) as a codec parameter. So even SCTP
|
|
|
|
|
// data channels need codecs.
|
|
|
|
|
DataRecvParameters recv_params = last_recv_params_;
|
|
|
|
|
RtpParametersFromMediaDescription(data, &recv_params);
|
|
|
|
|
if (!media_channel()->SetRecvParameters(recv_params)) {
|
|
|
|
|
SafeSetError("Failed to set remote data description recv parameters.",
|
|
|
|
|
error_desc);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (data_channel_type_ == DCT_RTP) {
|
|
|
|
|
for (const DataCodec& codec : data->codecs()) {
|
|
|
|
|
bundle_filter()->AddPayloadType(codec.id);
|
2014-05-05 20:18:08 +00:00
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
2015-08-07 16:05:34 -07:00
|
|
|
last_recv_params_ = recv_params;
|
|
|
|
|
|
|
|
|
|
// TODO(pthatcher): Move local streams into DataSendParameters, and
|
|
|
|
|
// only give it to the media channel once we have a remote
|
|
|
|
|
// description too (without a remote description, we won't be able
|
|
|
|
|
// to send them anyway).
|
|
|
|
|
if (!UpdateLocalStreams_w(data->streams(), action, error_desc)) {
|
|
|
|
|
SafeSetError("Failed to set local data description streams.", error_desc);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set_local_content_direction(content->direction());
|
2016-08-25 13:31:14 -07:00
|
|
|
UpdateMediaSendRecvState_w();
|
2015-08-07 16:05:34 -07:00
|
|
|
return true;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DataChannel::SetRemoteContent_w(const MediaContentDescription* content,
|
2014-01-15 23:15:54 +00:00
|
|
|
ContentAction action,
|
|
|
|
|
std::string* error_desc) {
|
2015-12-08 13:25:57 +01:00
|
|
|
TRACE_EVENT0("webrtc", "DataChannel::SetRemoteContent_w");
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(worker_thread() == rtc::Thread::Current());
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
const DataContentDescription* data =
|
|
|
|
|
static_cast<const DataContentDescription*>(content);
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(data != NULL);
|
2014-01-15 23:15:54 +00:00
|
|
|
if (!data) {
|
|
|
|
|
SafeSetError("Can't find data content in remote description.", error_desc);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
// If the remote data doesn't have codecs and isn't an update, it
|
|
|
|
|
// must be empty, so ignore it.
|
|
|
|
|
if (!data->has_codecs() && action != CA_UPDATE) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-15 23:15:54 +00:00
|
|
|
if (!SetDataChannelTypeFromContent(data, error_desc)) {
|
2013-07-10 00:45:36 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
LOG(LS_INFO) << "Setting remote data description";
|
|
|
|
|
if (data_channel_type_ == DCT_RTP &&
|
2016-05-11 19:55:27 +02:00
|
|
|
!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) {
|
2015-08-07 16:05:34 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
DataSendParameters send_params = last_send_params_;
|
|
|
|
|
RtpSendParametersFromMediaDescription<DataCodec>(data, &send_params);
|
|
|
|
|
if (!media_channel()->SetSendParameters(send_params)) {
|
|
|
|
|
SafeSetError("Failed to set remote data description send parameters.",
|
|
|
|
|
error_desc);
|
|
|
|
|
return false;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
2015-08-07 16:05:34 -07:00
|
|
|
last_send_params_ = send_params;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
// TODO(pthatcher): Move remote streams into DataRecvParameters,
|
|
|
|
|
// and only give it to the media channel once we have a local
|
|
|
|
|
// description too (without a local description, we won't be able to
|
|
|
|
|
// recv them anyway).
|
|
|
|
|
if (!UpdateRemoteStreams_w(data->streams(), action, error_desc)) {
|
|
|
|
|
SafeSetError("Failed to set remote data description streams.",
|
|
|
|
|
error_desc);
|
|
|
|
|
return false;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
2015-08-07 16:05:34 -07:00
|
|
|
|
|
|
|
|
set_remote_content_direction(content->direction());
|
2016-08-25 13:31:14 -07:00
|
|
|
UpdateMediaSendRecvState_w();
|
2015-08-07 16:05:34 -07:00
|
|
|
return true;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-08-25 13:31:14 -07:00
|
|
|
void DataChannel::UpdateMediaSendRecvState_w() {
|
2013-07-10 00:45:36 +00:00
|
|
|
// Render incoming data if we're the active call, and we have the local
|
|
|
|
|
// content. We receive data on the default channel and multiplexed streams.
|
2016-08-25 13:31:14 -07:00
|
|
|
bool recv = IsReadyToReceiveMedia_w();
|
2013-07-10 00:45:36 +00:00
|
|
|
if (!media_channel()->SetReceive(recv)) {
|
|
|
|
|
LOG(LS_ERROR) << "Failed to SetReceive on data channel";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Send outgoing data if we're the active call, we have the remote content,
|
|
|
|
|
// and we have had some form of connectivity.
|
2016-08-25 13:31:14 -07:00
|
|
|
bool send = IsReadyToSendMedia_w();
|
2013-07-10 00:45:36 +00:00
|
|
|
if (!media_channel()->SetSend(send)) {
|
|
|
|
|
LOG(LS_ERROR) << "Failed to SetSend on data channel";
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-07 19:03:26 +00:00
|
|
|
// Trigger SignalReadyToSendData asynchronously.
|
|
|
|
|
OnDataChannelReadyToSend(send);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
LOG(LS_INFO) << "Changing data state, recv=" << recv << " send=" << send;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
void DataChannel::OnMessage(rtc::Message *pmsg) {
|
2013-07-10 00:45:36 +00:00
|
|
|
switch (pmsg->message_id) {
|
|
|
|
|
case MSG_READYTOSENDDATA: {
|
2013-08-01 00:00:07 +00:00
|
|
|
DataChannelReadyToSendMessageData* data =
|
|
|
|
|
static_cast<DataChannelReadyToSendMessageData*>(pmsg->pdata);
|
2013-11-04 18:41:34 +00:00
|
|
|
ready_to_send_data_ = data->data();
|
|
|
|
|
SignalReadyToSendData(ready_to_send_data_);
|
2013-07-10 00:45:36 +00:00
|
|
|
delete data;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case MSG_DATARECEIVED: {
|
|
|
|
|
DataReceivedMessageData* data =
|
|
|
|
|
static_cast<DataReceivedMessageData*>(pmsg->pdata);
|
|
|
|
|
SignalDataReceived(this, data->params, data->payload);
|
|
|
|
|
delete data;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case MSG_CHANNEL_ERROR: {
|
|
|
|
|
const DataChannelErrorMessageData* data =
|
|
|
|
|
static_cast<DataChannelErrorMessageData*>(pmsg->pdata);
|
|
|
|
|
delete data;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-05-29 22:54:24 +00:00
|
|
|
case MSG_STREAMCLOSEDREMOTELY: {
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
rtc::TypedMessageData<uint32_t>* data =
|
|
|
|
|
static_cast<rtc::TypedMessageData<uint32_t>*>(pmsg->pdata);
|
2014-05-29 22:54:24 +00:00
|
|
|
SignalStreamClosedRemotely(data->data());
|
|
|
|
|
delete data;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
default:
|
|
|
|
|
BaseChannel::OnMessage(pmsg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DataChannel::OnConnectionMonitorUpdate(
|
2015-03-13 18:25:21 +00:00
|
|
|
ConnectionMonitor* monitor, const std::vector<ConnectionInfo>& infos) {
|
2013-07-10 00:45:36 +00:00
|
|
|
SignalConnectionMonitor(this, infos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DataChannel::StartMediaMonitor(int cms) {
|
|
|
|
|
media_monitor_.reset(new DataMediaMonitor(media_channel(), worker_thread(),
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::Thread::Current()));
|
2013-07-10 00:45:36 +00:00
|
|
|
media_monitor_->SignalUpdate.connect(
|
|
|
|
|
this, &DataChannel::OnMediaMonitorUpdate);
|
|
|
|
|
media_monitor_->Start(cms);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DataChannel::StopMediaMonitor() {
|
|
|
|
|
if (media_monitor_) {
|
|
|
|
|
media_monitor_->Stop();
|
|
|
|
|
media_monitor_->SignalUpdate.disconnect(this);
|
|
|
|
|
media_monitor_.reset();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DataChannel::OnMediaMonitorUpdate(
|
|
|
|
|
DataMediaChannel* media_channel, const DataMediaInfo& info) {
|
2016-08-25 13:31:14 -07:00
|
|
|
RTC_DCHECK(media_channel == this->media_channel());
|
2013-07-10 00:45:36 +00:00
|
|
|
SignalMediaMonitor(this, info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DataChannel::OnDataReceived(
|
|
|
|
|
const ReceiveDataParams& params, const char* data, size_t len) {
|
|
|
|
|
DataReceivedMessageData* msg = new DataReceivedMessageData(
|
|
|
|
|
params, data, len);
|
2016-06-10 14:17:27 -07:00
|
|
|
signaling_thread()->Post(RTC_FROM_HERE, this, MSG_DATARECEIVED, msg);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
void DataChannel::OnDataChannelError(uint32_t ssrc,
|
|
|
|
|
DataMediaChannel::Error err) {
|
2013-07-10 00:45:36 +00:00
|
|
|
DataChannelErrorMessageData* data = new DataChannelErrorMessageData(
|
|
|
|
|
ssrc, err);
|
2016-06-10 14:17:27 -07:00
|
|
|
signaling_thread()->Post(RTC_FROM_HERE, this, MSG_CHANNEL_ERROR, data);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2013-08-01 00:00:07 +00:00
|
|
|
void DataChannel::OnDataChannelReadyToSend(bool writable) {
|
|
|
|
|
// This is usded for congestion control to indicate that the stream is ready
|
|
|
|
|
// to send by the MediaChannel, as opposed to OnReadyToSend, which indicates
|
|
|
|
|
// that the transport channel is ready.
|
2016-06-10 14:17:27 -07:00
|
|
|
signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA,
|
2013-08-01 00:00:07 +00:00
|
|
|
new DataChannelReadyToSendMessageData(writable));
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
void DataChannel::GetSrtpCryptoSuites_n(std::vector<int>* crypto_suites) const {
|
2016-08-04 05:20:32 -07:00
|
|
|
GetSupportedDataCryptoSuites(crypto_options(), crypto_suites);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-05-11 19:55:27 +02:00
|
|
|
bool DataChannel::ShouldSetupDtlsSrtp_n() const {
|
|
|
|
|
return data_channel_type_ == DCT_RTP && BaseChannel::ShouldSetupDtlsSrtp_n();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
void DataChannel::OnStreamClosedRemotely(uint32_t sid) {
|
|
|
|
|
rtc::TypedMessageData<uint32_t>* message =
|
|
|
|
|
new rtc::TypedMessageData<uint32_t>(sid);
|
2016-06-10 14:17:27 -07:00
|
|
|
signaling_thread()->Post(RTC_FROM_HERE, this, MSG_STREAMCLOSEDREMOTELY,
|
|
|
|
|
message);
|
2014-05-29 22:54:24 +00:00
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
} // namespace cricket
|