forked from peterkvt80/vbit2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice.h
81 lines (67 loc) · 2.16 KB
/
service.h
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
#ifndef _SERVICE_H_
#define _SERVICE_H_
#include <iostream>
#include <iomanip>
#include <thread>
#include <ctime>
#include <list>
#include "configure.h"
#include "pagelist.h"
#include "packet.h"
#include <packetsource.h>
#include <packetmag.h>
#include <packet830.h>
#include <packetsubtitle.h>
/// Eight magazines and subtitles (maybe other packets too)
#define STREAMS 9
namespace ttx
{
/** A Service creates a teletext stream from packet sources.
* Packet sources are magazines, subtitles, Packet 830 and databroadcast.
* Service:
* Instances the packet sources
* Sends them timing events (cues for field timing etc.)
* Polls the packet sources for packets to send
* Sends the packets.
*
*/
class Service
{
public:
Service();
/**
* @param configure A Configure object with all the settings
* @param pageList A pageList object already loaded with pages
*/
Service(Configure* configure, PageList* pageList);
~Service();
/**
* Creates a worker thread and does not terminate (at least for now)
* @return Nothing useful yet. Perhaps return an error status if something goes wrong
*/
int run();
/** Part of Newfor subtitles implementation
* \return The packet source handling the subtitles
*/
vbit::PacketSubtitle* GetSubtitle(){return _subtitle;};
private:
// Member variables that define the service
Configure* _configure; /// Member reference to the configuration settings
PageList* _pageList; /// Member reference to the pages list
// Member variables for event management
uint8_t _linesPerField;
uint8_t _lineCounter; // Which VBI line are we on? Used to signal a new field.
uint8_t _fieldCounter; // Which field? Used to time packet 8/30
std::list<vbit::PacketSource*> _Sources; /// A list of packet sources
time_t _then;
vbit::PacketSubtitle* _subtitle; // Newfor needs to know which packet source is doing subtitles
// Member functions
void _register(vbit::PacketSource *src); /// Register packet sources
/**
* @brief Check if anything changed, and if so signal the event to the packet sources.
* Must be called once per transmitted row so that it can maintain a field count
*/
void _updateEvents();
};
}
#endif