rtsp_server 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/lib/rtsp/server.rb +8 -2
- data/lib/rtsp/socat_streaming.rb +23 -5
- data/lib/rtsp/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0f0e9d2cff96fa79d01dd739d0ae8758fa3e9e7
|
4
|
+
data.tar.gz: 0b9a1cac454571a76821a0fdc32c22caa525990e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71f013548763868491beb43245bc259a7f84f78098239045020d82f5314d9440141ad57c9e4d59b92b771dddac1441dc075ae1a8dbeab457b6c6c2127d7e5fd2
|
7
|
+
data.tar.gz: 885711e91338eb3e8d296b862af6f2f60d1ae2b7a1d651ce76c7be27127633852b1a15f4a6562ea7723ca287d85e5604fa56f81d0034cc3b25d1fe0b1b3198ed
|
data/lib/rtsp/server.rb
CHANGED
@@ -101,11 +101,15 @@ module RTSP
|
|
101
101
|
end
|
102
102
|
|
103
103
|
responses = []
|
104
|
+
puts "REQUEST **********************************"
|
105
|
+
p request_str
|
104
106
|
|
105
107
|
request_str.split("\r\n\r\n").each do |r|
|
106
108
|
responses << process_request(r, io)
|
107
109
|
end
|
108
110
|
|
111
|
+
puts "RESPONSE **********************************"
|
112
|
+
p responses
|
109
113
|
io.send(responses.join, 0)
|
110
114
|
return(-1) if request_str.include?("TEARDOWN")
|
111
115
|
end
|
@@ -166,7 +170,7 @@ module RTSP
|
|
166
170
|
@session = @session.next
|
167
171
|
multicast_check = request.transport.include?('multicast')
|
168
172
|
server_port = @stream_server.setup_streamer(@session,
|
169
|
-
request
|
173
|
+
request, request.stream_index, multicast_check)
|
170
174
|
response = []
|
171
175
|
transport = generate_transport(request, server_port, request.stream_index)
|
172
176
|
response << "Transport: #{transport.join}"
|
@@ -310,7 +314,9 @@ module RTSP
|
|
310
314
|
transport = request.transport.split(port_specifier)
|
311
315
|
transport[1] = port_specifier + transport[1]
|
312
316
|
transport[1] = "" if request.transport.include?("multicast")
|
313
|
-
|
317
|
+
/client_port=(?<p1>\d*)-(?<p2>\d*)/ =~ request.transport
|
318
|
+
transport[1] << ";port=#{p1}-#{p2}" unless p1.nil?
|
319
|
+
transport[1] << ";port=#{server_port}-#{server_port+1}" if p1.nil?
|
314
320
|
else
|
315
321
|
transport = [request.transport + ';', "port=#{server_port}-#{server_port + 1}"]
|
316
322
|
end
|
data/lib/rtsp/socat_streaming.rb
CHANGED
@@ -65,10 +65,11 @@ module RTSP
|
|
65
65
|
# Creates a RTP streamer using socat.
|
66
66
|
#
|
67
67
|
# @param [String] sid Session ID.
|
68
|
-
# @param [
|
68
|
+
# @param [RTSP::Requesti] reuuest RTSP request
|
69
69
|
# @param [Fixnum] index Stream index.
|
70
70
|
# @return [Fixnum] The port the streamer will stream on.
|
71
|
-
def setup_streamer(sid,
|
71
|
+
def setup_streamer(sid, request, index=1, multicast=false)
|
72
|
+
transport_url = request.transport_url
|
72
73
|
dest_ip, dest_port = transport_url.split ":" unless multicast
|
73
74
|
|
74
75
|
@rtcp_source_identifier ||= RTCP_SOURCE.pack("H*")
|
@@ -92,7 +93,19 @@ module RTSP
|
|
92
93
|
@processes ||= Sys::ProcTable.ps.map { |p| p.cmdline }
|
93
94
|
|
94
95
|
if multicast
|
95
|
-
|
96
|
+
if request.transport.include?('cleint_port')
|
97
|
+
/client_port=(?<p1>\d*)-(?<p2>\d*)/ =~ request.transport
|
98
|
+
dest_port = p1
|
99
|
+
if dest_port == "64000"
|
100
|
+
@sessions[sid] = :multicast
|
101
|
+
else
|
102
|
+
puts "Request malformed client-port not found #{request.transport}" if dest_port.nil?
|
103
|
+
raise "Request malformed client-port not found #{request.transport}" if dest_port.nil?
|
104
|
+
@sessions[sid] = build_socat(@source_ip[index - 1], dest_port.to_i, local_port, index)
|
105
|
+
end
|
106
|
+
else
|
107
|
+
@sessions[sid] = :multicast
|
108
|
+
end
|
96
109
|
else
|
97
110
|
@sessions[sid] = build_socat(dest_ip, dest_port, local_port, index)
|
98
111
|
end
|
@@ -272,15 +285,20 @@ EOF
|
|
272
285
|
# talk to.
|
273
286
|
# @
|
274
287
|
|
288
|
+
# @return [String] IP of the interface that would be used to talk to.
|
275
289
|
# @return [String] IP of the interface that would be used to talk to.
|
276
290
|
def build_socat(target_ip, target_port, server_port, index=1)
|
277
291
|
bsd_options = BSD_OPTIONS if OS.mac?
|
278
292
|
bsd_options ||= ""
|
293
|
+
multicast_options = MULTICAST_OPTIONS if target_ip.start_with?("239")
|
294
|
+
multicast_options ||= ""
|
295
|
+
src_port = "sourceport=#{server_port},"
|
296
|
+
src_port = "" if target_ip.start_with?("239")
|
279
297
|
|
280
298
|
"socat -b #{BLOCK_SIZE} UDP-RECV:#{@source_port[index-1]},reuseaddr," +
|
281
299
|
"#{bsd_options}"+ SOCAT_OPTIONS + ",ip-add-membership=#{@source_ip[index-1]}:" +
|
282
|
-
"#{@interface_ip} UDP:#{target_ip}:#{target_port}
|
283
|
-
SOCAT_OPTIONS
|
300
|
+
"#{@interface_ip}#{multicast_options} UDP:#{target_ip}:#{target_port},#{src_port}" +
|
301
|
+
SOCAT_OPTIONS + multicast_options
|
284
302
|
end
|
285
303
|
|
286
304
|
# Attempts to find a random bindable port between 50000-65500
|
data/lib/rtsp/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rtsp_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Loveless, Mike Kirby
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-08-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: parslet
|
@@ -257,20 +257,20 @@ signing_key:
|
|
257
257
|
specification_version: 4
|
258
258
|
summary: Library to allow RTSP streaming from RTSP-enabled devices.
|
259
259
|
test_files:
|
260
|
+
- spec/rtsp/response_spec.rb
|
260
261
|
- spec/rtsp/message_spec.rb
|
261
262
|
- spec/rtsp/helpers_spec.rb
|
262
|
-
- spec/rtsp/response_spec.rb
|
263
|
-
- spec/rtsp/transport_parser_spec.rb
|
264
263
|
- spec/rtsp/client_spec.rb
|
264
|
+
- spec/rtsp/transport_parser_spec.rb
|
265
265
|
- spec/rtsp_spec.rb
|
266
266
|
- spec/support/fake_rtsp_server.rb
|
267
267
|
- spec/spec_helper.rb
|
268
|
-
- features/client_changes_state.feature
|
269
|
-
- features/control_streams_as_client.feature
|
270
268
|
- features/step_definitions/client_changes_state_steps.rb
|
271
|
-
- features/step_definitions/control_streams_as_client_steps.rb
|
272
269
|
- features/step_definitions/client_requests_steps.rb
|
273
|
-
- features/
|
274
|
-
- features/support/env.rb
|
270
|
+
- features/step_definitions/control_streams_as_client_steps.rb
|
275
271
|
- features/support/hooks.rb
|
272
|
+
- features/support/env.rb
|
273
|
+
- features/client_changes_state.feature
|
274
|
+
- features/control_streams_as_client.feature
|
275
|
+
- features/client_requests.feature
|
276
276
|
has_rdoc:
|