blob: 5d6ccc8819445ea83309a7fb57225055d0c1c9d4 [file] [log] [blame]
pbos@webrtc.orge75a1bf2013-09-18 11:52:42 +00001/*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#include "video/transport_adapter.h"
pbos@webrtc.orge75a1bf2013-09-18 11:52:42 +000012
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020013#include "rtc_base/checks.h"
solenberg4fbae2b2015-08-28 04:07:10 -070014
pbos@webrtc.orge75a1bf2013-09-18 11:52:42 +000015namespace webrtc {
16namespace internal {
17
pbos2d566682015-09-28 09:59:31 -070018TransportAdapter::TransportAdapter(Transport* transport)
Yuwei Huangd9f99c12017-10-24 15:40:52 -070019 : transport_(transport), enabled_(false) {
henrikg91d6ede2015-09-17 00:24:34 -070020 RTC_DCHECK(nullptr != transport);
solenberg4fbae2b2015-08-28 04:07:10 -070021}
pbos@webrtc.orge75a1bf2013-09-18 11:52:42 +000022
Mirko Bonadei8fdcac32018-08-28 16:30:18 +020023TransportAdapter::~TransportAdapter() = default;
24
stefan1d8a5062015-10-02 03:39:33 -070025bool TransportAdapter::SendRtp(const uint8_t* packet,
26 size_t length,
27 const PacketOptions& options) {
Yuwei Huangd9f99c12017-10-24 15:40:52 -070028 if (!enabled_.load())
sprang@webrtc.orgd9b95602014-01-27 13:03:02 +000029 return false;
30
stefan1d8a5062015-10-02 03:39:33 -070031 return transport_->SendRtp(packet, length, options);
pbos@webrtc.orge75a1bf2013-09-18 11:52:42 +000032}
33
pbos2d566682015-09-28 09:59:31 -070034bool TransportAdapter::SendRtcp(const uint8_t* packet, size_t length) {
Yuwei Huangd9f99c12017-10-24 15:40:52 -070035 if (!enabled_.load())
sprang@webrtc.orgd9b95602014-01-27 13:03:02 +000036 return false;
37
pbos2d566682015-09-28 09:59:31 -070038 return transport_->SendRtcp(packet, length);
pbos@webrtc.orge75a1bf2013-09-18 11:52:42 +000039}
40
sprang@webrtc.orgd9b95602014-01-27 13:03:02 +000041void TransportAdapter::Enable() {
Yuwei Huangd9f99c12017-10-24 15:40:52 -070042 enabled_.store(true);
sprang@webrtc.orgd9b95602014-01-27 13:03:02 +000043}
44
Yuwei Huangd9f99c12017-10-24 15:40:52 -070045void TransportAdapter::Disable() {
46 enabled_.store(false);
47}
sprang@webrtc.orgd9b95602014-01-27 13:03:02 +000048
pbos@webrtc.orge75a1bf2013-09-18 11:52:42 +000049} // namespace internal
50} // namespace webrtc