summaryrefslogtreecommitdiff
path: root/include/spice-streaming-agent/frame-capture.hpp
blob: f226e9922d9651e3951a4c852b276c8498b2828f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* Common interface for all streaming / capture cards
 * used by SPICE streaming-agent.
 *
 * \copyright
 * Copyright 2016-2017 Red Hat Inc. All rights reserved.
 */
#ifndef SPICE_STREAMING_AGENT_FRAME_CAPTURE_HPP
#define SPICE_STREAMING_AGENT_FRAME_CAPTURE_HPP
#include <cstdio>

#include <spice/enums.h>

namespace SpiceStreamingAgent {

struct FrameSize
{
    unsigned width;
    unsigned height;
};

struct FrameInfo
{
    FrameSize size;
    /*! Memory buffer, valid till next frame is read */
    const void *buffer;
    size_t buffer_size;
    /*! Start of a new stream */
    bool stream_start;
};

/*!
 * Pure base class implementing the frame capture
 */
class FrameCapture
{
public:
    virtual ~FrameCapture()=default;

    /*! Grab a frame
     * This function will wait for next frame.
     * Capture is started if needed.
     */
    virtual FrameInfo CaptureFrame()=0;

    /*! Reset capturing
     * This will reset to beginning state
     */
    virtual void Reset()=0;

    /*!
     * Get video codec used to encode last frame
     */
    virtual SpiceVideoCodecType VideoCodecType() const=0;
protected:
    FrameCapture()=default;
    FrameCapture(const FrameCapture&)=delete;
    void operator=(const FrameCapture&)=delete;
};

}

#endif // SPICE_STREAMING_AGENT_FRAME_CAPTURE_HPP