Пример #1
0
NTSTATUS CaptureFilterVideoInPinProcess ( IN PKSPIN pKSPin )
{
    PKSSTREAM_POINTER pStreamPointer = NULL;
    NTSTATUS          ntStatus       = STATUS_UNSUCCESSFUL;
    DbgPrint("CaptureFilterVideoInPinProcess");

    //parameters valid?
    if( !pKSPin )
    {
        DbgPrint("Error: CaptureFilterVideoInPinProcess: Invalid argument");
        return STATUS_UNSUCCESSFUL;
    }

    //get next available system buffer
    pStreamPointer = KsPinGetLeadingEdgeStreamPointer(
                                           pKSPin,
                                           KSSTREAM_POINTER_STATE_LOCKED);
    if( !pStreamPointer )
    {
        DbgPrint("Error: CaptureFilterVideoInPinProcess: Streampointer invalid");
        return STATUS_UNSUCCESSFUL;
    }

     if( !(pStreamPointer->StreamHeader) )
    {
        DbgPrint(
            "Error: AnlgVideoInPinProcess: Streampointer header invalid");
        if(KsStreamPointerAdvance(pStreamPointer) != STATUS_SUCCESS)
        {
            DbgPrint(
                "Warning: AnlgVideoInPinProcess:\
				Streampointer advacement failed");
        }
Пример #2
0
NTSTATUS CStillPin::Process ()

/*++

Routine Description:

    The process dispatch for the pin bridges to this location.
    We handle setting up scatter gather mappings, etc...

Arguments:

    None

Return Value:

    Success / Failure

--*/

{
    PAGED_CODE();

    NTSTATUS Status = STATUS_SUCCESS;
    PKSSTREAM_POINTER Leading=NULL;

    SnPrint(DEBUGLVL_VERBOSE, ("Enter CStillPin::Process\n"));
    ASSERT(m_Pin);

    if (!m_Device)
    {
        DBGU_ERROR("DeviceState is not KSSTATE_RUN or m_Device of CStillPin is NULL!\n");
        return STATUS_UNSUCCESSFUL;
    }

    if (m_Pin->DeviceState != KSSTATE_RUN)
    {
        DBGU_WARNING("Stream State is not KSSTATE_RUN ..\n");
        return STATUS_UNSUCCESSFUL;
    }

    KsPinAcquireProcessingMutex(m_Pin);

    Leading = KsPinGetLeadingEdgeStreamPointer (
                  m_Pin,
                  KSSTREAM_POINTER_STATE_LOCKED
              );

    //
    // Find stream pointer that has Data buffer
    //
    while (NT_SUCCESS (Status) && Leading)
    {
        //
        // If no data is present in the Leading edge stream pointer, just
        // move on to the next frame
        //
        if ( NULL == Leading -> StreamHeader -> Data ) {
            Status = KsStreamPointerAdvance(Leading);
            continue;
        }

        break;
    }

    if (Leading && m_VideoInfoHeader)
    {
        //
        // fill Stream header
        //
        Leading->StreamHeader->DataUsed = 0;
        DBGU_TRACE("buffer Remaining = %d\n",Leading->OffsetOut.Remaining);

        if (Leading->OffsetOut.Remaining >= m_VideoInfoHeader->bmiHeader.biSizeImage)
        {
            Leading -> StreamHeader -> Duration =
                m_VideoInfoHeader -> AvgTimePerFrame;
            Leading -> StreamHeader -> PresentationTime.Numerator =
                Leading -> StreamHeader -> PresentationTime.Denominator = 1;

            Status = m_Device->FrameReadingProcess(
                         m_Pin,
                         Leading->StreamHeader
                     );

            /*// shawn 2011/07/27 for testing +++++
            //
            // Write image data to file.
            //
            IO_STATUS_BLOCK		ioStatusBlock;
            HANDLE				fh;
            LARGE_INTEGER		ByteOffset;
            UNICODE_STRING		uSnapShotFileName;
            OBJECT_ATTRIBUTES	oa;
            UCHAR				p[SNAPSHOT_FILE_HDR_SIZE];
            WCHAR				*wssfn=NULL;

            wssfn = new (NonPagedPool) WCHAR[MAX_PATH];

            //if(!wssfn)
            //	break;

            DBGU_TRACE("Still Process: Start Save Image file! \n");

            swprintf(wssfn, L"\\DosDevices\\C:\\Still_%ws",m_Device->pdx->pVideoDevice->m_SnapShotFileName);
            RtlInitUnicodeString(&uSnapShotFileName, wssfn);
            InitializeObjectAttributes(&oa,&uSnapShotFileName, OBJ_CASE_INSENSITIVE,NULL,NULL);

            if (NT_SUCCESS(ZwCreateFile(	&fh,
            							GENERIC_WRITE | SYNCHRONIZE,
            							&oa,
            							&ioStatusBlock,
            							0,
            							FILE_ATTRIBUTE_NORMAL,
            							FILE_SHARE_WRITE,
            							FILE_OVERWRITE_IF,
            							FILE_SYNCHRONOUS_IO_NONALERT,
            							NULL,
            							0)))
            {
            	ByteOffset.QuadPart = 0;

            	ZwWriteFile(fh,
            				NULL,
            				NULL,
            				NULL,
            				&ioStatusBlock,
            				Leading->StreamHeader->Data,
            				Leading->StreamHeader->DataUsed,
            				&ByteOffset,
            				NULL);

            	ZwClose(fh);
            }//zwCreateFile is ok

            if (wssfn)
            	delete wssfn;
            // shawn 2011/07/27 for testing -----*/

            // shawn 2011/07/28 remove for fixing method 2 MJPEG snapshot issue
            /*if (m_Clock) {
            	LONGLONG ClockTime = m_Clock -> GetTime ();
            	Leading -> StreamHeader -> PresentationTime.Time = ClockTime;
            	Leading -> StreamHeader -> OptionsFlags |=
            		KSSTREAM_HEADER_OPTIONSF_FLUSHONPAUSE |
            		KSSTREAM_HEADER_OPTIONSF_TIMEVALID |
            		KSSTREAM_HEADER_OPTIONSF_DURATIONVALID;
            } else*/ {
                //
                // If there is no clock, don't time stamp the packets.
                //
                Leading -> StreamHeader -> PresentationTime.Time = 0;
                Leading -> StreamHeader -> OptionsFlags |= KSSTREAM_HEADER_OPTIONSF_FLUSHONPAUSE;
            }

            //
            // Advances StreamPointer the specified number of bytes into the stream
            // and unlocks it.
            //
            KsStreamPointerAdvanceOffsetsAndUnlock(
                Leading,
                0,
                /*m_VideoInfoHeader->bmiHeader.biSizeImage*/Leading->StreamHeader->DataUsed,
                TRUE
            );
        }
        else
        {
            KeDelay(33);
            KsStreamPointerUnlock(Leading, FALSE);
            Status = STATUS_BUFFER_OVERFLOW;
        }
    }
    //
    // Turn Off the PinGate to avoid processing
    //
    PKSGATE pGate = KsPinGetAndGate(m_Pin);
    if (pGate)
    {
        KsGateTurnInputOff(pGate);
    }

    KsPinReleaseProcessingMutex(m_Pin);

    SnPrint(DEBUGLVL_VERBOSE, ("Leave CStillPin::Process (0x%X)\n",Status));
    return Status;
}