summaryrefslogtreecommitdiff
path: root/Stream.cpp
blob: 7c02b5ee0e7b0942733b9c6ecf8ad88ce44311d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "Stream.h"
#include <Poco/Format.h>

namespace plexclient
{

Stream::Stream(Poco::XML::Node* pNode)
{	
	if(Poco::icompare(pNode->nodeName(), "Stream") == 0) {

		Poco::XML::AutoPtr<Poco::XML::NamedNodeMap> pAttribs = pNode->attributes();
		
		m_bSelected = GetNodeValueAsBool(pAttribs->getNamedItem("selected"));
		m_iID = GetNodeValueAsInt(pAttribs->getNamedItem("id"));
		m_iStreamType = GetNodeValueAsInt(pAttribs->getNamedItem("streamType"));
		m_iIndex = GetNodeValueAsInt(pAttribs->getNamedItem("index"));
		m_iChannels = GetNodeValueAsInt(pAttribs->getNamedItem("channels"));
		m_sCodec = GetNodeValue(pAttribs->getNamedItem("codec"));
		m_sCodecId = GetNodeValue(pAttribs->getNamedItem("codecID"));
		m_sLanguage = GetNodeValue(pAttribs->getNamedItem("language"));
		m_sLanguageCode = GetNodeValue(pAttribs->getNamedItem("languageCode"));
		m_eStreamType = GetNodeValueAsStreamType(pAttribs->getNamedItem("streamType"));

		pAttribs->release();
	}
}

std::string Stream::GetSetStreamQuery()
{
	if(m_eStreamType == sAUDIO)	return Poco::format("audioStreamID=%d", m_iID);
	else if(m_eStreamType == sSUBTITLE && m_iID >= 0)	return Poco::format("subtitleStreamID=%d", m_iID);
	else if(m_eStreamType == sSUBTITLE && m_iID < 0)	return "subtitleStreamID=";
	else return "";
}

} // namespace