SubmitMediaInfoJobResult.cc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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/mts/model/SubmitMediaInfoJobResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Mts;
  19. using namespace AlibabaCloud::Mts::Model;
  20. SubmitMediaInfoJobResult::SubmitMediaInfoJobResult() :
  21. ServiceResult()
  22. {}
  23. SubmitMediaInfoJobResult::SubmitMediaInfoJobResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. SubmitMediaInfoJobResult::~SubmitMediaInfoJobResult()
  29. {}
  30. void SubmitMediaInfoJobResult::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 mediaInfoJobNode = value["MediaInfoJob"];
  37. if(!mediaInfoJobNode["JobId"].isNull())
  38. mediaInfoJob_.jobId = mediaInfoJobNode["JobId"].asString();
  39. if(!mediaInfoJobNode["UserData"].isNull())
  40. mediaInfoJob_.userData = mediaInfoJobNode["UserData"].asString();
  41. if(!mediaInfoJobNode["PipelineId"].isNull())
  42. mediaInfoJob_.pipelineId = mediaInfoJobNode["PipelineId"].asString();
  43. if(!mediaInfoJobNode["Async"].isNull())
  44. mediaInfoJob_.async = mediaInfoJobNode["Async"].asString() == "true";
  45. if(!mediaInfoJobNode["State"].isNull())
  46. mediaInfoJob_.state = mediaInfoJobNode["State"].asString();
  47. if(!mediaInfoJobNode["Code"].isNull())
  48. mediaInfoJob_.code = mediaInfoJobNode["Code"].asString();
  49. if(!mediaInfoJobNode["Message"].isNull())
  50. mediaInfoJob_.message = mediaInfoJobNode["Message"].asString();
  51. if(!mediaInfoJobNode["CreationTime"].isNull())
  52. mediaInfoJob_.creationTime = mediaInfoJobNode["CreationTime"].asString();
  53. auto inputNode = mediaInfoJobNode["Input"];
  54. if(!inputNode["Bucket"].isNull())
  55. mediaInfoJob_.input.bucket = inputNode["Bucket"].asString();
  56. if(!inputNode["Location"].isNull())
  57. mediaInfoJob_.input.location = inputNode["Location"].asString();
  58. if(!inputNode["Object"].isNull())
  59. mediaInfoJob_.input.object = inputNode["Object"].asString();
  60. auto propertiesNode = mediaInfoJobNode["Properties"];
  61. if(!propertiesNode["Width"].isNull())
  62. mediaInfoJob_.properties.width = propertiesNode["Width"].asString();
  63. if(!propertiesNode["Height"].isNull())
  64. mediaInfoJob_.properties.height = propertiesNode["Height"].asString();
  65. if(!propertiesNode["Bitrate"].isNull())
  66. mediaInfoJob_.properties.bitrate = propertiesNode["Bitrate"].asString();
  67. if(!propertiesNode["Duration"].isNull())
  68. mediaInfoJob_.properties.duration = propertiesNode["Duration"].asString();
  69. if(!propertiesNode["Fps"].isNull())
  70. mediaInfoJob_.properties.fps = propertiesNode["Fps"].asString();
  71. if(!propertiesNode["FileSize"].isNull())
  72. mediaInfoJob_.properties.fileSize = propertiesNode["FileSize"].asString();
  73. if(!propertiesNode["FileFormat"].isNull())
  74. mediaInfoJob_.properties.fileFormat = propertiesNode["FileFormat"].asString();
  75. auto streamsNode = propertiesNode["Streams"];
  76. auto allVideoStreamList = value["VideoStreamList"]["VideoStream"];
  77. for (auto value : allVideoStreamList)
  78. {
  79. MediaInfoJob::Properties::Streams::VideoStream videoStreamObject;
  80. if(!value["Index"].isNull())
  81. videoStreamObject.index = value["Index"].asString();
  82. if(!value["CodecName"].isNull())
  83. videoStreamObject.codecName = value["CodecName"].asString();
  84. if(!value["CodecLongName"].isNull())
  85. videoStreamObject.codecLongName = value["CodecLongName"].asString();
  86. if(!value["Profile"].isNull())
  87. videoStreamObject.profile = value["Profile"].asString();
  88. if(!value["CodecTimeBase"].isNull())
  89. videoStreamObject.codecTimeBase = value["CodecTimeBase"].asString();
  90. if(!value["CodecTagString"].isNull())
  91. videoStreamObject.codecTagString = value["CodecTagString"].asString();
  92. if(!value["CodecTag"].isNull())
  93. videoStreamObject.codecTag = value["CodecTag"].asString();
  94. if(!value["Width"].isNull())
  95. videoStreamObject.width = value["Width"].asString();
  96. if(!value["Height"].isNull())
  97. videoStreamObject.height = value["Height"].asString();
  98. if(!value["HasBFrames"].isNull())
  99. videoStreamObject.hasBFrames = value["HasBFrames"].asString();
  100. if(!value["Sar"].isNull())
  101. videoStreamObject.sar = value["Sar"].asString();
  102. if(!value["Dar"].isNull())
  103. videoStreamObject.dar = value["Dar"].asString();
  104. if(!value["PixFmt"].isNull())
  105. videoStreamObject.pixFmt = value["PixFmt"].asString();
  106. if(!value["Level"].isNull())
  107. videoStreamObject.level = value["Level"].asString();
  108. if(!value["Fps"].isNull())
  109. videoStreamObject.fps = value["Fps"].asString();
  110. if(!value["AvgFPS"].isNull())
  111. videoStreamObject.avgFPS = value["AvgFPS"].asString();
  112. if(!value["Timebase"].isNull())
  113. videoStreamObject.timebase = value["Timebase"].asString();
  114. if(!value["StartTime"].isNull())
  115. videoStreamObject.startTime = value["StartTime"].asString();
  116. if(!value["Duration"].isNull())
  117. videoStreamObject.duration = value["Duration"].asString();
  118. if(!value["Bitrate"].isNull())
  119. videoStreamObject.bitrate = value["Bitrate"].asString();
  120. if(!value["NumFrames"].isNull())
  121. videoStreamObject.numFrames = value["NumFrames"].asString();
  122. if(!value["Lang"].isNull())
  123. videoStreamObject.lang = value["Lang"].asString();
  124. if(!value["Rotate"].isNull())
  125. videoStreamObject.rotate = value["Rotate"].asString();
  126. auto networkCostNode = value["NetworkCost"];
  127. if(!networkCostNode["PreloadTime"].isNull())
  128. videoStreamObject.networkCost.preloadTime = networkCostNode["PreloadTime"].asString();
  129. if(!networkCostNode["CostBandwidth"].isNull())
  130. videoStreamObject.networkCost.costBandwidth = networkCostNode["CostBandwidth"].asString();
  131. if(!networkCostNode["AvgBitrate"].isNull())
  132. videoStreamObject.networkCost.avgBitrate = networkCostNode["AvgBitrate"].asString();
  133. mediaInfoJob_.properties.streams.videoStreamList.push_back(videoStreamObject);
  134. }
  135. auto allAudioStreamList = value["AudioStreamList"]["AudioStream"];
  136. for (auto value : allAudioStreamList)
  137. {
  138. MediaInfoJob::Properties::Streams::AudioStream audioStreamObject;
  139. if(!value["Index"].isNull())
  140. audioStreamObject.index = value["Index"].asString();
  141. if(!value["CodecName"].isNull())
  142. audioStreamObject.codecName = value["CodecName"].asString();
  143. if(!value["CodecTimeBase"].isNull())
  144. audioStreamObject.codecTimeBase = value["CodecTimeBase"].asString();
  145. if(!value["CodecLongName"].isNull())
  146. audioStreamObject.codecLongName = value["CodecLongName"].asString();
  147. if(!value["CodecTagString"].isNull())
  148. audioStreamObject.codecTagString = value["CodecTagString"].asString();
  149. if(!value["CodecTag"].isNull())
  150. audioStreamObject.codecTag = value["CodecTag"].asString();
  151. if(!value["SampleFmt"].isNull())
  152. audioStreamObject.sampleFmt = value["SampleFmt"].asString();
  153. if(!value["Samplerate"].isNull())
  154. audioStreamObject.samplerate = value["Samplerate"].asString();
  155. if(!value["Channels"].isNull())
  156. audioStreamObject.channels = value["Channels"].asString();
  157. if(!value["ChannelLayout"].isNull())
  158. audioStreamObject.channelLayout = value["ChannelLayout"].asString();
  159. if(!value["Timebase"].isNull())
  160. audioStreamObject.timebase = value["Timebase"].asString();
  161. if(!value["StartTime"].isNull())
  162. audioStreamObject.startTime = value["StartTime"].asString();
  163. if(!value["Duration"].isNull())
  164. audioStreamObject.duration = value["Duration"].asString();
  165. if(!value["Bitrate"].isNull())
  166. audioStreamObject.bitrate = value["Bitrate"].asString();
  167. if(!value["NumFrames"].isNull())
  168. audioStreamObject.numFrames = value["NumFrames"].asString();
  169. if(!value["Lang"].isNull())
  170. audioStreamObject.lang = value["Lang"].asString();
  171. mediaInfoJob_.properties.streams.audioStreamList.push_back(audioStreamObject);
  172. }
  173. auto allSubtitleStreamList = value["SubtitleStreamList"]["SubtitleStream"];
  174. for (auto value : allSubtitleStreamList)
  175. {
  176. MediaInfoJob::Properties::Streams::SubtitleStream subtitleStreamObject;
  177. if(!value["Index"].isNull())
  178. subtitleStreamObject.index = value["Index"].asString();
  179. if(!value["CodecName"].isNull())
  180. subtitleStreamObject.codecName = value["CodecName"].asString();
  181. if(!value["CodecTimeBase"].isNull())
  182. subtitleStreamObject.codecTimeBase = value["CodecTimeBase"].asString();
  183. if(!value["CodecLongName"].isNull())
  184. subtitleStreamObject.codecLongName = value["CodecLongName"].asString();
  185. if(!value["CodecTagString"].isNull())
  186. subtitleStreamObject.codecTagString = value["CodecTagString"].asString();
  187. if(!value["CodecTag"].isNull())
  188. subtitleStreamObject.codecTag = value["CodecTag"].asString();
  189. if(!value["Timebase"].isNull())
  190. subtitleStreamObject.timebase = value["Timebase"].asString();
  191. if(!value["StartTime"].isNull())
  192. subtitleStreamObject.startTime = value["StartTime"].asString();
  193. if(!value["Duration"].isNull())
  194. subtitleStreamObject.duration = value["Duration"].asString();
  195. if(!value["Lang"].isNull())
  196. subtitleStreamObject.lang = value["Lang"].asString();
  197. mediaInfoJob_.properties.streams.subtitleStreamList.push_back(subtitleStreamObject);
  198. }
  199. auto formatNode = propertiesNode["Format"];
  200. if(!formatNode["NumStreams"].isNull())
  201. mediaInfoJob_.properties.format.numStreams = formatNode["NumStreams"].asString();
  202. if(!formatNode["NumPrograms"].isNull())
  203. mediaInfoJob_.properties.format.numPrograms = formatNode["NumPrograms"].asString();
  204. if(!formatNode["FormatName"].isNull())
  205. mediaInfoJob_.properties.format.formatName = formatNode["FormatName"].asString();
  206. if(!formatNode["FormatLongName"].isNull())
  207. mediaInfoJob_.properties.format.formatLongName = formatNode["FormatLongName"].asString();
  208. if(!formatNode["StartTime"].isNull())
  209. mediaInfoJob_.properties.format.startTime = formatNode["StartTime"].asString();
  210. if(!formatNode["Duration"].isNull())
  211. mediaInfoJob_.properties.format.duration = formatNode["Duration"].asString();
  212. if(!formatNode["Size"].isNull())
  213. mediaInfoJob_.properties.format.size = formatNode["Size"].asString();
  214. if(!formatNode["Bitrate"].isNull())
  215. mediaInfoJob_.properties.format.bitrate = formatNode["Bitrate"].asString();
  216. auto mNSMessageResultNode = mediaInfoJobNode["MNSMessageResult"];
  217. if(!mNSMessageResultNode["MessageId"].isNull())
  218. mediaInfoJob_.mNSMessageResult.messageId = mNSMessageResultNode["MessageId"].asString();
  219. if(!mNSMessageResultNode["ErrorMessage"].isNull())
  220. mediaInfoJob_.mNSMessageResult.errorMessage = mNSMessageResultNode["ErrorMessage"].asString();
  221. if(!mNSMessageResultNode["ErrorCode"].isNull())
  222. mediaInfoJob_.mNSMessageResult.errorCode = mNSMessageResultNode["ErrorCode"].asString();
  223. }
  224. SubmitMediaInfoJobResult::MediaInfoJob SubmitMediaInfoJobResult::getMediaInfoJob()const
  225. {
  226. return mediaInfoJob_;
  227. }