-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcontext.hpp
97 lines (76 loc) · 1.87 KB
/
context.hpp
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
#ifndef _TSD_CONTEXT_HPP_
#define _TSD_CONTEXT_HPP_
#include <iostream>
#include <memory>
#include <map>
#include <string>
#include "util.hpp"
#include "crc.hpp"
#include "transport_packet.hpp"
#include "view.hpp"
#include "ts_trimmer.hpp"
#include "boost/optional.hpp"
namespace tsd {
class filter;
class section_filter;
class pes_filter;
class context
{
public:
context(std::unique_ptr<view> view);
void clear();
void handle_packet(const transport_packet& p);
void open_filter(
uint16_t pid,
std::unique_ptr<filter> f);
void open_section_filter(
uint16_t pid,
std::unique_ptr<section_filter> f);
void open_pes_filter(
uint16_t pid,
std::unique_ptr<pes_filter> f);
void open_pcr_filter(uint16_t pid);
bool is_opened(uint16_t pid) const;
view& get_view();
uint64_t get_packet_num() const {
return packet_counter_;
}
void set_ts_trimmer(std::unique_ptr<ts_trimmer> t) {
ts_trimmer_ = std::move(t);
}
void signal_pcr(uint64_t pcr) {
if(ts_trimmer_)
ts_trimmer_->signal_pcr(pcr);
}
void signal_pmt() {
if(ts_trimmer_)
ts_trimmer_->signal_pmt();
}
void signal_eit() {
if(ts_trimmer_)
ts_trimmer_->signal_eit();
}
private:
void set_initial_filters();
private:
std::map<
uint16_t,
std::unique_ptr<filter> > pids_;
std::unique_ptr<view> view_;
std::unique_ptr<ts_trimmer> ts_trimmer_;
uint64_t packet_counter_;
public:
boost::optional<uint16_t> transport_stream_id;
boost::optional<program_association_table> pat;
std::map<uint16_t, uint16_t> program_pcr;
boost::optional<uint64_t> first_pcr;
boost::optional<uint64_t> latest_pcr;
boost::optional<uint64_t> baseline_pcr;
boost::optional<time_t> baseline_time;
std::vector<std::pair<
uint16_t, // program_number
service_descriptor> > service_descriptors;
};
}
#include "context_impl.hpp"
#endif