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