1 | /* $Id: VideoRec.h 68803 2017-09-20 13:06:54Z 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 | /** Whether recording is enabled or not (as a whole). */
|
---|
60 | bool fEnabled;
|
---|
61 | /** Array of all screens containing whether they're enabled
|
---|
62 | * for recording or not. */
|
---|
63 | com::SafeArray<BOOL> aScreens;
|
---|
64 | /** Destination where to write the stream to. */
|
---|
65 | VIDEORECDEST enmDst;
|
---|
66 | union
|
---|
67 | {
|
---|
68 | /**
|
---|
69 | * Structure for keeping recording parameters if
|
---|
70 | * destination is a file.
|
---|
71 | */
|
---|
72 | struct
|
---|
73 | {
|
---|
74 | BSTR strFile;
|
---|
75 | /** Maximum file size (in MB) to record. */
|
---|
76 | uint32_t uMaxSizeMB;
|
---|
77 | } File;
|
---|
78 | };
|
---|
79 |
|
---|
80 | #ifdef VBOX_WITH_AUDIO_VIDEOREC
|
---|
81 | /**
|
---|
82 | * Structure for keeping the audio recording parameters.
|
---|
83 | */
|
---|
84 | struct
|
---|
85 | {
|
---|
86 | bool fEnabled;
|
---|
87 | uint16_t uHz;
|
---|
88 | uint8_t cBits;
|
---|
89 | uint8_t cChannels;
|
---|
90 | VIDEORECPROFILE enmProfile;
|
---|
91 | } Audio;
|
---|
92 | #endif
|
---|
93 |
|
---|
94 | /**
|
---|
95 | * Structure for keeping the video recording parameters.
|
---|
96 | */
|
---|
97 | struct
|
---|
98 | {
|
---|
99 | bool fEnabled;
|
---|
100 | uint32_t uWidth;
|
---|
101 | uint32_t uHeight;
|
---|
102 | uint32_t uRate;
|
---|
103 | uint32_t uFPS;
|
---|
104 |
|
---|
105 | #ifdef VBOX_WITH_LIBVPX
|
---|
106 | union
|
---|
107 | {
|
---|
108 | struct
|
---|
109 | {
|
---|
110 | /** Encoder deadline. */
|
---|
111 | unsigned int uEncoderDeadline;
|
---|
112 | } VPX;
|
---|
113 | } Codec;
|
---|
114 | #endif
|
---|
115 |
|
---|
116 | } Video;
|
---|
117 | /** Maximum time (in s) to record.
|
---|
118 | * Specify 0 to disable this check. */
|
---|
119 | uint32_t uMaxTimeS;
|
---|
120 |
|
---|
121 | VIDEORECCFG& operator=(const VIDEORECCFG &that)
|
---|
122 | {
|
---|
123 | fEnabled = that.fEnabled;
|
---|
124 |
|
---|
125 | aScreens.resize(that.aScreens.size());
|
---|
126 | for (size_t i = 0; i < that.aScreens.size(); ++i)
|
---|
127 | aScreens[i] = that.aScreens[i];
|
---|
128 |
|
---|
129 | enmDst = that.enmDst;
|
---|
130 |
|
---|
131 | File.strFile = that.File.strFile;
|
---|
132 | File.uMaxSizeMB = that.File.uMaxSizeMB;
|
---|
133 | #ifdef VBOX_WITH_AUDIO_VIDEOREC
|
---|
134 | Audio = that.Audio;
|
---|
135 | #endif
|
---|
136 | Video = that.Video;
|
---|
137 | uMaxTimeS = that.uMaxTimeS;
|
---|
138 | return *this;
|
---|
139 | }
|
---|
140 |
|
---|
141 | } VIDEORECCFG, *PVIDEORECCFG;
|
---|
142 |
|
---|
143 | /** Stores video recording features. */
|
---|
144 | typedef uint32_t VIDEORECFEATURES;
|
---|
145 |
|
---|
146 | /** Video recording is disabled completely. */
|
---|
147 | #define VIDEORECFEATURE_NONE 0
|
---|
148 | /** Capturing video is enabled. */
|
---|
149 | #define VIDEORECFEATURE_VIDEO RT_BIT(0)
|
---|
150 | /** Capturing audio is enabled. */
|
---|
151 | #define VIDEORECFEATURE_AUDIO RT_BIT(1)
|
---|
152 |
|
---|
153 | int VideoRecContextCreate(uint32_t cScreens, PVIDEORECCFG pVideoRecCfg, PVIDEORECCONTEXT *ppCtx);
|
---|
154 | int VideoRecContextDestroy(PVIDEORECCONTEXT pCtx);
|
---|
155 |
|
---|
156 | int VideoRecStreamInit(PVIDEORECCONTEXT pCtx, uint32_t uScreen);
|
---|
157 | int VideoRecStreamUninit(PVIDEORECCONTEXT pCtx, uint32_t uScreen);
|
---|
158 |
|
---|
159 | VIDEORECFEATURES VideoRecGetEnabled(PVIDEORECCFG pCfg);
|
---|
160 |
|
---|
161 | int VideoRecSendAudioFrame(PVIDEORECCONTEXT pCtx, const void *pvData, size_t cbData, uint64_t uTimestampMs);
|
---|
162 | int VideoRecSendVideoFrame(PVIDEORECCONTEXT pCtx, uint32_t uScreen,
|
---|
163 | uint32_t x, uint32_t y, uint32_t uPixelFormat, uint32_t uBPP,
|
---|
164 | uint32_t uBytesPerLine, uint32_t uSrcWidth, uint32_t uSrcHeight,
|
---|
165 | uint8_t *puSrcData, uint64_t uTimeStampMs);
|
---|
166 | bool VideoRecIsReady(PVIDEORECCONTEXT pCtx, uint32_t uScreen, uint64_t uTimeStampMs);
|
---|
167 | bool VideoRecIsActive(PVIDEORECCONTEXT pCtx);
|
---|
168 | bool VideoRecIsLimitReached(PVIDEORECCONTEXT pCtx, uint32_t uScreen, uint64_t tsNowMs);
|
---|
169 |
|
---|
170 | #endif /* !____H_VIDEOREC */
|
---|
171 |
|
---|