00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
#ifndef _PVSDL
00076
#define _PVSDL
00077
00078
#if P_SDL
00079
00080
#include <ptlib.h>
00081
#if defined(P_FREEBSD)
00082
#include <SDL11/SDL.h>
00083
#else
00084
#include <SDL/SDL.h>
00085
#endif
00086
00087
#undef main
00088
00089
class PSDLVideoFrame :
public PObject
00090 {
00091
PCLASSINFO(PSDLVideoFrame,
PObject);
00092
public:
00093 PSDLVideoFrame(
00094
unsigned newWidth,
00095
unsigned newHeight,
00096 Uint8 *data
00097 );
00098 PSDLVideoFrame(
00099
unsigned newWidth,
00100
unsigned newHeight,
00101
const void *_data
00102 );
00103
00104 ~PSDLVideoFrame();
00105
00106
unsigned GetWidth() {
return width; }
00107
unsigned GetHeight() {
return height; }
00108
00109 Uint8 *GetDataPointer() {
return data; }
00110
00111
void PrintOn(ostream & str)
const;
00112
00113
protected:
00114
void Initialise(
unsigned newWidth,
unsigned newHeight, Uint8 *_data);
00115
00116
unsigned width;
00117
unsigned height;
00118
00119 Uint8 *data;
00120 };
00121
00122
00123
class PSDLDisplayThread :
public PThread
00124 {
00125
PCLASSINFO(PSDLDisplayThread,
PThread);
00126
public:
00127 PSDLDisplayThread(
00128 BOOL _videoPIP
00129 );
00130 ~PSDLDisplayThread();
00131
00132
void Main();
00133
00136 BOOL AddFrame(PSDLVideoFrame *newFrame, BOOL isEncoding);
00137
00138 BOOL IsOpen();
00139
00140
virtual void Terminate();
00141
void RequestOpenWindow(BOOL isEncoding);
00142
void RequestCloseWindow(BOOL isEncoding);
00143
00144
protected:
00145 BOOL ScreenIsOpen();
00146 BOOL DisplayIsShutDown();
00147
void CloseWindow(BOOL isEncoding);
00148
00149 PSDLVideoFrame *GetNextFrame(BOOL isEncoding);
00150
00151 BOOL ResizeScreen(
unsigned newWidth,
unsigned newHeight);
00152
void InitDisplayPosn();
00153
void InitDisplayPosn(
unsigned w,
unsigned h);
00154
void CloseScreen();
00155 BOOL CreateOverlay(BOOL isEncoding);
00156 BOOL SetOverlaySize (BOOL isEncoding,
unsigned _width,
unsigned _height);
00157
00158
void WriteOutDisplay();
00159
00160
unsigned GetDisplayIndex(BOOL isEncoding);
00161
00164 BOOL SetFrameSize(BOOL isEncoding,
unsigned _width,
unsigned _height);
00165
00168
void ProcessSDLEvents(
void);
00169
00170 BOOL Redraw(BOOL isEncoding, PSDLVideoFrame *frame);
00171
00172
enum { RemoteIndex = 0 };
00173
enum { EncodeIndex = 1 };
00174
00175
const char * GetDirName(BOOL isEncoding)
00176 {
return (isEncoding ?
"local" :
"remote"); }
00177
00178
PMutex mutex;
00179
PSyncPoint commandSync;
00180 BOOL threadRunning;
00181
00182 SDL_Surface *screen;
00183 SDL_Overlay *overlay[2];
00184 SDL_Rect displayPosn[2];
00185
00186
unsigned width[2];
00187
unsigned height[2];
00188
unsigned oldScreenWidth, oldScreenHeight;
00189
00190
PString remoteName;
00191 BOOL displayIsShutDown;
00192 BOOL videoPIP;
00193
00194 BOOL closeEncWindow;
00195 BOOL closeRecWindow;
00196
00197 PSDLVideoFrame *nextEncFrame;
00198 PSDLVideoFrame *nextRcvFrame;
00199 };
00200
00201
00204
class PSDLVideoDevice :
public PVideoOutputDevice
00205 {
00206
PCLASSINFO(PSDLVideoDevice,
PVideoOutputDevice);
00207
00208
public:
00211 PSDLVideoDevice(
00212
const PString & _remoteName,
00213 BOOL _isEncoding,
00214 PSDLDisplayThread *_sdlThread
00215 );
00216
00219 ~PSDLVideoDevice();
00220
00223
virtual BOOL Open(
00224
const PString & ,
00225 BOOL = TRUE
00226 ) {
return TRUE; }
00227
00230 BOOL
Close();
00231
00234 BOOL
IsOpen();
00235
00236
unsigned GetFrameWidth()
const {
return width; }
00237
00238
unsigned GetFrameHeight()
const {
return height; }
00239
00243 BOOL Redraw (
const void *frame);
00244
00247
virtual PStringList GetDeviceNames() const;
00248
00254 virtual PINDEX GetMaxFrameBytes()
00255 {
return 352 * 288 * 3 * 2; }
00256
00259 BOOL SetFrameSize (
unsigned _width ,
unsigned _height);
00260
00261
virtual PString GetRemoteName()
const
00262
{
return remoteName ; }
00263
00266
virtual void SetRemoteName(
00267
const PString & _remoteName
00268 ) { remoteName = _remoteName; }
00269
00272
void ForceDepth(
int ) { }
00273
00274
00275 BOOL SetFrameData(
00276
unsigned x,
00277
unsigned y,
00278
unsigned width,
00279
unsigned height,
00280
const BYTE * data,
00281 BOOL endFrame = TRUE
00282 ) ;
00283
00286 BOOL EndFrame();
00287
00288
private:
00289 BOOL isEncoding;
00290
PString remoteName;
00291 PSDLDisplayThread *sdlThread;
00292
unsigned width, height;
00293 };
00294
00295
#endif // P_SDL
00296
00297
#endif
00298