forked from charlieh0tel/google-libusb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglibusb_endpoint_internal.h
83 lines (62 loc) · 2.55 KB
/
glibusb_endpoint_internal.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright 2012 Google Inc. All Rights Reserved.
//
// Wrapper for libusb's endpoints.
#ifndef _GLIBUSB_GLIBUSB_ENDPOINT_INTERNAL_H_
#define _GLIBUSB_GLIBUSB_ENDPOINT_INTERNAL_H_
#include <stddef.h>
#include <stdint.h>
#include <libusb.h>
#include "glibusb_endpoint.h"
class Notification;
namespace glibusb {
class Buffer;
// Provides an interface to allow reading from a USB endpoint.
class PhysicalUsbInEndpoint : public UsbInEndpoint {
public:
virtual ~PhysicalUsbInEndpoint();
private:
friend class PhysicalUsbDevice; // For constructor
// Constructs an endpoint given the context, handle, and a descriptor of the
// endpoint. The context and handle must remain valid throughout the
// lifetime of this object.
PhysicalUsbInEndpoint(struct libusb_context *context,
struct libusb_device_handle *handle,
const struct libusb_endpoint_descriptor *descriptor);
virtual int DoGetMaxPacketSize();
virtual int DoGetMaxIsoPacketSize();
// Actually executes the read, with the length, timeout, buffer, and
// notification.
virtual IoStatus DoRead(
uint32_t length, int32_t timeout_milliseconds, Buffer *out,
Notification *quit);
// Libusb handles and endpoint information.
struct libusb_context *libusb_context_;
struct libusb_device_handle *handle_;
PhysicalUsbInEndpoint(const PhysicalUsbInEndpoint &) = delete;
void operator=(const PhysicalUsbInEndpoint &) = delete;
};
// Provides an interface to allow writing to a USB endpoint.
class PhysicalUsbOutEndpoint : public UsbOutEndpoint {
public:
virtual ~PhysicalUsbOutEndpoint();
private:
friend class PhysicalUsbDevice; // For constructor
// Constructs an endpoint given the context, handle, and a descriptor of the
// endpoint. The context and handle must remain valid throughout the
// lifetime of this object.
PhysicalUsbOutEndpoint(struct libusb_context *context,
struct libusb_device_handle *handle,
const struct libusb_endpoint_descriptor *descriptor);
virtual int DoGetMaxPacketSize();
virtual int DoGetMaxIsoPacketSize();
// Implements the actual write.
virtual IoStatus DoWrite(const Buffer &buffer,
int32_t timeout_milliseconds);
// Libusb handles and endpoint information.
struct libusb_context *libusb_context_;
struct libusb_device_handle *handle_;
PhysicalUsbOutEndpoint(const PhysicalUsbOutEndpoint &) = delete;
void operator=(const PhysicalUsbOutEndpoint &) = delete;
};
} // namespace glibusb
#endif // _GLIBUSB_GLIBUSB_ENDPOINT_INTERNAL_H_