VirtualBox

source: vbox/trunk/src/VBox/Main/include/Recording.h@ 105006

最後變更 在這個檔案從105006是 105006,由 vboxsync 提交於 9 月 前

Video Recording: Big revamp to improve overall performance. We now don't rely on the periodic display refresh callback anymore to render the entire framebuffer but now rely on delta updates ("dirty rectangles"). Also, we now only encode new frames when an area has changed. This also needed cursor position + change change notifications, as we render the cursor on the host side if mouse integration is enabled (requires 7.1 Guest Additions as of now). Optimized the BGRA32->YUV IV420 color space conversion as well as the overall amount of pixel data shuffled forth and back. Added a new testcase for the cropping/centering code. bugref:10650

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
  • 屬性 svn:mergeinfo 設為 (切換已刪除的分支)
    /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
檔案大小: 7.0 KB
 
1/* $Id: Recording.h 105006 2024-06-24 17:43:00Z vboxsync $ */
2/** @file
3 * Recording code header.
4 */
5
6/*
7 * Copyright (C) 2012-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.alldomusa.eu.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef MAIN_INCLUDED_Recording_h
29#define MAIN_INCLUDED_Recording_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include <VBox/err.h>
35#include <VBox/settings.h>
36
37#include "RecordingStream.h"
38
39class Console;
40
41/** No flags specified. */
42#define VBOX_RECORDING_CURSOR_F_NONE 0
43/** Cursor is visible. */
44#define VBOX_RECORDING_CURSOR_F_VISIBLE RT_BIT(0)
45/** Cursor shape contains an alpha mask. */
46#define VBOX_RECORDING_CURSOR_F_ALPHA RT_BIT(1)
47/** Cursor state flags valid mask. */
48#define VBOX_RECORDING_CURSOR_F_VALID_MASK 0x3
49
50/**
51 * Class for keeping a recording cursor state.
52 */
53class RecordingCursorState
54{
55public:
56
57 RecordingCursorState();
58 virtual ~RecordingCursorState();
59
60 void Destroy();
61
62 int CreateOrUpdate(bool fAlpha, uint32_t uWidth, uint32_t uHeight, const uint8_t *pu8Shape, size_t cbShape);
63
64 int Move(int32_t iX, int32_t iY);
65
66 /** Cursor state flags. */
67 uint32_t m_fFlags;
68 /** The current cursor shape. */
69 RECORDINGVIDEOFRAME m_Shape;
70};
71
72/**
73 * Class for managing a recording context.
74 */
75class RecordingContext
76{
77public:
78
79 RecordingContext();
80
81 RecordingContext(Console *ptrConsole, const settings::RecordingSettings &Settings);
82
83 virtual ~RecordingContext(void);
84
85public:
86
87 const settings::RecordingSettings &GetConfig(void) const;
88 RecordingStream *GetStream(unsigned uScreen) const;
89 size_t GetStreamCount(void) const;
90#ifdef VBOX_WITH_AUDIO_RECORDING
91 PRECORDINGCODEC GetCodecAudio(void) { return &this->m_CodecAudio; }
92#endif
93
94 int Create(Console *pConsole, const settings::RecordingSettings &Settings);
95 void Destroy(void);
96
97 int Start(void);
98 int Stop(void);
99
100 int SendAudioFrame(const void *pvData, size_t cbData, uint64_t uTimestampMs);
101 int SendVideoFrame(uint32_t uScreen, PRECORDINGVIDEOFRAME pFrame, uint64_t msTimestamp);
102 int SendCursorPositionChange(uint32_t uScreen, int32_t x, int32_t y, uint64_t msTimestamp);
103 int SendCursorShapeChange(bool fVisible, bool fAlpha, uint32_t xHot, uint32_t yHot, uint32_t uWidth, uint32_t uHeight, const uint8_t *pu8Shape, size_t cbShape, uint64_t msTimestamp);
104 int SendScreenChange(uint32_t uScreen, PRECORDINGSURFACEINFO pInfo, uint64_t uTimestampMs);
105
106public:
107
108 uint64_t GetCurrentPTS(void) const;
109 bool IsFeatureEnabled(RecordingFeature_T enmFeature);
110 bool IsReady(void);
111 bool IsReady(uint32_t uScreen, uint64_t msTimestamp);
112 bool IsStarted(void);
113 bool IsLimitReached(void);
114 bool IsLimitReached(uint32_t uScreen, uint64_t msTimestamp);
115 bool NeedsUpdate(uint32_t uScreen, uint64_t msTimestamp);
116
117 DECLCALLBACK(int) OnLimitReached(uint32_t uScreen, int vrc);
118
119 /** The state mouse cursor state.
120 * We currently only support one mouse cursor at a time. */
121 RecordingCursorState m_Cursor;
122
123
124protected:
125
126 int createInternal(Console *ptrConsole, const settings::RecordingSettings &Settings);
127 int startInternal(void);
128 int stopInternal(void);
129
130 void destroyInternal(void);
131
132 RecordingStream *getStreamInternal(unsigned uScreen) const;
133
134 int processCommonData(RecordingBlockMap &mapCommon, RTMSINTERVAL msTimeout);
135 int writeCommonData(RecordingBlockMap &mapCommon, PRECORDINGCODEC pCodec, const void *pvData, size_t cbData, uint64_t msAbsPTS, uint32_t uFlags);
136
137 int lock(void);
138 int unlock(void);
139
140 static DECLCALLBACK(int) threadMain(RTTHREAD hThreadSelf, void *pvUser);
141
142 int threadNotify(void);
143
144protected:
145
146 int audioInit(const settings::RecordingScreenSettings &screenSettings);
147
148 static DECLCALLBACK(int) audioCodecWriteDataCallback(PRECORDINGCODEC pCodec, const void *pvData, size_t cbData, uint64_t msAbsPTS, uint32_t uFlags, void *pvUser);
149
150protected:
151
152 /**
153 * Enumeration for a recording context state.
154 */
155 enum RECORDINGSTS
156 {
157 /** Context not initialized. */
158 RECORDINGSTS_UNINITIALIZED = 0,
159 /** Context was created. */
160 RECORDINGSTS_CREATED = 1,
161 /** Context was started. */
162 RECORDINGSTS_STARTED = 2,
163 /** The usual 32-bit hack. */
164 RECORDINGSTS_32BIT_HACK = 0x7fffffff
165 };
166
167 /** Pointer to the console object. */
168 Console *m_pConsole;
169 /** Used recording configuration. */
170 settings::RecordingSettings m_Settings;
171 /** The current state. */
172 RECORDINGSTS m_enmState;
173 /** Critical section to serialize access. */
174 RTCRITSECT m_CritSect;
175 /** Semaphore to signal the encoding worker thread. */
176 RTSEMEVENT m_WaitEvent;
177 /** Shutdown indicator. */
178 bool m_fShutdown;
179 /** Encoding worker thread. */
180 RTTHREAD m_Thread;
181 /** Vector of current recording streams.
182 * Per VM screen (display) one recording stream is being used. */
183 RecordingStreams m_vecStreams;
184 /** Number of streams in vecStreams which currently are enabled for recording. */
185 uint16_t m_cStreamsEnabled;
186 /** Timestamp (in ms) of when recording has been started.
187 * Set to 0 if not started (yet). */
188 uint64_t m_tsStartMs;
189#ifdef VBOX_WITH_AUDIO_RECORDING
190 /** Audio codec to use.
191 *
192 * We multiplex audio data from this recording context to all streams,
193 * to avoid encoding the same audio data for each stream. We ASSUME that
194 * all audio data of a VM will be the same for each stream at a given
195 * point in time. */
196 RECORDINGCODEC m_CodecAudio;
197#endif /* VBOX_WITH_AUDIO_RECORDING */
198 /** Block map of raw common data blocks which need to get encoded first. */
199 RecordingBlockMap m_mapBlocksRaw;
200 /** Block map of encoded common blocks.
201 *
202 * Only do the encoding of common data blocks only once and then multiplex
203 * the encoded data to all affected recording streams.
204 *
205 * This avoids doing the (expensive) encoding + multiplexing work in other
206 * threads like EMT / audio async I/O..
207 *
208 * For now this only affects audio, e.g. all recording streams
209 * need to have the same audio data at a specific point in time. */
210 RecordingBlockMap m_mapBlocksEncoded;
211};
212#endif /* !MAIN_INCLUDED_Recording_h */
213
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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