VirtualBox

source: vbox/trunk/src/VBox/Main/include/VideoRec.h@ 75307

Last change on this file since 75307 was 75307, checked in by vboxsync, 6 years ago

Recording: Bugfixes for Main and FE/Qt.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
  • Property svn:mergeinfo set to (toggle deleted branches)
    /branches/VBox-3.0/src/VBox/Frontends/VBoxHeadless/VideoCapture/EncodeAndWrite.h58652,​70973
    /branches/VBox-3.2/src/VBox/Frontends/VBoxHeadless/VideoCapture/EncodeAndWrite.h66309,​66318
    /branches/VBox-4.0/src/VBox/Frontends/VBoxHeadless/VideoCapture/EncodeAndWrite.h70873
    /branches/VBox-4.1/src/VBox/Frontends/VBoxHeadless/VideoCapture/EncodeAndWrite.h74233
    /branches/VBox-4.2/src/VBox/Main/src-client/VideoRec.h91503-91504,​91506-91508,​91510,​91514-91515,​91521
    /branches/VBox-4.3/src/VBox/Main/src-client/VideoRec.h91223
    /branches/VBox-4.3/trunk/src/VBox/Main/src-client/VideoRec.h91223
    /branches/dsen/gui/src/VBox/Frontends/VBoxHeadless/VideoCapture/EncodeAndWrite.h79076-79078,​79089,​79109-79110,​79112-79113,​79127-79130,​79134,​79141,​79151,​79155,​79157-79159,​79193,​79197
    /branches/dsen/gui2/src/VBox/Frontends/VBoxHeadless/VideoCapture/EncodeAndWrite.h79224,​79228,​79233,​79235,​79258,​79262-79263,​79273,​79341,​79345,​79354,​79357,​79387-79388,​79559-79569,​79572-79573,​79578,​79581-79582,​79590-79591,​79598-79599,​79602-79603,​79605-79606,​79632,​79635,​79637,​79644
    /branches/dsen/gui3/src/VBox/Frontends/VBoxHeadless/VideoCapture/EncodeAndWrite.h79645-79692
