NDEVR
API Documentation
VLCCameraViewfinal

Camera view widget that uses VLC for video playback and recording. More...

Inheritance diagram for VLCCameraView:
[legend]
Collaboration diagram for VLCCameraView:
[legend]

Public Types

enum  VLCOutputCodec {
  MPEG2Video , MPEG4Video , H264 , Theora ,
  CodecSize
}
 Video codecs supported by VLC output. More...
enum  VLCOutputMux {
  TS , PS , MP4 , OGG ,
  AVI , MuxSize
}
 Output container (mux) formats supported by VLC. More...
Public Types inherited from PhysicalCameraView
enum  ViewMode { e_loading , e_error , e_camera }
 Describes the current display mode of the camera view. More...

Public Member Functions

 VLCCameraView ()
 Constructs a VLCCameraView with default settings.
 VLCCameraView (const DynamicPointer< Camera > &camera, InfoPipe *log, QWidget *parent=nullptr)
 Constructs a VLCCameraView for a specific camera.
virtual ~VLCCameraView ()
 Destroys the VLCCameraView and releases VLC resources.
void addSubtitle (const String &subtitle)
 Adds a subtitle text entry to the subtitle writer.
virtual Angle< fltp08cameraRotation () override
 Returns the current camera rotation angle.
bool event (QEvent *event) override
 Handles Qt events for this widget.
virtual QImage grabFramebuffer () override
 Captures the current video frame as a QImage.
virtual void refreshInstance () override
 Refreshes the VLC instance and reconnects the media source.
virtual void setCameraRotation (Angle< fltp08 > rotation) override
 Sets the camera rotation angle.
virtual bool setCameraSource (const StringView &connection_id) override
 Sets the camera source connection string.
virtual void setCameraZoom (fltp08 zoom) override
 Sets the camera zoom level.
virtual void setRecordingState (RecordingState recording_state) override
 Sets the recording state of this camera view.
Public Member Functions inherited from PhysicalCameraView
StringView activeCodec () const
 Returns the currently active codec identifier.
StringView activeVideoMux () const
 Returns the currently active video muxer identifier.
QWidget * activeWidget () const
 Returns the currently active widget in the stacked display.
virtual void addWidget (const QPointer< QWidget > &button) override
 Adds an overlay widget to the camera view.
ToolButtonSettings buttonSettings () const
 Returns the current toolbar button visibility settings.
virtual ConstPointer< Cameracamera () const override
 Returns a read-only pointer to the Camera.
virtual DynamicPointer< Cameracamera () override
 Returns a mutable pointer to the Camera.
bool event (QEvent *event) override
 Processes a Qt event.
virtual UUID id () const override
 Returns the unique identifier for this camera view.
ButtoninvertImageButton () const
 Returns the invert colors button.
void leaveEvent (QEvent *leave) override
 Handles the mouse leaving the widget area.
ButtonlightButton () const
 Returns the light toggle button.
virtual QPointer< QWidget > lightingSliderWidget ()
 Returns the lighting brightness slider widget.
LogPtr log () const
 Returns the current logger.
fltp08 maxZoomOut () const
 Returns the maximum zoom-out factor for this camera.
void mediaEnd ()
 Slot called when media playback reaches the end.
void mediaError ()
 Slot called when a media playback error occurs.
void mediaOpening ()
 Slot called when media is opening/buffering.
void mediaPlayingSlot ()
 Slot called when media playback begins.
void mediaStateChanged ()
 Slot called when the media player state changes.
void mediaStopped ()
 Slot called when media playback is stopped.
void mouseReleaseEvent (QMouseEvent *releaseEvent) override
 Handles mouse release events for the camera view.
RecordingState recordingState () const override
 Returns the current recording state.
ButtonrefreshButton () const
 Returns the refresh/reconnect button.
virtual void removeWidget (const QPointer< QWidget > &button) override
 Removes an overlay widget from the camera view.
void requestLight (bool light_on)
 Emitted to request turning the camera light on or off.
void requestLightBrightness (fltp04 percent)
 Emitted to request a specific light brightness level.
virtual void resetToolRibbon () override
 Resets the tool ribbon to its default configuration.
File screenshotPath () const
 Returns the configured screenshot output path.
void setAutoRotateCamera (bool auto_rotate)
 Enables or disables automatic camera rotation based on device orientation.
