1 /* 2 * Copyright (c) 2019 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 #ifndef TEST_PEER_SCENARIO_SIGNALING_ROUTE_H_ 11 #define TEST_PEER_SCENARIO_SIGNALING_ROUTE_H_ 12 13 #include <string> 14 #include <utility> 15 16 #include "test/network/network_emulation_manager.h" 17 #include "test/peer_scenario/peer_scenario_client.h" 18 19 namespace webrtc { 20 namespace test { 21 22 // Helper class to reduce the amount of boilerplate required for ICE signalling 23 // ad SDP negotiation. 24 class SignalingRoute { 25 public: 26 SignalingRoute(PeerScenarioClient* caller, 27 PeerScenarioClient* callee, 28 CrossTrafficRoute* send_route, 29 CrossTrafficRoute* ret_route); 30 31 void StartIceSignaling(); 32 33 // The `modify_offer` callback is used to modify an offer after the local 34 // description has been set. This is legal (but odd) behavior. 35 // The `munge_offer` callback is used to modify an offer between its creation 36 // and set local description. This behavior is forbidden according to the spec 37 // but available here in order to allow test coverage on corner cases. 38 // The `exchange_finished` callback is called with the answer produced after 39 // SDP negotations has completed. 40 // TODO(srte): Handle lossy links. 41 void NegotiateSdp( 42 std::function<void(SessionDescriptionInterface* offer)> munge_offer, 43 std::function<void(SessionDescriptionInterface* offer)> modify_offer, 44 std::function<void(const SessionDescriptionInterface& answer)> 45 exchange_finished); 46 void NegotiateSdp( 47 std::function<void(SessionDescriptionInterface* offer)> modify_offer, 48 std::function<void(const SessionDescriptionInterface& answer)> 49 exchange_finished); 50 void NegotiateSdp( 51 std::function<void(const SessionDescriptionInterface& answer)> 52 exchange_finished); reverse()53 SignalingRoute reverse() { 54 return SignalingRoute(callee_, caller_, ret_route_, send_route_); 55 } 56 57 private: 58 PeerScenarioClient* const caller_; 59 PeerScenarioClient* const callee_; 60 CrossTrafficRoute* const send_route_; 61 CrossTrafficRoute* const ret_route_; 62 }; 63 64 } // namespace test 65 } // namespace webrtc 66 67 #endif // TEST_PEER_SCENARIO_SIGNALING_ROUTE_H_ 68