rtsp 0.0.1.alpha → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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/.document ADDED
@@ -0,0 +1,3 @@
1
+ -
2
+ ChangeLog.*
3
+ LICENSE.rdoc
data/.infinity_test CHANGED
@@ -1,4 +1,4 @@
1
1
  infinity_test do
2
- use :rubies => %w(1.8.7 1.9.1 1.9.2), :test_framework => :rspec
2
+ use :rubies => %w(1.9.2), :test_framework => :rspec
3
3
  notifications :growl
4
4
  end
data/.yardopts ADDED
@@ -0,0 +1,4 @@
1
+ --title "rtsp Documentation"
2
+ --protected
3
+ --private
4
+ --readme README.rdoc
data/ChangeLog.rdoc ADDED
@@ -0,0 +1,9 @@
1
+ === 0.1.0 / 2011-04-12
2
+
3
+ * Happy birthday!
4
+ * All standard RTSP methods supported.
5
+ * Captures RTP data to a file, but doesn't ensure RTP sequencing before putting to file.
6
+ * One client object can only handle 1 stream; use a client per stream until this functionality
7
+ gets implemented.
8
+ * Only handles unicast, UDP streams.
9
+ * RTSP exceptions are all +RTSP::Error+s; this will change.
data/Gemfile CHANGED
@@ -1,12 +1,21 @@
1
+ require 'ore/specification'
2
+
1
3
  source :rubygems
2
4
 
3
- gem 'sdp', '~> 0.2.0'
5
+ gemspec
6
+ gem 'sdp', '~> 0.2.2'
7
+
8
+ gem 'simplecov', '>= 0.4.0', :require => false, :group => :test
4
9
 
5
10
  group :development do
6
- gem "rspec", '~> 2.4.0'
7
- gem "hoe-yard", :require => "hoe/yard"
8
- gem 'yard', '~> 0.6.0'
9
- gem 'infinity_test'
10
- gem 'metric_fu'
11
11
  gem 'code_statistics', '~> 0.2.13'
12
+ gem 'cucumber'
13
+ gem 'jeweler', '~> 1.5.0'
14
+ gem 'metric_fu', '>= 2.0.0'
15
+ gem 'ore', '~> 0.7.2'
16
+ gem 'ore-core', '~> 0.1.5'
17
+ gem 'ore-tasks', '~> 0.5.0'
18
+ gem 'rake', '~> 0.8.7'
19
+ gem "rspec", '~> 2.5.0'
20
+ gem 'yard', '~> 0.6.0'
12
21
  end
data/Gemfile.lock CHANGED
@@ -1,13 +1,21 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rtsp (0.1.0)
5
+ rtsp
6
+ sdp (~> 0.2.2)
7
+ sdp (~> 0.2.0)
8
+
1
9
  GEM
2
10
  remote: http://rubygems.org/
3
11
  specs:
4
12
  Saikuro (1.1.0)
5
13
  abstract (1.0.0)
6
- activesupport (3.0.3)
14
+ activesupport (3.0.6)
7
15
  arrayfields (4.7.4)
8
- blankslate (2.1.2.3)
9
- chronic (0.2.3)
10
- hoe (>= 1.2.1)
16
+ blankslate (2.1.2.4)
17
+ builder (3.0.0)
18
+ chronic (0.3.0)
11
19
  churn (0.0.13)
12
20
  chronic (>= 0.2.3)
13
21
  hirb
@@ -17,45 +25,61 @@ GEM
17
25
  sexp_processor (~> 3.0.3)
18
26
  code_statistics (0.2.13)
19
27
  colored (1.2)
28
+ cucumber (0.10.2)
29
+ builder (>= 2.1.2)
30
+ diff-lcs (>= 1.1.2)
31
+ gherkin (>= 2.3.5)
32
+ json (>= 1.4.6)
33
+ term-ansicolor (>= 1.0.5)
20
34
  diff-lcs (1.1.2)
