| 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_TEST_TURN_CUSTOMIZER_H_ |
| 12 | #define P2P_BASE_TEST_TURN_CUSTOMIZER_H_ |
| 13 |
| 14 | #include <memory> |
| 15 |
| 16 | #include "api/turn_customizer.h" |
| 17 | #include "rtc_base/gunit.h" |
| 18 |
| 19 | namespace cricket { |
| 20 |
| 21 | class TestTurnCustomizer : public webrtc::TurnCustomizer { |
| 22 | public: |
| 23 | TestTurnCustomizer() {} |
| 24 | virtual ~TestTurnCustomizer() {} |
| 25 |
| 26 | enum TestTurnAttributeExtensions { |
| 27 | // Test only attribute |
| 28 | STUN_ATTR_COUNTER = 0xFF02 // Number |
| 29 | }; |
| 30 |
| 31 | void MaybeModifyOutgoingStunMessage(cricket::PortInterface* port, |
| 32 | cricket::StunMessage* message) override { |
| 33 | modify_cnt_++; |
| 34 |
| 35 | ASSERT_NE(0, message->type()); |
| 36 | if (add_counter_) { |
| 37 | message->AddAttribute(std::make_unique<cricket::StunUInt32Attribute>( |
| 38 | STUN_ATTR_COUNTER, modify_cnt_)); |
| 39 | } |
| 40 | return; |
| 41 | } |
| 42 |
| 43 | bool AllowChannelData(cricket::PortInterface* port, |
| 44 | const void* data, |
| 45 | size_t size, |
| 46 | bool payload) override { |
| 47 | allow_channel_data_cnt_++; |
| 48 | return allow_channel_data_; |
| 49 | } |
| 50 |
| 51 | bool add_counter_ = false; |
| 52 | bool allow_channel_data_ = true; |
| 53 | unsigned int modify_cnt_ = 0; |
| 54 | unsigned int allow_channel_data_cnt_ = 0; |
| 55 | }; |
| 56 |
| 57 | } // namespace cricket |
| 58 |
| 59 | #endif // P2P_BASE_TEST_TURN_CUSTOMIZER_H_ |
| 60 |