~ubuntu-branches/ubuntu/vivid/ekiga/vivid-proposed

« back to all changes in this revision

Viewing changes to lib/engine/videooutput/common/videooutput-manager-common.h

  • Committer: Bazaar Package Importer
  • Author(s): Kilian Krause
  • Date: 2011-07-17 00:24:50 UTC
  • mfrom: (5.1.5 upstream) (7.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110717002450-ytg3wsrc1ptd3153
Tags: 3.3.1-1
* New upstream release.
 - Required libpt-dev 2.10 and libopal-dev 3.10
* Fix debian/watch to catch new version
* Remove libnotify0.7.patch - included upstream
* Add libboost-dev and libboost-signals-dev to Build-Depends
* debian/rules: Don't install *.la files for new internal shared libs
* Fix Vcs URIs to point to correct desktop/experimental/ekiga tree

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
/* Ekiga -- A VoIP and Video-Conferencing application
3
 
 * Copyright (C) 2000-2006 Damien Sandras
4
 
 *
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.
9
 
 *
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.
14
 
 *
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.
18
 
 *
19
 
 *
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.
26
 
 */
27
 
 
28
 
 
29
 
/*
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.
43
 
 */
44
 
 
45
 
 
46
 
#ifndef _VIDEOOUTPUT_MANAGER_COMMON_H_
47
 
#define _VIDEOOUTPUT_MANAGER_COMMON_H_
48
 
 
49
 
#include "videooutput-manager.h"
50
 
#include "runtime.h"
51
 
 
52
 
#include "ptbuildopts.h"
53
 
#include "ptlib.h"
54
 
 
55
 
/**
56
 
 * @addtogroup videooutput
57
 
 * @{
58
 
 */
59
 
 
60
 
  /** Common VideoOutputManager implementation for DX and XV
61
 
   *
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.
89
 
 
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.
94
 
   */
95
 
  class GMVideoOutputManager
96
 
    : public PThread,
97
 
      public Ekiga::VideoOutputManager
98
 
  {
99
 
    PCLASSINFO(GMVideoOutputManager, PThread); 
100
 
 
101
 
  public:
102
 
 
103
 
   /** See videooutput-manager.h for the API
104
 
     */
105
 
 
106
 
    GMVideoOutputManager (Ekiga::ServiceCore & core);
107
 
 
108
 
    virtual ~GMVideoOutputManager (void);
109
 
 
110
 
    virtual void open ();
111
 
 
112
 
    virtual void close ();
113
 
 
114
 
    virtual void set_frame_data (const char* data,
115
 
                                  unsigned width,
116
 
                                  unsigned height,
117
 
                                  bool local,
118
 
                                  int devices_nbr);
119
 
 
120
 
    virtual void set_display_info (const Ekiga::DisplayInfo & _display_info)
121
 
    {
122
 
      PWaitAndSignal m(display_info_mutex);
123
 
      display_info = _display_info;
124
 
    };
125
 
 
126
 
  protected:
127
 
    typedef struct {
128
 
      bool local;
129
 
      bool remote;
130
 
    } UpdateRequired;
131
 
 
132
 
    /** The main video thread loop
133
 
     * The video output thread loop that waits for a frame and
134
 
     * then displays it
135
 
     */
136
 
    virtual void Main ();
137
 
  
138
 
    /** Check if the display needs to be reinitialized
139
 
     * Returns true if the given settings require a
140
 
     * reinitialization of the display, false
141
 
     * otherwise.
142
 
     * @return wether the display needs to be reopened.
143
 
     */
144
 
    virtual bool frame_display_change_needed ();
145
 
  
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.
150
 
     */
151
 
    virtual void setup_frame_display () = 0;
152
 
  
153
 
    /** Close the display
154
 
     * Closes the frame display and returns false
155
 
     * in case of failure.
156
 
     */
157
 
    virtual void close_frame_display () = 0;
158
 
  
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().
163
 
     */
164
 
    virtual void display_frame (const char *frame,
165
 
                                unsigned width,
166
 
                                unsigned height) = 0;
167
 
 
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().
172
 
     */
173
 
    virtual void display_pip_frames (const char *local_frame,
174
 
                                    unsigned lf_width,
175
 
                                    unsigned lf_height,
176
 
                                    const char *remote_frame,
177
 
                                    unsigned rf_width,
178
 
                                    unsigned rf_height) = 0;
179
 
  
180
 
    /** Draw the frame 
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.
183
 
     */
184
 
    virtual UpdateRequired redraw ();
185
 
 
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.
190
 
     */
191
 
    virtual void sync(UpdateRequired sync_required) = 0;
192
 
 
193
 
    /** Initialises the display
194
 
     */
195
 
    virtual void init ();
196
 
  
197
 
    /** Uninitialises the display
198
 
     */
199
 
    virtual void uninit ();
200
 
 
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 
205
 
     */
206
 
    void update_gui_device();
207
 
 
208
 
    virtual void get_display_info (Ekiga::DisplayInfo & _display_info) {
209
 
          PWaitAndSignal m(display_info_mutex);
210
 
          _display_info = display_info;
211
 
    }
212
 
  
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 */
216
 
  
217
 
    PBYTEArray lframeStore;
218
 
    PBYTEArray rframeStore;
219
 
  
220
 
    typedef struct {
221
 
      Ekiga::VideoOutputMode mode;
222
 
      Ekiga::VideoOutputAccel accel;
223
 
      bool both_streams_active;
224
 
 
225
 
      unsigned int remote_width;
226
 
      unsigned int remote_height;
227
 
    
228
 
      unsigned int local_width;
229
 
      unsigned int local_height;
230
 
      
231
 
      unsigned int zoom;
232
 
    
233
 
      int embedded_x;
234
 
      int embedded_y;
235
 
    } FrameInfo;
236
 
 
237
 
    FrameInfo last_frame;
238
 
    FrameInfo current_frame;
239
 
    
240
 
    bool local_frame_received;
241
 
    bool remote_frame_received;
242
 
    bool video_disabled;
243
 
 
244
 
    UpdateRequired update_required;
245
 
  
246
 
    PSyncPoint run_thread;                  /* To signal the thread shall execute its tasks */
247
 
    bool       end_thread;
248
 
    bool       init_thread;
249
 
    bool       uninit_thread;
250
 
  
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 */
255
 
    
256
 
    PMutex var_mutex;      /* To protect variables that are read and written
257
 
                              from various threads */
258
 
  
259
 
    Ekiga::ServiceCore & core;
260
 
    Ekiga::Runtime & runtime;
261
 
  };
262
 
 
263
 
/**
264
 
 * @}
265
 
 */
266
 
 
267
 
#endif /* _VIDEOOUTPUT_MANAGER_COMMON_H_ */