summaryrefslogtreecommitdiff
path: root/avstream/avshws
diff options
context:
space:
mode:
authorsaredd <[email protected]>2018-01-19 17:19:00 -0800
committerWei Mao <[email protected]>2018-01-19 17:19:00 -0800
commit6e7c8cb437135e55917c34cfebe1be944bbf6d3f (patch)
treef7570fe170194facd45e4f9f887ff56dc683a31c /avstream/avshws
parentdd7e6f697ed67e94dc45cd33078b1dbcb643f439 (diff)
Updating Camera WDK Samples to RS3 version (#193)
Diffstat (limited to 'avstream/avshws')
-rw-r--r--avstream/avshws/README.md10
-rw-r--r--avstream/avshws/avshws.h148
-rw-r--r--avstream/avshws/avshws.inf4
-rw-r--r--avstream/avshws/device.cpp343
4 files changed, 325 insertions, 180 deletions
diff --git a/avstream/avshws/README.md b/avstream/avshws/README.md
index 19019304..9474ae60 100644
--- a/avstream/avshws/README.md
+++ b/avstream/avshws/README.md
@@ -17,7 +17,7 @@ This sample features enhanced parameter validation and overflow detection.
Provision a target computer
---------------------------
-After you've cloned the sample repo to your host computer, run Visual Studio, and from the **File** menu, select **Open**, then **Project/Solution...**, navigate to the Avshws sample directory, and select **avshws.sln**.
+After you've installed the sample on your host computer, run Visual Studio, and from the **File** menu, select **Open**, then **Project/Solution...**, navigate to the directory where you've copied the Avshws sample, then to the C++ folder, and select **avshws.vcxproj** (the VC++ Project).
In the **Solution Explorer** pane in Visual Studio, at the top is **Solution 'avshws'**. Right-click this and select **Configuration Manager**. Follow the instructions in [Building a Driver with the WDK](http://msdn.microsoft.com/en-us/library/windows/hardware/ff554644) to set the platform, operating system, and debug configuration you want to use, and to build the sample. This sample project will automatically sign the driver package.
@@ -26,7 +26,7 @@ Provision your target computer using instructions in, for example, [Preparing a
Deploy the driver to the target computer
----------------------------------------
-Now you can deploy the Avshws driver that you've just built to the target computer, using guidance in [Deploying a Driver to a Test Computer](https://docs.microsoft.com/windows-hardware/drivers/develop/deploying-a-driver-to-a-test-computer). Specifically, in the Visual Studio Solution Explorer, right click the Avshws project and select **Properties**. Under Configuration Properties, click **Driver Install** and then **Deployment**. Enter the **Target Device Name** and the host computer automatically provisions the target computer and sets up debugger options.
+Now you can deploy the Avshws driver that you've just built to the target computer, using guidance in [Deploying a Driver to a Test Computer](http://msdn.microsoft.com/en-us/library/windows/hardware/hh454834). Specifically, find the package file under the **Package** folder in the Avshws solution. Right-click **package** and select **Properties**. Under Configuration Properties, click **Driver install** and then **Deployment**. Here you must click the check box for **Enable deployment**, and then click the button to the right of **\<Configure Computer...\>**. In the next dialog you enter the **Target Computer Name** and can let the host computer automatically provision the target computer and set up debugger options.
Finally, in Visual Studio, from the **Build** menu select **Deploy Solution** to deploy the sample to the target computer. On the target computer, you can see the deployed package in the **%Systemdrive%\\drivertest\\drivers** folder.
@@ -35,7 +35,7 @@ Install the driver
On the target computer, open Device Manager, and follow these steps:
-1. In the **Action** menu, select the top node and click **Add Legacy Hardware**. Click **Next** and then **Next** again. You might need to select **Have disk** and search for the driver in the target driver folder that was set up when the test computer was provisioned.
+1. In the **Action** menu, click **Add Legacy Hardware**, and the **Add Hardware Wizard** appears. Click **Next** and then **Next** again.
2. In the **Add Hardware** window, select **Show All Devices**.
3. In the **Manufacturer** list in the left pane, click **Microsoft**.
4. You should see the **AVStream Simulated Hardware Sample** in the **Model** pane on the right. Click this and then click **Next**.
@@ -64,8 +64,8 @@ Run the sample
Follow these steps to see how the sample driver functions:
1. After installation has completed, access the driver through the Graphedt tool. Graphedt.exe is available in the *tools* directory of the WDK.
-2. Before running GraphEdt, use the regsvr32 utility to register the proppage.dll DLL and to enable GraphEdit to display property pages for some of the built-in Microsoft DirectShow filters. Open an elevated command window with Administrator privileges, and navigate to the WDK or SDK *tools* directory that contains proppage.dll.
-3. On the command line, type `regsvr32 "c:\Program Files (x86)\Windows Kits\10\Tools\x64\proppage.dll"`. If the registration succeeds, you'll get a message, "DllRegisterServer in proppage.dll succeeded." Click OK.
+2. Before running GraphEdit, use the regsvr32 utility to register the proppage.dll DLL and to enable GraphEdit to display property pages for some of the built-in Microsoft DirectShow filters. Open an elevated command window with Administrator privileges, and navigate to the WDK or SDK *tools* directory that contains proppage.dll.
+3. On the command line, type regsvr32 proppage.dll. If the registration succeeds, you'll get a message, "DllRegisterServer in proppage.dll succeeded." Click OK.
4. In the Graphedt tool, click the **Graph** menu and click **Insert Filters**. The sample appears under "WDM Streaming Capture Devices" as "avshws Source."
5. Click **Insert Filter**. The sample appears in the graph as a single filter labeled, "avshws Source." There is one output pin, which is the video capture pin. This pin emits video in YUY2 format.
6. Attach this filter to either a DirectShow Video Renderer or to the VMR default video renderer. Then click **Play**.
diff --git a/avstream/avshws/avshws.h b/avstream/avshws/avshws.h
index a6b3d8bc..3b8cc913 100644
--- a/avstream/avshws/avshws.h
+++ b/avstream/avshws/avshws.h
@@ -10,7 +10,7 @@
Abstract:
- AVStream Simulated Hardware Sample header file. This is the
+ AVStream Simulated Hardware Sample header file. This is the
main header.
History:
@@ -44,14 +44,6 @@ extern "C" {
#include <ks.h>
#include <ksmedia.h>
-// Note: Since VS2015 Update 2 overloaded operator new and operator delete may not
-// be declared inline (Level 1 (/W1) on-by-default, warning C4595).
-// See https://msdn.microsoft.com/en-us/library/mt656697.aspx
-//
-// To mitigate this issue, add "#define _NEW_DELETE_OPERATORS_" before "#include <kcom.h>"
-// and implement non-inline operator new and operator delete locally.
-#define _NEW_DELETE_OPERATORS_
-#include <kcom.h>
/*************************************************
@@ -84,7 +76,7 @@ const DebugLevel = DEBUGLVL_TERSE;
#define ABS(x) ((x) < 0 ? (-(x)) : (x))
-#ifndef mmioFOURCC
+#ifndef mmioFOURCC
#define mmioFOURCC( ch0, ch1, ch2, ch3 ) \
( (DWORD)(BYTE)(ch0) | ( (DWORD)(BYTE)(ch1) << 8 ) | \
( (DWORD)(BYTE)(ch2) << 16 ) | ( (DWORD)(BYTE)(ch3) << 24 ) )
@@ -145,12 +137,12 @@ CaptureFilterCategories [CAPTURE_FILTER_CATEGORIES_COUNT];
//
// capture.cpp externs:
//
-extern
+extern
const
KSALLOCATOR_FRAMING_EX
CapturePinAllocatorFraming;
-extern
+extern
const
KSPIN_DISPATCH
CapturePinDispatch;
@@ -218,38 +210,148 @@ public:
};
+
/*************************************************
Global Functions
*************************************************/
+#ifndef _NEW_DELETE_OPERATORS_
+#define _NEW_DELETE_OPERATORS_
-void __cdecl operator delete[]
+/*************************************************
+
+ Add definitions that are missing for C++14.
+
+*************************************************/
+
+PVOID operator new
+(
+ size_t iSize,
+ _When_((poolType & NonPagedPoolMustSucceed) != 0,
+ __drv_reportError("Must succeed pool allocations are forbidden. "
+ "Allocation failures cause a system crash"))
+ POOL_TYPE poolType
+);
+
+PVOID operator new
(
+ size_t iSize,
+ _When_((poolType & NonPagedPoolMustSucceed) != 0,
+ __drv_reportError("Must succeed pool allocations are forbidden. "
+ "Allocation failures cause a system crash"))
+ POOL_TYPE poolType,
+ ULONG tag
+);
+
+/*++
+
+Routine Description:
+
+ Array new() operator for creating objects with a specified allocation tag.
+
+Arguments:
+
+ iSize -
+ The size of the entire allocation.
+
+ poolType -
+ The type of allocation. Ex: PagedPool or NonPagedPoolNx
+
+ tag -
+ A 4-byte allocation identifier.
+
+Return Value:
+
+ None
+
+--*/
+PVOID
+operator new[](
+ size_t iSize,
+ _When_((poolType & NonPagedPoolMustSucceed) != 0,
+ __drv_reportError("Must succeed pool allocations are forbidden. "
+ "Allocation failures cause a system crash"))
+ POOL_TYPE poolType,
+ ULONG tag
+);
+
+/*++
+
+Routine Description:
+
+ Array delete() operator.
+
+Arguments:
+
+ pVoid -
+ The memory to free.
+
+Return Value:
+
+ None
+
+--*/
+void
+__cdecl
+operator delete[](
PVOID pVoid
);
+/*++
+
+Routine Description:
+
+ Sized delete() operator.
+
+Arguments:
+
+ pVoid -
+ The memory to free.
+
+ size -
+ The size of the memory to free.
+
+Return Value:
+
+ None
+
+--*/
void __cdecl operator delete
(
void *pVoid,
size_t /*size*/
);
+/*++
+
+Routine Description:
+
+ Sized delete[]() operator.
+
+Arguments:
+
+ pVoid -
+ The memory to free.
+
+ size -
+ The size of the memory to free.
+
+Return Value:
+
+ None
+
+--*/
void __cdecl operator delete[]
(
void *pVoid,
size_t /*size*/
);
-PVOID operator new
-(
- size_t iSize,
- _When_((poolType & NonPagedPoolMustSucceed) != 0,
- __drv_reportError("Must succeed pool allocations are forbidden. "
- "Allocation failures cause a system crash"))
- POOL_TYPE poolType,
- ULONG tag
-);
+#endif // _NEW_DELETE_OPERATORS_
+
+
+
/*************************************************
@@ -263,4 +365,4 @@ PVOID operator new
#include "filter.h"
#include "capture.h"
#include <uuids.h>
-#endif //_avshws_h_
+#endif //_avshws_h_ \ No newline at end of file
diff --git a/avstream/avshws/avshws.inf b/avstream/avshws/avshws.inf
index 8360d50f..9bbbc42a 100644
--- a/avstream/avshws/avshws.inf
+++ b/avstream/avshws/avshws.inf
@@ -21,8 +21,8 @@
[Version]
signature="$WINDOWS NT$"
-Class=Media
-ClassGUID={4d36e96c-e325-11ce-bfc1-08002be10318}
+Class=Camera
+ClassGuid={ca3e7ab9-b4c3-4ae6-8251-579ef933890f}
Provider=%ProviderName%
Catalogfile=avshws.cat
DriverVer=08/31/2006,6.0.5600.0
diff --git a/avstream/avshws/device.cpp b/avstream/avshws/device.cpp
index 2f54aca4..93376be4 100644
--- a/avstream/avshws/device.cpp
+++ b/avstream/avshws/device.cpp
@@ -21,6 +21,164 @@
**************************************************************************/
#include "avshws.h"
+
+PVOID operator new
+(
+ size_t iSize,
+ _When_((poolType & NonPagedPoolMustSucceed) != 0,
+ __drv_reportError("Must succeed pool allocations are forbidden. "
+ "Allocation failures cause a system crash"))
+ POOL_TYPE poolType
+)
+{
+ PVOID result = ExAllocatePoolWithTag(poolType,iSize,'wNCK');
+
+ if (result) {
+ RtlZeroMemory(result,iSize);
+ }
+
+ return result;
+}
+
+PVOID operator new
+(
+ size_t iSize,
+ _When_((poolType & NonPagedPoolMustSucceed) != 0,
+ __drv_reportError("Must succeed pool allocations are forbidden. "
+ "Allocation failures cause a system crash"))
+ POOL_TYPE poolType,
+ ULONG tag
+)
+{
+ PVOID result = ExAllocatePoolWithTag(poolType,iSize,tag);
+
+ if (result) {
+ RtlZeroMemory(result,iSize);
+ }
+
+ return result;
+}
+
+PVOID
+operator new[](
+ size_t iSize,
+ _When_((poolType & NonPagedPoolMustSucceed) != 0,
+ __drv_reportError("Must succeed pool allocations are forbidden. "
+ "Allocation failures cause a system crash"))
+ POOL_TYPE poolType,
+ ULONG tag
+)
+{
+ PVOID result = ExAllocatePoolWithTag(poolType, iSize, tag);
+
+ if (result)
+ {
+ RtlZeroMemory(result, iSize);
+ }
+
+ return result;
+}
+
+/*++
+
+Routine Description:
+
+ Array delete() operator.
+
+Arguments:
+
+ pVoid -
+ The memory to free.
+
+Return Value:
+
+ None
+
+--*/
+void
+__cdecl
+operator delete[](
+ PVOID pVoid
+)
+{
+ if (pVoid)
+ {
+ ExFreePool(pVoid);
+ }
+}
+
+/*++
+
+Routine Description:
+
+ Sized delete() operator.
+
+Arguments:
+
+ pVoid -
+ The memory to free.
+
+ size -
+ The size of the memory to free.
+
+Return Value:
+
+ None
+
+--*/
+void __cdecl operator delete
+(
+ void *pVoid,
+ size_t /*size*/
+)
+{
+ if (pVoid)
+ {
+ ExFreePool(pVoid);
+ }
+}
+
+/*++
+
+Routine Description:
+
+ Sized delete[]() operator.
+
+Arguments:
+
+ pVoid -
+ The memory to free.
+
+ size -
+ The size of the memory to free.
+
+Return Value:
+
+ None
+
+--*/
+void __cdecl operator delete[]
+(
+ void *pVoid,
+ size_t /*size*/
+)
+{
+ if (pVoid)
+ {
+ ExFreePool(pVoid);
+ }
+}
+
+void __cdecl operator delete
+(
+ PVOID pVoid
+ )
+{
+ if (pVoid) {
+ ExFreePool(pVoid);
+ }
+}
+
/**************************************************************************
PAGEABLE CODE
@@ -161,7 +319,7 @@ Return Value:
//
// By PnP, it's possible to receive multiple starts without an intervening
// stop (to reevaluate resources, for example). Thus, we only perform
- // creations of the simulation on the initial start and ignore any
+ // creations of the simulation on the initial start and ignore any
// subsequent start. Hardware drivers with resources should evaluate
// resources and make changes on 2nd start.
//
@@ -173,7 +331,7 @@ Return Value:
// If we couldn't create the hardware simulation, fail.
//
Status = STATUS_INSUFFICIENT_RESOURCES;
-
+
} else {
Status = KsAddItemToObjectBag (
m_Device -> Bag,
@@ -197,15 +355,15 @@ Return Value:
//
// Set up DMA...
//
- // Ordinarilly, we'd be using InterfaceBuffer or
- // InterfaceTypeUndefined if !NT_SUCCESS (IfStatus) as the
- // InterfaceType below; however, for the purposes of this sample,
+ // Ordinarilly, we'd be using InterfaceBuffer or
+ // InterfaceTypeUndefined if !NT_SUCCESS (IfStatus) as the
+ // InterfaceType below; however, for the purposes of this sample,
// we lie and say we're on the PCI Bus. Otherwise, we're using map
// registers on x86 32 bit physical to 32 bit logical and this isn't
// what I want to show in this sample.
//
//
- // NTSTATUS IfStatus =
+ // NTSTATUS IfStatus =
IoGetDeviceProperty (
m_Device -> PhysicalDeviceObject,
@@ -216,7 +374,7 @@ Return Value:
);
//
- // Initialize our fake device description. We claim to be a
+ // Initialize our fake device description. We claim to be a
// bus-mastering 32-bit scatter/gather capable piece of hardware.
//
DeviceDescription.Version = DEVICE_DESCRIPTION_VERSION;
@@ -229,7 +387,7 @@ Return Value:
DeviceDescription.Dma32BitAddresses = TRUE;
DeviceDescription.AutoInitialize = FALSE;
DeviceDescription.MaximumLength = (ULONG) -1;
-
+
//
// Get a DMA adapter object from the system.
//
@@ -238,21 +396,21 @@ Return Value:
&DeviceDescription,
&m_NumberOfMapRegisters
);
-
+
if (!m_DmaAdapterObject) {
Status = STATUS_UNSUCCESSFUL;
}
-
+
}
-
+
if (NT_SUCCESS (Status)) {
//
- // Initialize our DMA adapter object with AVStream. This is
+ // Initialize our DMA adapter object with AVStream. This is
// **ONLY** necessary **IF** you are doing DMA directly into
// capture buffers as this sample does. For this,
// KSPIN_FLAG_GENERATE_MAPPINGS must be specified on a queue.
//
-
+
//
// The (1 << 20) below is the maximum size of a single s/g mapping
// that this hardware can handle. Note that I have pulled this
@@ -264,11 +422,11 @@ Return Value:
(1 << 20),
sizeof (KSMAPPING)
);
-
+
}
#endif
}
-
+
return Status;
}
@@ -306,7 +464,7 @@ Return Value:
//
// Return the DMA adapter back to the system.
//
- m_DmaAdapterObject -> DmaOperations ->
+ m_DmaAdapterObject -> DmaOperations ->
PutDmaAdapter (m_DmaAdapterObject);
m_DmaAdapterObject = NULL;
@@ -328,7 +486,7 @@ AcquireHardwareResources (
Routine Description:
- Acquire hardware resources for the capture hardware. If the
+ Acquire hardware resources for the capture hardware. If the
resources are already acquired, this will return an error.
The hardware configuration must be passed as a VideoInfoHeader.
@@ -376,44 +534,44 @@ Return Value:
delete m_ImageSynth;
m_ImageSynth = NULL;
}
-
+
//
// Create the necessary type of image synthesizer.
//
if (m_VideoInfoHeader -> bmiHeader.biBitCount == 24 &&
m_VideoInfoHeader -> bmiHeader.biCompression == KS_BI_RGB) {
-
+
//
// If we're RGB24, create a new RGB24 synth. RGB24 surfaces
// can be in either orientation. The origin is lower left if
// height < 0. Otherwise, it's upper left.
//
- m_ImageSynth = new (NonPagedPoolNx, 'RysI')
+ m_ImageSynth = new (NonPagedPoolNx, 'RysI')
CRGB24Synthesizer (
m_VideoInfoHeader -> bmiHeader.biHeight >= 0
);
-
+
} else
if (m_VideoInfoHeader -> bmiHeader.biBitCount == 16 &&
(m_VideoInfoHeader -> bmiHeader.biCompression == FOURCC_YUY2)) {
-
+
//
// If we're UYVY, create the YUV synth.
//
m_ImageSynth = new(NonPagedPoolNx, 'YysI') CYUVSynthesizer;
-
+
}
else
//
// We don't synthesize anything but RGB 24 and UYVY.
//
Status = STATUS_INVALID_PARAMETER;
-
+
if (NT_SUCCESS (Status) && !m_ImageSynth) {
-
+
Status = STATUS_INSUFFICIENT_RESOURCES;
-
- }
+
+ }
if (NT_SUCCESS (Status)) {
//
@@ -428,7 +586,7 @@ Return Value:
//
ReleaseHardwareResources ();
}
-
+
} else {
//
@@ -660,9 +818,9 @@ Return Value:
PAGED_CODE();
+
-
- return
+ return
m_HardwareSimulation -> ProgramScatterGatherMappings (
Clone,
Buffer,
@@ -749,7 +907,7 @@ Return Value:
// of hardware registers (ReadNumberOfMappingsCompleted) which would likely
// be done in the ISR.
//
- ULONG NumMappingsCompleted =
+ ULONG NumMappingsCompleted =
m_HardwareSimulation -> ReadNumberOfMappingsCompleted ();
//
@@ -774,7 +932,7 @@ Return Value:
// CaptureFilterDescriptor:
//
// The filter descriptor for the capture device.
-DEFINE_KSFILTER_DESCRIPTOR_TABLE (FilterDescriptors) {
+DEFINE_KSFILTER_DESCRIPTOR_TABLE (FilterDescriptors) {
&CaptureFilterDescriptor
};
@@ -810,8 +968,8 @@ CaptureDeviceDispatch = {
// This is the device descriptor for the capture device. It points to the
// dispatch table and contains a list of filter descriptors that describe
// filter-types that this device supports. Note that the filter-descriptors
-// can be created dynamically and the factories created via
-// KsCreateFilterFactory as well.
+// can be created dynamically and the factories created via
+// KsCreateFilterFactory as well.
//
const
KSDEVICE_DESCRIPTOR
@@ -865,7 +1023,7 @@ Return Value:
// at add & start. Everything is done based on the descriptors passed
// here.
//
- return
+ return
KsInitializeDriver (
DriverObject,
RegistryPath,
@@ -873,118 +1031,3 @@ Return Value:
);
}
-
-/*************************************************
-
- Global Functions
-
-*************************************************/
-
-/*++
-
-Routine Description:
-
- Array delete() operator.
-
-Arguments:
-
- pVoid -
- The memory to free.
-
-Return Value:
-
- None
-
---*/
-void
-__cdecl
-operator delete[](
- PVOID pVoid
-)
-{
- if (pVoid)
- {
- ExFreePool(pVoid);
- }
-}
-
-/*++
-
-Routine Description:
-
- Sized delete() operator.
-
-Arguments:
-
- pVoid -
- The memory to free.
-
- size -
- The size of the memory to free.
-
-Return Value:
-
- None
-
---*/
-void __cdecl operator delete
-(
- void *pVoid,
- size_t /*size*/
-)
-{
- if (pVoid)
- {
- ExFreePool(pVoid);
- }
-}
-
-/*++
-
-Routine Description:
-
- Sized delete[]() operator.
-
-Arguments:
-
- pVoid -
- The memory to free.
-
- size -
- The size of the memory to free.
-
-Return Value:
-
- None
-
---*/
-void __cdecl operator delete[]
-(
- void *pVoid,
- size_t /*size*/
-)
-{
- if (pVoid)
- {
- ExFreePool(pVoid);
- }
-}
-
-PVOID operator new
-(
- size_t iSize,
- _When_((poolType & NonPagedPoolMustSucceed) != 0,
- __drv_reportError("Must succeed pool allocations are forbidden. "
- "Allocation failures cause a system crash"))
- POOL_TYPE poolType,
- ULONG tag
-)
-{
- PVOID result = ExAllocatePoolWithTag(poolType,iSize,tag);
-
- if (result) {
- RtlZeroMemory(result,iSize);
- }
-
- return result;
-}