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