File size: 6.9 KB
Line 
1/* $Id: VideoRec.h 75307 2018-11-07 13:56:14Z vboxsync $ */
2/** @file
3 * Video recording code header.
4 */
5
6/*
7 * Copyright (C) 2012-2018 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ____H_VIDEOREC
19#define ____H_VIDEOREC
20
21#include <VBox/com/array.h>
22#include <VBox/com/string.h>
23#include <VBox/com/VirtualBox.h>
24#include <VBox/err.h>
25#include <VBox/settings.h>
26
27using namespace com;
28
29#include "VideoRecInternals.h"
30#include "VideoRecStream.h"
31
32#if 0
33/**
34 * Enumeration for definining a video / audio
35 * profile setting.
36 */
37typedef enum VIDEORECPROFILE
38{
39 VIDEORECPROFILE_NONE = 0,
40 VIDEORECPROFILE_LOW,
41 VIDEORECPROFILE_MEDIUM,
42 VIDEORECPROFILE_HIGH,
43 VIDEORECPROFILE_BEST,
44 VIDEORECPROFILE_REALTIME
45} VIDEORECPROFILE;
46
47/** Stores video recording features. */
48typedef uint32_t VIDEORECFEATURES;
49
50/** Video recording is disabled completely. */
51#define VIDEORECFEATURE_NONE 0
52/** Capturing video is enabled. */
53#define VIDEORECFEATURE_VIDEO RT_BIT(0)
54/** Capturing audio is enabled. */
55#define VIDEORECFEATURE_AUDIO RT_BIT(1)
56
57/**
58 * Structure for keeping a screen recording configuration.
59 */
60typedef struct VIDEORECSCREENCFG
61{
62 VIDEORECSCREENCFG(void)
63 : enmDst(VIDEORECDEST_INVALID)
64 , uMaxTimeS(0)
65 {
66#ifdef VBOX_WITH_AUDIO_VIDEOREC
67 RT_ZERO(Audio);
68#endif
69 RT_ZERO(Video);
70 }
71
72 VIDEORECSCREENCFG& operator=(const VIDEORECSCREENCFG &that)
73 {
74 enmDst = that.enmDst;
75
76 File.strName = that.File.strName;
77 File.uMaxSizeMB = that.File.uMaxSizeMB;
78#ifdef VBOX_WITH_AUDIO_VIDEOREC
79 Audio = that.Audio;
80#endif
81 Video = that.Video;
82 uMaxTimeS = that.uMaxTimeS;
83 return *this;
84 }
85
86 unsigned long uScreenId;
87 /** Destination where to write the stream to. */
88 VIDEORECDEST enmDst;
89
90 /**
91 * Structure for keeping recording parameters if
92 * destination is a file.
93 */
94 struct
95 {
96 /** File name (as absolute path). */
97 com::Bstr strName;
98 /** Maximum file size (in MB) to record. */
99 uint32_t uMaxSizeMB;
100 } File;
101
102#ifdef VBOX_WITH_AUDIO_VIDEOREC
103 /**
104 * Structure for keeping the audio recording parameters.
105 */
106 struct
107 {
108 /** Whether audio recording is enabled or not. */
109 bool fEnabled;
110 /** The device LUN the audio driver is attached / configured to. */
111 unsigned uLUN;
112 /** Hertz (Hz) rate. */
113 uint16_t uHz;
114 /** Bits per sample. */
115 uint8_t cBits;
116 /** Number of audio channels. */
117 uint8_t cChannels;
118 /** Audio profile which is being used. */
119 VIDEORECPROFILE enmProfile;
120 } Audio;
121#endif
122
123 /**
124 * Structure for keeping the video recording parameters.
125 */
126 struct
127 {
128 /** Whether video recording is enabled or not. */
129 bool fEnabled;
130 /** Target width (in pixels). */
131 uint32_t uWidth;
132 /** Target height (in pixels). */
133 uint32_t uHeight;
134 /** Target encoding rate. */
135 uint32_t uRate;
136 /** Target FPS. */
137 uint32_t uFPS;
138
139#ifdef VBOX_WITH_LIBVPX
140 union
141 {
142 struct
143 {
144 /** Encoder deadline. */
145 unsigned int uEncoderDeadline;
146 } VPX;
147 } Codec;
148#endif
149
150 } Video;
151
152 /** Maximum time (in s) to record.
153 * Specify 0 to disable this check. */
154 uint32_t uMaxTimeS;
155} VIDEORECSCREENCFG, *PVIDEORECSCREENCFG;
156#endif
157
158class Console;
159
160/**
161 * Class for managing a capturing context.
162 */
163class CaptureContext
164{
165public:
166
167 CaptureContext(Console *pConsole);
168
169 CaptureContext(Console *pConsole, const settings::CaptureSettings &a_Settings);
170
171 virtual ~CaptureContext(void);
172
173public:
174
175 const settings::CaptureSettings &GetConfig(void) const;
176 CaptureStream *GetStream(unsigned uScreen) const;
177 size_t GetStreamCount(void) const;
178
179 int Create(const settings::CaptureSettings &a_Settings);
180 int Destroy(void);
181
182 int Start(void);
183 int Stop(void);
184
185 int SendAudioFrame(const void *pvData, size_t cbData, uint64_t uTimestampMs);
186 int SendVideoFrame(uint32_t uScreen,
187 uint32_t x, uint32_t y, uint32_t uPixelFormat, uint32_t uBPP,
188 uint32_t uBytesPerLine, uint32_t uSrcWidth, uint32_t uSrcHeight,
189 uint8_t *puSrcData, uint64_t uTimeStampMs);
190public:
191
192 bool IsFeatureEnabled(CaptureFeature_T enmFeature) const;
193 bool IsReady(void) const;
194 bool IsReady(uint32_t uScreen, uint64_t uTimeStampMs) const;
195 bool IsStarted(void) const;
196 bool IsLimitReached(uint32_t uScreen, uint64_t tsNowMs) const;
197
198protected:
199
200 int createInternal(const settings::CaptureSettings &a_Settings);
201 int startInternal(void);
202 int stopInternal(void);
203
204 int destroyInternal(void);
205
206 CaptureStream *getStreamInternal(unsigned uScreen) const;
207
208 static DECLCALLBACK(int) threadMain(RTTHREAD hThreadSelf, void *pvUser);
209
210 int threadNotify(void);
211
212protected:
213
214 /** Pointer to the console object. */
215 Console *pConsole;
216 /** Used recording configuration. */
217 settings::CaptureSettings Settings;
218 /** The current state. */
219 uint32_t enmState;
220 /** Critical section to serialize access. */
221 RTCRITSECT CritSect;
222 /** Semaphore to signal the encoding worker thread. */
223 RTSEMEVENT WaitEvent;
224 /** Whether this context is in started state or not. */
225 bool fStarted;
226 /** Shutdown indicator. */
227 bool fShutdown;
228 /** Worker thread. */
229 RTTHREAD Thread;
230 /** Vector of current recording streams.
231 * Per VM screen (display) one recording stream is being used. */
232 VideoRecStreams vecStreams;
233 /** Timestamp (in ms) of when recording has been started. */
234 uint64_t tsStartMs;
235 /** Block map of common blocks which need to get multiplexed
236 * to all recording streams. This common block maps should help
237 * reducing the time spent in EMT and avoid doing the (expensive)
238 * multiplexing work in there.
239 *
240 * For now this only affects audio, e.g. all recording streams
241 * need to have the same audio data at a specific point in time. */
242 VideoRecBlockMap mapBlocksCommon;
243};
244#endif /* !____H_VIDEOREC */
245
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette