vdr
2.0.4
Main Page
Namespaces
Classes
Files
File List
File Members
device.h
Go to the documentation of this file.
1
/*
2
* device.h: The basic device interface
3
*
4
* See the main source file 'vdr.c' for copyright information and
5
* how to reach the author.
6
*
7
* $Id: device.h 2.47.1.1 2013/08/22 12:01:48 kls Exp $
8
*/
9
10
#ifndef __DEVICE_H
11
#define __DEVICE_H
12
13
#include "
channels.h
"
14
#include "
ci.h
"
15
#include "
dvbsubtitle.h
"
16
#include "
eit.h
"
17
#include "
filter.h
"
18
#include "
nit.h
"
19
#include "
pat.h
"
20
#include "
remux.h
"
21
#include "
ringbuffer.h
"
22
#include "
sdt.h
"
23
#include "
sections.h
"
24
#include "
spu.h
"
25
#include "
thread.h
"
26
#include "
tools.h
"
27
28
#define MAXDEVICES 16 // the maximum number of devices in the system
29
#define MAXPIDHANDLES 64 // the maximum number of different PIDs per device
30
#define MAXRECEIVERS 16 // the maximum number of receivers per device
31
#define MAXVOLUME 255
32
#define VOLUMEDELTA 5 // used to increase/decrease the volume
33
#define MAXOCCUPIEDTIMEOUT 99 // max. time (in seconds) a device may be occupied
34
35
enum
eSetChannelResult
{
scrOk
,
scrNotAvailable
,
scrNoTransfer
,
scrFailed
};
36
37
enum
ePlayMode
{
pmNone
,
// audio/video from decoder
38
pmAudioVideo
,
// audio/video from player
39
pmAudioOnly
,
// audio only from player, video from decoder
40
pmAudioOnlyBlack
,
// audio only from player, no video (black screen)
41
pmVideoOnly
,
// video only from player, audio from decoder
42
pmExtern_THIS_SHOULD_BE_AVOIDED
43
// external player (e.g. MPlayer), release the device
44
// WARNING: USE THIS MODE ONLY AS A LAST RESORT, IF YOU
45
// ABSOLUTELY, POSITIVELY CAN'T IMPLEMENT YOUR PLAYER
46
// THE WAY IT IS SUPPOSED TO WORK. FORCING THE DEVICE
47
// TO RELEASE ITS FILES HANDLES (OR WHATEVER RESOURCES
48
// IT MAY USE) TO ALLOW AN EXTERNAL PLAYER TO ACCESS
49
// THEM MEANS THAT SUCH A PLAYER WILL NEED TO HAVE
50
// DETAILED KNOWLEDGE ABOUT THE INTERNALS OF THE DEVICE
51
// IN USE. AS A CONSEQUENCE, YOUR PLAYER MAY NOT WORK
52
// IF A PARTICULAR VDR INSTALLATION USES A DEVICE NOT
53
// KNOWN TO YOUR PLAYER.
54
};
55
56
enum
eVideoSystem
{
vsPAL
,
57
vsNTSC
58
};
59
60
enum
eVideoDisplayFormat
{
vdfPanAndScan
,
61
vdfLetterBox
,
62
vdfCenterCutOut
63
};
64
65
enum
eTrackType
{
ttNone
,
66
ttAudio
,
67
ttAudioFirst
=
ttAudio
,
68
ttAudioLast
=
ttAudioFirst
+ 31,
// MAXAPIDS - 1
69
ttDolby
,
70
ttDolbyFirst
=
ttDolby
,
71
ttDolbyLast
=
ttDolbyFirst
+ 15,
// MAXDPIDS - 1
72
ttSubtitle
,
73
ttSubtitleFirst
=
ttSubtitle
,
74
ttSubtitleLast
=
ttSubtitleFirst
+ 31,
// MAXSPIDS - 1
75
ttMaxTrackTypes
76
};
77
78
#define IS_AUDIO_TRACK(t) (ttAudioFirst <= (t) && (t) <= ttAudioLast)
79
#define IS_DOLBY_TRACK(t) (ttDolbyFirst <= (t) && (t) <= ttDolbyLast)
80
#define IS_SUBTITLE_TRACK(t) (ttSubtitleFirst <= (t) && (t) <= ttSubtitleLast)
81
82
struct
tTrackId
{
83
uint16_t
id
;
// The PES packet id or the PID.
84
char
language
[
MAXLANGCODE2
];
// something like either "eng" or "deu+eng"
85
char
description
[32];
// something like "Dolby Digital 5.1"
86
};
87
88
class
cPlayer
;
89
class
cReceiver
;
90
class
cLiveSubtitle
;
91
92
class
cDeviceHook
:
public
cListObject
{
93
public
:
94
cDeviceHook
(
void
);
98
virtual
bool
DeviceProvidesTransponder
(
const
cDevice
*Device,
const
cChannel
*Channel)
const
;
100
};
101
103
104
class
cDevice
:
public
cThread
{
105
friend
class
cLiveSubtitle
;
106
friend
class
cDeviceHook
;
107
private
:
108
static
int
numDevices
;
109
static
int
useDevice
;
110
static
cDevice
*
device
[
MAXDEVICES
];
111
static
cDevice
*
primaryDevice
;
112
public
:
113
static
int
NumDevices
(
void
) {
return
numDevices
; }
115
static
bool
WaitForAllDevicesReady
(
int
Timeout = 0);
121
static
void
SetUseDevice
(
int
n);
125
static
bool
UseDevice
(
int
n) {
return
useDevice
== 0 || (
useDevice
& (1 << n)) != 0; }
128
static
bool
SetPrimaryDevice
(
int
n);
132
static
cDevice
*
PrimaryDevice
(
void
) {
return
primaryDevice
; }
134
static
cDevice
*
ActualDevice
(
void
);
137
static
cDevice
*
GetDevice
(
int
Index
);
141
static
cDevice
*
GetDevice
(
const
cChannel
*Channel,
int
Priority
,
bool
LiveView,
bool
Query =
false
);
160
static
cDevice
*
GetDeviceForTransponder
(
const
cChannel
*Channel,
int
Priority
);
165
static
void
Shutdown
(
void
);
168
private
:
169
static
int
nextCardIndex
;
170
int
cardIndex
;
171
protected
:
172
cDevice
(
void
);
173
virtual
~cDevice
();
174
virtual
bool
Ready
(
void
);
179
static
int
NextCardIndex
(
int
n = 0);
191
virtual
void
MakePrimaryDevice
(
bool
On);
198
public
:
199
bool
IsPrimaryDevice
(
void
)
const
{
return
this
==
primaryDevice
&&
HasDecoder
(); }
200
int
CardIndex
(
void
)
const
{
return
cardIndex
; }
202
int
DeviceNumber
(
void
)
const
;
204
virtual
cString
DeviceType
(
void
)
const
;
210
virtual
cString
DeviceName
(
void
)
const
;
213
virtual
bool
HasDecoder
(
void
)
const
;
215
virtual
bool
AvoidRecording
(
void
)
const
{
return
false
; }
218
219
// Device hooks
220
221
private
:
222
static
cList<cDeviceHook>
deviceHooks
;
223
protected
:
224
bool
DeviceHooksProvidesTransponder
(
const
cChannel
*Channel)
const
;
225
226
// SPU facilities
227
228
private
:
229
cLiveSubtitle
*
liveSubtitle
;
230
cDvbSubtitleConverter
*
dvbSubtitleConverter
;
231
public
:
232
virtual
cSpuDecoder
*
GetSpuDecoder
(
void
);
235
236
// Channel facilities
237
238
private
:
239
time_t
occupiedTimeout
;
240
protected
:
241
static
int
currentChannel
;
242
public
:
243
virtual
bool
ProvidesSource
(
int
Source)
const
;
245
virtual
bool
ProvidesTransponder
(
const
cChannel
*Channel)
const
;
249
virtual
bool
ProvidesTransponderExclusively
(
const
cChannel
*Channel)
const
;
252
virtual
bool
ProvidesChannel
(
const
cChannel
*Channel,
int
Priority
=
IDLEPRIORITY
,
bool
*NeedsDetachReceivers = NULL)
const
;
266
virtual
bool
ProvidesEIT
(
void
)
const
;
270
virtual
int
NumProvidedSystems
(
void
)
const
;
276
virtual
int
SignalStrength
(
void
)
const
;
281
virtual
int
SignalQuality
(
void
)
const
;
286
virtual
const
cChannel
*
GetCurrentlyTunedTransponder
(
void
)
const
;
291
virtual
bool
IsTunedToTransponder
(
const
cChannel
*Channel)
const
;
294
virtual
bool
MaySwitchTransponder
(
const
cChannel
*Channel)
const
;
299
bool
SwitchChannel
(
const
cChannel
*Channel,
bool
LiveView);
302
static
bool
SwitchChannel
(
int
Direction);
306
private
:
307
eSetChannelResult
SetChannel
(
const
cChannel
*Channel,
bool
LiveView);
309
protected
:
310
virtual
bool
SetChannelDevice
(
const
cChannel
*Channel,
bool
LiveView);
312
public
:
313
static
int
CurrentChannel
(
void
) {
return
primaryDevice
?
currentChannel
: 0; }
315
static
void
SetCurrentChannel
(
const
cChannel
*Channel) {
currentChannel
= Channel ? Channel->
Number
() : 0; }
319
void
ForceTransferMode
(
void
);
321
int
Occupied
(
void
)
const
;
323
void
SetOccupied
(
int
Seconds);
331
virtual
bool
HasLock
(
int
TimeoutMs = 0)
const
;
337
virtual
bool
HasProgramme
(
void
)
const
;
340
341
// PID handle facilities
342
343
private
:
344
virtual
void
Action
(
void
);
345
protected
:
346
enum
ePidType
{
ptAudio
,
ptVideo
,
ptPcr
,
ptTeletext
,
ptDolby
,
ptOther
};
347
class
cPidHandle
{
348
public
:
349
int
pid
;
350
int
streamType
;
351
int
handle
;
352
int
used
;
353
cPidHandle
(
void
) {
pid
=
streamType
=
used
= 0;
handle
= -1; }
354
};
355
cPidHandle
pidHandles
[
MAXPIDHANDLES
];
356
bool
HasPid
(
int
Pid)
const
;
358
bool
AddPid
(
int
Pid,
ePidType
PidType =
ptOther
,
int
StreamType = 0);
360
void
DelPid
(
int
Pid,
ePidType
PidType =
ptOther
);
362
virtual
bool
SetPid
(
cPidHandle
*Handle,
int
Type,
bool
On);
370
public
:
371
void
DelLivePids
(
void
);
373
374
// Section filter facilities
375
376
private
:
377
cSectionHandler
*
sectionHandler
;
378
cEitFilter
*
eitFilter
;
379
cPatFilter
*
patFilter
;
380
cSdtFilter
*
sdtFilter
;
381
cNitFilter
*
nitFilter
;
382
protected
:
383
void
StartSectionHandler
(
void
);
387
void
StopSectionHandler
(
void
);
391
public
:
392
virtual
int
OpenFilter
(u_short Pid,
u_char
Tid,
u_char
Mask);
396
virtual
int
ReadFilter
(
int
Handle,
void
*Buffer,
size_t
Length);
400
virtual
void
CloseFilter
(
int
Handle);
405
void
AttachFilter
(
cFilter
*Filter);
407
void
Detach
(
cFilter
*Filter);
409
410
// Common Interface facilities:
411
412
private
:
413
time_t
startScrambleDetection
;
414
cCamSlot
*
camSlot
;
415
public
:
416
virtual
bool
HasCi
(
void
);
418
virtual
bool
HasInternalCam
(
void
) {
return
false
; }
424
void
SetCamSlot
(
cCamSlot
*
CamSlot
);
426
cCamSlot
*
CamSlot
(
void
)
const
{
return
camSlot
; }
429
430
// Image Grab facilities
431
432
public
:
433
virtual
uchar
*
GrabImage
(
int
&Size,
bool
Jpeg =
true
,
int
Quality = -1,
int
SizeX = -1,
int
SizeY = -1);
445
bool
GrabImageFile
(
const
char
*FileName,
bool
Jpeg =
true
,
int
Quality = -1,
int
SizeX = -1,
int
SizeY = -1);
450
451
// Video format facilities
452
453
public
:
454
virtual
void
SetVideoDisplayFormat
(
eVideoDisplayFormat
VideoDisplayFormat);
458
virtual
void
SetVideoFormat
(
bool
VideoFormat16_9);
461
virtual
eVideoSystem
GetVideoSystem
(
void
);
464
virtual
void
GetVideoSize
(
int
&Width,
int
&Height,
double
&VideoAspect);
471
virtual
void
GetOsdSize
(
int
&Width,
int
&Height,
double
&PixelAspect);
482
483
// Track facilities
484
485
private
:
486
tTrackId
availableTracks
[
ttMaxTrackTypes
];
487
eTrackType
currentAudioTrack
;
488
eTrackType
currentSubtitleTrack
;
489
cMutex
mutexCurrentAudioTrack
;
490
cMutex
mutexCurrentSubtitleTrack
;
491
int
currentAudioTrackMissingCount
;
492
bool
autoSelectPreferredSubtitleLanguage
;
493
bool
keepTracks
;
494
int
pre_1_3_19_PrivateStream
;
495
protected
:
496
virtual
void
SetAudioTrackDevice
(
eTrackType
Type);
498
virtual
void
SetSubtitleTrackDevice
(
eTrackType
Type);
500
public
:
501
void
ClrAvailableTracks
(
bool
DescriptionsOnly =
false
,
bool
IdsOnly =
false
);
506
bool
SetAvailableTrack
(
eTrackType
Type,
int
Index, uint16_t Id,
const
char
*Language = NULL,
const
char
*Description = NULL);
513
const
tTrackId
*
GetTrack
(
eTrackType
Type);
516
int
NumTracks
(
eTrackType
FirstTrack,
eTrackType
LastTrack)
const
;
519
int
NumAudioTracks
(
void
)
const
;
523
int
NumSubtitleTracks
(
void
)
const
;
525
eTrackType
GetCurrentAudioTrack
(
void
)
const
{
return
currentAudioTrack
; }
526
bool
SetCurrentAudioTrack
(
eTrackType
Type);
529
eTrackType
GetCurrentSubtitleTrack
(
void
)
const
{
return
currentSubtitleTrack
; }
530
bool
SetCurrentSubtitleTrack
(
eTrackType
Type,
bool
Manual =
false
);
536
void
EnsureAudioTrack
(
bool
Force =
false
);
540
void
EnsureSubtitleTrack
(
void
);
543
void
SetKeepTracks
(
bool
KeepTracks) {
keepTracks
= KeepTracks; }
547
548
// Audio facilities
549
550
private
:
551
bool
mute
;
552
int
volume
;
553
protected
:
554
virtual
int
GetAudioChannelDevice
(
void
);
557
virtual
void
SetAudioChannelDevice
(
int
AudioChannel);
559
virtual
void
SetVolumeDevice
(
int
Volume);
561
virtual
void
SetDigitalAudioDevice
(
bool
On);
564
public
:
565
bool
IsMute
(
void
)
const
{
return
mute
; }
566
bool
ToggleMute
(
void
);
568
int
GetAudioChannel
(
void
);
571
void
SetAudioChannel
(
int
AudioChannel);
574
void
SetVolume
(
int
Volume,
bool
Absolute =
false
);
577
static
int
CurrentVolume
(
void
) {
return
primaryDevice
?
primaryDevice
->
volume
: 0; }
//XXX???
578
579
// Player facilities
580
581
private
:
582
cPlayer
*
player
;
583
cPatPmtParser
patPmtParser
;
584
cTsToPes
tsToPesVideo
;
585
cTsToPes
tsToPesAudio
;
586
cTsToPes
tsToPesSubtitle
;
587
cTsToPes
tsToPesTeletext
;
588
bool
isPlayingVideo
;
589
protected
:
590
const
cPatPmtParser
*
PatPmtParser
(
void
)
const
{
return
&
patPmtParser
; }
593
virtual
bool
CanReplay
(
void
)
const
;
595
virtual
bool
SetPlayMode
(
ePlayMode
PlayMode);
598
virtual
int
PlayVideo
(
const
uchar
*Data,
int
Length);
605
virtual
int
PlayAudio
(
const
uchar
*Data,
int
Length,
uchar
Id);
613
virtual
int
PlaySubtitle
(
const
uchar
*Data,
int
Length);
620
virtual
int
PlayPesPacket
(
const
uchar
*Data,
int
Length,
bool
VideoOnly =
false
);
625
virtual
int
PlayTsVideo
(
const
uchar
*Data,
int
Length);
633
virtual
int
PlayTsAudio
(
const
uchar
*Data,
int
Length);
641
virtual
int
PlayTsSubtitle
(
const
uchar
*Data,
int
Length);
649
public
:
650
virtual
int64_t
GetSTC
(
void
);
661
virtual
bool
IsPlayingVideo
(
void
)
const
{
return
isPlayingVideo
; }
664
virtual
cRect
CanScaleVideo
(
const
cRect
&Rect,
int
Alignment =
taCenter
) {
return
cRect::Null
; }
685
virtual
void
ScaleVideo
(
const
cRect
&Rect =
cRect::Null
) {}
693
virtual
bool
HasIBPTrickSpeed
(
void
) {
return
false
; }
696
virtual
void
TrickSpeed
(
int
Speed);
706
virtual
void
Clear
(
void
);
710
virtual
void
Play
(
void
);
713
virtual
void
Freeze
(
void
);
715
virtual
void
Mute
(
void
);
719
virtual
void
StillPicture
(
const
uchar
*Data,
int
Length);
725
virtual
bool
Poll
(
cPoller
&Poller,
int
TimeoutMs = 0);
730
virtual
bool
Flush
(
int
TimeoutMs = 0);
736
virtual
int
PlayPes
(
const
uchar
*Data,
int
Length,
bool
VideoOnly =
false
);
746
virtual
int
PlayTs
(
const
uchar
*Data,
int
Length,
bool
VideoOnly =
false
);
762
bool
Replaying
(
void
)
const
;
764
bool
Transferring
(
void
)
const
;
766
void
StopReplay
(
void
);
768
bool
AttachPlayer
(
cPlayer
*Player);
770
void
Detach
(
cPlayer
*Player);
772
773
// Receiver facilities
774
775
private
:
776
mutable
cMutex
mutexReceiver
;
777
cReceiver
*
receiver
[
MAXRECEIVERS
];
778
public
:
779
int
Priority
(
void
)
const
;
782
protected
:
783
virtual
bool
OpenDvr
(
void
);
786
virtual
void
CloseDvr
(
void
);
788
virtual
bool
GetTSPacket
(
uchar
*&Data);
795
public
:
796
bool
Receiving
(
bool
Dummy =
false
)
const
;
798
bool
AttachReceiver
(
cReceiver
*Receiver);
800
void
Detach
(
cReceiver
*Receiver);
802
void
DetachAll
(
int
Pid);
804
virtual
void
DetachAllReceivers
(
void
);
806
};
807
815
816
class
cTSBuffer
:
public
cThread
{
817
private
:
818
int
f
;
819
int
cardIndex
;
820
bool
delivered
;
821
cRingBufferLinear
*
ringBuffer
;
822
virtual
void
Action
(
void
);
823
public
:
824
cTSBuffer
(
int
File,
int
Size,
int
CardIndex);
825
~cTSBuffer
();
826
uchar
*
Get
(
void
);
827
};
828
829
#endif //__DEVICE_H
830
Generated by
1.8.3.1