diff options
Diffstat (limited to 'xbmc/utils/StreamDetails.h')
| -rw-r--r-- | xbmc/utils/StreamDetails.h | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/xbmc/utils/StreamDetails.h b/xbmc/utils/StreamDetails.h new file mode 100644 index 0000000..fae9d46 --- /dev/null +++ b/xbmc/utils/StreamDetails.h | |||
| @@ -0,0 +1,137 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "ISerializable.h" | ||
| 12 | #include "utils/IArchivable.h" | ||
| 13 | |||
| 14 | #include <memory> | ||
| 15 | #include <string> | ||
| 16 | #include <vector> | ||
| 17 | |||
| 18 | class CStreamDetails; | ||
| 19 | class CVariant; | ||
| 20 | struct VideoStreamInfo; | ||
| 21 | struct AudioStreamInfo; | ||
| 22 | struct SubtitleStreamInfo; | ||
| 23 | |||
| 24 | class CStreamDetail : public IArchivable, public ISerializable | ||
| 25 | { | ||
| 26 | public: | ||
| 27 | enum StreamType { | ||
| 28 | VIDEO, | ||
| 29 | AUDIO, | ||
| 30 | SUBTITLE | ||
| 31 | }; | ||
| 32 | |||
| 33 | explicit CStreamDetail(StreamType type) : m_eType(type), m_pParent(NULL) {}; | ||
| 34 | virtual ~CStreamDetail() = default; | ||
| 35 | virtual bool IsWorseThan(const CStreamDetail &that) const = 0; | ||
| 36 | |||
| 37 | const StreamType m_eType; | ||
| 38 | |||
| 39 | protected: | ||
| 40 | CStreamDetails *m_pParent; | ||
| 41 | friend class CStreamDetails; | ||
| 42 | }; | ||
| 43 | |||
| 44 | class CStreamDetailVideo final : public CStreamDetail | ||
| 45 | { | ||
| 46 | public: | ||
| 47 | CStreamDetailVideo(); | ||
| 48 | CStreamDetailVideo(const VideoStreamInfo &info, int duration = 0); | ||
| 49 | void Archive(CArchive& ar) override; | ||
| 50 | void Serialize(CVariant& value) const override; | ||
| 51 | bool IsWorseThan(const CStreamDetail &that) const override; | ||
| 52 | |||
| 53 | int m_iWidth = 0; | ||
| 54 | int m_iHeight = 0; | ||
| 55 | float m_fAspect = 0.0; | ||
| 56 | int m_iDuration = 0; | ||
| 57 | std::string m_strCodec; | ||
| 58 | std::string m_strStereoMode; | ||
| 59 | std::string m_strLanguage; | ||
| 60 | }; | ||
| 61 | |||
| 62 | class CStreamDetailAudio final : public CStreamDetail | ||
| 63 | { | ||
| 64 | public: | ||
| 65 | CStreamDetailAudio(); | ||
| 66 | CStreamDetailAudio(const AudioStreamInfo &info); | ||
| 67 | void Archive(CArchive& ar) override; | ||
| 68 | void Serialize(CVariant& value) const override; | ||
| 69 | bool IsWorseThan(const CStreamDetail &that) const override; | ||
| 70 | |||
| 71 | int m_iChannels = -1; | ||
| 72 | std::string m_strCodec; | ||
| 73 | std::string m_strLanguage; | ||
| 74 | }; | ||
| 75 | |||
| 76 | class CStreamDetailSubtitle final : public CStreamDetail | ||
| 77 | { | ||
| 78 | public: | ||
| 79 | CStreamDetailSubtitle(); | ||
| 80 | CStreamDetailSubtitle(const SubtitleStreamInfo &info); | ||
| 81 | CStreamDetailSubtitle& operator=(const CStreamDetailSubtitle &that); | ||
| 82 | void Archive(CArchive& ar) override; | ||
| 83 | void Serialize(CVariant& value) const override; | ||
| 84 | bool IsWorseThan(const CStreamDetail &that) const override; | ||
| 85 | |||
| 86 | std::string m_strLanguage; | ||
| 87 | }; | ||
| 88 | |||
| 89 | class CStreamDetails final : public IArchivable, public ISerializable | ||
| 90 | { | ||
| 91 | public: | ||
| 92 | CStreamDetails() { Reset(); }; | ||
| 93 | CStreamDetails(const CStreamDetails &that); | ||
| 94 | CStreamDetails& operator=(const CStreamDetails &that); | ||
| 95 | bool operator ==(const CStreamDetails &that) const; | ||
| 96 | bool operator !=(const CStreamDetails &that) const; | ||
| 97 | |||
| 98 | static std::string VideoDimsToResolutionDescription(int iWidth, int iHeight); | ||
| 99 | static std::string VideoAspectToAspectDescription(float fAspect); | ||
| 100 | |||
| 101 | bool HasItems(void) const { return m_vecItems.size() > 0; }; | ||
| 102 | int GetStreamCount(CStreamDetail::StreamType type) const; | ||
| 103 | int GetVideoStreamCount(void) const; | ||
| 104 | int GetAudioStreamCount(void) const; | ||
| 105 | int GetSubtitleStreamCount(void) const; | ||
| 106 | const CStreamDetail* GetNthStream(CStreamDetail::StreamType type, int idx) const; | ||
| 107 | |||
| 108 | std::string GetVideoCodec(int idx = 0) const; | ||
| 109 | float GetVideoAspect(int idx = 0) const; | ||
| 110 | int GetVideoWidth(int idx = 0) const; | ||
| 111 | int GetVideoHeight(int idx = 0) const; | ||
| 112 | int GetVideoDuration(int idx = 0) const; | ||
| 113 | void SetVideoDuration(int idx, const int duration); | ||
| 114 | std::string GetStereoMode(int idx = 0) const; | ||
| 115 | std::string GetVideoLanguage(int idx = 0) const; | ||
| 116 | |||
| 117 | std::string GetAudioCodec(int idx = 0) const; | ||
| 118 | std::string GetAudioLanguage(int idx = 0) const; | ||
| 119 | int GetAudioChannels(int idx = 0) const; | ||
| 120 | |||
| 121 | std::string GetSubtitleLanguage(int idx = 0) const; | ||
| 122 | |||
| 123 | void AddStream(CStreamDetail *item); | ||
| 124 | void Reset(void); | ||
| 125 | void DetermineBestStreams(void); | ||
| 126 | |||
| 127 | void Archive(CArchive& ar) override; | ||
| 128 | void Serialize(CVariant& value) const override; | ||
| 129 | |||
| 130 | bool SetStreams(const VideoStreamInfo& videoInfo, int videoDuration, const AudioStreamInfo& audioInfo, const SubtitleStreamInfo& subtitleInfo); | ||
| 131 | private: | ||
| 132 | CStreamDetail *NewStream(CStreamDetail::StreamType type); | ||
| 133 | std::vector<std::unique_ptr<CStreamDetail>> m_vecItems; | ||
| 134 | const CStreamDetailVideo *m_pBestVideo; | ||
| 135 | const CStreamDetailAudio *m_pBestAudio; | ||
| 136 | const CStreamDetailSubtitle *m_pBestSubtitle; | ||
| 137 | }; | ||
