mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-09-28 17:57:59 +03:00
## Link to GitHub Issue or related Pull Request, if one exists #0 ## Description of change MSE method of streaming video needs the dimensions up front. This new api delivers that. Also provides an easier way to determine which screens are available and a way to discover port number. ## Testing See pending changes in substream project
44 lines
1.3 KiB
C++
44 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
#include "capture_pump.h"
|
|
|
|
namespace api {
|
|
|
|
// writes bytes to the client; false once the connection is gone
|
|
using StreamSend = std::function<bool(const void *, size_t)>;
|
|
|
|
// one wire format, instantiated per connection so it can keep encoder state across frames
|
|
class StreamWriter {
|
|
public:
|
|
virtual ~StreamWriter() = default;
|
|
|
|
StreamWriter(const StreamWriter &) = delete;
|
|
StreamWriter &operator=(const StreamWriter &) = delete;
|
|
|
|
// value for the HTTP Content-Type response header
|
|
virtual std::string content_type() const = 0;
|
|
|
|
// for formats that open with an init segment; runs once before any frame
|
|
virtual bool begin(const StreamSend &send) { return true; }
|
|
|
|
virtual bool write(const StreamSend &send, const capture_pump::Frame &frame) = 0;
|
|
|
|
protected:
|
|
StreamWriter() = default;
|
|
};
|
|
|
|
// null when the path does not name a format this build supports
|
|
std::unique_ptr<StreamWriter> make_stream_writer(
|
|
const std::string &path, int quality, int fps);
|
|
|
|
// name and path of every format compiled into this build, for clients to pick from
|
|
std::vector<std::pair<std::string, std::string>> stream_formats();
|
|
}
|