GetTranscodeTaskResult.cc 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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/vod/model/GetTranscodeTaskResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Vod;
  19. using namespace AlibabaCloud::Vod::Model;
  20. GetTranscodeTaskResult::GetTranscodeTaskResult() :
  21. ServiceResult()
  22. {}
  23. GetTranscodeTaskResult::GetTranscodeTaskResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. GetTranscodeTaskResult::~GetTranscodeTaskResult()
  29. {}
  30. void GetTranscodeTaskResult::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 transcodeTaskNode = value["TranscodeTask"];
  37. if(!transcodeTaskNode["TranscodeTaskId"].isNull())
  38. transcodeTask_.transcodeTaskId = transcodeTaskNode["TranscodeTaskId"].asString();
  39. if(!transcodeTaskNode["VideoId"].isNull())
  40. transcodeTask_.videoId = transcodeTaskNode["VideoId"].asString();
  41. if(!transcodeTaskNode["TaskStatus"].isNull())
  42. transcodeTask_.taskStatus = transcodeTaskNode["TaskStatus"].asString();
  43. if(!transcodeTaskNode["CreationTime"].isNull())
  44. transcodeTask_.creationTime = transcodeTaskNode["CreationTime"].asString();
  45. if(!transcodeTaskNode["CompleteTime"].isNull())
  46. transcodeTask_.completeTime = transcodeTaskNode["CompleteTime"].asString();
  47. if(!transcodeTaskNode["Trigger"].isNull())
  48. transcodeTask_.trigger = transcodeTaskNode["Trigger"].asString();
  49. if(!transcodeTaskNode["TranscodeTemplateGroupId"].isNull())
  50. transcodeTask_.transcodeTemplateGroupId = transcodeTaskNode["TranscodeTemplateGroupId"].asString();
  51. auto allTranscodeJobInfoList = value["TranscodeJobInfoList"]["TranscodeJobInfo"];
  52. for (auto value : allTranscodeJobInfoList)
  53. {
  54. TranscodeTask::TranscodeJobInfo transcodeJobInfoObject;
  55. if(!value["TranscodeJobId"].isNull())
  56. transcodeJobInfoObject.transcodeJobId = value["TranscodeJobId"].asString();
  57. if(!value["TranscodeTemplateId"].isNull())
  58. transcodeJobInfoObject.transcodeTemplateId = value["TranscodeTemplateId"].asString();
  59. if(!value["TranscodeJobStatus"].isNull())
  60. transcodeJobInfoObject.transcodeJobStatus = value["TranscodeJobStatus"].asString();
  61. if(!value["CreationTime"].isNull())
  62. transcodeJobInfoObject.creationTime = value["CreationTime"].asString();
  63. if(!value["CompleteTime"].isNull())
  64. transcodeJobInfoObject.completeTime = value["CompleteTime"].asString();
  65. if(!value["TranscodeProgress"].isNull())
  66. transcodeJobInfoObject.transcodeProgress = std::stol(value["TranscodeProgress"].asString());
  67. if(!value["InputFileUrl"].isNull())
  68. transcodeJobInfoObject.inputFileUrl = value["InputFileUrl"].asString();
  69. if(!value["Priority"].isNull())
  70. transcodeJobInfoObject.priority = value["Priority"].asString();
  71. if(!value["ErrorCode"].isNull())
  72. transcodeJobInfoObject.errorCode = value["ErrorCode"].asString();
  73. if(!value["ErrorMessage"].isNull())
  74. transcodeJobInfoObject.errorMessage = value["ErrorMessage"].asString();
  75. if(!value["Definition"].isNull())
  76. transcodeJobInfoObject.definition = value["Definition"].asString();
  77. auto outputFileNode = value["OutputFile"];
  78. if(!outputFileNode["Width"].isNull())
  79. transcodeJobInfoObject.outputFile.width = outputFileNode["Width"].asString();
  80. if(!outputFileNode["Height"].isNull())
  81. transcodeJobInfoObject.outputFile.height = outputFileNode["Height"].asString();
  82. if(!outputFileNode["Bitrate"].isNull())
  83. transcodeJobInfoObject.outputFile.bitrate = outputFileNode["Bitrate"].asString();
  84. if(!outputFileNode["Fps"].isNull())
  85. transcodeJobInfoObject.outputFile.fps = outputFileNode["Fps"].asString();
  86. if(!outputFileNode["Format"].isNull())
  87. transcodeJobInfoObject.outputFile.format = outputFileNode["Format"].asString();
  88. if(!outputFileNode["Duration"].isNull())
  89. transcodeJobInfoObject.outputFile.duration = outputFileNode["Duration"].asString();
  90. if(!outputFileNode["Filesize"].isNull())
  91. transcodeJobInfoObject.outputFile.filesize = std::stol(outputFileNode["Filesize"].asString());
  92. if(!outputFileNode["Encryption"].isNull())
  93. transcodeJobInfoObject.outputFile.encryption = outputFileNode["Encryption"].asString();
  94. if(!outputFileNode["AudioStreamList"].isNull())
  95. transcodeJobInfoObject.outputFile.audioStreamList = outputFileNode["AudioStreamList"].asString();
  96. if(!outputFileNode["VideoStreamList"].isNull())
  97. transcodeJobInfoObject.outputFile.videoStreamList = outputFileNode["VideoStreamList"].asString();
  98. if(!outputFileNode["SubtitleStreamList"].isNull())
  99. transcodeJobInfoObject.outputFile.subtitleStreamList = outputFileNode["SubtitleStreamList"].asString();
  100. if(!outputFileNode["OutputFileUrl"].isNull())
  101. transcodeJobInfoObject.outputFile.outputFileUrl = outputFileNode["OutputFileUrl"].asString();
  102. auto allWatermarkIdList = outputFileNode["WatermarkIdList"]["WatermarkId"];
  103. for (auto value : allWatermarkIdList)
  104. transcodeJobInfoObject.outputFile.watermarkIdList.push_back(value.asString());
  105. transcodeTask_.transcodeJobInfoList.push_back(transcodeJobInfoObject);
  106. }
  107. }
  108. GetTranscodeTaskResult::TranscodeTask GetTranscodeTaskResult::getTranscodeTask()const
  109. {
  110. return transcodeTask_;
  111. }