1 | /* $Id: VideoRecInternals.h 74999 2018-10-23 13:50:28Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Video recording internals header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2012-2018 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 ____H_VIDEOREC_INTERNALS
|
---|
19 | #define ____H_VIDEOREC_INTERNALS
|
---|
20 |
|
---|
21 | #include <list>
|
---|
22 |
|
---|
23 | #ifdef VBOX_WITH_LIBVPX
|
---|
24 | # define VPX_CODEC_DISABLE_COMPAT 1
|
---|
25 | # include "vpx/vp8cx.h"
|
---|
26 | # include "vpx/vpx_image.h"
|
---|
27 | # include "vpx/vpx_encoder.h"
|
---|
28 | #endif /* VBOX_WITH_LIBVPX */
|
---|
29 |
|
---|
30 | /**
|
---|
31 | * Enumeration for video recording destinations.
|
---|
32 | */
|
---|
33 | typedef enum VIDEORECDEST
|
---|
34 | {
|
---|
35 | /** Invalid destination, do not use. */
|
---|
36 | VIDEORECDEST_INVALID = 0,
|
---|
37 | /** Write to a file. */
|
---|
38 | VIDEORECDEST_FILE = 1
|
---|
39 | } VIDEORECDEST;
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * Enumeration for the video recording video codec type.
|
---|
43 | */
|
---|
44 | typedef enum VIDEORECVIDEOCODECTYPE
|
---|
45 | {
|
---|
46 | /** Unknown codec type, do not use. */
|
---|
47 | VIDEORECVIDEOCODECTYPE_UNKNOWN,
|
---|
48 | /** Codec is VP8. */
|
---|
49 | VIDEORECVIDEOCODECTYPE_VP8,
|
---|
50 | # ifdef VBOX_WITH_LIBVPX_VP9
|
---|
51 | /** Codec is VP9. */
|
---|
52 | VIDEORECVIDEOCODECTYPE_VP9
|
---|
53 | #endif
|
---|
54 | } VIDEORECVIDEOCODECTYPE;
|
---|
55 |
|
---|
56 | /**
|
---|
57 | * Structure for keeping specific video recording codec data.
|
---|
58 | */
|
---|
59 | typedef struct VIDEORECVIDEOCODEC
|
---|
60 | {
|
---|
61 | /** Used codec type. */
|
---|
62 | VIDEORECVIDEOCODECTYPE enmType;
|
---|
63 | #ifdef VBOX_WITH_LIBVPX
|
---|
64 | union
|
---|
65 | {
|
---|
66 | struct
|
---|
67 | {
|
---|
68 | /** VPX codec context. */
|
---|
69 | vpx_codec_ctx_t Ctx;
|
---|
70 | /** VPX codec configuration. */
|
---|
71 | vpx_codec_enc_cfg_t Cfg;
|
---|
72 | /** VPX image context. */
|
---|
73 | vpx_image_t RawImage;
|
---|
74 | /** Pointer to the codec's internal YUV buffer. */
|
---|
75 | uint8_t *pu8YuvBuf;
|
---|
76 | } VPX;
|
---|
77 | };
|
---|
78 | #endif /* VBOX_WITH_LIBVPX */
|
---|
79 | } VIDEORECVIDEOCODEC, *PVIDEORECVIDEOCODEC;
|
---|
80 |
|
---|
81 | /**
|
---|
82 | * Enumeration for supported pixel formats.
|
---|
83 | */
|
---|
84 | enum VIDEORECPIXELFMT
|
---|
85 | {
|
---|
86 | /** Unknown pixel format. */
|
---|
87 | VIDEORECPIXELFMT_UNKNOWN = 0,
|
---|
88 | /** RGB 24. */
|
---|
89 | VIDEORECPIXELFMT_RGB24 = 1,
|
---|
90 | /** RGB 24. */
|
---|
91 | VIDEORECPIXELFMT_RGB32 = 2,
|
---|
92 | /** RGB 565. */
|
---|
93 | VIDEORECPIXELFMT_RGB565 = 3,
|
---|
94 | /** The usual 32-bit hack. */
|
---|
95 | VIDEORECPIXELFMT_32BIT_HACK = 0x7fffffff
|
---|
96 | };
|
---|
97 |
|
---|
98 | /**
|
---|
99 | * Structure for keeping a single video recording video frame.
|
---|
100 | */
|
---|
101 | typedef struct VIDEORECVIDEOFRAME
|
---|
102 | {
|
---|
103 | /** X resolution of this frame. */
|
---|
104 | uint32_t uWidth;
|
---|
105 | /** Y resolution of this frame. */
|
---|
106 | uint32_t uHeight;
|
---|
107 | /** Pixel format of this frame. */
|
---|
108 | uint32_t uPixelFormat;
|
---|
109 | /** RGB buffer containing the unmodified frame buffer data from Main's display. */
|
---|
110 | uint8_t *pu8RGBBuf;
|
---|
111 | /** Size (in bytes) of the RGB buffer. */
|
---|
112 | size_t cbRGBBuf;
|
---|
113 | } VIDEORECVIDEOFRAME, *PVIDEORECVIDEOFRAME;
|
---|
114 |
|
---|
115 | #ifdef VBOX_WITH_AUDIO_VIDEOREC
|
---|
116 | /**
|
---|
117 | * Structure for keeping a single video recording audio frame.
|
---|
118 | */
|
---|
119 | typedef struct VIDEORECAUDIOFRAME
|
---|
120 | {
|
---|
121 | /** Pointer to audio data. */
|
---|
122 | uint8_t *pvBuf;
|
---|
123 | /** Size (in bytes) of audio data. */
|
---|
124 | size_t cbBuf;
|
---|
125 | } VIDEORECAUDIOFRAME, *PVIDEORECAUDIOFRAME;
|
---|
126 | #endif
|
---|
127 |
|
---|
128 | /**
|
---|
129 | * Enumeration for specifying a video recording block type.
|
---|
130 | */
|
---|
131 | typedef enum VIDEORECBLOCKTYPE
|
---|
132 | {
|
---|
133 | /** Uknown block type, do not use. */
|
---|
134 | VIDEORECBLOCKTYPE_UNKNOWN = 0,
|
---|
135 | /** The block is a video frame. */
|
---|
136 | VIDEORECBLOCKTYPE_VIDEO,
|
---|
137 | #ifdef VBOX_WITH_AUDIO_VIDEOREC
|
---|
138 | /** The block is an audio frame. */
|
---|
139 | VIDEORECBLOCKTYPE_AUDIO
|
---|
140 | #endif
|
---|
141 | } VIDEORECBLOCKTYPE;
|
---|
142 |
|
---|
143 | /**
|
---|
144 | * Generic structure for keeping a single video recording (data) block.
|
---|
145 | */
|
---|
146 | typedef struct VIDEORECBLOCK
|
---|
147 | {
|
---|
148 | /** The block's type. */
|
---|
149 | VIDEORECBLOCKTYPE enmType;
|
---|
150 | /** Number of references held of this block. */
|
---|
151 | uint16_t cRefs;
|
---|
152 | /** The (absolute) time stamp (in ms, PTS) of this block. */
|
---|
153 | uint64_t uTimeStampMs;
|
---|
154 | /** Opaque data block to the actual block data, depending on the block's type. */
|
---|
155 | void *pvData;
|
---|
156 | /** Size (in bytes) of the (opaque) data block. */
|
---|
157 | size_t cbData;
|
---|
158 | } VIDEORECBLOCK, *PVIDEORECBLOCK;
|
---|
159 |
|
---|
160 | /** List for keeping video recording (data) blocks. */
|
---|
161 | typedef std::list<PVIDEORECBLOCK> VideoRecBlockList;
|
---|
162 |
|
---|
163 | void VideoRecBlockFree(PVIDEORECBLOCK pBlock);
|
---|
164 | #ifdef VBOX_WITH_AUDIO_VIDEOREC
|
---|
165 | void VideoRecAudioFrameFree(PVIDEORECAUDIOFRAME pFrame);
|
---|
166 | #endif
|
---|
167 | void VideoRecVideoFrameFree(PVIDEORECVIDEOFRAME pFrame);
|
---|
168 |
|
---|
169 | #endif /* ____H_VIDEOREC_INTERNALS */
|
---|