From b05f0fb4f3ea463962b7174c58f1aa36bf2cbb83 Mon Sep 17 00:00:00 2001 From: greywolf-colorado Date: Tue, 6 Nov 2012 15:56:12 -0700 Subject: [PATCH 1/2] changed session id from an integer to a string --- lib/rtsp/client.rb | 2 +- lib/rtsp/response.rb | 4 ++-- spec/rtsp/client_spec.rb | 2 +- spec/rtsp/response_spec.rb | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/rtsp/client.rb b/lib/rtsp/client.rb index 543c851..7e65d85 100644 --- a/lib/rtsp/client.rb +++ b/lib/rtsp/client.rb @@ -438,7 +438,7 @@ def request message # # @raise [RTSP::Error] Raises if @session isn't set. def ensure_session - if @session.empty? || @session[:session_id] <= 0 + if @session.empty? #|| @session[:session_id] <= 0 raise RTSP::Error, "Session number not retrieved from server yet. Run SETUP first." end end diff --git a/lib/rtsp/response.rb b/lib/rtsp/response.rb index ab0f91f..5dc3136 100644 --- a/lib/rtsp/response.rb +++ b/lib/rtsp/response.rb @@ -94,8 +94,8 @@ def parse_head head if line.include? "Session: " value = {} - line =~ /Session: (\d+)/ - value[:session_id] = $1.to_i + line =~ /Session: ([\w\\$\-\.\+]+)/ + value[:session_id] = $1 if line =~ /timeout=(.+)/ value[:timeout] = $1.to_i diff --git a/spec/rtsp/client_spec.rb b/spec/rtsp/client_spec.rb index 1b99bd3..8c5e33f 100644 --- a/spec/rtsp/client_spec.rb +++ b/spec/rtsp/client_spec.rb @@ -183,7 +183,7 @@ def setup_client_at(url) it "extracts the session number" do @client.session.should be_empty @client.setup("rtsp://localhost/some_track") - @client.session[:session_id].should == 1234567890 + @client.session[:session_id].should == "1234567890" end it "changes the session_state to :ready" do diff --git a/spec/rtsp/response_spec.rb b/spec/rtsp/response_spec.rb index 354489a..8aca6ea 100644 --- a/spec/rtsp/response_spec.rb +++ b/spec/rtsp/response_spec.rb @@ -28,7 +28,7 @@ it "creates a :session reader with value being a Hash with key/value" do subject.stub(:extract_status_line) subject.should_receive(:create_reader).with("session", - { session_id: 118, timeout: 49 }) + { session_id: "118", timeout: 49 }) subject.parse_head(head) end end @@ -40,7 +40,7 @@ it "creates a :session reader with value being a Hash with key/value" do subject.stub(:extract_status_line) subject.should_receive(:create_reader).with("session", - { session_id: 118 }) + { session_id: "118" }) subject.parse_head(head) end end @@ -181,7 +181,7 @@ end it "returns the session" do - @response.session[:session_id].should == 118 + @response.session[:session_id].should == "118" end end @@ -207,7 +207,7 @@ end it "returns the session" do - @response.session[:session_id].should == 118 + @response.session[:session_id].should == "118" end it "returns the rtp_info" do From 988b85533d86b0a4220882db52e15ba742c585ac Mon Sep 17 00:00:00 2001 From: greywolf-colorado Date: Thu, 8 Nov 2012 08:52:05 -0700 Subject: [PATCH 2/2] removing a comment I missed --- lib/rtsp/client.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rtsp/client.rb b/lib/rtsp/client.rb index 7e65d85..d87d3b0 100644 --- a/lib/rtsp/client.rb +++ b/lib/rtsp/client.rb @@ -438,7 +438,7 @@ def request message # # @raise [RTSP::Error] Raises if @session isn't set. def ensure_session - if @session.empty? #|| @session[:session_id] <= 0 + if @session.empty? raise RTSP::Error, "Session number not retrieved from server yet. Run SETUP first." end end