Skip to content

Commit

Permalink
More changes for moving to RTP
Browse files Browse the repository at this point in the history
  • Loading branch information
turboladen committed Nov 22, 2011
1 parent 9dd526b commit 03596d0
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 14 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
source :rubygems

gemspec

gem 'rtp', path: '../rtp', require: 'rtp'
12 changes: 12 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@ PATH
parslet (~> 1.1.0)
sdp (~> 0.2.2)

PATH
remote: ../rtp
specs:
rtp (0.1.0)
bindata
log_switch

GEM
remote: http://rubygems.org/
specs:
Saikuro (1.1.0)
activesupport (3.1.1)
multi_json (~> 1.0)
bindata (1.4.3)
blankslate (2.1.2.4)
chronic (0.3.0)
churn (0.0.13)
Expand All @@ -33,6 +41,7 @@ GEM
hirb (0.5.0)
i18n (0.6.0)
json_pure (1.6.1)
log_switch (0.1.4)
main (4.7.1)
metric_fu (2.1.1)
Saikuro (>= 1.1.0)
Expand All @@ -57,6 +66,7 @@ GEM
i18n
progressbar
sexp_processor
rake (0.9.2.2)
rcov (0.9.11)
rcov (0.9.11-java)
reek (1.2.8)
Expand Down Expand Up @@ -96,7 +106,9 @@ DEPENDENCIES
bundler (~> 1.0.0)
code_statistics (~> 0.2.13)
metric_fu (>= 2.0.0)
rake (>= 0.8.7)
rspec (>= 2.5.0)
rtp!
rtsp!
simplecov (>= 0.4.0)
yard (>= 0.6.0)
15 changes: 7 additions & 8 deletions lib/rtsp/client.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require 'socket'
require 'tempfile'
require 'timeout'
require 'rtp/receiver'

require_relative 'transport_parser'
require_relative 'capturer'
require_relative 'error'
require_relative 'global'
require_relative 'helpers'
Expand All @@ -13,7 +13,7 @@
module RTSP

# This is the main interface to an RTSP server. A client object uses a couple
# main objects for configuration: an +RTSP::Capturer+ and a Connection Struct.
# main objects for configuration: an +RTP::Receiver+ and a Connection Struct.
# Use the capturer to configure how to capture the data which is the RTP
# stream provided by the RTSP server. Use the connection object to control
# the connection to the server.
Expand Down Expand Up @@ -56,7 +56,6 @@ class Client
include RTSP::Helpers
extend RTSP::Global

DEFAULT_CAPFILE_NAME = "ruby_rtsp_capture.rtsp"
MAX_BYTES_TO_RECEIVE = 3000

# @return [URI] The URI that points to the RTSP server's resource.
Expand All @@ -80,8 +79,8 @@ class Client
attr_accessor :connection

# Use to get/set an object for capturing received data.
# @param [RTSP::Capturer]
# @return [RTSP::Capturer]
# @param [RTP::Receiver]
# @return [RTP::Receiver]
attr_accessor :capturer

# @return [Symbol] See {RFC section A.1.}[http://tools.ietf.org/html/rfc2326#page-76]
Expand All @@ -95,7 +94,7 @@ def self.configure

# @param [String] server_url URL to the resource to stream. If no scheme is
# given, "rtsp" is assumed. If no port is given, 554 is assumed.
# @yield [Struct::Connection, RTSP::Capturer]
# @yield [Struct::Connection, RTP::Receiver]
# @yieldparam [Struct::Connection] server_url=
# @yieldparam [Struct::Connection] timeout=
# @yieldparam [Struct::Connection] socket=
Expand All @@ -111,7 +110,7 @@ def initialize(server_url=nil)
end

@connection = Struct::Connection.new
@capturer = RTSP::Capturer.new
@capturer = RTP::Receiver.new

yield(connection, capturer) if block_given?

Expand All @@ -124,7 +123,7 @@ def initialize(server_url=nil)
@capturer.rtp_port ||= 9000
@capturer.transport_protocol ||= :UDP
@capturer.broadcast_type ||= :unicast
@capturer.rtp_file ||= Tempfile.new(DEFAULT_CAPFILE_NAME)
@capturer.rtp_file ||= Tempfile.new(RTP::Receiver::DEFAULT_CAPFILE_NAME)

@play_thread = nil
@cseq = 1
Expand Down
1 change: 1 addition & 0 deletions rtsp.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ For more information see: http://www.ietf.org/rfc/rfc2326.txt}
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
s.add_development_dependency(%q<code_statistics>, ["~> 0.2.13"])
s.add_development_dependency(%q<metric_fu>, [">= 2.0.0"])
s.add_development_dependency(%q<rake>, [">= 0.8.7"])
s.add_development_dependency(%q<rspec>, [">= 2.5.0"])
s.add_development_dependency(%q<simplecov>, [">= 0.4.0"])
s.add_development_dependency(%q<yard>, [">= 0.6.0"])
Expand Down
4 changes: 2 additions & 2 deletions sarix_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require './lib/rtsp/client'

cap_file = File.new("sarix_cap.rtsp", "wb")
url = "rtsp://10.221.222.129/stream1"
url = "rtsp://10.221.222.242/stream1"
r = RTSP::Client.new url
r.capturer.rtp_file = cap_file

Expand All @@ -17,7 +17,7 @@
r.setup media_track
r.play aggregate_track

sleep 5
sleep 15

r.teardown media_track

2 changes: 1 addition & 1 deletion soma_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#client[media_track].setup
#client.media_control_tracks.play
client.play aggregate_track
sleep 5
sleep 15
#client[aggregate_track].play
client.teardown aggregate_track

Expand Down
6 changes: 3 additions & 3 deletions spec/rtsp/client_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'sdp'
require_relative '../spec_helper'
require 'rtsp/client'
require 'support/fake_rtsp_server'
require_relative '../support/fake_rtsp_server'

describe RTSP::Client do
def setup_client_at(url)
Expand All @@ -20,8 +20,8 @@ def setup_client_at(url)
end

before do
RTSP::Capturer.any_instance.stub(:run)
RTSP::Capturer.any_instance.stub(:stop)
RTP::Receiver.any_instance.stub(:run)
RTP::Receiver.any_instance.stub(:stop)
end

describe "#initialize" do
Expand Down

0 comments on commit 03596d0

Please sign in to comment.