Ocean
VSDescriptor.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_VS_DESCRIPTOR_H
9 #define META_OCEAN_SYSTEM_USB_VIDEO_VS_DESCRIPTOR_H
10 
12 
13 #include "ocean/base/Frame.h"
14 
16 
17 namespace Ocean
18 {
19 
20 namespace System
21 {
22 
23 namespace USB
24 {
25 
26 namespace Video
27 {
28 
29 /**
30  * This class implements the base class for all video streaming descriptors.
31  *
32  * @see http://www.cajunbot.com/wiki/images/8/85/USB_Video_Class_1.1.pdf
33  * @ingroup systemusbvideo
34  */
35 class VSDescriptor : public Descriptor
36 {
37  public:
38 
39  /**
40  * Definition of individual video streaming interfaces types.
41  * Video Class-Specific VS Interface Descriptor Subtypes.
42  */
44  {
45  /// Undefined descriptor.
46  VS_UNDEFINED = 0x00u,
47  /// The Input Header descriptor is used for VS interfaces that contain an IN endpoint for streaming video data.
48  VS_INPUT_HEADER = 0x01u,
49  /// The Output Header descriptor for VS interfaces that contain an OUT endpoint for streaming video data.
51  /// Descriptor for still images.
52  VS_STILL_FRAME = 0x03u,
53  /// Format descriptor for uncompressed streams.
55  /// Image descriptor for uncompressed stream.
57  /// Format descriptor for MJPEG streams.
58  VS_FORMAT_MJPEG = 0x06u,
59  /// Image descriptor for MJPEG stream.
60  VS_FRAME_MJPEG = 0x07u,
61  /// Color format descriptor for any stream.
62  VS_COLORFORMAT = 0x0Du,
63  /// Format descriptor for frame-based streams.
65  /// Image descriptor for frame-based stream.
66  VS_FRAME_FRAME_BASED = 0x11u
67  };
68 
69  protected:
70 
71  /**
72  * Returns the frame intervals of a given descriptor.
73  * @param descriptor The descriptor from which the intervals will be extracted
74  * @param frameRates Optional resulting vector holding the individual frame rates, one for each interval
75  * @return The descriptor's frame intervals, in 100ns
76  * @tparam TDescriptor The type of the descriptor
77  */
78  template <typename TDescriptor>
79  static Indices32 frameIntervals(const TDescriptor& descriptor, std::vector<double>* frameRates = nullptr);
80 };
81 
82 /**
83  * Input Header Descriptor (VS_INPUT_HEADER).
84  *
85  * The Input Header descriptor is used for VS interfaces that contain an IN endpoint for streaming video data.
86  * It provides information on the number of different format descriptors that will follow it, as well as the total size of all class-specific descriptors in alternate setting zero of this interface.
87  *
88  * @see http://www.cajunbot.com/wiki/images/8/85/USB_Video_Class_1.1.pdf
89  * @ingroup systemusbvideo
90  */
91 class OCEAN_SYSTEM_USB_VIDEO_EXPORT VSInputHeaderDescriptor : public VSDescriptor
92 {
93  friend class Descriptor;
94 
95  public:
96 
97  /**
98  * Default constructor creating an invalid descriptor.
99  */
101 
102  /**
103  * Creates a new input header descriptor from memory.
104  * @param buffer The memory buffer in which the descriptor is located, must be valid
105  * @param size The size of the buffer, in bytes, with range [13, infinity)
106  */
107  VSInputHeaderDescriptor(const void* buffer, const size_t size);
108 
109  /**
110  * Returns the endpoint address of this descriptor.
111  * @return The descriptor's endpoint address
112  */
113  inline uint8_t endpointAddress() const;
114 
115  /**
116  * Returns the content of this descriptor as string.
117  * @return The string representation of this descriptor
118  */
119  std::string toString() const;
120 
121  /**
122  * Returns whether this object holds valid descriptor information.
123  * @return True, if so
124  */
125  bool isValid() const;
126 
127  protected:
128 
129  /// Size of this descriptor, in bytes.
130  uint8_t bLength_ = 0u;
131 
132  /// CS_INTERFACE descriptor type.
133  uint8_t bDescriptorType_ = 0u;
134 
135  /// VS_INPUT_HEADER descriptor subtype.
136  uint8_t bDescriptorSubtype_ = 0u;
137 
138  public:
139 
140  /// Number of video payload format descriptors following for this interface (excluding video frame descriptors): p.
141  uint8_t bNumFormats_ = 0u;
142 
143  /// Total number of bytes returned for the class-specific VideoStreaming interface descriptors including this header descriptor.
144  uint16_t wTotalLength_ = 0u;
145 
146  /**
147  * The address of the isochronous or bulk endpoint used for video data.
148  * The address is encoded as follows:
149  * D7: Direction
150  * 1 = IN endpoint
151  * D6..4: Reserved, set to zero.
152  * D3..0: The endpoint number, determined by the designer.
153  */
154  uint8_t bEndpointAddress_ = 0u;
155 
156  /**
157  * Indicates the capabilities of this VideoStreaming interface:
158  * D0: Dynamic Format Change supported
159  * D7..1: Reserved, set to zero.
160  */
161  uint8_t bmInfo_ = 0u;
162 
163  /// The terminal ID of the Output Terminal to which the video endpoint of this interface is connected.
164  uint8_t bTerminalLink_ = 0u;
165 
166  /**
167  * Method of still image capture supported as described in section 2.4.2.4, "Still Image Capture":
168  * 0: None (Host software will not support any form of still image capture)
169  * 1: Method 1
170  * 2: Method 2
171  * 3: Method 3
172  */
173  uint8_t bStillCaptureMethod_ = 0u;
174 
175  /**
176  * Specifies if hardware triggering is supported through this interface
177  * 0: Not supported
178  * 1: Supported
179  */
180  uint8_t bTriggerSupport_= 0u;
181 
182  /**
183  * Specifies how the host software shall respond to a hardware trigger interrupt event from this interface. This is ignored if the bTriggerSupport field is zero.
184  * 0: Initiate still image capture
185  * 1: General purpose button event. Host driver will notify client application of button press and button release events
186  */
187  uint8_t bTriggerUsage_ = 0u;
188 
189  /**
190  * Size of each bmaControls(x) field, in bytes: n
191  */
192  uint8_t bControlSize_ = 0u;
193 
194  /**
195  * 'bNumFormats' entries of control bitmaps
196  *
197  * For bits D3..0, a bit set to 1 indicates that the named field is supported by the Video Probe and Commit Control when bFormatIndex is 1:
198  * D0: wKeyFrameRate
199  * D1: wPFrameRate
200  * D2: wCompQuality
201  * D3: wCompWindowSize
202  * For bits D5..4, a bit set to 1 indicates that the named control is supported by the device when bFormatIndex is 1:
203  * D4: Generate Key Frame
204  * D5: Update Frame Segment
205  * D6..(n*8-1): Reserved, set to zero
206  */
207  std::vector<std::vector<uint8_t>> bmaControls_;
208 };
209 
210 /**
211  * UncompressedVideoFormatDescriptor (VS_FORMAT_UNCOMPRESSED)
212  *
213  * The Uncompressed Video Format descriptor defines the characteristics of a specific video stream.
214  * It is used for formats that carry uncompressed video information, including all YUV variants.
215  *
216  * A Terminal corresponding to a USB IN or OUT endpoint, and the interface it belongs to, supports one or more format definitions.
217  * To select a particular format, host software sends control requests to the corresponding interface.
218  *
219  * The bFormatIndex field contains the one-based index of this format descriptor, and is used by requests from the host to set and get the current video format.
220  *
221  * The guidFormat field uniquely identifies the video data format that shall be used when communicating with this interface at the corresponding format index.
222  * For a video source function, the host software will deploy the corresponding video format decoder (if necessary) based on the format specified in this field.
223  *
224  * The bAspectRatioX and bAspectRatioY fields specify the X and Y dimensions of the picture aspect ratio respectively for video field (interlaced) data.
225  * For example, bAspectRatioX will be 16 and bAspectRatioY will be 9 for a 16:9 display.
226  *
227  * An Uncompressed Video Format Descriptor is followed by one or more Uncompressed Video Frame Descriptor(s);
228  * each Video Frame Descriptor conveys information specific to a frame size supported for the format.
229  *
230  * http://www.cajunbot.com/wiki/images/8/88/USB_Video_Payload_Uncompressed_1.1.pdf
231  * @ingroup systemusbvideo
232  */
233 class OCEAN_SYSTEM_USB_VIDEO_EXPORT VSUncompressedVideoFormatDescriptor : public VSDescriptor
234 {
235  public:
236 
237  /**
238  * Default constructor creating an invalid descriptor.
239  */
241 
242  /**
243  * Creates a new format descriptor from memory.
244  * @param buffer The memory buffer in which the descriptor is located, must be valid
245  * @param size The size of the buffer, in bytes, must be 27
246  */
247  VSUncompressedVideoFormatDescriptor(const void* buffer, const size_t size);
248 
249  /**
250  * Returns the pixel format of this descriptor.
251  * @return The descriptor's pixel format, FORMAT_UNDEFINED if unknown
252  */
253  inline FrameType::PixelFormat pixelFormat() const;
254 
255  /**
256  * Returns the content of this descriptor as string.
257  * @return The string representation of this descriptor
258  */
259  std::string toString() const;
260 
261  /**
262  * Returns whether this object holds valid descriptor information.
263  * @return True, if so
264  */
265  bool isValid() const;
266 
267  /**
268  * Translates a GUID to the corresponding pixel format.
269  * @param guidFormat The GUID to translate, must be valid
270  * @return The corresponding pixel format, FORMAT_UNDEFINED if unknown
271  */
272  static FrameType::PixelFormat translatePixelFormat(const uint8_t guidFormat[16]);
273 
274  protected:
275 
276  /// Size of this descriptor in byte: 27
277  uint8_t bLength_ = 0u;
278 
279  /// CS_INTERFACE descriptor type
280  uint8_t bDescriptorType_ = 0u;
281 
282  /// VS_FORMAT_UNCOMPRESSED descriptor subtype
283  uint8_t bDescriptorSubtype_ = 0u;
284 
285  public:
286 
287  /// Index of this format descriptor (stating with 1)
288  uint8_t bFormatIndex_ = 0u;
289 
290  /// Number of frame descriptors following
291  uint8_t bNumFrameDescriptors_ = 0u;
292 
293  /// GUID Globally Unique Identifier used to identify stream-encoding format
294  uint8_t guidFormat_[16] = {};
295 
296  /// Number of bits per pixel used to specify color in the decoded video frame
297  uint8_t bBitsPerPixel_ = 0u;
298 
299  /// Optimum Frame Index (used to select resolution) for this stream
300  uint8_t bDefaultFrameIndex_ = 0u;
301 
302  /// The X dimension of the picture aspect ratio
303  uint8_t bAspectRatioX_ = 0u;
304 
305  /// The Y dimension of the picture aspect ratio
306  uint8_t bAspectRatioY_ = 0u;
307 
308  /**
309  * Specifies interlace information.
310  * If the scanning mode control in the Camera Terminal is supported for this stream, this field shall reflect the field format used in interlaced mode.
311  * (Top field in PAL is field 1, top field in NTSC is field 2.):
312  * D0: Interlaced stream or variable. 1 = Yes
313  * D1: Fields per frame. 0= 2 fields, 1 = 1 field
314  * D2: Field 1 first. 1 = Yes
315  * D3: Reserved
316  * D5..4: Field pattern
317  * 00 = Field 1 only
318  * 01 = Field 2 only
319  * 10 = Regular pattern of fields 1 and 2
320  * 11 = Random pattern of fields 1 and 2
321  * D7..6: Reserved. Do not use.
322  */
323  uint8_t bmInterlaceFlags_ = 0u;
324 
325  /// Boolean Specifies whether duplication of the video stream is restricted: 0: No restrictions 1: Restrict duplication
326  uint8_t bCopyProtect_ = 0u;
327 };
328 
329 /**
330  * Uncompressed Frame Descriptor (VS_FRAME_UNCOMPRESSED).
331  *
332  * Uncompressed Video Frame descriptors (or Frame descriptors for short) are used to describe the decoded video and still-image frame dimensions and other frame-specific characteristics supported by a particular stream.
333  * One or more Frame descriptors follow the Uncompressed Video Format descriptor they correspond to.
334  * The Frame descriptor is also used to determine the range of frame intervals supported for the frame size specified.
335  *
336  * The Uncompressed Video Frame descriptor is used only for video formats for which the Uncompressed Video Format descriptor applies (see section 3.1.1, "Uncompressed Video Format Descriptor").
337  *
338  * The bFrameIndex field contains the one-based index of this frame descriptor, and is used by requests from the host to set and get the current frame index for the format in use.
339  * This index is one-based for each corresponding format descriptor supported by the device.
340  *
341  * The range of frame intervals supported can be either a continuous range or a discrete set of values.
342  * For a continuous range, dwMinFrameInterval, dwMaxFrameInterval and dwFrameIntervalStep indicate the limits and granularity of the range.
343  * For discrete values, the dwFrameInterval(x) fields indicate the range of frame intervals (and therefore frame rates) supported at this frame size.
344  * The frame interval is the average display time of a single decoded video frame in 100ns units.
345  *
346  * http://www.cajunbot.com/wiki/images/8/88/USB_Video_Payload_Uncompressed_1.1.pdf
347  * @ingroup systemusbvideo
348  */
349 class OCEAN_SYSTEM_USB_VIDEO_EXPORT VSUncompressedVideoFrameDescriptor : public VSDescriptor
350 {
351  friend class Descriptor;
352 
353  public:
354 
355  /**
356  * Default constructor creating an invalid descriptor.
357  */
359 
360  /**
361  * Creates a new frame descriptor from memory.
362  * @param buffer The memory buffer in which the descriptor is located, must be valid
363  * @param size The size of the buffer, in bytes, with range [27, infinity)
364  */
365  VSUncompressedVideoFrameDescriptor(const uint8_t* buffer, const size_t size);
366 
367  /**
368  * Returns the frame intervals of this descriptor.
369  * @param frameRates Optional resulting vector holding the individual frame rates, one for each interval
370  * @return The descriptor's frame intervals, in 100ns
371  */
372  Indices32 frameIntervals(std::vector<double>* frameRates = nullptr) const;
373 
374  /**
375  * Returns the content of this descriptor as string.
376  * @return The string representation of this descriptor
377  */
378  std::string toString() const;
379 
380  /**
381  * Returns whether this object holds valid descriptor information.
382  * @return True, if so
383  */
384  bool isValid() const;
385 
386  private:
387 
388  /**
389  * Size of this descriptor in bytes when bFrameIntervalType is 0: 38
390  * Size of this descriptor in bytes when bFrameIntervalType > 0: 26+(4*n)
391  */
392  uint8_t bLength_ = 0u;
393 
394  /// CS_INTERFACE descriptor type
395  uint8_t bDescriptorType_ = 0u;
396 
397  /// VS_FRAME_UNCOMPRESSED descriptor subtype
398  uint8_t bDescriptorSubtype_ = 0u;
399 
400  public:
401 
402  /// Index of this frame descriptor.
403  uint8_t bFrameIndex_ = 0u;
404 
405  /**
406  * D0: Still image supported Specifies whether still images are supported at this frame setting.
407  * This is only applicable for VS interfaces with an IN video endpoint using Still Image Capture Method 1, and should be set to 0 in all other cases.
408  *
409  * D1: Fixed frame-rate Specifies whether the device provides a fixed frame rate on a stream associated with this frame descriptor.
410  */
411  uint8_t bmCapabilities_ = 0u;
412 
413  /// Number Height of decoded bitmap frame in pixels
414  uint16_t wWidth_ = 0u;
415 
416  /// Number Height of decoded bitmap frame in pixels
417  uint16_t wHeight_ = 0u;
418 
419  /// Specifies the minimum bit rate at the longest frame interval in units of bps at which the data can be transmitted.
420  uint32_t dwMinBitRate_ = 0u;
421 
422  /// Specifies the maximum bit rate at the shortest frame interval in units of bps at which the data can be transmitted.
423  uint32_t dwMaxBitRate_ = 0u;
424 
425  /**
426  * Use of this field has been deprecated.
427  *
428  * Specifies the maximum number of bytes that the compressor will produce for a video frame or still image.
429  * The dwMaxVideoFrameSize field of the Video Probe and Commit control replaces this descriptor field.
430  * A value for this field shall be chosen for compatibility with host software that implements an earlier version of this specification.
431  */
432  uint32_t dwMaxVideoFrameBufferSize_ = 0u;
433 
434  /// Number Specifies the frame interval the device would like to indicate for use as a default. This must be a valid frame interval described in the fields below.
435  uint32_t dwDefaultFrameInterval_ = 0u;
436 
437  /// Indicates how the frame interval can be programmed: 0: Continuous frame interval 1..255: The number of discrete frame intervals supported (n)
438  uint8_t bFrameIntervalType_ = 0u;
439 
440  /**
441  * For continuous Frame Intervals:
442  * Shortest frame interval supported (at highest frame rate), in 100 ns units.
443  */
444  uint32_t dwMinFrameInterval_ = 0u;
445 
446  /**
447  * For continuous Frame Intervals:
448  * Longest frame interval supported (at lowest frame rate), in 100 ns units
449  */
450  uint32_t dwMaxFrameInterval_ = 0u;
451 
452  /**
453  * For continuous Frame Intervals:
454  * Indicates granularity of frame interval range, in 100 ns units.
455  */
456  uint32_t dwFrameIntervalStep_ = 0u;
457 
458  /**
459  * For discrete Frame Intervals
460  * First entry: Shortest frame interval supported (at highest frame rate), in 100 ns units.
461  * ...
462  * Last entry: Longest frame interval supported (at lowest frame rate), in 100 ns units.
463  */
465 };
466 
467 /**
468  * Frame Based Payload Video Format Descriptor (VS_FORMAT_FRAME_BASED).
469  *
470  * The Frame Based Payload Video Format descriptor defines the characteristics of a specific video stream.
471  * It is used for formats that carry Frame Based Payload video information.
472  *
473  * A Terminal corresponding to a USB IN or OUT endpoint, and the interface it belongs to, supports one or more format definitions.
474  * To select a particular format, host software sends control requests to the corresponding interface.
475  *
476  * The bFormatIndex field contains the one-based index of this format descriptor, and is used by requests from the host to set and get the current video format.
477  *
478  * The guidFormat field uniquely identifies the video data format that shall be used when communicating with this interface at the corresponding format index.
479  * For a video source function, the host software will deploy the corresponding video format decoder (if necessary) based on the format specified in this field.
480  *
481  * The bAspectRatioX and bAspectRatioY fields specify the X and Y dimensions of the picture aspect ratio, respectively.
482  * For example, bAspectRatioX will be 16 and bAspectRatioY will be 9 for a 16:9 display.
483  *
484  * A Frame Based Payload Video Format Descriptor is followed by one or more Frame Based Payload Video Frame Descriptor(s);
485  * each Video Frame Descriptor conveys information specific to a frame size supported for the format.
486  *
487  * http://cajunbot.com/wiki/images/3/3a/USB_Video_Payload_Frame_Based_1.1.pdf
488  * @ingroup systemusbvideo
489  */
490 class OCEAN_SYSTEM_USB_VIDEO_EXPORT VSFrameBasedVideoFormatDescriptor : public VSDescriptor
491 {
492  public:
493 
494  /**
495  * Definition of individual encoding formats.
496  */
497  enum EncodingFormat : uint32_t
498  {
499  /// Invalid encoding format.
500  EF_INVALID = 0u,
501  /// The encoding is using H.264
503  /// The encoding is using H.265
504  EF_H265
505  };
506 
507  public:
508 
509  /**
510  * Default constructor creating an invalid descriptor.
511  */
513 
514  /**
515  * Creates a new format descriptor from memory.
516  * @param buffer The memory buffer in which the descriptor is located, must be valid
517  * @param size The size of the buffer, in bytes, must be 28
518  */
519  VSFrameBasedVideoFormatDescriptor(const void* buffer, const size_t size);
520 
521  /**
522  * Returns the content of this descriptor as string.
523  * @return The string representation of this descriptor
524  */
525  std::string toString() const;
526 
527  /**
528  * Returns the encoding format of this descriptor.
529  * @return The encoding format, EF_INVALID if unknown
530  */
531  inline EncodingFormat encodingFormat() const;
532 
533  /**
534  * Returns whether this object holds valid descriptor information.
535  * @return True, if so
536  */
537  bool isValid() const;
538 
539  /**
540  * Translates a GUID to the corresponding encoding format.
541  * @param guidFormat The GUID to translate, must be valid
542  * @return The encoding format, EF_INVALID if unknown
543  */
544  static EncodingFormat translateEncodingFormat(const uint8_t guidFormat[16]);
545 
546  /**
547  * Translates an encoding format to a string.
548  * @param encodingFormat The encoding format to translate
549  * @return The string representation of the encoding format, 'Invalid' if unknown
550  */
551  static std::string translateEncodingFormat(const EncodingFormat encodingFormat);
552 
553  protected:
554 
555  /// Size of this descriptor in bytes: 28.
556  uint8_t bLength_ = 0u;
557 
558  /// CS_INTERFACE descriptor type.
559  uint8_t bDescriptorType_ = 0u;
560 
561  /// VS_FORMAT_FRAME_BASED descriptor subtype.
562  uint8_t bDescriptorSubtype_ = 0u;
563 
564  public:
565 
566  /// Index of this format descriptor.
567  uint8_t bFormatIndex_ = 0u;
568 
569  /// Number of frame descriptors following that correspond to this format.
570  uint8_t bNumFrameDescriptors_ = 0u;
571 
572  /// Globally Unique Identifier used to identify stream-encoding format.
573  uint8_t guidFormat_[16] = {};
574 
575  /// Number of bits per pixel used to specify color in the decoded video frame. May be zero if not applicable.
576  uint8_t bBitsPerPixel_ = 0u;
577 
578  /// Optimum Frame Index (used to select resolution) for this stream.
579  uint8_t bDefaultFrameIndex_ = 0u;
580 
581  /// The X dimension of the picture aspect ratio.
582  uint8_t bAspectRatioX_ = 0u;
583 
584  /// The Y dimension of the picture aspect ratio.
585  uint8_t bAspectRatioY_ = 0u;
586 
587  /**
588  * Specifies interlace information.
589  * If the scanning mode control in the Camera Terminal is supported for this stream, this field shall reflect the field format used in interlaced mode.
590  * (Top field in PAL is field 1, top field in NTSC is field 2.):
591  * D0: Interlaced stream or variable. 1 = Yes
592  * D1: Fields per frame. 0= 2 fields, 1 = 1 field
593  * D2: Field 1 first. 1 = Yes
594  * D3: Reserved
595  * D5..4: Field pattern
596  * 00 = Field 1 only
597  * 01 = Field 2 only
598  * 10 = Regular pattern of fields 1 and 2
599  * 11 = Random pattern of fields 1 and 2
600  * D7..6: Reserved. Do not use.
601  */
602  uint8_t bmInterlaceFlags_ = 0u;
603 
604  /**
605  * Specifies whether duplication of the video stream is restricted:
606  * FALSE (0): No restrictions
607  * TRUE (1): Restrict duplication
608  */
609  uint8_t bCopyProtect_ = 0u;
610 
611  /**
612  * Specifies whether the data within the frame is of variable length from frame to frame.
613  * TRUE (1): Variable Size
614  * FALSE (0): Fixed Size
615  * If bVariableSize is TRUE (1), then dwBytesPerLine (below) must be set to zero (0).
616  */
617  uint8_t bVariableSize_ = 0u;
618 };
619 
620 /**
621  * Frame Based Payload Frame Descriptor (VS_FRAME_FRAME_BASED).
622  *
623  * Frame Based Payload Video Frame descriptors (or Frame descriptors for short) are used to
624  * describe the decoded video and still-image frame dimensions and other frame-specific
625  * characteristics supported by a particular stream. One or more Frame descriptors follow the
626  * Frame Based Payload Video Format descriptor they correspond to. The Frame descriptor is also
627  * used to determine the range of frame intervals supported for the frame size specified.
628  *
629  * The bFrameIndex field contains the one-based index of this frame descriptor, and is used by
630  * requests from the host to set and get the current frame index for the format in use. This index is
631  * one-based for each corresponding format descriptor supported by the device.
632  *
633  * The range of frame intervals supported can be either a continuous range or a discrete set of
634  * values. For a continuous range, dwMinFrameInterval, dwMaxFrameInterval and
635  * dwFrameIntervalStep indicate the limits and granularity of the range. For discrete values, the
636  * dwFrameInterval(x) fields indicate the range of frame intervals (and therefore frame rates)
637  * supported at this frame size. The frame interval is the average display time of a single decoded
638  * video frame in 100ns units.
639  *
640  * http://cajunbot.com/wiki/images/3/3a/USB_Video_Payload_Frame_Based_1.1.pdf
641  * @ingroup systemusbvideo
642  */
643 class OCEAN_SYSTEM_USB_VIDEO_EXPORT VSFrameBasedFrameDescriptor : public VSDescriptor
644 {
645  friend class Descriptor;
646 
647  public:
648 
649  /**
650  * Default constructor creating an invalid descriptor.
651  */
653 
654  /**
655  * Creates a new frame descriptor from memory.
656  * @param buffer The memory buffer in which the descriptor is located, must be valid
657  * @param size The size of the buffer, in bytes, must be 27
658  */
659  VSFrameBasedFrameDescriptor(const void* buffer, const size_t size);
660 
661  /**
662  * Returns the frame intervals of this descriptor.
663  * @param frameRates Optional resulting vector holding the individual frame rates, one for each interval
664  * @return The descriptor's frame intervals, in 100ns
665  */
666  Indices32 frameIntervals(std::vector<double>* frameRates = nullptr) const;
667 
668  /**
669  * Returns the content of this descriptor as string.
670  * @return The string representation of this descriptor
671  */
672  std::string toString() const;
673 
674  /**
675  * Returns whether this object holds valid descriptor information.
676  * @return True, if so
677  */
678  bool isValid() const;
679 
680  private:
681 
682  /// Size of this descriptor in bytes when bFrameIntervalType is 0: 38 Size of this descriptor in bytes when bFrameIntervalType > 0: 26+(4*n)
683  uint8_t bLength_ = 0u;
684 
685  /// CS_INTERFACE descriptor type
686  uint8_t bDescriptorType_ = 0u;
687 
688  /// VS_FRAME_FRAME_BASED descriptor subtype
689  uint8_t bDescriptorSubtype_ = 0u;
690 
691  public:
692 
693  /// Index of this frame descriptor
694  uint8_t bFrameIndex_ = 0u;
695 
696  /// D0: Still image supported Specifies whether still images are supported at this frame setting.
697  uint8_t bmCapabilities_ = 0u;
698 
699  /// Width of decoded bitmap frame in pixels
700  uint16_t wWidth_ = 0u;
701 
702  /// Height of decoded bitmap frame in pixels
703  uint16_t wHeight_ = 0u;
704 
705  /// Specifies the minimum bit rate at the longest frame interval in units of bps at which the data can be transmitted.
706  uint32_t dwMinBitRate_ = 0u;
707 
708  /// Specifies the maximum bit rate at the shortest frame interval in units of bps at which the data can be transmitted.
709  uint32_t dwMaxBitRate_ = 0u;
710 
711  /// Specifies the frame interval the device would like to indicate for use as a default. This must be a valid frame interval described in the fields below.
712  uint32_t dwDefaultFrameInterval_ = 0u;
713 
714  /// Indicates how the frame interval can be programmed: 0: Continuous frame interval 1..255: The number of discrete frame intervals supported (n)
715  uint8_t bFrameIntervalType_ = 0u;
716 
717  /**
718  * Specifies the number of bytes per line of video for packed fixed frame size formats, allowing the receiver to perform stride alignment of the video.
719  * If the bVariableSize value (above) is TRUE (1), or if the format does not permit such alignment, this value shall be set to zero (0).
720  */
721  uint32_t dwBytesPerLine_ = 0u;
722 
723  /// Shortest frame interval supported (at highest frame rate), in 100 ns units.
724  uint32_t dwMinFrameInterval_ = 0u;
725 
726  /// Longest frame interval supported (at lowest frame rate), in 100 ns units.
727  uint32_t dwMaxFrameInterval_ = 0u;
728 
729  /// Indicates granularity of frame interval range, in 100 ns units.
730  uint32_t dwFrameIntervalStep_ = 0u;
731 
732  /**
733  * For discrete Frame Intervals
734  * First entry: Shortest frame interval supported (at highest frame rate), in 100 ns units.
735  * ...
736  * Last entry: Longest frame interval supported (at lowest frame rate), in 100 ns units.
737  */
739 };
740 
741 
742 /**
743  * Color Matching Descriptor (VS_COLORFORMAT).
744  *
745  * The Color Matching descriptor is an optional descriptor used to describe the color profile of the video data in an unambiguous way.
746  * Only one instance is allowed for a given format and if present, the Color Matching descriptor shall be placed following the Video and Still Image Frame descriptors for that format.
747  *
748  * For example, this descriptor would be used with Uncompressed Video, MJPEG and MPEG-1 formats.
749  * It would not be used in the case MPEG-2, DV or MPEG-4 because the information is already available implicitly (DV) or explicitly (MPEG-2, MPEG-4).
750  * If a format requires this descriptor, the corresponding payload specification must enforce this requirement.
751  * In the absence of this descriptor, or in the case of “Unspecified” values within the descriptor, color matching defaults will be assumed.
752  * The color matching defaults are compliant with sRGB since the BT.709 transfer function and the sRGB transfer function are very similar.
753  *
754  * The viewing conditions and monitor setup are implicitly based on sRGB and the device should compensate for them (D50 ambient white, dim viewing or 64 lux ambient illuminance, 2.2 gamma reference CRT, etc).
755  *
756  * http://www.cajunbot.com/wiki/images/8/85/USB_Video_Class_1.1.pdf
757  * @ingroup systemusbvideo
758  */
759 class OCEAN_SYSTEM_USB_VIDEO_EXPORT VSColorMatchingDescriptor : public VSDescriptor
760 {
761  public:
762 
763  /**
764  * Default constructor creating an invalid descriptor.
765  */
767 
768  /**
769  * Creates a new color matching descriptor from memory.
770  * @param buffer The memory buffer in which the descriptor is located, must be valid
771  * @param size The size of the buffer, in bytes, must be 6
772  */
773  VSColorMatchingDescriptor(const void* buffer, const size_t size);
774 
775  /**
776  * Returns the content of this descriptor as string.
777  * @return The string representation of this descriptor
778  */
779  std::string toString() const;
780 
781  /**
782  * Returns whether this object holds valid descriptor information.
783  * @return True, if so
784  */
785  bool isValid() const;
786 
787  private:
788 
789  /// Size of this descriptor in bytes, 6.
790  uint8_t bLength_ = 0u;
791 
792  /// CS_INTERFACE descriptor type
793  uint8_t bDescriptorType_ = 0u;
794 
795  /// VS_COLORFORMAT descriptor subtype
796  uint8_t bDescriptorSubtype_ = 0u;
797 
798  public:
799 
800  /**
801  * This defines the color primaries and the reference white.
802  * 0: Unspecified (Image characteristics unknown)
803  * 1: BT.709, sRGB (default)
804  * 2: BT.470-2 (M)
805  * 3: BT.470-2 (B, G)
806  * 4: SMPTE 170M
807  * 5: SMPTE 240M
808  * 6-255: Reserved
809  */
810  uint8_t bColorPrimaries_ = 0u;
811 
812  /**
813  * This field defines the optoelectronic transfer characteristic of the source picture also called the gamma function.
814  * 0: Unspecified (Image characteristics unknown)
815  * 1: BT.709 (default)
816  * 2: BT.470-2 M
817  * 3: BT.470-2 B, G
818  * 4: SMPTE 170M
819  * 5: SMPTE 240M
820  * 6: Linear (V = Lc)
821  * 7: sRGB (very similar to BT.709)
822  * 8-255: Reserved
823  */
824  uint8_t bTransferCharacteristics_ = 0u;
825 
826  /**
827  * Matrix used to compute luma and chroma values from the color primaries.
828  * 0: Unspecified (Image characteristics unknown)
829  * 1: BT. 709
830  * 2: FCC
831  * 3: BT.470-2 B, G
832  * 4: SMPTE 170M (BT.601, default)
833  * 5: SMPTE 240M
834  * 6-255: Reserved
835  */
836  uint8_t bMatrixCoefficients_ = 0u;
837 };
838 
839 /**
840  * MJPEG Video Format Descriptor (VS_FORMAT_MJPEG).
841  *
842  * The MJPEG Video Format Descriptor defines the characteristics of a specific video stream.
843  * It is used for formats that carry MJPEG video information, including all YUV/RGB variants.
844  * A Terminal corresponding to a USB IN or OUT endpoint, and the interface it belongs to, supports one or more format definitions.
845  * To select a particular format, host software sends control requests to the corresponding interface.
846  *
847  * The bFormatIndex field contains the one-based index of this format Descriptor, and is used by requests from the host to set and get the current video format.
848  * The bDescriptorSubtype field uniquely identifies the video data format that should be used when communicating with this interface at the corresponding format index.
849  * For a video source function, the host software will deploy the corresponding video format decoder (if necessary) based on the format specified in this field.
850  *
851  * The bAspectRatioX and bAspectRatioY fields specify the X and Y dimensions respectively of the picture aspect ratio for video field (interlaced) data.
852  * For example, bAspectRatioX will be 16 and bAspectRatioY will be 9 for a 16:9 display.
853  *
854  * The bmFlags field holds information about the video data stream characteristics.
855  * FixedSizeSamples indicates whether all video samples are the same size.
856  * A MJPEG Video Format Descriptor is followed by one or more MJPEG Video Frame Descriptor(s);
857  * each Video Frame Descriptor conveys information specific to a frame size supported for the format.
858  *
859  * @see http://www.cajunbot.com/wiki/images/7/71/USB_Video_Payload_MJPEG_1.1.pdf.
860  * @ingroup systemusbvideo
861  */
862 class OCEAN_SYSTEM_USB_VIDEO_EXPORT VSMJPEGVideoFormatDescriptor : public VSDescriptor
863 {
864  public:
865 
866  /**
867  * Default constructor creating an invalid descriptor.
868  */
870 
871  /**
872  * Creates a new format descriptor from memory.
873  * @param buffer The memory buffer in which the descriptor is located, must be valid
874  * @param size The size of the buffer, in bytes, must be 11
875  */
876  VSMJPEGVideoFormatDescriptor(const void* buffer, const size_t size);
877 
878  /**
879  * Returns the content of this descriptor as string.
880  * @return The string representation of this descriptor
881  */
882  std::string toString() const;
883 
884  /**
885  * Returns whether this object holds valid descriptor information.
886  * @return True, if so
887  */
888  bool isValid() const;
889 
890  protected:
891 
892  /// Size of this Descriptor, in bytes: 11.
893  uint8_t bLength_ = 0u;
894 
895  /// CS_INTERFACE Descriptor type.
896  uint8_t bDescriptorType_ = 0u;
897 
898  /// VS_FORMAT_MJPEG Descriptor subtype.
899  uint8_t bDescriptorSubtype_ = 0u;
900 
901  public:
902 
903  /// Index of this Format Descriptor.
904  uint8_t bFormatIndex_ = 0u;
905 
906  /// Number of Frame Descriptors following that correspond to this format.
907  uint8_t bNumFrameDescriptors_ = 0u;
908 
909  /**
910  * Specifies characteristics of this format
911  * D0: FixedSizeSamples. 1 = Yes
912  * All other bits are reserved for future use and shall be reset to zero.
913  */
914  uint8_t bmFlags_ = 0u;
915 
916  /// Optimum Frame Index (used to select resolution) for this stream.
917  uint8_t bDefaultFrameIndex_ = 0u;
918 
919  /// The X dimension of the picture aspect ratio.
920  uint8_t bAspectRatioX_ = 0u;
921 
922  /// The Y dimension of the picture aspect ratio.
923  uint8_t bAspectRatioY_ = 0u;
924 
925  /**
926  * Specifies interlace information. If the scanning mode control in the Camera Terminal is supported for this stream, this field should reflect the field format used in interlaced mode.
927  * (Top field in PAL is field 1, top field in NTSC is field 2.):
928  * D0: Interlaced stream or variable. 1 = Yes
929  * D1: Fields per frame. 0= 2 fields, 1 = 1 field
930  * D2: Field 1 first. 1 = Yes
931  * D3: Reserved
932  * D5..4: Field pattern
933  * 00 = Field 1 only
934  * 01 = Field 2 only
935  * 10 = Regular pattern of fields 1 and 2
936  * 11 = Random pattern of fields 1 and 2
937  * D7..6: Reserved. Do not use.
938  */
939  uint8_t bmInterlaceFlags_ = 0u;
940 
941  /**
942  * Specifies if duplication of the video stream should be restricted:
943  * 0: No restrictions
944  * 1: Restrict duplication
945  */
946  uint8_t bCopyProtect_ = 0u;
947 };
948 
949 /**
950  * MJPEG Video Frame Descriptors (VS_FRAME_MJPEG).
951  *
952  * MJPEG Video Frame Descriptors (or simply Frame Descriptors) are used to describe the decoded video and still image frame dimensions, and other frame-specific characteristics supported by a particular stream.
953  * One or more Frame Descriptors follow the MJPEG Video Format Descriptor they correspond to.
954  * The Frame Descriptor is also used to determine the range of frame intervals that are supported for the specified frame size.
955  *
956  * The MJPEG Video Frame Descriptor is used only for video formats for which the MJPEG Video Format Descriptor applies (see section 3.1.1, "MJPEG Video Format Descriptor").
957  *
958  * The bFrameIndex field contains the one-based index of this Frame Descriptor, and is used by requests from the host to set and get the current frame index for the format in use.
959  * This index is one-based for each corresponding Format Descriptor supported by the device.
960  *
961  * The range of frame intervals supported can be either a continuous range or a discrete set of values.
962  * For a continuous range, dwMinFrameInterval, dwMaxFrameInterval and dwFrameIntervalStep indicate the limits and granularity of the range.
963  * For discrete values, the dwFrameInterval(x) fields indicate the range of frame intervals (and therefore frame rates) supported at this frame size.
964  * The frame interval is the average display time of a single decoded video frame in 100ns Units.
965  *
966  * @see http://www.cajunbot.com/wiki/images/7/71/USB_Video_Payload_MJPEG_1.1.pdf
967  * @ingroup systemusbvideo
968  */
969 class OCEAN_SYSTEM_USB_VIDEO_EXPORT VSMJPEGVideoFrameDescriptor : public VSDescriptor
970 {
971  friend class Descriptor;
972 
973  public:
974 
975  /**
976  * Default constructor creating an invalid descriptor.
977  */
979 
980  /**
981  * Creates a new frame descriptor from memory.
982  * @param buffer The memory buffer in which the descriptor is located, must be valid
983  * @param size The size of the buffer, in bytes, with range [27, infinity)
984  */
985  VSMJPEGVideoFrameDescriptor(const void* buffer, const size_t size);
986 
987  /**
988  * Returns the frame intervals of this descriptor.
989  * @param frameRates Optional resulting vector holding the individual frame rates, one for each interval
990  * @return The descriptor's frame intervals, in 100ns
991  */
992  Indices32 frameIntervals(std::vector<double>* frameRates = nullptr) const;
993 
994  /**
995  * Returns the content of this descriptor as string.
996  * @return The string representation of this descriptor
997  */
998  std::string toString() const;
999 
1000  /**
1001  * Returns whether this object holds valid descriptor information.
1002  * @return True, if so
1003  */
1004  bool isValid() const;
1005 
1006  protected:
1007 
1008  /**
1009  * Size of this descriptor in bytes when bFrameIntervalType is 0: 38.
1010  * Size of this descriptor in bytes when bFrameIntervalType > 0: 26+(4*n).
1011  */
1012  uint8_t bLength_ = 0u;
1013 
1014  /// CS_INTERFACE Descriptor type.
1015  uint8_t bDescriptorType_ = 0u;
1016 
1017  /// VS_FRAME_MJPEG Descriptor subtype.
1018  uint8_t bDescriptorSubtype_ = 0u;
1019 
1020  public:
1021 
1022  /// Index of this Frame Descriptor.
1023  uint8_t bFrameIndex_ = 0u;
1024 
1025  /**
1026  * D0: Still image supported Specifies whether still images are supported at this frame setting.
1027  * This is only applicable for VS interfaces with an IN video endpoint using Still Image Capture Method 1, and should be set to 0 in all other cases.
1028  *
1029  * D1: Fixed frame-rate Specifies whether the device provides a fixed frame rate on a stream associated with this frame descriptor. Set to 1 if fixed rate is enabled; otherwise, set to 0.
1030  *
1031  * D7..2: Reserved, set to 0.
1032  */
1033  uint8_t bmCapabilities_ = 0u;
1034 
1035  /// Width of decoded bitmap frame in pixels.
1036  uint16_t wWidth_ = 0u;
1037 
1038  /// Height of decoded bitmap frame in pixels.
1039  uint16_t wHeight_ = 0u;
1040 
1041  /// Specifies the minimum bit rate at default compression quality and longest frame interval in Units of bps at which the data can be transmitted.
1042  uint32_t dwMinBitRate_ = 0u;
1043 
1044  /// Specifies the maximum bit rate at default compression quality and shortest frame interval in Units of bps at which the data can be transmitted.
1045  uint32_t dwMaxBitRate_ = 0u;
1046 
1047  /**
1048  * Use of this field has been deprecated.
1049  *
1050  * Specifies the maximum number of bytes for a video (or still image) frame the compressor will produce.
1051  *
1052  * The dwMaxVideoFrameSize field of the Video Probe and Commit control replaces this descriptor field.
1053  * A value for this field shall be chosen for compatibility with host software that implements an earlier version of this specification.
1054  */
1055  uint32_t dwMaxVideoFrameBufferSize_ = 0u;
1056 
1057  /// Specifies the frame interval the device would like to indicate for use as a default. This must be a valid frame interval described in the fields below.
1058  uint32_t dwDefaultFrameInterval_ = 0u;
1059 
1060  /**
1061  * Indicates how the frame interval can be programmed:
1062  * 0: Continuous frame interval
1063  * 1..255: The number of discrete frame intervals supported (n)
1064  */
1065  uint8_t bFrameIntervalType_ = 0u;
1066 
1067  /**
1068  * For continuous Frame Intervals:
1069  * Shortest frame interval supported (at highest frame rate), in 100 ns units.
1070  */
1071  uint32_t dwMinFrameInterval_ = 0u;
1072 
1073  /**
1074  * For continuous Frame Intervals:
1075  * Longest frame interval supported (at lowest frame rate), in 100 ns units
1076  */
1077  uint32_t dwMaxFrameInterval_ = 0u;
1078 
1079  /**
1080  * For continuous Frame Intervals:
1081  * Indicates granularity of frame interval range, in 100 ns units.
1082  */
1083  uint32_t dwFrameIntervalStep_ = 0u;
1084 
1085  /**
1086  * For discrete Frame Intervals
1087  * First entry: Shortest frame interval supported (at highest frame rate), in 100 ns units.
1088  * ...
1089  * Last entry: Longest frame interval supported (at lowest frame rate), in 100 ns units.
1090  */
1092 };
1093 
1094 template <typename TDescriptor>
1095 Indices32 VSDescriptor::frameIntervals(const TDescriptor& descriptor, std::vector<double>* frameRates)
1096 {
1097  if (frameRates != nullptr)
1098  {
1099  frameRates->clear();
1100  }
1101 
1102  if (!descriptor.isValid())
1103  {
1104  return Indices32();
1105  }
1106 
1107  Indices32 result;
1108 
1109  if (descriptor.bFrameIntervalType_ == 0u)
1110  {
1111  // continuous frame intervals mode
1112 
1113  result.reserve(16);
1114 
1115  for (unsigned int frameInterval = descriptor.dwMinFrameInterval_; frameInterval <= descriptor.dwMaxFrameInterval_; frameInterval += descriptor.dwFrameIntervalStep_)
1116  {
1117  result.emplace_back(frameInterval);
1118  }
1119  }
1120  else
1121  {
1122  // discrete frame intervals mode
1123 
1124  result = descriptor.dwFrameInterval_;
1125  }
1126 
1127  if (frameRates != nullptr)
1128  {
1129  frameRates->reserve(result.size());
1130 
1131  for (const uint32_t frameInterval : result)
1132  {
1133  frameRates->emplace_back(interval2frequency(frameInterval));
1134  }
1135  }
1136 
1137  return result;
1138 }
1139 
1141 {
1142  ocean_assert(isValid());
1143 
1144  /*
1145  * The address is encoded as follows:
1146  * D7: Direction
1147  * 1 = IN endpoint
1148  * D6..4: Reserved, set to zero.
1149  * D3..0: The endpoint number, determined by the designer.
1150  */
1151  return bEndpointAddress_ & 0x8Fu;
1152 }
1153 
1155 {
1156  ocean_assert(isValid());
1157  if (!isValid())
1158  {
1160  }
1161 
1163 }
1164 
1166 {
1167  ocean_assert(isValid());
1168  if (!isValid())
1169  {
1170  return EF_INVALID;
1171  }
1172 
1174 }
1175 
1176 }
1177 
1178 }
1179 
1180 }
1181 
1182 }
1183 
1184 #endif // META_OCEAN_SYSTEM_USB_VIDEO_VS_DESCRIPTOR_H
PixelFormat
Definition of all pixel formats available in the Ocean framework.
Definition: Frame.h:183
@ FORMAT_UNDEFINED
Undefined pixel format.
Definition: Frame.h:187
This class implements the base class for all interface descriptors.
Definition: system/usb/Descriptor.h:29
static double interval2frequency(const uint32_t timeInterval)
Converts a time interval (in 100ns) to frequency in Hz.
Color Matching Descriptor (VS_COLORFORMAT).
Definition: VSDescriptor.h:760
VSColorMatchingDescriptor(const void *buffer, const size_t size)
Creates a new color matching descriptor from memory.
VSColorMatchingDescriptor()=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.
This class implements the base class for all video streaming descriptors.
Definition: VSDescriptor.h:36
VideoStreamingInterfaceTypes
Definition of individual video streaming interfaces types.
Definition: VSDescriptor.h:44
@ VS_FRAME_MJPEG
Image descriptor for MJPEG stream.
Definition: VSDescriptor.h:60
@ VS_STILL_FRAME
Descriptor for still images.
Definition: VSDescriptor.h:52
@ VS_COLORFORMAT
Color format descriptor for any stream.
Definition: VSDescriptor.h:62
@ VS_FORMAT_FRAME_BASED
Format descriptor for frame-based streams.
Definition: VSDescriptor.h:64
@ VS_OUTPUT_HEADER
The Output Header descriptor for VS interfaces that contain an OUT endpoint for streaming video data.
Definition: VSDescriptor.h:50
@ VS_INPUT_HEADER
The Input Header descriptor is used for VS interfaces that contain an IN endpoint for streaming video...
Definition: VSDescriptor.h:48
@ VS_FORMAT_UNCOMPRESSED
Format descriptor for uncompressed streams.
Definition: VSDescriptor.h:54
@ VS_UNDEFINED
Undefined descriptor.
Definition: VSDescriptor.h:46
@ VS_FRAME_FRAME_BASED
Image descriptor for frame-based stream.
Definition: VSDescriptor.h:66
@ VS_FRAME_UNCOMPRESSED
Image descriptor for uncompressed stream.
Definition: VSDescriptor.h:56
@ VS_FORMAT_MJPEG
Format descriptor for MJPEG streams.
Definition: VSDescriptor.h:58
static Indices32 frameIntervals(const TDescriptor &descriptor, std::vector< double > *frameRates=nullptr)
Returns the frame intervals of a given descriptor.
Definition: VSDescriptor.h:1095
Frame Based Payload Frame Descriptor (VS_FRAME_FRAME_BASED).
Definition: VSDescriptor.h:644
Indices32 frameIntervals(std::vector< double > *frameRates=nullptr) const
Returns the frame intervals of this descriptor.
VSFrameBasedFrameDescriptor(const void *buffer, const size_t size)
Creates a new frame descriptor from memory.
Indices32 dwFrameInterval_
For discrete Frame Intervals First entry: Shortest frame interval supported (at highest frame rate),...
Definition: VSDescriptor.h:738
VSFrameBasedFrameDescriptor()=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.
Frame Based Payload Video Format Descriptor (VS_FORMAT_FRAME_BASED).
Definition: VSDescriptor.h:491
std::string toString() const
Returns the content of this descriptor as string.
uint8_t guidFormat_[16]
Globally Unique Identifier used to identify stream-encoding format.
Definition: VSDescriptor.h:573
static std::string translateEncodingFormat(const EncodingFormat encodingFormat)
Translates an encoding format to a string.
static EncodingFormat translateEncodingFormat(const uint8_t guidFormat[16])
Translates a GUID to the corresponding encoding format.
VSFrameBasedVideoFormatDescriptor()=default
Default constructor creating an invalid descriptor.
bool isValid() const
Returns whether this object holds valid descriptor information.
VSFrameBasedVideoFormatDescriptor(const void *buffer, const size_t size)
Creates a new format descriptor from memory.
EncodingFormat
Definition of individual encoding formats.
Definition: VSDescriptor.h:498
@ EF_INVALID
Invalid encoding format.
Definition: VSDescriptor.h:500
@ EF_H264
The encoding is using H.264.
Definition: VSDescriptor.h:502
EncodingFormat encodingFormat() const
Returns the encoding format of this descriptor.
Definition: VSDescriptor.h:1165
Input Header Descriptor (VS_INPUT_HEADER).
Definition: VSDescriptor.h:92
VSInputHeaderDescriptor(const void *buffer, const size_t size)
Creates a new input header descriptor from memory.
VSInputHeaderDescriptor()=default
Default constructor creating an invalid descriptor.
std::vector< std::vector< uint8_t > > bmaControls_
'bNumFormats' entries of control bitmaps
Definition: VSDescriptor.h:207
uint8_t endpointAddress() const
Returns the endpoint address of this descriptor.
Definition: VSDescriptor.h:1140
std::string toString() const
Returns the content of this descriptor as string.
uint8_t bEndpointAddress_
The address of the isochronous or bulk endpoint used for video data.
Definition: VSDescriptor.h:154
bool isValid() const
Returns whether this object holds valid descriptor information.
MJPEG Video Format Descriptor (VS_FORMAT_MJPEG).
Definition: VSDescriptor.h:863
bool isValid() const
Returns whether this object holds valid descriptor information.
std::string toString() const
Returns the content of this descriptor as string.
VSMJPEGVideoFormatDescriptor()=default
Default constructor creating an invalid descriptor.
VSMJPEGVideoFormatDescriptor(const void *buffer, const size_t size)
Creates a new format descriptor from memory.
MJPEG Video Frame Descriptors (VS_FRAME_MJPEG).
Definition: VSDescriptor.h:970
VSMJPEGVideoFrameDescriptor()=default
Default constructor creating an invalid descriptor.
std::string toString() const
Returns the content of this descriptor as string.
Indices32 frameIntervals(std::vector< double > *frameRates=nullptr) const
Returns the frame intervals of this descriptor.
bool isValid() const
Returns whether this object holds valid descriptor information.
VSMJPEGVideoFrameDescriptor(const void *buffer, const size_t size)
Creates a new frame descriptor from memory.
Indices32 dwFrameInterval_
For discrete Frame Intervals First entry: Shortest frame interval supported (at highest frame rate),...
Definition: VSDescriptor.h:1091
UncompressedVideoFormatDescriptor (VS_FORMAT_UNCOMPRESSED)
Definition: VSDescriptor.h:234
bool isValid() const
Returns whether this object holds valid descriptor information.
VSUncompressedVideoFormatDescriptor()=default
Default constructor creating an invalid descriptor.
VSUncompressedVideoFormatDescriptor(const void *buffer, const size_t size)
Creates a new format descriptor from memory.
static FrameType::PixelFormat translatePixelFormat(const uint8_t guidFormat[16])
Translates a GUID to the corresponding pixel format.
FrameType::PixelFormat pixelFormat() const
Returns the pixel format of this descriptor.
Definition: VSDescriptor.h:1154
uint8_t guidFormat_[16]
GUID Globally Unique Identifier used to identify stream-encoding format.
Definition: VSDescriptor.h:294
std::string toString() const
Returns the content of this descriptor as string.
Uncompressed Frame Descriptor (VS_FRAME_UNCOMPRESSED).
Definition: VSDescriptor.h:350
std::string toString() const
Returns the content of this descriptor as string.
VSUncompressedVideoFrameDescriptor()=default
Default constructor creating an invalid descriptor.
Indices32 dwFrameInterval_
For discrete Frame Intervals First entry: Shortest frame interval supported (at highest frame rate),...
Definition: VSDescriptor.h:464
bool isValid() const
Returns whether this object holds valid descriptor information.
Indices32 frameIntervals(std::vector< double > *frameRates=nullptr) const
Returns the frame intervals of this descriptor.
VSUncompressedVideoFrameDescriptor(const uint8_t *buffer, const size_t size)
Creates a new frame descriptor from memory.
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition: Base.h:96
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15