5c39662cc2
A gtkmm-4.0 control panel (behind -Dgui=true, default off): refresh shows discovered receivers (grouped and preference-sorted), a bitrate scale, and start/stop that runs the whole session on a worker thread so the interactive portal picker never blocks the UI. The CLI and the GUI now share the new sc_app_core static library holding the pipelines, session orchestration (negotiation + PLI feedback), and a state store. The sender pipeline publishes its state to $XDG_RUNTIME_DIR/screencast/sender.json (session id, receiver, bitrate, pid, start time; stale files detected by pid liveness) and persists the last session for one-click restarts. The new 'screencast waybar' subcommand prints a waybar module line and its --toggle flag stops a running sender gracefully or spawns a detached restart of the last receiver. Waybar on the dev machine is wired: custom/screencast module with click-to-toggle and right-click panel, plus styles, with a timestamped backup of both config files. Both binaries are installed to /usr/local/bin. Validated: waybar output (idle and streaming states with a synthetic state file), GUI launches on the desktop (window observed via hyprctl), meson test 5/5 in both build configurations, formatting clean.
56 lines
1.7 KiB
C++
56 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include "screencast/app/pipeline.h"
|
|
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <variant>
|
|
|
|
namespace sc {
|
|
|
|
// A running sender session: it negotiated over signaling (keeping the
|
|
// channel open for PLI feedback) and drives the sender pipeline. Shared by
|
|
// the CLI, the GUI, and the waybar widget's one-click restart.
|
|
class SenderSession {
|
|
public:
|
|
// Blocking: connects, offers, waits for the answer, and starts the
|
|
// pipeline — which includes the portal's interactive source picker.
|
|
// Returns an error message on failure.
|
|
static std::variant<SenderSession, std::string>
|
|
start(const Endpoint& signaling_endpoint, int bitrate_kbps, CaptureTarget target);
|
|
|
|
// Ordering for trying a receiver's addresses: private IPv4 first (LANs,
|
|
// most reliable), then public IPv4, ULA, and global IPv6. 6to4 (2002::)
|
|
// and link-local addresses last: 6to4 is frequently unreachable between
|
|
// LAN peers, and link-local needs a scope id to even route.
|
|
static int address_preference(std::string_view host);
|
|
|
|
SenderSession() = default;
|
|
~SenderSession();
|
|
|
|
SenderSession(SenderSession&& other) noexcept;
|
|
SenderSession& operator=(SenderSession&& other) noexcept;
|
|
|
|
// Graceful stop: withdraws state and closes the signaling channel.
|
|
void stop();
|
|
|
|
[[nodiscard]] const std::string& session_id() const {
|
|
return session_id_;
|
|
}
|
|
|
|
[[nodiscard]] const std::string& receiver() const {
|
|
return receiver_;
|
|
}
|
|
|
|
private:
|
|
std::unique_ptr<class SignalingChannel> channel_;
|
|
std::unique_ptr<SenderPipeline> pipeline_;
|
|
std::string session_id_;
|
|
std::string receiver_;
|
|
bool stopped_ = false;
|
|
};
|
|
|
|
} // namespace sc
|