This commit is contained in:
2026-04-01 21:14:30 -03:00
parent 0f7e4424bc
commit 172f21a845
9 changed files with 139 additions and 106 deletions

View File

@@ -25,6 +25,7 @@ class ChtWindow(Adw.ApplicationWindow):
self.set_title(APP_NAME)
self.set_default_size(1400, 900)
self._streaming = False
self._gone_live = False
self._stream_mgr = None
self._tracker = None
self._known_frames = set()
@@ -72,6 +73,7 @@ class ChtWindow(Adw.ApplicationWindow):
self._connect_btn.remove_css_class("suggested-action")
self._connect_btn.add_css_class("destructive-action")
self._streaming = True
self._gone_live = False
# Create session
self._stream_mgr = StreamManager()
@@ -91,15 +93,11 @@ class ChtWindow(Adw.ApplicationWindow):
)
self._tracker.start()
# Go LIVE after a short delay — ffmpeg needs time to establish TCP
# and begin writing both outputs. UDP relay starts immediately after.
GLib.timeout_add(4000, self._go_live_once)
# Start scene detection
self._stream_mgr.start_scene_detector(on_new_frames=self._on_new_scene_frames)
# Start polling for frame thumbnails
GLib.timeout_add(3000, self._poll_frames)
GLib.timeout_add(1000, self._poll_frames)
# Tick the LIVE cursor every second
GLib.timeout_add(1000, self._tick_live)
@@ -123,6 +121,9 @@ class ChtWindow(Adw.ApplicationWindow):
def _on_duration_update(self, duration):
"""Called from RecordingTracker thread."""
GLib.idle_add(self._timeline.set_duration, duration)
if not self._gone_live:
self._gone_live = True
GLib.idle_add(self._go_live_once)
def _on_new_scene_frames(self, frames):
"""Called from scene detector thread when new frames are found."""
@@ -223,7 +224,8 @@ class ChtWindow(Adw.ApplicationWindow):
# Horizontal scrolling strip — storyboard style
self._frames_scroll = Gtk.ScrolledWindow()
self._frames_scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER)
self._frames_scroll.set_min_content_height(180) # 144px thumb + label + padding
self._frames_scroll.set_min_content_height(168)
self._frames_scroll.set_size_request(-1, 168) # 144px thumb + label + padding
self._frames_strip = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=4)
self._frames_strip.set_margin_start(4)
@@ -366,9 +368,10 @@ class ChtWindow(Adw.ApplicationWindow):
label.set_ellipsize(Pango.EllipsizeMode.END)
box.append(label)
# Click to seek into scrub mode
# Click to highlight — does NOT switch mode or seek
# (future: jump to timestamp in scrub bar without leaving live)
gesture = Gtk.GestureClick()
gesture.connect("released", lambda g, n, x, y: self._timeline.seek(timestamp))
gesture.connect("released", lambda g, n, x, y: log.debug("Frame clicked: %s at %.1fs", frame_id, timestamp))
box.add_controller(gesture)
self._frames_strip.append(box)