]> git.vomp.tv Git - vompclient.git/blob - vmediaview.h
Rewritten vomp discovery protocol
[vompclient.git] / vmediaview.h
1 /*
2     Copyright 2004-2005 Chris Tallon, Andreas Vogel
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 VMEDIAVIEW_H
22 #define VMEDIAVIEW_H
23
24 #include <stdio.h>
25 #include <string.h>
26 #include <vector>
27
28 #include "boxx.h"
29 #include "timerreceiver.h"
30 #include "vmedialist.h"
31 #include "colour.h"
32 #include "wjpeg.h"
33 #include "imagereader.h"
34
35 #define TESTCOLOURS
36 class Message;
37 class VInfo;
38 class AudioPlayer;
39 class DrawingThread;
40
41 /**
42   * the picture viewer
43   * will ineract with the parent List for ff,back, slide show...
44   *
45 */
46 class VPictureBanner;
47 class MediaOptions;
48 class VPreader;
49
50 class VMediaView : public Boxx, public TimerReceiver
51 {
52   friend class VPReader;
53   public:
54     ~VMediaView();
55
56     void processMessage(Message* m);
57     int handleCommand(int command);
58     void draw();
59     void timercall(int clientReference);
60     //factory method, create an instance (setting it disabled)
61     //return NULL on error
62     static VMediaView *createViewer(VMediaList * parent);
63     //show the picture currently selected in the parent
64     //potentially moving to next/previous one
65     void showPicture(ULONG move,bool bslideshow,bool forceBanner);
66
67     void enableBanner(bool enable);
68
69     //play audio
70     //if activate is false no info will be shown
71     int play(bool all,bool activate,ULONG move=VMediaList::MV_NONE,bool showInfo=false);
72
73     //check if the audio player is still running
74     //to decide wether to shutdown or not
75     bool isAudioPlaying();
76
77     //player event parameters - no interference with audioplayer! - so we start at 100
78     const static int EVENT_SLIDESHOW;
79     const static int EVENT_DRAWINGDONE;
80     const static int EVENT_DRAWINGERROR;
81     const static int EVENT_DIRECTORYDONE;
82
83   private:
84
85     /**
86       * Common functions
87       * *************************************************************
88       */
89     void setPictureMode(bool enabled);
90     void setAudioMode(bool enabled,bool doHiding=true);
91     //destroy a view (banner, info) - from timer calls
92                 void sendViewMsg(Boxx *v);
93                 //send command in main thread - especially if this view is not on top
94                 void sendCommandMsg(int command);
95     VMediaList   *parent;
96     VMediaView(VMediaList * plist);
97     bool audioEnabled;
98     bool pictureEnabled;
99
100
101
102     /**
103       * Picture viewer
104       * *************************************************************
105       */
106     const static int PICTUREBANNER_TIME=8;
107     //start a slideshow
108     void startSlideshow();
109     //stop the sliedshow
110     void stopSlideshow(bool hard=true);
111     //showXXX functions enable the corresponding banner and restart the timer
112     //updateXXX functions update the content but do not retrigger the timer
113     void showPictureBanner(bool loading=false);
114     void destroyPictureBanner(bool fromTimer=false);
115     void updatePictureBanner(bool loading=false);
116     void showPictureInfo();
117     void updatePictureInfo();
118     void destroyInfo(bool fromTimer=false);
119     int  loadPicture(Media *m,bool forceBanner);
120     void getDrawingParam(Surface *&sfc,WJpeg::JpegControl *&ctl);
121     void switchSurface(); //will switch surface and currentControl
122     void drawingDone(bool hasError);
123
124     // Picture member variables
125     VPreader   *reader; //the reader for the drawing part
126     ImageReader *ireader;//the buffered media reader
127     VPictureBanner *pictureBanner;
128     bool havePictureBanner; //dow we have a normal banner (except during loading)
129     bool pictureLoading;
130     bool pictureShowing; //set to false if loading next is impossible
131     bool slideshow;
132     int showtime;
133     const char * pictureError;
134     Media * currentPicture;
135     const static int INITIAL_SHOWTIME=5;
136     WJpeg::Rotation rotate;
137     WJpeg::ScaleMode cropmode;
138     VInfo * info;
139     static Colour pictureBack;
140     static Colour infoBack;
141     static Colour audioBannerBack;
142     int currentScale;
143     MediaOptions *options;
144     WJpeg::JpegControl ctl;
145     WJpeg::JpegControl ctl2;
146     WJpeg::JpegControl *currentControl;
147     Surface *sfc1;
148     Surface *sfc2;
149     //which is the active surface
150     bool secondSurface(){
151       return surface == sfc2;
152     }
153     UINT originalw;
154     UINT originalh;
155     bool bannerEnabled;
156
157     DrawingThread *drawingThread;
158     /**
159       * Audio player
160       * *************************************************************
161       */
162                 const static int AUDIOBANNER_TIME=30;
163                 const static int AUDIOERROR_TIME=5;
164
165
166                 //margin on SCREEN on each side
167                 const static int AUDIOBANNER_X_MARGIN=50;
168                 //margin on bottom of screen
169                 const static int AUDIOBANNER_BOTTOM_MARGIN=30;
170                 //length of the progress bar
171                 const static int AUDIOBARLEN=250;
172
173     //the  AudioInfo uses the same member as the PictureInfo
174     //so only one of them can be active at the same time
175                 void updateAudioInfo();
176     void showAudioInfo();
177                 void drawAudioInfo();
178                 void drawAudioClocks();
179     void showAudioBanner();
180     void destroyAudioBanner(); //currently not called from timer!
181                 //get the player - create it if necessary
182                 AudioPlayer* getPlayer(bool create=true);
183     bool playall;
184     const char * audioError;
185     Media * currentAudio;
186                 bool justPlaying;
187                 Region barRegion;
188                 Region clocksRegion;
189           Colour barBlue;
190     //retrigger info on events?
191     bool retriggerAudioInfo;
192     VInfo *audioBanner;
193
194
195  };
196
197
198
199 #endif