21
35
  erubis (2.6.6)
22
36
  abstract (>= 1.0.0)
23
37
  fattr (2.2.0)
24
- flay (1.4.1)
38
+ flay (1.4.2)
25
39
  ruby_parser (~> 2.0)
26
40
  sexp_processor (~> 3.0)
27
- flog (2.5.0)
41
+ flog (2.5.1)
28
42
  ruby_parser (~> 2.0)
29
43
  sexp_processor (~> 3.0)
44
+ gherkin (2.3.5)
45
+ json (>= 1.4.6)
46
+ gherkin (2.3.5-java)
47
+ json (>= 1.4.6)
48
+ git (1.2.5)
30
49
  haml (3.0.25)
31
- hirb (0.3.6)
32
- hoe (2.8.0)
33
- rake (>= 0.8.7)
34
- hoe-yard (0.1.2)
35
- yard (>= 0.2.3.1)
50
+ hirb (0.4.3)
36
51
  i18n (0.5.0)
37
- infinity_test (1.0.2)
38
- notifiers (>= 1.1.0)
39
- watchr (>= 0.7)
40
- json_pure (1.4.6)
52
+ jeweler (1.5.2)
53
+ bundler (~> 1.0.0)
54
+ git (>= 1.2.5)
55
+ rake
56
+ json (1.5.1)
57
+ json (1.5.1-java)
58
+ json_pure (1.5.1)
41
59
  main (4.4.0)
42
60
  arrayfields (>= 4.7.4)
43
61
  fattr (>= 2.1.0)
44
- metric_fu (2.0.1)
62
+ metric_fu (2.1.1)
45
63
  Saikuro (>= 1.1.0)
46
64
  activesupport (>= 2.0.0)
47
- chronic (~> 0.2.3)
65
+ chronic (~> 0.3.0)
48
66
  churn (>= 0.0.7)
49
67
  flay (>= 1.2.1)
50
- flog (>= 2.2.0)
51
- rails_best_practices (>= 0.3.16)
68
+ flog (>= 2.3.0)
69
+ rails_best_practices (>= 0.6.4)
52
70
  rcov (>= 0.8.3.3)
53
71
  reek (>= 1.2.6)
54
72
  roodi (>= 2.1.0)
55
- notifiers (1.1.0)
56
- parslet (1.0.1)
57
- blankslate (~> 2.1.2.3)
58
- rails_best_practices (0.6.5)
73
+ syntax
74
+ ore (0.7.2)
75
+ ore-core (>= 0.1.4, ~> 0.1)
76
+ thor (~> 0.14.3)
77
+ ore-core (0.1.5)
78
+ ore-tasks (0.5.0)
79
+ ore-core (>= 0.1.3, ~> 0.1)
80
+ parslet (1.1.1)
81
+ blankslate (~> 2.0)
82
+ rails_best_practices (0.7.5)
59
83
  activesupport
60
84
  colored (~> 1.2)
61
85
  erubis (~> 2.6.6)
@@ -65,40 +89,54 @@ GEM
65
89
  ruby_parser (~> 2.0.4)
66
90
  rake (0.8.7)
67
91
  rcov (0.9.9)
92
+ rcov (0.9.9-java)
68
93
  reek (1.2.8)
69
94
  ruby2ruby (~> 1.2)
70
95
  ruby_parser (~> 2.0)
71
96
  sexp_processor (~> 3.0)
72
97
  roodi (2.1.0)
73
98
  ruby_parser
74
- rspec (2.4.0)
75
- rspec-core (~> 2.4.0)
76
- rspec-expectations (~> 2.4.0)
77
- rspec-mocks (~> 2.4.0)
78
- rspec-core (2.4.0)
79
- rspec-expectations (2.4.0)
99
+ rspec (2.5.0)
100
+ rspec-core (~> 2.5.0)
101
+ rspec-expectations (~> 2.5.0)
102
+ rspec-mocks (~> 2.5.0)
103
+ rspec-core (2.5.1)
104
+ rspec-expectations (2.5.0)
80
105
  diff-lcs (~> 1.1.2)
