Jonas Oreland | bdcee28 | 2017-10-10 14:01:40 +0200 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2017 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 | #ifndef P2P_BASE_TESTTURNCUSTOMIZER_H_ |
| 12 | #define P2P_BASE_TESTTURNCUSTOMIZER_H_ |
| 13 | |
| 14 | #include "api/turncustomizer.h" |
| 15 | #include "rtc_base/ptr_util.h" |
| 16 | |
| 17 | namespace cricket { |
| 18 | |
| 19 | class TestTurnCustomizer : public webrtc::TurnCustomizer { |
| 20 | public: |
| 21 | TestTurnCustomizer() {} |
| 22 | virtual ~TestTurnCustomizer() {} |
| 23 | |
| 24 | enum TestTurnAttributeExtensions { |
| 25 | // Test only attribute |
| 26 | STUN_ATTR_COUNTER = 0xFF02 // Number |
| 27 | }; |
| 28 | |
| 29 | void MaybeModifyOutgoingStunMessage( |
| 30 | cricket::PortInterface* port, |
| 31 | cricket::StunMessage* message) override { |
| 32 | modify_cnt_ ++; |
| 33 | |
| 34 | if (add_counter_) { |
| 35 | message->AddAttribute(rtc::MakeUnique<cricket::StunUInt32Attribute>( |
| 36 | STUN_ATTR_COUNTER, modify_cnt_)); |
| 37 | } |
| 38 | return; |
| 39 | } |
| 40 | |
| 41 | bool AllowChannelData(cricket::PortInterface* port, |
| 42 | const void* data, |
| 43 | size_t size, |
| 44 | bool payload) override { |
| 45 | allow_channel_data_cnt_++; |
| 46 | return allow_channel_data_; |
| 47 | } |
| 48 | |
| 49 | bool add_counter_ = false; |
| 50 | bool allow_channel_data_ = true; |
| 51 | unsigned int modify_cnt_ = 0; |
| 52 | unsigned int allow_channel_data_cnt_ = 0; |
| 53 | }; |
| 54 | |
| 55 | } // namespace cricket |
| 56 | |
| 57 | #endif // P2P_BASE_TESTTURNCUSTOMIZER_H_ |