~ubuntu-branches/ubuntu/quantal/vdr-plugin-xine/quantal

« back to all changes in this revision

Viewing changes to xineLib.h

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Schmidt
  • Date: 2008-04-06 21:34:14 UTC
  • Revision ID: james.westby@ubuntu.com-20080406213414-54lbe5pj1cbbquon
Tags: upstream-0.8.2
ImportĀ upstreamĀ versionĀ 0.8.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#ifndef __XINELIB_H
 
3
#define __XINELIB_H
 
4
 
 
5
 
 
6
 
 
7
#include "xineCommon.h"
 
8
 
 
9
#include <vdr/remote.h>
 
10
 
 
11
#if APIVERSNUM < 10307
 
12
 
 
13
#include <vdr/osdbase.h>
 
14
 
 
15
#else
 
16
 
 
17
#include <vdr/osd.h>
 
18
#define  MAXNUMWINDOWS MAXOSDAREAS
 
19
 
 
20
#endif
 
21
 
 
22
#include <vdr/plugin.h>
 
23
 
 
24
#include "xineExternal.h"
 
25
#include "xineSettings.h"
 
26
 
 
27
 
 
28
 
 
29
namespace PluginXine
 
30
{
 
31
 
 
32
  class cXineLibEvents
 
33
  {
 
34
  protected:
 
35
    virtual ~cXineLibEvents() {}
 
36
  public:
 
37
    virtual void OnClientConnect() = 0;
 
38
    virtual void OnClientDisconnect() = 0;
 
39
    virtual void ReshowCurrentOSD(const int frameLeft, const int frameTop, const int frameWidth, const int frameHeight, const int frameZoomX, const int frameZoomY) = 0;
 
40
    virtual bool DeviceReplayingOrTransferring() = 0;
 
41
  };
 
42
 
 
43
 
 
44
  
 
45
  class cXineLib;
 
46
 
 
47
// This class performs the adaption from Xine events
 
48
// to VDR's remote control events.
 
49
  class cXineRemote
 
50
    : public cRemote
 
51
    , private cThread 
 
52
  {
 
53
  private:
 
54
    bool m_active;
 
55
    cMutex m_activeMutex;
 
56
    cCondVar m_activeCondVar;
 
57
    const bool m_remoteOn;
 
58
    cXineLib *m_xineLib;
 
59
    
 
60
    virtual void Action (void);
 
61
    bool Ready(void) { return false; };
 
62
    bool isConnected();
 
63
 
 
64
  public:
 
65
    cXineRemote(const bool remoteOn);
 
66
    virtual ~cXineRemote();
 
67
 
 
68
    void setXineLib(cXineLib *const xineLib);
 
69
  };
 
70
  
 
71
 
 
72
  class cXineOsd;
 
73
  class cXineSettings;
 
74
  
 
75
  class cXineLib : public cThread
 
76
  {
 
77
  public:
 
78
    enum eNeedsScaling
 
79
    {
 
80
      no = 0
 
81
      , yes
 
82
      , shq
 
83
    };
 
84
 
 
85
    string m_fifoDir;
 
86
    string m_fifoNameControl;
 
87
    string m_fifoNameResult;
 
88
    string m_fifoNameRemote;
 
89
    string m_fifoNameStream;
 
90
    string m_fifoNameExtControl;
 
91
    string m_fifoNameExtResult;
 
92
    in_addr_t m_bindIp;
 
93
    int m_bindPort;
 
94
 
 
95
  private:
 
96
    cPlugin *const m_plugin;
 
97
    cXineExternal m_external;
 
98
    
 
99
    void internalPaused(const bool paused);
 
100
    cMutex m_pausedMutex;
 
101
    cCondVar m_pausedCondVar;
 
102
    cMutex m_shutdownMutex;
 
103
    cCondVar m_shutdownCondVar;
 
104
      
 
105
    const cXineSettings &m_settings;
 
106
    
 
107
    bool m_osdWindowVisible[ MAXNUMWINDOWS ];
 
108
 
 
109
#if APIVERSNUM >= 10307
 
110
    int m_osdWindowVideoLeft[ MAXNUMWINDOWS ];
 
111
    int m_osdWindowVideoTop[ MAXNUMWINDOWS ];
 
112
    int m_osdWindowVideoWidth[ MAXNUMWINDOWS ];
 
113
    int m_osdWindowVideoHeight[ MAXNUMWINDOWS ];
 
114
    int m_osdWindowVideoZoomX[ MAXNUMWINDOWS ];
 
115
    int m_osdWindowVideoZoomY[ MAXNUMWINDOWS ];
 
116
    int m_osdWindowLeft[ MAXNUMWINDOWS ];
 
117
    int m_osdWindowTop[ MAXNUMWINDOWS ];
 
118
    int m_osdWindowWidth[ MAXNUMWINDOWS ];
 
119
    int m_osdWindowHeight[ MAXNUMWINDOWS ];
 
120
        
 
121
    int m_osdWindowColorsNum[ MAXNUMWINDOWS ];
 
122
    tColor m_osdWindowColors[ MAXNUMWINDOWS ][ MAXNUMCOLORS ];
 
123
 
 
124
    int m_scaledWindowColorsNum[ MAXNUMWINDOWS ];
 
125
    tColor m_scaledWindowColors[ MAXNUMWINDOWS ][ MAXNUMCOLORS ];
 
126
 
 
127
    cXineSettings::eOsdMode m_osdWindowMode[ MAXNUMWINDOWS ];
 
128
    int m_osdWindowGamma[ MAXNUMWINDOWS ];
 
129
    bool m_osdWindowSupportTransparency[ MAXNUMWINDOWS ];
 
130
 
 
131
    int m_osdWindowBufferSize[ MAXNUMWINDOWS ];
 
132
    tIndex *m_osdWindowBuffer[ MAXNUMWINDOWS ];
 
133
    
 
134
    tArea m_vidWin;
 
135
#endif    
 
136
 
 
137
    void cloneBitmap(const int windowNum, cBitmap *bitmap, int x1, int y1, int x2, int y2);
 
138
    bool bitmapDiffers(const int windowNum, cXineOsd *xineOsd, cBitmap *bitmap, int &x1, int &y1, int &x2, int &y2); 
 
139
    bool clipBitmap(cXineOsd *xineOsd, cBitmap *bitmap, int &x1, int &y1, const int x2, const int y2); 
 
140
    
 
141
    bool m_osdFlushRequired;
 
142
 
 
143
  public:
 
144
    int getRemoteFD() const
 
145
    {
 
146
      return fd_remote;
 
147
    }
 
148
    
 
149
  private:    
 
150
    int CreateServerSocket(unsigned short port);
 
151
    int SocketAcceptHelper(int fd);
 
152
 
 
153
    int fd_fifo0_serv, fd_result_serv, fd_control_serv, fd_remote_serv;
 
154
    int fd_fifo0, fd_result, fd_control, fd_remote;
 
155
 
 
156
    cMutex m_ioMutex, m_dataMutex, m_disconnectMutex;
 
157
    cMutex &m_osdMutex;
 
158
 
 
159
    bool m_paused;
 
160
    bool m_frozen;
 
161
    bool m_ignore;
 
162
    bool m_shutdown;
 
163
 
 
164
    bool m_muted;
 
165
    int m_volume;
 
166
    int m_audioChannel;
 
167
    bool m_trickSpeedMode;
 
168
 
 
169
  public:    
 
170
    bool isConnected();
 
171
    void disconnect();
 
172
 
 
173
    int xwrite(int f, const void *b, int n);
 
174
    int xread(int f, void *b, int n);
 
175
 
 
176
  private:
 
177
    char m_noSignalStreamData[ 6 + 0xffff ];
 
178
    long m_noSignalStreamSize;
 
179
 
 
180
    cXineLibEvents *m_eventSink;
 
181
 
 
182
    eNeedsScaling NeedsScaling(const int maxOsdWidth, const int maxOsdHeight, const int videoWidth, const int videoHeight);
 
183
 
 
184
    bool pushOut(const uchar id = 0xff);
 
185
 
 
186
  public:
 
187
    bool hasNoSignalStream() const
 
188
    {
 
189
      return m_noSignalStreamSize > 0;
 
190
    }
 
191
    
 
192
    virtual void Action(void);
 
193
 
 
194
    bool checkXineVersion();
 
195
    bool checkConnect();
 
196
 
 
197
    void enableExternal(const bool enable = true);
 
198
    void ExternalStreamFinished();
 
199
 
 
200
  public:
 
201
    cXineLib(cPlugin *const plugin, const cXineSettings &settings, cMutex &osdMutex, cXineRemote *const remote);
 
202
    virtual ~cXineLib();
 
203
 
 
204
    void SetEventSink(cXineLibEvents *const eventSink);
 
205
    
 
206
    bool Open();
 
207
    void Close();
 
208
 
 
209
    bool Poll(cPoller &Poller, int TimeoutMs = 0, const bool special = false);
 
210
 
 
211
#if APIVERSNUM < 10307
 
212
    
 
213
    bool OpenWindow(cXineOsd *const xineOsd, cWindow *Window);
 
214
    void CommitWindow(cXineOsd *const xineOsd, cWindow *Window, const bool optimize = true);
 
215
    void ShowWindow(cXineOsd *const xineOsd, cWindow *Window);
 
216
    void HideWindow(cXineOsd *const xineOsd, cWindow *Window, bool Hide);
 
217
    void MoveWindow(cXineOsd *const xineOsd, cWindow *Window, int x, int y);
 
218
    void CloseWindow(cXineOsd *const xineOsd, cWindow *Window);
 
219
    void CloseWindow(cXineOsd *const xineOsd, int Window);
 
220
 
 
221
#else
 
222
 
 
223
    void sendWindow(const int maxOsdWidth, const int maxOsdHeight, cXineOsd *const xineOsd, const int windowNum, cBitmap *bitmap = 0, const int videoLeft = -1, const int videoTop = -1, const int videoWidth = -1, const int videoHeight = -1, const int videoZoomX = -1, const int videoZoomY = -1, const bool dontOptimize = false);
 
224
    void SendWindow(const int maxOsdWidth, const int maxOsdHeight, cXineOsd *const xineOsd, const int windowNum, cBitmap *bitmap = 0, const int videoLeft = -1, const int videoTop = -1, const int videoWidth = -1, const int videoHeight = -1, const int videoZoomX = -1, const int videoZoomY = -1, const bool dontOptimize = false);
 
225
    
 
226
    bool execFuncOsdNew(const int maxOsdWidth, const int maxOsdHeight, const eNeedsScaling needsScaling, const int videoLeft, const int videoTop, const int videoWidth, const int videoHeight, int window, int x, int y, int width, int height);
 
227
    bool execFuncOsdDrawBitmap(const int maxOsdWidth, const int maxOsdHeight, const eNeedsScaling needsScaling, const int videoWidth, const int videoHeight, cXineOsd *const xineOsd, int window, cBitmap *const bitmap, int x, int y, int width, int height, int stride);
 
228
 
 
229
    void SetVideoWindow(const int maxOsdWidth, const int maxOsdHeight, tArea vidWin, const bool dontOptimize = false);
 
230
    
 
231
#endif    
 
232
    
 
233
    int execFuncStream1(const uchar *Data, int Length);
 
234
    int execFuncStream(const uchar *Data, int Length);
 
235
    bool execFuncStream0(const uchar *Data, int Length);
 
236
    bool execFuncStart();
 
237
    bool execFuncEnd();
 
238
    bool execFuncWait();
 
239
    bool execFuncSetup();
 
240
    bool execFuncDiscontinuity();
 
241
 
 
242
    bool execFuncOsdFlush();
 
243
    bool execFuncOsdNew(int window, int x, int y, int width, int height);
 
244
    bool execFuncOsdFree(int window);
 
245
    bool execFuncOsdShow(int window);
 
246
    bool execFuncOsdHide(int window);
 
247
    bool execFuncOsdSetPosition(int window, int x, int y);
 
248
    bool execFuncOsdDrawBitmap(int window, uint8_t *bitmap, int x, int y, int width, int height, int stride);
 
249
 
 
250
#if APIVERSNUM < 10307
 
251
    bool execFuncSetColor(int window, int index, eDvbColor color);
 
252
    bool execFuncSetColor(int window, int index, eDvbColor *const colors, int numColors);
 
253
    eDvbColor filterAlpha(eDvbColor color);
 
254
#else
 
255
    bool execFuncSetColor(int window, int index, tColor color);
 
256
    bool execFuncSetColor(int window, int index, tColor *const colors, int numColors);
 
257
    tColor filterAlpha(tColor color);
 
258
#endif
 
259
    
 
260
    bool execFuncSetColor(int window, int index, int numColors, uint32_t *const colors);
 
261
 
 
262
    bool execFuncMute(bool mute = true);
 
263
    bool execFuncClear(int n);
 
264
    bool execFuncResetAudio();
 
265
    bool execFuncSelectAudio(int channel);
 
266
    bool execFuncFirstFrame();
 
267
    bool execFuncStillFrame();
 
268
    bool execFuncFlush(int TimeoutMs = -1, const bool justWait = false);
 
269
    bool execFuncSetVolume(int volume);
 
270
    bool execFuncSetSpeed(double speed);
 
271
    bool execFuncTrickSpeedMode(bool on);
 
272
    bool execFuncDelay(int usDelay);
 
273
    bool execFuncMetronom(int64_t pts, uint32_t flags = 0);
 
274
    bool execFuncNop();
 
275
    bool execFuncSetPrebuffer(int frames);
 
276
    bool execFuncGetPTS(int64_t &pts);
 
277
    bool execFuncVideoSize(int &videoLeft, int &videoTop, int &videoWidth, int &videoHeight, int &videoZoomX, int &videoZoomY);
 
278
 
 
279
    bool execFuncGetVersion(int32_t &version);
 
280
 
 
281
    uchar *execFuncGrabImage(const char *FileName, int &Size, bool Jpeg, int Quality, int SizeX, int SizeY);
 
282
 
 
283
    bool execFuncSetVideoWindow(int x, int y, int w, int h, int wRef, int hRef);
 
284
 
 
285
    bool execFuncPlayExternal(const char *const fileName = 0);
 
286
 
 
287
    bool showNoSignal();
 
288
    
 
289
    void pause(bool doPause = true);
 
290
    void freeze(bool doFreeze = true);
 
291
    void ignore(bool doIgnore = true);
 
292
 
 
293
    void flush();
 
294
 
 
295
    void ReshowCurrentOSD(const int frameLeft, const int frameTop, const int frameWidth, const int frameHeight, const int frameZoomX, const int frameZoomY);
 
296
 
 
297
    void ReshowCurrentOSD()
 
298
    {
 
299
      ReshowCurrentOSD(-1, -1, -1, -1, -1, -1);
 
300
    }
 
301
  };
 
302
 
 
303
};
 
304
 
 
305
 
 
306
 
 
307
#endif //__XINELIB_H