81
- rspec-mocks (2.4.0)
106
+ rspec-mocks (2.5.0)
82
107
  ruby-progressbar (0.0.9)
83
108
  ruby2ruby (1.2.5)
84
109
  ruby_parser (~> 2.0)
85
110
  sexp_processor (~> 3.0)
86
- ruby_parser (2.0.5)
111
+ ruby_parser (2.0.6)
87
112
  sexp_processor (~> 3.0)
88
- sdp (0.2.0)
89
- parslet (~> 1.0.0)
113
+ sdp (0.2.2)
114
+ parslet (~> 1.1.0)
90
115
  sexp_processor (3.0.5)
91
- watchr (0.7)
92
- yard (0.6.4)
116
+ simplecov (0.4.2)
117
+ simplecov-html (~> 0.4.4)
118
+ simplecov-html (0.4.4)
119
+ syntax (1.0.0)
120
+ term-ansicolor (1.0.5)
121
+ thor (0.14.6)
122
+ yard (0.6.7)
93
123
 
94
124
  PLATFORMS
125
+ java
95
126
  ruby
96
127
 
97
128
  DEPENDENCIES
129
+ bundler (~> 1.0.0)
98
130
  code_statistics (~> 0.2.13)
99
- hoe-yard
100
- infinity_test
101
- metric_fu
102
- rspec (~> 2.4.0)
103
- sdp (~> 0.2.0)
131
+ cucumber
132
+ jeweler (~> 1.5.0)
133
+ metric_fu (>= 2.0.0)
134
+ ore (~> 0.7.2)
135
+ ore-core (~> 0.1.5)
136
+ ore-tasks (~> 0.5.0)
137
+ rake (~> 0.8.7)
138
+ rspec (~> 2.5.0)
139
+ rtsp!
140
+ sdp (~> 0.2.2)
141
+ simplecov (>= 0.4.0)
104
142
  yard (~> 0.6.0)
data/LICENSE.rdoc ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 sloveless, mkirby
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/PostInstall.txt CHANGED
@@ -2,6 +2,3 @@
2
2
  Thanks for installing rtsp. We hope you get some good streaming out of it!
3
3
 
4
4
  Take a look at the README to help get you started.
5
-
6
- NOTE: This is only an alpha version!! It is not well tested and doesn't have
7
- much error handling built in yet.
data/README.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = rtsp_client
1
+ = rtsp
2
2
 
3
3
  * https://github.com/turboladen/rtsp
4
4
 
@@ -16,24 +16,91 @@ SDP: http://tools.ietf.org/html/rfc4566
16
16
 
17
17
  == FEATURES/PROBLEMS:
18
18
 
19
- * RTSP client
20
- * Currently, only unicast
19
+ * All standard RTSP methods supported.
20
+ * Captures RTP data to a file, but doesn't ensure RTP sequencing before putting to file.
21
+ * One client object can only handle 1 stream; use a client per stream until this functionality
22
+ gets implemented.
23
+ * Only handles unicast, UDP streams.
24
+ * RTSP exceptions are all +RTSP::Error+s; this will change.
21
25
 
22
26
  == SYNOPSIS:
23
27
 
