changed: update version strings for beta4
[xbmc.git] / xbmc / utils / StreamDetails.h
blobd021fd122ea2f230f939b860bf5e2e8250135f67
1 #pragma once
2 /*
3 * Copyright (C) 2005-2008 Team XBMC
4 * http://www.xbmc.org
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.
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.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, write to
18 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19 * http://www.gnu.org/copyleft/gpl.html
23 #include "Archive.h"
24 #include <vector>
26 class CStreamDetails;
28 class CStreamDetail : public ISerializable
30 public:
31 enum StreamType {
32 VIDEO,
33 AUDIO,
34 SUBTITLE
37 CStreamDetail(StreamType type) : m_eType(type) {};
38 virtual void Serialize(CArchive& ar);
39 virtual bool IsWorseThan(CStreamDetail *that) { return true; };
41 const StreamType m_eType;
43 protected:
44 CStreamDetails *m_pParent;
45 friend class CStreamDetails;
48 class CStreamDetailVideo : public CStreamDetail
50 public:
51 CStreamDetailVideo();
52 virtual void Serialize(CArchive& ar);
53 virtual bool IsWorseThan(CStreamDetail *that);
55 int m_iWidth;
56 int m_iHeight;
57 float m_fAspect;
58 int m_iDuration;
59 CStdString m_strCodec;
62 class CStreamDetailAudio : public CStreamDetail
64 public:
65 CStreamDetailAudio();
66 virtual void Serialize(CArchive& ar);
67 virtual bool IsWorseThan(CStreamDetail *that);
69 int m_iChannels;
70 CStdString m_strCodec;
71 CStdString m_strLanguage;
72 private:
73 int GetCodecPriority() const;
76 class CStreamDetailSubtitle : public CStreamDetail
78 public:
79 CStreamDetailSubtitle();
80 virtual void Serialize(CArchive& ar);
81 virtual bool IsWorseThan(CStreamDetail *that);
83 CStdString m_strLanguage;
86 class CStreamDetails : public ISerializable
88 public:
89 CStreamDetails() { Reset(); };
90 CStreamDetails(const CStreamDetails &that);
91 ~CStreamDetails() { Reset(); };
92 CStreamDetails& operator=(const CStreamDetails &that);
94 static CStdString VideoDimsToResolutionDescription(int iWidth, int iHeight);
95 static CStdString VideoAspectToAspectDescription(float fAspect);
97 bool HasItems(void) const { return m_vecItems.size() > 0; };
98 int GetStreamCount(CStreamDetail::StreamType type) const;
99 int GetVideoStreamCount(void) const;
100 int GetAudioStreamCount(void) const;
101 int GetSubtitleStreamCount(void) const;
102 const CStreamDetail* GetNthStream(CStreamDetail::StreamType type, int idx) const;
104 CStdString GetVideoCodec(int idx = 0) const;
105 float GetVideoAspect(int idx = 0) const;
106 int GetVideoWidth(int idx = 0) const;
107 int GetVideoHeight(int idx = 0) const;
108 int GetVideoDuration(int idx = 0) const;
110 CStdString GetAudioCodec(int idx = 0) const;
111 CStdString GetAudioLanguage(int idx = 0) const;
112 int GetAudioChannels(int idx = 0) const;
114 CStdString GetSubtitleLanguage(int idx = 0) const;
116 void AddStream(CStreamDetail *item);
117 void Reset(void);
118 void DetermineBestStreams(void);
120 virtual void Serialize(CArchive& ar);
122 // Language to use for "best" subtitle stream
123 CStdString m_strLanguage;
125 private:
126 CStreamDetail *NewStream(CStreamDetail::StreamType type);
127 std::vector<CStreamDetail *> m_vecItems;
128 CStreamDetailVideo *m_pBestVideo;
129 CStreamDetailAudio *m_pBestAudio;
130 CStreamDetailSubtitle *m_pBestSubtitle;
133 class IStreamDetailsObserver
135 public:
136 virtual ~IStreamDetailsObserver() {}
137 virtual void OnStreamDetails(const CStreamDetails &details, const CStdString &strFileName, long lFileId) = 0;