1 | //********************************************************************************* |
2 | // Rendition.h |
3 | //--------------------------------------------------------------------------------- |
4 | // |
5 | //--------------------------------------------------------------------------------- |
6 | // Hugo Mercier <hmercier31[at]gmail.com> (c) 2008 |
7 | // Carlos Garcia Campos <carlosgc@gnome.org> (c) 2010 |
8 | // Albert Astals Cid <aacid@kde.org> (C) 2017, 2018, 2021 |
9 | // |
10 | // This program is free software; you can redistribute it and/or modify |
11 | // it under the terms of the GNU General Public License as published by |
12 | // the Free Software Foundation; either version 2 of the License, or |
13 | // (at your option) any later version. |
14 | // |
15 | // This program is distributed in the hope that it will be useful, |
16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | // GNU General Public License for more details. |
19 | // |
20 | // You should have received a copy of the GNU General Public License |
21 | // along with this program; if not, write to the Free Software |
22 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 | //********************************************************************************* |
24 | |
25 | #ifndef _RENDITION_H_ |
26 | #define _RENDITION_H_ |
27 | |
28 | #include "Object.h" |
29 | |
30 | struct MediaWindowParameters |
31 | { |
32 | |
33 | MediaWindowParameters(); |
34 | ~MediaWindowParameters(); |
35 | |
36 | // parse from a floating window parameters dictionary |
37 | void parseFWParams(Object *obj); |
38 | |
39 | enum MediaWindowType |
40 | { |
41 | windowFloating = 0, |
42 | windowFullscreen, |
43 | windowHidden, |
44 | windowEmbedded |
45 | }; |
46 | |
47 | enum MediaWindowRelativeTo |
48 | { |
49 | windowRelativeToDocument = 0, |
50 | windowRelativeToApplication, |
51 | windowRelativeToDesktop |
52 | }; |
53 | |
54 | // DEFAULT VALUE |
55 | |
56 | MediaWindowType type; // movieWindowEmbedded |
57 | |
58 | int width; // -1 |
59 | int height; // -1 |
60 | |
61 | // floating window position |
62 | MediaWindowRelativeTo relativeTo; // windowRelativeToDocument (or to desktop) |
63 | double XPosition; // 0.5 |
64 | double YPosition; // 0.5 |
65 | |
66 | bool hasTitleBar; // true |
67 | bool hasCloseButton; // true |
68 | bool isResizeable; // true |
69 | }; |
70 | |
71 | struct MediaParameters |
72 | { |
73 | |
74 | MediaParameters(); |
75 | ~MediaParameters(); |
76 | |
77 | // parse from a "Media Play Parameters" dictionary |
78 | void parseMediaPlayParameters(Object *playObj); |
79 | // parse from a "Media Screen Parameters" dictionary |
80 | void parseMediaScreenParameters(Object *screenObj); |
81 | |
82 | enum MediaFittingPolicy |
83 | { |
84 | fittingMeet = 0, |
85 | fittingSlice, |
86 | fittingFill, |
87 | fittingScroll, |
88 | fittingHidden, |
89 | fittingUndefined |
90 | }; |
91 | |
92 | struct Color |
93 | { |
94 | double r, g, b; |
95 | }; |
96 | |
97 | int duration; // 0 |
98 | |
99 | int volume; // 100 |
100 | |
101 | // defined in media play parameters, p 770 |
102 | // correspond to 'fit' SMIL's attribute |
103 | MediaFittingPolicy fittingPolicy; // fittingUndefined |
104 | |
105 | bool autoPlay; // true |
106 | |
107 | // repeat count, can be real values, 0 means forever |
108 | double repeatCount; // 1.0 |
109 | |
110 | // background color // black = (0.0 0.0 0.0) |
111 | Color bgColor; |
112 | |
113 | // opacity in [0.0 1.0] |
114 | double opacity; // 1.0 |
115 | |
116 | bool showControls; // false |
117 | |
118 | MediaWindowParameters windowParams; |
119 | }; |
120 | |
121 | class POPPLER_PRIVATE_EXPORT MediaRendition |
122 | { |
123 | public: |
124 | explicit MediaRendition(Object *obj); |
125 | MediaRendition(const MediaRendition &other); |
126 | ~MediaRendition(); |
127 | MediaRendition &operator=(const MediaRendition &) = delete; |
128 | |
129 | bool isOk() const { return ok; } |
130 | |
131 | const MediaParameters *getMHParameters() const { return &MH; } |
132 | const MediaParameters *getBEParameters() const { return &BE; } |
133 | |
134 | const GooString *getContentType() const { return contentType; } |
135 | const GooString *getFileName() const { return fileName; } |
136 | |
137 | bool getIsEmbedded() const { return isEmbedded; } |
138 | Stream *getEmbbededStream() const { return isEmbedded ? embeddedStreamObject.getStream() : nullptr; } |
139 | const Object *getEmbbededStreamObject() const { return isEmbedded ? &embeddedStreamObject : nullptr; } |
140 | // write embedded stream to file |
141 | void outputToFile(FILE *); |
142 | |
143 | MediaRendition *copy() const; |
144 | |
145 | private: |
146 | bool ok; |
147 | |
148 | // "Must Honor" parameters |
149 | MediaParameters MH; |
150 | // "Best Effort" parameters |
151 | MediaParameters BE; |
152 | |
153 | bool isEmbedded; |
154 | |
155 | GooString *contentType; |
156 | |
157 | // if it's embedded |
158 | Object embeddedStreamObject; |
159 | |
160 | // if it's not embedded |
161 | GooString *fileName; |
162 | }; |
163 | |
164 | #endif /* _RENDITION_H_ */ |
165 | |