VR-Engage  2.2
Loading...
Searching...
No Matches
streamingVideoUpdater.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file streamingVideoUpdater.h
7//! \brief Component for managing video streaming and screen capture functionality
8//! \ingroup vreCommonComponents
9
10#pragma once
11
15
16namespace makVre
17{
18class DtInitTable;
19class DtPlayerStation;
20} // namespace makVre
21
22namespace makVrv
23{
24class DtChannel;
25class DtChannelManager;
26class DtVideoStream;
27} // namespace makVrv
28
29namespace makVre
30{
32{
33//! \ingroup RoleConfigParams
34//! \defgroup StreamingVideoUpdaterRoleParams Streaming Video Updater Role Parameters
35//! \roleInherits{PlayerComponentRoleParams}
36//! Configuration Options for streaming video updater role.
37//! @{
38
39//! \vreRoleParam{defaultStreamChannel,string,"Channel 1",streamingVideoUpdater,Default channel name for video streaming output.}
40constexpr const char* defaultStreamChannel = "defaultStreamChannel";
41
42//! \vreRoleParam{defaultStreamLabel,string,"Main Window",streamingVideoUpdater,Default label for the video stream display.}
43constexpr const char* defaultStreamLabel = "defaultStreamLabel";
44
45//! \vreRoleParam{defaultStreamWindow,string,"Window 1",streamingVideoUpdater,Default window name for video streaming capture.}
46constexpr const char* defaultStreamWindow = "defaultStreamWindow";
47
48//! \vreRoleParam{readBuffer,string,"back",streamingVideoUpdater,Buffer selection for video capture (front or back buffer).}
49constexpr const char* readBuffer = "readBuffer";
50
51//! \vreRoleParam{streamName,string,"",streamingVideoUpdater,Name identifier for the video stream configuration.}
52constexpr const char* streamName = "streamName";
53
54//! \vreRoleParam{streamOutputFilenameOverride,string,"",streamingVideoUpdater,Override filename for stream output file generation.}
55constexpr const char* streamOutputFilenameOverride = "streamOutputFilenameOverride";
56
57//! \vreRoleParam{videoStreamAutoStart,bool,false,streamingVideoUpdater,Whether to automatically start video streaming when the component initializes.}
58constexpr const char* videoStreamAutoStart = "videoStreamAutoStart";
59
60//! @}
61} // namespace StreamingVideoUpdaterConfig
62}
63
64//! \brief Type identifier for DtStreamingVideoUpdater component
65constexpr const char* DtStreamingVideoUpdaterType = "DtStreamingVideoUpdater";
66
67//! \brief Component for enabling video streaming and screen capture functionality
68//!
69//! DtStreamingVideoUpdater manages streaming video capture from specified channels
70//! to external formats. It supports toggling streams on and off, selecting video sources,
71//! capturing screenshots, and automatically starting streams when channels are created.
72//! The component maintains state attributes for UI display and responds to messaging
73//! system events for control.
75{
76public:
77 //! \brief Constructor for DtStreamingVideoUpdater
78 //!
79 //! Initializes the component with default stream settings
81
82 //! \brief Virtual destructor for DtStreamingVideoUpdater
83 virtual ~DtStreamingVideoUpdater() override;
84
85 //! \brief Initializes the streaming video updater component
86 //! \param player Pointer to the player station this component belongs to
87 //! \param config Configuration table containing streaming settings
88 //! \return True if initialization succeeded, false otherwise
89 //!
90 //! Reads configuration settings including stream name, read buffer type,
91 //! default source channel, and auto-start options. Sets up message handlers
92 //! and channel connection signals.
94 //! \brief Called every frame to update the streaming state
95 //! \param dt Delta time since the last frame in seconds
96 //!
97 //! Attempts auto-start of video streaming if the retry flag is set
98 virtual void tick(double dt) override;
99 //! \brief Shuts down the streaming video updater component
100 //!
101 //! Stops active video streams and removes message handlers and channel signals
102 virtual void shutdown() override;
103
104 //! \brief Returns the type identifier for this component
105 //! \return The type string for DtStreamingVideoUpdater
106 virtual const char* type() const override;
107
108 //! \brief Starts the configured video stream
109 //!
110 //! Configures and activates the video stream with the current settings,
111 //! applying any filename overrides if specified
112 virtual void startVideoStream();
113
114 //! \brief Stops the active video stream
115 //!
116 //! Halts the current video stream and updates the stream state attribute
117 virtual void stopVideoStream();
118
119 //! \brief Toggles the video stream on or off
120 //!
121 //! Starts the stream if it's stopped or stops it if it's running
122 virtual void toggleVideoStream();
123
124 //! \brief Selects a new video source for streaming
125 //! \param guiText Display name for the source in the UI
126 //! \param window Name of the window containing the source channel
127 //! \param channel Name of the channel to capture
128 //!
129 //! Updates the video stream to use a different source channel, handling
130 //! stream restart if necessary and updating state attributes
131 virtual void selectVideoSource(const std::string& guiText, const std::string& window, const std::string& channel);
132
133protected:
134 //! \brief Handles toggle video stream messages
135 //! \param msg Toggle video stream message
136 //! \return Message handling result indicating the message was handled
137 //!
138 //! Processes messages to toggle the video stream state
140
141 //! \brief Handles video source selection messages
142 //! \param msg Select video source message
143 //! \return Message handling result indicating the message was handled
144 //!
145 //! Processes messages to change the video stream source channel
147
148 //! \brief Slot called when a channel is added to the system
149 //! \param mgr Pointer to the channel manager
150 //! \param channel Pointer to the newly added channel
151 //!
152 //! Updates stream state when a new channel is added, enabling auto-start
153 //! if the channel matches the current stream source
154 virtual void slot_channelAdded(makVrv::DtChannelManager* mgr, makVrv::DtChannel* channel);
155
156 //! \brief Slot called when a channel is about to be removed
157 //! \param mgr Pointer to the channel manager
158 //! \param channel Pointer to the channel being removed
159 //!
160 //! Stops streaming and updates state when the current source channel is removed
161 virtual void slot_channelToBeRemoved(makVrv::DtChannelManager* mgr, makVrv::DtChannel* channel);
162
163 //! \brief Checks if a specified channel exists
164 //! \param windowName Name of the window
165 //! \param channelName Name of the channel
166 //! \return True if the channel exists, false otherwise
167 //!
168 //! Verifies whether a specified window and channel combination exists in the system
169 virtual bool channelExists(const std::string& windowName, const std::string& channelName);
170
171 //! \brief Handles screen capture messages
172 //! \param msg Screen capture message
173 //! \return Message handling result indicating the message was handled
174 //!
175 //! Processes messages to capture a screenshot of the current video source
177
178 //! \brief Updates the output filename for a video stream
179 //! \param stream Pointer to the video stream to update
180 //!
181 //! Modifies the stream's output filename based on the override setting,
182 //! supporting timestamp substitution with [t] in the filename
183 virtual void updateStreamFilename(makVrv::DtVideoStream* stream);
184
185 //! \brief Name of the video stream configuration to use
186 std::string myStreamName;
187
188 //! \brief Buffer type to read for streaming (back, front, back_hardware, front_hardware)
189 //!
190 //! Determines whether to include graphical overlays in the stream
191 std::string myReadBuffer;
192
193 //! \brief Flag indicating whether to automatically start streaming when the channel appears
195
196 //! \brief Optional override for the stream output filename
197 //!
198 //! If not empty, replaces the filename in the stream configuration
200
201 //! \brief Flag indicating to retry auto-starting the stream on the next tick
203};
std::string myStreamOutputFilenameOverride
Optional override for the stream output filename.
Definition streamingVideoUpdater.h:199
virtual void slot_channelAdded(makVrv::DtChannelManager *mgr, makVrv::DtChannel *channel)
Slot called when a channel is added to the system.
virtual void toggleVideoStream()
Toggles the video stream on or off.
virtual void selectVideoSource(const std::string &guiText, const std::string &window, const std::string &channel)
Selects a new video source for streaming.
virtual makVre::DtVreMessageResult handleScreenCapture(makVre::DtVreMessage *msg)
Handles screen capture messages.
std::string myReadBuffer
Buffer type to read for streaming (back, front, back_hardware, front_hardware)
Definition streamingVideoUpdater.h:191
virtual void tick(double dt) override
Called every frame to update the streaming state.
virtual makVre::DtVreMessageResult handleSelectVideoStreamChannel(makVre::DtVreMessage *msg)
Handles video source selection messages.
bool myRetryAutoStart
Flag indicating to retry auto-starting the stream on the next tick.
Definition streamingVideoUpdater.h:202
virtual bool channelExists(const std::string &windowName, const std::string &channelName)
Checks if a specified channel exists.
virtual void shutdown() override
Shuts down the streaming video updater component.
virtual void stopVideoStream()
Stops the active video stream.
DtStreamingVideoUpdater()
Constructor for DtStreamingVideoUpdater.
virtual void startVideoStream()
Starts the configured video stream.
virtual void updateStreamFilename(makVrv::DtVideoStream *stream)
Updates the output filename for a video stream.
std::string myStreamName
Name of the video stream configuration to use.
Definition streamingVideoUpdater.h:186
virtual bool initialize(makVre::DtPlayerStation *player, makVre::DtInitTable &config) override
Initializes the streaming video updater component.
virtual makVre::DtVreMessageResult handleToggleVideoStream(makVre::DtVreMessage *msg)
Handles toggle video stream messages.
bool myAutoStartStream
Flag indicating whether to automatically start streaming when the channel appears.
Definition streamingVideoUpdater.h:194
virtual ~DtStreamingVideoUpdater() override
Virtual destructor for DtStreamingVideoUpdater.
virtual void slot_channelToBeRemoved(makVrv::DtChannelManager *mgr, makVrv::DtChannel *channel)
Slot called when a channel is about to be removed.
virtual const char * type() const override
Returns the type identifier for this component.
Table-based access to Lua state for configuration data.
Definition initializer.h:38
Base class for all role components in VR-Engage.
Definition playerComponent.h:78
virtual DtPlayerStation & player()
Gets the player station.
Class for managing the user interface for engaged roles.
Definition playerStation.h:51
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
constexpr const char * streamName
Definition streamingVideoUpdater.h:52
constexpr const char * defaultStreamChannel
Definition streamingVideoUpdater.h:40
constexpr const char * readBuffer
Definition streamingVideoUpdater.h:49
constexpr const char * defaultStreamLabel
Definition streamingVideoUpdater.h:43
constexpr const char * streamOutputFilenameOverride
Definition streamingVideoUpdater.h:55
constexpr const char * defaultStreamWindow
Definition streamingVideoUpdater.h:46
constexpr const char * videoStreamAutoStart
Definition streamingVideoUpdater.h:58
Defines export/import macros for the vreCommonComponents library.
#define VRECOMMONCOMPONENTS_DLL
DLL export/import macro for the vreCommonComponents library.
Definition export.h:28
Definition streamingVideoUpdater.h:32
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
Definition appLauncherComponent.h:28
Defines the DtPlayerComponent base class for VR-Engage role components.
constexpr const char * DtStreamingVideoUpdaterType
Type identifier for DtStreamingVideoUpdater component.
Definition streamingVideoUpdater.h:65
Defines the base class for all VREngage messages.