Fix issue 1) not recognizes some usb device, 2) reconnect when ffmpeg encoder error
[rtmpclient.git] / app / src / main / jni / libusb-1.0.22 / libusb / os / windows_nt_common.h
1 /*
2  * Windows backend common header for libusb 1.0
3  *
4  * This file brings together header code common between
5  * the desktop Windows backends.
6  * Copyright © 2012-2013 RealVNC Ltd.
7  * Copyright © 2009-2012 Pete Batard <pete@akeo.ie>
8  * With contributions from Michael Plante, Orin Eman et al.
9  * Parts of this code adapted from libusb-win32-v1 by Stephan Meyer
10  * Major code testing contribution by Xiaofan Chen
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25  */
26
27 #pragma once
28
29 #include "windows_nt_shared_types.h"
30
31  /* Windows versions */
32 enum windows_version {
33         WINDOWS_UNDEFINED,
34         WINDOWS_2000,
35         WINDOWS_XP,
36         WINDOWS_2003,   // Also XP x64
37         WINDOWS_VISTA,
38         WINDOWS_7,
39         WINDOWS_8,
40         WINDOWS_8_1,
41         WINDOWS_10,
42         WINDOWS_11_OR_LATER
43 };
44
45 extern enum windows_version windows_version;
46
47 /* This call is only available from Vista */
48 extern BOOL (WINAPI *pCancelIoEx)(HANDLE, LPOVERLAPPED);
49
50 struct windows_backend {
51         int (*init)(struct libusb_context *ctx);
52         void (*exit)(struct libusb_context *ctx);
53         int (*get_device_list)(struct libusb_context *ctx,
54                 struct discovered_devs **discdevs);
55         int (*open)(struct libusb_device_handle *dev_handle);
56         void (*close)(struct libusb_device_handle *dev_handle);
57         int (*get_device_descriptor)(struct libusb_device *device, unsigned char *buffer);
58         int (*get_active_config_descriptor)(struct libusb_device *device,
59                 unsigned char *buffer, size_t len);
60         int (*get_config_descriptor)(struct libusb_device *device,
61                 uint8_t config_index, unsigned char *buffer, size_t len);
62         int (*get_config_descriptor_by_value)(struct libusb_device *device,
63                 uint8_t bConfigurationValue, unsigned char **buffer);
64         int (*get_configuration)(struct libusb_device_handle *dev_handle, int *config);
65         int (*set_configuration)(struct libusb_device_handle *dev_handle, int config);
66         int (*claim_interface)(struct libusb_device_handle *dev_handle, int interface_number);
67         int (*release_interface)(struct libusb_device_handle *dev_handle, int interface_number);
68         int (*set_interface_altsetting)(struct libusb_device_handle *dev_handle,
69                 int interface_number, int altsetting);
70         int (*clear_halt)(struct libusb_device_handle *dev_handle,
71                 unsigned char endpoint);
72         int (*reset_device)(struct libusb_device_handle *dev_handle);
73         void (*destroy_device)(struct libusb_device *dev);
74         int (*submit_transfer)(struct usbi_transfer *itransfer);
75         int (*cancel_transfer)(struct usbi_transfer *itransfer);
76         void (*clear_transfer_priv)(struct usbi_transfer *itransfer);
77         int (*copy_transfer_data)(struct usbi_transfer *itransfer, uint32_t io_size);
78         int (*get_transfer_fd)(struct usbi_transfer *itransfer);
79         void (*get_overlapped_result)(struct usbi_transfer *itransfer,
80                 DWORD *io_result, DWORD *io_size);
81 };
82
83 struct windows_context_priv {
84         const struct windows_backend *backend;
85 };
86
87 union windows_device_priv {
88         struct usbdk_device_priv usbdk_priv;
89         struct winusb_device_priv winusb_priv;
90 };
91
92 union windows_device_handle_priv {
93         struct usbdk_device_handle_priv usbdk_priv;
94         struct winusb_device_handle_priv winusb_priv;
95 };
96
97 union windows_transfer_priv {
98         struct usbdk_transfer_priv usbdk_priv;
99         struct winusb_transfer_priv winusb_priv;
100 };
101
102 extern const struct windows_backend usbdk_backend;
103 extern const struct windows_backend winusb_backend;
104
105 unsigned long htab_hash(const char *str);
106 void windows_force_sync_completion(OVERLAPPED *overlapped, ULONG size);
107
108 #if defined(ENABLE_LOGGING)
109 const char *windows_error_str(DWORD error_code);
110 #endif