forked from berolinaro/dvbv5-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwatch.cpp
41 lines (33 loc) · 863 Bytes
/
watch.cpp
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
#include "DVBInterface.h"
#include "ChannelList.h"
#include "Service.h"
#include <iostream>
#include <fstream>
extern "C" {
#include <sys/poll.h>
}
int main(int argc, char **argv) {
if(argc<2) {
std::cerr << "Usage: " << argv[0] << " \"Channel name\"" << std::endl;
return 1;
}
DVBInterfaces cards = DVBInterfaces::all();
if(cards.size() == 0) {
std::cerr << "No DVB interfaces found" << std::endl;
return 1;
}
ChannelList channels("channels.dvb");
auto channel=channels.find(argv[1]);
if(!channel.first) {
std::cerr << "No such channel " << argv[1] << std::endl;
return 1;
}
cards[0].tune(channel.first);
cards[0].setup(*channel.second);
std::cerr << "You can now grab data from /dev/dvb/adapter0/dvr0. Press any key when done." << std::endl;
pollfd p;
p.fd = 0;
p.events = POLLIN;
while(!poll(&p, 1, 100000)) {}
return 0;
}