Class: RTSP::Response

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/rtsp/response.rb

Overview

Parses raw response data from the server/client and turns it into attr_readers.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Common

#inspect, #multicast?, #parse_body, #parse_head, #split_head_and_body_from, #to_s, #transport_url

Constructor Details

#initialize(raw_response) ⇒ Response

server/client.

Parameters:

  • raw_response (String)

    The raw response string returned from the



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rtsp/response.rb', line 19

def initialize(raw_response)
  if raw_response.nil? || raw_response.empty?
    raise RTSP::Error,
      "#{self.class} received nil string--this shouldn't happen."
  end

  @raw_body = raw_response

  head, body = split_head_and_body_from @raw_body
  parse_head(head)
  @body = parse_body(body)
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



15
16
17
# File 'lib/rtsp/response.rb', line 15

def body
  @body
end

#codeObject (readonly)

Returns the value of attribute code.



13
14
15
# File 'lib/rtsp/response.rb', line 13

def code
  @code
end

#messageObject (readonly)

Returns the value of attribute message.



14
15
16
# File 'lib/rtsp/response.rb', line 14

def message
  @message
end

#rtsp_versionObject (readonly)

Returns the value of attribute rtsp_version.



12
13
14
# File 'lib/rtsp/response.rb', line 12

def rtsp_version
  @rtsp_version
end

Instance Method Details

#extract_status_line(line) ⇒ Object

Pulls out the RTSP version, response code, and response message (AKA the status line info) into instance variables.

Parameters:

  • line (String)

    The String containing the status line info.



36
37
38
39
40
41
42
43
44
45
# File 'lib/rtsp/response.rb', line 36

def extract_status_line(line)
  line =~ /RTSP\/(\d\.\d) (\d\d\d) ([^\r\n]+)/
  @rtsp_version = $1
  @code         = $2.to_i
  @message      = $3

  if @rtsp_version.nil?
    raise RTSP::Error, "Status line corrupted: #{line}"
  end
end