-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlivestreamerProcess.cpp
43 lines (34 loc) · 1.14 KB
/
livestreamerProcess.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
42
43
#include "livestreamerProcess.h"
#include <vector>
livestreamerProcess::livestreamerProcess(const Glib::ustring& streamUrl, const Glib::ustring& streamQuality)
{
using namespace Glib;
std::vector<ustring> argv;
argv.push_back("streamlink");
argv.push_back(streamUrl);
argv.push_back(streamQuality);
spawn_async_with_pipes("",
argv,
SPAWN_SEARCH_PATH | SPAWN_DO_NOT_REAP_CHILD,
SlotSpawnChildSetup(),
&pid,
&stdin,
&stdout,
&stderr
);
output = IOChannel::create_from_fd(stdout);
signal_child_watch().connect([this] (auto pid, auto status) {
delete this;
}, pid);
}
livestreamerProcess::~livestreamerProcess()
{
for (auto &connection : connections) {
connection.disconnect();
}
Glib::spawn_close_pid(pid);
}
void livestreamerProcess::addOutputWatch(const sigc::slot< bool, Glib::IOCondition >& slot)
{
connections.push_back(Glib::signal_io().connect(slot, stdout, Glib::IO_IN));
}