summaryrefslogtreecommitdiff
path: root/avstream/avscamera/sys/VideoCapture.cpp
blob: 92bf4b51537814b9938a663fa87e1a88fab89277 (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
/**************************************************************************

    A/V Stream Camera Sample

    Copyright (c) 2001, Microsoft Corporation.

    File:

        videocapture.cpp

    Abstract:

        Video Capture Pin implementation.  

        Handles construction and defines pin data ranges.

    History:

        created 3/8/2001

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

#include "Common.h"
#include "ntintsafe.h"

#ifdef ALLOC_PRAGMA
#pragma code_seg("PAGE")
#endif // ALLOC_PRAGMA


CVideoCapturePin::CVideoCapturePin(IN PKSPIN Pin) :
    CCapturePin (Pin)
{
    PAGED_CODE();

}


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

Routine Description:

    Create a new capture pin.  This is the creation dispatch for
    the video capture pin.

Arguments:

    Pin -
        The pin being created

    Irp -
        The creation Irp

Return Value:

    Success / Failure

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

NTSTATUS 
CVideoCapturePin::
DispatchCreate(
    IN PKSPIN Pin, 
    IN PIRP Irp
)
{
    PAGED_CODE();

    DBG_ENTER("(Pin=%d)", Pin->Id);

    NTSTATUS Status = STATUS_SUCCESS;

    CCaptureFilter* pFilter = reinterpret_cast <CCaptureFilter*>(KsPinGetParentFilter(Pin)->Context);
    CVideoCapturePin *CapPin = new (NonPagedPoolNx) CVideoCapturePin (Pin);

    if( !CapPin )
    {
        // Fail if we couldn't create the pin.
        Status = STATUS_INSUFFICIENT_RESOURCES;
    }
    else
    {
        Status = 
            CapPin->Initialize();
    }

    if( NT_SUCCESS (Status) )
    {
        //
        // Adjust the stream header size.  The video packets have extended
        // header info (KS_FRAME_INFO).
        //
        pFilter->setPin(CapPin, Pin->Id);
    }
    else
    {
        //  Clean up.
        delete CapPin;
    }

    DBG_LEAVE("(Pin=%d)=0x%08X", Pin->Id, Status);
    return Status;
}

//
// CapturePinDispatch:
//
// This is the dispatch table for the capture pin.  It provides notifications
// about creation, closure, processing, data formats, etc...
//
DEFINE_CAMERA_KSPIN_DISPATCH( VideoCapturePinDispatch, CVideoCapturePin );

//
// CapturePinAllocatorFraming:
//
// This is the simple framing structure for the capture pin.  Note that this
// will be modified via KsEdit when the actual capture format is determined.
//
DECLARE_SIMPLE_FRAMING_EX(
    VideoCapturePinAllocatorFraming,
    STATICGUIDOF( KSMEMORY_TYPE_KERNEL_NONPAGED ),
    KSALLOCATOR_REQUIREMENTF_SYSTEM_MEMORY |
    KSALLOCATOR_REQUIREMENTF_PREFERENCES_ONLY,
    2,
    0,
    2 * PAGE_SIZE,
    2 * PAGE_SIZE
);