Convert Media*Channel to contain a webrtc::Transport
Media*Channel objects used to subclass webrtc::Transport. This was not an optimal design. This CL makes the transport a member variable of MediaChannelUtil. Bug: None Change-Id: I85d33cc1b32b931e563b7bb2d277f1c512600831 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/309800 Commit-Queue: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Florent Castelli <orphis@webrtc.org> Cr-Commit-Position: refs/heads/main@{#40328}
This commit is contained in:
parent
0510463439
commit
84fdf990e8
@ -59,24 +59,17 @@ VideoOptions::~VideoOptions() = default;
|
||||
|
||||
MediaChannelUtil::MediaChannelUtil(TaskQueueBase* network_thread,
|
||||
bool enable_dscp)
|
||||
: enable_dscp_(enable_dscp),
|
||||
network_safety_(PendingTaskSafetyFlag::CreateDetachedInactive()),
|
||||
network_thread_(network_thread) {}
|
||||
: transport_(network_thread, enable_dscp) {}
|
||||
|
||||
MediaChannel::MediaChannel(Role role,
|
||||
TaskQueueBase* network_thread,
|
||||
bool enable_dscp)
|
||||
: MediaChannelUtil(network_thread, enable_dscp), role_(role) {}
|
||||
|
||||
MediaChannelUtil::~MediaChannelUtil() {
|
||||
RTC_DCHECK(!network_interface_);
|
||||
}
|
||||
MediaChannelUtil::~MediaChannelUtil() {}
|
||||
|
||||
void MediaChannelUtil::SetInterface(MediaChannelNetworkInterface* iface) {
|
||||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
iface ? network_safety_->SetAlive() : network_safety_->SetNotAlive();
|
||||
network_interface_ = iface;
|
||||
UpdateDscp();
|
||||
transport_.SetInterface(iface);
|
||||
}
|
||||
|
||||
int MediaChannelUtil::GetRtpSendTimeExtnId() const {
|
||||
@ -97,19 +90,18 @@ void MediaChannelUtil::SetFrameDecryptor(
|
||||
|
||||
bool MediaChannelUtil::SendPacket(rtc::CopyOnWriteBuffer* packet,
|
||||
const rtc::PacketOptions& options) {
|
||||
return DoSendPacket(packet, false, options);
|
||||
return transport_.DoSendPacket(packet, false, options);
|
||||
}
|
||||
|
||||
bool MediaChannelUtil::SendRtcp(rtc::CopyOnWriteBuffer* packet,
|
||||
const rtc::PacketOptions& options) {
|
||||
return DoSendPacket(packet, true, options);
|
||||
return transport_.DoSendPacket(packet, true, options);
|
||||
}
|
||||
|
||||
int MediaChannelUtil::SetOption(MediaChannelNetworkInterface::SocketType type,
|
||||
rtc::Socket::Option opt,
|
||||
int option) {
|
||||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
return SetOptionLocked(type, opt, option);
|
||||
return transport_.SetOption(type, opt, option);
|
||||
}
|
||||
|
||||
// Corresponds to the SDP attribute extmap-allow-mixed, see RFC8285.
|
||||
@ -125,8 +117,7 @@ bool MediaChannelUtil::ExtmapAllowMixed() const {
|
||||
}
|
||||
|
||||
bool MediaChannelUtil::HasNetworkInterface() const {
|
||||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
return network_interface_ != nullptr;
|
||||
return transport_.HasNetworkInterface();
|
||||
}
|
||||
|
||||
void MediaChannelUtil::SetEncoderToPacketizerFrameTransformer(
|
||||
@ -137,119 +128,12 @@ void MediaChannelUtil::SetDepacketizerToDecoderFrameTransformer(
|
||||
uint32_t ssrc,
|
||||
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer) {}
|
||||
|
||||
int MediaChannelUtil::SetOptionLocked(
|
||||
MediaChannelNetworkInterface::SocketType type,
|
||||
rtc::Socket::Option opt,
|
||||
int option) {
|
||||
if (!network_interface_)
|
||||
return -1;
|
||||
return network_interface_->SetOption(type, opt, option);
|
||||
}
|
||||
|
||||
bool MediaChannelUtil::DscpEnabled() const {
|
||||
return enable_dscp_;
|
||||
}
|
||||
|
||||
// This is the DSCP value used for both RTP and RTCP channels if DSCP is
|
||||
// enabled. It can be changed at any time via `SetPreferredDscp`.
|
||||
rtc::DiffServCodePoint MediaChannelUtil::PreferredDscp() const {
|
||||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
return preferred_dscp_;
|
||||
return transport_.DscpEnabled();
|
||||
}
|
||||
|
||||
void MediaChannelUtil::SetPreferredDscp(rtc::DiffServCodePoint new_dscp) {
|
||||
if (!network_thread_->IsCurrent()) {
|
||||
// This is currently the common path as the derived channel classes
|
||||
// get called on the worker thread. There are still some tests though
|
||||
// that call directly on the network thread.
|
||||
network_thread_->PostTask(SafeTask(
|
||||
network_safety_, [this, new_dscp]() { SetPreferredDscp(new_dscp); }));
|
||||
return;
|
||||
}
|
||||
|
||||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
if (new_dscp == preferred_dscp_)
|
||||
return;
|
||||
|
||||
preferred_dscp_ = new_dscp;
|
||||
UpdateDscp();
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<PendingTaskSafetyFlag> MediaChannelUtil::network_safety() {
|
||||
return network_safety_;
|
||||
}
|
||||
|
||||
void MediaChannelUtil::UpdateDscp() {
|
||||
rtc::DiffServCodePoint value =
|
||||
enable_dscp_ ? preferred_dscp_ : rtc::DSCP_DEFAULT;
|
||||
int ret = SetOptionLocked(MediaChannelNetworkInterface::ST_RTP,
|
||||
rtc::Socket::OPT_DSCP, value);
|
||||
if (ret == 0)
|
||||
SetOptionLocked(MediaChannelNetworkInterface::ST_RTCP,
|
||||
rtc::Socket::OPT_DSCP, value);
|
||||
}
|
||||
|
||||
bool MediaChannelUtil::DoSendPacket(rtc::CopyOnWriteBuffer* packet,
|
||||
bool rtcp,
|
||||
const rtc::PacketOptions& options) {
|
||||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
if (!network_interface_)
|
||||
return false;
|
||||
|
||||
return (!rtcp) ? network_interface_->SendPacket(packet, options)
|
||||
: network_interface_->SendRtcp(packet, options);
|
||||
}
|
||||
|
||||
void MediaChannelUtil::SendRtp(const uint8_t* data,
|
||||
size_t len,
|
||||
const webrtc::PacketOptions& options) {
|
||||
auto send =
|
||||
[this, packet_id = options.packet_id,
|
||||
included_in_feedback = options.included_in_feedback,
|
||||
included_in_allocation = options.included_in_allocation,
|
||||
batchable = options.batchable,
|
||||
last_packet_in_batch = options.last_packet_in_batch,
|
||||
packet = rtc::CopyOnWriteBuffer(data, len, kMaxRtpPacketLen)]() mutable {
|
||||
rtc::PacketOptions rtc_options;
|
||||
rtc_options.packet_id = packet_id;
|
||||
if (DscpEnabled()) {
|
||||
rtc_options.dscp = PreferredDscp();
|
||||
}
|
||||
rtc_options.info_signaled_after_sent.included_in_feedback =
|
||||
included_in_feedback;
|
||||
rtc_options.info_signaled_after_sent.included_in_allocation =
|
||||
included_in_allocation;
|
||||
rtc_options.batchable = batchable;
|
||||
rtc_options.last_packet_in_batch = last_packet_in_batch;
|
||||
SendPacket(&packet, rtc_options);
|
||||
};
|
||||
|
||||
// TODO(bugs.webrtc.org/11993): ModuleRtpRtcpImpl2 and related classes (e.g.
|
||||
// RTCPSender) aren't aware of the network thread and may trigger calls to
|
||||
// this function from different threads. Update those classes to keep
|
||||
// network traffic on the network thread.
|
||||
if (network_thread_->IsCurrent()) {
|
||||
send();
|
||||
} else {
|
||||
network_thread_->PostTask(SafeTask(network_safety_, std::move(send)));
|
||||
}
|
||||
}
|
||||
|
||||
void MediaChannelUtil::SendRtcp(const uint8_t* data, size_t len) {
|
||||
auto send = [this, packet = rtc::CopyOnWriteBuffer(
|
||||
data, len, kMaxRtpPacketLen)]() mutable {
|
||||
rtc::PacketOptions rtc_options;
|
||||
if (DscpEnabled()) {
|
||||
rtc_options.dscp = PreferredDscp();
|
||||
}
|
||||
SendRtcp(&packet, rtc_options);
|
||||
};
|
||||
|
||||
if (network_thread_->IsCurrent()) {
|
||||
send();
|
||||
} else {
|
||||
network_thread_->PostTask(SafeTask(network_safety_, std::move(send)));
|
||||
}
|
||||
transport_.SetPreferredDscp(new_dscp);
|
||||
}
|
||||
|
||||
MediaSenderInfo::MediaSenderInfo() = default;
|
||||
@ -316,4 +200,140 @@ cricket::MediaType VideoMediaChannel::media_type() const {
|
||||
|
||||
void VideoMediaChannel::SetVideoCodecSwitchingEnabled(bool enabled) {}
|
||||
|
||||
// --------------------- MediaChannelUtil::TransportForMediaChannels -----
|
||||
|
||||
MediaChannelUtil::TransportForMediaChannels::TransportForMediaChannels(
|
||||
webrtc::TaskQueueBase* network_thread,
|
||||
bool enable_dscp)
|
||||
: network_safety_(webrtc::PendingTaskSafetyFlag::CreateDetachedInactive()),
|
||||
network_thread_(network_thread),
|
||||
|
||||
enable_dscp_(enable_dscp) {}
|
||||
|
||||
MediaChannelUtil::TransportForMediaChannels::~TransportForMediaChannels() {
|
||||
RTC_DCHECK(!network_interface_);
|
||||
}
|
||||
|
||||
bool MediaChannelUtil::TransportForMediaChannels::SendRtcp(const uint8_t* data,
|
||||
size_t len) {
|
||||
auto send = [this, packet = rtc::CopyOnWriteBuffer(
|
||||
data, len, kMaxRtpPacketLen)]() mutable {
|
||||
rtc::PacketOptions rtc_options;
|
||||
if (DscpEnabled()) {
|
||||
rtc_options.dscp = PreferredDscp();
|
||||
}
|
||||
DoSendPacket(&packet, true, rtc_options);
|
||||
};
|
||||
|
||||
if (network_thread_->IsCurrent()) {
|
||||
send();
|
||||
} else {
|
||||
network_thread_->PostTask(SafeTask(network_safety_, std::move(send)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MediaChannelUtil::TransportForMediaChannels::SendRtp(
|
||||
const uint8_t* data,
|
||||
size_t len,
|
||||
const webrtc::PacketOptions& options) {
|
||||
auto send =
|
||||
[this, packet_id = options.packet_id,
|
||||
included_in_feedback = options.included_in_feedback,
|
||||
included_in_allocation = options.included_in_allocation,
|
||||
batchable = options.batchable,
|
||||
last_packet_in_batch = options.last_packet_in_batch,
|
||||
packet = rtc::CopyOnWriteBuffer(data, len, kMaxRtpPacketLen)]() mutable {
|
||||
rtc::PacketOptions rtc_options;
|
||||
rtc_options.packet_id = packet_id;
|
||||
if (DscpEnabled()) {
|
||||
rtc_options.dscp = PreferredDscp();
|
||||
}
|
||||
rtc_options.info_signaled_after_sent.included_in_feedback =
|
||||
included_in_feedback;
|
||||
rtc_options.info_signaled_after_sent.included_in_allocation =
|
||||
included_in_allocation;
|
||||
rtc_options.batchable = batchable;
|
||||
rtc_options.last_packet_in_batch = last_packet_in_batch;
|
||||
DoSendPacket(&packet, false, rtc_options);
|
||||
};
|
||||
|
||||
// TODO(bugs.webrtc.org/11993): ModuleRtpRtcpImpl2 and related classes (e.g.
|
||||
// RTCPSender) aren't aware of the network thread and may trigger calls to
|
||||
// this function from different threads. Update those classes to keep
|
||||
// network traffic on the network thread.
|
||||
if (network_thread_->IsCurrent()) {
|
||||
send();
|
||||
} else {
|
||||
network_thread_->PostTask(SafeTask(network_safety_, std::move(send)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void MediaChannelUtil::TransportForMediaChannels::SetInterface(
|
||||
MediaChannelNetworkInterface* iface) {
|
||||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
iface ? network_safety_->SetAlive() : network_safety_->SetNotAlive();
|
||||
network_interface_ = iface;
|
||||
UpdateDscp();
|
||||
}
|
||||
|
||||
void MediaChannelUtil::TransportForMediaChannels::UpdateDscp() {
|
||||
rtc::DiffServCodePoint value =
|
||||
enable_dscp_ ? preferred_dscp_ : rtc::DSCP_DEFAULT;
|
||||
int ret = SetOptionLocked(MediaChannelNetworkInterface::ST_RTP,
|
||||
rtc::Socket::OPT_DSCP, value);
|
||||
if (ret == 0)
|
||||
SetOptionLocked(MediaChannelNetworkInterface::ST_RTCP,
|
||||
rtc::Socket::OPT_DSCP, value);
|
||||
}
|
||||
|
||||
bool MediaChannelUtil::TransportForMediaChannels::DoSendPacket(
|
||||
rtc::CopyOnWriteBuffer* packet,
|
||||
bool rtcp,
|
||||
const rtc::PacketOptions& options) {
|
||||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
if (!network_interface_)
|
||||
return false;
|
||||
|
||||
return (!rtcp) ? network_interface_->SendPacket(packet, options)
|
||||
: network_interface_->SendRtcp(packet, options);
|
||||
}
|
||||
|
||||
int MediaChannelUtil::TransportForMediaChannels::SetOption(
|
||||
MediaChannelNetworkInterface::SocketType type,
|
||||
rtc::Socket::Option opt,
|
||||
int option) {
|
||||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
return SetOptionLocked(type, opt, option);
|
||||
}
|
||||
|
||||
int MediaChannelUtil::TransportForMediaChannels::SetOptionLocked(
|
||||
MediaChannelNetworkInterface::SocketType type,
|
||||
rtc::Socket::Option opt,
|
||||
int option) {
|
||||
if (!network_interface_)
|
||||
return -1;
|
||||
return network_interface_->SetOption(type, opt, option);
|
||||
}
|
||||
|
||||
void MediaChannelUtil::TransportForMediaChannels::SetPreferredDscp(
|
||||
rtc::DiffServCodePoint new_dscp) {
|
||||
if (!network_thread_->IsCurrent()) {
|
||||
// This is currently the common path as the derived channel classes
|
||||
// get called on the worker thread. There are still some tests though
|
||||
// that call directly on the network thread.
|
||||
network_thread_->PostTask(SafeTask(
|
||||
network_safety_, [this, new_dscp]() { SetPreferredDscp(new_dscp); }));
|
||||
return;
|
||||
}
|
||||
|
||||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
if (new_dscp == preferred_dscp_)
|
||||
return;
|
||||
|
||||
preferred_dscp_ = new_dscp;
|
||||
UpdateDscp();
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
@ -79,7 +79,11 @@ class MediaChannelUtil {
|
||||
virtual ~MediaChannelUtil();
|
||||
// Returns the absolute sendtime extension id value from media channel.
|
||||
virtual int GetRtpSendTimeExtnId() const;
|
||||
// Base method to send packet using MediaChannelNetworkInterface.
|
||||
|
||||
webrtc::Transport* transport() { return &transport_; }
|
||||
|
||||
// Base methods to send packet using MediaChannelNetworkInterface.
|
||||
// These methods are used by some tests only.
|
||||
bool SendPacket(rtc::CopyOnWriteBuffer* packet,
|
||||
const rtc::PacketOptions& options);
|
||||
|
||||
@ -121,45 +125,74 @@ class MediaChannelUtil {
|
||||
rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer);
|
||||
|
||||
protected:
|
||||
int SetOptionLocked(MediaChannelNetworkInterface::SocketType type,
|
||||
rtc::Socket::Option opt,
|
||||
int option) RTC_RUN_ON(network_thread_);
|
||||
|
||||
bool DscpEnabled() const;
|
||||
|
||||
// This is the DSCP value used for both RTP and RTCP channels if DSCP is
|
||||
// enabled. It can be changed at any time via `SetPreferredDscp`.
|
||||
rtc::DiffServCodePoint PreferredDscp() const;
|
||||
void SetPreferredDscp(rtc::DiffServCodePoint new_dscp);
|
||||
|
||||
rtc::scoped_refptr<webrtc::PendingTaskSafetyFlag> network_safety();
|
||||
|
||||
// Utility implementation for derived classes (video/voice) that applies
|
||||
// the packet options and passes the data onwards to `SendPacket`.
|
||||
void SendRtp(const uint8_t* data,
|
||||
size_t len,
|
||||
const webrtc::PacketOptions& options);
|
||||
|
||||
void SendRtcp(const uint8_t* data, size_t len);
|
||||
|
||||
private:
|
||||
// Apply the preferred DSCP setting to the underlying network interface RTP
|
||||
// and RTCP channels. If DSCP is disabled, then apply the default DSCP value.
|
||||
void UpdateDscp() RTC_RUN_ON(network_thread_);
|
||||
// Implementation of the webrtc::Transport interface required
|
||||
// by Call().
|
||||
class TransportForMediaChannels : public webrtc::Transport {
|
||||
public:
|
||||
TransportForMediaChannels(webrtc::TaskQueueBase* network_thread,
|
||||
bool enable_dscp);
|
||||
|
||||
bool DoSendPacket(rtc::CopyOnWriteBuffer* packet,
|
||||
bool rtcp,
|
||||
const rtc::PacketOptions& options);
|
||||
virtual ~TransportForMediaChannels();
|
||||
|
||||
// Implementation of webrtc::Transport
|
||||
bool SendRtp(const uint8_t* packet,
|
||||
size_t length,
|
||||
const webrtc::PacketOptions& options) override;
|
||||
bool SendRtcp(const uint8_t* packet, size_t length) override;
|
||||
|
||||
// Not implementation of webrtc::Transport
|
||||
void SetInterface(MediaChannelNetworkInterface* iface);
|
||||
|
||||
int SetOption(MediaChannelNetworkInterface::SocketType type,
|
||||
rtc::Socket::Option opt,
|
||||
int option);
|
||||
|
||||
bool DoSendPacket(rtc::CopyOnWriteBuffer* packet,
|
||||
bool rtcp,
|
||||
const rtc::PacketOptions& options);
|
||||
|
||||
bool HasNetworkInterface() const {
|
||||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
return network_interface_ != nullptr;
|
||||
}
|
||||
bool DscpEnabled() const { return enable_dscp_; }
|
||||
|
||||
void SetPreferredDscp(rtc::DiffServCodePoint new_dscp);
|
||||
|
||||
private:
|
||||
// This is the DSCP value used for both RTP and RTCP channels if DSCP is
|
||||
// enabled. It can be changed at any time via `SetPreferredDscp`.
|
||||
rtc::DiffServCodePoint PreferredDscp() const {
|
||||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
return preferred_dscp_;
|
||||
}
|
||||
|
||||
// Apply the preferred DSCP setting to the underlying network interface RTP
|
||||
// and RTCP channels. If DSCP is disabled, then apply the default DSCP
|
||||
// value.
|
||||
void UpdateDscp() RTC_RUN_ON(network_thread_);
|
||||
|
||||
int SetOptionLocked(MediaChannelNetworkInterface::SocketType type,
|
||||
rtc::Socket::Option opt,
|
||||
int option) RTC_RUN_ON(network_thread_);
|
||||
|
||||
const rtc::scoped_refptr<webrtc::PendingTaskSafetyFlag> network_safety_
|
||||
RTC_PT_GUARDED_BY(network_thread_);
|
||||
webrtc::TaskQueueBase* const network_thread_;
|
||||
const bool enable_dscp_;
|
||||
MediaChannelNetworkInterface* network_interface_
|
||||
RTC_GUARDED_BY(network_thread_) = nullptr;
|
||||
rtc::DiffServCodePoint preferred_dscp_ RTC_GUARDED_BY(network_thread_) =
|
||||
rtc::DSCP_DEFAULT;
|
||||
};
|
||||
|
||||
const bool enable_dscp_;
|
||||
const rtc::scoped_refptr<webrtc::PendingTaskSafetyFlag> network_safety_
|
||||
RTC_PT_GUARDED_BY(network_thread_);
|
||||
webrtc::TaskQueueBase* const network_thread_;
|
||||
MediaChannelNetworkInterface* network_interface_
|
||||
RTC_GUARDED_BY(network_thread_) = nullptr;
|
||||
rtc::DiffServCodePoint preferred_dscp_ RTC_GUARDED_BY(network_thread_) =
|
||||
rtc::DSCP_DEFAULT;
|
||||
bool extmap_allow_mixed_ = false;
|
||||
TransportForMediaChannels transport_;
|
||||
};
|
||||
|
||||
// The `MediaChannel` class implements both the SendChannel and
|
||||
@ -179,9 +212,9 @@ class MediaChannel : public MediaChannelUtil,
|
||||
// TODO(bugs.webrtc.org/13931): Remove kBoth when usage is removed.
|
||||
};
|
||||
|
||||
explicit MediaChannel(Role role,
|
||||
webrtc::TaskQueueBase* network_thread,
|
||||
bool enable_dscp = false);
|
||||
MediaChannel(Role role,
|
||||
webrtc::TaskQueueBase* network_thread,
|
||||
bool enable_dscp = false);
|
||||
virtual ~MediaChannel() = default;
|
||||
|
||||
Role role() const { return role_; }
|
||||
|
||||
@ -1371,7 +1371,7 @@ bool WebRtcVideoSendChannel::AddSendStream(const StreamParams& sp) {
|
||||
for (uint32_t used_ssrc : sp.ssrcs)
|
||||
send_ssrcs_.insert(used_ssrc);
|
||||
|
||||
webrtc::VideoSendStream::Config config(this);
|
||||
webrtc::VideoSendStream::Config config(transport());
|
||||
|
||||
for (const RidDescription& rid : sp.rids()) {
|
||||
config.rtp.rids.push_back(rid.rid);
|
||||
@ -1603,18 +1603,6 @@ void WebRtcVideoSendChannel::SetVideoCodecSwitchingEnabled(bool enabled) {
|
||||
}
|
||||
}
|
||||
|
||||
bool WebRtcVideoSendChannel::SendRtp(const uint8_t* data,
|
||||
size_t len,
|
||||
const webrtc::PacketOptions& options) {
|
||||
MediaChannelUtil::SendRtp(data, len, options);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebRtcVideoSendChannel::SendRtcp(const uint8_t* data, size_t len) {
|
||||
MediaChannelUtil::SendRtcp(data, len);
|
||||
return true;
|
||||
}
|
||||
|
||||
WebRtcVideoSendChannel::WebRtcVideoSendStream::VideoSendStreamParameters::
|
||||
VideoSendStreamParameters(
|
||||
webrtc::VideoSendStream::Config config,
|
||||
@ -2798,8 +2786,9 @@ bool WebRtcVideoReceiveChannel::AddRecvStream(const StreamParams& sp,
|
||||
for (uint32_t used_ssrc : sp.ssrcs)
|
||||
receive_ssrcs_.insert(used_ssrc);
|
||||
|
||||
webrtc::VideoReceiveStreamInterface::Config config(this, decoder_factory_);
|
||||
webrtc::FlexfecReceiveStream::Config flexfec_config(this);
|
||||
webrtc::VideoReceiveStreamInterface::Config config(transport(),
|
||||
decoder_factory_);
|
||||
webrtc::FlexfecReceiveStream::Config flexfec_config(transport());
|
||||
ConfigureReceiverRtp(&config, &flexfec_config, sp);
|
||||
|
||||
config.crypto_options = crypto_options_;
|
||||
|
||||
@ -167,7 +167,6 @@ struct VideoCodecSettings {
|
||||
|
||||
class WebRtcVideoSendChannel : public MediaChannelUtil,
|
||||
public VideoMediaSendChannelInterface,
|
||||
public webrtc::Transport,
|
||||
public webrtc::EncoderSwitchRequestCallback {
|
||||
public:
|
||||
WebRtcVideoSendChannel(
|
||||
@ -452,11 +451,6 @@ class WebRtcVideoSendChannel : public MediaChannelUtil,
|
||||
|
||||
void Construct(webrtc::Call* call, WebRtcVideoEngine* engine);
|
||||
|
||||
bool SendRtp(const uint8_t* data,
|
||||
size_t len,
|
||||
const webrtc::PacketOptions& options) override;
|
||||
bool SendRtcp(const uint8_t* data, size_t len) override;
|
||||
|
||||
// Get all codecs that are compatible with the receiver.
|
||||
std::vector<VideoCodecSettings> SelectSendVideoCodecs(
|
||||
const std::vector<VideoCodecSettings>& remote_mapped_codecs) const
|
||||
@ -584,8 +578,7 @@ class WebRtcVideoSendChannel : public MediaChannelUtil,
|
||||
};
|
||||
|
||||
class WebRtcVideoReceiveChannel : public MediaChannelUtil,
|
||||
public VideoMediaReceiveChannelInterface,
|
||||
public webrtc::Transport {
|
||||
public VideoMediaReceiveChannelInterface {
|
||||
public:
|
||||
WebRtcVideoReceiveChannel(webrtc::Call* call,
|
||||
const MediaConfig& config,
|
||||
@ -603,17 +596,6 @@ class WebRtcVideoReceiveChannel : public MediaChannelUtil,
|
||||
RTC_CHECK_NOTREACHED();
|
||||
return nullptr;
|
||||
}
|
||||
// Functions imported from MediaChannelUtil
|
||||
bool SendRtp(const uint8_t* data,
|
||||
size_t len,
|
||||
const webrtc::PacketOptions& options) override {
|
||||
MediaChannelUtil::SendRtp(data, len, options);
|
||||
return true;
|
||||
}
|
||||
bool SendRtcp(const uint8_t* data, size_t len) override {
|
||||
MediaChannelUtil::SendRtcp(data, len);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Common functions between sender and receiver
|
||||
void SetInterface(MediaChannelNetworkInterface* iface) override;
|
||||
|
||||
@ -2712,8 +2712,7 @@ class WebRtcVideoChannelTest : public WebRtcVideoEngineTest {
|
||||
// Casts a shim channel to a webrtc::Transport. Used once.
|
||||
webrtc::Transport* ChannelImplAsTransport(
|
||||
cricket::VideoMediaSendChannelInterface* channel) {
|
||||
return static_cast<webrtc::Transport*>(
|
||||
static_cast<cricket::WebRtcVideoSendChannel*>(channel));
|
||||
return static_cast<cricket::WebRtcVideoSendChannel*>(channel)->transport();
|
||||
}
|
||||
|
||||
cricket::VideoCodec GetEngineCodec(const std::string& name) {
|
||||
|
||||
@ -1545,7 +1545,7 @@ bool WebRtcVoiceSendChannel::AddSendStream(const StreamParams& sp) {
|
||||
ssrc, mid_, sp.cname, sp.id, send_codec_spec_, ExtmapAllowMixed(),
|
||||
send_rtp_extensions_, max_send_bitrate_bps_,
|
||||
audio_config_.rtcp_report_interval_ms, audio_network_adaptor_config,
|
||||
call_, this, engine()->encoder_factory_, codec_pair_id_, nullptr,
|
||||
call_, transport(), engine()->encoder_factory_, codec_pair_id_, nullptr,
|
||||
crypto_options_);
|
||||
send_streams_.insert(std::make_pair(ssrc, stream));
|
||||
if (ssrc_list_changed_callback_) {
|
||||
@ -1799,18 +1799,6 @@ void WebRtcVoiceSendChannel::SetEncoderToPacketizerFrameTransformer(
|
||||
std::move(frame_transformer));
|
||||
}
|
||||
|
||||
bool WebRtcVoiceSendChannel::SendRtp(const uint8_t* data,
|
||||
size_t len,
|
||||
const webrtc::PacketOptions& options) {
|
||||
MediaChannelUtil::SendRtp(data, len, options);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebRtcVoiceSendChannel::SendRtcp(const uint8_t* data, size_t len) {
|
||||
MediaChannelUtil::SendRtcp(data, len);
|
||||
return true;
|
||||
}
|
||||
|
||||
webrtc::RtpParameters WebRtcVoiceSendChannel::GetRtpSendParameters(
|
||||
uint32_t ssrc) const {
|
||||
RTC_DCHECK_RUN_ON(worker_thread_);
|
||||
@ -2265,8 +2253,9 @@ bool WebRtcVoiceReceiveChannel::AddRecvStream(const StreamParams& sp) {
|
||||
// Create a new channel for receiving audio data.
|
||||
auto config = BuildReceiveStreamConfig(
|
||||
ssrc, receiver_reports_ssrc_, recv_nack_enabled_, enable_non_sender_rtt_,
|
||||
sp.stream_ids(), recv_rtp_extensions_, this, engine()->decoder_factory_,
|
||||
decoder_map_, codec_pair_id_, engine()->audio_jitter_buffer_max_packets_,
|
||||
sp.stream_ids(), recv_rtp_extensions_, transport(),
|
||||
engine()->decoder_factory_, decoder_map_, codec_pair_id_,
|
||||
engine()->audio_jitter_buffer_max_packets_,
|
||||
engine()->audio_jitter_buffer_fast_accelerate_,
|
||||
engine()->audio_jitter_buffer_min_delay_ms_, unsignaled_frame_decryptor_,
|
||||
crypto_options_, unsignaled_frame_transformer_);
|
||||
@ -2692,18 +2681,6 @@ void WebRtcVoiceReceiveChannel::SetDepacketizerToDecoderFrameTransformer(
|
||||
std::move(frame_transformer));
|
||||
}
|
||||
|
||||
bool WebRtcVoiceReceiveChannel::SendRtp(const uint8_t* data,
|
||||
size_t len,
|
||||
const webrtc::PacketOptions& options) {
|
||||
MediaChannelUtil::SendRtp(data, len, options);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebRtcVoiceReceiveChannel::SendRtcp(const uint8_t* data, size_t len) {
|
||||
MediaChannelUtil::SendRtcp(data, len);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebRtcVoiceReceiveChannel::MaybeDeregisterUnsignaledRecvStream(
|
||||
uint32_t ssrc) {
|
||||
RTC_DCHECK_RUN_ON(worker_thread_);
|
||||
|
||||
@ -195,8 +195,7 @@ class WebRtcVoiceEngine final : public VoiceEngineInterface {
|
||||
};
|
||||
|
||||
class WebRtcVoiceSendChannel final : public MediaChannelUtil,
|
||||
public VoiceMediaSendChannelInterface,
|
||||
public webrtc::Transport {
|
||||
public VoiceMediaSendChannelInterface {
|
||||
public:
|
||||
WebRtcVoiceSendChannel(WebRtcVoiceEngine* engine,
|
||||
const MediaConfig& config,
|
||||
@ -279,13 +278,6 @@ class WebRtcVoiceSendChannel final : public MediaChannelUtil,
|
||||
rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer)
|
||||
override;
|
||||
|
||||
// implements Transport interface
|
||||
bool SendRtp(const uint8_t* data,
|
||||
size_t len,
|
||||
const webrtc::PacketOptions& options) override;
|
||||
|
||||
bool SendRtcp(const uint8_t* data, size_t len) override;
|
||||
|
||||
bool SenderNackEnabled() const override {
|
||||
if (!send_codec_spec_) {
|
||||
return false;
|
||||
@ -363,8 +355,7 @@ class WebRtcVoiceSendChannel final : public MediaChannelUtil,
|
||||
|
||||
class WebRtcVoiceReceiveChannel final
|
||||
: public MediaChannelUtil,
|
||||
public VoiceMediaReceiveChannelInterface,
|
||||
public webrtc::Transport {
|
||||
public VoiceMediaReceiveChannelInterface {
|
||||
public:
|
||||
WebRtcVoiceReceiveChannel(WebRtcVoiceEngine* engine,
|
||||
const MediaConfig& config,
|
||||
@ -446,13 +437,6 @@ class WebRtcVoiceReceiveChannel final
|
||||
rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer)
|
||||
override;
|
||||
|
||||
// implements Transport interface
|
||||
bool SendRtp(const uint8_t* data,
|
||||
size_t len,
|
||||
const webrtc::PacketOptions& options) override;
|
||||
|
||||
bool SendRtcp(const uint8_t* data, size_t len) override;
|
||||
|
||||
void SetReceiveNackEnabled(bool enabled) override;
|
||||
void SetReceiveNonSenderRttEnabled(bool enabled) override;
|
||||
|
||||
|
||||
@ -857,7 +857,7 @@ TEST_P(WebRtcVoiceEngineTestFake, CreateSendStream) {
|
||||
EXPECT_EQ(kSsrcX, config.rtp.ssrc);
|
||||
EXPECT_EQ("", config.rtp.c_name);
|
||||
EXPECT_EQ(0u, config.rtp.extensions.size());
|
||||
EXPECT_EQ(SendImpl(), config.send_transport);
|
||||
EXPECT_EQ(SendImpl()->transport(), config.send_transport);
|
||||
}
|
||||
|
||||
// Test that we can add a receive stream and that it has the correct defaults.
|
||||
@ -868,7 +868,7 @@ TEST_P(WebRtcVoiceEngineTestFake, CreateRecvStream) {
|
||||
GetRecvStreamConfig(kSsrcX);
|
||||
EXPECT_EQ(kSsrcX, config.rtp.remote_ssrc);
|
||||
EXPECT_EQ(0xFA17FA17, config.rtp.local_ssrc);
|
||||
EXPECT_EQ(ReceiveImpl(), config.rtcp_send_transport);
|
||||
EXPECT_EQ(ReceiveImpl()->transport(), config.rtcp_send_transport);
|
||||
EXPECT_EQ("", config.sync_group);
|
||||
}
|
||||
|
||||
@ -3242,8 +3242,9 @@ TEST_P(WebRtcVoiceEngineTestFake, TestSetDscpOptions) {
|
||||
|
||||
// Packets should also self-identify their dscp in PacketOptions.
|
||||
const uint8_t kData[10] = {0};
|
||||
EXPECT_TRUE(
|
||||
SendImplFromPointer(channel.get())->SendRtcp(kData, sizeof(kData)));
|
||||
EXPECT_TRUE(SendImplFromPointer(channel.get())
|
||||
->transport()
|
||||
->SendRtcp(kData, sizeof(kData)));
|
||||
EXPECT_EQ(rtc::DSCP_CS1, network_interface.options().dscp);
|
||||
channel->SetInterface(nullptr);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user