class Argus::VideoDataEnvelope
Attributes
socket[R]
Public Class Methods
new(socket)
click to toggle source
# File lib/argus/video_data_envelope.rb 5 def initialize(socket) 6 @socket = socket 7 parse 8 end
Public Instance Methods
data(name, size, format)
click to toggle source
# File lib/argus/video_data_envelope.rb 39 def data(name, size, format) 40 define_data(name, get_data(size, format)) 41 end
define_data(name, value)
click to toggle source
# File lib/argus/video_data_envelope.rb 47 def define_data(name, value) 48 ivar = "@#{name}".to_sym 49 instance_variable_set(ivar, value) 50 self.class.send(:define_method, name) do 51 instance_variable_get(ivar) 52 end 53 end
get_data(size, format)
click to toggle source
# File lib/argus/video_data_envelope.rb 43 def get_data(size, format) 44 socket.read(size).unpack(format).first 45 end
parse()
click to toggle source
# File lib/argus/video_data_envelope.rb 10 def parse 11 data(:signature, 4, "A*") 12 data(:version, 1, "C") 13 data(:video_codec, 1, "C") 14 data(:header_size, 2, "v") 15 data(:payload_size, 4, "V") 16 data(:encoded_stream_width, 2, "v") 17 data(:encoded_stream_height, 2, "v") 18 data(:display_width, 2, "v") 19 data(:display_height, 2, "v") 20 data(:frame_number, 4, "V") 21 data(:timestamp, 4, "V") 22 data(:total_chunks, 1, "C") 23 data(:chunk_index, 1, "C") 24 data(:frame_type, 1, "C") 25 data(:control, 1, "C") 26 data(:stream_byte_position_lw, 4, "V") 27 data(:stream_byte_position_uw, 4, "V") 28 data(:stream_id, 2, "v") 29 data(:total_slices, 1, "C") 30 data(:slice_index, 1, "C") 31 data(:header1_size, 1, "C") 32 data(:header2_size, 1, "C") 33 data(:reserved_2, 2, "H*") 34 data(:advertised_size, 4, "V") 35 data(:reserved_12, 12, "H*") 36 socket.read(4) # TODO: look at why just throwing this data away 37 end