lib/rtsp/client.rb in rtsp-0.3.0 vs lib/rtsp/client.rb in rtsp-0.4.0

- old
+ new

@@ -281,11 +281,11 @@ # @raise [RTSP::Error] If +#play+ is called but the session hasn't yet been # set up via +#setup+. # @see http://tools.ietf.org/html/rfc2326#page-34 RFC 2326, Section 10.5. def play(track, additional_headers={}) message = RTSP::Message.play(track).with_headers({ - cseq: @cseq, session: @session }) + cseq: @cseq, session: @session[:session_id] }) message.add_headers additional_headers request(message) do unless @session_state == :ready raise RTSP::Error, "Session not set up yet. Run #setup first." @@ -311,11 +311,11 @@ # @param [Hash] additional_headers # @return [RTSP::Response] # @see http://tools.ietf.org/html/rfc2326#page-36 RFC 2326, Section 10.6. def pause(track, additional_headers={}) message = RTSP::Message.pause(track).with_headers({ - cseq: @cseq, session: @session }) + cseq: @cseq, session: @session[:session_id] }) message.add_headers additional_headers request(message) do if [:playing, :recording].include? @session_state @session_state = :ready @@ -330,11 +330,11 @@ # @param [Hash] additional_headers # @return [RTSP::Response] # @see http://tools.ietf.org/html/rfc2326#page-37 RFC 2326, Section 10.7. def teardown(track, additional_headers={}) message = RTSP::Message.teardown(track).with_headers({ - cseq: @cseq, session: @session }) + cseq: @cseq, session: @session[:session_id] }) message.add_headers additional_headers request(message) do reset_state @@ -348,11 +348,11 @@ # Sets state related variables back to their starting values; # +@session_state+ is set to +:init+; +@session+ is set to 0. def reset_state @session_state = :init - @session = 0 + @session = {} end # Sends the GET_PARAMETERS request. # # @param [String] track The presentation or media track to ping. @@ -391,11 +391,11 @@ # @param [Hash] additional_headers # @return [RTSP::Response] # @see http://tools.ietf.org/html/rfc2326#page-39 RFC 2326, Section 10.11. def record(track, additional_headers={}) message = RTSP::Message.record(track).with_headers({ - cseq: @cseq, session: @session }) + cseq: @cseq, session: @session[:session_id] }) message.add_headers additional_headers request(message) { @session_state = :recording } end @@ -436,11 +436,11 @@ # Ensures that +@session+ is set before continuing on. # # @raise [RTSP::Error] Raises if @session isn't set. def ensure_session - unless @session > 0 + if @session.empty? || @session[:session_id] <= 0 raise RTSP::Error, "Session number not retrieved from server yet. Run SETUP first." end end # Extracts the URL associated with the "control" attribute from the main @@ -498,11 +498,11 @@ # # @param [Fixnum] server_session Session number returned by the server. # @raise [RTSP::Error] If the server returns a Session value that's different # from what the client sent. def compare_session_number server_session - if @session != server_session - message = "Session number mismatch. Client: #{@session}, Server: #{server_session}" + if @session[:session_id] != server_session + message = "Session number mismatch. Client: #{@session[:session_id]}, Server: #{server_session}" raise RTSP::Error, message end end # Takes the methods returned from the Public header from an OPTIONS response