signaling_route.h 2.4 KB

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