Intel Wireless Display: for the developer

    No, this is not a mistake in the Habra engine, and not a repeat of an article published last week on WiDi technology . This time we’ll talk about how developers can use WiDi in their applications. Did you know that WiDi Extension SDK exists for working with WiDi ? Not? Then this article is for you.

    Which of the developers might find this useful? In theory, this can be limited only by the imagination of the developer. Ideas that lie 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 reproduced content on the TV screen. It is possible that at the moment this topic is not very relevant - there are not so many WiDi adapters at the moment.

    But in the near future, after WiDi adapters begin to be installed immediately on TVs, for example, LG has already demonstrated the first TV at CES 2012 and is going to launch 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:

    • Detect WiDi Availability and Performance
    • Finding and identifying ready-to-connect adapters
    • Connect to adapter
    • Change screen settings, display mode (clone screen, expand the desktop to a second screen)




    In the SDK you will find documentation, files necessary 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. Such iron will be needed only for testing.

    We will begin to build functionality for working with WiDi in our program.

    First you need to go to the site and download the Intel WiDi Extensions SDK . Inside the archive is a distribution containing the SDK itself. We save, unpack, install.

    We create our test application, connect the header file to the project

    #include 

    The first thing to do is create and initialize 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 of the result of the operation, window messages are sent to the window whose handle was passed when the Initialize function was called .

    HRESULT Initialize(
      HWND windowHandle
    );
    

    In order to receive a notification about 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, the WM_WIDI_INITIALIZATION_FAILED message is used . The wParam parameter of the WM_WIDI_INITIALIZATION_FAILED message handler will contain the corresponding error code:

    RC_WIDI_APP_NOT_FOUND		// Не установлено приложение для работы с WiDi
    RC_WIDI_FAILED_TO_START		// Не удалось запустить приложение для работы с WiDi
    RC_INTERNAL_ERROR		// Произошла внутренняя ошибка
    RC_WIDI_APPLICATION_ERROR 	// Неизвестная ошибка
    

    After successful initialization, you can begin to search for available WiDi adapters. This is done using the StartScanForAdapters function .

    HRESULT StartScanForAdapters();
    

    To notify about the adapter found, the message WM_WIDI_ADAPTER_DISCOVERED is used . The lParam parameter will be a pointer to the adapter identifier. This identifier is required to connect to the selected adapter.

    After the search is completed, the window will receive the message WM_WIDI_SCAN_COMPLETE . The wParam parameter will contain code, the analysis of which will help determine why the scan was completed:

    RC_SUCCESS                    // Поиск успешно завершен
    RC_UNABLE_TO_START_SCAN    // Поиск не удалось запустить
    RC_INTERNAL_ERROR           // Произошла внутренняя ошибка
    RC_WIDI_APPLICATION_ERROR   // Произошла внутренняя ошибка приложения для работы с WiDi 
    RC_CONNECT_CANCELLED_SCAN // Поиск был прерван
    


    If one or more devices were detected, you can proceed with the connection. 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 the message WM_WIDI_CONNECTED . In case of problems - WM_WIDI_DISCONNECT_FAILED , the wParam parameter will contain the code:

    RC_CONNECTION_DROPPED    // Подключение не было установлено
    RC_USER_DISCONNECT         // Подключение было прервано пользователем
    

    The adapter identifier will be passed to the lParam parameter .

    That's all for now. For more information on the capabilities of the WiDi Extensions SDK, you can study the documentation that comes with the SDK. There will be questions - ask here, in the comments, or on the Intel Software Network forum .

    Also popular now: