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 "api/peer_connection_interface.h"
23#include "json/json.h"
24
26
27namespace cuttlefish {
28namespace webrtc_streaming {
29
30// Parses a session description object from a JSON message.
31Result<std::unique_ptr<webrtc::SessionDescriptionInterface>>
32ParseSessionDescription(const std::string& type, const Json::Value& message,
33 webrtc::SdpType sdp_type);
34
35// Parses an IceCandidate from a JSON message.
36Result<std::unique_ptr<webrtc::IceCandidateInterface>> ParseIceCandidate(
37 const std::string& type, const Json::Value& message);
38
39// Parses a JSON error message.
40Result<std::string> ParseError(const std::string& type,
41 const Json::Value& message);
42
43// Checks if the message contains an "ice_servers" array field and parses it
44// into a vector of webrtc ICE servers. Returns an empty vector if the field
45// isn't present.
46Result<std::vector<webrtc::PeerConnectionInterface::IceServer>>
47ParseIceServersMessage(const Json::Value& message);
48
49// Generates a JSON message from a list of ICE servers.
51 const std::vector<webrtc::PeerConnectionInterface::IceServer>& ice_servers);
52
53} // namespace webrtc_streaming
54} // namespace cuttlefish
Result< std::string > ParseError(const std::string &type, const Json::Value &message)
Definition: utils.cpp:69
Result< std::unique_ptr< webrtc::SessionDescriptionInterface > > ParseSessionDescription(const std::string &type, const Json::Value &message, webrtc::SdpType sdp_type)
Definition: utils.cpp:44
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:54
Result< std::vector< webrtc::PeerConnectionInterface::IceServer > > ParseIceServersMessage(const Json::Value &message)
Definition: utils.cpp:75
Definition: alloc_driver.h:20
uint8_t type
Definition: pairing_connection.h:0