xref: /aosp_15_r20/external/webrtc/test/peer_scenario/signaling_route.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1*d9f75844SAndroid Build Coastguard Worker /*
2*d9f75844SAndroid Build Coastguard Worker  *  Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
3*d9f75844SAndroid Build Coastguard Worker  *
4*d9f75844SAndroid Build Coastguard Worker  *  Use of this source code is governed by a BSD-style license
5*d9f75844SAndroid Build Coastguard Worker  *  that can be found in the LICENSE file in the root of the source
6*d9f75844SAndroid Build Coastguard Worker  *  tree. An additional intellectual property rights grant can be found
7*d9f75844SAndroid Build Coastguard Worker  *  in the file PATENTS.  All contributing project authors may
8*d9f75844SAndroid Build Coastguard Worker  *  be found in the AUTHORS file in the root of the source tree.
9*d9f75844SAndroid Build Coastguard Worker  */
10*d9f75844SAndroid Build Coastguard Worker #ifndef TEST_PEER_SCENARIO_SIGNALING_ROUTE_H_
11*d9f75844SAndroid Build Coastguard Worker #define TEST_PEER_SCENARIO_SIGNALING_ROUTE_H_
12*d9f75844SAndroid Build Coastguard Worker 
13*d9f75844SAndroid Build Coastguard Worker #include <string>
14*d9f75844SAndroid Build Coastguard Worker #include <utility>
15*d9f75844SAndroid Build Coastguard Worker 
16*d9f75844SAndroid Build Coastguard Worker #include "test/network/network_emulation_manager.h"
17*d9f75844SAndroid Build Coastguard Worker #include "test/peer_scenario/peer_scenario_client.h"
18*d9f75844SAndroid Build Coastguard Worker 
19*d9f75844SAndroid Build Coastguard Worker namespace webrtc {
20*d9f75844SAndroid Build Coastguard Worker namespace test {
21*d9f75844SAndroid Build Coastguard Worker 
22*d9f75844SAndroid Build Coastguard Worker // Helper class to reduce the amount of boilerplate required for ICE signalling
23*d9f75844SAndroid Build Coastguard Worker // ad SDP negotiation.
24*d9f75844SAndroid Build Coastguard Worker class SignalingRoute {
25*d9f75844SAndroid Build Coastguard Worker  public:
26*d9f75844SAndroid Build Coastguard Worker   SignalingRoute(PeerScenarioClient* caller,
27*d9f75844SAndroid Build Coastguard Worker                  PeerScenarioClient* callee,
28*d9f75844SAndroid Build Coastguard Worker                  CrossTrafficRoute* send_route,
29*d9f75844SAndroid Build Coastguard Worker                  CrossTrafficRoute* ret_route);
30*d9f75844SAndroid Build Coastguard Worker 
31*d9f75844SAndroid Build Coastguard Worker   void StartIceSignaling();
32*d9f75844SAndroid Build Coastguard Worker 
33*d9f75844SAndroid Build Coastguard Worker   // The `modify_offer` callback is used to modify an offer after the local
34*d9f75844SAndroid Build Coastguard Worker   // description has been set. This is legal (but odd) behavior.
35*d9f75844SAndroid Build Coastguard Worker   // The `munge_offer` callback is used to modify an offer between its creation
36*d9f75844SAndroid Build Coastguard Worker   // and set local description. This behavior is forbidden according to the spec
37*d9f75844SAndroid Build Coastguard Worker   // but available here in order to allow test coverage on corner cases.
38*d9f75844SAndroid Build Coastguard Worker   // The `exchange_finished` callback is called with the answer produced after
39*d9f75844SAndroid Build Coastguard Worker   // SDP negotations has completed.
40*d9f75844SAndroid Build Coastguard Worker   // TODO(srte): Handle lossy links.
41*d9f75844SAndroid Build Coastguard Worker   void NegotiateSdp(
42*d9f75844SAndroid Build Coastguard Worker       std::function<void(SessionDescriptionInterface* offer)> munge_offer,
43*d9f75844SAndroid Build Coastguard Worker       std::function<void(SessionDescriptionInterface* offer)> modify_offer,
44*d9f75844SAndroid Build Coastguard Worker       std::function<void(const SessionDescriptionInterface& answer)>
45*d9f75844SAndroid Build Coastguard Worker           exchange_finished);
46*d9f75844SAndroid Build Coastguard Worker   void NegotiateSdp(
47*d9f75844SAndroid Build Coastguard Worker       std::function<void(SessionDescriptionInterface* offer)> modify_offer,
48*d9f75844SAndroid Build Coastguard Worker       std::function<void(const SessionDescriptionInterface& answer)>
49*d9f75844SAndroid Build Coastguard Worker           exchange_finished);
50*d9f75844SAndroid Build Coastguard Worker   void NegotiateSdp(
51*d9f75844SAndroid Build Coastguard Worker       std::function<void(const SessionDescriptionInterface& answer)>
52*d9f75844SAndroid Build Coastguard Worker           exchange_finished);
reverse()53*d9f75844SAndroid Build Coastguard Worker   SignalingRoute reverse() {
54*d9f75844SAndroid Build Coastguard Worker     return SignalingRoute(callee_, caller_, ret_route_, send_route_);
55*d9f75844SAndroid Build Coastguard Worker   }
56*d9f75844SAndroid Build Coastguard Worker 
57*d9f75844SAndroid Build Coastguard Worker  private:
58*d9f75844SAndroid Build Coastguard Worker   PeerScenarioClient* const caller_;
59*d9f75844SAndroid Build Coastguard Worker   PeerScenarioClient* const callee_;
60*d9f75844SAndroid Build Coastguard Worker   CrossTrafficRoute* const send_route_;
61*d9f75844SAndroid Build Coastguard Worker   CrossTrafficRoute* const ret_route_;
62*d9f75844SAndroid Build Coastguard Worker };
63*d9f75844SAndroid Build Coastguard Worker 
64*d9f75844SAndroid Build Coastguard Worker }  // namespace test
65*d9f75844SAndroid Build Coastguard Worker }  // namespace webrtc
66*d9f75844SAndroid Build Coastguard Worker 
67*d9f75844SAndroid Build Coastguard Worker #endif  // TEST_PEER_SCENARIO_SIGNALING_ROUTE_H_
68