rtsp 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ChangeLog.rdoc +37 -18
- data/Gemfile +1 -1
- data/Rakefile +2 -1
- data/bin/client_tester +78 -0
- data/bin/rtsp_client +13 -0
- data/lib/rtsp.rb +9 -1
- data/lib/rtsp/client.rb +35 -4
- data/lib/rtsp/message.rb +8 -0
- data/lib/rtsp/transport_parser.rb +24 -1
- data/lib/rtsp/version.rb +11 -2
- data/rtsp.gemspec +14 -14
- data/spec/integration/client_use_spec.rb +102 -72
- data/spec/integration/real_server_wowza_client_use_spec.rb +250 -0
- data/spec/support/fake_rtsp_server.rb +5 -1
- data/spec/unit/rtsp_spec.rb +16 -4
- metadata +31 -216
- data/lib/ext/time_ext.rb +0 -7
- data/lib/rtsp/presentation.rb +0 -160
- data/lib/rtsp/session.rb +0 -65
- data/spec/integration/coverage/assets/0.7.1/application.css +0 -1110
- data/spec/integration/coverage/assets/0.7.1/application.js +0 -626
- data/spec/integration/coverage/assets/0.7.1/fancybox/blank.gif +0 -0
- data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_close.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_loading.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_nav_left.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_nav_right.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_e.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_n.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_ne.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_nw.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_s.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_se.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_sw.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_w.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_title_left.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_title_main.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_title_over.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_title_right.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/fancybox/fancybox-x.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/fancybox/fancybox-y.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/fancybox/fancybox.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/favicon_green.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/favicon_red.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/favicon_yellow.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/loading.gif +0 -0
- data/spec/integration/coverage/assets/0.7.1/magnify.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/spec/integration/coverage/index.html +0 -72
- data/spec/unit/ext/coverage/assets/0.7.1/application.css +0 -1110
- data/spec/unit/ext/coverage/assets/0.7.1/application.js +0 -626
- data/spec/unit/ext/coverage/assets/0.7.1/fancybox/blank.gif +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/fancybox/fancy_close.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/fancybox/fancy_loading.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/fancybox/fancy_nav_left.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/fancybox/fancy_nav_right.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/fancybox/fancy_shadow_e.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/fancybox/fancy_shadow_n.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/fancybox/fancy_shadow_ne.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/fancybox/fancy_shadow_nw.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/fancybox/fancy_shadow_s.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/fancybox/fancy_shadow_se.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/fancybox/fancy_shadow_sw.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/fancybox/fancy_shadow_w.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/fancybox/fancy_title_left.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/fancybox/fancy_title_main.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/fancybox/fancy_title_over.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/fancybox/fancy_title_right.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/fancybox/fancybox-x.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/fancybox/fancybox-y.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/fancybox/fancybox.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/favicon_green.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/favicon_red.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/favicon_yellow.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/loading.gif +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/magnify.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/spec/unit/ext/coverage/assets/0.7.1/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/spec/unit/ext/coverage/index.html +0 -72
@@ -2,204 +2,234 @@ require 'sdp'
|
|
2
2
|
require 'spec_helper'
|
3
3
|
require 'rtsp/client'
|
4
4
|
|
5
|
-
|
5
|
+
|
6
|
+
describe 'Client use' do
|
6
7
|
subject do
|
7
8
|
fake_rtsp_server = FakeRTSPServer.new
|
9
|
+
|
10
|
+
if @setup_maybeSource_maybePorts
|
11
|
+
fake_rtsp_server.setup_maybeSource_maybePorts =
|
12
|
+
@setup_maybeSource_maybePorts
|
13
|
+
end
|
8
14
|
|
9
15
|
RTSP::Client.new('http://localhost') do |connection|
|
10
16
|
connection.socket = fake_rtsp_server
|
11
17
|
end
|
12
18
|
end
|
13
19
|
|
14
|
-
describe
|
20
|
+
describe '#options' do
|
15
21
|
it "extracts the server's supported methods" do
|
16
22
|
subject.options
|
17
23
|
subject.supported_methods.should ==
|
18
24
|
[:describe, :setup, :teardown, :play, :pause]
|
19
25
|
end
|
20
26
|
|
21
|
-
it
|
27
|
+
it 'returns a Response' do
|
22
28
|
response = subject.options
|
23
29
|
response.should be_a RTSP::Response
|
24
30
|
end
|
25
31
|
end
|
26
32
|
|
27
|
-
describe
|
33
|
+
describe '#describe' do
|
28
34
|
before do
|
29
35
|
@response = subject.describe
|
30
36
|
end
|
31
37
|
|
32
|
-
it
|
33
|
-
subject.aggregate_control_track.should ==
|
38
|
+
it 'extracts the aggregate control track' do
|
39
|
+
subject.aggregate_control_track.should == 'rtsp://64.202.98.91:554/sa.sdp/'
|
34
40
|
end
|
35
41
|
|
36
|
-
it
|
37
|
-
subject.media_control_tracks.should == [
|
42
|
+
it 'extracts the media control tracks' do
|
43
|
+
subject.media_control_tracks.should == %w[rtsp://64.202.98.91:554/sa.sdp/trackID=1]
|
38
44
|
end
|
39
45
|
|
40
|
-
it
|
46
|
+
it 'extracts the SDP object' do
|
41
47
|
subject.instance_variable_get(:@session_description).should ==
|
42
48
|
@response.body
|
43
49
|
end
|
44
50
|
|
45
|
-
it
|
51
|
+
it 'extracts the Content-Base header' do
|
46
52
|
subject.instance_variable_get(:@content_base).should ==
|
47
|
-
URI.parse(
|
53
|
+
URI.parse('rtsp://64.202.98.91:554/sa.sdp/')
|
48
54
|
end
|
49
55
|
|
50
|
-
it
|
56
|
+
it 'returns a Response' do
|
51
57
|
@response.should be_a RTSP::Response
|
52
58
|
end
|
53
59
|
end
|
54
60
|
|
55
|
-
describe
|
56
|
-
it
|
61
|
+
describe '#announce' do
|
62
|
+
it 'returns a Response' do
|
57
63
|
sdp = SDP::Description.new
|
58
|
-
subject.setup(
|
59
|
-
response = subject.announce(
|
64
|
+
subject.setup('rtsp://localhost/another_track')
|
65
|
+
response = subject.announce('rtsp://localhost/another_track', sdp)
|
60
66
|
response.should be_a RTSP::Response
|
61
67
|
end
|
62
68
|
end
|
63
69
|
|
64
|
-
describe
|
70
|
+
describe '#setup' do
|
65
71
|
after do
|
66
|
-
subject.teardown(
|
72
|
+
subject.teardown('rtsp://localhost/some_track')
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'extracts the session number: default' do
|
76
|
+
subject.session.should be_empty
|
77
|
+
subject.setup('rtsp://localhost/some_track')
|
78
|
+
subject.session[:session_id].should == '1234567890'
|
67
79
|
end
|
68
80
|
|
69
|
-
it
|
81
|
+
it 'extracts the session number with a client_port then source in transport' do
|
82
|
+
@setup_maybeSource_maybePorts =
|
83
|
+
'client_port=9000-9001;source=10.221.222.235;server_port=6700-6701'
|
70
84
|
subject.session.should be_empty
|
71
|
-
subject.setup(
|
72
|
-
subject.session[:session_id].should ==
|
85
|
+
subject.setup('rtsp://localhost/some_track')
|
86
|
+
subject.session[:session_id].should == '1234567890'
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'extracts the session number with a client_port,server_port,then source in transport' do
|
90
|
+
@setup_maybeSource_maybePorts =
|
91
|
+
'client_port=9000-9001;server_port=6700-6701;source=10.221.222.235'
|
92
|
+
subject.session.should be_empty
|
93
|
+
subject.setup('rtsp://localhost/some_track')
|
94
|
+
subject.session[:session_id].should == '1234567890'
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'extracts the session number with a server_port,client_port,then source in transport' do
|
98
|
+
@setup_maybeSource_maybePorts =
|
99
|
+
'server_port=6700-6701;client_port=9000-9001;source=10.221.222.235'
|
100
|
+
subject.session.should be_empty
|
101
|
+
subject.setup('rtsp://localhost/some_track')
|
102
|
+
subject.session[:session_id].should == '1234567890'
|
73
103
|
end
|
74
104
|
|
75
|
-
it
|
76
|
-
subject.setup(
|
105
|
+
it 'changes the session_state to :ready' do
|
106
|
+
subject.setup('rtsp://localhost/some_track')
|
77
107
|
subject.session_state.should == :ready
|
78
108
|
end
|
79
109
|
|
80
|
-
it
|
110
|
+
it 'extracts the transport header info' do
|
81
111
|
subject.instance_variable_get(:@transport).should be_nil
|
82
|
-
subject.setup(
|
112
|
+
subject.setup('rtsp://localhost/some_track')
|
83
113
|
subject.instance_variable_get(:@transport).should == {
|
84
|
-
streaming_protocol:
|
85
|
-
profile:
|
86
|
-
broadcast_type:
|
87
|
-
destination:
|
88
|
-
source:
|
89
|
-
client_port: { rtp:
|
90
|
-
server_port: { rtp:
|
114
|
+
streaming_protocol: 'RTP',
|
115
|
+
profile: 'AVP',
|
116
|
+
broadcast_type: 'unicast',
|
117
|
+
destination: '127.0.0.1',
|
118
|
+
source: '10.221.222.235',
|
119
|
+
client_port: { rtp: '9000', rtcp: '9001' },
|
120
|
+
server_port: { rtp: '6700', rtcp: '6701' }
|
91
121
|
}
|
92
122
|
end
|
93
123
|
|
94
|
-
it
|
95
|
-
response = subject.setup(
|
124
|
+
it 'returns a Response' do
|
125
|
+
response = subject.setup('rtsp://localhost/some_track')
|
96
126
|
response.should be_a RTSP::Response
|
97
127
|
end
|
98
128
|
end
|
99
129
|
|
100
|
-
describe
|
130
|
+
describe '#play' do
|
101
131
|
before do
|
102
|
-
subject.setup(
|
132
|
+
subject.setup('rtsp://localhost/some_track')
|
103
133
|
end
|
104
134
|
|
105
135
|
after do
|
106
136
|
subject.teardown('rtsp://localhost/some_track')
|
107
137
|
end
|
108
138
|
|
109
|
-
it
|
110
|
-
subject.play(
|
139
|
+
it 'changes the session_state to :playing' do
|
140
|
+
subject.play('rtsp://localhost/some_track')
|
111
141
|
subject.session_state.should == :playing
|
112
142
|
end
|
113
143
|
|
114
|
-
it
|
115
|
-
RTSP::Client.log =
|
116
|
-
RTP::Logger.log =
|
117
|
-
response = subject.play(
|
144
|
+
it 'returns a Response' do
|
145
|
+
RTSP::Client.log = false
|
146
|
+
RTP::Logger.log = false
|
147
|
+
response = subject.play('rtsp://localhost/some_track')
|
118
148
|
response.should be_a RTSP::Response
|
119
149
|
end
|
120
150
|
end
|
121
151
|
|
122
|
-
describe
|
152
|
+
describe '#pause' do
|
123
153
|
before :each do
|
124
|
-
subject.setup(
|
154
|
+
subject.setup('rtsp://localhost/some_track')
|
125
155
|
end
|
126
156
|
|
127
157
|
after do
|
128
158
|
subject.teardown('rtsp://localhost/some_track')
|
129
159
|
end
|
130
160
|
|
131
|
-
it
|
132
|
-
subject.play(
|
133
|
-
subject.pause(
|
161
|
+
it 'changes the session_state from :playing to :ready' do
|
162
|
+
subject.play('rtsp://localhost/some_track')
|
163
|
+
subject.pause('rtsp://localhost/some_track')
|
134
164
|
subject.session_state.should == :ready
|
135
165
|
end
|
136
166
|
|
137
|
-
it
|
138
|
-
subject.record(
|
139
|
-
subject.pause(
|
167
|
+
it 'changes the session_state from :recording to :ready' do
|
168
|
+
subject.record('rtsp://localhost/some_track')
|
169
|
+
subject.pause('rtsp://localhost/some_track')
|
140
170
|
subject.session_state.should == :ready
|
141
171
|
end
|
142
172
|
|
143
|
-
it
|
144
|
-
response = subject.pause(
|
173
|
+
it 'returns a Response' do
|
174
|
+
response = subject.pause('rtsp://localhost/some_track')
|
145
175
|
response.should be_a RTSP::Response
|
146
176
|
end
|
147
177
|
end
|
148
178
|
|
149
|
-
describe
|
179
|
+
describe '#teardown' do
|
150
180
|
before do
|
151
|
-
subject.setup(
|
181
|
+
subject.setup('rtsp://localhost/some_track')
|
152
182
|
end
|
153
183
|
|
154
|
-
it
|
184
|
+
it 'changes the session_state to :init' do
|
155
185
|
subject.session_state.should_not == :init
|
156
|
-
subject.teardown(
|
186
|
+
subject.teardown('rtsp://localhost/some_track')
|
157
187
|
subject.session_state.should == :init
|
158
188
|
end
|
159
189
|
|
160
|
-
it
|
190
|
+
it 'changes the session_id back to 0' do
|
161
191
|
subject.session.should_not be_empty
|
162
|
-
subject.teardown(
|
192
|
+
subject.teardown('rtsp://localhost/some_track')
|
163
193
|
subject.session.should be_empty
|
164
194
|
end
|
165
195
|
|
166
|
-
it
|
167
|
-
response = subject.teardown(
|
196
|
+
it 'returns a Response' do
|
197
|
+
response = subject.teardown('rtsp://localhost/some_track')
|
168
198
|
response.should be_a RTSP::Response
|
169
199
|
end
|
170
200
|
end
|
171
201
|
|
172
|
-
describe
|
173
|
-
it
|
174
|
-
response = subject.get_parameter(
|
202
|
+
describe '#get_parameter' do
|
203
|
+
it 'returns a Response' do
|
204
|
+
response = subject.get_parameter('rtsp://localhost/some_track', 'ping!')
|
175
205
|
response.should be_a RTSP::Response
|
176
206
|
end
|
177
207
|
end
|
178
208
|
|
179
|
-
describe
|
180
|
-
it
|
181
|
-
response = subject.set_parameter(
|
209
|
+
describe '#set_parameter' do
|
210
|
+
it 'returns a Response' do
|
211
|
+
response = subject.set_parameter('rtsp://localhost/some_track', 'ping!')
|
182
212
|
response.should be_a RTSP::Response
|
183
213
|
end
|
184
214
|
end
|
185
215
|
|
186
|
-
describe
|
216
|
+
describe '#record' do
|
187
217
|
before :each do
|
188
|
-
subject.setup(
|
218
|
+
subject.setup('rtsp://localhost/some_track')
|
189
219
|
end
|
190
220
|
|
191
221
|
after do
|
192
222
|
subject.teardown('rtsp://localhost/some_track')
|
193
223
|
end
|
194
224
|
|
195
|
-
it
|
196
|
-
response = subject.record(
|
225
|
+
it 'returns a Response' do
|
226
|
+
response = subject.record('rtsp://localhost/some_track')
|
197
227
|
response.is_a?(RTSP::Response).should be_true
|
198
228
|
end
|
199
229
|
|
200
|
-
it
|
230
|
+
it 'changes the session_state to :recording' do
|
201
231
|
subject.session_state.should == :ready
|
202
|
-
subject.record(
|
232
|
+
subject.record('rtsp://localhost/some_track')
|
203
233
|
subject.session_state.should == :recording
|
204
234
|
end
|
205
235
|
end
|
@@ -0,0 +1,250 @@
|
|
1
|
+
=begin
|
2
|
+
adapted from
|
3
|
+
https://github.com/turboladen/rtsp
|
4
|
+
original copyright notice follows:
|
5
|
+
|
6
|
+
Copyright © 2011 sloveless, mkirby, nmccready
|
7
|
+
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
9
|
+
this software and associated documentation files (the “Software”), to deal in
|
10
|
+
the Software without restriction, including without limitation the rights to
|
11
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
12
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
13
|
+
so, subject to the following conditions:
|
14
|
+
|
15
|
+
The above copyright notice and this permission notice shall be included in all
|
16
|
+
copies or substantial portions of the Software.
|
17
|
+
|
18
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
24
|
+
SOFTWARE.
|
25
|
+
=end
|
26
|
+
require 'sdp'
|
27
|
+
require 'spec_helper'
|
28
|
+
require 'rtsp/client'
|
29
|
+
|
30
|
+
describe "Real Server (Wowza) Client use" do
|
31
|
+
|
32
|
+
# block to show raw output for debugging
|
33
|
+
def setup(url)
|
34
|
+
response = subject.setup(@mediaUrl) do |transport|
|
35
|
+
puts "SETUP RAW RESPONSE, Trasport: #{transport}"
|
36
|
+
#by using a block we can now check the error location of the where the
|
37
|
+
#problem begins
|
38
|
+
#puts "Pre-ERROR @ RESPONSE #{transport[35]}"
|
39
|
+
#puts "Pre-ERROR @ RESPONSE #{transport[36]}"
|
40
|
+
#puts "ERROR @ RESPONSE #{transport[37]}"
|
41
|
+
end
|
42
|
+
return response
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
subject do
|
47
|
+
#urls provided by rtsp client adroid app
|
48
|
+
#alkass TV (updated)
|
49
|
+
@baseUrl = "78.100.44.238" if @baseUrl.nil?
|
50
|
+
@mediaUrl = "#{@baseUrl}/live-kass/kass" if @mediaUrl.nil?
|
51
|
+
puts "RTSP: URL #{@baseUrl}!!!!!"
|
52
|
+
puts "RTSP: Media URL #{@mediaUrl}!!!!!"
|
53
|
+
RTSP::Client.new(@baseUrl)
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#options" do
|
57
|
+
it "extracts the server's supported methods" do
|
58
|
+
subject.options
|
59
|
+
subject.supported_methods.should ==
|
60
|
+
[:describe, :setup, :teardown, :play, :pause,
|
61
|
+
:options,:announce,:record,:get_parameter]
|
62
|
+
end
|
63
|
+
|
64
|
+
it "returns a Response" do
|
65
|
+
response = subject.options
|
66
|
+
response.should be_a RTSP::Response
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# describe "#describe" do
|
71
|
+
# before do
|
72
|
+
# puts "Before describe"
|
73
|
+
# @response = subject.describe
|
74
|
+
# puts "Response field = #{@response}"
|
75
|
+
# end
|
76
|
+
#
|
77
|
+
# it "extracts the aggregate control track" do
|
78
|
+
# puts "Agg #{subject.aggregate_control_track}"
|
79
|
+
# "rtsp://#{configatron.rtsp_server_wowza.url}/sa.sdp/"
|
80
|
+
# end
|
81
|
+
#
|
82
|
+
# it "extracts the media control tracks" do
|
83
|
+
# subject.media_control_tracks.should == ["rtsp://64.202.98.91:554/sa.sdp/trackID=1"]
|
84
|
+
# end
|
85
|
+
#
|
86
|
+
# it "extracts the SDP object" do
|
87
|
+
# subject.instance_variable_get(:@session_description).should ==
|
88
|
+
# @response.body
|
89
|
+
# end
|
90
|
+
#
|
91
|
+
# it "extracts the Content-Base header" do
|
92
|
+
# subject.instance_variable_get(:@content_base).should ==
|
93
|
+
# URI.parse("rtsp://64.202.98.91:554/sa.sdp/")
|
94
|
+
# end
|
95
|
+
#
|
96
|
+
# it "returns a Response" do
|
97
|
+
# @response.should be_a RTSP::Response
|
98
|
+
# end
|
99
|
+
# end
|
100
|
+
|
101
|
+
describe "#announce" do
|
102
|
+
it "returns a Response" do
|
103
|
+
sdp = SDP::Description.new
|
104
|
+
subject.setup(@mediaUrl)
|
105
|
+
response = subject.announce(@mediaUrl, sdp)
|
106
|
+
response.should be_a RTSP::Response
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "#setup" do
|
111
|
+
after do
|
112
|
+
subject.teardown(@mediaUrl)
|
113
|
+
end
|
114
|
+
|
115
|
+
it "extracts the session number" do
|
116
|
+
#RTSP::Client.log = true
|
117
|
+
subject.session.should be_empty
|
118
|
+
setup(@mediaUrl)
|
119
|
+
subject.session[:session_id].to_i.should >= 0
|
120
|
+
end
|
121
|
+
|
122
|
+
it "changes the session_state to :ready" do
|
123
|
+
setup(@mediaUrl)
|
124
|
+
subject.session_state.should == :ready
|
125
|
+
end
|
126
|
+
|
127
|
+
it "extracts the transport header info" do
|
128
|
+
subject.instance_variable_get(:@transport).should be_nil
|
129
|
+
setup(@mediaUrl)
|
130
|
+
transport = subject.instance_variable_get(:@transport)
|
131
|
+
#puts "HASH: transport = #{transport}"
|
132
|
+
transport[:streaming_protocol].should == "RTP"
|
133
|
+
transport[:profile].should == "AVP"
|
134
|
+
transport[:broadcast_type].should == "unicast"
|
135
|
+
transport[:source].should == "78.100.44.238"
|
136
|
+
end
|
137
|
+
|
138
|
+
it "returns a Response" do
|
139
|
+
response = setup(@mediaUrl)
|
140
|
+
response.should be_a RTSP::Response
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
# describe "#play" do
|
145
|
+
# before do
|
146
|
+
# subject.setup(configatron.rtsp_server_wowza.media_url)
|
147
|
+
# end
|
148
|
+
#
|
149
|
+
# after do
|
150
|
+
# subject.teardown(configatron.rtsp_server_wowza.media_url)
|
151
|
+
# end
|
152
|
+
#
|
153
|
+
# it "changes the session_state to :playing" do
|
154
|
+
# subject.play(configatron.rtsp_server_wowza.media_url)
|
155
|
+
# subject.session_state.should == :playing
|
156
|
+
# end
|
157
|
+
#
|
158
|
+
# it "returns a Response" do
|
159
|
+
# RTSP::Client.log = true
|
160
|
+
# RTP::Logger.log = true
|
161
|
+
# response = subject.play(configatron.rtsp_server_wowza.media_url)
|
162
|
+
# response.should be_a RTSP::Response
|
163
|
+
# end
|
164
|
+
# end
|
165
|
+
#
|
166
|
+
# describe "#pause" do
|
167
|
+
# before :each do
|
168
|
+
# subject.setup("rtsp://localhost/some_track")
|
169
|
+
# end
|
170
|
+
#
|
171
|
+
# after do
|
172
|
+
# subject.teardown('rtsp://localhost/some_track')
|
173
|
+
# end
|
174
|
+
#
|
175
|
+
# it "changes the session_state from :playing to :ready" do
|
176
|
+
# subject.play("rtsp://localhost/some_track")
|
177
|
+
# subject.pause("rtsp://localhost/some_track")
|
178
|
+
# subject.session_state.should == :ready
|
179
|
+
# end
|
180
|
+
#
|
181
|
+
# it "changes the session_state from :recording to :ready" do
|
182
|
+
# subject.record("rtsp://localhost/some_track")
|
183
|
+
# subject.pause("rtsp://localhost/some_track")
|
184
|
+
# subject.session_state.should == :ready
|
185
|
+
# end
|
186
|
+
#
|
187
|
+
# it "returns a Response" do
|
188
|
+
# response = subject.pause("rtsp://localhost/some_track")
|
189
|
+
# response.should be_a RTSP::Response
|
190
|
+
# end
|
191
|
+
# end
|
192
|
+
#
|
193
|
+
# describe "#teardown" do
|
194
|
+
# before do
|
195
|
+
# subject.setup("rtsp://localhost/some_track")
|
196
|
+
# end
|
197
|
+
#
|
198
|
+
# it "changes the session_state to :init" do
|
199
|
+
# subject.session_state.should_not == :init
|
200
|
+
# subject.teardown("rtsp://localhost/some_track")
|
201
|
+
# subject.session_state.should == :init
|
202
|
+
# end
|
203
|
+
#
|
204
|
+
# it "changes the session_id back to 0" do
|
205
|
+
# subject.session.should_not be_empty
|
206
|
+
# subject.teardown("rtsp://localhost/some_track")
|
207
|
+
# subject.session.should be_empty
|
208
|
+
# end
|
209
|
+
#
|
210
|
+
# it "returns a Response" do
|
211
|
+
# response = subject.teardown("rtsp://localhost/some_track")
|
212
|
+
# response.should be_a RTSP::Response
|
213
|
+
# end
|
214
|
+
# end
|
215
|
+
#
|
216
|
+
# describe "#get_parameter" do
|
217
|
+
# it "returns a Response" do
|
218
|
+
# response = subject.get_parameter("rtsp://localhost/some_track", "ping!")
|
219
|
+
# response.should be_a RTSP::Response
|
220
|
+
# end
|
221
|
+
# end
|
222
|
+
#
|
223
|
+
# describe "#set_parameter" do
|
224
|
+
# it "returns a Response" do
|
225
|
+
# response = subject.set_parameter("rtsp://localhost/some_track", "ping!")
|
226
|
+
# response.should be_a RTSP::Response
|
227
|
+
# end
|
228
|
+
# end
|
229
|
+
#
|
230
|
+
# describe "#record" do
|
231
|
+
# before :each do
|
232
|
+
# subject.setup("rtsp://localhost/some_track")
|
233
|
+
# end
|
234
|
+
#
|
235
|
+
# after do
|
236
|
+
# subject.teardown('rtsp://localhost/some_track')
|
237
|
+
# end
|
238
|
+
#
|
239
|
+
# it "returns a Response" do
|
240
|
+
# response = subject.record("rtsp://localhost/some_track")
|
241
|
+
# response.is_a?(RTSP::Response).should be_true
|
242
|
+
# end
|
243
|
+
#
|
244
|
+
# it "changes the session_state to :recording" do
|
245
|
+
# subject.session_state.should == :ready
|
246
|
+
# subject.record("rtsp://localhost/some_track")
|
247
|
+
# subject.session_state.should == :recording
|
248
|
+
# end
|
249
|
+
# end
|
250
|
+
end
|