Android-cuttlefish cvd tool
utils.h
Go to the documentation of this file.
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
27
28namespace cuttlefish {
29namespace webrtc_streaming {
30
31// Parses a session description object from a JSON message.
32Result<std::unique_ptr<webrtc::SessionDescriptionInterface>>
33ParseSessionDescription(const std::string& type, const Json::Value& message,
34 webrtc::SdpType sdp_type);
35
36// Parses an IceCandidate from a JSON message.
37Result<std::unique_ptr<webrtc::IceCandidateInterface>> ParseIceCandidate(
38 const std::string& type, const Json::Value& message);
39
40// Parses a JSON error message.
41Result<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.
47Result<std::vector<webrtc::PeerConnectionInterface::IceServer>>
48ParseIceServersMessage(const Json::Value& message);
49
50// Generates a JSON message from a list of ICE servers.
52 const std::vector<webrtc::PeerConnectionInterface::IceServer>& ice_servers);
53
54} // namespace webrtc_streaming
55} // namespace cuttlefish
Result< std::string > ParseError(const std::string &type, const Json::Value &message)
Definition: utils.cpp:68
Result< std::unique_ptr< webrtc::SessionDescriptionInterface > > ParseSessionDescription(const std::string &type, const Json::Value &message, webrtc::SdpType sdp_type)
Definition: utils.cpp:43
Json::Value GenerateIceServersMessage(const std::vector< webrtc::PeerConnectionInterface::IceServer > &ice_servers)
Definition: utils.cpp:106
Result< std::unique_ptr< webrtc::IceCandidateInterface > > ParseIceCandidate(const std::string &type, const Json::Value &message)
Definition: utils.cpp:53
Result< std::vector< webrtc::PeerConnectionInterface::IceServer > > ParseIceServersMessage(const Json::Value &message)
Definition: utils.cpp:74
Definition: alloc_utils.cpp:23
uint8_t type
Definition: pairing_connection.h:0