VirtualBox

Changeset 75251 in vbox for trunk/src/VBox/Main/include


Ignore:
Timestamp:
Nov 5, 2018 5:55:29 PM (6 years ago)
Author:
vboxsync
Message:

Capturing: Separated capturing settings into new interfaces ICaptureSettings and ICaptureScreenSettings to unload stuff from IMachine; a lot of internal interface / code cleanups. Also see #9286. Work in progress.

Location:
trunk/src/VBox/Main/include
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r74765 r75251  
    2424#include "SecretKeyStore.h"
    2525#include "ConsoleWrap.h"
     26#ifdef VBOX_WITH_VIDEOREC
     27# include "VideoRec.h"
     28#endif
    2629
    2730class Guest;
     
    139142#endif
    140143#ifdef VBOX_WITH_AUDIO_VIDEOREC
    141     AudioVideoRec *i_getAudioVideoRec() const { return mAudioVideoRec; }
    142     HRESULT i_audioVideoRecSendAudio(const void *pvData, size_t cbData, uint64_t uDurationMs);
     144    int i_videoRecLoad(settings::CaptureSettings &Settings);
     145    int i_videoRecStart(void);
     146    int i_videoRecStop(void);
     147    AudioVideoRec *i_videoRecGetAudioDrv(void) const { return Capture.mAudioVideoRec; }
     148    CaptureContext *i_videoRecGetContext(void) const { return Capture.mpVideoRecCtx; }
     149    HRESULT i_videoRecSendAudio(const void *pvData, size_t cbData, uint64_t uDurationMs);
    143150#endif
    144151
     
    169176    HRESULT i_onDnDModeChange(DnDMode_T aDnDMode);
    170177    HRESULT i_onVRDEServerChange(BOOL aRestart);
    171     HRESULT i_onVideoCaptureChange();
     178    HRESULT i_onCaptureChange();
    172179    HRESULT i_onUSBControllerChange();
    173180    HRESULT i_onSharedFolderChange(BOOL aGlobal);
     
    939946    VMMDev *                    m_pVMMDev;
    940947    AudioVRDE * const           mAudioVRDE;
    941 #ifdef VBOX_WITH_AUDIO_VIDEOREC
    942     /** The video recording audio backend. */
    943     AudioVideoRec * const       mAudioVideoRec;
    944 #endif
    945948    Nvram   * const             mNvram;
    946949#ifdef VBOX_WITH_USB_CARDREADER
     
    10281031    ComPtr<IEventListener> mVmListener;
    10291032
     1033#ifdef VBOX_WITH_VIDEOREC
     1034    struct Capture
     1035    {
     1036        Capture()
     1037            : mpVideoRecCtx(NULL)
     1038            , mAudioVideoRec(NULL) { }
     1039
     1040        /** The capturing context. */
     1041        CaptureContext       *mpVideoRecCtx;
     1042# ifdef VBOX_WITH_AUDIO_VIDEOREC
     1043        /** Pointer to capturing audio backend. */
     1044        AudioVideoRec * const mAudioVideoRec;
     1045# endif
     1046    } Capture;
     1047#endif /* VBOX_WITH_VIDEOREC */
     1048
    10301049    friend class VMTask;
    10311050    friend class ConsoleVRDPServer;
  • trunk/src/VBox/Main/include/DisplayImpl.h

    r75072 r75251  
    3232#endif
    3333
    34 #ifdef VBOX_WITH_VIDEOREC
    35 # include "VideoRec.h"
    36 struct VIDEORECCONTEXT;
    37 #endif
    38 
    3934#include "DisplaySourceBitmapWrap.h"
    4035#include "GuestScreenInfoWrap.h"
     
    184179                                          uint32_t x, uint32_t y, uint32_t uPixelFormat, uint32_t uBitsPerPixel,
    185180                                          uint32_t uBytesPerLine, uint32_t uGuestWidth, uint32_t uGuestHeight,
    186                                           uint8_t *pu8BufferAddress, uint64_t u64TimeStamp);
    187     /** @todo r=bird: u64TimeStamp - using the 'u64' prefix add nothing.
    188      *        However, using one of the prefixes indicating the timestamp unit
    189      *        would be very valuable!  */
    190     bool i_handleCrVRecScreenshotBegin(uint32_t uScreen, uint64_t u64TimeStamp);
    191     void i_handleCrVRecScreenshotEnd(uint32_t uScreen, uint64_t u64TimeStamp);
     181                                          uint8_t *pu8BufferAddress, uint64_t uTimestampMs);
     182    bool i_handleCrVRecScreenshotBegin(uint32_t uScreen, uint64_t uTimestampMs);
     183    void i_handleCrVRecScreenshotEnd(uint32_t uScreen, uint64_t uTimestampMs);
    192184    void i_handleVRecCompletion();
    193185#endif
     
    209201
    210202#ifdef VBOX_WITH_VIDEOREC
    211     PVIDEORECCFG             i_videoRecGetConfig(void) { return &mVideoRecCfg; }
    212     VIDEORECFEATURES         i_videoRecGetFeatures(void);
    213     bool                     i_videoRecStarted(void);
    214     void                     i_videoRecInvalidate();
    215     int                      i_videoRecSendAudio(const void *pvData, size_t cbData, uint64_t uTimestampMs);
    216     int                      i_videoRecStart(void);
    217     void                     i_videoRecStop(void);
    218     void                     i_videoRecScreenChanged(unsigned uScreenId);
     203    int  i_videoRecInvalidate(void);
     204    void i_videoRecScreenChanged(unsigned uScreenId);
    219205#endif
    220206
     
    486472    /* Serializes access to video recording source bitmaps. */
    487473    RTCRITSECT           mVideoRecLock;
    488     /** The current video recording configuration being used. */
    489     VIDEORECCFG          mVideoRecCfg;
    490     /** The video recording context. */
    491     VIDEORECCONTEXT     *mpVideoRecCtx;
    492     /** Array which defines which screens are being enabled for recording. */
     474    /** Array which defines which screens are being enabled for capturing. */
    493475    bool                 maVideoRecEnabled[SchemaDefs::MaxGuestMonitors];
    494476#endif
  • trunk/src/VBox/Main/include/DrvAudioVideoRec.h

    r74955 r75251  
    2020
    2121#include <VBox/com/ptr.h>
     22#include <VBox/settings.h>
    2223#include <VBox/vmm/pdmdrv.h>
    2324#include <VBox/vmm/pdmifs.h>
     
    4445public:
    4546
    46     int applyConfiguration(const PVIDEORECCFG pVideoRecCfg);
     47    int applyConfiguration(const settings::CaptureSettings &a_Settings);
    4748
    4849public:
     
    5859
    5960    /** Pointer to the associated video recording audio driver. */
    60     struct DRVAUDIOVIDEOREC *mpDrv;
    61     /** Video recording configuration used for configuring the driver. */
    62     struct VIDEORECCFG      mVideoRecCfg;
     61    struct DRVAUDIOVIDEOREC         *mpDrv;
     62    /** Capturing configuration used for configuring the driver. */
     63    struct settings::CaptureSettings mVideoRecCfg;
    6364};
    6465
  • trunk/src/VBox/Main/include/MachineImpl.h

    r72919 r75251  
    55
    66/*
    7  * Copyright (C) 2006-2017 Oracle Corporation
     7 * Copyright (C) 2006-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3232#include "ParallelPortImpl.h"
    3333#include "BIOSSettingsImpl.h"
     34#include "CaptureSettingsImpl.h"
    3435#include "StorageControllerImpl.h"          // required for MachineImpl.h to compile on Windows
    3536#include "USBControllerImpl.h"              // required for MachineImpl.h to compile on Windows
     
    265266        GraphicsControllerType_T mGraphicsControllerType;
    266267        ULONG               mVRAMSize;
    267         ULONG               mVideoCaptureWidth;
    268         ULONG               mVideoCaptureHeight;
    269         ULONG               mVideoCaptureRate;
    270         ULONG               mVideoCaptureFPS;
    271         ULONG               mVideoCaptureMaxTime;
    272         ULONG               mVideoCaptureMaxFileSize;
    273         Utf8Str             mVideoCaptureOptions;
    274         Utf8Str             mVideoCaptureFile;
    275         BOOL                mVideoCaptureEnabled;
    276         BOOL                maVideoCaptureScreens[SchemaDefs::MaxGuestMonitors];
     268        settings::CaptureSettings mCaptureSettings;
    277269        ULONG               mMonitorCount;
    278270        BOOL                mHWVirtExEnabled;
     
    484476        IsModified_SharedFolders        = 0x0400,
    485477        IsModified_Snapshots            = 0x0800,
    486         IsModified_BandwidthControl     = 0x1000
     478        IsModified_BandwidthControl     = 0x1000,
     479        IsModified_Capture              = 0x2000
    487480    };
    488481
     
    528521    virtual HRESULT i_onStorageDeviceChange(IMediumAttachment * /* mediumAttachment */, BOOL /* remove */,
    529522                                            BOOL /* silent */) { return S_OK; }
    530     virtual HRESULT i_onVideoCaptureChange() { return S_OK; }
     523    virtual HRESULT i_onCaptureChange() { return S_OK; }
    531524
    532525    HRESULT i_saveRegistryEntry(settings::MachineRegistryEntry &data);
     
    540533
    541534    void i_composeSavedStateFilename(Utf8Str &strStateFilePath);
    542 
    543     void i_getDefaultVideoCaptureFile(Utf8Str &strFile);
    544535
    545536    bool i_isUSBControllerPresent();
     
    783774    const ComObjPtr<USBDeviceFilters>  mUSBDeviceFilters;
    784775    const ComObjPtr<BIOSSettings>      mBIOSSettings;
     776    const ComObjPtr<CaptureSettings>   mCaptureSettings;
    785777    const ComObjPtr<BandwidthControl>  mBandwidthControl;
    786778
     
    829821    void i_deleteConfigHandler(DeleteConfigTask &task);
    830822
     823    friend class Appliance;
     824    friend class CaptureSettings;
     825    friend class CaptureScreenSettings;
    831826    friend class SessionMachine;
    832827    friend class SnapshotMachine;
    833     friend class Appliance;
    834828    friend class VirtualBox;
    835829
     
    882876    HRESULT getMonitorCount(ULONG *aMonitorCount);
    883877    HRESULT setMonitorCount(ULONG aMonitorCount);
    884     HRESULT getVideoCaptureEnabled(BOOL *aVideoCaptureEnabled);
    885     HRESULT setVideoCaptureEnabled(BOOL aVideoCaptureEnabled);
    886     HRESULT getVideoCaptureScreens(std::vector<BOOL> &aVideoCaptureScreens);
    887     HRESULT setVideoCaptureScreens(const std::vector<BOOL> &aVideoCaptureScreens);
    888     HRESULT getVideoCaptureFile(com::Utf8Str &aVideoCaptureFile);
    889     HRESULT setVideoCaptureFile(const com::Utf8Str &aVideoCaptureFile);
    890     HRESULT getVideoCaptureWidth(ULONG *aVideoCaptureWidth);
    891     HRESULT setVideoCaptureWidth(ULONG aVideoCaptureWidth);
    892     HRESULT getVideoCaptureHeight(ULONG *aVideoCaptureHeight);
    893     HRESULT setVideoCaptureHeight(ULONG aVideoCaptureHeight);
    894     HRESULT getVideoCaptureRate(ULONG *aVideoCaptureRate);
    895     HRESULT setVideoCaptureRate(ULONG aVideoCaptureRate);
    896     HRESULT getVideoCaptureFPS(ULONG *aVideoCaptureFPS);
    897     HRESULT setVideoCaptureFPS(ULONG aVideoCaptureFPS);
    898     HRESULT getVideoCaptureMaxTime(ULONG *aVideoCaptureMaxTime);
    899     HRESULT setVideoCaptureMaxTime(ULONG aVideoCaptureMaxTime);
    900     HRESULT getVideoCaptureMaxFileSize(ULONG *aVideoCaptureMaxFileSize);
    901     HRESULT setVideoCaptureMaxFileSize(ULONG aVideoCaptureMaxFileSize);
    902     HRESULT getVideoCaptureOptions(com::Utf8Str &aVideoCaptureOptions);
    903     HRESULT setVideoCaptureOptions(const com::Utf8Str &aVideoCaptureOptions);
    904878    HRESULT getBIOSSettings(ComPtr<IBIOSSettings> &aBIOSSettings);
     879    HRESULT getCaptureSettings(ComPtr<ICaptureSettings> &aCaptureSettings);
    905880    HRESULT getFirmwareType(FirmwareType_T *aFirmwareType);
    906881    HRESULT setFirmwareType(FirmwareType_T aFirmwareType);
     
    13481323    HRESULT i_onCPUChange(ULONG aCPU, BOOL aRemove);
    13491324    HRESULT i_onVRDEServerChange(BOOL aRestart);
    1350     HRESULT i_onVideoCaptureChange();
     1325    HRESULT i_onCaptureChange();
    13511326    HRESULT i_onUSBControllerChange();
    13521327    HRESULT i_onUSBDeviceAttach(IUSBDevice *aDevice,
  • trunk/src/VBox/Main/include/SessionImpl.h

    r68986 r75251  
    102102    HRESULT onCPUExecutionCapChange(ULONG aExecutionCap);
    103103    HRESULT onVRDEServerChange(BOOL aRestart);
    104     HRESULT onVideoCaptureChange();
     104    HRESULT onCaptureChange();
    105105    HRESULT onUSBControllerChange();
    106106    HRESULT onSharedFolderChange(BOOL aGlobal);
  • trunk/src/VBox/Main/include/VideoRec.h

    r75067 r75251  
    2323#include <VBox/com/VirtualBox.h>
    2424#include <VBox/err.h>
     25#include <VBox/settings.h>
    2526
    2627using namespace com;
     
    2930#include "VideoRecStream.h"
    3031
     32#if 0
    3133/**
    3234 * Enumeration for definining a video / audio
     
    5456
    5557/**
    56  * Structure for keeping a video recording configuration.
    57  */
    58 typedef struct VIDEORECCFG
     58 * Structure for keeping a screen recording configuration.
     59 */
     60typedef struct VIDEORECSCREENCFG
    5961{
    60     VIDEORECCFG(void)
    61         :  enmDst(VIDEORECDEST_INVALID)
     62    VIDEORECSCREENCFG(void)
     63        : enmDst(VIDEORECDEST_INVALID)
    6264        , uMaxTimeS(0)
    6365    {
     
    6870    }
    6971
    70     /** Array of all screens containing whether they're enabled
    71      *  for recording or not.  */
    72     com::SafeArray<BOOL>    aScreens;
     72    VIDEORECSCREENCFG& operator=(const VIDEORECSCREENCFG &that)
     73    {
     74        enmDst          = that.enmDst;
     75
     76        File.strName    = that.File.strName;
     77        File.uMaxSizeMB = that.File.uMaxSizeMB;
     78#ifdef VBOX_WITH_AUDIO_VIDEOREC
     79        Audio           = that.Audio;
     80#endif
     81        Video           = that.Video;
     82        uMaxTimeS       = that.uMaxTimeS;
     83        return *this;
     84    }
     85
     86    unsigned long           uScreenId;
    7387    /** Destination where to write the stream to. */
    7488    VIDEORECDEST            enmDst;
     
    135149
    136150    } Video;
     151
    137152    /** Maximum time (in s) to record.
    138153     *  Specify 0 to disable this check. */
    139154    uint32_t                uMaxTimeS;
    140 
    141     VIDEORECCFG& operator=(const VIDEORECCFG &that)
    142     {
    143         aScreens.resize(that.aScreens.size());
    144         for (size_t i = 0; i < that.aScreens.size(); ++i)
    145             aScreens[i] = that.aScreens[i];
    146 
    147         enmDst   = that.enmDst;
    148 
    149         File.strName    = that.File.strName;
    150         File.uMaxSizeMB = that.File.uMaxSizeMB;
    151 #ifdef VBOX_WITH_AUDIO_VIDEOREC
    152         Audio           = that.Audio;
    153 #endif
    154         Video           = that.Video;
    155         uMaxTimeS       = that.uMaxTimeS;
    156         return *this;
    157     }
    158 
    159 } VIDEORECCFG, *PVIDEORECCFG;
     155} VIDEORECSCREENCFG, *PVIDEORECSCREENCFG;
     156#endif
     157
     158class Console;
    160159
    161160/**
    162  * Structure for keeping a video recording context.
    163  */
    164 typedef struct VIDEORECCONTEXT
     161 * Class for managing a capturing context.
     162 */
     163class CaptureContext
    165164{
     165public:
     166
     167    CaptureContext(Console *pConsole);
     168
     169    CaptureContext(Console *pConsole, const settings::CaptureSettings &a_Settings);
     170
     171    virtual ~CaptureContext(void);
     172
     173public:
     174
     175    const settings::CaptureSettings &GetConfig(void) const;
     176    CaptureStream *GetStream(unsigned uScreen) const;
     177    size_t GetStreamCount(void) const;
     178
     179    int Create(const settings::CaptureSettings &a_Settings);
     180    int Destroy(void);
     181
     182    int SendAudioFrame(const void *pvData, size_t cbData, uint64_t uTimestampMs);
     183    int SendVideoFrame(uint32_t uScreen,
     184                       uint32_t x, uint32_t y, uint32_t uPixelFormat, uint32_t uBPP,
     185                       uint32_t uBytesPerLine, uint32_t uSrcWidth, uint32_t uSrcHeight,
     186                       uint8_t *puSrcData, uint64_t uTimeStampMs);
     187public:
     188
     189    bool IsFeatureEnabled(CaptureFeature_T enmFeature) const;
     190    bool IsReady(void) const;
     191    bool IsReady(uint32_t uScreen, uint64_t uTimeStampMs) const;
     192    bool IsStarted(void) const;
     193    bool IsLimitReached(uint32_t uScreen, uint64_t tsNowMs) const;
     194
     195protected:
     196
     197    int createInternal(const settings::CaptureSettings &a_Settings);
     198
     199    int destroyInternal(void);
     200
     201    CaptureStream *getStreamInternal(unsigned uScreen) const;
     202
     203    static DECLCALLBACK(int) threadMain(RTTHREAD hThreadSelf, void *pvUser);
     204
     205    int threadNotify(void);
     206
     207protected:
     208
     209    /** Pointer to the console object. */
     210    Console                  *pConsole;
    166211    /** Used recording configuration. */
    167     VIDEORECCFG         Cfg;
     212    settings::CaptureSettings Settings;
    168213    /** The current state. */
    169     uint32_t            enmState;
     214    uint32_t                  enmState;
    170215    /** Critical section to serialize access. */
    171     RTCRITSECT          CritSect;
     216    RTCRITSECT                CritSect;
    172217    /** Semaphore to signal the encoding worker thread. */
    173     RTSEMEVENT          WaitEvent;
    174     /** Whether this conext is in started state or not. */
    175     bool                fStarted;
     218    RTSEMEVENT                WaitEvent;
     219    /** Whether this context is in started state or not. */
     220    bool                      fStarted;
    176221    /** Shutdown indicator. */
    177     bool                fShutdown;
     222    bool                      fShutdown;
    178223    /** Worker thread. */
    179     RTTHREAD            Thread;
     224    RTTHREAD                  Thread;
    180225    /** Vector of current recording streams.
    181226     *  Per VM screen (display) one recording stream is being used. */
    182     VideoRecStreams     vecStreams;
     227    VideoRecStreams           vecStreams;
    183228    /** Timestamp (in ms) of when recording has been started. */
    184     uint64_t            tsStartMs;
     229    uint64_t                  tsStartMs;
    185230    /** Block map of common blocks which need to get multiplexed
    186231     *  to all recording streams. This common block maps should help
     
    190235     *  For now this only affects audio, e.g. all recording streams
    191236     *  need to have the same audio data at a specific point in time. */
    192     VideoRecBlockMap    mapBlocksCommon;
    193 } VIDEORECCONTEXT, *PVIDEORECCONTEXT;
    194 
    195 int VideoRecContextCreate(uint32_t cScreens, PVIDEORECCFG pVideoRecCfg, PVIDEORECCONTEXT *ppCtx);
    196 int VideoRecContextDestroy(PVIDEORECCONTEXT pCtx);
    197 
    198 VIDEORECFEATURES VideoRecGetFeatures(PVIDEORECCFG pCfg);
    199 PVIDEORECSTREAM VideoRecGetStream(PVIDEORECCONTEXT pCtx, uint32_t uScreen);
    200 
    201 int VideoRecSendAudioFrame(PVIDEORECCONTEXT pCtx, const void *pvData, size_t cbData, uint64_t uTimestampMs);
    202 int VideoRecSendVideoFrame(PVIDEORECCONTEXT pCtx, uint32_t uScreen,
    203                             uint32_t x, uint32_t y, uint32_t uPixelFormat, uint32_t uBPP,
    204                             uint32_t uBytesPerLine, uint32_t uSrcWidth, uint32_t uSrcHeight,
    205                             uint8_t *puSrcData, uint64_t uTimeStampMs);
    206 bool VideoRecIsReady(PVIDEORECCONTEXT pCtx, uint32_t uScreen, uint64_t uTimeStampMs);
    207 bool VideoRecIsStarted(PVIDEORECCONTEXT pCtx);
    208 bool VideoRecIsLimitReached(PVIDEORECCONTEXT pCtx, uint32_t uScreen, uint64_t tsNowMs);
    209 
     237    VideoRecBlockMap          mapBlocksCommon;
     238};
    210239#endif /* !____H_VIDEOREC */
    211240
  • trunk/src/VBox/Main/include/VideoRecInternals.h

    r75005 r75251  
    3030
    3131/**
    32  * Enumeration for video recording destinations.
    33  */
    34 typedef enum VIDEORECDEST
    35 {
    36     /** Invalid destination, do not use. */
    37     VIDEORECDEST_INVALID = 0,
    38     /** Write to a file. */
    39     VIDEORECDEST_FILE    = 1
    40 } VIDEORECDEST;
    41 
    42 /**
    43  * Enumeration for the video recording video codec type.
    44  */
    45 typedef enum VIDEORECVIDEOCODECTYPE
    46 {
    47     /** Unknown codec type, do not use. */
    48     VIDEORECVIDEOCODECTYPE_UNKNOWN,
    49     /** Codec is VP8. */
    50     VIDEORECVIDEOCODECTYPE_VP8,
    51 # ifdef VBOX_WITH_LIBVPX_VP9
    52     /** Codec is VP9. */
    53     VIDEORECVIDEOCODECTYPE_VP9
    54 #endif
    55 } VIDEORECVIDEOCODECTYPE;
    56 
    57 /**
    5832 * Structure for keeping specific video recording codec data.
    5933 */
    6034typedef struct VIDEORECVIDEOCODEC
    6135{
    62     /** Used codec type. */
    63     VIDEORECVIDEOCODECTYPE enmType;
    6436#ifdef VBOX_WITH_LIBVPX
    6537    union
     
    7547            /** Pointer to the codec's internal YUV buffer. */
    7648            uint8_t            *pu8YuvBuf;
     49            unsigned int        uEncoderDeadline;
    7750        } VPX;
    7851    };
  • trunk/src/VBox/Main/include/VideoRecStream.h

    r75067 r75251  
    2727#include <VBox/com/VirtualBox.h>
    2828#include <VBox/err.h>
     29#include <VBox/settings.h>
    2930
    3031#include "VideoRecInternals.h"
     
    3233class WebMWriter;
    3334
    34 struct VIDEORECCFG;
    35 typedef struct VIDEORECCFG *PVIDEORECCFG;
    36 
    37 struct VIDEORECCONTEXT;
    38 typedef struct VIDEORECCONTEXT *PVIDEORECCONTEXT;
     35struct CaptureContext;
     36typedef struct CaptureContext *PVIDEORECCONTEXT;
    3937
    4038
    4139/** Structure for queuing all blocks bound to a single timecode.
    4240 *  This can happen if multiple tracks are being involved. */
    43 struct VideoRecBlocks
     41struct CaptureBlocks
    4442{
    45     virtual ~VideoRecBlocks()
     43    virtual ~CaptureBlocks()
    4644    {
    4745        Clear();
     
    7169 *  The key specifies a unique timecode, whereas the value
    7270 *  is a list of blocks which all correlate to the same key (timecode). */
    73 typedef std::map<uint64_t, VideoRecBlocks *> VideoRecBlockMap;
     71typedef std::map<uint64_t, CaptureBlocks *> VideoRecBlockMap;
    7472
    7573/**
    76  * Structure for holding a set of video recording (data) blocks.
    77  */
    78 struct VideoRecBlockSet
     74 * Structure for holding a set of recording (data) blocks.
     75 */
     76struct CaptureBlockSet
    7977{
    80     virtual ~VideoRecBlockSet()
     78    virtual ~CaptureBlockSet()
    8179    {
    8280        Clear();
     
    8482
    8583    /**
    86      * Resets a video recording block set by removing (destroying)
     84     * Resets a recording block set by removing (destroying)
    8785     * all current elements.
    8886     */
    89     void Clear()
     87    void Clear(void)
    9088    {
    9189        VideoRecBlockMap::iterator it = Map.begin();
     
    108106
    109107/**
    110  * Structure for maintaining a video recording stream.
    111  */
    112 typedef struct VIDEORECSTREAM
     108 * Class for managing a recording stream.
     109 */
     110class CaptureStream
    113111{
    114     /** Video recording context this stream is associated to. */
    115     PVIDEORECCONTEXT            pCtx;
    116     /** Destination where to write the stream to. */
    117     VIDEORECDEST                enmDst;
     112public:
     113
     114    CaptureStream(void);
     115
     116    CaptureStream(uint32_t a_uScreen, const settings::CaptureScreenSettings &a_Settings);
     117
     118    virtual ~CaptureStream(void);
     119
     120public:
     121
     122    int Init(uint32_t a_uScreen, const settings::CaptureScreenSettings &a_Settings);
     123    int Uninit(void);
     124
     125    int Process(VideoRecBlockMap &mapBlocksCommon);
     126    int SendVideoFrame(uint32_t x, uint32_t y, uint32_t uPixelFormat, uint32_t uBPP, uint32_t uBytesPerLine,
     127                       uint32_t uSrcWidth, uint32_t uSrcHeight, uint8_t *puSrcData, uint64_t uTimeStampMs);
     128
     129    const settings::CaptureScreenSettings &GetConfig(void) const;
     130    bool IsLimitReached(uint64_t tsNowMs) const;
     131    bool IsReady(void) const;
     132
     133protected:
     134
     135    int open(void);
     136    int close(void);
     137
     138    int initInternal(uint32_t a_uScreen, const settings::CaptureScreenSettings &a_Settings);
     139    int uninitInternal(void);
     140
     141    int initVideo(void);
     142    int unitVideo(void);
     143
     144    int initAudio(void);
     145
     146#ifdef VBOX_WITH_LIBVPX
     147    int initVideoVPX(void);
     148    int uninitVideoVPX(void);
     149    int writeVideoVPX(uint64_t uTimeStampMs, PVIDEORECVIDEOFRAME pFrame);
     150#endif
     151    void lock(void);
     152    void unlock(void);
     153
     154    int parseOptionsString(const com::Utf8Str &strOptions);
     155
     156protected:
     157
     158    /** Recording context this stream is associated to. */
     159    CaptureContext             *pCtx;
    118160    union
    119161    {
     
    123165            RTFILE              hFile;
    124166            /** File name being used for this stream. */
    125             char               *pszFile;
     167            Utf8Str             strName;
    126168            /** Pointer to WebM writer instance being used. */
    127169            WebMWriter         *pWEBM;
    128170        } File;
    129171    };
     172    bool                fEnabled;
    130173#ifdef VBOX_WITH_AUDIO_VIDEOREC
    131174    /** Track number of audio stream. */
     
    136179    /** Screen ID. */
    137180    uint16_t            uScreenID;
    138     /** Whether video recording is enabled or not. */
    139     bool                fEnabled;
    140181    /** Critical section to serialize access. */
    141182    RTCRITSECT          CritSect;
     183    /** Timestamp (in ms) of when recording has been start. */
     184    uint64_t            tsStartMs;
    142185
    143186    struct
    144187    {
    145         /** Codec-specific data. */
    146         VIDEORECVIDEOCODEC  Codec;
    147188        /** Minimal delay (in ms) between two video frames.
    148189         *  This value is based on the configured FPS rate. */
    149190        uint32_t            uDelayMs;
    150         /** Target X resolution (in pixels). */
    151         uint32_t            uWidth;
    152         /** Target Y resolution (in pixels). */
    153         uint32_t            uHeight;
    154191        /** Time stamp (in ms) of the last video frame we encoded. */
    155192        uint64_t            uLastTimeStampMs;
    156193        /** Number of failed attempts to encode the current video frame in a row. */
    157194        uint16_t            cFailedEncodingFrames;
     195        VIDEORECVIDEOCODEC  Codec;
    158196    } Video;
    159197
     198    settings::CaptureScreenSettings Settings;
    160199    /** Common set of video recording (data) blocks, needed for
    161200     *  multiplexing to all recording streams. */
    162     VideoRecBlockSet Blocks;
    163 } VIDEORECSTREAM, *PVIDEORECSTREAM;
     201    CaptureBlockSet                Blocks;
     202};
    164203
    165204/** Vector of video recording streams. */
    166 typedef std::vector <PVIDEORECSTREAM> VideoRecStreams;
    167 
    168 int VideoRecStreamClose(PVIDEORECSTREAM pStream);
    169 int VideoRecStreamOpen(PVIDEORECSTREAM pStream, PVIDEORECCFG pCfg);
    170 int VideoRecStreamProcess(PVIDEORECSTREAM pStream);
    171 int VideoRecStreamInit(PVIDEORECSTREAM pStream, PVIDEORECCONTEXT pCtx, uint32_t uScreen);
    172 int VideoRecStreamUninit(PVIDEORECSTREAM pStream);
    173 int VideoRecStreamUnitVideo(PVIDEORECSTREAM pStream);
    174 int VideoRecStreamInitVideo(PVIDEORECSTREAM pStream, PVIDEORECCFG pCfg);
    175 #ifdef VBOX_WITH_LIBVPX
    176 int VideoRecStreamInitVideoVPX(PVIDEORECSTREAM pStream, PVIDEORECCFG pCfg);
    177 int VideoRecStreamUninitVideoVPX(PVIDEORECSTREAM pStream);
    178 int VideoRecStreamWriteVideoVPX(PVIDEORECSTREAM pStream, uint64_t uTimeStampMs, PVIDEORECVIDEOFRAME pFrame);
    179 #endif
    180 void VideoRecStreamLock(PVIDEORECSTREAM pStream);
    181 void VideoRecStreamUnlock(PVIDEORECSTREAM pStream);
     205typedef std::vector <CaptureStream *> VideoRecStreams;
    182206
    183207#endif /* ____H_VIDEOREC_STREAM */
Note: See TracChangeset for help on using the changeset viewer.

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