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
11 #include "video/transport_adapter.h"
12
13 #include "rtc_base/checks.h"
14
15 namespace webrtc {
16 namespace internal {
17
TransportAdapter(Transport * transport)18 TransportAdapter::TransportAdapter(Transport* transport)
19 : transport_(transport), enabled_(false) {
20 RTC_DCHECK(nullptr != transport);
21 }
22
23 TransportAdapter::~TransportAdapter() = default;
24
SendRtp(const uint8_t * packet,size_t length,const PacketOptions & options)25 bool TransportAdapter::SendRtp(const uint8_t* packet,
26 size_t length,
27 const PacketOptions& options) {
28 if (!enabled_.load())
29 return false;
30
31 return transport_->SendRtp(packet, length, options);
32 }
33
SendRtcp(const uint8_t * packet,size_t length)34 bool TransportAdapter::SendRtcp(const uint8_t* packet, size_t length) {
35 if (!enabled_.load())
36 return false;
37
38 return transport_->SendRtcp(packet, length);
39 }
40
Enable()41 void TransportAdapter::Enable() {
42 enabled_.store(true);
43 }
44
Disable()45 void TransportAdapter::Disable() {
46 enabled_.store(false);
47 }
48
49 } // namespace internal
50 } // namespace webrtc
51