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