Exemple #1
0
NTSTATUS
CStillPin::
DispatchClose (
    IN PKSPIN Pin,
    IN PIRP Irp
)
{
    PAGED_CODE();

    NTSTATUS Status = STATUS_SUCCESS;
    DBGU_TRACE("Enter CStillPin::DispatchClose\n");

    PKSDEVICE pDevice = KsPinGetDevice (Pin);
    CCaptureDevice *pCapDevice = reinterpret_cast <CCaptureDevice *> (pDevice -> Context);

    if (!pCapDevice)
        Status = STATUS_UNSUCCESSFUL;

    if (NT_SUCCESS (Status))
    {
        Status = pCapDevice->StreamOpen(FALSE,Pin);
    }

    return Status;
}
Exemple #2
0
CStillPin::CStillPin (
    IN PKSPIN Pin
) :
    m_Pin (Pin),
//    ,m_SurfaceType (KS_CAPTURE_ALLOC_SYSTEM)
    m_PresentationTime (0)

    /*++

    Routine Description:

        Construct a new capture pin.

    Arguments:

        Pin -
            The AVStream pin object corresponding to the capture pin

    Return Value:

        None

    --*/

{
    PAGED_CODE();

    PKSDEVICE Device = KsPinGetDevice (Pin);

    //
    // Set up our device pointer.  This gives us access to "hardware I/O"
    // during the capture routines.
    //
    m_Device = reinterpret_cast <CCaptureDevice *> (Device -> Context);
}
Exemple #3
0
CEncoderPin::
CEncoderPin (
    IN PKSPIN Pin
) :
    m_Pin (Pin)

    /*++

    Routine Description:

        Construct a new capture pin.

    Arguments:

        Pin -
            The AVStream pin object corresponding to the capture pin

    Return Value:

        None

    --*/

{

    PAGED_CODE();

    PKSDEVICE Device = KsPinGetDevice (Pin);

    //
    // Set up our device pointer.  This gives us access to "hardware I/O"
    // during the capture routines.
    //
    m_Device = reinterpret_cast <CEncoderDevice *> (Device -> Context);

}
Exemple #4
0
NTSTATUS
CStillPin::
DispatchCreate (
    IN PKSPIN Pin,
    IN PIRP Irp
)

/*++

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

--*/

{
    PAGED_CODE();

    NTSTATUS Status = STATUS_SUCCESS;
    DBGU_TRACE("Enter CStillPin::DispatchCreate\n");

    CStillPin *StiPin = new (NonPagedPool) CStillPin (Pin);

    if (!StiPin) {
        //
        // Return failure if we couldn't create the pin.
        //
        Status = STATUS_INSUFFICIENT_RESOURCES;
    } else {
        //
        // Add the item to the object bag if we we were successful.
        // Whenever the pin closes, the bag is cleaned up and we will be
        // freed.
        //
        Status = KsAddItemToObjectBag (
                     Pin -> Bag,
                     reinterpret_cast <PVOID> (StiPin),
                     reinterpret_cast <PFNKSFREE> (CStillPin::Cleanup)
                 );

        if (!NT_SUCCESS (Status)) {
            delete StiPin;
        } else {
            Pin -> Context = reinterpret_cast <PVOID> (StiPin);
        }
    }

    //
    // If we succeeded so far, stash the video info header away and change
    // our allocator framing to reflect the fact that only now do we know
    // the framing requirements based on the connection format.
    //
    PKS_VIDEOINFOHEADER VideoInfoHeader = NULL;		// for Vista change to KS_VIDEOINFOHEADER2

    if (NT_SUCCESS (Status)) {

        VideoInfoHeader = StiPin -> CaptureVideoInfoHeader ();

        if (!VideoInfoHeader) {
            Status = STATUS_INSUFFICIENT_RESOURCES;
        }
    }

    if (NT_SUCCESS (Status)) {

        //
        // We need to edit the descriptor to ensure we don't mess up any other
        // pins using the descriptor or touch read-only memory.
        //
        Status = KsEdit (
                     Pin,
                     &Pin -> Descriptor,
                     AVSHWS_POOLTAG);

        if (NT_SUCCESS (Status)) {
            do {
                PKSFILTER Filter = (PKSFILTER)KsGetParent(Pin);

                if (!Filter) {
                    Status = STATUS_UNSUCCESSFUL;
                    break;
                }

                CCaptureFilter* ParentFilter = static_cast<CCaptureFilter*>(Filter -> Context);

                if (!ParentFilter) {
                    Status = STATUS_UNSUCCESSFUL;
                    break;
                }
            } while (FALSE);
        }

        //
        // If the edits proceeded without running out of memory, adjust
        // the framing based on the video info header.
        //
        Status = KsEdit (
                     Pin,
                     &Pin -> Descriptor -> AllocatorFraming,
                     AVSHWS_POOLTAG);

        if (NT_SUCCESS (Status)) {

            //
            // We've KsEdit'ed this...  I'm safe to cast away constness as
            // long as the edit succeeded.
            //
            PKSALLOCATOR_FRAMING_EX Framing =
                const_cast <PKSALLOCATOR_FRAMING_EX> (
                    Pin -> Descriptor -> AllocatorFraming
                );

            Framing -> FramingItem [0].Frames = 2;

            //
            // The physical and optimal ranges must be biSizeImage.  We only
            // support one frame size, precisely the size of each capture
            // image.
            //
            Framing -> FramingItem [0].PhysicalRange.MinFrameSize =
                Framing -> FramingItem [0].PhysicalRange.MaxFrameSize =
                    Framing -> FramingItem [0].FramingRange.Range.MinFrameSize =
                        Framing -> FramingItem [0].FramingRange.Range.MaxFrameSize =
                            VideoInfoHeader -> bmiHeader.biSizeImage;

            Framing -> FramingItem [0].PhysicalRange.Stepping =
                Framing -> FramingItem [0].FramingRange.Range.Stepping =
                    0;
        }
    }

    PKSDEVICE pDevice = KsPinGetDevice (Pin);
    CCaptureDevice *pCapDevice = reinterpret_cast <CCaptureDevice *> (pDevice -> Context);

    if (!pCapDevice)
        Status = STATUS_UNSUCCESSFUL;

    if (NT_SUCCESS (Status))
    {
        Status = pCapDevice->StreamOpen(TRUE,Pin);
    }

    DBGU_TRACE("Exit CStillPin::DispatchCreate Status= %X\n",Status);
    return Status;
}