pbos@webrtc.org | e75a1bf | 2013-09-18 11:52:42 +0000 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "video/transport_adapter.h" |
pbos@webrtc.org | e75a1bf | 2013-09-18 11:52:42 +0000 | [diff] [blame] | 12 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 13 | #include "rtc_base/checks.h" |
solenberg | 4fbae2b | 2015-08-28 04:07:10 -0700 | [diff] [blame] | 14 | |
pbos@webrtc.org | e75a1bf | 2013-09-18 11:52:42 +0000 | [diff] [blame] | 15 | namespace webrtc { |
| 16 | namespace internal { |
| 17 | |
pbos | 2d56668 | 2015-09-28 09:59:31 -0700 | [diff] [blame] | 18 | TransportAdapter::TransportAdapter(Transport* transport) |
Yuwei Huang | d9f99c1 | 2017-10-24 15:40:52 -0700 | [diff] [blame] | 19 | : transport_(transport), enabled_(false) { |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 20 | RTC_DCHECK(nullptr != transport); |
solenberg | 4fbae2b | 2015-08-28 04:07:10 -0700 | [diff] [blame] | 21 | } |
pbos@webrtc.org | e75a1bf | 2013-09-18 11:52:42 +0000 | [diff] [blame] | 22 | |
Mirko Bonadei | 8fdcac3 | 2018-08-28 16:30:18 +0200 | [diff] [blame] | 23 | TransportAdapter::~TransportAdapter() = default; |
| 24 | |
stefan | 1d8a506 | 2015-10-02 03:39:33 -0700 | [diff] [blame] | 25 | bool TransportAdapter::SendRtp(const uint8_t* packet, |
| 26 | size_t length, |
| 27 | const PacketOptions& options) { |
Yuwei Huang | d9f99c1 | 2017-10-24 15:40:52 -0700 | [diff] [blame] | 28 | if (!enabled_.load()) |
sprang@webrtc.org | d9b9560 | 2014-01-27 13:03:02 +0000 | [diff] [blame] | 29 | return false; |
| 30 | |
stefan | 1d8a506 | 2015-10-02 03:39:33 -0700 | [diff] [blame] | 31 | return transport_->SendRtp(packet, length, options); |
pbos@webrtc.org | e75a1bf | 2013-09-18 11:52:42 +0000 | [diff] [blame] | 32 | } |
| 33 | |
pbos | 2d56668 | 2015-09-28 09:59:31 -0700 | [diff] [blame] | 34 | bool TransportAdapter::SendRtcp(const uint8_t* packet, size_t length) { |
Yuwei Huang | d9f99c1 | 2017-10-24 15:40:52 -0700 | [diff] [blame] | 35 | if (!enabled_.load()) |
sprang@webrtc.org | d9b9560 | 2014-01-27 13:03:02 +0000 | [diff] [blame] | 36 | return false; |
| 37 | |
pbos | 2d56668 | 2015-09-28 09:59:31 -0700 | [diff] [blame] | 38 | return transport_->SendRtcp(packet, length); |
pbos@webrtc.org | e75a1bf | 2013-09-18 11:52:42 +0000 | [diff] [blame] | 39 | } |
| 40 | |
sprang@webrtc.org | d9b9560 | 2014-01-27 13:03:02 +0000 | [diff] [blame] | 41 | void TransportAdapter::Enable() { |
Yuwei Huang | d9f99c1 | 2017-10-24 15:40:52 -0700 | [diff] [blame] | 42 | enabled_.store(true); |
sprang@webrtc.org | d9b9560 | 2014-01-27 13:03:02 +0000 | [diff] [blame] | 43 | } |
| 44 | |
Yuwei Huang | d9f99c1 | 2017-10-24 15:40:52 -0700 | [diff] [blame] | 45 | void TransportAdapter::Disable() { |
| 46 | enabled_.store(false); |
| 47 | } |
sprang@webrtc.org | d9b9560 | 2014-01-27 13:03:02 +0000 | [diff] [blame] | 48 | |
pbos@webrtc.org | e75a1bf | 2013-09-18 11:52:42 +0000 | [diff] [blame] | 49 | } // namespace internal |
| 50 | } // namespace webrtc |