/*
 * Copyright 2009-2017 Alibaba Cloud All rights reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <alibabacloud/cdn/model/DescribeLiveStreamFrameInfoResult.h>
#include <json/json.h>

using namespace AlibabaCloud::Cdn;
using namespace AlibabaCloud::Cdn::Model;

DescribeLiveStreamFrameInfoResult::DescribeLiveStreamFrameInfoResult() :
	ServiceResult()
{}

DescribeLiveStreamFrameInfoResult::DescribeLiveStreamFrameInfoResult(const std::string &payload) :
	ServiceResult()
{
	parse(payload);
}

DescribeLiveStreamFrameInfoResult::~DescribeLiveStreamFrameInfoResult()
{}

void DescribeLiveStreamFrameInfoResult::parse(const std::string &payload)
{
	Json::Reader reader;
	Json::Value value;
	reader.parse(payload, value);

	setRequestId(value["RequestId"].asString());
	auto allFrameDataInfos = value["FrameDataInfos"]["FrameDataModel"];
	for (auto value : allFrameDataInfos)
	{
		FrameDataModel frameDataInfosObject;
		if(!value["Time"].isNull())
			frameDataInfosObject.time = value["Time"].asString();
		if(!value["Stream"].isNull())
			frameDataInfosObject.stream = value["Stream"].asString();
		if(!value["ClientAddr"].isNull())
			frameDataInfosObject.clientAddr = value["ClientAddr"].asString();
		if(!value["Server"].isNull())
			frameDataInfosObject.server = value["Server"].asString();
		if(!value["AudioRate"].isNull())
			frameDataInfosObject.audioRate = std::stof(value["AudioRate"].asString());
		if(!value["AudioByte"].isNull())
			frameDataInfosObject.audioByte = std::stof(value["AudioByte"].asString());
		if(!value["FrameRate"].isNull())
			frameDataInfosObject.frameRate = std::stof(value["FrameRate"].asString());
		if(!value["FrameByte"].isNull())
			frameDataInfosObject.frameByte = std::stof(value["FrameByte"].asString());
		frameDataInfos_.push_back(frameDataInfosObject);
	}

}

std::vector<DescribeLiveStreamFrameInfoResult::FrameDataModel> DescribeLiveStreamFrameInfoResult::getFrameDataInfos()const
{
	return frameDataInfos_;
}

