1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
|
/*
* device.h:
*
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
* $Id$
*
*/
#ifndef __XINELIB_DEVICE_H
#define __XINELIB_DEVICE_H
#include <vdr/config.h>
#include <vdr/device.h>
#include <vdr/tools.h>
#include <vdr/thread.h>
#include "config.h"
class cXinelibStatusMonitor;
class cXinelibThread;
class cChannel;
class cFunctor;
struct video_size_s;
struct ts_state_s;
typedef enum {
miTitle = 0,
miTracknumber = 1,
miArtist = 2,
miAlbum = 3,
miDvdTitleNo = 4,
miDvdButtons = 5,
mi_Count = 6
} eMetainfoType;
#define ttXSubtitleNone (-2)
#define ttXSubtitleAuto (-1)
#define MAX_METAINFO_LEN 63
#define MAX_NUM_PIP 16
class cXinelibDevice : public cDevice
{
// Singleton
private:
static cXinelibDevice* m_pInstance; // singleton
cXinelibDevice(); //
cXinelibDevice(cXinelibDevice&); // no copy constructor
public:
static cXinelibDevice& Instance(void); // singleton
static void Dispose(void);
virtual ~cXinelibDevice();
// device start/stop (from cPlugin)
public:
bool InitDevice(void);
bool StartDevice(void);
void StopDevice(void);
// function calls waiting to be executed in VDR main thread context
private:
cList<cFunctor> m_MainThreadFunctors;
cMutex m_MainThreadLock;
public:
void MainThreadHook(void);
// Primary device switching
private:
int m_OriginalPrimaryDevice;
int m_ForcePrimaryDeviceCnt;
void ForcePrimaryDeviceImpl(bool On);
public:
virtual void MakePrimaryDevice(bool On);
bool ForcePrimaryDevice(bool On);
// Device capabilities
public:
virtual bool HasDecoder(void) const { return true; };
virtual bool CanReplay(void) const { return true; };
virtual bool HasIBPTrickSpeed(void) { return xc.ibp_trickspeed; }
virtual cRect CanScaleVideo(const cRect &Rect, int Alignment = taCenter);
bool SupportsTrueColorOSD(void);
// Playback control
private:
ePlayMode m_PlayMode;
int m_TrickSpeed;
int m_TrickSpeedMode;
cRect m_VideoWindow;
public:
virtual bool SetPlayMode(ePlayMode PlayMode);
ePlayMode GetPlayMode(void) const { return m_PlayMode; };
const cRect& GetVideoWindow(void) { return m_VideoWindow; }
protected:
virtual void Clear(void);
virtual void Play(void);
virtual void TrickSpeed(int Speed, bool Forward) { TrickSpeed(Speed); }
virtual void TrickSpeed(int Speed);
virtual void Freeze(void);
virtual bool Flush(int TimeoutMs = 0);
virtual int64_t GetSTC(void);
virtual void ScaleVideo(const cRect &Rect = cRect::Null);
// Video format facilities
public:
virtual void SetVideoDisplayFormat(eVideoDisplayFormat VideoDisplayFormat);
virtual void SetVideoFormat(bool VideoFormat16_9);
#if VDRVERSNUM < 20301
virtual eVideoSystem GetVideoSystem(void);
#endif
struct video_size_s *m_VideoSize;
struct ts_state_s *m_tssVideoSize;
virtual void GetVideoSize(int &Width, int &Height, double &VideoAspect);
virtual void GetOsdSize(int &Width, int &Height, double &PixelAspect);
// Track facilities
protected:
virtual void SetAudioTrackDevice(eTrackType Type);
public:
virtual void SetSubtitleTrackDevice(eTrackType Type);
// Audio facilities
private:
int m_AudioChannel;
protected:
virtual int GetAudioChannelDevice(void) { return m_AudioChannel; }
virtual void SetAudioChannelDevice(int AudioChannel);
virtual void SetVolumeDevice(int Volume);
virtual void SetDigitalAudioDevice(bool On);
// Image grabbing
public:
virtual uchar *GrabImage(int &Size, bool Jpeg = true,
int Quality = -1, int SizeX = -1, int SizeY = -1);
// SPU decoder
private:
cSpuDecoder *m_spuDecoder;
friend class cXineSpuDecoder;
public:
virtual cSpuDecoder *GetSpuDecoder(void);
// Messages from StatusMonitor:
private:
cXinelibStatusMonitor *m_statusMonitor;
bool m_liveMode;
protected:
friend class cXinelibStatusMonitor;
void SetTvMode(int ChannelNumber);
void SetReplayMode(void);
void StopOutput(void);
// Osd Commands (from cXinelibOsd)
public:
void OsdCmd(void *cmd);
// Configuration
private:
cList<cXinelibThread> m_clients;
cXinelibThread *m_server;
cXinelibThread *m_local;
public:
void ConfigurePostprocessing(const char *deinterlace_method,
int audio_delay,
int audio_compression,
const int *audio_equalizer,
int audio_surround,
int speaker_type);
void ConfigurePostprocessing(const char *name, bool on = true,
const char *args = NULL);
void ConfigureVideo(int hue, int saturation, int brightness, int sharpness,
int noise_reduction, int contrast, int overscan, int vo_aspect_ratio);
// local mode:
void ConfigureWindow(int fullscreen, int width, int height,
int modeswitch, const char *modeline,
int aspect, int scale_video);
void ConfigureDecoder(int pes_buffers);
// remote mode:
void Listen(bool activate, int port);
// File playback
private:
ePlayMode m_PlayingFile;
public:
bool PlayFile(const char *Filename, int Position = 0,
bool LoopPlay = false, ePlayMode PlayMode = pmAudioVideo,
int TimeoutMs = -1);
int PlayFileCtrl(const char *Cmd, int TimeoutMs = -1);
bool EndOfStreamReached(void);
// Metainfo cache
private:
char m_MetaInfo[mi_Count][MAX_METAINFO_LEN+1];
public:
const char *GetMetaInfo(eMetainfoType Type);
void SetMetaInfo(eMetainfoType Type, const char *Value);
// Stream data
private:
bool m_RadioStream;
int m_AudioCount;
bool m_SkipAudio;
bool m_StreamStart;
int m_FreeBufs;
int PlayAny(const uchar *Data, int Length);
bool AcceptVideoPacket(const uchar *Data, int Length);
bool AcceptAudioPacket(const uchar *Data, int Length);
protected:
virtual bool Poll(cPoller &Poller, int TimeoutMs = 0);
virtual void StillPicture(const uchar *Data, int Length);
// MPEG-PES
virtual int PlayVideo(const uchar *Data, int Length);
virtual int PlayAudio(const uchar *Data, int Length, uchar Id);
virtual int PlaySubtitle(const uchar *Data, int Length);
// join multiple TS packets to xineliboutput transport packet
cMutex m_TsBufLock;
uint8_t m_TsBuf[4096];
uint m_TsBufSize;
int TsBufferFlush(void);
void TsBufferClear(void);
int PlayTsAny(const uchar *Data, int Length);
// MPEG-TS
virtual int PlayTsVideo(const uchar *Data, int Length);
virtual int PlayTsAudio(const uchar *Data, int Length);
virtual int PlayTsSubtitle(const uchar *Data, int Length);
virtual int PlayTs(const uchar *Data, int Length, bool VideoOnly = false);
// Picture-In-Picture
protected:
uint16_t m_PipPid[MAX_NUM_PIP];
public:
int Pip_Open (void);
void Pip_Config (int Index, int X, int Y, int W, int H);
int Pip_Play (int Index, uint8_t *Data, int Length);
void Pip_Close (int Index);
};
#endif // __XINELIB_DEVICE_H
|