void setButtonSettings (const ToolButtonSettings &settings)
 Applies new toolbar button visibility settings.
void setConnectingIcon (const StringView &image)
 Sets the icon shown while the camera is connecting.
void setConnectingMessage (const TranslatedString &message)
 Sets the message displayed while the camera is connecting.
void setErrorIcon (const StringView &image)
 Sets the icon shown when the camera is in an error state.
void setErrorState (bool is_in_error_state)
 Sets whether the camera is in an error state, updating the display accordingly.
virtual void setIconSizeMultiplier (fltp04 multiplier) override
 Sets a multiplier for toolbar icon sizes.
void setLightBrightness (fltp04 percent)
 Sets the brightness level of the camera light.
void setLog (LogPtr log)
 Sets the logger for this camera view.
void setReadyForImageCapture (bool ready)
 Sets whether the camera is ready to capture an image.
void setRecordingElapsedTime (const TimeSpan &span)
 Updates the displayed recording elapsed time.
void setScreenshotFileName (const StringView &file_name)
 Sets the base file name used for screenshot files.
void setScreenshotPath (const File &file)
 Sets the file path used for saving screenshots.
void setSettingsVisible (bool visible, PopupInfo info)
 Shows or hides the settings widget.
void setSettingsWidget (QWidget *settings_widget, bool is_popup=false)
 Sets a custom settings widget for camera configuration.
virtual void setSwapMode (SwapMode mode) override
 Sets the buffer swap mode for rendering.
virtual void setTouchTheme (bool touch_theme) override
 Enables or disables the touch-optimized theme.
void setupForCaptureMode (bool capture_mode)
 Configures the view for image capture mode, adjusting UI elements.
void setVideoOutputPath (const File &file)
 Sets the file path used for saving recorded video.
virtual void showToolRibbon (bool show_ribbon) override
 Shows or hides the tool ribbon overlay.
QWidget * stack () const
 Returns the stacked widget used for switching between view modes.
virtual void startNewRecording (StringView file_name=StringView())
 Begins a new video recording session.
virtual void stopAndSaveRecording ()
 Stops the current recording and saves the video file.
void takeImage ()
 Captures a screenshot from the current camera frame.
ButtontakeImageButton () const
 Returns the screenshot capture button.
void tryToConnect ()
 Attempts to establish a connection to the camera source.
virtual void updateView () override
 Refreshes the camera view display.
File videoPath () const
 Returns the configured video output path.
void windowCapturedEvent (QEvent *event)
 Handles events forwarded from the embedded window container.

Static Public Member Functions

static VLCOutputCodec ConvertCodec (const OutputCodec &codec)
 Converts a generic OutputCodec to the VLCOutputCodec type.
static OutputCodec ConvertCodec (const VLCOutputCodec &codec)
 Converts a VLCOutputCodec to the generic OutputCodec type.
static VLCOutputMux ConvertMux (const OutputMux &mux)
 Converts a generic OutputMux to the VLCOutputMux type.
static OutputMux ConvertMux (const VLCOutputMux &mux)
 Converts a VLCOutputMux to the generic OutputMux type.
Static Public Member Functions inherited from PhysicalCameraView
static void ResetSettingsToDefaults ()
 Resets all camera-related application settings to their defaults.
static Buffer< PhysicalCameraView::OutputCodecSupportedOutputCodecs ()
 Returns a list of all video codecs supported by the current backend.
static Buffer< PhysicalCameraView::OutputMuxSupportedOutputMuxes ()
 Returns a list of all container/muxer formats supported by the current backend.

Protected Member Functions

void cleanup () override
 Cleans up VLC resources and stops playback.
void createVLCInstance ()
 Creates and initializes the VLC instance.
bool finishRecord (File file) override
 Finishes and finalizes the recording.
void imageSaved (int id, const QString &fileName)
 Callback invoked when an image has been saved to disk.
virtual void invertScreenColors (bool invert) override
 Inverts the screen colors for the video display.
bool startRecord (const File &file) override
 Starts recording to the specified file.
virtual bool takeImage (const File &file) override
 Takes a still image and saves it to the specified file.
void updateCameraOrientationSubtitle ()
 Updates the subtitle overlay with the current camera orientation.
Buffer< StringViewvlcArgs ()
 Builds the VLC initialization argument list.
