VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxHeadless/VideoCapture/FFmpegFB.h@ 7485

最後變更 在這個檔案從7485是 7485,由 vboxsync 提交於 17 年 前

warnings

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 6.1 KB
 
1/** @file
2 *
3 * VBox Remote Desktop Protocol.
4 * FFmpeg framebuffer interface.
5 */
6
7/*
8 * Copyright (C) 2006-2007 innotek GmbH
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.alldomusa.eu.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19#ifndef _H_FFMPEGFB
20#define _H_FFMPEGFB
21
22#include <VBox/com/VirtualBox.h>
23
24#include <iprt/uuid.h>
25
26#include <VBox/com/com.h>
27#include <VBox/com/string.h>
28
29#include <iprt/runtime.h>
30#include <iprt/critsect.h>
31
32#ifdef DEBUG
33# define VBOX_DEBUG_FF DEBUG
34# include <avcodec.h>
35# include <avformat.h>
36# undef DEBUG
37# define DEBUG VBOX_DEBUG_FF
38#else /* DEBUG not defined */
39# include <avcodec.h>
40# include <avformat.h>
41#endif /* DEBUG not defined */
42
43class FFmpegFB : public IFramebuffer
44{
45public:
46 FFmpegFB(ULONG width, ULONG height, ULONG bitrate, com::Bstr filename);
47 virtual ~FFmpegFB();
48
49#ifndef VBOX_WITH_XPCOM
50 STDMETHOD_(ULONG, AddRef)()
51 {
52 return ::InterlockedIncrement (&refcnt);
53 }
54 STDMETHOD_(ULONG, Release)()
55 {
56 long cnt = ::InterlockedDecrement (&refcnt);
57 if (cnt == 0)
58 delete this;
59 return cnt;
60 }
61 STDMETHOD(QueryInterface) (REFIID riid , void **ppObj)
62 {
63 if (riid == IID_IUnknown)
64 {
65 *ppObj = this;
66 AddRef();
67 return S_OK;
68 }
69 if (riid == IID_IFramebuffer)
70 {
71 *ppObj = this;
72 AddRef();
73 return S_OK;
74 }
75 *ppObj = NULL;
76 return E_NOINTERFACE;
77 }
78#endif
79
80 NS_DECL_ISUPPORTS
81
82 // public methods only for internal purposes
83 HRESULT init ();
84
85 STDMETHOD(COMGETTER(Width))(ULONG *width);
86 STDMETHOD(COMGETTER(Height))(ULONG *height);
87 STDMETHOD(Lock)();
88 STDMETHOD(Unlock)();
89 STDMETHOD(COMGETTER(Address))(BYTE **address);
90 STDMETHOD(COMGETTER(BitsPerPixel))(ULONG *bitsPerPixel);
91 STDMETHOD(COMGETTER(BytesPerLine))(ULONG *bytesPerLine);
92 STDMETHOD(COMGETTER(PixelFormat)) (ULONG *pixelFormat);
93 STDMETHOD(COMGETTER(UsesGuestVRAM)) (BOOL *usesGuestVRAM);
94 STDMETHOD(COMGETTER(HeightReduction)) (ULONG *heightReduction);
95 STDMETHOD(COMGETTER(Overlay)) (IFramebufferOverlay **aOverlay);
96
97 STDMETHOD(NotifyUpdate)(ULONG x, ULONG y,
98 ULONG w, ULONG h, BOOL *finished);
99 STDMETHOD(RequestResize)(ULONG aScreenId, ULONG pixelFormat, BYTE *vram,
100 ULONG bitsPerPixel, ULONG bytesPerLine,
101 ULONG w, ULONG h, BOOL *finished);
102 STDMETHOD(OperationSupported)(FramebufferAccelerationOperation_T operation, BOOL *supported);
103 STDMETHOD(VideoModeSupported)(ULONG width, ULONG height, ULONG bpp, BOOL *supported);
104 STDMETHOD(SolidFill)(ULONG x, ULONG y, ULONG width, ULONG height,
105 ULONG color, BOOL *handled);
106 STDMETHOD(CopyScreenBits)(ULONG xDst, ULONG yDst, ULONG xSrc, ULONG ySrc,
107 ULONG width, ULONG height, BOOL *handled);
108 STDMETHOD(GetVisibleRegion)(BYTE *rectangles, ULONG count, ULONG *countCopied);
109 STDMETHOD(SetVisibleRegion)(BYTE *rectangles, ULONG count);
110
111private:
112 /** true if url_fopen actually succeeded */
113 bool mfUrlOpen;
114 /** Guest framebuffer width */
115 ULONG mGuestWidth;
116 /** Guest framebuffer height */
117 ULONG mGuestHeight;
118 /** Bit rate used for encoding */
119 ULONG mBitRate;
120 /** Guest framebuffer pixel format */
121 ULONG mPixelFormat;
122 /** Guest framebuffer color depth */
123 ULONG mBitsPerPixel;
124 /** Name of the file we will write to */
125 com::Bstr mFileName;
126 /** Guest framebuffer line length */
127 ULONG mBytesPerLine;
128 /** MPEG frame framebuffer width */
129 ULONG mFrameWidth;
130 /** MPEG frame framebuffer height */
131 ULONG mFrameHeight;
132 /** The size of one YUV frame */
133 ULONG mYUVFrameSize;
134 /** If we can't use the video RAM directly, we allocate our own
135 * buffer */
136 uint8_t *mRGBBuffer;
137 /** The address of the buffer - can be either mRGBBuffer or the
138 * guests VRAM (HC address) if we can handle that directly */
139 uint8_t *mBufferAddress;
140 /** An intermediary RGB buffer with the same dimensions */
141 uint8_t *mTempRGBBuffer;
142 /** Frame buffer translated into YUV420 for the mpeg codec */
143 uint8_t *mYUVBuffer;
144 /** Temporary buffer into which the codec writes frames to be
145 * written into the file */
146 uint8_t *mOutBuf;
147 RTCRITSECT mCritSect;
148 /** File where we store the mpeg stream */
149 RTFILE mFile;
150 /** time at which the last "real" frame was created */
151 int64_t mLastTime;
152 /** Pointer to ffmpeg's format information context */
153 AVFormatContext *mpFormatContext;
154 /** ffmpeg context containing information about the stream */
155 AVStream *mpStream;
156 /** Information for ffmpeg describing the current frame */
157 AVFrame *mFrame;
158 /** An AVPicture structure containing information about the
159 * guest framebuffer */
160 AVPicture mGuestPicture;
161 /** ffmpeg pixel format of guest framebuffer */
162 int mFFMPEGPixelFormat;
163 /** An AVPicture structure containing information about the
164 * MPEG frame framebuffer */
165 AVPicture mFramePicture;
166 /** Since we are building without exception support, we use this
167 to signal allocation failure in the constructor */
168 bool mOutOfMemory;
169 /** A hack: ffmpeg mpeg2 only writes a frame if something has
170 changed. So we flip the low luminance bit of the first
171 pixel every frame. */
172 bool mToggle;
173
174 HRESULT setup_library();
175 HRESULT setup_output_format();
176 HRESULT list_formats();
177 HRESULT open_codec();
178 HRESULT open_output_file();
179 void copy_to_intermediate_buffer(ULONG x, ULONG y, ULONG w, ULONG h);
180 HRESULT do_rgb_to_yuv_conversion();
181 HRESULT do_encoding_and_write();
182 HRESULT write_png();
183#ifndef VBOX_WITH_XPCOM
184 long refcnt;
185#endif
186};
187
188
189#endif /* !_H_FFMPEGFB */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette