rtsp 0.0.1.alpha → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. data/.document +3 -0
  2. data/.infinity_test +1 -1
  3. data/.yardopts +4 -0
  4. data/ChangeLog.rdoc +9 -0
  5. data/Gemfile +15 -6
  6. data/Gemfile.lock +78 -40
  7. data/LICENSE.rdoc +20 -0
  8. data/PostInstall.txt +0 -3
  9. data/README.rdoc +85 -36
  10. data/Rakefile +33 -49
  11. data/bin/rtsp_client +129 -0
  12. data/features/client_changes_state.feature +58 -0
  13. data/features/client_requests.feature +27 -0
  14. data/features/control_streams_as_client.feature +26 -0
  15. data/features/step_definitions/client_changes_state_steps.rb +46 -0
  16. data/features/step_definitions/client_requests_steps.rb +74 -0
  17. data/features/step_definitions/control_streams_as_client_steps.rb +34 -0
  18. data/features/support/env.rb +31 -29
  19. data/features/support/hooks.rb +3 -0
  20. data/gemspec.yml +30 -0
  21. data/lib/ext/logger.rb +8 -0
  22. data/lib/rtsp.rb +3 -6
  23. data/lib/rtsp/capturer.rb +105 -0
  24. data/lib/rtsp/client.rb +446 -204
  25. data/lib/rtsp/error.rb +6 -0
  26. data/lib/rtsp/global.rb +63 -0
  27. data/lib/rtsp/helpers.rb +28 -0
  28. data/lib/rtsp/message.rb +270 -0
  29. data/lib/rtsp/response.rb +89 -29
  30. data/lib/rtsp/transport_parser.rb +64 -0
  31. data/lib/rtsp/version.rb +4 -0
  32. data/nsm_test.rb +26 -0
  33. data/rtsp.gemspec +284 -0
  34. data/sarix_test.rb +23 -0
  35. data/soma_test.rb +39 -0
  36. data/spec/rtsp/client_spec.rb +302 -27
  37. data/spec/rtsp/helpers_spec.rb +53 -0
  38. data/spec/rtsp/message_spec.rb +420 -0
  39. data/spec/rtsp/response_spec.rb +144 -58
  40. data/spec/rtsp/transport_parser_spec.rb +54 -0
  41. data/spec/rtsp_spec.rb +3 -3
  42. data/spec/spec_helper.rb +66 -7
  43. data/spec/support/fake_rtsp_server.rb +123 -0
  44. data/tasks/metrics.rake +27 -0
  45. data/tasks/roodi_config.yml +14 -0
  46. data/tasks/stats.rake +12 -0
  47. metadata +174 -183
  48. data/.autotest +0 -23
  49. data/History.txt +0 -4
  50. data/Manifest.txt +0 -26
  51. data/bin/rtsp +0 -121
  52. data/features/step_definitions/stream_steps.rb +0 -50
  53. data/features/stream.feature +0 -17
  54. data/features/support/common.rb +0 -1
  55. data/features/support/world.rb +0 -1
  56. data/lib/rtsp/request_messages.rb +0 -104
  57. data/lib/rtsp/status_code.rb +0 -7
