1 | /* $Id: VideoRec.h 72015 2018-04-25 13:31:43Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Encodes the screen content in VPX format.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2012-2017 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
|
---|
19 | #define ____H_VIDEOREC
|
---|
20 |
|
---|
21 | #include <VBox/com/array.h>
|
---|
22 |
|
---|
23 | struct VIDEORECCONTEXT;
|
---|
24 | typedef struct VIDEORECCONTEXT *PVIDEORECCONTEXT;
|
---|
25 |
|
---|
26 | struct VIDEORECSTREAM;
|
---|
27 | typedef struct VIDEORECSTREAM *PVIDEORECSTREAM;
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * Enumeration for video recording destinations.
|
---|
31 | */
|
---|
32 | typedef enum VIDEORECDEST
|
---|
33 | {
|
---|
34 | /** Invalid destination, do not use. */
|
---|
35 | VIDEORECDEST_INVALID = 0,
|
---|
36 | /** Write to a file. */
|
---|
37 | VIDEORECDEST_FILE = 1
|
---|
38 | } VIDEORECDEST;
|
---|
39 |
|
---|
40 | /**
|
---|
41 | * Enumeration for definining a video / audio
|
---|
42 | * profile setting.
|
---|
43 | */
|
---|
44 | typedef enum VIDEORECPROFILE
|
---|
45 | {
|
---|
46 | VIDEORECPROFILE_NONE = 0,
|
---|
47 | VIDEORECPROFILE_LOW,
|
---|
48 | VIDEORECPROFILE_MEDIUM,
|
---|
49 | VIDEORECPROFILE_HIGH,
|
---|
50 | VIDEORECPROFILE_BEST,
|
---|
51 | VIDEORECPROFILE_REALTIME
|
---|
52 | } VIDEORECPROFILE;
|
---|
53 |
|
---|
54 | /**
|
---|
55 | * Structure for keeping a video recording configuration.
|
---|
56 | */
|
---|
57 | typedef struct VIDEORECCFG
|
---|
58 | {
|
---|
59 | VIDEORECCFG(void)
|
---|
60 | : enmDst(VIDEORECDEST_INVALID)
|
---|
61 | , uMaxTimeS(0)
|
---|
62 | {
|
---|
63 | #ifdef VBOX_WITH_AUDIO_VIDEOREC
|
---|
64 | RT_ZERO(Audio);
|
---|
65 | #endif
|
---|
66 | RT_ZERO(Video);
|
---|
67 | }
|
---|
68 |
|
---|
69 | /** Array of all screens containing whether they're enabled
|
---|
70 | * for recording or not. */
|
---|
71 | com::SafeArray<BOOL> aScreens;
|
---|
72 | /** Destination where to write the stream to. */
|
---|
73 | VIDEORECDEST enmDst;
|
---|
74 |
|
---|
75 | /**
|
---|
76 | * Structure for keeping recording parameters if
|
---|
77 | * destination is a file.
|
---|
78 | */
|
---|
79 | struct
|
---|
80 | {
|
---|
81 | /** File name (as absolute path). */
|
---|
82 | com::Bstr strName;
|
---|
83 | /** Maximum file size (in MB) to record. */
|
---|
84 | uint32_t uMaxSizeMB;
|
---|
85 | } File;
|
---|
86 |
|
---|
87 | #ifdef VBOX_WITH_AUDIO_VIDEOREC
|
---|
88 | /**
|
---|
89 | * Structure for keeping the audio recording parameters.
|
---|
90 | */
|
---|
91 | struct
|
---|
92 | {
|
---|
93 | /** Whether audio recording is enabled or not. */
|
---|
94 | bool fEnabled;
|
---|
95 | /** The device LUN the audio driver is attached / configured to. */
|
---|
96 | unsigned uLUN;
|
---|
97 | /** Hertz (Hz) rate. */
|
---|
98 | uint16_t uHz;
|
---|
99 | /** Bits per sample. */
|
---|
100 | uint8_t cBits;
|
---|
101 | /** Number of audio channels. */
|
---|
102 | uint8_t cChannels;
|
---|
103 | /** Audio profile which is being used. */
|
---|
104 | VIDEORECPROFILE enmProfile;
|
---|
105 | } Audio;
|
---|
106 | #endif
|
---|
107 |
|
---|
108 | /**
|
---|
109 | * Structure for keeping the video recording parameters.
|
---|
110 | */
|
---|
111 | struct
|
---|
112 | {
|
---|
113 | /** Whether video recording is enabled or not. */
|
---|
114 | bool fEnabled;
|
---|
115 | /** Target width (in pixels). */
|
---|
116 | uint32_t uWidth;
|
---|
117 | /** Target height (in pixels). */
|
---|
118 | uint32_t uHeight;
|
---|
119 | /** Target encoding rate. */
|
---|
120 | uint32_t uRate;
|
---|
121 | /** Target FPS. */
|
---|
122 | uint32_t uFPS;
|
---|
123 |
|
---|
124 | #ifdef VBOX_WITH_LIBVPX
|
---|
125 | union
|
---|
126 | {
|
---|
127 | struct
|
---|
128 | {
|
---|
129 | /** Encoder deadline. */
|
---|
130 | unsigned int uEncoderDeadline;
|
---|
131 | } VPX;
|
---|
132 | } Codec;
|
---|
133 | #endif
|
---|
134 |
|
---|
135 | } Video;
|
---|
136 | /** Maximum time (in s) to record.
|
---|
137 | * Specify 0 to disable this check. */
|
---|
138 | uint32_t uMaxTimeS;
|
---|
139 |
|
---|
140 | VIDEORECCFG& operator=(const VIDEORECCFG &that)
|
---|
141 | {
|
---|
142 | aScreens.resize(that.aScreens.size());
|
---|
143 | for (size_t i = 0; i < that.aScreens.size(); ++i)
|
---|
144 | aScreens[i] = that.aScreens[i];
|
---|
145 |
|
---|
146 | enmDst = that.enmDst;
|
---|
147 |
|
---|
148 | File.strName = that.File.strName;
|
---|
149 | File.uMaxSizeMB = that.File.uMaxSizeMB;
|
---|
150 | #ifdef VBOX_WITH_AUDIO_VIDEOREC
|
---|
151 | Audio = that.Audio;
|
---|
152 | #endif
|
---|
153 | Video = that.Video;
|
---|
154 | uMaxTimeS = that.uMaxTimeS;
|
---|
155 | return *this;
|
---|
156 | }
|
---|
157 |
|
---|
158 | } VIDEORECCFG, *PVIDEORECCFG;
|
---|
159 |
|
---|
160 | /** Stores video recording features. */
|
---|
161 | typedef uint32_t VIDEORECFEATURES;
|
---|
162 |
|
---|
163 | /** Video recording is disabled completely. */
|
---|
164 | #define VIDEORECFEATURE_NONE 0
|
---|
165 | /** Capturing video is enabled. */
|
---|
166 | #define VIDEORECFEATURE_VIDEO RT_BIT(0)
|
---|
167 | /** Capturing audio is enabled. */
|
---|
168 | #define VIDEORECFEATURE_AUDIO RT_BIT(1)
|
---|
169 |
|
---|
170 | int VideoRecContextCreate(uint32_t cScreens, PVIDEORECCFG pVideoRecCfg, PVIDEORECCONTEXT *ppCtx);
|
---|
171 | int VideoRecContextDestroy(PVIDEORECCONTEXT pCtx);
|
---|
172 |
|
---|
173 | int VideoRecStreamInit(PVIDEORECCONTEXT pCtx, uint32_t uScreen);
|
---|
174 | int VideoRecStreamUninit(PVIDEORECCONTEXT pCtx, uint32_t uScreen);
|
---|
175 |
|
---|
176 | VIDEORECFEATURES VideoRecGetFeatures(PVIDEORECCFG pCfg);
|
---|
177 |
|
---|
178 | int VideoRecSendAudioFrame(PVIDEORECCONTEXT pCtx, const void *pvData, size_t cbData, uint64_t uTimestampMs);
|
---|
179 | int VideoRecSendVideoFrame(PVIDEORECCONTEXT pCtx, uint32_t uScreen,
|
---|
180 | uint32_t x, uint32_t y, uint32_t uPixelFormat, uint32_t uBPP,
|
---|
181 | uint32_t uBytesPerLine, uint32_t uSrcWidth, uint32_t uSrcHeight,
|
---|
182 | uint8_t *puSrcData, uint64_t uTimeStampMs);
|
---|
183 | bool VideoRecIsReady(PVIDEORECCONTEXT pCtx, uint32_t uScreen, uint64_t uTimeStampMs);
|
---|
184 | bool VideoRecIsStarted(PVIDEORECCONTEXT pCtx);
|
---|
185 | bool VideoRecIsLimitReached(PVIDEORECCONTEXT pCtx, uint32_t uScreen, uint64_t tsNowMs);
|
---|
186 |
|
---|
187 | #endif /* !____H_VIDEOREC */
|
---|
188 |
|
---|