Protected Member Functions inherited from PhysicalCameraView
 PhysicalCameraView ()
 Default constructor for subclass use only.
 PhysicalCameraView (const DynamicPointer< Camera > &camera, QWidget *parent=nullptr)
 Constructs a PhysicalCameraView for the given camera.
virtual QWidget * cameraToolbar () override
 Returns the camera toolbar widget.
void closeEvent (QCloseEvent *event) override
 Handles the widget close event, performing cleanup.
virtual ToolButtonSettings defaultButtonSettings () const
 Returns the default toolbar button visibility settings for this camera type.
void displayCamera (QCustomStackedWidget::StackAnimationDirection=QCustomStackedWidget::e_automatic)
 Displays the live camera panel.
virtual void displayCurrentViewTab (QCustomStackedWidget::StackAnimationDirection=QCustomStackedWidget::e_automatic)
 Switches to the appropriate view tab based on the current view mode.
void displayError (const TranslatedString &error, QCustomStackedWidget::StackAnimationDirection=QCustomStackedWidget::e_automatic)
 Displays the error panel with a message.
void displayFinder (QCustomStackedWidget::StackAnimationDirection=QCustomStackedWidget::e_automatic)
 Displays the connection/finder panel.
virtual void handleError ()
 Handles a camera error by updating the display and notifying the user.
virtual int heightForWidth (int w) const override
 Returns the preferred height for the given width, maintaining aspect ratio.
virtual void init ()
 Initializes the UI, toolbar, and internal state after construction.
void keyPressEvent (QKeyEvent *event) override
 Handles key press events for camera shortcuts.
void keyReleaseEvent (QKeyEvent *event) override
 Handles key release events.
void networkRequestReady ()
 Handles a completed network request for the camera stream.
void pause ()
 Pauses the camera stream playback.
virtual bool pauseRecord (bool paused, const File &file)
 Pauses or resumes the current recording.
void processCapturedImage (const QPixmap &img)
 Processes a captured image for saving or display.
virtual File recordPath (StringView name, bool is_finished_recording) const
 Computes the file path for a recording.
void setExposureCompensation (int index)
 Sets the exposure compensation level.
void setMuted (bool)
 Mutes or unmutes the audio from the camera stream.
virtual QPointer< QWidget > settingsWidget ()
 Returns the settings widget for this camera view.
void setupRulers ()
 Creates and configures the measurement ruler overlays.
virtual QSize sizeHint () const override
 Returns the recommended size for this widget.
void sourceChanged ()
 Handles a change in the camera source.
QCustomStackedWidgetstackedWidget () const
 Returns the stacked widget used for switching between view panels.
void startCamera ()
 Starts the camera stream.
void stop ()
 Stops the camera stream completely.
void stopCamera ()
 Stops the camera stream.
void toggleLock ()
 Toggles the lock state of the camera controls.
void updateCameraRotation ()
 Updates the camera rotation based on device orientation or user settings.
void updateCameraWindowSize ()
 Resizes the camera rendering surface to match the widget dimensions.
void updateRulers ()
 Updates the ruler display to match the current zoom and position.
WindowContainerwindowContainer () const
 Returns the window container holding the camera rendering surface.

Additional Inherited Members

Static Public Attributes inherited from PhysicalCameraView
static ApplicationOption< TimeSpandefault_buffer_time
 Default video buffer duration.
static ApplicationOption< Angle< fltp08 > > default_camera_angle_offset
 Default camera rotation angle offset.
static ApplicationOption< Stringdefault_camera_server_location
 Default camera server URL or address.
static ApplicationOption< Stringdefault_camera_server_password
 Default camera server password.
static ApplicationOption< uint04default_output_bitrate
 Default video output bitrate.
static ApplicationOption< Stringdefault_output_codec
 Default video codec.
static ApplicationOption< Stringdefault_output_extension
 Default video file extension.
static ApplicationOption< uint04default_output_fps
 Default video output frames per second.
static ApplicationOption< Stringdefault_output_mux
 Default video container/muxer format.
static Resource< Filedefault_screenshot_folder
 Default folder for saving screenshots.
static Resource< Filedefault_video_folder
 Default folder for saving recorded videos.
static Dictionary< UUID, PhysicalCameraView * > s_active_logging
 Registry of camera views with active logging.
static ApplicationOption< bool > write_video_to_memory
 Whether to buffer video in memory before writing to disk.
Protected Attributes inherited from PhysicalCameraView
File m_active_record_path
 The file path of the active recording.
