Class: UVC::ClassSpecificVCInterfaceDescriptor

Inherits:
Object
  • Object
show all
Defined in:
lib/uvc.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bDescriptorType, bDescriptorSubType, rest = nil) ⇒ ClassSpecificVCInterfaceDescriptor

Returns a new instance of ClassSpecificVCInterfaceDescriptor.



265
266
267
268
269
# File 'lib/uvc.rb', line 265

def initialize(bDescriptorType, bDescriptorSubType, rest=nil)
  @bDescriptorType = bDescriptorType
  @bDescriptorSubType = bDescriptorSubType
  @rest = nil
end

Instance Attribute Details

#bDescriptorSubTypeObject (readonly)

Returns the value of attribute bDescriptorSubType.



229
230
231
# File 'lib/uvc.rb', line 229

def bDescriptorSubType
  @bDescriptorSubType
end

#bDescriptorTypeObject (readonly)

Returns the value of attribute bDescriptorType.



228
229
230
# File 'lib/uvc.rb', line 228

def bDescriptorType
  @bDescriptorType
end

#restObject (readonly)

Returns the value of attribute rest.



230
231
232
# File 'lib/uvc.rb', line 230

def rest
  @rest
end

Class Method Details

.parse(bytes) ⇒ Object



243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/uvc.rb', line 243

def self.parse(bytes)
  bDescriptorType, bDescriptorSubType, rest = *bytes.unpack("cca*")
  case [bDescriptorType, bDescriptorSubType]
  when [CS_INTERFACE, VC_HEADER]
    VCInterfaceHeaderDescriptor.parse(bDescriptorType, bDescriptorSubType, rest)
  when [CS_INTERFACE, VC_INPUT_TERMINAL]
    InputTerminalDescriptor.parse(bDescriptorType, bDescriptorSubType, rest)
  when [CS_INTERFACE, VC_OUTPUT_TERMINAL]
    OutputTerminalDescriptor.parse(bDescriptorType, bDescriptorSubType, rest)
  when [CS_INTERFACE, VC_SELECTOR_UNIT]
    SelectorUnitDescriptor.parse(bDescriptorType, bDescriptorSubType, rest)
  when [CS_INTERFACE, VC_PROCESSING_UNIT]
    ProcessingUnitDescriptor.parse(bDescriptorType, bDescriptorSubType, rest)
  when [CS_INTERFACE, VC_ENCODING_UNIT]
    EncodingUnitDescriptor.parse(bDescriptorType, bDescriptorSubType, rest)
  when [CS_INTERFACE, VC_EXTENSION_UNIT]
    ExtensionUnitDescriptor.parse(bDescriptorType, bDescriptorSubType, rest)
  else
    self.new(bDescriptorType, bDescriptorSubType, rest)
  end
end

.parse_array(extra) ⇒ Object



232
233
234
235
236
237
238
239
240
241
# File 'lib/uvc.rb', line 232

def self.parse_array(extra)
  extra = StringIO.new(extra, 'r')
  descs = []
  until extra.eof?
    len = extra.read(1).ord
    desc = ClassSpecificVCInterfaceDescriptor.parse(extra.read(len-1))
    descs << desc
  end
  descs
end

Instance Method Details

#short_inspectObject



271
272
273
274
275
# File 'lib/uvc.rb', line 271

def short_inspect
  "%s" % [
    self.class.name.sub(/Descriptor$/, ''),
  ]
end