DescribeCasterLayoutsResult.cc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright 2009-2017 Alibaba Cloud All rights reserved.
  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. #include <alibabacloud/live/model/DescribeCasterLayoutsResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Live;
  19. using namespace AlibabaCloud::Live::Model;
  20. DescribeCasterLayoutsResult::DescribeCasterLayoutsResult() :
  21. ServiceResult()
  22. {}
  23. DescribeCasterLayoutsResult::DescribeCasterLayoutsResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeCasterLayoutsResult::~DescribeCasterLayoutsResult()
  29. {}
  30. void DescribeCasterLayoutsResult::parse(const std::string &payload)
  31. {
  32. Json::Reader reader;
  33. Json::Value value;
  34. reader.parse(payload, value);
  35. setRequestId(value["RequestId"].asString());
  36. auto allLayouts = value["Layouts"]["Layout"];
  37. for (auto value : allLayouts)
  38. {
  39. Layout layoutsObject;
  40. if(!value["LayoutId"].isNull())
  41. layoutsObject.layoutId = value["LayoutId"].asString();
  42. auto allVideoLayers = value["VideoLayers"]["VideoLayer"];
  43. for (auto value : allVideoLayers)
  44. {
  45. Layout::VideoLayer videoLayersObject;
  46. if(!value["FillMode"].isNull())
  47. videoLayersObject.fillMode = value["FillMode"].asString();
  48. if(!value["HeightNormalized"].isNull())
  49. videoLayersObject.heightNormalized = std::stof(value["HeightNormalized"].asString());
  50. if(!value["WidthNormalized"].isNull())
  51. videoLayersObject.widthNormalized = std::stof(value["WidthNormalized"].asString());
  52. if(!value["PositionRefer"].isNull())
  53. videoLayersObject.positionRefer = value["PositionRefer"].asString();
  54. if(!value["FixedDelayDuration"].isNull())
  55. videoLayersObject.fixedDelayDuration = std::stoi(value["FixedDelayDuration"].asString());
  56. auto allPositionNormalizeds = value["PositionNormalizeds"]["Position"];
  57. for (auto value : allPositionNormalizeds)
  58. videoLayersObject.positionNormalizeds.push_back(value.asString());
  59. layoutsObject.videoLayers.push_back(videoLayersObject);
  60. }
  61. auto allAudioLayers = value["AudioLayers"]["AudioLayer"];
  62. for (auto value : allAudioLayers)
  63. {
  64. Layout::AudioLayer audioLayersObject;
  65. if(!value["VolumeRate"].isNull())
  66. audioLayersObject.volumeRate = std::stof(value["VolumeRate"].asString());
  67. if(!value["ValidChannel"].isNull())
  68. audioLayersObject.validChannel = value["ValidChannel"].asString();
  69. if(!value["FixedDelayDuration"].isNull())
  70. audioLayersObject.fixedDelayDuration = std::stoi(value["FixedDelayDuration"].asString());
  71. layoutsObject.audioLayers.push_back(audioLayersObject);
  72. }
  73. auto allBlendList = value["BlendList"]["LocationId"];
  74. for (auto value : allBlendList)
  75. layoutsObject.blendList.push_back(value.asString());
  76. auto allMixList = value["MixList"]["LocationId"];
  77. for (auto value : allMixList)
  78. layoutsObject.mixList.push_back(value.asString());
  79. layouts_.push_back(layoutsObject);
  80. }
  81. if(!value["Total"].isNull())
  82. total_ = std::stoi(value["Total"].asString());
  83. }
  84. std::vector<DescribeCasterLayoutsResult::Layout> DescribeCasterLayoutsResult::getLayouts()const
  85. {
  86. return layouts_;
  87. }
  88. int DescribeCasterLayoutsResult::getTotal()const
  89. {
  90. return total_;
  91. }