• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <memory>
20 #include <vector>
21 
22 #include <json/json.h>
23 
24 #include <api/peer_connection_interface.h>
25 
26 #include "common/libs/utils/result.h"
27 
28 namespace cuttlefish {
29 namespace webrtc_streaming {
30 
31 // Parses a session description object from a JSON message.
32 Result<std::unique_ptr<webrtc::SessionDescriptionInterface>>
33 ParseSessionDescription(const std::string& type, const Json::Value& message,
34                         webrtc::SdpType sdp_type);
35 
36 // Parses an IceCandidate from a JSON message.
37 Result<std::unique_ptr<webrtc::IceCandidateInterface>> ParseIceCandidate(
38     const std::string& type, const Json::Value& message);
39 
40 // Parses a JSON error message.
41 Result<std::string> ParseError(const std::string& type,
42                                const Json::Value& message);
43 
44 // Checks if the message contains an "ice_servers" array field and parses it
45 // into a vector of webrtc ICE servers. Returns an empty vector if the field
46 // isn't present.
47 Result<std::vector<webrtc::PeerConnectionInterface::IceServer>>
48 ParseIceServersMessage(const Json::Value& message);
49 
50 // Generates a JSON message from a list of ICE servers.
51 Json::Value GenerateIceServersMessage(
52     const std::vector<webrtc::PeerConnectionInterface::IceServer>& ice_servers);
53 
54 }  // namespace webrtc_streaming
55 }  // namespace cuttlefish
56