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; }
NTSTATUS CEncoderPin:: 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; UNREFERENCED_PARAMETER(Irp); CEncoderPin *EncPin = new (NonPagedPool, MS_SAMPLE_ANALOG_POOL_TAG) CEncoderPin (Pin); if (!EncPin) { // // 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> (EncPin), reinterpret_cast <PFNKSFREE> (CEncoderPin::Cleanup) ); if (!NT_SUCCESS (Status)) { delete EncPin; } else { Pin -> Context = reinterpret_cast <PVOID> (EncPin); } } // // 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. // PBDA_TRANSPORT_INFO TransportInfo = NULL; if (NT_SUCCESS (Status)) { TransportInfo = EncPin -> EncoderBdaTransportInfo (); if (!TransportInfo) { 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, MS_SAMPLE_ANALOG_POOL_TAG); if (NT_SUCCESS (Status)) { Status = KsEdit ( Pin, &(Pin -> Descriptor -> AllocatorFraming), MS_SAMPLE_ANALOG_POOL_TAG ); } // // If the edits proceeded without running out of memory, adjust // the framing based on the video info header. // 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 = 8; // // 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 = TransportInfo -> ulcbPhyiscalFrame; Framing -> FramingItem [0].PhysicalRange.Stepping = Framing -> FramingItem [0].FramingRange.Range.Stepping = 0; } } return Status; }