]> git.vomp.tv Git - vompclient.git/blob - tvmedia.h
Fix text corruption in channel number display on live tv
[vompclient.git] / tvmedia.h
1 /*
2     Copyright 2014 Marten Richter
3
4     This file is part of VOMP.
5
6     VOMP 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 of the License, or
9     (at your option) any later version.
10
11     VOMP 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 VOMP; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 #ifndef TVMEDIA_H
22 #define TVMEDIA_H
23
24 #include "defines.h"
25 #include <vector>
26 #include <string>
27
28 class MovieInfo;
29 class SeriesInfo;
30
31
32 class TVMediaInfo
33 {
34 friend class VDR;
35 public:
36         TVMediaInfo();
37         TVMediaInfo(const TVMediaInfo& info);
38
39         friend bool operator<(const TVMediaInfo& rhs, const TVMediaInfo& lhs);
40         friend bool operator==(const TVMediaInfo& rhs, const TVMediaInfo& lhs);
41
42         void setSeasonThumb() { type_pict=2; container=0; container_member=0;};
43         void setPosterThumb() { type_pict=1; container=0; container_member=0;};
44         void setElement(int cont,int memb) { type_pict=0; container=cont; container_member=memb;};
45         void setMovieInfo(const MovieInfo * mi);
46         void setSeriesInfo(const SeriesInfo * si);
47         void setPosterThumb(const char* recname);
48         void setPosterThumb(int channel, int eventid);
49         void setChannelLogo(int channel);
50         void setStaticArtwork(int artwork);
51         void setStaticFallback(int fallback);
52         int getType() {return type;};
53         int getPrimaryID() {return primary_id;};
54         int getSecondaryID() {return secondary_id;};
55         int getStaticFallback() {return static_fallback;};
56
57 private:
58         int type; // 1 movie or 2 series or 3 unknown recording or 4 static artwork
59         int primary_id; //movie or series_id
60         int secondary_id;  //0 or episode id
61         int type_pict; // 0 full info, 1 poster thumb, 2 season thumb
62         int container; // indices the dataelements with picture in movieinfo or seriesinfo
63         int container_member; // index into the container
64         std::string primary_name;
65         int static_fallback; // id of static replacement in case resource is not available
66 };
67
68 struct TVMedia
69 {
70         unsigned int width;
71         unsigned int height;
72
73         // no filename, file handling is only on the server
74         TVMediaInfo info;
75
76 };
77
78 typedef std::vector<TVMedia> TVMedias;
79
80 struct Actor
81 {
82         std::string name;
83         std::string role;
84         TVMedia thumb;
85 };
86
87 typedef std::vector<Actor> Actors;
88
89
90 inline bool operator<(const TVMediaInfo& rhs, const TVMediaInfo& lhs)
91 {
92         if (rhs.type==lhs.type) {
93                 if (rhs.primary_id==lhs.primary_id) {
94                         if (rhs.static_fallback==lhs.static_fallback) {
95                                 if (rhs.secondary_id==lhs.secondary_id) {
96                                         if (rhs.type_pict==lhs.type_pict) {
97                                                 if (rhs.container==lhs.container) {
98                                                         if (rhs.primary_name== lhs.primary_name) {
99                                                                 return rhs.container_member < lhs.container_member;
100                                                         } else {
101                                                                 return rhs.primary_name < lhs.primary_name;
102                                                         }
103                                                 } else {
104                                                         return rhs.container<lhs.container;
105                                                 }
106
107
108                                         } else {
109                                                 return rhs.type_pict<lhs.type_pict;
110                                         }
111
112                                 } else {
113                                         return rhs.secondary_id<lhs.secondary_id;
114                                 }
115                         } else {
116                                 return rhs.static_fallback<lhs.static_fallback;
117                         }
118
119                 } else {
120                         return rhs.primary_id<lhs.primary_id;
121                 }
122
123
124         } else {
125                 return rhs.type < lhs.type;
126         }
127 }
128
129 inline bool operator==(const TVMediaInfo& rhs, const TVMediaInfo& lhs)
130 {
131         return (rhs.type==lhs.type)  && (rhs.primary_id==lhs.primary_id) && (rhs.static_fallback==lhs.static_fallback)  &&
132              (rhs.secondary_id==lhs.secondary_id) && (rhs.type_pict==lhs.type_pict) &&
133                 (rhs.container==lhs.container)  && (rhs.primary_name== lhs.primary_name)
134                                                 && (rhs.container_member == lhs.container_member);
135 }
136
137 #endif