Benjamin Wright | 8efafdf | 2019-01-11 10:48:42 -0800 | [diff] [blame^] | 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 | |
| 11 | #include "test/call_config_utils.h" |
| 12 | |
| 13 | #include <string> |
| 14 | #include <vector> |
| 15 | |
| 16 | namespace webrtc { |
| 17 | namespace test { |
| 18 | |
| 19 | // Deserializes a JSON representation of the VideoReceiveStream::Config back |
| 20 | // into a valid object. This will not initialize the decoders or the renderer. |
| 21 | VideoReceiveStream::Config ParseVideoReceiveStreamJsonConfig( |
| 22 | webrtc::Transport* transport, |
| 23 | const Json::Value& json) { |
| 24 | auto receive_config = VideoReceiveStream::Config(transport); |
| 25 | for (const auto decoder_json : json["decoders"]) { |
| 26 | VideoReceiveStream::Decoder decoder; |
| 27 | decoder.video_format = |
| 28 | SdpVideoFormat(decoder_json["payload_name"].asString()); |
| 29 | decoder.payload_type = decoder_json["payload_type"].asInt64(); |
| 30 | for (const auto& params_json : decoder_json["codec_params"]) { |
| 31 | std::vector<std::string> members = params_json.getMemberNames(); |
| 32 | RTC_CHECK_EQ(members.size(), 1); |
| 33 | decoder.video_format.parameters[members[0]] = |
| 34 | params_json[members[0]].asString(); |
| 35 | } |
| 36 | receive_config.decoders.push_back(decoder); |
| 37 | } |
| 38 | receive_config.render_delay_ms = json["render_delay_ms"].asInt64(); |
| 39 | receive_config.target_delay_ms = json["target_delay_ms"].asInt64(); |
| 40 | receive_config.rtp.remote_ssrc = json["rtp"]["remote_ssrc"].asInt64(); |
| 41 | receive_config.rtp.local_ssrc = json["rtp"]["local_ssrc"].asInt64(); |
| 42 | receive_config.rtp.rtcp_mode = |
| 43 | json["rtp"]["rtcp_mode"].asString() == "RtcpMode::kCompound" |
| 44 | ? RtcpMode::kCompound |
| 45 | : RtcpMode::kReducedSize; |
| 46 | receive_config.rtp.remb = json["rtp"]["remb"].asBool(); |
| 47 | receive_config.rtp.transport_cc = json["rtp"]["transport_cc"].asBool(); |
| 48 | receive_config.rtp.nack.rtp_history_ms = |
| 49 | json["rtp"]["nack"]["rtp_history_ms"].asInt64(); |
| 50 | receive_config.rtp.ulpfec_payload_type = |
| 51 | json["rtp"]["ulpfec_payload_type"].asInt64(); |
| 52 | receive_config.rtp.red_payload_type = |
| 53 | json["rtp"]["red_payload_type"].asInt64(); |
| 54 | receive_config.rtp.rtx_ssrc = json["rtp"]["rtx_ssrc"].asInt64(); |
| 55 | |
| 56 | for (const auto& pl_json : json["rtp"]["rtx_payload_types"]) { |
| 57 | std::vector<std::string> members = pl_json.getMemberNames(); |
| 58 | RTC_CHECK_EQ(members.size(), 1); |
| 59 | Json::Value rtx_payload_type = pl_json[members[0]]; |
| 60 | receive_config.rtp.rtx_associated_payload_types[std::stoi(members[0])] = |
| 61 | rtx_payload_type.asInt64(); |
| 62 | } |
| 63 | for (const auto& ext_json : json["rtp"]["extensions"]) { |
| 64 | receive_config.rtp.extensions.emplace_back(ext_json["uri"].asString(), |
| 65 | ext_json["id"].asInt64(), |
| 66 | ext_json["encrypt"].asBool()); |
| 67 | } |
| 68 | return receive_config; |
| 69 | } |
| 70 | |
| 71 | } // namespace test. |
| 72 | } // namespace webrtc. |