2013-07-10 00:45:36 +00:00
|
|
|
/*
|
|
|
|
|
* libjingle
|
|
|
|
|
* Copyright 2004 Google Inc.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
|
*
|
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
|
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
|
|
|
|
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
|
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
|
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "talk/session/media/channel.h"
|
|
|
|
|
|
2014-08-07 17:18:00 +00:00
|
|
|
#include "talk/media/base/constants.h"
|
|
|
|
|
#include "talk/media/base/rtputils.h"
|
2014-10-28 22:20:11 +00:00
|
|
|
#include "webrtc/p2p/base/transportchannel.h"
|
2014-08-07 17:18:00 +00:00
|
|
|
#include "talk/session/media/channelmanager.h"
|
2014-08-07 22:09:08 +00:00
|
|
|
#include "webrtc/base/bind.h"
|
|
|
|
|
#include "webrtc/base/buffer.h"
|
|
|
|
|
#include "webrtc/base/byteorder.h"
|
|
|
|
|
#include "webrtc/base/common.h"
|
|
|
|
|
#include "webrtc/base/dscp.h"
|
|
|
|
|
#include "webrtc/base/logging.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
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
enum {
|
2014-02-07 19:03:26 +00:00
|
|
|
MSG_EARLYMEDIATIMEOUT = 1,
|
2013-07-10 00:45:36 +00:00
|
|
|
MSG_SCREENCASTWINDOWEVENT,
|
|
|
|
|
MSG_RTPPACKET,
|
|
|
|
|
MSG_RTCPPACKET,
|
|
|
|
|
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 PacketMessageData : public rtc::MessageData {
|
|
|
|
|
rtc::Buffer packet;
|
2015-10-15 07:26:07 -07:00
|
|
|
rtc::PacketOptions options;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
struct ScreencastEventMessageData : 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
|
|
|
ScreencastEventMessageData(uint32_t s, rtc::WindowEvent we)
|
|
|
|
|
: ssrc(s), event(we) {}
|
|
|
|
|
uint32_t ssrc;
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::WindowEvent event;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
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;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2014-02-07 19:03:26 +00:00
|
|
|
struct VideoChannel::ScreencastDetailsData {
|
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
|
|
|
explicit ScreencastDetailsData(uint32_t s)
|
|
|
|
|
: ssrc(s), fps(0), screencast_max_pixels(0) {}
|
|
|
|
|
uint32_t ssrc;
|
2013-08-30 21:24:16 +00:00
|
|
|
int fps;
|
|
|
|
|
int screencast_max_pixels;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const char* PacketType(bool rtcp) {
|
|
|
|
|
return (!rtcp) ? "RTP" : "RTCP";
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
static bool ValidPacket(bool rtcp, const rtc::Buffer* 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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class Codec, class Options>
|
|
|
|
|
void RtpSendParametersFromMediaDescription(
|
|
|
|
|
const MediaContentDescriptionImpl<Codec>* desc,
|
|
|
|
|
RtpSendParameters<Codec, Options>* send_params) {
|
|
|
|
|
RtpParametersFromMediaDescription(desc, send_params);
|
|
|
|
|
send_params->max_bandwidth_bps = desc->bandwidth();
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
BaseChannel::BaseChannel(rtc::Thread* thread,
|
2015-09-23 11:50:27 -07:00
|
|
|
MediaChannel* media_channel,
|
|
|
|
|
TransportController* transport_controller,
|
|
|
|
|
const std::string& content_name,
|
|
|
|
|
bool rtcp)
|
2013-07-10 00:45:36 +00:00
|
|
|
: worker_thread_(thread),
|
2015-09-23 11:50:27 -07:00
|
|
|
transport_controller_(transport_controller),
|
2013-07-10 00:45:36 +00:00
|
|
|
media_channel_(media_channel),
|
|
|
|
|
content_name_(content_name),
|
2015-09-23 11:50:27 -07:00
|
|
|
rtcp_transport_enabled_(rtcp),
|
|
|
|
|
transport_channel_(nullptr),
|
|
|
|
|
rtcp_transport_channel_(nullptr),
|
2013-07-10 00:45:36 +00:00
|
|
|
enabled_(false),
|
|
|
|
|
writable_(false),
|
|
|
|
|
rtp_ready_to_send_(false),
|
|
|
|
|
rtcp_ready_to_send_(false),
|
|
|
|
|
was_ever_writable_(false),
|
|
|
|
|
local_content_direction_(MD_INACTIVE),
|
|
|
|
|
remote_content_direction_(MD_INACTIVE),
|
|
|
|
|
has_received_packet_(false),
|
|
|
|
|
dtls_keyed_(false),
|
2014-02-21 23:43:24 +00:00
|
|
|
secure_required_(false),
|
|
|
|
|
rtp_abs_sendtime_extn_id_(-1) {
|
2014-07-29 17:36:52 +00:00
|
|
|
ASSERT(worker_thread_ == rtc::Thread::Current());
|
2013-07-10 00:45:36 +00:00
|
|
|
LOG(LS_INFO) << "Created channel for " << content_name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BaseChannel::~BaseChannel() {
|
2014-07-29 17:36:52 +00:00
|
|
|
ASSERT(worker_thread_ == rtc::Thread::Current());
|
2013-10-07 23:32:02 +00:00
|
|
|
Deinit();
|
2013-07-10 00:45:36 +00:00
|
|
|
StopConnectionMonitor();
|
|
|
|
|
FlushRtcpMessages(); // Send any outstanding RTCP packets.
|
2014-02-07 19:03:26 +00:00
|
|
|
worker_thread_->Clear(this); // eats any outstanding messages or packets
|
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_;
|
2015-09-23 11:50:27 -07:00
|
|
|
// Note that we don't just call set_transport_channel(nullptr) because that
|
|
|
|
|
// would call a pure virtual method which we can't do from a destructor.
|
|
|
|
|
if (transport_channel_) {
|
|
|
|
|
DisconnectFromTransportChannel(transport_channel_);
|
|
|
|
|
transport_controller_->DestroyTransportChannel_w(
|
|
|
|
|
transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTP);
|
|
|
|
|
}
|
|
|
|
|
if (rtcp_transport_channel_) {
|
|
|
|
|
DisconnectFromTransportChannel(rtcp_transport_channel_);
|
|
|
|
|
transport_controller_->DestroyTransportChannel_w(
|
|
|
|
|
transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
LOG(LS_INFO) << "Destroyed channel";
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-16 20:19:12 +00:00
|
|
|
bool BaseChannel::Init() {
|
2015-09-23 11:50:27 -07:00
|
|
|
if (!SetTransport(content_name())) {
|
2013-07-10 00:45:36 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2015-03-16 20:19:12 +00:00
|
|
|
|
2015-11-18 19:41:53 -08:00
|
|
|
if (!SetDtlsSrtpCryptoSuites(transport_channel(), false)) {
|
2013-07-10 00:45:36 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2015-09-23 11:50:27 -07:00
|
|
|
if (rtcp_transport_enabled() &&
|
2015-11-18 19:41:53 -08:00
|
|
|
!SetDtlsSrtpCryptoSuites(rtcp_transport_channel(), true)) {
|
2013-07-10 00:45:36 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-31 15:40:38 +00:00
|
|
|
// Both RTP and RTCP channels are set, we can call SetInterface on
|
|
|
|
|
// media channel and it can set network options.
|
|
|
|
|
media_channel_->SetInterface(this);
|
2013-07-10 00:45:36 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-07 23:32:02 +00:00
|
|
|
void BaseChannel::Deinit() {
|
|
|
|
|
media_channel_->SetInterface(NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-23 11:50:27 -07:00
|
|
|
bool BaseChannel::SetTransport(const std::string& transport_name) {
|
|
|
|
|
return worker_thread_->Invoke<bool>(
|
|
|
|
|
Bind(&BaseChannel::SetTransport_w, this, transport_name));
|
2015-03-16 20:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
2015-09-23 11:50:27 -07:00
|
|
|
bool BaseChannel::SetTransport_w(const std::string& transport_name) {
|
2015-03-16 20:19:12 +00:00
|
|
|
ASSERT(worker_thread_ == rtc::Thread::Current());
|
|
|
|
|
|
2015-09-23 11:50:27 -07:00
|
|
|
if (transport_name == transport_name_) {
|
|
|
|
|
// Nothing to do if transport name isn't changing
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set_transport_channel(transport_controller_->CreateTransportChannel_w(
|
|
|
|
|
transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP));
|
2015-03-16 20:19:12 +00:00
|
|
|
if (!transport_channel()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-09-23 11:50:27 -07:00
|
|
|
if (rtcp_transport_enabled()) {
|
|
|
|
|
LOG(LS_INFO) << "Create RTCP TransportChannel for " << content_name()
|
|
|
|
|
<< " on " << transport_name << " transport ";
|
|
|
|
|
set_rtcp_transport_channel(transport_controller_->CreateTransportChannel_w(
|
|
|
|
|
transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP));
|
2015-03-16 20:19:12 +00:00
|
|
|
if (!rtcp_transport_channel()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-23 11:50:27 -07:00
|
|
|
transport_name_ = transport_name;
|
2015-03-16 20:19:12 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::set_transport_channel(TransportChannel* new_tc) {
|
|
|
|
|
ASSERT(worker_thread_ == rtc::Thread::Current());
|
|
|
|
|
|
|
|
|
|
TransportChannel* old_tc = transport_channel_;
|
2015-09-23 11:50:27 -07:00
|
|
|
if (!old_tc && !new_tc) {
|
|
|
|
|
// Nothing to do
|
2015-03-16 20:19:12 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2015-09-23 11:50:27 -07:00
|
|
|
ASSERT(old_tc != new_tc);
|
|
|
|
|
|
2015-03-16 20:19:12 +00:00
|
|
|
if (old_tc) {
|
|
|
|
|
DisconnectFromTransportChannel(old_tc);
|
2015-09-23 11:50:27 -07:00
|
|
|
transport_controller_->DestroyTransportChannel_w(
|
|
|
|
|
transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTP);
|
2015-03-16 20:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
transport_channel_ = new_tc;
|
|
|
|
|
|
|
|
|
|
if (new_tc) {
|
|
|
|
|
ConnectToTransportChannel(new_tc);
|
2015-09-23 11:50:27 -07:00
|
|
|
for (const auto& pair : socket_options_) {
|
|
|
|
|
new_tc->SetOption(pair.first, pair.second);
|
|
|
|
|
}
|
2015-03-16 20:19:12 +00:00
|
|
|
}
|
2015-09-23 11:50:27 -07:00
|
|
|
|
|
|
|
|
// Update aggregate writable/ready-to-send state between RTP and RTCP upon
|
|
|
|
|
// setting new channel
|
|
|
|
|
UpdateWritableState_w();
|
|
|
|
|
SetReadyToSend(false, new_tc && new_tc->writable());
|
2015-03-16 20:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::set_rtcp_transport_channel(TransportChannel* new_tc) {
|
|
|
|
|
ASSERT(worker_thread_ == rtc::Thread::Current());
|
|
|
|
|
|
|
|
|
|
TransportChannel* old_tc = rtcp_transport_channel_;
|
2015-09-23 11:50:27 -07:00
|
|
|
if (!old_tc && !new_tc) {
|
|
|
|
|
// Nothing to do
|
2015-03-16 20:19:12 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2015-09-23 11:50:27 -07:00
|
|
|
ASSERT(old_tc != new_tc);
|
|
|
|
|
|
2015-03-16 20:19:12 +00:00
|
|
|
if (old_tc) {
|
|
|
|
|
DisconnectFromTransportChannel(old_tc);
|
2015-09-23 11:50:27 -07:00
|
|
|
transport_controller_->DestroyTransportChannel_w(
|
|
|
|
|
transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
|
2015-03-16 20:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rtcp_transport_channel_ = new_tc;
|
|
|
|
|
|
|
|
|
|
if (new_tc) {
|
|
|
|
|
ConnectToTransportChannel(new_tc);
|
2015-09-23 11:50:27 -07:00
|
|
|
for (const auto& pair : rtcp_socket_options_) {
|
|
|
|
|
new_tc->SetOption(pair.first, pair.second);
|
|
|
|
|
}
|
2015-03-16 20:19:12 +00:00
|
|
|
}
|
2015-09-23 11:50:27 -07:00
|
|
|
|
|
|
|
|
// Update aggregate writable/ready-to-send state between RTP and RTCP upon
|
|
|
|
|
// setting new channel
|
|
|
|
|
UpdateWritableState_w();
|
|
|
|
|
SetReadyToSend(true, new_tc && new_tc->writable());
|
2015-03-16 20:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::ConnectToTransportChannel(TransportChannel* tc) {
|
|
|
|
|
ASSERT(worker_thread_ == rtc::Thread::Current());
|
|
|
|
|
|
|
|
|
|
tc->SignalWritableState.connect(this, &BaseChannel::OnWritableState);
|
|
|
|
|
tc->SignalReadPacket.connect(this, &BaseChannel::OnChannelRead);
|
|
|
|
|
tc->SignalReadyToSend.connect(this, &BaseChannel::OnReadyToSend);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::DisconnectFromTransportChannel(TransportChannel* tc) {
|
|
|
|
|
ASSERT(worker_thread_ == rtc::Thread::Current());
|
|
|
|
|
|
|
|
|
|
tc->SignalWritableState.disconnect(this);
|
|
|
|
|
tc->SignalReadPacket.disconnect(this);
|
|
|
|
|
tc->SignalReadyToSend.disconnect(this);
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
bool BaseChannel::Enable(bool enable) {
|
2014-02-07 19:03:26 +00:00
|
|
|
worker_thread_->Invoke<void>(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) {
|
2014-02-07 19:03:26 +00:00
|
|
|
return InvokeOnWorker(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) {
|
2014-02-07 19:03:26 +00:00
|
|
|
return InvokeOnWorker(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(
|
|
|
|
|
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) {
|
2014-02-07 19:03:26 +00:00
|
|
|
return InvokeOnWorker(
|
|
|
|
|
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) {
|
2014-02-07 19:03:26 +00:00
|
|
|
return InvokeOnWorker(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) {
|
2014-02-07 19:03:26 +00:00
|
|
|
return InvokeOnWorker(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.
|
|
|
|
|
connection_monitor_.reset(new ConnectionMonitor(
|
|
|
|
|
this, worker_thread(), rtc::Thread::Current()));
|
|
|
|
|
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) {
|
|
|
|
|
ASSERT(worker_thread_ == rtc::Thread::Current());
|
|
|
|
|
return transport_channel_->GetStats(infos);
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
bool BaseChannel::IsReadyToReceive() const {
|
|
|
|
|
// Receive data if we are enabled and have local content,
|
|
|
|
|
return enabled() && IsReceiveContentDirection(local_content_direction_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BaseChannel::IsReadyToSend() const {
|
|
|
|
|
// Send outgoing data if we are enabled, have local and remote content,
|
|
|
|
|
// and we have had some form of connectivity.
|
2015-12-05 09:55:44 -08:00
|
|
|
return enabled() &&
|
|
|
|
|
IsReceiveContentDirection(remote_content_direction_) &&
|
2013-07-10 00:45:36 +00:00
|
|
|
IsSendContentDirection(local_content_direction_) &&
|
2015-12-05 09:55:44 -08:00
|
|
|
was_ever_writable();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
bool BaseChannel::SendPacket(rtc::Buffer* 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
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
bool BaseChannel::SendRtcp(rtc::Buffer* 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) {
|
2013-12-11 18:25:07 +00:00
|
|
|
TransportChannel* channel = NULL;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::OnWritableState(TransportChannel* channel) {
|
|
|
|
|
ASSERT(channel == transport_channel_ || channel == rtcp_transport_channel_);
|
2015-09-23 11:50:27 -07:00
|
|
|
UpdateWritableState_w();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::OnChannelRead(TransportChannel* channel,
|
2013-12-13 00:21:03 +00:00
|
|
|
const char* data, size_t len,
|
2014-07-29 17:36:52 +00:00
|
|
|
const rtc::PacketTime& packet_time,
|
2013-12-13 00:21:03 +00:00
|
|
|
int flags) {
|
2013-07-10 00:45:36 +00:00
|
|
|
// OnChannelRead gets called from P2PSocket; now pass data to MediaEngine
|
2014-07-29 17:36:52 +00:00
|
|
|
ASSERT(worker_thread_ == rtc::Thread::Current());
|
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.
|
|
|
|
|
bool rtcp = PacketIsRtcp(channel, data, len);
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::Buffer packet(data, len);
|
2013-12-13 00:21:03 +00:00
|
|
|
HandlePacket(rtcp, &packet, packet_time);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::OnReadyToSend(TransportChannel* channel) {
|
2015-09-23 11:50:27 -07:00
|
|
|
ASSERT(channel == transport_channel_ || channel == rtcp_transport_channel_);
|
|
|
|
|
SetReadyToSend(channel == rtcp_transport_channel_, true);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-09-23 11:50:27 -07:00
|
|
|
void BaseChannel::SetReadyToSend(bool rtcp, bool ready) {
|
|
|
|
|
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
|
|
|
|
2015-09-23 11:50:27 -07:00
|
|
|
if (rtp_ready_to_send_ &&
|
|
|
|
|
// In the case of rtcp mux |rtcp_transport_channel_| will be null.
|
|
|
|
|
(rtcp_ready_to_send_ || !rtcp_transport_channel_)) {
|
2015-09-23 02:16:58 -07:00
|
|
|
// Notify the MediaChannel when both rtp and rtcp channel can send.
|
|
|
|
|
media_channel_->OnReadyToSend(true);
|
2015-09-23 11:50:27 -07:00
|
|
|
} else {
|
|
|
|
|
// Notify the MediaChannel when either rtp or rtcp channel can't send.
|
|
|
|
|
media_channel_->OnReadyToSend(false);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BaseChannel::PacketIsRtcp(const TransportChannel* channel,
|
|
|
|
|
const char* data, size_t len) {
|
|
|
|
|
return (channel == 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,
|
|
|
|
|
rtc::Buffer* packet,
|
|
|
|
|
const rtc::PacketOptions& options) {
|
2013-07-10 00:45:36 +00:00
|
|
|
// SendPacket gets called from MediaEngine, typically on an encoder thread.
|
|
|
|
|
// If the thread is not our worker thread, we will post to our worker
|
|
|
|
|
// so that the real work happens on our worker. This avoids us having to
|
|
|
|
|
// 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.
|
2014-07-29 17:36:52 +00:00
|
|
|
if (rtc::Thread::Current() != worker_thread_) {
|
2013-07-10 00:45:36 +00:00
|
|
|
// Avoid a copy by transferring the ownership of the packet data.
|
|
|
|
|
int message_id = (!rtcp) ? MSG_RTPPACKET : MSG_RTCPPACKET;
|
|
|
|
|
PacketMessageData* data = new PacketMessageData;
|
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
|
|
|
data->packet = packet->Pass();
|
2015-10-15 07:26:07 -07:00
|
|
|
data->options = options;
|
2013-07-10 00:45:36 +00:00
|
|
|
worker_thread_->Post(this, message_id, data);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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()) {
|
|
|
|
|
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";
|
|
|
|
|
|
|
|
|
|
ASSERT(false);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Bon voyage.
|
2015-03-24 09:19:06 +00:00
|
|
|
int ret =
|
2015-10-15 07:26:07 -07:00
|
|
|
channel->SendPacket(packet->data<char>(), packet->size(), updated_options,
|
2015-03-24 09:19:06 +00:00
|
|
|
(secure() && secure_dtls()) ? PF_SRTP_BYPASS : 0);
|
|
|
|
|
if (ret != static_cast<int>(packet->size())) {
|
2013-07-10 00:45:36 +00:00
|
|
|
if (channel->GetError() == EWOULDBLOCK) {
|
|
|
|
|
LOG(LS_WARNING) << "Got EWOULDBLOCK from socket.";
|
2015-09-23 11:50:27 -07:00
|
|
|
SetReadyToSend(rtcp, false);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
bool BaseChannel::WantsPacket(bool rtcp, rtc::Buffer* 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.
|
|
|
|
|
return bundle_filter_.DemuxPacket(packet->data<uint8_t>(), packet->size());
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
void BaseChannel::HandlePacket(bool rtcp, rtc::Buffer* packet,
|
|
|
|
|
const rtc::PacketTime& packet_time) {
|
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;
|
|
|
|
|
signaling_thread()->Post(this, MSG_FIRSTPACKETRECEIVED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Unprotect the packet, if needed.
|
|
|
|
|
if (srtp_filter_.IsActive()) {
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Push it down to the media channel.
|
|
|
|
|
if (!rtcp) {
|
2013-12-13 00:21:03 +00:00
|
|
|
media_channel_->OnPacketReceived(packet, packet_time);
|
2013-07-10 00:45:36 +00:00
|
|
|
} else {
|
2013-12-13 00:21:03 +00:00
|
|
|
media_channel_->OnRtcpReceived(packet, 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() {
|
2014-07-29 17:36:52 +00:00
|
|
|
ASSERT(worker_thread_ == rtc::Thread::Current());
|
2013-07-10 00:45:36 +00:00
|
|
|
if (enabled_)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
LOG(LS_INFO) << "Channel enabled";
|
|
|
|
|
enabled_ = true;
|
|
|
|
|
ChangeState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::DisableMedia_w() {
|
2014-07-29 17:36:52 +00:00
|
|
|
ASSERT(worker_thread_ == rtc::Thread::Current());
|
2013-07-10 00:45:36 +00:00
|
|
|
if (!enabled_)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
LOG(LS_INFO) << "Channel disabled";
|
|
|
|
|
enabled_ = false;
|
|
|
|
|
ChangeState();
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-23 11:50:27 -07:00
|
|
|
void BaseChannel::UpdateWritableState_w() {
|
|
|
|
|
if (transport_channel_ && transport_channel_->writable() &&
|
|
|
|
|
(!rtcp_transport_channel_ || rtcp_transport_channel_->writable())) {
|
|
|
|
|
ChannelWritable_w();
|
|
|
|
|
} else {
|
|
|
|
|
ChannelNotWritable_w();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
void BaseChannel::ChannelWritable_w() {
|
2014-07-29 17:36:52 +00:00
|
|
|
ASSERT(worker_thread_ == rtc::Thread::Current());
|
2015-12-05 09:55:44 -08:00
|
|
|
if (writable_)
|
2013-07-10 00:45:36 +00:00
|
|
|
return;
|
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
|
|
std::vector<ConnectionInfo> infos;
|
|
|
|
|
transport_channel_->GetStats(&infos);
|
|
|
|
|
for (std::vector<ConnectionInfo>::const_iterator it = infos.begin();
|
|
|
|
|
it != infos.end(); ++it) {
|
|
|
|
|
if (it->best_connection) {
|
|
|
|
|
LOG(LS_INFO) << "Using " << it->local_candidate.ToSensitiveString()
|
|
|
|
|
<< "->" << it->remote_candidate.ToSensitiveString();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-05 09:55:44 -08:00
|
|
|
// If we're doing DTLS-SRTP, now is the time.
|
|
|
|
|
if (!was_ever_writable_ && ShouldSetupDtlsSrtp()) {
|
|
|
|
|
if (!SetupDtlsSrtp(false)) {
|
|
|
|
|
SignalDtlsSetupFailure_w(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rtcp_transport_channel_) {
|
|
|
|
|
if (!SetupDtlsSrtp(true)) {
|
|
|
|
|
SignalDtlsSetupFailure_w(true);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
was_ever_writable_ = true;
|
|
|
|
|
writable_ = true;
|
|
|
|
|
ChangeState();
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-16 19:34:23 +00:00
|
|
|
void BaseChannel::SignalDtlsSetupFailure_w(bool rtcp) {
|
|
|
|
|
ASSERT(worker_thread() == rtc::Thread::Current());
|
|
|
|
|
signaling_thread()->Invoke<void>(Bind(
|
|
|
|
|
&BaseChannel::SignalDtlsSetupFailure_s, this, rtcp));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::SignalDtlsSetupFailure_s(bool rtcp) {
|
|
|
|
|
ASSERT(signaling_thread() == rtc::Thread::Current());
|
|
|
|
|
SignalDtlsSetupFailure(this, rtcp);
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-18 19:41:53 -08:00
|
|
|
bool BaseChannel::SetDtlsSrtpCryptoSuites(TransportChannel* tc, bool rtcp) {
|
|
|
|
|
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) {
|
2015-11-18 19:41:53 -08:00
|
|
|
GetSrtpCryptoSuites(&crypto_suites);
|
2013-07-10 00:45:36 +00:00
|
|
|
} else {
|
2015-11-18 19:41:53 -08:00
|
|
|
GetDefaultSrtpCryptoSuites(&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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BaseChannel::ShouldSetupDtlsSrtp() const {
|
2015-12-05 09:55:44 -08:00
|
|
|
return true;
|
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.
|
|
|
|
|
bool BaseChannel::SetupDtlsSrtp(bool rtcp_channel) {
|
|
|
|
|
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:55:44 -08:00
|
|
|
// No DTLS
|
|
|
|
|
if (!channel->IsDtlsActive())
|
|
|
|
|
return true;
|
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);
|
|
|
|
|
|
|
|
|
|
// OK, we're now doing DTLS (RFC 5764)
|
|
|
|
|
std::vector<unsigned char> dtls_buffer(SRTP_MASTER_KEY_KEY_LEN * 2 +
|
|
|
|
|
SRTP_MASTER_KEY_SALT_LEN * 2);
|
|
|
|
|
|
|
|
|
|
// 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";
|
|
|
|
|
ASSERT(false); // This should never happen
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Sync up the keys with the DTLS-SRTP interface
|
|
|
|
|
std::vector<unsigned char> client_write_key(SRTP_MASTER_KEY_KEY_LEN +
|
|
|
|
|
SRTP_MASTER_KEY_SALT_LEN);
|
|
|
|
|
std::vector<unsigned char> server_write_key(SRTP_MASTER_KEY_KEY_LEN +
|
|
|
|
|
SRTP_MASTER_KEY_SALT_LEN);
|
|
|
|
|
size_t offset = 0;
|
|
|
|
|
memcpy(&client_write_key[0], &dtls_buffer[offset],
|
|
|
|
|
SRTP_MASTER_KEY_KEY_LEN);
|
|
|
|
|
offset += SRTP_MASTER_KEY_KEY_LEN;
|
|
|
|
|
memcpy(&server_write_key[0], &dtls_buffer[offset],
|
|
|
|
|
SRTP_MASTER_KEY_KEY_LEN);
|
|
|
|
|
offset += SRTP_MASTER_KEY_KEY_LEN;
|
|
|
|
|
memcpy(&client_write_key[SRTP_MASTER_KEY_KEY_LEN],
|
|
|
|
|
&dtls_buffer[offset], SRTP_MASTER_KEY_SALT_LEN);
|
|
|
|
|
offset += SRTP_MASTER_KEY_SALT_LEN;
|
|
|
|
|
memcpy(&server_write_key[SRTP_MASTER_KEY_KEY_LEN],
|
|
|
|
|
&dtls_buffer[offset], SRTP_MASTER_KEY_SALT_LEN);
|
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
|
LOG(LS_WARNING) << "DTLS-SRTP key installation failed";
|
|
|
|
|
else
|
|
|
|
|
dtls_keyed_ = true;
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::ChannelNotWritable_w() {
|
2014-07-29 17:36:52 +00:00
|
|
|
ASSERT(worker_thread_ == rtc::Thread::Current());
|
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;
|
|
|
|
|
ChangeState();
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
bool BaseChannel::SetRtpTransportParameters_w(
|
|
|
|
|
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
|
|
|
|
|
if (src == CS_LOCAL) {
|
|
|
|
|
set_secure_required(content->crypto_required() != CT_NONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!SetSrtp_w(content->cryptos(), action, src, error_desc)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!SetRtcpMux_w(content->rtcp_mux(), action, src, error_desc)) {
|
|
|
|
|
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.
|
|
|
|
|
bool BaseChannel::CheckSrtpConfig(const std::vector<CryptoParams>& cryptos,
|
2014-01-15 23:15:54 +00:00
|
|
|
bool* dtls,
|
|
|
|
|
std::string* error_desc) {
|
2013-10-13 17:18:27 +00:00
|
|
|
*dtls = transport_channel_->IsDtlsActive();
|
|
|
|
|
if (*dtls && !cryptos.empty()) {
|
2014-01-15 23:15:54 +00:00
|
|
|
SafeSetError("Cryptos must be empty when DTLS is active.",
|
|
|
|
|
error_desc);
|
2013-10-13 17:18:27 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
bool BaseChannel::SetSrtp_w(const std::vector<CryptoParams>& cryptos,
|
2014-01-15 23:15:54 +00:00
|
|
|
ContentAction action,
|
|
|
|
|
ContentSource src,
|
|
|
|
|
std::string* error_desc) {
|
|
|
|
|
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;
|
2014-01-15 23:15:54 +00:00
|
|
|
ret = CheckSrtpConfig(cryptos, &dtls, error_desc);
|
|
|
|
|
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() {
|
|
|
|
|
worker_thread_->Invoke<void>(Bind(
|
|
|
|
|
&BaseChannel::ActivateRtcpMux_w, this));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::ActivateRtcpMux_w() {
|
|
|
|
|
if (!rtcp_mux_filter_.IsActive()) {
|
|
|
|
|
rtcp_mux_filter_.SetActive();
|
2015-09-23 11:50:27 -07:00
|
|
|
set_rtcp_transport_channel(nullptr);
|
|
|
|
|
rtcp_transport_enabled_ = false;
|
2015-05-21 07:48:41 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
bool BaseChannel::SetRtcpMux_w(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:
|
|
|
|
|
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();
|
|
|
|
|
set_rtcp_transport_channel(nullptr);
|
|
|
|
|
rtcp_transport_enabled_ = 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()) {
|
|
|
|
|
ChannelWritable_w();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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) {
|
2014-07-29 17:36:52 +00:00
|
|
|
ASSERT(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) {
|
2014-07-29 17:36:52 +00:00
|
|
|
ASSERT(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;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-21 23:43:24 +00:00
|
|
|
void BaseChannel::MaybeCacheRtpAbsSendTimeHeaderExtension(
|
|
|
|
|
const std::vector<RtpHeaderExtension>& extensions) {
|
|
|
|
|
const RtpHeaderExtension* send_time_extension =
|
2014-03-06 23:46:59 +00:00
|
|
|
FindHeaderExtension(extensions, kRtpAbsoluteSenderTimeHeaderExtension);
|
2014-02-21 23:43:24 +00:00
|
|
|
rtp_abs_sendtime_extn_id_ =
|
|
|
|
|
send_time_extension ? send_time_extension->id : -1;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
void BaseChannel::OnMessage(rtc::Message *pmsg) {
|
2013-07-10 00:45:36 +00:00
|
|
|
switch (pmsg->message_id) {
|
|
|
|
|
case MSG_RTPPACKET:
|
|
|
|
|
case MSG_RTCPPACKET: {
|
|
|
|
|
PacketMessageData* data = static_cast<PacketMessageData*>(pmsg->pdata);
|
2015-10-15 07:26:07 -07:00
|
|
|
SendPacket(pmsg->message_id == MSG_RTCPPACKET, &data->packet,
|
|
|
|
|
data->options);
|
2013-07-10 00:45:36 +00:00
|
|
|
delete data; // because it is Posted
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case MSG_FIRSTPACKETRECEIVED: {
|
|
|
|
|
SignalFirstPacketReceived(this);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseChannel::FlushRtcpMessages() {
|
|
|
|
|
// Flush all remaining RTCP messages. This should only be called in
|
|
|
|
|
// destructor.
|
2014-07-29 17:36:52 +00:00
|
|
|
ASSERT(rtc::Thread::Current() == worker_thread_);
|
|
|
|
|
rtc::MessageList rtcp_messages;
|
2014-02-07 19:03:26 +00:00
|
|
|
worker_thread_->Clear(this, MSG_RTCPPACKET, &rtcp_messages);
|
2014-07-29 17:36:52 +00:00
|
|
|
for (rtc::MessageList::iterator it = rtcp_messages.begin();
|
2013-07-10 00:45:36 +00:00
|
|
|
it != rtcp_messages.end(); ++it) {
|
2014-02-07 19:03:26 +00:00
|
|
|
worker_thread_->Send(this, MSG_RTCPPACKET, it->pdata);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
VoiceChannel::VoiceChannel(rtc::Thread* 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)
|
2015-09-23 11:50:27 -07:00
|
|
|
: BaseChannel(thread,
|
|
|
|
|
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() {
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool VoiceChannel::Init() {
|
2015-03-16 20:19:12 +00:00
|
|
|
if (!BaseChannel::Init()) {
|
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,
|
|
|
|
|
AudioRenderer* renderer) {
|
2015-09-23 11:50:27 -07:00
|
|
|
return InvokeOnWorker(Bind(&VoiceMediaChannel::SetAudioSend, media_channel(),
|
2015-10-01 02:31:10 -07:00
|
|
|
ssrc, enable, options, renderer));
|
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
|
2014-02-07 19:03:26 +00:00
|
|
|
worker_thread()->PostDelayed(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() {
|
2014-02-07 19:03:26 +00:00
|
|
|
return InvokeOnWorker(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) {
|
2014-02-07 19:03:26 +00:00
|
|
|
return InvokeOnWorker(Bind(&VoiceChannel::InsertDtmf_w, this,
|
2015-12-02 12:35:09 -08:00
|
|
|
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) {
|
|
|
|
|
return InvokeOnWorker(Bind(&VoiceMediaChannel::SetOutputVolume,
|
|
|
|
|
media_channel(), ssrc, volume));
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
2014-02-07 19:03:26 +00:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
bool VoiceChannel::GetStats(VoiceMediaInfo* stats) {
|
2014-02-07 19:03:26 +00:00
|
|
|
return InvokeOnWorker(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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VoiceChannel::OnChannelRead(TransportChannel* channel,
|
2013-12-13 00:21:03 +00:00
|
|
|
const char* data, size_t len,
|
2014-07-29 17:36:52 +00:00
|
|
|
const rtc::PacketTime& packet_time,
|
2013-12-13 00:21:03 +00:00
|
|
|
int flags) {
|
|
|
|
|
BaseChannel::OnChannelRead(channel, 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.
|
|
|
|
|
if (!received_media_ && !PacketIsRtcp(channel, data, len)) {
|
|
|
|
|
received_media_ = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VoiceChannel::ChangeState() {
|
|
|
|
|
// 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.
|
|
|
|
|
bool recv = IsReadyToReceive();
|
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.
|
|
|
|
|
bool send = IsReadyToSend();
|
|
|
|
|
SendFlags send_flag = send ? SEND_MICROPHONE : SEND_NOTHING;
|
|
|
|
|
if (!media_channel()->SetSend(send_flag)) {
|
|
|
|
|
LOG(LS_ERROR) << "Failed to SetSend " << send_flag << " on voice channel";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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) {
|
2014-07-29 17:36:52 +00:00
|
|
|
ASSERT(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);
|
|
|
|
|
ASSERT(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
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
if (!SetRtpTransportParameters_w(content, action, CS_LOCAL, error_desc)) {
|
|
|
|
|
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());
|
|
|
|
|
ChangeState();
|
|
|
|
|
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) {
|
2014-07-29 17:36:52 +00:00
|
|
|
ASSERT(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);
|
|
|
|
|
ASSERT(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
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
if (!SetRtpTransportParameters_w(content, action, CS_REMOTE, error_desc)) {
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
if (!media_channel()->SetSendParameters(send_params)) {
|
|
|
|
|
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()) {
|
|
|
|
|
MaybeCacheRtpAbsSendTimeHeaderExtension(audio->rtp_header_extensions());
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
set_remote_content_direction(content->direction());
|
|
|
|
|
ChangeState();
|
|
|
|
|
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) {
|
|
|
|
|
ASSERT(media_channel == this->media_channel());
|
|
|
|
|
SignalMediaMonitor(this, info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VoiceChannel::OnAudioMonitorUpdate(AudioMonitor* monitor,
|
|
|
|
|
const AudioInfo& info) {
|
|
|
|
|
SignalAudioMonitor(this, info);
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-18 19:41:53 -08:00
|
|
|
void VoiceChannel::GetSrtpCryptoSuites(std::vector<int>* crypto_suites) const {
|
|
|
|
|
GetSupportedAudioCryptoSuites(crypto_suites);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
VideoChannel::VideoChannel(rtc::Thread* 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)
|
2015-09-23 11:50:27 -07:00
|
|
|
: BaseChannel(thread,
|
|
|
|
|
media_channel,
|
|
|
|
|
transport_controller,
|
|
|
|
|
content_name,
|
2013-07-10 00:45:36 +00:00
|
|
|
rtcp),
|
|
|
|
|
renderer_(NULL),
|
2015-09-23 11:50:27 -07:00
|
|
|
previous_we_(rtc::WE_CLOSE) {}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
bool VideoChannel::Init() {
|
2015-03-16 20:19:12 +00:00
|
|
|
if (!BaseChannel::Init()) {
|
2013-07-10 00:45:36 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VideoChannel::~VideoChannel() {
|
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
|
|
|
std::vector<uint32_t> screencast_ssrcs;
|
2013-07-10 00:45:36 +00:00
|
|
|
ScreencastMap::iterator iter;
|
|
|
|
|
while (!screencast_capturers_.empty()) {
|
|
|
|
|
if (!RemoveScreencast(screencast_capturers_.begin()->first)) {
|
|
|
|
|
LOG(LS_ERROR) << "Unable to delete screencast with ssrc "
|
|
|
|
|
<< screencast_capturers_.begin()->first;
|
|
|
|
|
ASSERT(false);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
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 VideoChannel::SetRenderer(uint32_t ssrc, VideoRenderer* renderer) {
|
2014-02-07 19:03:26 +00:00
|
|
|
worker_thread()->Invoke<void>(Bind(
|
|
|
|
|
&VideoMediaChannel::SetRenderer, media_channel(), ssrc, renderer));
|
2013-07-10 00:45:36 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool VideoChannel::ApplyViewRequest(const ViewRequest& request) {
|
2014-02-07 19:03:26 +00:00
|
|
|
return InvokeOnWorker(Bind(&VideoChannel::ApplyViewRequest_w, this, request));
|
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 VideoChannel::AddScreencast(uint32_t ssrc, VideoCapturer* capturer) {
|
2014-08-07 22:09:08 +00:00
|
|
|
return worker_thread()->Invoke<bool>(Bind(
|
|
|
|
|
&VideoChannel::AddScreencast_w, this, ssrc, capturer));
|
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 VideoChannel::SetCapturer(uint32_t ssrc, VideoCapturer* capturer) {
|
2014-02-07 19:03:26 +00:00
|
|
|
return InvokeOnWorker(Bind(&VideoMediaChannel::SetCapturer,
|
|
|
|
|
media_channel(), ssrc, capturer));
|
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 VideoChannel::RemoveScreencast(uint32_t ssrc) {
|
2014-02-07 19:03:26 +00:00
|
|
|
return InvokeOnWorker(Bind(&VideoChannel::RemoveScreencast_w, this, ssrc));
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool VideoChannel::IsScreencasting() {
|
2014-02-07 19:03:26 +00:00
|
|
|
return InvokeOnWorker(Bind(&VideoChannel::IsScreencasting_w, this));
|
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
|
|
|
int VideoChannel::GetScreencastFps(uint32_t ssrc) {
|
2014-02-07 19:03:26 +00:00
|
|
|
ScreencastDetailsData data(ssrc);
|
|
|
|
|
worker_thread()->Invoke<void>(Bind(
|
|
|
|
|
&VideoChannel::GetScreencastDetails_w, this, &data));
|
2013-08-30 21:24:16 +00:00
|
|
|
return data.fps;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
int VideoChannel::GetScreencastMaxPixels(uint32_t ssrc) {
|
2014-02-07 19:03:26 +00:00
|
|
|
ScreencastDetailsData data(ssrc);
|
|
|
|
|
worker_thread()->Invoke<void>(Bind(
|
|
|
|
|
&VideoChannel::GetScreencastDetails_w, this, &data));
|
2013-08-30 21:24:16 +00:00
|
|
|
return data.screencast_max_pixels;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool VideoChannel::SendIntraFrame() {
|
2014-02-07 19:03:26 +00:00
|
|
|
worker_thread()->Invoke<void>(Bind(
|
|
|
|
|
&VideoMediaChannel::SendIntraFrame, media_channel()));
|
2013-07-10 00:45:36 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool VideoChannel::RequestIntraFrame() {
|
2014-02-07 19:03:26 +00:00
|
|
|
worker_thread()->Invoke<void>(Bind(
|
|
|
|
|
&VideoMediaChannel::RequestIntraFrame, media_channel()));
|
2013-07-10 00:45:36 +00:00
|
|
|
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 VideoChannel::SetVideoSend(uint32_t ssrc,
|
2015-09-23 11:50:27 -07:00
|
|
|
bool mute,
|
2015-09-10 01:57:14 -07:00
|
|
|
const VideoOptions* options) {
|
2015-09-23 11:50:27 -07:00
|
|
|
return InvokeOnWorker(Bind(&VideoMediaChannel::SetVideoSend, media_channel(),
|
|
|
|
|
ssrc, mute, options));
|
2015-09-10 01:57:14 -07:00
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
void VideoChannel::ChangeState() {
|
|
|
|
|
// Send outgoing data if we're the active call, we have the remote content,
|
|
|
|
|
// and we have had some form of connectivity.
|
|
|
|
|
bool send = IsReadyToSend();
|
|
|
|
|
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) {
|
|
|
|
|
return InvokeOnWorker(
|
|
|
|
|
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) {
|
2014-07-29 17:36:52 +00:00
|
|
|
ASSERT(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);
|
|
|
|
|
ASSERT(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
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
if (!SetRtpTransportParameters_w(content, action, CS_LOCAL, error_desc)) {
|
|
|
|
|
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());
|
|
|
|
|
ChangeState();
|
|
|
|
|
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) {
|
2014-07-29 17:36:52 +00:00
|
|
|
ASSERT(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);
|
|
|
|
|
ASSERT(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
|
|
|
|
|
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
if (!SetRtpTransportParameters_w(content, action, CS_REMOTE, error_desc)) {
|
|
|
|
|
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()) {
|
2015-11-10 22:34:18 +01:00
|
|
|
send_params.options.conference_mode = rtc::Optional<bool>(true);
|
2015-08-07 16:05:34 -07:00
|
|
|
}
|
|
|
|
|
if (!media_channel()->SetSendParameters(send_params)) {
|
|
|
|
|
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()) {
|
|
|
|
|
MaybeCacheRtpAbsSendTimeHeaderExtension(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());
|
|
|
|
|
ChangeState();
|
|
|
|
|
return true;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool VideoChannel::ApplyViewRequest_w(const ViewRequest& request) {
|
|
|
|
|
bool ret = true;
|
|
|
|
|
// Set the send format for each of the local streams. If the view request
|
|
|
|
|
// does not contain a local stream, set its send format to 0x0, which will
|
|
|
|
|
// drop all frames.
|
|
|
|
|
for (std::vector<StreamParams>::const_iterator it = local_streams().begin();
|
|
|
|
|
it != local_streams().end(); ++it) {
|
|
|
|
|
VideoFormat format(0, 0, 0, cricket::FOURCC_I420);
|
|
|
|
|
StaticVideoViews::const_iterator view;
|
|
|
|
|
for (view = request.static_video_views.begin();
|
|
|
|
|
view != request.static_video_views.end(); ++view) {
|
|
|
|
|
if (view->selector.Matches(*it)) {
|
|
|
|
|
format.width = view->width;
|
|
|
|
|
format.height = view->height;
|
|
|
|
|
format.interval = cricket::VideoFormat::FpsToInterval(view->framerate);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ret &= media_channel()->SetSendStreamFormat(it->first_ssrc(), format);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if the view request has invalid streams.
|
|
|
|
|
for (StaticVideoViews::const_iterator it = request.static_video_views.begin();
|
|
|
|
|
it != request.static_video_views.end(); ++it) {
|
2015-01-22 23:00:41 +00:00
|
|
|
if (!GetStream(local_streams(), it->selector)) {
|
2013-07-10 00:45:36 +00:00
|
|
|
LOG(LS_WARNING) << "View request for ("
|
|
|
|
|
<< it->selector.ssrc << ", '"
|
|
|
|
|
<< it->selector.groupid << "', '"
|
|
|
|
|
<< it->selector.streamid << "'"
|
|
|
|
|
<< ") is not in the local streams.";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
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 VideoChannel::AddScreencast_w(uint32_t ssrc, VideoCapturer* capturer) {
|
2013-07-10 00:45:36 +00:00
|
|
|
if (screencast_capturers_.find(ssrc) != screencast_capturers_.end()) {
|
2014-08-07 22:09:08 +00:00
|
|
|
return false;
|
2014-08-07 17:18:00 +00:00
|
|
|
}
|
2014-08-07 22:09:08 +00:00
|
|
|
capturer->SignalStateChange.connect(this, &VideoChannel::OnStateChange);
|
|
|
|
|
screencast_capturers_[ssrc] = capturer;
|
|
|
|
|
return true;
|
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 VideoChannel::RemoveScreencast_w(uint32_t ssrc) {
|
2013-07-10 00:45:36 +00:00
|
|
|
ScreencastMap::iterator iter = screencast_capturers_.find(ssrc);
|
|
|
|
|
if (iter == screencast_capturers_.end()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// Clean up VideoCapturer.
|
|
|
|
|
delete iter->second;
|
|
|
|
|
screencast_capturers_.erase(iter);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool VideoChannel::IsScreencasting_w() const {
|
|
|
|
|
return !screencast_capturers_.empty();
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-07 19:03:26 +00:00
|
|
|
void VideoChannel::GetScreencastDetails_w(
|
|
|
|
|
ScreencastDetailsData* data) const {
|
2013-08-30 21:24:16 +00:00
|
|
|
ScreencastMap::const_iterator iter = screencast_capturers_.find(data->ssrc);
|
2013-07-10 00:45:36 +00:00
|
|
|
if (iter == screencast_capturers_.end()) {
|
2013-08-30 21:24:16 +00:00
|
|
|
return;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
VideoCapturer* capturer = iter->second;
|
|
|
|
|
const VideoFormat* video_format = capturer->GetCaptureFormat();
|
2013-08-30 21:24:16 +00:00
|
|
|
data->fps = VideoFormat::IntervalToFps(video_format->interval);
|
|
|
|
|
data->screencast_max_pixels = capturer->screencast_max_pixels();
|
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 VideoChannel::OnScreencastWindowEvent_s(uint32_t ssrc,
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::WindowEvent we) {
|
|
|
|
|
ASSERT(signaling_thread() == rtc::Thread::Current());
|
2013-07-10 00:45:36 +00:00
|
|
|
SignalScreencastWindowEvent(ssrc, we);
|
|
|
|
|
}
|
|
|
|
|
|
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_SCREENCASTWINDOWEVENT: {
|
|
|
|
|
const ScreencastEventMessageData* data =
|
|
|
|
|
static_cast<ScreencastEventMessageData*>(pmsg->pdata);
|
|
|
|
|
OnScreencastWindowEvent_s(data->ssrc, data->event);
|
|
|
|
|
delete data;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
|
ASSERT(media_channel == this->media_channel());
|
|
|
|
|
SignalMediaMonitor(this, info);
|
|
|
|
|
}
|
|
|
|
|
|
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 VideoChannel::OnScreencastWindowEvent(uint32_t ssrc,
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::WindowEvent event) {
|
2013-07-10 00:45:36 +00:00
|
|
|
ScreencastEventMessageData* pdata =
|
|
|
|
|
new ScreencastEventMessageData(ssrc, event);
|
|
|
|
|
signaling_thread()->Post(this, MSG_SCREENCASTWINDOWEVENT, pdata);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VideoChannel::OnStateChange(VideoCapturer* capturer, CaptureState ev) {
|
|
|
|
|
// Map capturer events to window events. In the future we may want to simply
|
|
|
|
|
// pass these events up directly.
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::WindowEvent we;
|
2013-07-10 00:45:36 +00:00
|
|
|
if (ev == CS_STOPPED) {
|
2014-07-29 17:36:52 +00:00
|
|
|
we = rtc::WE_CLOSE;
|
2013-07-10 00:45:36 +00:00
|
|
|
} else if (ev == CS_PAUSED) {
|
2014-07-29 17:36:52 +00:00
|
|
|
we = rtc::WE_MINIMIZE;
|
|
|
|
|
} else if (ev == CS_RUNNING && previous_we_ == rtc::WE_MINIMIZE) {
|
|
|
|
|
we = rtc::WE_RESTORE;
|
2013-07-10 00:45:36 +00:00
|
|
|
} else {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
previous_we_ = we;
|
|
|
|
|
|
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
|
|
|
if (!GetLocalSsrc(capturer, &ssrc)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-02-07 19:03:26 +00:00
|
|
|
|
|
|
|
|
OnScreencastWindowEvent(ssrc, we);
|
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 VideoChannel::GetLocalSsrc(const VideoCapturer* capturer, uint32_t* ssrc) {
|
2013-07-10 00:45:36 +00:00
|
|
|
*ssrc = 0;
|
|
|
|
|
for (ScreencastMap::iterator iter = screencast_capturers_.begin();
|
|
|
|
|
iter != screencast_capturers_.end(); ++iter) {
|
|
|
|
|
if (iter->second == capturer) {
|
|
|
|
|
*ssrc = iter->first;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-18 19:41:53 -08:00
|
|
|
void VideoChannel::GetSrtpCryptoSuites(std::vector<int>* crypto_suites) const {
|
|
|
|
|
GetSupportedVideoCryptoSuites(crypto_suites);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
DataChannel::DataChannel(rtc::Thread* 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)
|
2015-09-23 11:50:27 -07:00
|
|
|
: BaseChannel(thread,
|
|
|
|
|
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() {
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DataChannel::Init() {
|
2015-03-16 20:19:12 +00:00
|
|
|
if (!BaseChannel::Init()) {
|
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,
|
2014-07-29 17:36:52 +00:00
|
|
|
const rtc::Buffer& payload,
|
2013-07-10 00:45:36 +00:00
|
|
|
SendDataResult* result) {
|
2014-02-07 19:03:26 +00:00
|
|
|
return InvokeOnWorker(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);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
bool DataChannel::WantsPacket(bool rtcp, rtc::Buffer* 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) {
|
2014-07-29 17:36:52 +00:00
|
|
|
ASSERT(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);
|
|
|
|
|
ASSERT(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) {
|
|
|
|
|
if (!SetRtpTransportParameters_w(content, action, CS_LOCAL, error_desc)) {
|
|
|
|
|
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());
|
|
|
|
|
ChangeState();
|
|
|
|
|
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) {
|
2014-07-29 17:36:52 +00:00
|
|
|
ASSERT(worker_thread() == rtc::Thread::Current());
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
const DataContentDescription* data =
|
|
|
|
|
static_cast<const DataContentDescription*>(content);
|
|
|
|
|
ASSERT(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 &&
|
|
|
|
|
!SetRtpTransportParameters_w(content, action, CS_REMOTE, error_desc)) {
|
|
|
|
|
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());
|
|
|
|
|
ChangeState();
|
|
|
|
|
return true;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DataChannel::ChangeState() {
|
|
|
|
|
// 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.
|
|
|
|
|
bool recv = IsReadyToReceive();
|
|
|
|
|
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.
|
|
|
|
|
bool send = IsReadyToSend();
|
|
|
|
|
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) {
|
|
|
|
|
ASSERT(media_channel == this->media_channel());
|
|
|
|
|
SignalMediaMonitor(this, info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DataChannel::OnDataReceived(
|
|
|
|
|
const ReceiveDataParams& params, const char* data, size_t len) {
|
|
|
|
|
DataReceivedMessageData* msg = new DataReceivedMessageData(
|
|
|
|
|
params, data, len);
|
|
|
|
|
signaling_thread()->Post(this, MSG_DATARECEIVED, msg);
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
signaling_thread()->Post(this, MSG_CHANNEL_ERROR, data);
|
|
|
|
|
}
|
|
|
|
|
|
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.
|
|
|
|
|
signaling_thread()->Post(this, MSG_READYTOSENDDATA,
|
|
|
|
|
new DataChannelReadyToSendMessageData(writable));
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-18 19:41:53 -08:00
|
|
|
void DataChannel::GetSrtpCryptoSuites(std::vector<int>* crypto_suites) const {
|
|
|
|
|
GetSupportedDataCryptoSuites(crypto_suites);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DataChannel::ShouldSetupDtlsSrtp() const {
|
2015-12-05 09:55:44 -08:00
|
|
|
return (data_channel_type_ == DCT_RTP);
|
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);
|
2014-05-29 22:54:24 +00:00
|
|
|
signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message);
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
} // namespace cricket
|