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
17
18 #include <alibabacloud/oss/model/GetLiveChannelInfoResult.h>
19 #include <alibabacloud/oss/model/Owner.h>
20 #include <external/tinyxml2/tinyxml2.h>
21 #include <sstream>
22 #include "utils/Utils.h"
23 using namespace AlibabaCloud::OSS;
24 using namespace tinyxml2;
25
GetLiveChannelInfoResult()26 GetLiveChannelInfoResult::GetLiveChannelInfoResult() :
27 OssResult(),
28 fragDuration_(0),
29 fragCount_(0)
30 {
31
32 }
33
GetLiveChannelInfoResult(const std::string & result)34 GetLiveChannelInfoResult::GetLiveChannelInfoResult(const std::string& result):
35 GetLiveChannelInfoResult()
36 {
37 *this = result;
38 }
39
GetLiveChannelInfoResult(const std::shared_ptr<std::iostream> & result)40 GetLiveChannelInfoResult::GetLiveChannelInfoResult(const std::shared_ptr<std::iostream>& result):
41 GetLiveChannelInfoResult()
42 {
43 std::istreambuf_iterator<char> isb(*result.get()), end;
44 std::string str(isb, end);
45 *this = str;
46 }
47
operator =(const std::string & result)48 GetLiveChannelInfoResult& GetLiveChannelInfoResult::operator =(const std::string& result)
49 {
50 XMLDocument doc;
51 XMLError xml_err;
52 if ((xml_err = doc.Parse(result.c_str(), result.size())) == XML_SUCCESS) {
53 XMLElement* root =doc.RootElement();
54 if (root && !std::strncmp("LiveChannelConfiguration", root->Name(), 24)) {
55 XMLElement *node;
56
57 node = root->FirstChildElement("Description");
58 if(node && node->GetText())
59 {
60 description_ = node->GetText();
61 }
62
63 node = root->FirstChildElement("Status");
64 if(node && node->GetText())
65 {
66 status_ = ToLiveChannelStatusType(node->GetText());
67 }
68
69 XMLElement *targetNode = root->FirstChildElement("Target");
70 if(targetNode)
71 {
72 node = targetNode->FirstChildElement("Type");
73 if(node && node->GetText())
74 {
75 channelType_ = node->GetText();
76 }
77
78 node = targetNode->FirstChildElement("FragDuration");
79 if(node && node->GetText())
80 {
81 fragDuration_ = std::strtoull(node->GetText(), nullptr, 10);
82 }
83
84 node = targetNode->FirstChildElement("FragCount");
85 if(node && node->GetText())
86 {
87 fragCount_ = std::strtoull(node->GetText(), nullptr, 10);
88 }
89
90 node = targetNode->FirstChildElement("PlaylistName");
91 if(node && node->GetText())
92 {
93 playListName_ = node->GetText();
94 }
95 }
96 parseDone_ = true;
97 }
98 }
99 return *this;
100 }
101
Description() const102 const std::string& GetLiveChannelInfoResult::Description() const
103 {
104 return description_;
105 }
106
Status() const107 LiveChannelStatus GetLiveChannelInfoResult::Status() const
108 {
109 return status_;
110 }
111
Type() const112 const std::string& GetLiveChannelInfoResult::Type() const
113 {
114 return channelType_;
115 }
FragDuration() const116 uint64_t GetLiveChannelInfoResult::FragDuration() const
117 {
118 return fragDuration_;
119 }
120
FragCount() const121 uint64_t GetLiveChannelInfoResult::FragCount() const
122 {
123 return fragCount_;
124 }
125
PlaylistName() const126 const std::string& GetLiveChannelInfoResult::PlaylistName() const
127 {
128 return playListName_;
129 }
130