2
/* Ekiga -- A VoIP and Video-Conferencing application
3
* Copyright (C) 2000-2006 Damien Sandras
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20
* Ekiga is licensed under the GPL license and as a special exception,
21
* you have permission to link or otherwise combine this program with the
22
* programs OPAL, OpenH323 and PWLIB, and distribute the combination,
23
* without applying the requirements of the GNU GPL to the OPAL, OpenH323
24
* and PWLIB programs, as long as you do follow the requirements of the
25
* GNU GPL for all the rest of the software thus combined.
30
* videooutput-manager-common.h - description
31
* ------------------------------
32
* begin : Sat Feb 17 2001
33
* copyright : (C) 2000-2008 by Damien Sandras
34
* : (C) 2007-2008 by Matthias Schneider
35
* description : Generic class that represents
36
* a thread that can display a video image and defines.
37
* generic functions for local/remote/pip/pip external
38
* window/fullscreen video display. Provides interface
39
* to the GUI for an embedded window, display mode
40
* control and feedback of information like the status
41
* of the video acceleration. Also provides the
42
* copying and local storage of the video frame.
46
#ifndef _VIDEOOUTPUT_MANAGER_COMMON_H_
47
#define _VIDEOOUTPUT_MANAGER_COMMON_H_
49
#include "videooutput-manager.h"
52
#include "ptbuildopts.h"
56
* @addtogroup videooutput
60
/** Common VideoOutputManager implementation for DX and XV
62
* This class features the shared functionality between the DX and XV output managers.
63
* The GMVideoOutputManager consists of a special thread that will do all accesses
64
* to the dxWindow and xWindow/xvWindow classes (important for windows where all
65
* accesses to a specific window not only have to be thread-safe, but also have to
66
* come all from the same thread). The main task of that thread is to wait for triggers
67
* and then act on them, the thread itself will be active for the whole lifetime of Ekiga.
68
* A call to open() from the core will signal the thread to execute the initalize function,
69
* with open() blocking until the thread has finished its task.
70
* The thread is now ready to accept frames, which will arrive from the core via
71
* set_frame_data(). set_frame_data will make a local copy of the image via memcpy,
72
* and signal the thread that a new remote or local frame has arrived and is ready to be
73
* displayed. Then set_frame_data() will be left, while the actual display of the frame
74
* will be performed in the thread.
75
* Once the thread has been triggered with a new frame to display, it will first call redraw
76
* for passing the frame to the graphics adaptor, and then do_sync to actually displaying it.
77
* The reason these procedures are separate has the following motivation: do_sync can block for
78
* quite some time if synv-to-vblank is active. If this would be executed in the mutex-protected
79
* redraw procedure, we would be blocking the video processing threads, possibly leading to lost packets
80
* and interfering with synchronous frame transmission.
81
* redraw() will check whether the dxWindow/xvWindow classes need to be reinitialized (e.g. we want to
82
* switching from non-pip mode to pip mode, etc.), do that if desired and then pass pointers to the
83
* (copied) frames to the dxWindow/xvWindow classes via display_frame() and display_pip_frames(). It will
84
* also determine if only one or both frames need to be synched to the screen.
85
* Once the device has been opened/initialized and no new frame arrives, the frames will nevertheless
86
* be updated every 250 ms.
87
* In order to close the devices, an uninit request is sent to the thread, which performes the
88
* necessary cleanup. Like open(), close() blocks until the thread signals the cleanup has been completed.
90
* the frames to all of them.
91
* Before passing the first frame, start() has to be called. In order to close the video,
92
* stop() has to be called. The video output core interacts with the GUI when switching to fullscreen,
93
* when the size of the video has been changed and when a device is opened and closed.
95
class GMVideoOutputManager
97
public Ekiga::VideoOutputManager
99
PCLASSINFO(GMVideoOutputManager, PThread);
103
/** See videooutput-manager.h for the API
106
GMVideoOutputManager (Ekiga::ServiceCore & core);
108
virtual ~GMVideoOutputManager (void);
110
virtual void open ();
112
virtual void close ();
114
virtual void set_frame_data (const char* data,
120
virtual void set_display_info (const Ekiga::DisplayInfo & _display_info)
122
PWaitAndSignal m(display_info_mutex);
123
display_info = _display_info;
132
/** The main video thread loop
133
* The video output thread loop that waits for a frame and
136
virtual void Main ();
138
/** Check if the display needs to be reinitialized
139
* Returns true if the given settings require a
140
* reinitialization of the display, false
142
* @return wether the display needs to be reopened.
144
virtual bool frame_display_change_needed ();
146
/** Set up the display
147
* Setup the display following the display type,
148
* picture dimensions and zoom value.
149
* Returns false in case of failure.
151
virtual void setup_frame_display () = 0;
153
/** Close the display
154
* Closes the frame display and returns false
155
* in case of failure.
157
virtual void close_frame_display () = 0;
159
/** Display one frame
160
* Display the given frame on the correct display.
161
* The display needs to be initialized first by using
162
* setup_frame_display().
164
virtual void display_frame (const char *frame,
166
unsigned height) = 0;
168
/** Display two frames as picture-in-picture
169
* Display the given frames as Picture in Picture.
170
* The display needs to be initialized first by using
171
* setup_frame_display().
173
virtual void display_pip_frames (const char *local_frame,
176
const char *remote_frame,
178
unsigned rf_height) = 0;
181
* Draw the frame to a backbuffer, do not show it yet.
182
* @return wether the local, the remote or both frames need to be synced to the screen.
184
virtual UpdateRequired redraw ();
186
/** Sync the output of the frame
187
* Bring the frame to the screen. May block for
188
* a while if sync-to-vblank is active
189
* @param sync_required wether the local, the remote or both frames need to be synced to the screen.
191
virtual void sync(UpdateRequired sync_required) = 0;
193
/** Initialises the display
195
virtual void init ();
197
/** Uninitialises the display
199
virtual void uninit ();
201
/** Update the GUI about the new device state
202
* Triggers a device_closed and device_opened callback.
203
* Used to inform the GUI that the second video signal
204
* has arrived for the first time
206
void update_gui_device();
208
virtual void get_display_info (Ekiga::DisplayInfo & _display_info) {
209
PWaitAndSignal m(display_info_mutex);
210
_display_info = display_info;
213
/* This variable has to be protected by display_info_mutex */
214
Ekiga::DisplayInfo display_info;
215
PMutex display_info_mutex; /* To protect the DisplayInfo object */
217
PBYTEArray lframeStore;
218
PBYTEArray rframeStore;
221
Ekiga::VideoOutputMode mode;
222
Ekiga::VideoOutputAccel accel;
223
bool both_streams_active;
225
unsigned int remote_width;
226
unsigned int remote_height;
228
unsigned int local_width;
229
unsigned int local_height;
237
FrameInfo last_frame;
238
FrameInfo current_frame;
240
bool local_frame_received;
241
bool remote_frame_received;
244
UpdateRequired update_required;
246
PSyncPoint run_thread; /* To signal the thread shall execute its tasks */
251
PSyncPoint thread_created; /* To signal that the thread has been created */
252
PSyncPoint thread_initialised; /* To signal that the thread has been initialised */
253
PSyncPoint thread_uninitialised; /* To signal that the thread has been uninitialised */
254
PMutex thread_ended; /* To exit */
256
PMutex var_mutex; /* To protect variables that are read and written
257
from various threads */
259
Ekiga::ServiceCore & core;
260
Ekiga::Runtime & runtime;
267
#endif /* _VIDEOOUTPUT_MANAGER_COMMON_H_ */