Class: Argus::VideoDataEnvelope
- Inherits:
-
Object
- Object
- Argus::VideoDataEnvelope
- Defined in:
- lib/argus/video_data_envelope.rb
Instance Attribute Summary collapse
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Instance Method Summary collapse
- #data(name, size, format) ⇒ Object
- #define_data(name, value) ⇒ Object
- #get_data(size, format) ⇒ Object
-
#initialize(socket) ⇒ VideoDataEnvelope
constructor
A new instance of VideoDataEnvelope.
- #parse ⇒ Object
Constructor Details
#initialize(socket) ⇒ VideoDataEnvelope
Returns a new instance of VideoDataEnvelope.
5 6 7 8 |
# File 'lib/argus/video_data_envelope.rb', line 5 def initialize(socket) @socket = socket parse end |
Instance Attribute Details
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
3 4 5 |
# File 'lib/argus/video_data_envelope.rb', line 3 def socket @socket end |
Instance Method Details
#data(name, size, format) ⇒ Object
39 40 41 |
# File 'lib/argus/video_data_envelope.rb', line 39 def data(name, size, format) define_data(name, get_data(size, format)) end |
#define_data(name, value) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/argus/video_data_envelope.rb', line 47 def define_data(name, value) ivar = "@#{name}".to_sym instance_variable_set(ivar, value) self.class.send(:define_method, name) do instance_variable_get(ivar) end end |
#get_data(size, format) ⇒ Object
43 44 45 |
# File 'lib/argus/video_data_envelope.rb', line 43 def get_data(size, format) socket.read(size).unpack(format).first end |
#parse ⇒ Object
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 |
# File 'lib/argus/video_data_envelope.rb', line 10 def parse data(:signature, 4, "A*") data(:version, 1, "C") data(:video_codec, 1, "C") data(:header_size, 2, "v") data(:payload_size, 4, "V") data(:encoded_stream_width, 2, "v") data(:encoded_stream_height, 2, "v") data(:display_width, 2, "v") data(:display_height, 2, "v") data(:frame_number, 4, "V") data(:timestamp, 4, "V") data(:total_chunks, 1, "C") data(:chunk_index, 1, "C") data(:frame_type, 1, "C") data(:control, 1, "C") data(:stream_byte_position_lw, 4, "V") data(:stream_byte_position_uw, 4, "V") data(:stream_id, 2, "v") data(:total_slices, 1, "C") data(:slice_index, 1, "C") data(:header1_size, 1, "C") data(:header2_size, 1, "C") data(:reserved_2, 2, "H*") data(:advertised_size, 4, "V") data(:reserved_12, 12, "H*") socket.read(4) # TODO: look at why just throwing this data away end |