data/.autotest DELETED
@@ -1,23 +0,0 @@
1
- # -*- ruby -*-
2
-
3
- require 'autotest/restart'
4
-
5
- # Autotest.add_hook :initialize do |at|
6
- # at.extra_files << "../some/external/dependency.rb"
7
- #
8
- # at.libs << ":../some/external"
9
- #
10
- # at.add_exception 'vendor'
11
- #
12
- # at.add_mapping(/dependency.rb/) do |f, _|
13
- # at.files_matching(/test_.*rb$/)
14
- # end
15
- #
16
- # %w(TestA TestB).each do |klass|
17
- # at.extra_class_map[klass] = "test/test_misc.rb"
18
- # end
19
- # end
20
-
21
- # Autotest.add_hook :run_command do |at|
22
- # system "rake build"
23
- # end
data/History.txt DELETED
@@ -1,4 +0,0 @@
1
- h3. 0.0.1 / 2010-12-15
2
-
3
- * Happy birthday!
4
-
data/Manifest.txt DELETED
@@ -1,26 +0,0 @@
1
- .autotest
2
- .infinity_test
3
- .rspec
4
- Gemfile
5
- Gemfile.lock
6
- History.txt
7
- Manifest.txt
8
- PostInstall.txt
9
- README.rdoc
10
- Rakefile
11
- bin/rtsp
12
- features/step_definitions/stream_steps.rb
13
- features/stream.feature
14
- features/support/common.rb
15
- features/support/env.rb
16
- features/support/world.rb
17
- lib/rtsp.rb
18
- lib/rtsp/client.rb
19
- lib/rtsp/request_messages.rb
20
- lib/rtsp/response.rb
21
- lib/rtsp/status_code.rb
22
- spec/.rspec
23
- spec/rtsp/client_spec.rb
24
- spec/rtsp/response_spec.rb
25
- spec/rtsp_spec.rb
26
- spec/spec_helper.rb
data/bin/rtsp DELETED
@@ -1,121 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rubygems'
4
- require 'tempfile'
5
- require 'optparse'
6
-
7
- $:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/')
8
- require 'rtsp/client'
9
-
10
- options = {}
11
-
12
- optparse = OptionParser.new do |opts|
13
- opts.banner = "Usage: #{__FILE__} [options] url"
14
-
15
- options[:debug] = false
16
- opts.on('-d', '--debug', "Turn on debug logging. (not hooked up!)") do
17
- options[:debug] = true
18
- end
19
-
20
- opts.on('--show-tracks', "Show available tracks from the given URL.") do |url|
21
- rtsp_client = RTSP::Client.new(url)
22
- puts rtsp_client.stream_tracks
23
- end
24
-
25
- opts.on('-h', '--help', "You're looking at it.") do
26
- puts opts
27
- exit
28
- end
29
- end
30
-
31
- optparse.parse!
32
-
33
- # Allows for running an RTSP client
34
- url = ARGV.first || "rtsp://64.202.98.91:554/sa.sdp"
35
-
36
- rtsp_client = RTSP::Client.new(url)
37
- response = rtsp_client.options
38
- puts "code: #{response.code}"
39
- puts "message: #{response.message}"
40
- #puts "server: #{response.server}"
41
- puts "cseq: #{response.cseq}"
42
- puts "public: #{response.public}"
43
-
44
- response = rtsp_client.describe
45
- puts "code: #{response.code}"
46
- puts "message: #{response.message}"
47
- puts "server: #{response.server}" if response.respond_to? "server"
48
- puts "cseq: #{response.cseq}"
49
- puts "cache_control: #{response.cache_control}" if response.respond_to? "cache_control"
50
- puts "content_length: #{response.content_length}"
51
- puts "date: #{response.date}"
52
- puts "expires: #{response.expires}" if response.respond_to? "expires"
53
- puts "content_type: #{response.content_type}"
54
- puts "content_base: #{response.content_base}"
55
-
56
- # content_base is the base URI for any track to work with
57
- track = URI.parse response.content_base
58
- puts rtsp_client.aggregate_control_track
59
- puts rtsp_client.media_control_tracks
60
-
61
- # Add the first media_control_track to the URI
62
- puts track.path += rtsp_client.media_control_tracks.first
63
- puts track.to_s
64
-
65
- # Replace the client's list of tracks with the available track
66
- rtsp_client.stream_tracks[0] = track.to_s
67
- response = rtsp_client.setup(:destination => 'unicast')
68
- puts "code: #{response.code}"
69
- puts "message: #{response.message}"
70
- puts "server: #{response.server}" if response.respond_to? "server"
71
- puts "cseq: #{response.cseq}"
72
- puts "session: #{response.session}"
73
- puts "transport: #{response.transport}"
74
- session = response.session
75
- transport_info = response.transport
76
-
77
- if response.message == "OK"
78
- r = rtsp_client.play(:session => session)
79
- puts "code: #{r.code}"
80
- puts "message: #{r.message}"
81
- puts "server: #{r.server}" if response.respond_to? "server"
82
- puts "cseq: #{r.cseq}"
83
- puts "session: #{r.session}"
84
- puts "range: #{r.range}"
85
- puts "rtp_info: #{r.rtp_info}"
86
- cseq = r.cseq
87
- sleep 5
88
- #rtsp_client.pause({ :session => session, :sequence => cseq })
89
- r2 = rtsp_client.teardown
90
- puts "code: #{r2.code}"
91
- puts "message: #{r2.message}"
92
- puts "server: #{r2.server}" if r2.respond_to? "server"
93
- puts "cseq: #{r2.cseq}"
94
- puts "connection: #{r2.connection}" if r2.respond_to? "connection"
95
- end
96
- exit
97
-
98
- #rtsp_client = RTSP::Client.new "192.168.10.219"
99
- #rtsp_client.setup :port => 8554
100
-
101
- socket = UDPSocket.new
102
- socket.bind "0.0.0.0", 8554
103
- streamed_file = Tempfile.new "spectra_hd_streamed_file"
104
-
105
- begin
106
- Timeout::timeout(5) do
107
- while data = socket.recvfrom(102400).first
108
- puts "data size = #{data.size}"
109
- streamed_file.write data
110
- end
111
- end
112
- rescue Timeout::Error
113
- # blah
114
- end
115
-
116
- socket.close
117
- rtsp_client.teardown
118
-
119
- require 'fileutils'
120
- FileUtils.cp(streamed_file, "/Users/sloveless/Desktop/")
121
- streamed_file.close
@@ -1,50 +0,0 @@
1
- Given /^an RTSP server at "([^"]*)" and port (\d+)$/ do |ip_address, port|
2
- @rtp_port = port
3
- @client = RTSP::Client.new ip_address
4
- @client.setup :port => @rtp_port.to_i
5
- end
6
-
7
- Given /^an RTSP server at "([^"]*)" and port (\d+) and URL "([^"]*)"$/ do |ip_address, port, path|
8
- uri = "rtsp://#{ip_address}:#{port}#{path}"
9
- @rtp_port = port
10
- @client = RTSP::Client.new uri
11
- #@client.setup( { :port => @rtp_port.to_i, :stream_path => path })
12
- @client.setup( { :port => @rtp_port.to_i })
13
- end
14
-
15
- When /^I play a stream from that server$/ do
16
- @play_result = lambda { @client.play }
17
- end
18
-
19
- Then /^I should not receive any errors$/ do
20
- @play_result.should_not raise_error
21
- end
22
-
23
- Then /^I should receive data on the same port$/ do
24
- socket = UDPSocket.new
25
- socket.bind("0.0.0.0", @rtp_port)
26
-
27
- begin
28
- status = Timeout::timeout(5) do
29
- while data = socket.recvfrom(102400)[0]
30
- puts "marker size:#{data.size}"
31
- puts "data: #{data}" if data =~ /\r\n/
32
- end
33
- end
34
-
35
- data.should_not be_nil
36
- rescue Timeout::Error
37
- # Blind rescue
38
- ensure
39
- socket.close
40
- @client.teardown
41
- end
42
- end
43
-
44
- Given /^I know what the describe response looks like$/ do
45
- @response_text = DESCRIBE_RESPONSE
46
- end
47
-
48
- When /^I ask the server to describe$/ do
49
- puts @client.describe
50
- end
@@ -1,17 +0,0 @@
1
- Feature: Stream from an RTSP server
2
- As an RTSP consumer
3
- I want to be able to pull an RTSP stream from a server
4
- So that I can view its contents
5
-
6
- @wip
7
- Scenario: Play
8
- Given an RTSP server at "10.221.222.235" and port 9010 and URL ""
9
- When I play a stream from that server
10
- Then I should not receive any errors
11
- And I should receive data on the same port
12
-
13
- Scenario: Describe
14
- Given I know what the describe response looks like
15
- When I ask the server to describe
16
- Then I should not receive any errors
17
- And I should receive data on the same port
@@ -1 +0,0 @@
1
-
@@ -1 +0,0 @@
1
-
@@ -1,104 +0,0 @@
1
- module RTSP
2
-
3
- # This module defines the template strings that make up RTSP methods. Other
4
- # objects should use these for building request messages to communicate in
5
- # RTSP.
6
- module RequestMessages
7
- RTSP_VER = "RTSP/1.0"
8
- RTSP_ACCEPT_TYPE = "application/sdp"
9
- RTP_DEFAULT_PORT = 9000
10
- RTP_DEFAULT_PACKET_TYPE = "RTP/AVP"
11
- RTP_DEFAULT_ROUTING = "unicast"
12
- RTSP_DEFAULT_SEQUENCE_NUMBER = 1
13
- RTSP_DEFAULT_NPT = "0.000-"
14
-
15
- def self.options(stream, options={})
16
- options[:sequence] ||= RTSP_DEFAULT_SEQUENCE_NUMBER
17
- message = "OPTIONS #{stream} #{RTSP_VER}\r\n"
18
- message << "CSeq: #{options[:sequence]}\r\n\r\n"
19
- end
20
-
21
- # See section 10.2
22
- #
23
- # @param [String] stream
24
- # @param [Hash] options
25
- # @option options [Number] sequence
26
- # @option options [Array]
27
- def self.describe(stream, options={})
28
- options[:sequence] ||= RTSP_DEFAULT_SEQUENCE_NUMBER
29
- options[:accept] ||= RTSP_ACCEPT_TYPE
30
- message = "DESCRIBE #{stream} #{RTSP_VER}\r\n"
31
- message << "CSeq: #{options[:sequence]}\r\n"
32
- message << "Accept: #{options[:accept]}\r\n\r\n"
33
- end
34
-
35
- # @param [String] stream
36
- # @param [Number] session
37
- # @param [Hash]
38
- def self.announce(stream, session, options={})
39
- options[:content_type] ||= RTSP_ACCEPT_TYPE
40
- message = "ANNOUNCE #{stream} #{RTSP_VER}\r\n"
41
- message << "CSeq: #{options[:sequence]}\r\n"
42
- message << "Date: "
43
- message << "Session: #{session}"
44
- message << "Content-Type: #{options[:content_type]}\r\n"
45
- message << "Content-Length: #{options[:content_length]}\r\n"
46
- end
47
-
48
- def self.setup(track, options={})
49
- options[:sequence] ||= RTSP_DEFAULT_SEQUENCE_NUMBER
50
- options[:transport] ||= RTP_DEFAULT_PACKET_TYPE
51
- options[:port] ||= RTP_DEFAULT_PORT
52
- options[:routing] ||= RTP_DEFAULT_ROUTING
53
- message = "SETUP #{track} #{RTSP_VER}\r\n"
54
- message << "CSeq: #{options[:sequence]}\r\n"
55
- message << "Transport: #{options[:transport]};"
56
- message << "#{options[:destination]};"
57
- message << "client_port=#{options[:port]}-#{options[:port]+1}\r\n\r\n"
58
- end
59
-
60
- def self.play(stream, session, options={})
61
- options[:sequence] ||= RTSP_DEFAULT_SEQUENCE_NUMBER
62
- options[:npt] ||= RTSP_DEFAULT_NPT
63
- message = "PLAY #{stream} #{RTSP_VER}\r\n"
64
- message << "CSeq: #{options[:sequence]}\r\n"
65
- message << "Session: #{session}\r\n"
66
- message << "Range: npt=#{options[:npt]}\r\n\r\n"
67
- end
68
-
69
- def self.pause(stream, session, sequence)
70
- message = "PAUSE #{stream} #{RTSP_VER}\r\n"
71
- message << "CSeq: #{sequence}\r\n"
72
- message << "Session: #{session}\r\n"
73
- end
74
-
75
- def self.teardown(stream, session, options={})
76
- options[:sequence] ||= RTSP_DEFAULT_SEQUENCE_NUMBER
77
- message = "TEARDOWN #{stream} #{RTSP_VER}\r\n"
78
- message << "CSeq: #{options[:sequence]}\r\n"
79
- message << "Session: #{session}\r\n\r\n"
80
- end
81
-
82
- def self.get_parameter(stream, session, options={})
83
- message = "GET_PARAMETER #{stream} #{RTSP_VER}\r\n"
84
- message << "CSeq: #{options[:sequence]}\r\n"
85
- message << "Content-Type: #{options[:content_type]}\r\n"
86
- message << "Content-Length: #{options[:content_length]}\r\n"
87
- message << "Session: #{session}\r\n\r\n"
88
- end
89
-
90
- def self.set_parameter(stream, options={})
91
- message = "SET_PARAMETER #{stream} #{RTSP_VER}\r\n"
92
- message << "CSeq: #{options[:sequence]}\r\n"
93
- message << "Content-Type: #{options[:content_type]}\r\n"
94
- message << "Content-Length: #{options[:content_length]}\r\n"
95
- end
96
-
97
- def self.record(stream, session, options={})
98
- message = "RECORD #{stream} #{RTSP_VER}\r\n"
99
- message << "CSeq: #{options[:sequence]}\r\n"
100
- message << "Session: #{session}\r\n\r\n"
101
- message << "Conference: #{options[:conference]}\r\n\r\n"
102
- end
103
- end
104
- end
@@ -1,7 +0,0 @@
1
- module RTSP
2
- module StatusCode
3
- CONTINUE = 100
4
- OK = 200
5
-
6
- end
7
- end