aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-08-05 10:22:41 +0200
committerdec05eba <dec05eba@protonmail.com>2021-08-05 10:29:32 +0200
commita0c0f0bd551155270b11ac23c7f1c526a20a44b9 (patch)
tree5058c250fce097684d75aa900d060c9d1519b591 /plugins
parent6c85194c3b1baef0eaa011c4f1b8e48e11860f45 (diff)
Youtube: attempt to auto-detect throttling and restart download
Diffstat (limited to 'plugins')
-rw-r--r--plugins/youtube/YoutubeMediaProxy.hpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/plugins/youtube/YoutubeMediaProxy.hpp b/plugins/youtube/YoutubeMediaProxy.hpp
index 28aa6fe..d50d8df 100644
--- a/plugins/youtube/YoutubeMediaProxy.hpp
+++ b/plugins/youtube/YoutubeMediaProxy.hpp
@@ -2,10 +2,13 @@
#include "../../include/Program.hpp"
#include <string>
+#include <functional>
// TODO: Sync sequence for video and audio (for live stream).
namespace QuickMedia {
+ using ThrottleHandler = std::function<void()>;
+
class YoutubeMediaProxy {
public:
enum Error {
@@ -29,7 +32,7 @@ namespace QuickMedia {
class YoutubeStaticMediaProxy : public YoutubeMediaProxy {
public:
- YoutubeStaticMediaProxy() = default;
+ YoutubeStaticMediaProxy(ThrottleHandler throttle_handler = nullptr);
YoutubeStaticMediaProxy(YoutubeStaticMediaProxy&) = delete;
YoutubeStaticMediaProxy&operator=(YoutubeStaticMediaProxy&) = delete;
~YoutubeStaticMediaProxy();
@@ -65,11 +68,19 @@ namespace QuickMedia {
bool download_header_remaining_sent = false;
int download_header_written_offset = 0;
int download_header_offset_to_end_of_header = 0;
+ time_t download_start_time = 0;
+ time_t throttle_start_time = 0;
+ int64_t total_downloaded_bytes = 0;
+ bool download_started = false;
+ bool throttle_started = false;
+ bool throttle_callback_called = false;
+ ThrottleHandler throttle_handler = nullptr;
bool client_request_finished = false;
std::string client_request_buffer;
char download_read_buffer[16384];
};
+ // TODO: Add throttle detection for live streams
class YoutubeLiveStreamMediaProxy : public YoutubeMediaProxy {
public:
YoutubeLiveStreamMediaProxy() = default;