Developing Metro style Device Apps for Cameras
Transcription
Developing Metro style Device Apps for Cameras
Developing Metro style Device Apps for Cameras May 31, 2012 Abstract This paper provides information about developing a Metro style device app to customize the capture experience and provide additional features for a specific camera. The intended audience is independent hardware vendors (IHVs) and original equipment manufacturers (OEMs) who are interested in providing a Metro style device app to differentiate their attached or embedded camera. Some sections of this paper assume that the reader is familiar with JavaScript, C++, and Media Foundation. This paper contains an appendix with special requirements for internally embedded cameras. This information applies to the following operating systems: Windows 8 Release Preview References and resources discussed here are listed at the end of this paper. The current version of this paper is maintained on the web at: Developing Metro style Device Apps for Cameras Disclaimer Disclaimer: This document is provided “as-is”. Information and views expressed in this document, including URL and other Internet website references, may change without notice. You bear the risk of using it. Some examples depicted herein are provided for illustration only and are fictitious. No real association or connection is intended or should be inferred. This document does not provide you with any legal rights to any intellectual property in any Microsoft product. You may copy and use this document for your internal, reference purposes. You may modify this document for your internal, reference purposes. © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 2 Document History Date Change May 31, 2012 Updated information about installing, testing, and troubleshooting the samples and installing the Metro style device app for a camera. February 28, 2012 Updated for Windows 8 Consumer Preview September 13, 2011 First publication Contents Introduction.................................................................................................................... 5 Metro style app features............................................................................................ 5 Exposure to all Metro style apps............................................................................5 Enhanced camera capture experiences......................................................................6 Architectural overview................................................................................................7 The Metro style device app for camera.......................................................................... 7 The Start experience...................................................................................................8 The Options experience..............................................................................................8 Exposure to the built-in camera experience.......................................................... 9 Exposure to Metro style apps...............................................................................10 Camera settings declaration..................................................................................... 11 Handle the activation event..................................................................................... 13 Controlling settings and effects................................................................................ 15 Sample: Metro style device app for camera.............................................................17 UI dimensions........................................................................................................... 17 Design guidelines...................................................................................................... 19 Suggested effects................................................................................................. 19 Suggested settings................................................................................................19 May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 3 Restrictions...........................................................................................................19 The Driver MFT..............................................................................................................20 Prerequisites............................................................................................................. 22 How the Driver MFT is exposed to apps...................................................................22 Multi-pin cameras.....................................................................................................23 Driver MFT implementation..................................................................................... 23 Development tools............................................................................................... 23 Driver MFT characteristics....................................................................................23 Communication between the camera and the Driver MFT................................. 24 How to access device source information............................................................25 How to implement passthrough mode................................................................ 25 Header files to include..........................................................................................25 How to implement IInspectable........................................................................... 25 COM implementation...........................................................................................26 Exposing the Driver MFT to JavaScript and C# Metro style device apps............. 28 Installing and registering the Driver MFT................................................................. 28 Associating your app with the camera..........................................................................29 Updates.....................................................................................................................29 Multiple models........................................................................................................29 Internal cameras....................................................................................................... 29 Creating the device metadata package.................................................................... 30 Tutorial: Installing, testing, and troubleshooting the samples..................................... 31 Prerequisites............................................................................................................. 31 Install the Metro style device app for cameras........................................................ 32 Install the Driver MFT............................................................................................... 33 Test the samples....................................................................................................... 35 May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 4 Troubleshooting the samples................................................................................... 35 Appendix A: Requirements for identifying internal cameras........................................37 Internal camera settings........................................................................................... 37 Group camera device nodes under the PC device container............................... 37 Set the Model ID for the internal camera’s device node..................................... 38 Metadata structure...................................................................................................42 Pre-installation requirements...................................................................................42 Resources...................................................................................................................... 42 May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 5 Introduction Metro style device apps are a new feature in Windows Release Preview that enables users to easily access unique device features from an app that is automatically downloaded the first time the device is attached. Device manufacturers provide Metro style device apps to offer additional functionality that differentiates their devices. Hardware manufacturers can extend the capture experience for their attached or embedded camera by providing a Metro style device app for cameras. This incorporates additional features, such as custom video effects, into the built-in experience for capturing photos and videos in Windows Release Preview, as well as offering these customizations to any Metro style app that captures from the camera. Metro style app features Metro style apps use the new app model introduced with Windows Developer Preview. A Metro style device app for camera is a special type of Metro style app that is associated with a camera, so it has features and benefits common to all Metro style apps: • Development platforms - Metro style apps are built using the Windows Software Development Kit for Metro style apps and the Windows Runtime APIs. • Programming languages - You can build Metro style apps using JavaScript with an HTML and CSS presentation layer, or by using C++ or C# with a XAML presentation layer. • Touch optimization - Touch interaction support is built in. You can design your Metro style device app for touch, and Windows gives you keyboard, mouse, and graphical scaling support for free. For more information about Metro style apps, see Metro style app samples on MSDN and the “Resources” section at the end of this paper. Exposure to all Metro style apps In addition to the benefits of being a Metro style app, a key benefit of a Metro style device app for your camera is exposure to every Metro style app that uses the camera. When your camera’s Metro style device app is registered with Windows, the features it implements are automatically made available to any Metro style apps that call the Windows.Media.Capture.CameraOptionsUI.Show API to display a camera options user interface. Therefore, there is no need to implement an app that runs constantly in the background, waiting to attach to a video stream. In Windows Release Preview, the application model does not support this type of background application. Metro style apps are automatically suspended to conserve system resources when the user isn’t interacting with the app. May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 6 Enhanced camera capture experiences Your Metro style device app for camera can provide interesting and valuable enhancements when the user captures a photo or video for sharing later, or in a live video chat feed. Here are some examples of ways users can enhance their capture experiences using a Metro style device app for camera: • The user’s favorite sports team has just won, so she wants to post a celebratory message to YouTube. She opens a camera app and begins previewing the camera feed. Then she taps on an options button in the app to invoke the Metro style device app provided by the camera manufacturer. She selects a fireworks background effect and then records a video message to share on YouTube. • The user wants to wish her son a happy birthday, so she starts a video call app and calls him. From the app, she then invokes the camera’s Metro style device app to add a birthday cake and candles to the video feed and sings “Happy Birthday”. • The user wants to take a new profile picture for a social networking site, and thinks it would be funny to be wearing huge sunglasses in the picture. So she selects a sunglasses effect from the camera’s Metro style device app and then takes the picture. Figure 1: The user of a video capture app selects a sunglasses overlay effect. May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 7 Figure 2: The user of a video chat application selects an effect that overlays a pair of sunglasses on his face. Architectural overview To use a Metro style device app for camera to provide differentiating features requires three components, and device metadata ties them all together. Figure 3. Components of a camera camera’’s device experience • The camera’s Metro style device app provides the custom user interface for selecting camera options and choosing effects when the camera is used to capture video. Windows determines whether a Metro style device app is installed by checking the device metadata package. • The Driver MFT is the Media Foundation Transform (MFT) that implements the effects. This media extension that provides the effects is an implementation of IMediaTransform IMediaTransform. This MFT is the first transform applied to the video stream coming out of the driver. It will be available to any app that requests a capture from that device. • The camera itself is the essential piece of the Metro style device app experience. The capture options for the Metro style device app only appear if the camera is in use, and the effects implemented in the Driver MFT are applied only to the stream from the specific camera. It is possible to use the same Metro style device app for more than one camera, but each camera’s device metadata must specify the app, and the Driver MFT must be installed for each camera. May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 8 You associate the Metro style device app with the camera by creating and submitting device metadata. This process is described in the “Associating your app with the camera” section later in this paper. The Metro style device app for camera This section describes the Metro style device app for camera, how it’s exposed in Windows Release Preview, and how to implement it. If Windows detects that a Metro style device app is installed, this app replaces the default camera options user interface (UI) by providing customized options that are shown when the user invokes camera settings in a video or photo capture app. A Metro style device app for camera can be launched in two different contexts: the Start experience, and the Options experience. The Start experience The Start experience is the functionality a Metro style device app for camera provides when the app is launched from the app tile in the Start screen. This Start experience is displayed full-screen, like any other Windows Metro app that is launched from an app tile, and there are no special restrictions on the type of UI controls it may use. It is distinct from any functionality applied to the capture stream from the camera. Your camera’s Metro style device app should provide an interesting and engaging Start experience. This experience can be used to highlight related products or provide customer support and other services. Figure 4. The user launches the Start experience by clicking the Metro style device app app’’s tile in the Start screen The Options experience The Options experience is the functionality a Metro style device app for camera provides when a Metro style app captures or previews video from the camera. It is not full-screen, but displays within a flyout, which is a control for displaying a lightweight, contextual user interface that is dismissed when a user clicks or taps outside of it. May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 9 When no Metro style device app for camera is installed, Windows provides a default flyout that is available from the built-in Camera Capture UI, as well as from any Metro style apps that call Windows Runtime APIs to display UI for camera options. If Windows detects than a Metro style device app is installed for your camera, your Options experience replaces the default flyout, extending both the built-in capture experience and the capture experience available from any Metro style app. The sequence of user actions to invoke the Options experience is slightly different depending on whether the user is capturing video using the Camera Capture UI, or from another Metro style app. Exposure to the built-in camera experience The Camera Capture UI is a full-screen Metro style UI for capturing a photo or video. It is shown by the Windows-provided Camera app, and by apps that call Windows.Media.Capture.CameraCaptureUI.CaptureFileAsync Windows.Media.Capture.CameraCaptureUI.CaptureFileAsync. Figure 5. The full-screen Camera Capture UI To get to the Options experience in the Camera Capture UI, the user does the following: 1. Tap the Options button in the Camera Capture UI. 2. A default flyout appears that shows basic options for setting resolution and video stabilization. This first flyout has a link to More More. May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 10 3. Tap or click More More. A second flyout displayed. If a Metro style device app is installed for the active camera, its Options experience is displayed in the flyout. If no Metro style device app is installed, the default system-provided flyout is displayed. Figure 6. Invoking a camera camera’’s Metro style device app from the Camera Capture UI Exposure to Metro style apps If an app calls Windows.Media.Capture.CameraOptionsUI.Show to display a camera options flyout, the first flyout for resolution and video stabilization is not shown. If a Metro style device app is installed, the Options experience it provides is displayed immediate after the app calls CameraOptionsUI.Show CameraOptionsUI.Show. May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 11 Figure 7. Invoking a camera camera’’s Metro style device app from CameraOptionsUI.Show Camera settings declaration In order for Windows to recognize the Options experience supplied by a Metro style device app for camera, the app must declare that it is providing an extension to system functionality. A Metro style device app that is declared as a camera settings extension can be activated by Windows when a user clicks the Options button or an app calls Windows.Media.Capture.CameraOptionsUI.Show Windows.Media.Capture.CameraOptionsUI.Show. The Metro style device app then handles the event that is raised when the app is activated. The objects that May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 12 allow the Metro style device app to control settings are supplied in the arguments to the activation event. You make the declaration in the package.appxmanifest file for your Microsoft Visual Studio 11 Beta project using the following steps: 1. In Microsoft Visual Studio 11 Beta, double-click your project’s package.appxmanifest in Solution Explorer. 2. In the Declarations tab, choose Camera Settings from Available Declarations Declarations, and click Add Add. 3. Enter app info under Properties Properties: • For a Metro style device app using JavaScript and HTML, enter the file name of the app’s start page (for example, default.html) in the StartPage field of Application Settings Settings. Figure 8: The required Camera Settings properties for a Metro style device app using JavaScript and HTML • For a Metro style device app using XAML with C++ or C#, enter the executable file name (for example, settingspanel.exe) in the Executable field and the application entry point (for example, settingspanel.App) in the EntryPoint field. The application name and entry point are defined in the <Applications> element inside the package.appxmanifest.xml file. May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 13 Figure 9. The required properties for the Camera Settings declaration for a Metro style device app using C# or C++ and XAML Handle the activation event If your app provides the Camera Settings declaration, it must supply a handler for the app activation event. Recall that the Metro style device app can be launched in two contexts: 1. The full-screen Start experience launched from the app tile in Start. 2. The Options experience flyout that is launched from a Metro style app that is capturing from the camera. The handler initializes the Start experience when launched from the tile, and the Options experience when activated from a capture app. In a JavaScript implementation, you handle the activated event, and examine the Windows.ApplicationModel.Activation.CameraSettingsActivatedEventArgs passed to the event handler to determine whether the Metro style device app was launched from its tile or activated from a capture app. If the event argument’s kind property is Windows.ApplicationModel.Activation.ActivationKind.launch Windows.ApplicationModel.Activation.ActivationKind.launch, provide the Start experience. If the kind property is Windows.ApplicationModel.Activation.ActivationKind.cameraSettings Windows.ApplicationModel.Activation.ActivationKind.cameraSettings, provide the Options experience. The activation event arguments are located on the WinJS eventargs.detail object. For example, kind can be accessed as follows. May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 14 var activationKind = eventArgs.detail.kind; The following snippet demonstrates how to attach the event handler and determine the app context using JavaScript. var activatedHandler = function (eventArgs) { var kind = eventArgs.detail.kind; var activationType = Windows.ApplicationModel.Activation.ActivationKind; if (kind === activationType.cameraSettings) { // Initialize logic for the flyout that provides camera // effects here. } else if (kind === activationType.launch) { // Do not provide settings or effects if launched. // Instead, you may provide support, services, // or other functionality that does not apply effects. } } WinJS.Application.start(); WinJS.Application.addEventListener("activated", activatedHandler, false); In C++ and C# implementations, the OnLaunched handler is invoked for the Start experience and the OnActivated handler is invoked for the Options experience. The following snippet demonstrates how this can be done in C#. using Windows.ApplicationModel.Activation; namespace CameraMetrostyleDeviceApp { public partial class App { public App() { InitializeComponent(); } May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 15 protected override void OnLaunched( LaunchActivatedEventArgs args) { // Initialize the start page Window.Current.Content = new StartPage(); Window.Current.Activate(); } protected override void OnActivated(IActivatedEventArgs args) { if (args.Kind == ActivationKind.CameraSettings) { base.OnActivated(args); MainPage page = new MainPage(); Window.Current.Content = page; // The args object contains properties for // controlling the device settings page.Initialize((CameraSettingsActivatedEventArgs)args); Window.Current.Activate(); } } } } Controlling settings and effects This activation event provides an event argument of type Windows.ApplicationModel.Activation.CameraSettingsActivatedEventArgs that exposes two properties for controlling the camera. The VideoDeviceController property provides methods for adjusting standard settings. It is an object of type Windows.Media.Devices.VideoDeviceController Windows.Media.Devices.VideoDeviceController. See the API reference section of Metro style app development (http://msdn.microsoft.com/windows/apps) for more information on the VideoDeviceController class. The VideoDeviceExtension is a pointer to the Driver MFT interfaces for applying custom settings. It will be null if no Driver MFT interfaces are exposed. The Metro style device app for camera sample demonstrates how to use VideoDeviceExtension. See “Example: Metro style device app for camera” later in this paper for more details May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 16 on the sample project, and see “The Driver MFT” later in this paper for more information on the Driver MFT. The following snippet demonstrates how to access the VideoDeviceController property using JavaScript. var videodev = null; var videoext = null; var lcWrapper = null; function activatedHandler(eventArgs) { if (eventArgs.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.cameraSettings) { videoext = eventArgs.detail.videoDeviceExtension; videodev = eventArgs.detail.videoDeviceController; if (videoext !== null) { initializeExtension(videoext); } if (videodev !== null) { initializeSlider(); // do other initialization here… } } } WinJS.Application.start(); WinJS.Application.addEventListener("activated", activatedHandler, false); function initializeExtension(mft0) { lcWrapper = Wrapper.WinRTComponent(); lcWrapper.initialize(mft0); } // Initialize a slider element using the VideoDeviceController object function initializeSlider() { try { var bValue = 0; var bAuto = 0; var slider; if (videodev != null) { May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 17 bValue = videodev.brightness.tryGetValue(); slider = document.getElementById("slBrt"); slider.value = bValue.value; slider.min = videodev.brightness.capabilities.min; slider.max = videodev.brightness.capabilities.max; } } The following snippet demonstrates how to access the VideoDeviceController property in C#. protected override void OnActivated(IActivatedEventArgs args) { if (args.Kind == ActivationKind.CameraSettings) { base.OnActivated(args); MainPage page = new MainPage(); Window.Current.Content = page; page.Initialize((CameraSettingsActivatedEventArgs)args); Window.Current.Activate(); } } public void Initialize(CameraSettingsActivatedEventArgs args) { // videoDevController is assumed to be defined elsewhere // as a global variable videoDevController = (VideoDeviceController)args.VideoDeviceController; bool bAuto = false; double value = 0.0; // Initialize slBrt, a slider control if (videoDevController.Brightness.Capabilities.Step != 0) { slBrt.Minimum = videoDevController.Brightness.Capabilities.Min; slBrt.Maximum = videoDevController.Brightness.Capabilities.Max; slBrt.StepFrequency = videoDevController.Brightness.Capabilities.Step; videoDevController.Brightness.TryGetValue(out value); slBrt.Value = value; } } May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 18 Sample: Metro style device app for camera For an example that demonstrates how a Driver MFT can be referenced from a Metro style device app, see the Metro style Device App for Camera sample. You will also need to install the Driver MFT Sample . UI dimensions In Windows Release Preview, the flyout that displays the Metro style device app for camera is 625 pixels high and 340 pixels wide. The area containing the “More options” text at the top is provided by Windows and is approximately 65 pixels high, leaving 560 pixels for the viewable area of the Metro style device app. If your Metro style device app is more than 560 pixels in height, the user may slide or scroll to view parts of the app that are above or below the viewable area. A Metro style device app should not exceed 340 pixels in width. May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 19 Figure 10. Dimensions of the flyout that displays the options experience for a Metro style device app for camera May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 20 Design guidelines This section contains recommendations and restrictions for the implementation of your Metro style device app for camera. Suggested effects • Color effects, such as grayscale, sepia tone, or solarizing the entire picture. • Face-tracking effects – these are often overlays, where a face is identified in the picture and an overlay, such as a hat or a pair of glasses, is added on top of it. • Scene modes – these are preset exposure and focus modes for different lighting conditions. Suggested settings • Your Metro style device app can provide a switch to enable hardwareimplemented settings, such as color correction schemes. Some examples of color correction schemes are TrueColor and RightColor. • Implement basic properties that supplement the other settings exposed by your Metro style device app. For example, many devices may expose controls for adjusting brightness, contrast, flicker, focus, and exposure, but a device that implements TrueColor to automatically adjust the brightness and contrast may not need to provide these settings. Restrictions This section lists practices that a Metro style device app for camera should not attempt: • Do not show a user interface for selecting settings or effects if the app is launched from its tile in Start rather than from a capture app. Settings will not persist from the Start experience. • Do not provide a preview or otherwise take ownership of the video stream from inside your Metro style device app. A Metro style device app for camera is meant to function as a companion to another app that captures video. The capture app has ownership of the video stream. You shouldn’t try to access the video stream using low-level APIs. This may cause unexpected behavior, in which the capture app loses access to the stream. • Do not adjust resolution in your Metro style device app. May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 21 • Do not attempt to display pop-ups, notifications, or dialogs outside of the area intended for the Metro style device app’s Options experience. These types of dialogs are not permitted. • Do not initiate audio or video capture inside the Options experience. The Options experience for your Metro style device app is meant to extend another app that is capturing video, rather than initiate the capture itself. Additionally, capturing audio or video may trigger a system dialog, and popup dialogs are not permitted inside the Options flyout. • Do not declare the SMS device capability in your Visual Studio project. The Driver MFT This section describes the Media Foundation Transform (MFT) that you create to apply effects to the media capture stream coming from the camera. This is how you provide transforms for color effects, scheme modes, and face-tracking effects that really distinguish your camera from others. This MFT, known as a Driver MFT, is first applied to the connected video stream coming from the camera driver when a Metro style app begins video capture. When that app invokes the Options UI, Windows automatically provides access to any interfaces the Driver MFT implements for controlling its custom effects. Figure 11. The flow of data between an app that captures video, settings app, Driver MFT, driver, and camera. May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 22 The following process diagram shows the sequence of events across different process spaces that result in the Metro style device app’s control of a Driver MFT. The Metro style device app for camera runs in a different process than the app that is capturing from the camera. Figure 12. The process interaction for invoking a Metro style device app for camera May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 23 Note that the Driver MFT is not strictly required for a Metro style device app, but it supplies the custom settings and effects. A device manufacturer may choose to implement a Metro style device app without a Driver MFT, simply to provide a differentiated user interface containing branding for their hardware, without applying custom effects to the video stream. The Driver MFT implements IMFTransform IMFTransform. It also must be exposed to the Windows Runtime, so it must also implement IInspectable IInspectable. For more information on implementing IInspectable IInspectable, see the “Driver MFT Implementation” section later in this paper. Prerequisites Your camera’s driver must use the AvStream driver model. For more information on the AvStream driver model, see AVStream Overview in the Windows Driver Kit. How the Driver MFT is exposed to apps A Driver MFT is registered with Windows as a COM interface so that the transform it implements can be applied to the media stream coming out of a specific device, such as a camera. Note that a Driver MFT shouldn’t be registered using the MFTRegister function because it is device specific and not a general purpose MFT. See the “Installing and registering the Driver MFT” section later in this paper for information on the registry key. When an app initiates a video capture, a Media Foundation Source Reader is instantiated to provide the video stream. This media source reads a registry value from the device registry key. If the CLSID of the Driver MFT’s COM class is found in the registry value, the source reader instantiates the Driver MFT and inserts it into the media pipeline. In addition to Metro style device apps, the Driver MFT functionality can be accessed when the device associated with it is used to capture video using the following APIs: • HTML5 <video> tags in a Metro style app using HTML. Transforms that the Driver MFT has enabled will affect video that is being played using the <video> element, as in the following code example: var video = document.getElementById('myvideo'); video.src = URL.createObjectURL(fileItem); video.play(); May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 24 • Windows.Media.MediaCapture API in a Metro style app using the Windows Runtime. For more information on how this API is used, see the Media Capture Sample. • Media Foundation’s Source Reader, for apps processing media data. The Driver MFT will be exposed to applications as the first (0th) MFT when calling IMFSourceReaderEx::GetTransformForStream IMFSourceReaderEx::GetTransformForStream. The category that will be returned is MFT_CATEGORY_VIDEO_EFFECT. Figure 13. Source Reader Reader’’s role in media capture Multi-pin cameras If you have a three-pin or other multi-pin camera, see Considerations for Driver MFT Implementations on Multi-Pin Cameras for more info on special considerations for your Driver MFT implementation. Driver MFT implementation This section provides information on implementing your Driver MFT. For a full example of a Driver MFT that works together with a Metro style device app for camera, see the Driver MFT Sample. Development tools Visual Studio 11 Ultimate Beta is required. May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 25 Driver MFT characteristics The Driver MFT is instantiated per stream. For each stream the camera supports, an instance of the MFT is instantiated and connected to it. The Driver MFT is expected to have a single input stream and a single output stream. The Driver MFT may be either a synchronous MFT or an asynchronous MFT. Communication between the camera and the Driver MFT To enable two-way communication between the media source and the Driver MFT, the pointer to source stream’s attribute store is set on the input stream attribute store of the Driver MFT as MFT_CONNECTED_STREAM_ATTRIBUTE. This occurs through a handshake process you enable by exposing MFT_ENUM_HARDWARE_URL_Attribute in Driver MFT, as in the following example. HRESULT CDriverMft::GetAttributes(IMFAttributes** ppAttributes) { HRESULT hr = S_OK; if (NULL == ppAttributes) { return E_POINTER; }; if(!m_pGlobalAttributes) { MFCreateAttributes(&m_pGlobalAttributes, 1); m_pGlobalAttributes-> SetString(MFT_ENUM_HARDWARE_URL_Attribute, L"driverMFT"); } *ppAttributes = m_pGlobalAttributes; (*ppAttributes)->AddRef(); return S_OK; } The MFT_CONNECTED_STREAM_ATTRIBUTE in the Driver MFT’s attribute store is set to point to the device source stream’s attribute store, as depicted in the following diagram. May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 26 Figure 14. Driver MFT attribute store points to device source stream attribute store See Hardware Handshake Sequence at http://msdn.microsoft.com/enus/library/dd940330(VS.85).aspx#handshake for further details on how communication between the camera and the MFT is set up. How to access device source information The code example that follows shows how the Driver MFT can get the pointer to the source transform from its input attribute store. The Driver MFT can then use the source pointer to get device source info. if(!m_pSourceTransform && m_pInputAttributes) { m_pInputAttributes-> GetUnknown( MFT_CONNECTED_STREAM_ATTRIBUTE, IID_PPV_ARGS(&pSourceAttributes)); pSourceAttributes-> GetUnknown( MF_DEVICESTREAM_EXTENSION_PLUGIN_CONNECTION_POINT, IID_PPV_ARGS(&pUnk))); pUnk->QueryInterface(__uuidof(IMFTransform), (void**)&m_pSourceTransform)); } if (m_pSourceTransform) { // Put code to get device source information here. } May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 27 How to implement passthrough mode To put the Driver MFT in passthrough mode, specify the same media type for the input and output stream. ProcessInput and ProcessOutput calls on the MFT will still be made. It is left up to your Driver MFT implementation to determine whether or not any processing occurs in passthrough mode. Header files to include You’ll need to include header files for the IInspectable and IMFTransform methods that the Driver MFT must implement. For a list of header files to include, see stdafx.h in the SampleMFT0 directory of the Metro style device app for camera sample. // required for IInspectable #include <inspectable.h> How to implement IInspectable A Driver MFT that’s intended for use from a camera’s Metro style device app must implement the methods of IInspectable so that the Metro style device app can access a pointer to the Driver MFT when launched. Your Driver MFT should implement the methods of IInspectable as follows: • IInspectable::GetIids should return null in the iids out parameter, and return 0 in the iidCount out parameter. • IInspectable::GetRuntimeClassName should return null in the out parameter. • IInspectable::GetTrustLevel should return TrustLevel::BaseTrust in the out parameter. The following code example shows how the IInspectable methods are implemented in the sample Driver MFT. This code can be found in the Mft0.cpp file, in the SampleMFT0 directory of the sample. // Mft0.cpp STDMETHODIMP CMft0::GetIids( /* [out] */ __RPC__out ULONG *iidCount, /* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID **iids) { HRESULT hr = S_OK; do { CHK_NULL_PTR_BRK(iidCount); CHK_NULL_PTR_BRK(iids); *iids = NULL; *iidCount = 0; } while (FALSE); May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 28 return hr; } STDMETHODIMP CMft0::GetRuntimeClassName( /* [out] */ __RPC__deref_out_opt HSTRING *className) { HRESULT hr = S_OK; do { CHK_NULL_PTR_BRK(className); *className = NULL; } while (FALSE); return hr; } STDMETHODIMP CMft0::GetTrustLevel( /* [out] */ __RPC__out TrustLevel *trustLevel) { HRESULT hr = S_OK; do { CHK_NULL_PTR_BRK(trustLevel); *trustLevel = TrustLevel::BaseTrust; } while (FALSE); return hr; } COM implementation This section contains information on the COM implementation of a Driver MFT intended for a Metro style device app for camera. Interfaces should derive from IUnknown Each interface your Driver MFT implements should implement and derive from IUnknown IUnknown, in order to be correctly marshaled to the camera’s Metro style device app. The following is an example .idl file for a Driver MFT that demonstrates this. // SampleMft0.idl : IDL source for SampleMft0 // May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 29 // This file will be processed by the MIDL tool to // produce the type library (SampleMft0.tlb) and marshalling code. import "oaidl.idl"; import "ocidl.idl"; import "Inspectable.idl"; import "mftransform.idl"; [ object, uuid(F5208B72-A37A-457E-A309-AE3060780E21), oleautomation, nonextensible, pointer_default(unique) ] interface IMft0 : IUnknown{ [id(1)] HRESULT UpdateDsp([in] UINT32 uiPercentOfScreen); [id(2)] HRESULT Enable(void); [id(3)] HRESULT Disable(void); [id(4)] HRESULT GetDspSetting([out] UINT* puiPercentOfScreen, [out] BOOL* pIsEnabled); }; [ uuid(DE05674A-C564-4C0E-9B7C-E1519F7AA767), version(1.0), ] library SampleMft0Lib { importlib("stdole2.tlb"); [ uuid(7BB640D9-33A4-4759-B290-F41A31DCF848) ] coclass Mft0 { [default] interface IMft0; interface IInspectable; interface IMFTransform; }; }; May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 30 Note that the Driver MFT is a regular COM class that can be created using CoCreateInstance CoCreateInstance. You should not use the MFTRegister function to register it because it is not a general-purpose MFT. Create a proxy The Driver MFT is an out-of-process server. To use it in a Windows Metro style device app, you must provide marshaling support in a proxy so that your Driver MFT interface can be used across process boundaries. You can find an example of this in the Driver MFT Sample. The sample uses the MIDL compiler to generate a stubless proxy. Exposing the Driver MFT to JavaScript and C# Metro style device apps To write a Metro style device app in C# or JavaScript that interacts with a Driver MFT, you need to create an additional component in the Metro style device app’s Visual Studio project. This component is a wrapper that exposes the Driver MFT interfaces in a Windows Runtime Component that is visible to the Metro style device app. The Wrapper subproject in the Metro style Device App for Camera sample provides an example of how to expose your Driver MFT to the Windows Runtime so that you can use it from a Metro style device app implemented in C# or JavaScript. It is designed to work together with the Driver MFT Sample. See Tutorial: Installing, testing and troubleshooting the samples later in this document for a step-by-step guide to installing, running, and testing the samples. Installing and registering the Driver MFT This section lists steps for installing the Driver MFT: 1. The Driver MFT DLL must be installed in a subdirectory of one of the following locations: • %SystemDrive%\Program Files\ • %SystemDrive%\Program Files (x86)\ 2. Install both the x86 and the x64 versions of the DLL on an x64 system. 3. Your camera installer registers the Driver MFT by calling regsvr32 on your Driver MFT DLL, or by providing a driver manifest (.man) file for the DLL that the installer uses for registration. 4. Set the CameraPostProcessingPluginCLSID value in the registry key for your camera. Your INF file should specify the CLSID of the Driver MFT in the device class registry key for the device, by setting the CameraPostProcessingPluginCLSID value to the CLSID GUID of the Driver MFT class. The following is an example from an INF file entry that populates the registry keys for a camera. May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 31 KSCATEGORY_VIDEO_CAMERA: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\DeviceClasses\{E53 23777-F976-4f5b-9B55B94699C46E44}\##?#USB#VID_045E&PID_075D&MI_00#8&23C3DB65&0&0 000#{E5323777-F976-4f5b-9B55-B94699C46E44}\#GLOBAL\Device Parameters] "CLSID"="{17CCA71B-ECD7-11D0-B908-00A0C9223196}" "FriendlyName"="USB Video Device" "RTCFlags"=dword:00000010 "CameraPostProcessingPluginCLSID"="{3456A71B-ECD7-11D0-B90800A0C9223196}" KSCATEGORY_CAPTURE: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\DeviceClasses\{ 65E 8773D-8F56-11D0-A3B900A0C9223196}\##?#USB#VID_045E&PID_075D&MI_00#8&23C3DB65&0&0 000#{65E8773D-8F56-11D0-A3B9-00A0C9223196}\#GLOBAL\Device Parameters] "CLSID"="{17CCA71B-ECD7-11D0-B908-00A0C9223196}" "FriendlyName"="USB Video Device" "RTCFlags"=dword:00000010 "CameraPostProcessingPluginCLSID"="{3456A71B-ECD7-11D0-B90800A0C9223196}" Note that KSCATEGORY_VIDEO_CAMERA is recommended for cameras. You will normally only need one of the registry keys, depending on how the device is registered. Associating your app with the camera This section contains information on steps required to identify your camera in device metadata and in the Windows registry. This metadata enables you to pair your Metro style device app to the camera and identifies your app so that it can be downloaded seamlessly the first time the camera is connected. Updates After the first installation of the app, if the user downloads an updated version of the app, then the updates are automatically integrated into the camera capture May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 32 experience. However, updates are not downloaded automatically. The user must download additional app updates from the Windows Store, because the app is automatically acquired only on first connect. The Start experience for your camera’s Metro style device app can provide notifications that updates are available and provide links to download updates. Your updated app should work with any updated drivers distributed through Windows Update. Multiple models Multiple camera models can declare same Metro style device app in their device metadata. It is also possible for two cameras on the same computer to declare different Metro style device apps. Internal cameras Internal cameras embedded inside a portable computer do not have their Metro style device app downloaded, because there is no act of connecting the camera to trigger the download. There are additional steps required to associate a Metro style device app with an internal camera. These described in “Appendix A: Requirements for identifying internal cameras” later in this document. Creating the device metadata package For both internal and external cameras, you need to create a device metadata package. When you submit your camera’s Metro style device app to the Windows Store (or preinstall it using the OPK, in the case of internal cameras), in addition to the application itself, you’ll need to provide metadata containing the following: • Application publisher name • Application package name • Application element identifier • Device experience identifier (provided by driver developer) For instructions on how to generate the device experience identifier, as well as information on the submission and validation process for Metro style device apps and the device drivers that accompany them, see The Metro style Device App Lifecycle – Deployment, Acquisition, Uninstall and Update. This document describes how the metadata is used, and provides instructions on how to submit the metadata package for validation. You can create or edit device metadata using the Device Metadata Authoring Wizard that is integrated with Visual Studio 2010 and Visual Studio 11 Beta and available in the in the Windows Driver Kit (WDK). May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 33 After you have installed the WDK and launched Visual Studio, you can add properties for your Metro style device app to existing device metadata by following these steps: i.On the Driver menu in Visual Studio, click Device Metadata Metadata, and then click Authoring Authoring. ii. Click Update existing device metadata package package, click Browse to select the package, and then click Next Next. iii. Click the Application tab to edit the properties required for identifying a Metro style device app. Fill out the following fields under Device Companion Application Application: • Package Name • Publisher Name • App ID These properties can be found in the package.appmanifest file in the Visual Studio project for the Metro style device app. May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 34 Figure 15. Properties for a Metro style device app in the Device Metadata Authoring Wizard To review and save your package after completing all the tabs in the wizard, click the Finish tab. If you want to install and test the metadata package on your PC, select Copy packages to your system system’’s local metadata store under Save As As. For more detailed information on the metadata properties included in a device metadata package, see Device Metadata Package Schema Reference for Windows 8. Tutorial: Installing, testing, and troubleshooting the samples This section provides step-by-step instructions for running the Metro style device app for camera sample together with the Driver MFT Sample. Prerequisites • You will need a copy of the device metadata package for your camera, to add the Metro style device app info to it. If you don’t have device metadata, you can build it using the Device Metadata Authoring Wizard that is integrated with Visual Studio and available in the in the Windows Driver Kit (WDK). See the Device Metadata Authoring Wizard documentation for more information. • You will need to have the WDK Installed so that you have the Device Metadata Authoring Wizard to use the edit the metadata. This tool is then available from the Driver menu in Visual Studio 11 Ultimate. May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 35 • If you have an internally embedded camera, rather an externally connected one, follow the requirements that apply to your camera, described in “Appendix A: Requirements for identifying internal cameras” later in this paper. • Download the Metro style device app for camera sample from http://go.microsoft.com/fwlink/?LinkID=227865. • Download the Driver MFT sample from http://go.microsoft.com/fwlink/?LinkId=252881 • Download the Camera Capture UI sample from http://go.microsoft.com/fwlink/?LinkId=228589 Install the Metro style device app for cameras Start by using these steps to install the Metro style device app for cameras. 1. Enable test signing so that metadata can be installed for your device. a. In an administrator command prompt, run this command: bcdedit -set testsigning on b. Reboot the machine. 2. Open the DeviceAppForWebcam solution in the folder for the programming language you choose. a. Build the DeviceAppForWebcam solution (Ctrl-Shift-B) . b. Open package.appxmanifest in Solution Explorer and take note of the following fields in the Packaging tab. You will use them to edit the metadata in a later step: o Package Name Name: Depending on which programming language you chose for the sample, this value is either Microsoft.SDKSamples.DeviceAppForWebcam.CPP, Microsoft.SDKSamples.DeviceAppForWebcam.CS, or Microsoft.SDKSamples.DeviceAppForWebcam.JS. o Publisher Publisher: By default, this is CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US. o Application Id Id: View the code inside package.appxmanifest and copy this value from the <Application> tag’s Id attribute. May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 36 3. Disconnect and uninstall the camera. This step is required so that Windows reads the updated device metadata the next time the device is detected. o If you have an externally connected camera, disconnect and uninstall your camera. o If you have an internal camera, use Device Manager to uninstall the camera. 4. Edit and install device metadata. a. Click the Driver menu in Visual Studio, select Device Metadata Metadata, and then select Authoring Authoring. b. Open your device metadata file, and go to the Applications tab. Fill in Package Name Name, Publisher Name Name, and App ID from the step 2. c. Go to the Finish tab and save your metadata file by following these steps under Save As As: i. Confirm the package name in the Save As box. ii. Next to Folder location location, confirm the location on your computer where you want the package to be saved, or click Change to select a different location. iii. Select Copy packages to your system's local metadata store to install the metadata. d. Click Finish Finish. 5. Reconnect your camera so that Windows reads the updated camera when the device is connected. • If you have an external camera, simply connect the camera. • If you have an internal camera, do one of the following: o Refresh the PC in the Devices and Printers folder o Use Device Manager to scan for hardware changes. Windows should read the updated metadata when the device is detected. Install the Driver MFT Use these steps to install the Driver MFT. 1. Open the SampleMft0 Solution Note: To build for ARM, follow these steps: May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 37 a. Using Configuration Manager, from the drop-down box for Active solution platform, select <New…>. In the New Project Platform dialog box, under New platform platform, select ARM and click OK OK. b. Open project properties for the SampleMFT0 project and follow these steps: i. Under Configuration Properties > General General, set Use of ATL to Static Link to ATL ATL. ii. Under Configuration Properties > C/C++ > Code Generation Generation, set Runtime Library to Multi-threaded (/MT) (/MT). iii. Under Linker > Input Input, edit Ignore Specific Default Libraries to include shlwapi.lib and urlmon.lib. 2. Build the solution (Ctrl-Shift-B). 3. Copy SampleMft0.dll to C:\Program Files (x86)\SampleMft0 (or to C:\Program Files\SampleMft0) on a 32-bit system). 4. In an administrator command prompt, navigate to the new location of DLL. 5. Run regsvr32 on SampleMft0.dll. 6. On an x64 system, build the x64 version of the DLL and repeat steps 3 to 5, copying the 64-bit DLL to C:\Program Files\SampleMft0) 7. Run regedit, and open the device registry key for your camera, under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\DeviceClasses\ • The following example shows the path to a device registry key for a camera. Your camera will have a different device ID and may have a different device class: HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Control\ DeviceClasses\ {E5323777-F976-4f5b-9B55-B94699C46E44}\ ##?#USB#VID_045E&PID_075D&MI_00#8&23C3DB65&0&0000#{E5323777-F976-4f5b9B55-B94699C46E44}\ • As shown in the following screenshot, under the GLOBAL#\Device Parameters key, add a CameraPostProcessingPluginCLSID value, and set its value to {7BB640D9-33A4-4759-B290-F41A31DCF848}. This is the CLSID of the Driver MFT defined in the SampleMFT0 project. May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 38 Figure 16. The device registry key key’’s CameraPostProcessingPluginCLSID Test the samples Follow these steps to test the Metro style device app and driver MFT that you installed by invoking the Metro style device app’s flyout using the Camera Capture UI sample. 1. Attach your camera. 2. Build and run the Camera Capture UI sample. 3. When the Camera Capture UI is displayed, tap the Camera options button and then click More in the Options flyout. • If the Metro style device app is correctly installed, the More options flyout that is shown contains Effect On/Off and Effect controls. • If the Driver MFT is correctly installed, the bottom half of the video preview will be green, as shown in the following screen shot. Modify the effect by adjusting the Effect On/Off and Effect switches in the More options flyout. Figure 17. The Driver MFT MFT’’s effect on the video preview May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 39 Troubleshooting the samples If the More options flyout doesn’t contain Effect On/Off and Effect controls, the Metro style device app isn’t correctly installed. Try the following: • Enable test signing by running bcdedit -set testsigning on. Then reboot your machine. • Make sure Package Name Name, Publisher Name Name, and App ID in the device metadata match the fields defined in the package.appxmanifest. • If you have an internal camera, note that you don’t have to provide the PLD information described in “Appendix A: Requirements for identifying internal cameras” later in this paper, if your camera does not expose PLD info in its ACPI tables. • If you have an internal camera, refresh the PC using the Devices and Printers folder. Select the PC in the folder, and click the refresh button as shown in the following screen shot. The camera itself should not be visible in the Devices and Printers folder. This is because internal cameras are enumerated as part of the PC device container. Figure 18. Refreshing the PC in the Devices and Printers folder If the green box in the bottom half of the video preview doesn’t appear, the Driver MFT isn’t correctly installed. Check the following: • Check that the Effect On/Off switch in the More Options flyout is set to On On. • Check that the SampleMFT0.DLL is registered and that you have entered the CLSID of the Driver MFT under the device registry key for the camera you are using to capture video. • Check that SampleMFT0.DLL is in a subdirectory of Program Files. May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 40 Appendix A: Requirements for identifying internal cameras This section contains additional requirements for internal cameras. Internal webcams must define additional information to ensure that the metadata package for the camera is correctly linked to the camera’s Metro style device app. Internal camera settings Windows Release Preview installs the metadata package for internal cameras based on the Model ID information in the device node, which is linked to the cameraspecific Metro style device app. To make an internal camera’s metadata discoverable by Windows, so that the device metadata package is correctly associated with the device, an OEM needs to do the following: • Override the removable device capability, so that camera device nodes are grouped under the PC device container, by using the DeviceOverrides registry key or by modifying the “user-visible” flag in the ACPI table. • Set the Model ID in the device node, by using the InternalDeviceModification flag in the device registry key. • Provide the _PLD Location property. Group camera device nodes under the PC device container In accordance with logo program requirement SYSFUND-0200, the internal camera device nodes must be grouped under the PC device container. In other words, the internal camera should not be displayed in Devices and Printers and must be consolidated into the PC container. The way to do this depends on the bus type of the internal camera. If the device can expose information on the physical device location in ACPI tables, the correct grouping can be specified in the ACPI layer by including _PLD information in the tables. Otherwise, override the removable flag by using the DeviceOverrides registry key. More information on the DeviceOverrides registry key is available on MSDN (http://msdn.microsoft.com/library/ff541144(VS.85).aspx). Refer to Multifunction Device Support and Device Container Groupings for more detailed information. May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 41 Set the Model ID for the internal camera’s device node The Windows device metadata system is able to query for an internally embedded camera’s device metadata package only if the camera’s device node has a Model ID property and the device category is Imaging.Webcam. For internal cameras, the Model ID property is determined using the InternalDeviceModification mechanism, which is a registry-based lookup table (LUT) that consists of registry keys that map to specific devices. This InternalDeviceModification table is maintained under the following registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\InternalDeviceModification The subkey entry under the InternalDeviceModification registry key is ModelID. The presence of this key adds the Model ID to the camera’s device node, based on the device hardware ID and the location information indicated by the _PLD value in the ACPI table. Figure 19. InternalDeviceModification registry key and subkeys. May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 42 InternalDeviceModification registry key Registry key name InternalDeviceModification Required/optional Required Path HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control Format requirements None Valid subkeys ModelID (See the following subkey format requirements and examples.) The InternalDeviceModification registry key indicates that at least one camera uses the ModelID. ModelID registry key Registry key name ModelID (exact modelID value is the key name) Required/optional Required Format requirements The model ID must have both opening and closing braces. Valid Values Hardware IDs PLD_Panel Examples {43922620-DAD9-4C05-BE3F-F65B089D84D8} HardwareID registry value Registry value name HardwareIDs Required/optional Required Type Multi-string Format requirements Must include the bus prefix of the HardwareID. All ”\” characters must be replaced with a “#”. USB#VID_1234&PID_ABCD&REV_0001 Examples PCI#VEN_ABCD&DEV_1234&SUBSYS_000 May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 43 Registry value name HardwareIDs Comment Multiple hardware ID values can be provided. When any of the hardware IDs occur in the list more than once, the system sets the Model ID based on the hardware ID. PLD_Panel registry value Registry value name PLD_Panel Required/optional Optional (Required in Windows Release Preview) Type DWORD Examples 4, 5 PLD_Panel Details Providing the PLD_Panel value enables cameras to be distinguished from each other using the Model ID property when a system has two identical camera devices and both have identical hardware IDs. To create different Model IDs, the combination of hardware IDs and PLD_Panel value is used. If the system has only one internal camera device, the PLD_Panel information doesn’t need to be provided. Note Note: Setting the PLD_Panel registry value is required for Windows Release Preview. The PLD_Panel setting in the registry key will be optional in subsequent versions of Windows. The PLD_Panel registry value is defined as _PLD (Physical Device Location) in the ACPI specification. This value, which indicates the camera’s physical location in its enclosure, must be one of the following. Value Description 0 Top 1 Bottom 2 Left 3 Right 4 Front 5 Back May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 44 Value Description 6 Unknown (Vertical position and Horizontal position will be ignored) InternalDeviceModification Registry key examples The following examples demonstrate the format of the InternalDeviceModification registry key. {00001111-2222-3333-4444-555566667777} HardwareIDs (Multi sz) = “USB#VID_1234&PID_ABCD&REV_0001”,“USB#VID_1234&PID_ABCD” PLD_Panel (DWORD) = 4 {88889999-aaaa-bbbb-cccc-ddddeeeeffff} HardwareIDs (multi sz) = “USB#VID_5678&PID_WXYZ&REV_0001” PLD_Panel (DWORD) = 5 Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE¥SYSTEM¥CurrentControlSet¥Control¥InternalDeviceModi fication] [HKEY_LOCAL_MACHINE¥SYSTEM¥CurrentControlSet¥Control¥InternalDeviceModi fication¥{BBBF38D6-9866-493D-B86F-986E339E096D}] "PLD_Panel"=dword:00000004 "HardwareIDs"=hex(7):55,00,53,00,42,00,23,00,56,00,49,00,44,00,5f,00,30,0 0,34,¥ 00,35,00,45,00,26,00,50,00,49,00,44,00,5f,00,30,00,30,00,31,00,30,00,23, 00,¥ 52,00,45,00,56,00,5f,00,30,00,30,00,30,00,31,00,00,00,55,00,53,00,42,00, 23,¥ 00,56,00,49,00,44,00,5f,00,30,00,34,00,35,00,45,00,26,00,50,00,49,00,44, 00,¥ 5f,00,30,00,30,00,31,00,30,00,00,00,00,00 May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 45 Defining the _PLD in the ACPI table The _PLD value indicating the camera’s location can also be set in the ACPI table. For a USB-connected internal camera, the device node for the USB device needs to be created under the USB Port device node in the ACPI table. Copy the _ADR value from the device node or USB port. This value is 0x6 in the example below. The ninth byte is the panel code for the location. The following is an example of the ACPI table for a USB-connected camera. Device(PRTD) { Name(_ADR, 0x6) Name(_UPC, Package(0x4) { .... } Name(_PLD, Buffer(0x10) { .... } Device(WCAM) { Name(_ADR, 0x6) Name(_PLD, Buffer(0x10) { 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}) } } Metadata structure The device metadata package for an internal camera has the same structure as the device metadata package for any other device. The MetadataKey in packageinfo.xml within the device metadata package is the Model ID defined by using the InternalDeviceModification registry key. The Windows metadata system downloads the device metadata package based on the Model ID. The hardware ID of the internal camera is not used. Pre-installation requirements Both the Metro style device app for camera and the device metadata package need to be preinstalled on the device using the OEM Preinstallation Kit (OPK). May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 46 Resources Windows Metro App Developer Center http://code.msdn.microsoft.com/windowsapps Metro style Device App for Camera Sample http://go.microsoft.com/fwlink/?LinkID=227865 Driver MFT Sample http://go.microsoft.com/fwlink/?LinkId=252881 Media Capture Sample http://go.microsoft.com/fwlink/?LinkId=243997 Windows.Media.Capture.CameraCaptureUI Sample http://go.microsoft.com/fwlink/?LinkId=228589 Windows.Media.Capture.CameraOptionsUI.Show Sample http://go.microsoft.com/fwlink/?LinkID=228588 Media Foundation Transforms http://msdn.microsoft.com/library/ms696274(VS.85).aspx IMFTransform http://msdn.microsoft.com/library/ms696260(VS.85).aspx AvStream Overview http://go.microsoft.com/fwlink/?LinkID=228585 Metro style Device Apps http://go.microsoft.com/fwlink/?LinkId=228590 May 31, 2012 © 2012 Microsoft. All rights reserved. Developing Metro style Device Apps for Cameras - 47 Device Metadata Authoring Wizard http://msdn.microsoft.com/library/windows/hardware/hh454213Device Metadata Package Schema Reference for Windows 8 http://go.microsoft.com/fwlink/p/?LinkId=226753 The Device Software Lifecycle -- Deployment, Acquisition, Uninstall and Update Process http://go.microsoft.com/fwlink/p/?LinkId=226757 Windows Store App Developer Portal https://appdev.microsoft.com/StorePortals May 31, 2012 © 2012 Microsoft. All rights reserved.