Change DataChannelTransportInterface/Sink methods to pure virtual.

These methods are implemented everywhere, so they no longer need to
provide default implementations.

Bug: webrtc:9719
Change-Id: Idf67a78010a55f545d882793d0d6edbccfae525b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/154002
Commit-Queue: Bjorn Mellem <mellem@webrtc.org>
Commit-Queue: Seth Hampson <shampson@webrtc.org>
Reviewed-by: Seth Hampson <shampson@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29262}
This commit is contained in:
Bjorn A Mellem
2019-09-20 12:32:16 -07:00
committed by Commit Bot
parent d702231268
commit 88db835278
4 changed files with 24 additions and 51 deletions

View File

@ -56,8 +56,6 @@ class FakeDatagramTransport : public DatagramTransportInterface {
void SetDatagramSink(DatagramSinkInterface* sink) override {}
bool IsReadyToSend() const override { return false; }
std::string GetTransportParameters() const override {
if (settings_.remote_transport_parameters) {
return *settings_.remote_transport_parameters;
@ -65,6 +63,24 @@ class FakeDatagramTransport : public DatagramTransportInterface {
return transport_parameters_;
}
RTCError OpenChannel(int channel_id) override {
return RTCError(RTCErrorType::UNSUPPORTED_OPERATION);
}
RTCError SendData(int channel_id,
const SendDataParams& params,
const rtc::CopyOnWriteBuffer& buffer) override {
return RTCError(RTCErrorType::UNSUPPORTED_OPERATION);
}
RTCError CloseChannel(int channel_id) override {
return RTCError(RTCErrorType::UNSUPPORTED_OPERATION);
}
void SetDataSink(DataChannelSink* /*sink*/) override {}
bool IsReadyToSend() const override { return false; }
rtc::PacketTransportInternal* packet_transport() { return packet_transport_; }
void set_state(webrtc::MediaTransportState state) {

View File

@ -72,7 +72,6 @@ rtc_source_set("datagram_transport_interface") {
visibility = [ "*" ]
sources = [
"congestion_control_interface.h",
"data_channel_transport_interface.cc",
"data_channel_transport_interface.h",
"datagram_transport_interface.h",
]

View File

@ -1,40 +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 "api/transport/data_channel_transport_interface.h"
namespace webrtc {
// TODO(mellem): Delete these default implementations and make these functions
// pure virtual as soon as downstream implementations override them.
RTCError DataChannelTransportInterface::OpenChannel(int channel_id) {
return RTCError(RTCErrorType::UNSUPPORTED_OPERATION);
}
RTCError DataChannelTransportInterface::SendData(
int channel_id,
const SendDataParams& params,
const rtc::CopyOnWriteBuffer& buffer) {
return RTCError(RTCErrorType::UNSUPPORTED_OPERATION);
}
RTCError DataChannelTransportInterface::CloseChannel(int channel_id) {
return RTCError(RTCErrorType::UNSUPPORTED_OPERATION);
}
void DataChannelTransportInterface::SetDataSink(DataChannelSink* /*sink*/) {}
bool DataChannelTransportInterface::IsReadyToSend() const {
return false;
}
void DataChannelSink::OnReadyToSend() {}
} // namespace webrtc

View File

@ -83,8 +83,7 @@ class DataChannelSink {
// registered if the transport is ready at that time. This callback may be
// invoked again following send errors (eg. due to the transport being
// temporarily blocked or unavailable).
// TODO(mellem): Make pure virtual when downstream sinks override this.
virtual void OnReadyToSend();
virtual void OnReadyToSend() = 0;
};
// Transport for data channels.
@ -94,30 +93,29 @@ class DataChannelTransportInterface {
// Opens a data |channel_id| for sending. May return an error if the
// specified |channel_id| is unusable. Must be called before |SendData|.
virtual RTCError OpenChannel(int channel_id);
virtual RTCError OpenChannel(int channel_id) = 0;
// Sends a data buffer to the remote endpoint using the given send parameters.
// |buffer| may not be larger than 256 KiB. Returns an error if the send
// fails.
virtual RTCError SendData(int channel_id,
const SendDataParams& params,
const rtc::CopyOnWriteBuffer& buffer);
const rtc::CopyOnWriteBuffer& buffer) = 0;
// Closes |channel_id| gracefully. Returns an error if |channel_id| is not
// open. Data sent after the closing procedure begins will not be
// transmitted. The channel becomes closed after pending data is transmitted.
virtual RTCError CloseChannel(int channel_id);
virtual RTCError CloseChannel(int channel_id) = 0;
// Sets a sink for data messages and channel state callbacks. Before media
// transport is destroyed, the sink must be unregistered by setting it to
// nullptr.
virtual void SetDataSink(DataChannelSink* sink);
virtual void SetDataSink(DataChannelSink* sink) = 0;
// Returns whether this data channel transport is ready to send.
// Note: the default implementation always returns false (as it assumes no one
// has implemented the interface). This default implementation is temporary.
// TODO(mellem): Change this to pure virtual.
virtual bool IsReadyToSend() const;
virtual bool IsReadyToSend() const = 0;
};
} // namespace webrtc