-
Notifications
You must be signed in to change notification settings - Fork 16
/
service.h
105 lines (87 loc) · 3.82 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#ifndef _SERVICE_H_
#define _SERVICE_H_
#include <iostream>
#include <iomanip>
#include <thread>
#include <ctime>
#include <list>
#include "configure.h"
#include "debug.h"
#include "pagelist.h"
#include "packetServer.h"
#include "datacastServer.h"
#include "packet.h"
#include "packetsource.h"
#include "packetmag.h"
#include "packet830.h"
#include "packetsubtitle.h"
#include "packetDebug.h"
#include "masterClock.h"
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:
/**
* @param configure A Configure object with all the settings
* @param pageList A pageList object already loaded with pages
*/
Service(Configure* configure, vbit::Debug* debug, PageList* pageList, PacketServer* packetServer, DatacastServer *datacastServer);
~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
vbit::Debug* _debug;
PageList* _pageList; /// Member reference to the pages list
vbit::PacketMag** _magList;
PacketServer* _packetServer;
DatacastServer* _datacastServer;
// Member variables for event management
uint16_t _linesPerField;
uint16_t _datacastLines;
uint16_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
uint64_t _PTS; // presentation timestamp counter
bool _PTSFlag; // generate PCR and PTS
std::list<vbit::PacketSource*> _magazineSources; // A list of packet sources for magazine data
std::list<vbit::PacketSource*> _datacastSources; // A list of sources for independent data line packets
vbit::PacketSubtitle* _subtitle; // Newfor needs to know which packet source is doing subtitles
vbit::Packet830* _packet830; // BSDP packet source
vbit::PacketDebug* _packetDebug; // Debug packet source
// Member functions
void _register(std::list<vbit::PacketSource*> *list, 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();
/* output a packet in the desired format */
void _packetOutput(vbit::Packet* pkt);
/* queue up packets for outputting as a Packetised Elementary Stream */
std::vector<std::vector<uint8_t>> _PESBuffer;
Configure::OutputFormat _OutputFormat;
uint16_t _PID;
uint8_t _tscontinuity;
/* queue up a frame of packets for the packet server */
std::vector<std::vector<uint8_t>> _FrameBuffer;
};
}
#endif