
No, this is not a mistake in the Habra engine, and not a repetition of an article published last week
on WiDi technology . This time we will talk about how developers can use WiDi in their applications. Did you know that there is a
WiDi Extension SDK for working with WiDi? Not? Then this article is for you.
Which developer can this be useful? In theory, this may be limited only by the imagination of the developer. Ideas lying on the surface are programs for playing video or audio with visualization, programs for viewing photos. A smart program can detect the presence of WiDi in the system and prompt the user to display the content being played on the TV screen. It is possible that at the moment this topic is not very relevant - WiDi adapters are currently not so much.
But in the near future, after WiDi adapters start installing directly into televisions, for example, LG has already demonstrated the first television at CES 2012 and
is going to start their release this year, this topic will interest many developers.
For developers who want to integrate WiDi functionality into their applications, Intel has released the Intel WiDi Extensions SDK. This SDK allows you to:
')
- Determine the availability and availability of WiDi
- Find and identify adapters ready to connect
- Connect to adapter
- Change screen settings, display mode (clone screen, expand desktop on second screen)
In the SDK you will find the documentation, the files needed for inclusion in the project and examples in C ++, C #.
By the way, to develop an application that works with WiDi, it is not necessary to have hardware that supports this technology. This iron is needed only for testing.
We will begin to build functionality for working with WiDi into our program.
First you need to go to the site and download the
Intel WiDi Extensions SDK . Inside the archive is a distribution kit containing the SDK itself. Save, unpack, install.
Create our test application, connect the header file to the project
#include <IntelWiDiExtensions_i.h>
The first thing to do is create and initialize the IWiDiExtensions
HRESULT hr; hr = CoCreateInstance(CLSID_WiDiExtensions, NULL, CLSCTX_INPROC_SERVER, __uuidof(IWiDiExtensions), (LPVOID*)&m_pWiDi); if(hr == S_OK) { hr = m_pWiDi->Initialize((DWORD)m_hWnd); }
All WiDi API functions are asynchronous. To notify about the result of the operation performed, window messages are sent to the window, the handle of which was transferred when the
Initialize function was called.
HRESULT Initialize( HWND windowHandle );
In order to receive notification of the successful completion of initialization, the application window must be able to process the
WM_WIDI_INITIALIZED message.
To receive notification of an error that occurred during the initialization process, use the
WM_WIDI_INITIALIZATION_FAILED message. The wParam parameter of the
WM_WIDI_INITIALIZATION_FAILED message
handler will contain the corresponding error code:
RC_WIDI_APP_NOT_FOUND
After successful initialization, you can start searching for available WiDi adapters. This is done using the
StartScanForAdapters function
. HRESULT StartScanForAdapters();
To notify about the found adapter, the
WM_WIDI_ADAPTER_DISCOVERED message is
used . The lParam parameter will be a pointer to the adapter identifier. This ID is required to connect to the selected adapter.
After the search is completed, the window will receive the
WM_WIDI_SCAN_COMPLETE message. The wParam parameter will contain a code whose analysis will help determine why the scan was completed:
RC_SUCCESS
If one or more devices were detected, you can proceed with the connection. The connection is made by calling the
StartConnectionToAdapter function.
HRESULT StartConnectionToAdapter( BSTR AdapterUniqueID, int SourceScreenResolution, int TargetScreenResolution, ScreenMode Mode );
After successful connection, the window will receive a
WM_WIDI_CONNECTED message. In case of problems -
WM_WIDI_DISCONNECT_FAILED , the wParam parameter will contain the code:
RC_CONNECTION_DROPPED
The adapter ID will be passed to the
lParam parameter.
That's all for now. For more information about the capabilities of the WiDi Extensions SDK, you can view the documentation that comes with the SDK. There will be questions - ask here, in the comments, or on the
Intel Software Network forum.