diff --git a/api/test/fake_datagram_transport.h b/api/test/fake_datagram_transport.h index 8cb399cd22..16cb8d5e7e 100644 --- a/api/test/fake_datagram_transport.h +++ b/api/test/fake_datagram_transport.h @@ -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) { diff --git a/api/transport/BUILD.gn b/api/transport/BUILD.gn index 12bcf099c1..972340713b 100644 --- a/api/transport/BUILD.gn +++ b/api/transport/BUILD.gn @@ -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", ] diff --git a/api/transport/data_channel_transport_interface.cc b/api/transport/data_channel_transport_interface.cc deleted file mode 100644 index 122e282525..0000000000 --- a/api/transport/data_channel_transport_interface.cc +++ /dev/null @@ -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 diff --git a/api/transport/data_channel_transport_interface.h b/api/transport/data_channel_transport_interface.h index 9b29323514..db53a5ed1d 100644 --- a/api/transport/data_channel_transport_interface.h +++ b/api/transport/data_channel_transport_interface.h @@ -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