summaryrefslogtreecommitdiff
path: root/avstream/avscamera/sys/imagehwsim.h
blob: 4eaa407dc445e57ed63c23fb26fe9946f737fdd0 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/**************************************************************************

    A/V Stream Camera Sample

    Copyright (c) 2001, Microsoft Corporation.

    File:

        ImageHwSim.h

    Abstract:

        This file contains the definition of the CImageHardwareSimulation class.

        This is a specialization of CHardwareSimulation that provides photo-
        specific metadata and implements specialized functionality for photo, 
        photo sequence and variable photo sequence.

    History:

        created 3/9/2001

**************************************************************************/

//  forward references
struct ISP_FRAME_SETTINGS;

class CImageHardwareSimulation
    : public CHardwareSimulation
{
private:
    LIST_ENTRY      m_BurstList;
    PWSTR           m_szwFramePath;
    BOOLEAN         m_bTriggered;
    BOOLEAN         m_bEndOfSequence;
    BOOLEAN         m_bFlashed;
    BOOLEAN         m_bPastBufferTrigger;
    PIN_MODE        m_PinMode;
    ULONG           m_PastBufferCount;
    ULONGLONG       m_TriggerTime;
    PIKSREFERENCECLOCK m_Clock;
    ULONGLONG       m_FlashStatus;

    //  Settings for VPS simulation.
    ULONG               m_PfsLoopLimit;
    ULONG               m_PfsFrameLimit;
    ISP_FRAME_SETTINGS *m_pIspSettings;          //
    ULONG               m_PfsLoopNumber;           // Number of loops we've done.
    ULONG               m_PfsFrameNumber;
    ULONGLONG           m_GlobalFrameNumber;    //  Informational only.

    //  Copy a synthesized framebuffer.
    virtual
    NTSTATUS
    FillScatterGatherBuffers();

    //  Find and complete any history frames.
    NTSTATUS
    CompletePastBuffers();

    //  Put an item onto the history list.
    void
    PushCloneList(_Inout_  PSCATTER_GATHER_ENTRY SGEntry);

    //  Complete the history list.
    NTSTATUS
    CompleteCloneList();

    //  Add Photo-specific metadata.
    void
    EmitMetadata(
        _Inout_ PKSSTREAM_HEADER   pStreamHeader
    );

    //  Does the current frame need a photo confirmation?
    BOOLEAN
    IsPhotoConfirmationNeeded();

    //  Helper function that gets a buffer full of image metadata.
    METADATA_IMAGEAGGREGATION
    GetMetadata();

public:
    PKSSTREAM_POINTER m_pClone;
    PHOTOCONFIRMATION_INFO  m_PhotoConfirmationInfo;

    //  Constructor
    CImageHardwareSimulation (
        _Inout_ CSensor *Sensor,
        _In_    LONG    PinID
    );

    //  Destructor
    virtual
    ~CImageHardwareSimulation();

    //  Periodic interrupt handling
    virtual
    void
    FakeHardware();

    //  Start streaming.
    virtual
    NTSTATUS
    Start(
        _In_    CSynthesizer *ImageSynth,
        _In_    ULONG Width,
        _In_    ULONG Height,
        _In_    ULONG ImageSize,
        _In_    PIN_MODE pinMode
    );

    //  Stop streaming.
    virtual
    NTSTATUS
    Stop();

    virtual
    NTSTATUS
    Reset();

    //  Take a picture or start a photo sequence.
    virtual
    NTSTATUS
    Trigger(
        _In_    LONG mode
    );

    LONG
    GetTriggerMode();

	//  Limit the rate of frames produced.
    virtual
    NTSTATUS
    SetPhotoFrameRate (
        _In_    ULONGLONG TimePerFrame
    );

    //  Get the rate of frames produced.
    virtual
    ULONGLONG
    GetPhotoFrameRate()
    {
        return m_TimePerFrame;
    }

    //  Set the master clock.
    NTSTATUS
    SetClock(
        _In_    PKSPIN pin
    );

    //  Identify exactly when the user pressed that button.
    void
    SetTriggerTime(
        _In_    ULONGLONG TriggerTime
    );

    //  Report the current trigger time.
    ULONGLONG
    GetTriggerTime()
    {
        return m_TriggerTime;
    }

    //  Normal vs. Photo sequence + number of history frames.
    NTSTATUS
    SetMode(
        _In_    ULONGLONG Flags,
        _In_    ULONG PastBuffers
    );

    NTSTATUS
    SetFlashStatus(
        _In_    ULONGLONG ulFlashStatus
    );

    //  Program the Per Frame Settings for simulation
    //  We do it before calling start so we can be ready
    //  to program our simulation's hardware.
    //  Note: We make a local copy.
    NTSTATUS
    SetPFS(
        _In_opt_    ISP_FRAME_SETTINGS  *pIspSettings,
        _In_        ULONG               FrameLimit,
        _In_        ULONG               LoopLimit
    );

    //  Advance our frame and loop pointers to the next PFS settings.
    bool
    AdvanceFrameCounter(void);

    //  Determine if we're at the EOS.
    bool
    IsPfsEOS(void);

    //  Determine if we're in a Variable Photo Sequence.
    BOOL
    IsPfsActive(void);

    //  Get the current frame settings.
    virtual
    ISP_FRAME_SETTINGS *
    GetIspSettings(void);
};