Ocean
VCDescriptor.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_SYSTEM_USB_VIDEO_VC_DESCRIPTOR_H
9 #define META_OCEAN_SYSTEM_USB_VIDEO_VC_DESCRIPTOR_H
10 
12 
14 
15 namespace Ocean
16 {
17 
18 namespace System
19 {
20 
21 namespace USB
22 {
23 
24 namespace Video
25 {
26 
27 /**
28  * This class implements the base class for all video control descriptors.
29  * @see http://www.cajunbot.com/wiki/images/8/85/USB_Video_Class_1.1.pdf
30  * @ingroup systemusbvideo
31  */
32 class VCDescriptor : public Descriptor
33 {
34  public:
35 
36  /**
37  * Definition of individual video control interfaces types.
38  * Video Class-Specific VC Interface Descriptor Subtypes.
39  */
41  {
42  /// Undefined descriptor.
44  /// Video interface header descriptor.
45  VC_HEADER = 0x01u,
46  /// This descriptor describes the input terminal that represents a camera or other video source.
48  /// This descriptor describes the output terminal that represents the USB pipe to the host.
50  /// This descriptor describes the selector unit that is connected to the processing unit. Either the CCD sensor or media transport mechanism can be selected as the input.
52  /// This descriptor describes the processing unit that processes the video stream data that is delivered by the selector unit. The only control supported by this implementation is the brightness control.
54  /// Extension unit descriptor.
55  VC_EXTENSION_UNIT = 0x06u
56  };
57 };
58 
59 /**
60  * Class-Specific VC Interface Descriptor (VC_HEADER).
61  *
62  * The class-specific VC interface descriptor is a concatenation of all the descriptors that are used
63  * to fully describe the video function, i.e., all Unit Descriptors (UDs) and Terminal Descriptors
64  * (TDs).
65  *
66  * The total length of the class-specific VC interface descriptor depends on the number of Units and
67  * Terminals in the video function. Therefore, the descriptor starts with a header that reflects the
68  * total length in bytes of the entire class-specific VC interface descriptor in the wTotalLength
69  * field. The bcdUVC field identifies the release of the Video Device Class Specification with
70  * which this video function and its descriptors are compliant. The bInCollection field indicates
71  * how many VideoStreaming interfaces there are in the Video Interface Collection to which this
72  * VideoControl interface belongs. The baInterfaceNr() array contains the interface numbers of all
73  * the VideoStreaming interfaces in the Collection. The bInCollection and baInterfaceNr() fields
74  * together provide all necessary information to determine which interfaces together constitute the
75  * entire USB interface to the video function, i.e., describe the Video Interface Collection.
76  *
77  * The order in which the Unit and Terminal descriptors are reported is not important, because
78  * every descriptor can be identified through its bDescriptorType and bDescriptorSubtype fields.
79  *
80  * http://www.cajunbot.com/wiki/images/8/85/USB_Video_Class_1.1.pdf
81  * @ingroup systemusb
82  */
83 class OCEAN_SYSTEM_USB_VIDEO_EXPORT VCHeaderDescriptor : public VCDescriptor
84 {
85  friend class Descriptor;
86 
87  public:
88 
89  /**
90  * Default constructor creating an invalid descriptor.
91  */
92  VCHeaderDescriptor() = default;
93 
94  /**
95  * Creates a new header descriptor from memory.
96  * @param buffer The memory buffer in which the descriptor is located, must be valid
97  * @param size The size of the buffer, in bytes, with range [12, infinity)
98  */
99  VCHeaderDescriptor(const void* buffer, const size_t size);
100 
101  /**
102  * Returns the content of this descriptor as string.
103  * @return The string representation of this descriptor
104  */
105  std::string toString() const;
106 
107  /**
108  * Returns whether this object holds valid descriptor information.
109  * @return True, if so
110  */
111  bool isValid() const;
112 
113  protected:
114 
115  /// Size of this descriptor, in bytes: 12+n.
116  uint8_t bLength_ = 0u;
117 
118  /// CS_INTERFACE descriptor type.
119  uint8_t bDescriptorType_ = 0u;
120 
121  /// VC_HEADER descriptor subtype.
122  uint8_t bDescriptorSubtype_ = 0u;
123 
124  public:
125 
126  /// Video Device Class Specification release number in binary-coded decimal. (i.e. 2.10 is 210H).
127  uint16_t bcdUVC_ = 0u;
128 
129  /// Total number of bytes returned for the class-specific VideoControl interface descriptor. Includes the combined length of this descriptor header and all Unit and Terminal descriptors.
130  uint16_t wTotalLength_ = 0u;
131 
132  /**
133  * Use of this field has been deprecated.
134  *
135  * The device clock frequency in Hz. This will specify the units used for the time information fields in the Video Payload Headers of the primary data stream and format.
136  *
137  * The dwClockFrequency field of the Video Probe and Commit control replaces this descriptor field.
138  * A value for this field shall be chosen such that the primary or default function of the device will be available to host software that implements Version 1.0 of this specification.
139  */
140  uint32_t dwClockFrequency_ = 0u;
141 
142  /// The number of VideoStreaming interfaces in the Video Interface Collection to which this VideoControl interface belongs: n
143  uint8_t bInCollection_ = 0u;
144 
145  /// Interface number of the first VideoStreaming interface in the Collection.
146  std::vector<uint8_t> baInterfaceNr_;
147 };
148 
149 /**
150  * Input Terminal Descriptor (VC_INPUT_TERMINAL)
151  *
152  * The Input Terminal descriptor (ITD) provides information to the Host that is related to the
153  * functional aspects of the Input Terminal.
154  *
155  * The Input Terminal is uniquely identified by the value in the bTerminalID field. No other Unit
156  * or Terminal within the same video function may have the same ID. This value must be passed in
157  * the bTerminalID field of each request that is directed to the Terminal.
158  *
159  * The wTerminalType field provides pertinent information about the physical entity that the Input
160  * Terminal represents. This could be a USB OUT endpoint, an external Composite Video In
161  * connection, a camera sensor, etc. A complete list of Terminal Type codes is provided in section
162  * B.2, "Input Terminal Types".
163  *
164  * The bAssocTerminal field is used to associate an Output Terminal to this Input Terminal,
165  * effectively implementing a bi-directional Terminal pair. An example of this would be a tape unit
166  * on a camcorder, which would have Input and Output Terminals to sink and source video
167  * respectively. If the bAssocTerminal field is used, both associated Terminals must belong to the
168  * bi-directional Terminal Type group. If no association exists, the bAssocTerminal field must be
169  * set to zero.
170  *
171  * The Host software can treat the associated Terminals as being physically related. In many cases,
172  * one Terminal can not exist without the other. An index to a string descriptor is provided to
173  * further describe the Input Terminal
174  *
175  * @see http://www.cajunbot.com/wiki/images/8/85/USB_Video_Class_1.1.pdf
176  * @ingroup systemusb
177  */
178 class OCEAN_SYSTEM_USB_VIDEO_EXPORT VCInputTerminalDescriptor : public VCDescriptor
179 {
180  friend class Descriptor;
181 
182  public:
183 
184  /**
185  * Definition of individual terminal types.
186  */
187  enum InputTerminalType : uint16_t
188  {
189  /// Undefined input terminal type.
191  /// Vendor-Specific Input Terminal.
192  ITT_VENDOR_SPECIFIC = 0x200u,
193  /// Camera sensor. To be used only in Camera Terminal descriptors.
194  ITT_CAMERA = 0x0201u,
195  /// Sequential media. To be used only in Media Transport Terminal Descriptors.
196  ITT_MEDIA_TRANSPORT_INPUT = 0x0202u
197  };
198 
199  /**
200  * Definition of Camera Terminal Control Selectors.
201  */
202  enum ControlSelector : uint8_t
203  {
204  CT_CONTROL_UNDEFINED = 0x00u,
205  CT_SCANNING_MODE_CONTROL = 0x01u,
206  CT_AE_MODE_CONTROL = 0x02u,
207  CT_AE_PRIORITY_CONTROL = 0x03u,
208  CT_EXPOSURE_TIME_ABSOLUTE_CONTROL = 0x04u,
209  CT_EXPOSURE_TIME_RELATIVE_CONTROL = 0x05u,
210  CT_FOCUS_ABSOLUTE_CONTROL = 0x06u,
211  CT_FOCUS_RELATIVE_CONTROL = 0x07u,
212  CT_FOCUS_AUTO_CONTROL = 0x08u,
213  CT_IRIS_ABSOLUTE_CONTROL = 0x09u,
214  CT_IRIS_RELATIVE_CONTROL = 0x0Au,
215  CT_ZOOM_ABSOLUTE_CONTROL = 0x0Bu,
216  CT_ZOOM_RELATIVE_CONTROL = 0x0Cu,
217  CT_PANTILT_ABSOLUTE_CONTROL = 0x0Du,
218  CT_PANTILT_RELATIVE_CONTROL = 0x0Eu,
219  CT_ROLL_ABSOLUTE_CONTROL = 0x0Fu,
220  CT_ROLL_RELATIVE_CONTROL = 0x10u,
221  CT_PRIVACY_CONTROL = 0x11u
222  };
223 
224  public:
225 
226  /**
227  * Default constructor creating an invalid descriptor.
228  */
230 
231  /**
232  * Creates a new input terminal descriptor from memory.
233  * @param buffer The memory buffer in which the descriptor is located, must be valid
234  * @param size The size of the buffer, in bytes, with range [8, infinity)
235  */
236  VCInputTerminalDescriptor(const void* buffer, const size_t size);
237 
238  /**
239  * Returns the content of this descriptor as string.
240  * @param usbDeviceHandle Optional handle of the device associated with this descriptor to provide the terminal description
241  * @return The string representation of this descriptor
242  */
243  std::string toString(libusb_device_handle* usbDeviceHandle = nullptr) const;
244 
245  /**
246  * Returns whether this input terminal supports a specified control.
247  * This descriptor must have type ITT_CAMERA (wTerminalType_).
248  * @param controlSelector The control to be checked, must be valid
249  * @return True, if so
250  */
251  bool isControlSupported(const ControlSelector controlSelector) const;
252 
253  /**
254  * Returns whether this object holds valid descriptor information.
255  * @return True, if so
256  */
257  bool isValid() const;
258 
259  protected:
260 
261  /// Size of this descriptor, in bytes: 8+ n (e.g., 15+n for ITT_CAMERA).
262  uint8_t bLength_ = 0u;
263 
264  /// CS_INTERFACE descriptor type.
265  uint8_t bDescriptorType_ = 0u;
266 
267  /// VC_INPUT_TERMINAL descriptor subtype.
268  uint8_t bDescriptorSubtype_ = 0u;
269 
270  public:
271 
272  /// Constant A non-zero constant that uniquely identifies the Terminal within the video function. This value is used in all requests to address this Terminal.
273  uint8_t bTerminalID_ = 0u;
274 
275  /// Constant that characterizes the type of Terminal. See Appendix B, "Terminal Types".
276  uint16_t wTerminalType_ = 0u;
277 
278  /// ID of the Output Terminal to which this Input Terminal is associated, or zero (0) if no such association exists.
279  uint8_t bAssocTerminal_ = 0u;
280 
281  /// Index of a string descriptor, describing the Input Terminal.
282  uint8_t iTerminal_ = 0u;
283 
284  /// The value of Lmin (see section 2.4.2.5.1 "Optical Zoom"). If Optical Zoom is not supported, this field shall be set to 0.
285  uint16_t wObjectiveFocalLengthMin_ = 0u;
286 
287  /// The value of Lmax (see section 2.4.2.5.1 "Optical Zoom"). If Optical Zoom is not supported, this field shall be set to 0.
288  uint16_t wObjectiveFocalLengthMax_ = 0u;
289 
290  /// The value of Locular (see section 2.4.2.5.1 "Optical Zoom"). If Optical Zoom is not supported, this field shall be set to 0.
291  uint16_t wOcularFocalLength_ = 0u;
292 
293  /// Size in bytes of the bmControls field: n
294  uint8_t bControlSize_ = 0u;
295 
296  /**
297  * A bit set to 1 indicates that the mentioned Control is supported for the video stream.
298  * D0: Scanning Mode
299  * D1: Auto-Exposure Mode
300  * D2: Auto-Exposure Priority
301  * D3: Exposure Time (Absolute)
302  * D4: Exposure Time (Relative)
303  * D5: Focus (Absolute)
304  * D6: Focus (Relative)
305  * D7: Iris (Absolute)
306  * D8: Iris (Relative)
307  * D9: Zoom (Absolute)
308  * D10: Zoom (Relative)
309  * D11: PanTilt (Absolute)
310  * D12: PanTilt (Relative)
311  * D13: Roll (Absolute)
312  * D14: Roll (Relative)
313  * D15: Reserved
314  * D16: Reserved
315  * D17: Focus, Auto
316  * D18: Privacy
317  * D19..(n*8-1): Reserved, set to zero
318  */
319  std::vector<uint8_t> bmControls_;
320 };
321 
322 /**
323  * Processing Unit Descriptor (VC_PROCESSING_UNIT).
324  *
325  * The Processing Unit is uniquely identified by the value in the bUnitID field of the Processing
326  * Unit descriptor (PUD). No other Unit or Terminal within the same video function may have the
327  * same ID. This value must be passed with each request that is directed to the Processing Unit.
328  *
329  * The bSourceID field is used to describe the connectivity for this Processing Unit. It contains the
330  * ID of the Unit or Terminal to which this Processing Unit is connected via its Input Pin. The
331  * bmControls field is a bit-map, indicating the availability of certain processing Controls for the
332  * video stream. For future expandability, the number of bytes occupied by the bmControls field is
333  * indicated in the bControlSize field. The bControlSize field is permitted to specify a value less
334  * than the value needed to cover all the control bits (including zero), in which case the unspecified
335  * bmControls bytes will not be present and the corresponding control bits are assumed to be zero.
336  *
337  * An index to a string descriptor is provided to further describe the Processing Unit.
338  *
339  * @see http://www.cajunbot.com/wiki/images/8/85/USB_Video_Class_1.1.pdf
340  * @ingroup systemusb
341  */
342 class OCEAN_SYSTEM_USB_VIDEO_EXPORT VCProcessingUnitDescriptor : public VCDescriptor
343 {
344  friend class Descriptor;
345 
346  public:
347 
348  /**
349  * Definition of Processing Unit Control Selectors.
350  */
351  enum ControlSelector : uint8_t
352  {
353  PU_CONTROL_UNDEFINED = 0x00u,
354  PU_BACKLIGHT_COMPENSATION_CONTROL = 0x01u,
355  PU_BRIGHTNESS_CONTROL = 0x02u,
356  PU_CONTRAST_CONTROL = 0x03u,
357  PU_GAIN_CONTROL = 0x04u,
358  PU_POWER_LINE_FREQUENCY_CONTROL = 0x05u,
359  PU_HUE_CONTROL = 0x06u,
360  PU_SATURATION_CONTROL = 0x07u,
361  PU_SHARPNESS_CONTROL = 0x08u,
362  PU_GAMMA_CONTROL = 0x09u,
363  PU_WHITE_BALANCE_TEMPERATURE_CONTROL = 0x0Au,
364  PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL = 0x0Bu,
365  PU_WHITE_BALANCE_COMPONENT_CONTROL = 0x0Cu,
366  PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL = 0x0Du,
367  PU_DIGITAL_MULTIPLIER_CONTROL = 0x0Eu,
368  PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL = 0x0Fu,
369  PU_HUE_AUTO_CONTROL = 0x10u,
370  PU_ANALOG_VIDEO_STANDARD_CONTROL = 0x11u,
371  PU_ANALOG_LOCK_STATUS_CONTROL = 0x12u
372  };
373 
374  public:
375 
376  /**
377  * Default constructor creating an invalid descriptor.
378  */
380 
381  /**
382  * Creates a new processing unit descriptor from memory.
383  * @param buffer The memory buffer in which the descriptor is located, must be valid
384  * @param size The size of the buffer, in bytes, with range [10, infinity)
385  */
386  VCProcessingUnitDescriptor(const void* buffer, const size_t size);
387 
388  /**
389  * Returns the content of this descriptor as string.
390  * @param usbDeviceHandle Optional handle of the device associated with this descriptor to provide the terminal description
391  * @return The string representation of this descriptor
392  */
393  std::string toString(libusb_device_handle* usbDeviceHandle = nullptr) const;
394 
395  /**
396  * Returns whether this input terminal supports a specified control.
397  * This descriptor must have type ITT_CAMERA (wTerminalType_).
398  * @param controlSelector The control to be checked, must be valid
399  * @return True, if so
400  */
401  bool isControlSupported(const ControlSelector controlSelector) const;
402 
403  /**
404  * Returns whether this object holds valid descriptor information.
405  * @return True, if so
406  */
407  bool isValid() const;
408 
409  protected:
410 
411  /// Size of this descriptor, in bytes: 10+n.
412  uint8_t bLength_ = 0u;
413 
414  /// CS_INTERFACE descriptor type.
415  uint8_t bDescriptorType_ = 0u;
416 
417  /// VC_PROCESSING_UNIT descriptor subtype.
418  uint8_t bDescriptorSubtype_ = 0u;
419 
420  public:
421 
422  /// A non-zero constant that uniquely identifies the Unit within the video function. This value is used in all requests to address this Unit.
423  uint8_t bUnitID_ = 0u;
424 
425  /// ID of the Unit or Terminal to which this Unit is connected.
426  uint8_t bSourceID_ = 0u;
427 
428  /**
429  * If the Digital Multiplier control is supported, this field indicates the maximum digital magnification, multiplied by 100.
430  * For example, for a device that supports 1-4.5X digital zoom (a multiplier of 4.5), this field would be set to 450. If the Digital Multiplier control is not supported, this field shall be set to 0.
431  */
432  uint16_t wMaxMultiplier_ = 0u;
433 
434  /// Size of the bmControls field, in bytes: n.
435  uint8_t bControlSize_ = 0u;
436 
437  /**
438  * A bit set to 1 indicates that the mentioned Control is supported for the video stream.
439  * D0: Brightness
440  * D1: Contrast
441  * D2: Hue
442  * D3: Saturation
443  * D4: Sharpness
444  * D5: Gamma
445  * D6: White Balance Temperature
446  * D7: White Balance Component
447  * D8: Backlight Compensation
448  * D9: Gain
449  * D10: Power Line Frequency
450  * D11: Hue, Auto
451  * D12: White Balance Temperature, Auto
452  * D13: White Balance Component, Auto
453  * D14: Digital Multiplier
454  * D15: Digital Multiplier Limit
455  * D16: Analog Video Standard
456  * D17: Analog Video Lock Status
457  * D18..(n*8-1): Reserved. Set to zero.
458  */
459  std::vector<uint8_t> bmControls_;
460 
461  // Index of a string descriptor that describes this processing unit.
462  uint8_t iProcessing_ = 0u;
463 
464  /**
465  * A bitmap of all analog video standards supported by the Processing Unit.
466  * A value of zero indicates that this bitmap should be ignored.
467  * D0: None
468  * D1: NTSC – 525/60
469  * D2: PAL – 625/50
470  * D3: SECAM – 625/50
471  * D4: NTSC – 625/50
472  * D5: PAL – 525/60
473  */
474  uint8_t bmVideoStandards_ = 0u;
475 };
476 
477 /**
478  * Selector Unit Descriptor (VC_SELECTOR_UNIT).
479  *
480  * The Selector Unit is uniquely identified by the value in the bUnitID field of the Selector Unit
481  * descriptor (SUD). No other Unit or Terminal within the same video function may have the same
482  * ID. This value must be passed with each request that is directed to the Selector Unit.
483  *
484  * The bNrInPins field contains the number of Input Pins (p) of the Selector Unit. The connectivity
485  * of the Input Pins is described via the baSourceID() array that contains p elements. The index i
486  * into the array is one-based and directly related to the Input Pin numbers. baSourceID(i) contains
487  * the ID of the Unit or Terminal to which Input Pin i is connected.
488  *
489  * An index to a string descriptor is provided to further describe the Selector Unit.
490  *
491  * @see http://www.cajunbot.com/wiki/images/8/85/USB_Video_Class_1.1.pdf
492  * @ingroup systemusb
493  */
494 class OCEAN_SYSTEM_USB_VIDEO_EXPORT VCSelectorUnitDescriptor : public VCDescriptor
495 {
496  friend class Descriptor;
497 
498  public:
499 
500  /**
501  * Default constructor creating an invalid descriptor.
502  */
504 
505  /**
506  * Creates a new selector unit descriptor from memory.
507  * @param buffer The memory buffer in which the descriptor is located, must be valid
508  * @param size The size of the buffer, in bytes, with range [6, infinity)
509  */
510  VCSelectorUnitDescriptor(const void* buffer, const size_t size);
511 
512  /**
513  * Returns the content of this descriptor as string.
514  * @param usbDeviceHandle Optional handle of the device associated with this descriptor to provide the terminal description
515  * @return The string representation of this descriptor
516  */
517  std::string toString(libusb_device_handle* usbDeviceHandle = nullptr) const;
518 
519  /**
520  * Returns whether this object holds valid descriptor information.
521  * @return True, if so
522  */
523  bool isValid() const;
524 
525  protected:
526 
527  /// Size of this descriptor, in bytes: 6+p.
528  uint8_t bLength_ = 0u;
529 
530  /// Constant CS_INTERFACE descriptor type.
531  uint8_t bDescriptorType_ = 0u;
532 
533  /// VC_SELECTOR_UNIT descriptor subtype.
534  uint8_t bDescriptorSubtype_ = 0u;
535 
536  public:
537 
538  /// A non-zero constant that uniquely identifies the Unit within the video function. This value is used in all requests to address this Unit.
539  uint8_t bUnitID_ = 0u;
540 
541  /// Number of Input Pins of this Unit: p.
542  uint8_t bNrInPins_ = 0u;
543 
544  /// ID of the Unit or Terminal to which the Input Pins of this Selector Unit is connected.
545  std::vector<uint8_t> baSourceID_;
546 
547  /// Index of a string descriptor, describing the Selector Unit.
548  uint8_t iSelector_ = 0u;
549 };
550 
551 /**
552  * Extension Unit Descriptor (VC_EXTENSION_UNIT)
553  *
554  * The Extension Unit is uniquely identified by the value in the bUnitID field of the Extension Unit
555  * descriptor (XUD). No other Unit or Terminal within the same video function may have the same
556  * ID. This value must be passed with each request that is directed to the Extension Unit.
557  *
558  * The Extension Unit Descriptor allows the hardware designer to define any arbitrary set of
559  * controls such that a class driver can act as an intermediary between vendor-supplied host
560  * software and functionality of the device.
561  *
562  * The guidExtensionCode field contains a vendor-specific code that further identifies the
563  * Extension Unit.
564  *
565  * The bNrInPins field contains the number of Input Pins (p) of the Extension Unit. The
566  * connectivity of the Input Pins is described via the baSourceID() array that contains p elements.
567  * The index i into the array is one-based and directly related to the Input Pin numbers.
568  * baSourceID(i) contains the ID of the Unit or Terminal to which Input Pin i is connected.
569  *
570  * The bmControls field is a bitmap, indicating the availability of certain video Controls in the
571  * Extension Unit. For future expandability, the number of bytes occupied by the bmControls field
572  * is indicated in the bControlSize field. All Controls are optional.
573  *
574  * An index to a string descriptor is provided to further describe the Extension Unit.
575  *
576  * @see http://www.cajunbot.com/wiki/images/8/85/USB_Video_Class_1.1.pdf
577  * @ingroup systemusb
578  */
579 class OCEAN_SYSTEM_USB_VIDEO_EXPORT VCExtensionUnitDescriptor : public VCDescriptor
580 {
581  friend class Descriptor;
582 
583  public:
584 
585  /**
586  * Default constructor creating an invalid descriptor.
587  */
589 
590  /**
591  * Creates a new extension unit descriptor from memory.
592  * @param buffer The memory buffer in which the descriptor is located, must be valid
593  * @param size The size of the buffer, in bytes, with range [24, infinity)
594  */
595  VCExtensionUnitDescriptor(const void* buffer, const size_t size);
596 
597  /**
598  * Returns the content of this descriptor as string.
599  * @param usbDeviceHandle Optional handle of the device associated with this descriptor to provide the terminal description
600  * @return The string representation of this descriptor
601  */
602  std::string toString(libusb_device_handle* usbDeviceHandle = nullptr) const;
603 
604  /**
605  * Returns whether this object holds valid descriptor information.
606  * @return True, if so
607  */
608  bool isValid() const;
609 
610  protected:
611 
612  /// Size of this descriptor, in bytes: 24+p+n.
613  uint8_t bLength_ = 0u;
614 
615  /// CS_INTERFACE descriptor type.
616  uint8_t bDescriptorType_ = 0u;
617 
618  /// VC_EXTENSION_UNIT descriptor subtype.
619  uint8_t bDescriptorSubtype_ = 0u;
620 
621  public:
622 
623  /// A non-zero constant that uniquely identifies the Unit within the video function. This value is used in all requests to address this Unit.
624  uint8_t bUnitID_ = 0u;
625 
626  /// Vendor-specific code identifying the Extension Unit (GUID).
627  uint8_t guidExtensionCode_[16];
628 
629  /// Number of controls in this extension unit.
630  uint8_t bNumControls_ = 0u;
631 
632  /// Number of Input Pins of this Unit: p.
633  uint8_t bNrInPins_ = 0u;
634 
635  /// IDs of the Unit or Terminal to which the Input Pins of this Extension Unit is connected.
636  std::vector<uint8_t> baSourceID_;
637 
638  /// Size of the bmControls field, in bytes: n.
639  uint8_t bControlSize_ = 0u;
640 
641  /// A bit set to 1 indicates that the mentioned Control is supported: D(n*8-1)..0: Vendor-specific
642  std::vector<uint8_t> bmControls_;
643 
644  /// Index of a string descriptor that describes this extension unit.
645  uint8_t iExtension_ = 0u;
646 };
647 
648 }
649 
650 }
651 
652 }
653 
654 }
655 
656 #endif // META_OCEAN_SYSTEM_USB_VIDEO_VC_DESCRIPTOR_H
This class implements the base class for all interface descriptors.
Definition: system/usb/Descriptor.h:29
This class implements the base class for all video control descriptors.
Definition: VCDescriptor.h:33
VideoControlInterfaceTypes
Definition of individual video control interfaces types.
Definition: VCDescriptor.h:41
@ VC_HEADER
Video interface header descriptor.
Definition: VCDescriptor.h:45
@ VC_PROCESSING_UNIT
This descriptor describes the processing unit that processes the video stream data that is delivered ...
Definition: VCDescriptor.h:53
@ VC_SELECTOR_UNIT
This descriptor describes the selector unit that is connected to the processing unit....
Definition: VCDescriptor.h:51
@ VC_DESCRIPTOR_UNDEFINED
Undefined descriptor.
Definition: VCDescriptor.h:43
@ VC_EXTENSION_UNIT
Extension unit descriptor.
Definition: VCDescriptor.h:55
@ VC_OUTPUT_TERMINAL
This descriptor describes the output terminal that represents the USB pipe to the host.
Definition: VCDescriptor.h:49
@ VC_INPUT_TERMINAL
This descriptor describes the input terminal that represents a camera or other video source.
Definition: VCDescriptor.h:47
Extension Unit Descriptor (VC_EXTENSION_UNIT)
Definition: VCDescriptor.h:580
bool isValid() const
Returns whether this object holds valid descriptor information.
std::vector< uint8_t > bmControls_
A bit set to 1 indicates that the mentioned Control is supported: D(n*8-1)..0: Vendor-specific.
Definition: VCDescriptor.h:642
std::string toString(libusb_device_handle *usbDeviceHandle=nullptr) const
Returns the content of this descriptor as string.
VCExtensionUnitDescriptor()=default
Default constructor creating an invalid descriptor.
VCExtensionUnitDescriptor(const void *buffer, const size_t size)
Creates a new extension unit descriptor from memory.
std::vector< uint8_t > baSourceID_
IDs of the Unit or Terminal to which the Input Pins of this Extension Unit is connected.
Definition: VCDescriptor.h:636
Class-Specific VC Interface Descriptor (VC_HEADER).
Definition: VCDescriptor.h:84
VCHeaderDescriptor()=default
Default constructor creating an invalid descriptor.
std::string toString() const
Returns the content of this descriptor as string.
bool isValid() const
Returns whether this object holds valid descriptor information.
VCHeaderDescriptor(const void *buffer, const size_t size)
Creates a new header descriptor from memory.
std::vector< uint8_t > baInterfaceNr_
Interface number of the first VideoStreaming interface in the Collection.
Definition: VCDescriptor.h:146
Input Terminal Descriptor (VC_INPUT_TERMINAL)
Definition: VCDescriptor.h:179
InputTerminalType
Definition of individual terminal types.
Definition: VCDescriptor.h:188
@ ITT_UNDEFINED
Undefined input terminal type.
Definition: VCDescriptor.h:190
bool isValid() const
Returns whether this object holds valid descriptor information.
std::string toString(libusb_device_handle *usbDeviceHandle=nullptr) const
Returns the content of this descriptor as string.
bool isControlSupported(const ControlSelector controlSelector) const
Returns whether this input terminal supports a specified control.
VCInputTerminalDescriptor()=default
Default constructor creating an invalid descriptor.
VCInputTerminalDescriptor(const void *buffer, const size_t size)
Creates a new input terminal descriptor from memory.
ControlSelector
Definition of Camera Terminal Control Selectors.
Definition: VCDescriptor.h:203
std::vector< uint8_t > bmControls_
A bit set to 1 indicates that the mentioned Control is supported for the video stream.
Definition: VCDescriptor.h:319
Processing Unit Descriptor (VC_PROCESSING_UNIT).
Definition: VCDescriptor.h:343
VCProcessingUnitDescriptor()=default
Default constructor creating an invalid descriptor.
bool isControlSupported(const ControlSelector controlSelector) const
Returns whether this input terminal supports a specified control.
VCProcessingUnitDescriptor(const void *buffer, const size_t size)
Creates a new processing unit descriptor from memory.
bool isValid() const
Returns whether this object holds valid descriptor information.
std::string toString(libusb_device_handle *usbDeviceHandle=nullptr) const
Returns the content of this descriptor as string.
ControlSelector
Definition of Processing Unit Control Selectors.
Definition: VCDescriptor.h:352
std::vector< uint8_t > bmControls_
A bit set to 1 indicates that the mentioned Control is supported for the video stream.
Definition: VCDescriptor.h:459
Selector Unit Descriptor (VC_SELECTOR_UNIT).
Definition: VCDescriptor.h:495
bool isValid() const
Returns whether this object holds valid descriptor information.
std::string toString(libusb_device_handle *usbDeviceHandle=nullptr) const
Returns the content of this descriptor as string.
VCSelectorUnitDescriptor(const void *buffer, const size_t size)
Creates a new selector unit descriptor from memory.
std::vector< uint8_t > baSourceID_
ID of the Unit or Terminal to which the Input Pins of this Selector Unit is connected.
Definition: VCDescriptor.h:545
VCSelectorUnitDescriptor()=default
Default constructor creating an invalid descriptor.
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15