6 std::string path, std::string name,
const std::string& type_str,
9 : name(std::move(name))
10 , path(std::move(path))
13 const auto detected = identify(
this->path);
15 if (type_str.empty() || type_str ==
type_name(detected
)) {
17 }
else if (type_str ==
"local") {
19 }
else if (type_str ==
"file") {
21 }
else if (type_str ==
"rtsp") {
23 }
else if (type_str ==
"http") {
37 std::scoped_lock lock(other.lines_mtx);
38 lines = std::move(other.lines);
47 std::scoped_lock lock(lines_mtx, other.lines_mtx);
49 name = std::move(other.name);
50 path = std::move(other.path);
54 lines = std::move(other.lines);
61 if (path.rfind(
"/dev/video", 0) == 0) {
64 if (path.rfind(
"rtsp://", 0) == 0) {
67 if (path.rfind(
"http://", 0) == 0 || path.rfind(
"https://", 0) == 0) {
74 static constexpr std::array<std::string_view, 4> type_names {
75 "local",
"file",
"rtsp",
"http"
77 const auto idx =
static_cast<size_t>(type);
78 if (idx >= type_names.size()) {
81 return std::string(type_names[idx]);
86 static constexpr std::array<std::string_view, 3> pipeline_names {
87 "manual",
"automatic",
"none"
89 const auto idx =
static_cast<size_t>(pipeline);
90 if (idx >= pipeline_names.size()) {
93 return std::string(pipeline_names[idx]);
107 std::ostream& out,
const bool connections
109 out <<
"Stream(name=" << name <<
", path=" << path
110 <<
", type=" << type_name(type)
111 <<
", loop=" << (loop ?
"true" :
"false")
112 <<
", active_pipeline=" << pipeline_name(active) <<
")";
118 const auto names = line_names();
123 out <<
"\n\tConnected lines:";
124 for (
const auto& ln : names) {
143 std::scoped_lock lock(lines_mtx);
144 lines.emplace(line->name, line);
148 std::scoped_lock lock(lines_mtx);
149 return lines | std::views::keys
150 | std::ranges::to<std::vector<std::string>>();
155 std::scoped_lock lock(lines_mtx);
156 std::vector<line_ptr> out;
157 out.reserve(lines.size());
158 for (
const auto& lp : lines | std::views::values) {
Represents a single video stream and its analytic connections.
std::string get_name() const
Get logical stream name.
stream & operator=(stream &&other) noexcept
Move-assign a stream.
std::vector< line_ptr > lines_snapshot() const
Get a snapshot of all connected lines.
void activate(stream_pipeline pipeline=stream_pipeline::automatic)
Activate the stream in a pipeline.
stream(stream &&other) noexcept
Move-construct a stream.
bool loop
Looping behavior for file streams.
void dump(std::ostream &out, bool connections=false) const
Dump stream metadata to an output stream.
std::vector< std::string > line_names() const
Get a list of names of all connected lines.
bool is_looping() const
Whether the stream is configured to loop on exhaustion.
void connect_line(line_ptr line)
Connect a geometric line to this stream.
stream_pipeline pipeline() const
Get current pipeline activity of the stream.
void deactivate()
Deactivate the stream.
static std::string type_name(const stream_type type)
Convert a stream type to a canonical textual name.
std::string get_path() const
Get stream path or URL.
stream_type get_type() const
Get the stream transport/source type.
stream_type type
Detected or user-specified stream type.
static std::string pipeline_name(const stream_pipeline pipeline)
Convert a pipeline mode to its textual name.
stream_pipeline active
Currently active pipeline mode.
stream_pipeline
Processing pipeline mode for a stream.
std::shared_ptr< line const > line_ptr
Shared, immutable line pointer.
stream_type
Source/transport type of a video stream.