VirtualBox

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

Last change on this file since 96407 was 96407, checked in by vboxsync, 22 months ago

scm copyright and license note update

  • 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
RevLine 
[45841]1/* $Id: Recording.h 96407 2022-08-22 17:43:14Z vboxsync $ */
2/** @file
[75344]3 * Recording code header.
[45841]4 */
5
6/*
[96407]7 * Copyright (C) 2012-2022 Oracle and/or its affiliates.
[45841]8 *
[96407]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
[45841]26 */
27
[76562]28#ifndef MAIN_INCLUDED_Recording_h
29#define MAIN_INCLUDED_Recording_h
[76487]30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
[45841]33
[82422]34#include <VBox/err.h>
[75251]35#include <VBox/settings.h>
[68798]36
[75344]37#include "RecordingStream.h"
[45950]38
[75251]39class Console;
[68798]40
[74992]41/**
[76893]42 * Class for managing a recording context.
[74992]43 */
[75354]44class RecordingContext
[74992]45{
[75251]46public:
47
[95645]48 RecordingContext();
[75251]49
[96229]50 RecordingContext(Console *ptrConsole, const settings::RecordingSettings &Settings);
[95645]51
[75354]52 virtual ~RecordingContext(void);
[75251]53
54public:
55
[75361]56 const settings::RecordingSettings &GetConfig(void) const;
[75354]57 RecordingStream *GetStream(unsigned uScreen) const;
[75251]58 size_t GetStreamCount(void) const;
[96229]59#ifdef VBOX_WITH_AUDIO_RECORDING
[96324]60 PRECORDINGCODEC GetCodecAudio(void) { return &this->m_CodecAudio; }
[96229]61#endif
[75251]62
[96229]63 int Create(Console *pConsole, const settings::RecordingSettings &Settings);
[76893]64 void Destroy(void);
[75251]65
[75307]66 int Start(void);
67 int Stop(void);
68
[75251]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,
[75499]73 uint8_t *puSrcData, uint64_t msTimestamp);
[75251]74public:
75
[75488]76 bool IsFeatureEnabled(RecordingFeature_T enmFeature);
[76893]77 bool IsReady(void);
[75499]78 bool IsReady(uint32_t uScreen, uint64_t msTimestamp);
[75488]79 bool IsStarted(void);
80 bool IsLimitReached(void);
[75499]81 bool IsLimitReached(uint32_t uScreen, uint64_t msTimestamp);
[96322]82 bool NeedsUpdate( uint32_t uScreen, uint64_t msTimestamp);
[75251]83
[75488]84 DECLCALLBACK(int) OnLimitReached(uint32_t uScreen, int rc);
85
[75251]86protected:
87
[96229]88 int createInternal(Console *ptrConsole, const settings::RecordingSettings &Settings);
[75307]89 int startInternal(void);
90 int stopInternal(void);
[75251]91
[76893]92 void destroyInternal(void);
[75251]93
[75354]94 RecordingStream *getStreamInternal(unsigned uScreen) const;
[75251]95
[96260]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);
[96229]98
[75488]99 int lock(void);
100 int unlock(void);
101
[75251]102 static DECLCALLBACK(int) threadMain(RTTHREAD hThreadSelf, void *pvUser);
103
104 int threadNotify(void);
105
106protected:
107
[96229]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
[75313]114 /**
115 * Enumeration for a recording context state.
116 */
[75354]117 enum RECORDINGSTS
[75313]118 {
119 /** Context not initialized. */
[75354]120 RECORDINGSTS_UNINITIALIZED = 0,
[75313]121 /** Context was created. */
[75354]122 RECORDINGSTS_CREATED = 1,
[75313]123 /** Context was started. */
[75354]124 RECORDINGSTS_STARTED = 2,
[75313]125 /** The usual 32-bit hack. */
[75354]126 RECORDINGSTS_32BIT_HACK = 0x7fffffff
[75313]127 };
128
[75251]129 /** Pointer to the console object. */
[96324]130 Console *m_pConsole;
[74992]131 /** Used recording configuration. */
[96229]132 settings::RecordingSettings m_Settings;
[74992]133 /** The current state. */
[96324]134 RECORDINGSTS m_enmState;
[74992]135 /** Critical section to serialize access. */
[96324]136 RTCRITSECT m_CritSect;
[74992]137 /** Semaphore to signal the encoding worker thread. */
[96324]138 RTSEMEVENT m_WaitEvent;
[74992]139 /** Shutdown indicator. */
[96324]140 bool m_fShutdown;
[96229]141 /** Encoding worker thread. */
[96324]142 RTTHREAD m_Thread;
[74992]143 /** Vector of current recording streams.
144 * Per VM screen (display) one recording stream is being used. */
[96324]145 RecordingStreams m_vecStreams;
[75441]146 /** Number of streams in vecStreams which currently are enabled for recording. */
[96324]147 uint16_t m_cStreamsEnabled;
[74992]148 /** Timestamp (in ms) of when recording has been started. */
[96324]149 uint64_t m_tsStartMs;
[96229]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. */
[96324]157 RECORDINGCODEC m_CodecAudio;
[96229]158#endif /* VBOX_WITH_AUDIO_RECORDING */
[96260]159 /** Block map of raw common data blocks which need to get encoded first. */
[96324]160 RecordingBlockMap m_mapBlocksRaw;
[96260]161 /** Block map of encoded common blocks.
[74992]162 *
[96260]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 *
[74992]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. */
[96324]171 RecordingBlockMap m_mapBlocksEncoded;
[75251]172};
[76562]173#endif /* !MAIN_INCLUDED_Recording_h */
[45841]174
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use