-
Notifications
You must be signed in to change notification settings - Fork 0
/
ffmpeghandler.h
79 lines (58 loc) · 2.25 KB
/
ffmpeghandler.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
#pragma once
#include <string>
#include <thread>
#include "process.hpp"
#include "browserclient.h"
#include "vdrclient.h"
#include "transcodeconfig.h"
#include "json.hpp"
#include "m3u8handler.h"
using json = nlohmann::json;
extern std::map<std::string, std::string> transparentVideos;
class FFmpegHandler {
private:
std::string ffmpeg;
TinyProcessLib::Process *streamHandler;
std::thread *readerThread;
public:
FFmpegHandler(std::string browserIp, int browserPort, std::string vdrIp, int vdrPort, TranscodeConfig& tc, BrowserClient* client, std::string movie_path, const std::string& transparent_movie);
~FFmpegHandler();
std::shared_ptr<std::string>
probeVideo(std::string url, std::string position, std::string cookies, std::string referer, std::string userAgent, std::string postfix);
bool streamVideo(std::string url, std::string position, std::string cookies, std::string referer, std::string userAgent);
bool pauseVideo();
bool resumeVideo(std::string position);
void stopVideo();
bool seekTo(std::string pos);
bool hasStreamError() { return streamError; };
bool stopHandler() { return stopRequest; };
std::string getAudioInfo();
std::string getVideoName() { return transparentVideoFile; };
private:
std::string browserIp;
int browserPort;
bool streamError;
bool stopRequest;
std::string cookies;
std::string referer;
std::string userAgent;
std::string postfix;
std::string transparentVideoFile;
// non-m3u streams
json bstreams;
bool ffmpegCopy;
std::string duration;
// m3u streams
m3u_stream m3u;
std::string currentUrl;
BrowserClient* browserClient;
VdrClient* vdrClient;
TranscodeConfig transcodeConfig;
std::string movie_path;
std::string transparent_movie;
private:
std::shared_ptr<std::string> probe(const std::string& url);
bool createVideoWithLength(std::string seconds, const std::string& name);
std::vector<std::string> prepareStreamCmd(std::string url, std::string position, std::string cookies, std::string referer, std::string userAgent);
std::vector<std::string> prepareStreamM3uCmd(std::string url, std::string position, std::string cookies, std::string referer, std::string userAgent);
};