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