feat: receive ordered stream playback queues
This commit is contained in:
@@ -7,6 +7,9 @@
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <sys/types.h>
|
||||
#include <string_view>
|
||||
#include <thread>
|
||||
|
||||
@@ -26,6 +29,8 @@ public:
|
||||
void closeMedia() noexcept;
|
||||
// Call after the decoder joins; drains queued records and joins the writer.
|
||||
void finish() noexcept;
|
||||
// Reopen only this session's original private inode, never an arbitrary existing file.
|
||||
void resume();
|
||||
std::string error() const;
|
||||
|
||||
private:
|
||||
@@ -36,6 +41,9 @@ private:
|
||||
bool eligible = false;
|
||||
} snapshot;
|
||||
std::string mediaURL;
|
||||
std::string path;
|
||||
dev_t device = 0;
|
||||
ino_t inode = 0;
|
||||
std::function<double()> clock;
|
||||
bool live = false;
|
||||
bool hasSnapshot = false;
|
||||
@@ -58,4 +66,24 @@ private:
|
||||
void disable(const char *message, int osError = 0) noexcept;
|
||||
void writeRecords() noexcept;
|
||||
};
|
||||
|
||||
// Routes decoder-owned snapshots by immutable media identity; only the active writer runs.
|
||||
class ProgressReports {
|
||||
public:
|
||||
explicit ProgressReports(const std::string &path);
|
||||
ProgressReports() = default;
|
||||
void registerFile(const std::string &identity, const std::string &path);
|
||||
void begin(const std::string &identity, bool live = false) noexcept;
|
||||
void observe(const PlayerState &state) noexcept { if (active) active->observe(state); }
|
||||
void closeMedia() noexcept { if (active) active->closeMedia(); }
|
||||
void finish() noexcept;
|
||||
std::string error() const;
|
||||
private:
|
||||
struct Entry { std::string path; std::unique_ptr<ProgressReporter> reporter; };
|
||||
std::unique_ptr<ProgressReporter> single;
|
||||
std::map<std::string, Entry> entries;
|
||||
ProgressReporter *active = nullptr;
|
||||
mutable std::mutex mutex;
|
||||
std::string failure;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user