Delete CompositeDataChannelTransport
And delete the always null members data_channel_transport_ and composite_data_channel_transport_ from the JsepTransport class. Bug: webrtc:9719 Change-Id: Ibfd92b74708d63a75521f6f1d5fbc3830bd67e20 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/179280 Reviewed-by: Taylor <deadbeef@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31727}
This commit is contained in:
@ -32,8 +32,6 @@ rtc_library("rtc_pc_base") {
|
||||
"channel_interface.h",
|
||||
"channel_manager.cc",
|
||||
"channel_manager.h",
|
||||
"composite_data_channel_transport.cc",
|
||||
"composite_data_channel_transport.h",
|
||||
"composite_rtp_transport.cc",
|
||||
"composite_rtp_transport.h",
|
||||
"dtls_srtp_transport.cc",
|
||||
|
@ -1,123 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 The WebRTC Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "pc/composite_data_channel_transport.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "absl/algorithm/container.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
CompositeDataChannelTransport::CompositeDataChannelTransport(
|
||||
std::vector<DataChannelTransportInterface*> transports)
|
||||
: transports_(std::move(transports)) {
|
||||
for (auto transport : transports_) {
|
||||
transport->SetDataSink(this);
|
||||
}
|
||||
}
|
||||
|
||||
CompositeDataChannelTransport::~CompositeDataChannelTransport() {
|
||||
for (auto transport : transports_) {
|
||||
transport->SetDataSink(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void CompositeDataChannelTransport::SetSendTransport(
|
||||
DataChannelTransportInterface* send_transport) {
|
||||
if (!absl::c_linear_search(transports_, send_transport)) {
|
||||
return;
|
||||
}
|
||||
send_transport_ = send_transport;
|
||||
// NB: OnReadyToSend() checks if we're actually ready to send, and signals
|
||||
// |sink_| if appropriate. This signal is required upon setting the sink.
|
||||
OnReadyToSend();
|
||||
}
|
||||
|
||||
void CompositeDataChannelTransport::RemoveTransport(
|
||||
DataChannelTransportInterface* transport) {
|
||||
RTC_DCHECK(transport != send_transport_) << "Cannot remove send transport";
|
||||
|
||||
auto it = absl::c_find(transports_, transport);
|
||||
if (it == transports_.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
transport->SetDataSink(nullptr);
|
||||
transports_.erase(it);
|
||||
}
|
||||
|
||||
RTCError CompositeDataChannelTransport::OpenChannel(int channel_id) {
|
||||
RTCError error = RTCError::OK();
|
||||
for (auto transport : transports_) {
|
||||
RTCError e = transport->OpenChannel(channel_id);
|
||||
if (!e.ok()) {
|
||||
error = std::move(e);
|
||||
}
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
RTCError CompositeDataChannelTransport::SendData(
|
||||
int channel_id,
|
||||
const SendDataParams& params,
|
||||
const rtc::CopyOnWriteBuffer& buffer) {
|
||||
if (send_transport_) {
|
||||
return send_transport_->SendData(channel_id, params, buffer);
|
||||
}
|
||||
return RTCError(RTCErrorType::NETWORK_ERROR, "Send transport is not ready");
|
||||
}
|
||||
|
||||
RTCError CompositeDataChannelTransport::CloseChannel(int channel_id) {
|
||||
if (send_transport_) {
|
||||
return send_transport_->CloseChannel(channel_id);
|
||||
}
|
||||
return RTCError(RTCErrorType::NETWORK_ERROR, "Send transport is not ready");
|
||||
}
|
||||
|
||||
void CompositeDataChannelTransport::SetDataSink(DataChannelSink* sink) {
|
||||
sink_ = sink;
|
||||
// NB: OnReadyToSend() checks if we're actually ready to send, and signals
|
||||
// |sink_| if appropriate. This signal is required upon setting the sink.
|
||||
OnReadyToSend();
|
||||
}
|
||||
|
||||
bool CompositeDataChannelTransport::IsReadyToSend() const {
|
||||
return send_transport_ && send_transport_->IsReadyToSend();
|
||||
}
|
||||
|
||||
void CompositeDataChannelTransport::OnDataReceived(
|
||||
int channel_id,
|
||||
DataMessageType type,
|
||||
const rtc::CopyOnWriteBuffer& buffer) {
|
||||
if (sink_) {
|
||||
sink_->OnDataReceived(channel_id, type, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
void CompositeDataChannelTransport::OnChannelClosing(int channel_id) {
|
||||
if (sink_) {
|
||||
sink_->OnChannelClosing(channel_id);
|
||||
}
|
||||
}
|
||||
|
||||
void CompositeDataChannelTransport::OnChannelClosed(int channel_id) {
|
||||
if (sink_) {
|
||||
sink_->OnChannelClosed(channel_id);
|
||||
}
|
||||
}
|
||||
|
||||
void CompositeDataChannelTransport::OnReadyToSend() {
|
||||
if (sink_ && send_transport_ && send_transport_->IsReadyToSend()) {
|
||||
sink_->OnReadyToSend();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 The WebRTC Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef PC_COMPOSITE_DATA_CHANNEL_TRANSPORT_H_
|
||||
#define PC_COMPOSITE_DATA_CHANNEL_TRANSPORT_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "api/transport/data_channel_transport_interface.h"
|
||||
#include "rtc_base/critical_section.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Composite implementation of DataChannelTransportInterface. Allows users to
|
||||
// receive data channel messages over multiple transports and send over one of
|
||||
// those transports.
|
||||
class CompositeDataChannelTransport : public DataChannelTransportInterface,
|
||||
public DataChannelSink {
|
||||
public:
|
||||
explicit CompositeDataChannelTransport(
|
||||
std::vector<DataChannelTransportInterface*> transports);
|
||||
~CompositeDataChannelTransport() override;
|
||||
|
||||
// Specifies which transport to be used for sending. Must be called before
|
||||
// sending data.
|
||||
void SetSendTransport(DataChannelTransportInterface* send_transport);
|
||||
|
||||
// Removes a given transport from the composite, if present.
|
||||
void RemoveTransport(DataChannelTransportInterface* transport);
|
||||
|
||||
// DataChannelTransportInterface overrides.
|
||||
RTCError OpenChannel(int channel_id) override;
|
||||
RTCError SendData(int channel_id,
|
||||
const SendDataParams& params,
|
||||
const rtc::CopyOnWriteBuffer& buffer) override;
|
||||
RTCError CloseChannel(int channel_id) override;
|
||||
void SetDataSink(DataChannelSink* sink) override;
|
||||
bool IsReadyToSend() const override;
|
||||
|
||||
// DataChannelSink overrides.
|
||||
void OnDataReceived(int channel_id,
|
||||
DataMessageType type,
|
||||
const rtc::CopyOnWriteBuffer& buffer) override;
|
||||
void OnChannelClosing(int channel_id) override;
|
||||
void OnChannelClosed(int channel_id) override;
|
||||
void OnReadyToSend() override;
|
||||
|
||||
private:
|
||||
std::vector<DataChannelTransportInterface*> transports_;
|
||||
DataChannelTransportInterface* send_transport_ = nullptr;
|
||||
DataChannelSink* sink_ = nullptr;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // PC_COMPOSITE_DATA_CHANNEL_TRANSPORT_H_
|
@ -134,13 +134,6 @@ JsepTransport::JsepTransport(
|
||||
std::vector<webrtc::RtpTransportInternal*>{
|
||||
datagram_rtp_transport_.get(), default_rtp_transport()});
|
||||
}
|
||||
|
||||
if (data_channel_transport_ && sctp_data_channel_transport_) {
|
||||
composite_data_channel_transport_ =
|
||||
std::make_unique<webrtc::CompositeDataChannelTransport>(
|
||||
std::vector<webrtc::DataChannelTransportInterface*>{
|
||||
data_channel_transport_, sctp_data_channel_transport_.get()});
|
||||
}
|
||||
}
|
||||
|
||||
JsepTransport::~JsepTransport() {
|
||||
|
@ -20,11 +20,11 @@
|
||||
#include "api/candidate.h"
|
||||
#include "api/ice_transport_interface.h"
|
||||
#include "api/jsep.h"
|
||||
#include "api/transport/data_channel_transport_interface.h"
|
||||
#include "media/sctp/sctp_transport_internal.h"
|
||||
#include "p2p/base/dtls_transport.h"
|
||||
#include "p2p/base/p2p_constants.h"
|
||||
#include "p2p/base/transport_info.h"
|
||||
#include "pc/composite_data_channel_transport.h"
|
||||
#include "pc/composite_rtp_transport.h"
|
||||
#include "pc/dtls_srtp_transport.h"
|
||||
#include "pc/dtls_transport.h"
|
||||
@ -218,15 +218,15 @@ class JsepTransport : public sigslot::has_slots<> {
|
||||
return sctp_transport_;
|
||||
}
|
||||
|
||||
// TODO(bugs.webrtc.org/9719): Delete method, update callers to use
|
||||
// SctpTransport() instead.
|
||||
webrtc::DataChannelTransportInterface* data_channel_transport() const
|
||||
RTC_LOCKS_EXCLUDED(accessor_lock_) {
|
||||
rtc::CritScope scope(&accessor_lock_);
|
||||
if (composite_data_channel_transport_) {
|
||||
return composite_data_channel_transport_.get();
|
||||
} else if (sctp_data_channel_transport_) {
|
||||
if (sctp_data_channel_transport_) {
|
||||
return sctp_data_channel_transport_.get();
|
||||
}
|
||||
return data_channel_transport_;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// This is signaled when RTCP-mux becomes active and
|
||||
@ -381,15 +381,6 @@ class JsepTransport : public sigslot::has_slots<> {
|
||||
std::unique_ptr<webrtc::RtpTransportInternal> datagram_rtp_transport_
|
||||
RTC_GUARDED_BY(accessor_lock_);
|
||||
|
||||
// Non-SCTP data channel transport. Set to |datagram_transport_| if that
|
||||
// transport should be used for data chanels. Unset otherwise.
|
||||
webrtc::DataChannelTransportInterface* data_channel_transport_
|
||||
RTC_GUARDED_BY(accessor_lock_) = nullptr;
|
||||
|
||||
// Composite data channel transport, used during negotiation.
|
||||
std::unique_ptr<webrtc::CompositeDataChannelTransport>
|
||||
composite_data_channel_transport_ RTC_GUARDED_BY(accessor_lock_);
|
||||
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(JsepTransport);
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user