Merge pull request #4676 from jmarshallnz/dont_set_scraper_on_tvshow_on_nfo
[vuplus_xbmc] / xbmc / utils / StreamDetails.h
1 #pragma once
2 /*
3  *      Copyright (C) 2005-2013 Team XBMC
4  *      http://xbmc.org
5  *
6  *  This Program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2, or (at your option)
9  *  any later version.
10  *
11  *  This Program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with XBMC; see the file COPYING.  If not, see
18  *  <http://www.gnu.org/licenses/>.
19  *
20  */
21
22 #include "utils/StdString.h"
23 #include "Archive.h"
24 #include "ISerializable.h"
25 #include <vector>
26
27 class CStreamDetails;
28
29 class CStreamDetail : public IArchivable, public ISerializable
30 {
31 public:
32   enum StreamType {
33     VIDEO,
34     AUDIO,
35     SUBTITLE
36   };
37
38   CStreamDetail(StreamType type) : m_eType(type), m_pParent(NULL) {};
39   virtual void Archive(CArchive& ar);
40   virtual void Serialize(CVariant& value) const;
41   virtual bool IsWorseThan(CStreamDetail *that) { return true; };
42
43   const StreamType m_eType;
44
45 protected:
46   CStreamDetails *m_pParent;
47   friend class CStreamDetails;
48 };
49
50 class CStreamDetailVideo : public CStreamDetail
51 {
52 public:
53   CStreamDetailVideo();
54   virtual void Archive(CArchive& ar);
55   virtual void Serialize(CVariant& value) const;
56   virtual bool IsWorseThan(CStreamDetail *that);
57
58   int m_iWidth;
59   int m_iHeight;
60   float m_fAspect;
61   int m_iDuration;
62   CStdString m_strCodec;
63   std::string m_strStereoMode;
64 };
65
66 class CStreamDetailAudio : public CStreamDetail
67 {
68 public:
69   CStreamDetailAudio();
70   virtual void Archive(CArchive& ar);
71   virtual void Serialize(CVariant& value) const;
72   virtual bool IsWorseThan(CStreamDetail *that);
73
74   int m_iChannels;
75   CStdString m_strCodec;
76   CStdString m_strLanguage;
77 };
78
79 class CStreamDetailSubtitle : public CStreamDetail
80 {
81 public:
82   CStreamDetailSubtitle();
83   CStreamDetailSubtitle& operator=(const CStreamDetailSubtitle &that);
84   virtual void Archive(CArchive& ar);
85   virtual void Serialize(CVariant& value) const;
86   virtual bool IsWorseThan(CStreamDetail *that);
87
88   CStdString m_strLanguage;
89 };
90
91 class CStreamDetails : public IArchivable, public ISerializable
92 {
93 public:
94   CStreamDetails() { Reset(); };
95   CStreamDetails(const CStreamDetails &that);
96   ~CStreamDetails() { Reset(); };
97   CStreamDetails& operator=(const CStreamDetails &that);
98   bool operator ==(const CStreamDetails &that) const;
99   bool operator !=(const CStreamDetails &that) const;
100
101   static CStdString VideoDimsToResolutionDescription(int iWidth, int iHeight);
102   static CStdString VideoAspectToAspectDescription(float fAspect);
103
104   bool HasItems(void) const { return m_vecItems.size() > 0; };
105   int GetStreamCount(CStreamDetail::StreamType type) const;
106   int GetVideoStreamCount(void) const;
107   int GetAudioStreamCount(void) const;
108   int GetSubtitleStreamCount(void) const;
109   const CStreamDetail* GetNthStream(CStreamDetail::StreamType type, int idx) const;
110
111   CStdString GetVideoCodec(int idx = 0) const;
112   float GetVideoAspect(int idx = 0) const;
113   int GetVideoWidth(int idx = 0) const;
114   int GetVideoHeight(int idx = 0) const;
115   int GetVideoDuration(int idx = 0) const;
116   void SetVideoDuration(int idx, const int duration);
117   std::string GetStereoMode(int idx = 0) const;
118
119   CStdString GetAudioCodec(int idx = 0) const;
120   CStdString GetAudioLanguage(int idx = 0) const;
121   int GetAudioChannels(int idx = 0) const;
122
123   CStdString GetSubtitleLanguage(int idx = 0) const;
124
125   void AddStream(CStreamDetail *item);
126   void Reset(void);
127   void DetermineBestStreams(void);
128
129   virtual void Archive(CArchive& ar);
130   virtual void Serialize(CVariant& value) const;
131
132 private:
133   CStreamDetail *NewStream(CStreamDetail::StreamType type);
134   std::vector<CStreamDetail *> m_vecItems;
135   CStreamDetailVideo *m_pBestVideo;
136   CStreamDetailAudio *m_pBestAudio;
137   CStreamDetailSubtitle *m_pBestSubtitle;
138 };