VirtualBox

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

Last change on this file since 100615 was 98278, checked in by vboxsync, 23 months ago

Main/src-client: Some more rc -> hrc/vrc stuff found by grep. A build fix. bugref:10223

  • 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: 5.8 KB
Line 
1/* $Id: Recording.h 98278 2023-01-24 11:55: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.virtualbox.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/**
42 * Class for managing a recording context.
43 */
44class RecordingContext
45{
46public:
47
48 RecordingContext();
49
50 RecordingContext(Console *ptrConsole, const settings::RecordingSettings &Settings);
51
52 virtual ~RecordingContext(void);
53
54public:
55
56 const settings::RecordingSettings &GetConfig(void) const;
57 RecordingStream *GetStream(unsigned uScreen) const;
58 size_t GetStreamCount(void) const;
59#ifdef VBOX_WITH_AUDIO_RECORDING
60 PRECORDINGCODEC GetCodecAudio(void) { return &this->m_CodecAudio; }
61#endif
62
63 int Create(Console *pConsole, const settings::RecordingSettings &Settings);
64 void Destroy(void);
65
66 int Start(void);
67 int Stop(void);
68
69 int SendAudioFrame(const void *pvData, size_t cbData, uint64_t uTimestampMs);
70 int SendVideoFrame(uint32_t uScreen,
71 uint32_t x, uint32_t y, uint32_t uPixelFormat, uint32_t uBPP,
72 uint32_t uBytesPerLine, uint32_t uSrcWidth, uint32_t uSrcHeight,
73 uint8_t *puSrcData, uint64_t msTimestamp);
74public:
75
76 bool IsFeatureEnabled(RecordingFeature_T enmFeature);
77 bool IsReady(void);
78 bool IsReady(uint32_t uScreen, uint64_t msTimestamp);
79 bool IsStarted(void);
80 bool IsLimitReached(void);
81 bool IsLimitReached(uint32_t uScreen, uint64_t msTimestamp);
82 bool NeedsUpdate(uint32_t uScreen, uint64_t msTimestamp);
83
84 DECLCALLBACK(int) OnLimitReached(uint32_t uScreen, int vrc);
85
86protected:
87
88 int createInternal(Console *ptrConsole, const settings::RecordingSettings &Settings);
89 int startInternal(void);
90 int stopInternal(void);
91
92 void destroyInternal(void);
93
94 RecordingStream *getStreamInternal(unsigned uScreen) const;
95
96 int processCommonData(RecordingBlockMap &mapCommon, RTMSINTERVAL msTimeout);
97 int writeCommonData(RecordingBlockMap &mapCommon, PRECORDINGCODEC pCodec, const void *pvData, size_t cbData, uint64_t msAbsPTS, uint32_t uFlags);
98
99 int lock(void);
100 int unlock(void);
101
102 static DECLCALLBACK(int) threadMain(RTTHREAD hThreadSelf, void *pvUser);
103
104 int threadNotify(void);
105
106protected:
107
108 int audioInit(const settings::RecordingScreenSettings &screenSettings);
109
110 static DECLCALLBACK(int) audioCodecWriteDataCallback(PRECORDINGCODEC pCodec, const void *pvData, size_t cbData, uint64_t msAbsPTS, uint32_t uFlags, void *pvUser);
111
112protected:
113
114 /**
115 * Enumeration for a recording context state.
116 */
117 enum RECORDINGSTS
118 {
119 /** Context not initialized. */
120 RECORDINGSTS_UNINITIALIZED = 0,
121 /** Context was created. */
122 RECORDINGSTS_CREATED = 1,
123 /** Context was started. */
124 RECORDINGSTS_STARTED = 2,
125 /** The usual 32-bit hack. */
126 RECORDINGSTS_32BIT_HACK = 0x7fffffff
127 };
128
129 /** Pointer to the console object. */
130 Console *m_pConsole;
131 /** Used recording configuration. */
132 settings::RecordingSettings m_Settings;
133 /** The current state. */
134 RECORDINGSTS m_enmState;
135 /** Critical section to serialize access. */
136 RTCRITSECT m_CritSect;
137 /** Semaphore to signal the encoding worker thread. */
138 RTSEMEVENT m_WaitEvent;
139 /** Shutdown indicator. */
140 bool m_fShutdown;
141 /** Encoding worker thread. */
142 RTTHREAD m_Thread;
143 /** Vector of current recording streams.
144 * Per VM screen (display) one recording stream is being used. */
145 RecordingStreams m_vecStreams;
146 /** Number of streams in vecStreams which currently are enabled for recording. */
147 uint16_t m_cStreamsEnabled;
148 /** Timestamp (in ms) of when recording has been started. */
149 uint64_t m_tsStartMs;
150#ifdef VBOX_WITH_AUDIO_RECORDING
151 /** Audio codec to use.
152 *
153 * We multiplex audio data from this recording context to all streams,
154 * to avoid encoding the same audio data for each stream. We ASSUME that
155 * all audio data of a VM will be the same for each stream at a given
156 * point in time. */
157 RECORDINGCODEC m_CodecAudio;
158#endif /* VBOX_WITH_AUDIO_RECORDING */
159 /** Block map of raw common data blocks which need to get encoded first. */
160 RecordingBlockMap m_mapBlocksRaw;
161 /** Block map of encoded common blocks.
162 *
163 * Only do the encoding of common data blocks only once and then multiplex
164 * the encoded data to all affected recording streams.
165 *
166 * This avoids doing the (expensive) encoding + multiplexing work in other
167 * threads like EMT / audio async I/O..
168 *
169 * For now this only affects audio, e.g. all recording streams
170 * need to have the same audio data at a specific point in time. */
171 RecordingBlockMap m_mapBlocksEncoded;
172};
173#endif /* !MAIN_INCLUDED_Recording_h */
174
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