24
- The uber-quick get started:
25
-
26
- rtsp_client = RTSP::Client.new "192.168.1.10"
27
- rtsp_client.setup :port => 8554
28
- rtsp_client.play
29
- rtsp_client.teardown
28
+ The quick get started:
29
+
30
+ RTSP::Client.log? # => true
31
+ RTSP::Client.log = false
32
+ client = RTSP::Client.new "rtsp://64.202.98.91/sa.sdp" do |connection, capturer|
33
+ connection.timeout = 5
34
+ capturer.rtp_port = 8554
35
+ capturer.rtp_file = File.open("captured_stuff.rtp", "wb")
36
+ end
37
+
38
+ client.server_uri # => #<URI::Generic:0x00000100ba4db0 URL:rtsp://64.202.98.91:554/sa.sdp>
39
+ client.session_state # => :init
40
+ client.cseq # => 1
41
+ client.connection.do_capture # => true
42
+ client.connection.interleave # => false
43
+ client.connection.timeout # => 5
44
+ client.capturer.broadcast_type # => :unicast
45
+ client.capturer.rtp_port # => 8554
46
+ client.capturer.rtp_file # => #<File:captured_stuff.rtp>
47
+ client.capturer.transport_protocol # => :UDP
48
+
49
+ response = client.options
50
+ response.class # => RTSP::Response
51
+ response.code # => 200
52
+ response.message # => "OK"
53
+ client.cseq # => 2
54
+
55
+ response = client.describe
56
+ response.body.class # => SDP::Description
57
+ response.content_type # => "application/sdp"
58
+ response.server # => "DSS/5.5 (Build/489.7; Platform/Linux; Release/Darwin; )"
59
+ client.aggregate_control_track # => "rtsp://64.202.98.91:554/sa.sdp/"
60
+ client.media_control_tracks # => ["rtsp://64.202.98.91:554/sa.sdp/trackID=1"]
61
+ client.cseq # => 3
62
+
63
+ response = client.setup(client.media_control_tracks.first)
64
+ response.session # => 7098486223178290313
65
+ client.session # => 7098486223178290313
66
+ client.cseq # => 4
67
+ client.session_state # => :ready
68
+
69
+
70
+ response = client.play(client.aggregate_control_track)
71
+ response.range # => "npt=now="
72
+ resposne.rtp_info # => "url=rtsp://64.202.98.91:554/sa.sdp/trackID=1"
73
+ client.session_state # => :playing
74
+
75
+ # Wait while the video streams
76
+ sleep 5
77
+
78
+ client.pause(client.aggregate_control_track)
79
+ client.session_state # => :ready
80
+
81
+ # Wait while the video is paused
82
+ sleep 2
83
+
84
+ client.teardown(client.aggregate_control_track)
85
+ client.session # => 0
86
+ client.session_state # => :init
87
+
88
+ # Check the streamed file's contents
89
+ puts client.capturer.rtp_file # => (Lots of data)
30
90
 
31
91
  == REQUIREMENTS:
32
92
 
33
- * Ruby
34
- * 1.8.7
35
- * 1.9.1
36
- * 1.9.2
93
+ * (Tested) Rubies
94
+ * 1.9.2-p180
95
+ * RubyGems
96
+ * sdp, '~> 0.2.2'
97
+ * RubyGems (development)
98
+ * ore-core, '~> 0.1.0'
99
+ * jeweler, '~> 1.5.0'
100
+ * ore-tasks, '~> 0.3.0'
101
+ * yard, '~> 0.6.0'
102
+ * metric_fu
103
+ * code_statistics, '~> 0.2.13'
37
104
 
38
105
  == INSTALL:
39
106
 
@@ -43,32 +110,14 @@ The uber-quick get started:
43
110
 
44
111
  After checking out the source, run:
45
112
 
46
- $ rake newb
113
+ $ bundle install
47
114
 
48
- This task will install any missing dependencies, run the tests/specs,
49
- and generate the RDoc.
115
+ This task will install any missing dependencies.
50
116
 
51
117
  == LICENSE:
52
118
 
53
119
  (The MIT License)
54
120
 
55
- Copyright (c) 2010 FIX
56
-
57
- Permission is hereby granted, free of charge, to any person obtaining
58
- a copy of this software and associated documentation files (the
59
- 'Software'), to deal in the Software without restriction, including
60
- without limitation the rights to use, copy, modify, merge, publish,
61
- distribute, sublicense, and/or sell copies of the Software, and to
62
- permit persons to whom the Software is furnished to do so, subject to
63
- the following conditions:
64
-
65
- The above copyright notice and this permission notice shall be
66
- included in all copies or substantial portions of the Software.
67
-
68
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
69
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
70
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
71
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
72
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
73
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
74
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
121
+ Copyright (c) 2011 Steve Loveless, Mike Kirby
122
+
123
+ See LICENSE.rdoc for details.
data/Rakefile CHANGED
@@ -1,57 +1,41 @@
1
1
  require 'rubygems' if RUBY_VERSION < "1.9.0"