bool m_application_exiting = false
 Whether the application is shutting down.
QPointer< QCustomSliderm_brightness_slider
 The slider controlling light brightness.
QPointer< QWidget > m_brightness_slider_widget
 Container widget for the brightness slider.
DynamicPointer< Cameram_camera
 The camera being displayed.
String m_connecting_icon
 Resource identifier for the connecting state icon.
TranslatedString m_connecting_message
 The message displayed while connecting.
String m_error_icon
 Resource identifier for the error state icon.
String m_file_name
 The current recording file name.
bool m_is_black_and_white = false
 Whether the display is in black and white mode.
bool m_is_capturing_image = false
 Whether an image capture is in progress.
bool m_is_in_error_state = false
 Whether the camera is in an error state.
bool m_is_inverted_color = false
 Whether the display colors are inverted.
bool m_is_playing = false
 Whether the camera stream is currently playing.
TranslatedString m_last_error
 The most recent error message.
bool m_lock_controls = false
 Whether the camera controls are locked.
LogPtr m_log
 Logger for camera events and errors.
String m_output_codec
 The active video codec identifier.
String m_output_mux
 The active video container/muxer identifier.
RecordingState m_recording_state = RecordingState::e_stopped
 The current video recording state.
Buttonm_ruler_button = nullptr
 The button to toggle ruler visibility.
QPointer< CameraRulerMenum_ruler_combo
 The ruler configuration menu widget.
String m_screenshot_file_name
 Base file name template for screenshots.
File m_screenshot_path
 The directory path for saving screenshots.
bool m_settings_popup = true
 Whether the settings widget displays as a popup.
QPointer< QWidget > m_settings_widget
 The optional settings widget for camera configuration.
bool m_show_edge_ruler = false
 Whether the side ruler is visible.
bool m_show_top_ruler = false
 Whether the top ruler is visible.
Rulerm_side_ruler = nullptr
 The side measurement ruler overlay.
QTimer * m_timeout_timer = nullptr
 Timer for connection timeout detection.
ToolButtonSettings m_tool_button_settings
 Current toolbar button visibility configuration.
bool m_tool_temp_showing = false
 Whether the toolbar is temporarily shown on hover.
Toolbarm_toolbar = nullptr
 The camera toolbar widget.
Rulerm_top_ruler = nullptr
 The top measurement ruler overlay.
File m_video_path
 The directory path for saving videos.
ViewMode m_view_mode = e_loading
 The current display mode of the view.
WindowContainerm_view_panel
 The container holding the camera rendering surface.
Ui::PhysicalCameraViewUI * ui
 The auto-generated UI form.

Detailed Description

Camera view widget that uses VLC for video playback and recording.

Provides a physical camera view backed by VLC, supporting live video streaming, recording with configurable codecs and muxers, subtitle overlays, camera rotation, and zoom.

Definition at line 78 of file VLCCameraView.h.

Member Enumeration Documentation

◆ VLCOutputCodec

Video codecs supported by VLC output.

Enumerator
MPEG2Video 

MPEG-2 video codec.

MPEG4Video 

MPEG-4 video codec.

H264 

H.264 / AVC video codec.

Theora 

Theora video codec.

CodecSize 

Number of codec formats.

Definition at line 94 of file VLCCameraView.h.

◆ VLCOutputMux

Output container (mux) formats supported by VLC.

Enumerator
TS 

MPEG Transport Stream.

PS 

MPEG Program Stream.

MP4 

MPEG-4 container.

OGG 

Ogg container.

AVI 

AVI container.

MuxSize 

Number of mux formats.

Definition at line 83 of file VLCCameraView.h.

Constructor & Destructor Documentation

◆ VLCCameraView()

VLCCameraView::VLCCameraView ( const DynamicPointer< Camera > & camera,
InfoPipe * log,
QWidget * parent = nullptr )

Constructs a VLCCameraView for a specific camera.

Parameters
[in]camerathe camera design object to display.
[in]logthe info pipe for logging.
[in]parentthe parent widget.

References PhysicalCameraView::camera(), and PhysicalCameraView::log().

Member Function Documentation

◆ addSubtitle()

void VLCCameraView::addSubtitle ( const String & subtitle)

Adds a subtitle text entry to the subtitle writer.

Parameters
[in]subtitlethe subtitle text to add.

◆ cameraRotation()

