NDEVR
API Documentation
VLCCameraView.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Widgets
28File: VLCCameraView.h
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/PhysicalCameraView.h>
35#define NDEVR_USE_VLC_OPENGLRENDERER 1
36#if NDEVR_USE_VLC_OPENGLRENDERER
37#include "VLCInterface/Headers/VLCOpenGLRenderer.h"
38#else
39#include "VLCInterface/Headers/VLCWindow.h"
40#endif
41#include "Design/Headers/Camera.h"
42#include "Base/Headers/Pointer.hpp"
43#include "Base/Headers/File.h"
44#include "Base/Headers/Translator.h"
45
46#include "VLCInterface/Headers/Media.h"
47#include "VLCInterface/Headers/MetaManager.h"
48#include "VLCInterface/Headers/Instance.h"
49#include "VLCInterface/Headers/MediaPlayer.h"
50#include "VLCInterface/Headers/Video.h"
51#include "vlc/libvlc.h"
52
53#if NDEVR_SUPPORTS_VLC
54namespace NDEVR
55{
56 class VlcInstance;
57}
58class VlcMedia;
59class VlcMediaPlayer;
60class VlcVideoStream;
61#endif
62#define THREADED_INIT = false;
63
64namespace NDEVR
65{
66
67 class Button;
68 class VlcWindow;
69 class Log;
70 class BasicThread;
78 class VLC_INTERFACE_API VLCCameraView final : public PhysicalCameraView
79 {
80 Q_OBJECT
81 public:
92
102
124 VLCCameraView(const DynamicPointer<Camera>& camera, InfoPipe* log, QWidget* parent = nullptr);
126 virtual ~VLCCameraView();
130 virtual bool setCameraSource(const StringView& connection_id) override;
132 virtual void refreshInstance() override;
136 bool event(QEvent* event) override;
137
140 virtual void setRecordingState(RecordingState recording_state) override;
143 virtual QImage grabFramebuffer() override;
146 virtual void setCameraRotation(Angle<fltp08> rotation) override;
149 virtual void setCameraZoom(fltp08 zoom) override;
152 virtual Angle<fltp08> cameraRotation() override;
155 void addSubtitle(const String& subtitle);
156 protected:
160 bool startRecord(const File& file) override;
164 bool finishRecord(File file) override;
168 virtual bool takeImage(const File& file) override;
171 virtual void invertScreenColors(bool invert) override;
178 void cleanup() override;
182 void imageSaved(int id, const QString& fileName);
183 protected slots:
186 private:
187 VlcInstance* m_vlc_instance;
188 VlcMediaPlayer* m_media_player;
189 VlcMedia* m_vlc_media;
190#if NDEVR_USE_VLC_OPENGLRENDERER
191 VLCOpenGLRenderer* m_gl_renderer = nullptr;
192 Time m_init_time;
193#else
194 VlcWindow* m_video_window = nullptr;
195#endif
196 SubtitleFileWriter* m_subtitle_writer = nullptr;
197 Time m_start_record_time;
198 uint04 m_connection_retry_count = 0;
199 };
200
206 {
207 public:
219 virtual CameraView* createView(const DynamicPointer<Camera>& camera, DesignObjectLookup* model_manager, QWidget* parent = nullptr) override;
225 virtual bool canCreateView(const DynamicPointer<Camera>& camera, DesignObjectLookup* model_manager, bool ignore_active) override;
227 virtual void resetToDefaults() override;
228 };
229}
230
DLL export macros and version definitions for the VLCInterface module.
Stores an angle in an optimized internal format with support for efficient trigonometric operations.
Definition Angle.h:83
A thread that executes a user-provided callback function concurrently.
Definition BasicThread.h:47
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A core widget that allows the user to click one of many button types.
Definition Button.h:68
A core class where all Design Objects including models, materials, and geometries are stored.
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:356
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Definition File.h:53
A light-weight base class for Log that allows processes to update, without the need for additional in...
Serves as the primary program interface for processes to report issues and allows any number of LogSt...
Definition Log.h:50
Factory for creating PhysicalCameraView instances and querying supported output formats.
virtual ConstPointer< Camera > camera() const override
Returns a read-only pointer to the Camera.
LogPtr log() const
Returns the current logger.
PhysicalCameraView()
Default constructor for subclass use only.
The core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
Class which can be used to write a subtitle in real time to a file, which can be played back alongsid...
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:62
void createVLCInstance()
Creates and initializes the VLC instance.
bool startRecord(const File &file) override
Starts recording to the specified file.
virtual void refreshInstance() override
Refreshes the VLC instance and reconnects the media source.
VLCOutputMux
Output container (mux) formats supported by VLC.
@ MP4
MPEG-4 container.
@ MuxSize
Number of mux formats.
@ AVI
AVI container.
@ PS
MPEG Program Stream.
@ OGG
Ogg container.
@ TS
MPEG Transport Stream.
void imageSaved(int id, const QString &fileName)
Callback invoked when an image has been saved to disk.
static OutputMux ConvertMux(const VLCOutputMux &mux)
Converts a VLCOutputMux to the generic OutputMux type.
virtual QImage grabFramebuffer() override
Captures the current video frame as a QImage.
virtual ~VLCCameraView()
Destroys the VLCCameraView and releases VLC resources.
bool finishRecord(File file) override
Finishes and finalizes the recording.
virtual void setCameraZoom(fltp08 zoom) override
Sets the camera zoom level.
void cleanup() override
Cleans up VLC resources and stops playback.
VLCCameraView()
Constructs a VLCCameraView with default settings.
virtual Angle< fltp08 > cameraRotation() override
Returns the current camera rotation angle.
VLCOutputCodec
Video codecs supported by VLC output.
@ MPEG2Video
MPEG-2 video codec.
@ H264
H.264 / AVC video codec.
@ Theora
Theora video codec.
@ MPEG4Video
MPEG-4 video codec.
@ CodecSize
Number of codec formats.
static VLCOutputMux ConvertMux(const OutputMux &mux)
Converts a generic OutputMux to the VLCOutputMux type.
virtual void invertScreenColors(bool invert) override
Inverts the screen colors for the video display.
static VLCOutputCodec ConvertCodec(const OutputCodec &codec)
Converts a generic OutputCodec to the VLCOutputCodec type.
bool event(QEvent *event) override
Handles Qt events for this widget.
VLCCameraView(const DynamicPointer< Camera > &camera, InfoPipe *log, QWidget *parent=nullptr)
Constructs a VLCCameraView for a specific camera.
Buffer< StringView > vlcArgs()
Builds the VLC initialization argument list.
void updateCameraOrientationSubtitle()
Updates the subtitle overlay with the current camera orientation.
virtual bool takeImage(const File &file) override
Takes a still image and saves it to the specified file.
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.
static OutputCodec ConvertCodec(const VLCOutputCodec &codec)
Converts a VLCOutputCodec to the generic OutputCodec type.
void addSubtitle(const String &subtitle)
Adds a subtitle text entry to the subtitle writer.
virtual void setRecordingState(RecordingState recording_state) override
Sets the recording state of this camera view.
Factory for creating VLCCameraView instances.
virtual void resetToDefaults() override
Resets factory settings to their defaults.
virtual CameraView * createView(const DynamicPointer< Camera > &camera, DesignObjectLookup *model_manager, QWidget *parent=nullptr) override
Creates a camera view for the given camera.
virtual bool canCreateView(const DynamicPointer< Camera > &camera, DesignObjectLookup *model_manager, bool ignore_active) override
Checks whether a camera view can be created for the given camera.
virtual Buffer< PhysicalCameraView::OutputCodec > supportedOutputCodecs() override
Returns the list of video codecs supported by VLC output.
virtual Buffer< PhysicalCameraView::OutputMux > supportedOutputMuxes() override
Returns the list of container formats supported by VLC output.
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
Describes a video output codec with an identifier and display name.
Describes a video output muxer/container format with an identifier and display name.