2
- require 'hoe'
3
- require 'hoe/yard'
4
- require 'yard'
5
- require 'newgem/tasks'
6
- require 'bundler/setup'
7
- require File.expand_path(File.dirname(__FILE__)) + '/lib/rtsp'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'bundler'
6
+ rescue LoadError => e
7
+ STDERR.puts e.message
8
+ STDERR.puts "Run `gem install bundler` to install Bundler."
9
+ exit e.status_code
10
+ end
8
11
 
9
- Hoe.plugin :newgem
10
- Hoe.plugin :yard
11
- Hoe.plugin :cucumberfeatures
12
- Hoe.plugins.delete :rubyforge
12
+ begin
13
+ Bundler.setup(:development)
14
+ rescue Bundler::BundlerError => e
15
+ STDERR.puts e.message
16
+ STDERR.puts "Run `bundle install` to install missing gems."
17
+ exit e.status_code
18
+ end
13
19
 
14
- # Gets the description from the README file
15
- def get_descr_from_readme
16
- paragraph_count = 0
20
+ require 'ore/specification'
21
+ require 'jeweler'
22
+ Jeweler::Tasks.new(Ore::Specification.new)
17
23
 
18
- File.readlines('README.rdoc', '').each do |paragraph|
19
- paragraph_count += 1
24
+ require 'ore/tasks'
25
+ Ore::Tasks.new
20
26
 
21
- return paragraph if paragraph_count == 2
22
- end
27
+ require 'rspec/core/rake_task'
28
+ RSpec::Core::RakeTask.new(:spec) do |t|
29
+ t.ruby_opts = "-w"
30
+ t.rspec_opts = ['--format', 'documentation', '--color']
23
31
  end
32
+ task :default => :spec
24
33
 
25
- # The main Gemspec definition
26
- Hoe.spec 'rtsp' do
27
- self.summary = 'Library to allow RTSP streaming from RTSP-enabled devices.'
28
- self.developer('Steve Loveless & Mike Kirby', 'steve.loveless@gmail.com, mkirby@gmail.com')
29
- self.post_install_message = File.readlines 'PostInstall.txt'
30
- self.version = RTSP::VERSION
31
- self.url = RTSP::WWW
32
- self.description = get_descr_from_readme
33
- self.readme_file = 'README.rdoc'
34
- self.history_file = 'History.txt'
35
- self.rspec_options += ['--color', '--format', 'documentation']
36
- self.extra_deps += [
37
- ['sdp', '~>0.2.0']
38
- ]
39
- self.extra_dev_deps += [
40
- ['rspec', ">=2.0.1"],
41
- ['yard', '>=0.6.4'],
42
- ['cucumber'],
43
- ['hoe-yard', '>=0.1.2']
44
- ]
45
-
46
- self.test_globs = 'spec/*.rb'
47
-
48
- # Extra Yard options
49
- self.yard_title = "#{self.name} Documentation (#{self.version})"
50
- self.yard_opts += ['--output-dir', 'doc']
51
- self.yard_opts += ['--private']
52
- self.yard_opts += ['--protected']
53
- self.yard_opts += ['--verbose']
54
- self.yard_opts += ['--files',
55
- [self.history_file, 'Manifest.txt', self.readme_file]
56
- ]
34
+ require 'yard'
35
+ YARD::Rake::YardocTask.new do |t|
36
+ t.options = ['--verbose']
57
37
  end
38
+
39
+ # Load all extra rake tasks
40
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].each { |ext| load ext }
41
+