DescribeHlsLiveStreamRealTimeBpsDataResult.cc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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/DescribeHlsLiveStreamRealTimeBpsDataResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Live;
  19. using namespace AlibabaCloud::Live::Model;
  20. DescribeHlsLiveStreamRealTimeBpsDataResult::DescribeHlsLiveStreamRealTimeBpsDataResult() :
  21. ServiceResult()
  22. {}
  23. DescribeHlsLiveStreamRealTimeBpsDataResult::DescribeHlsLiveStreamRealTimeBpsDataResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeHlsLiveStreamRealTimeBpsDataResult::~DescribeHlsLiveStreamRealTimeBpsDataResult()
  29. {}
  30. void DescribeHlsLiveStreamRealTimeBpsDataResult::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 allUsageDataNode = value["UsageData"]["UsageDataPerDomain"];
  37. for (auto valueUsageDataUsageDataPerDomain : allUsageDataNode)
  38. {
  39. UsageDataPerDomain usageDataObject;
  40. if(!valueUsageDataUsageDataPerDomain["DomainName"].isNull())
  41. usageDataObject.domainName = valueUsageDataUsageDataPerDomain["DomainName"].asString();
  42. auto allStreamInfosNode = allUsageDataNode["StreamInfos"]["StreamInfo"];
  43. for (auto allUsageDataNodeStreamInfosStreamInfo : allStreamInfosNode)
  44. {
  45. UsageDataPerDomain::StreamInfo streamInfosObject;
  46. if(!allUsageDataNodeStreamInfosStreamInfo["StreamName"].isNull())
  47. streamInfosObject.streamName = allUsageDataNodeStreamInfosStreamInfo["StreamName"].asString();
  48. auto allInfosNode = allStreamInfosNode["Infos"]["Info"];
  49. for (auto allStreamInfosNodeInfosInfo : allInfosNode)
  50. {
  51. UsageDataPerDomain::StreamInfo::Info infosObject;
  52. if(!allStreamInfosNodeInfosInfo["DownFlow"].isNull())
  53. infosObject.downFlow = std::stof(allStreamInfosNodeInfosInfo["DownFlow"].asString());
  54. if(!allStreamInfosNodeInfosInfo["Rate"].isNull())
  55. infosObject.rate = allStreamInfosNodeInfosInfo["Rate"].asString();
  56. if(!allStreamInfosNodeInfosInfo["Online"].isNull())
  57. infosObject.online = std::stof(allStreamInfosNodeInfosInfo["Online"].asString());
  58. streamInfosObject.infos.push_back(infosObject);
  59. }
  60. usageDataObject.streamInfos.push_back(streamInfosObject);
  61. }
  62. usageData_.push_back(usageDataObject);
  63. }
  64. if(!value["Time"].isNull())
  65. time_ = value["Time"].asString();
  66. }
  67. std::vector<DescribeHlsLiveStreamRealTimeBpsDataResult::UsageDataPerDomain> DescribeHlsLiveStreamRealTimeBpsDataResult::getUsageData()const
  68. {
  69. return usageData_;
  70. }
  71. std::string DescribeHlsLiveStreamRealTimeBpsDataResult::getTime()const
  72. {
  73. return time_;
  74. }