1 | /* $Id: Recording.h 75488 2018-11-15 16:12:07Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Recording code 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_RECORDING
|
---|
19 | #define ____H_RECORDING
|
---|
20 |
|
---|
21 | #include <VBox/com/array.h>
|
---|
22 | #include <VBox/com/string.h>
|
---|
23 | #include <VBox/com/VirtualBox.h>
|
---|
24 | #include <VBox/err.h>
|
---|
25 | #include <VBox/settings.h>
|
---|
26 |
|
---|
27 | using namespace com;
|
---|
28 |
|
---|
29 | #include "RecordingInternals.h"
|
---|
30 | #include "RecordingStream.h"
|
---|
31 |
|
---|
32 | class Console;
|
---|
33 |
|
---|
34 | /**
|
---|
35 | * Class for managing a capturing context.
|
---|
36 | */
|
---|
37 | class RecordingContext
|
---|
38 | {
|
---|
39 | public:
|
---|
40 |
|
---|
41 | RecordingContext(Console *pConsole, const settings::RecordingSettings &a_Settings);
|
---|
42 |
|
---|
43 | virtual ~RecordingContext(void);
|
---|
44 |
|
---|
45 | public:
|
---|
46 |
|
---|
47 | const settings::RecordingSettings &GetConfig(void) const;
|
---|
48 | RecordingStream *GetStream(unsigned uScreen) const;
|
---|
49 | size_t GetStreamCount(void) const;
|
---|
50 |
|
---|
51 | int Create(const settings::RecordingSettings &a_Settings);
|
---|
52 | int Destroy(void);
|
---|
53 |
|
---|
54 | int Start(void);
|
---|
55 | int Stop(void);
|
---|
56 |
|
---|
57 | int SendAudioFrame(const void *pvData, size_t cbData, uint64_t uTimestampMs);
|
---|
58 | int SendVideoFrame(uint32_t uScreen,
|
---|
59 | uint32_t x, uint32_t y, uint32_t uPixelFormat, uint32_t uBPP,
|
---|
60 | uint32_t uBytesPerLine, uint32_t uSrcWidth, uint32_t uSrcHeight,
|
---|
61 | uint8_t *puSrcData, uint64_t uTimeStampMs);
|
---|
62 | public:
|
---|
63 |
|
---|
64 | bool IsFeatureEnabled(RecordingFeature_T enmFeature);
|
---|
65 | bool IsReady(void) const;
|
---|
66 | bool IsReady(uint32_t uScreen, uint64_t uTimeStampMs);
|
---|
67 | bool IsStarted(void);
|
---|
68 | bool IsLimitReached(void);
|
---|
69 | bool IsLimitReached(uint32_t uScreen, uint64_t uTimeStampMs);
|
---|
70 |
|
---|
71 | DECLCALLBACK(int) OnLimitReached(uint32_t uScreen, int rc);
|
---|
72 |
|
---|
73 | protected:
|
---|
74 |
|
---|
75 | int createInternal(const settings::RecordingSettings &a_Settings);
|
---|
76 | int startInternal(void);
|
---|
77 | int stopInternal(void);
|
---|
78 |
|
---|
79 | int destroyInternal(void);
|
---|
80 |
|
---|
81 | RecordingStream *getStreamInternal(unsigned uScreen) const;
|
---|
82 |
|
---|
83 | int lock(void);
|
---|
84 | int unlock(void);
|
---|
85 |
|
---|
86 | static DECLCALLBACK(int) threadMain(RTTHREAD hThreadSelf, void *pvUser);
|
---|
87 |
|
---|
88 | int threadNotify(void);
|
---|
89 |
|
---|
90 | protected:
|
---|
91 |
|
---|
92 | /**
|
---|
93 | * Enumeration for a recording context state.
|
---|
94 | */
|
---|
95 | enum RECORDINGSTS
|
---|
96 | {
|
---|
97 | /** Context not initialized. */
|
---|
98 | RECORDINGSTS_UNINITIALIZED = 0,
|
---|
99 | /** Context was created. */
|
---|
100 | RECORDINGSTS_CREATED = 1,
|
---|
101 | /** Context was started. */
|
---|
102 | RECORDINGSTS_STARTED = 2,
|
---|
103 | /** The usual 32-bit hack. */
|
---|
104 | RECORDINGSTS_32BIT_HACK = 0x7fffffff
|
---|
105 | };
|
---|
106 |
|
---|
107 | /** Pointer to the console object. */
|
---|
108 | Console *pConsole;
|
---|
109 | /** Used recording configuration. */
|
---|
110 | settings::RecordingSettings Settings;
|
---|
111 | /** The current state. */
|
---|
112 | RECORDINGSTS enmState;
|
---|
113 | /** Critical section to serialize access. */
|
---|
114 | RTCRITSECT CritSect;
|
---|
115 | /** Semaphore to signal the encoding worker thread. */
|
---|
116 | RTSEMEVENT WaitEvent;
|
---|
117 | /** Shutdown indicator. */
|
---|
118 | bool fShutdown;
|
---|
119 | /** Worker thread. */
|
---|
120 | RTTHREAD Thread;
|
---|
121 | /** Vector of current recording streams.
|
---|
122 | * Per VM screen (display) one recording stream is being used. */
|
---|
123 | RecordingStreams vecStreams;
|
---|
124 | /** Number of streams in vecStreams which currently are enabled for recording. */
|
---|
125 | uint16_t cStreamsEnabled;
|
---|
126 | /** Timestamp (in ms) of when recording has been started. */
|
---|
127 | uint64_t tsStartMs;
|
---|
128 | /** Block map of common blocks which need to get multiplexed
|
---|
129 | * to all recording streams. This common block maps should help
|
---|
130 | * reducing the time spent in EMT and avoid doing the (expensive)
|
---|
131 | * multiplexing work in there.
|
---|
132 | *
|
---|
133 | * For now this only affects audio, e.g. all recording streams
|
---|
134 | * need to have the same audio data at a specific point in time. */
|
---|
135 | RecordingBlockMap mapBlocksCommon;
|
---|
136 | };
|
---|
137 | #endif /* !____H_RECORDING */
|
---|
138 |
|
---|