virtual Angle< fltp08 > VLCCameraView::cameraRotation ( )
overridevirtual

Returns the current camera rotation angle.

Returns
the current rotation angle.

◆ ConvertCodec() [1/2]

VLCOutputCodec VLCCameraView::ConvertCodec ( const OutputCodec & codec)
static

Converts a generic OutputCodec to the VLCOutputCodec type.

Parameters
[in]codecthe generic codec to convert.
Returns
the corresponding VLCOutputCodec value.

◆ ConvertCodec() [2/2]

OutputCodec VLCCameraView::ConvertCodec ( const VLCOutputCodec & codec)
static

Converts a VLCOutputCodec to the generic OutputCodec type.

Parameters
[in]codecthe VLC codec to convert.
Returns
the corresponding OutputCodec value.

◆ ConvertMux() [1/2]

VLCOutputMux VLCCameraView::ConvertMux ( const OutputMux & mux)
static

Converts a generic OutputMux to the VLCOutputMux type.

Parameters
[in]muxthe generic mux to convert.
Returns
the corresponding VLCOutputMux value.

◆ ConvertMux() [2/2]

OutputMux VLCCameraView::ConvertMux ( const VLCOutputMux & mux)
static

Converts a VLCOutputMux to the generic OutputMux type.

Parameters
[in]muxthe VLC mux to convert.
Returns
the corresponding OutputMux value.

◆ event()

bool VLCCameraView::event ( QEvent * event)
override

Handles Qt events for this widget.

Parameters
[in]eventthe event to process.
Returns
true if the event was handled.

References event().

Referenced by event().

◆ finishRecord()

bool VLCCameraView::finishRecord ( File file)
overrideprotectedvirtual

Finishes and finalizes the recording.

Parameters
[in]filethe output file that was being recorded.
Returns
true if recording was finalized successfully.

Reimplemented from PhysicalCameraView.

◆ grabFramebuffer()

virtual QImage VLCCameraView::grabFramebuffer ( )
overridevirtual

Captures the current video frame as a QImage.

Returns
the current frame as a QImage.

Reimplemented from PhysicalCameraView.

◆ imageSaved()

void VLCCameraView::imageSaved ( int id,
const QString & fileName )
protected

Callback invoked when an image has been saved to disk.

Parameters
[in]idthe image request identifier.
[in]fileNamethe path the image was saved to.

◆ invertScreenColors()

virtual void VLCCameraView::invertScreenColors ( bool invert)
overrideprotectedvirtual

Inverts the screen colors for the video display.

Parameters
[in]invertwhether to enable color inversion.

Reimplemented from PhysicalCameraView.

◆ setCameraRotation()

virtual void VLCCameraView::setCameraRotation ( Angle< fltp08 > rotation)
overridevirtual

Sets the camera rotation angle.

Parameters
[in]rotationthe rotation angle to apply.

◆ setCameraSource()

virtual bool VLCCameraView::setCameraSource ( const StringView & connection_id)
overridevirtual

Sets the camera source connection string.

Parameters
[in]connection_idthe connection URI or identifier.
Returns
true if the source was set successfully.

Reimplemented from PhysicalCameraView.

◆ setCameraZoom()

virtual void VLCCameraView::setCameraZoom ( fltp08 zoom)
overridevirtual

Sets the camera zoom level.

Parameters
[in]zoomthe zoom level to apply.

◆ setRecordingState()

virtual void VLCCameraView::setRecordingState ( RecordingState recording_state)
overridevirtual

Sets the recording state of this camera view.

Parameters
[in]recording_statethe desired recording state.

Reimplemented from PhysicalCameraView.

◆ startRecord()

bool VLCCameraView::startRecord ( const File & file)
overrideprotectedvirtual

Starts recording to the specified file.

Parameters
[in]filethe output file for recording.
Returns
true if recording started successfully.

Reimplemented from PhysicalCameraView.

◆ takeImage()

virtual bool VLCCameraView::takeImage ( const File & file)
overrideprotectedvirtual

Takes a still image and saves it to the specified file.

Parameters
[in]filethe output file for the image.
Returns
true if the image was captured successfully.

Reimplemented from PhysicalCameraView.

◆ vlcArgs()

Buffer< StringView > VLCCameraView::vlcArgs ( )
protected

Builds the VLC initialization argument list.

Returns
a buffer of string views containing the VLC arguments.

The documentation for this class was generated from the following file: