VirtualBox

source: vbox/trunk/src/VBox/Main/include/RecordingInternals.h@ 94249

Last change on this file since 94249 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1/* $Id: RecordingInternals.h 93115 2022-01-01 11:31:46Z vboxsync $ */
2/** @file
3 * Recording internals header.
4 */
5
6/*
7 * Copyright (C) 2012-2022 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 MAIN_INCLUDED_RecordingInternals_h
19#define MAIN_INCLUDED_RecordingInternals_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <list>
25
26#include <iprt/assert.h>
27#include <iprt/types.h> /* drag in stdint.h before vpx does it. */
28
29#ifdef VBOX_WITH_LIBVPX
30# define VPX_CODEC_DISABLE_COMPAT 1
31# include "vpx/vp8cx.h"
32# include "vpx/vpx_image.h"
33# include "vpx/vpx_encoder.h"
34#endif /* VBOX_WITH_LIBVPX */
35
36/**
37 * Structure for keeping specific recording video codec data.
38 */
39typedef struct RECORDINGVIDEOCODEC
40{
41#ifdef VBOX_WITH_LIBVPX
42 union
43 {
44 struct
45 {
46 /** VPX codec context. */
47 vpx_codec_ctx_t Ctx;
48 /** VPX codec configuration. */
49 vpx_codec_enc_cfg_t Cfg;
50 /** VPX image context. */
51 vpx_image_t RawImage;
52 /** Pointer to the codec's internal YUV buffer. */
53 uint8_t *pu8YuvBuf;
54 /** The encoder's deadline (in ms).
55 * The more time the encoder is allowed to spend encoding, the better the encoded
56 * result, in exchange for higher CPU usage and time spent encoding. */
57 unsigned int uEncoderDeadline;
58 } VPX;
59 };
60#endif /* VBOX_WITH_LIBVPX */
61} RECORDINGVIDEOCODEC, *PRECORDINGVIDEOCODEC;
62
63/**
64 * Enumeration for supported pixel formats.
65 */
66enum RECORDINGPIXELFMT
67{
68 /** Unknown pixel format. */
69 RECORDINGPIXELFMT_UNKNOWN = 0,
70 /** RGB 24. */
71 RECORDINGPIXELFMT_RGB24 = 1,
72 /** RGB 24. */
73 RECORDINGPIXELFMT_RGB32 = 2,
74 /** RGB 565. */
75 RECORDINGPIXELFMT_RGB565 = 3,
76 /** The usual 32-bit hack. */
77 RECORDINGPIXELFMT_32BIT_HACK = 0x7fffffff
78};
79
80/**
81 * Structure for keeping a single recording video frame.
82 */
83typedef struct RECORDINGVIDEOFRAME
84{
85 /** X resolution of this frame. */
86 uint32_t uWidth;
87 /** Y resolution of this frame. */
88 uint32_t uHeight;
89 /** Pixel format of this frame. */
90 uint32_t uPixelFormat;
91 /** RGB buffer containing the unmodified frame buffer data from Main's display. */
92 uint8_t *pu8RGBBuf;
93 /** Size (in bytes) of the RGB buffer. */
94 size_t cbRGBBuf;
95} RECORDINGVIDEOFRAME, *PRECORDINGVIDEOFRAME;
96
97#ifdef VBOX_WITH_AUDIO_RECORDING
98/**
99 * Structure for keeping a single recording audio frame.
100 */
101typedef struct RECORDINGAUDIOFRAME
102{
103 /** Pointer to audio data. */
104 uint8_t *pvBuf;
105 /** Size (in bytes) of audio data. */
106 size_t cbBuf;
107} RECORDINGAUDIOFRAME, *PRECORDINGAUDIOFRAME;
108#endif
109
110/**
111 * Enumeration for specifying a video recording block type.
112 */
113typedef enum RECORDINGBLOCKTYPE
114{
115 /** Uknown block type, do not use. */
116 RECORDINGBLOCKTYPE_UNKNOWN = 0,
117 /** The block is a video frame. */
118 RECORDINGBLOCKTYPE_VIDEO,
119#ifdef VBOX_WITH_AUDIO_RECORDING
120 /** The block is an audio frame. */
121 RECORDINGBLOCKTYPE_AUDIO
122#endif
123} RECORDINGBLOCKTYPE;
124
125#ifdef VBOX_WITH_AUDIO_RECORDING
126void RecordingAudioFrameFree(PRECORDINGAUDIOFRAME pFrame);
127#endif
128void RecordingVideoFrameFree(PRECORDINGVIDEOFRAME pFrame);
129
130/**
131 * Generic structure for keeping a single video recording (data) block.
132 */
133struct RecordingBlock
134{
135 RecordingBlock()
136 : enmType(RECORDINGBLOCKTYPE_UNKNOWN)
137 , cRefs(0)
138 , pvData(NULL)
139 , cbData(0) { }
140
141 virtual ~RecordingBlock()
142 {
143 Reset();
144 }
145
146 void Reset(void)
147 {
148 switch (enmType)
149 {
150 case RECORDINGBLOCKTYPE_UNKNOWN:
151 break;
152
153 case RECORDINGBLOCKTYPE_VIDEO:
154 RecordingVideoFrameFree((PRECORDINGVIDEOFRAME)pvData);
155 break;
156
157#ifdef VBOX_WITH_AUDIO_RECORDING
158 case RECORDINGBLOCKTYPE_AUDIO:
159 RecordingAudioFrameFree((PRECORDINGAUDIOFRAME)pvData);
160 break;
161#endif
162 default:
163 AssertFailed();
164 break;
165 }
166
167 enmType = RECORDINGBLOCKTYPE_UNKNOWN;
168 cRefs = 0;
169 pvData = NULL;
170 cbData = 0;
171 }
172
173 /** The block's type. */
174 RECORDINGBLOCKTYPE enmType;
175 /** Number of references held of this block. */
176 uint16_t cRefs;
177 /** The (absolute) timestamp (in ms, PTS) of this block. */
178 uint64_t msTimestamp;
179 /** Opaque data block to the actual block data, depending on the block's type. */
180 void *pvData;
181 /** Size (in bytes) of the (opaque) data block. */
182 size_t cbData;
183};
184
185/** List for keeping video recording (data) blocks. */
186typedef std::list<RecordingBlock *> RecordingBlockList;
187
188#endif /* !MAIN_INCLUDED_RecordingInternals_h */
189
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