Class: Dropcam::Stream
- Inherits:
-
Object
- Object
- Dropcam::Stream
- Defined in:
- lib/dropcam/stream.rb
Constant Summary collapse
- DEFAULT_RTSP_PORT =
"554"
- BUFFER_SIZE =
1024
Instance Attribute Summary collapse
-
#camera ⇒ Object
readonly
Returns the value of attribute camera.
Instance Method Summary collapse
-
#initialize(camera) ⇒ Stream
constructor
A new instance of Stream.
- #rtmp_details ⇒ Object
- #rtmpdump ⇒ Object
- #rtsp_details ⇒ Object
- #rtsp_uri ⇒ Object
- #save_live(filename, duration = 30) ⇒ Object
Constructor Details
#initialize(camera) ⇒ Stream
Returns a new instance of Stream.
9 10 11 |
# File 'lib/dropcam/stream.rb', line 9 def initialize(camera) @camera = camera end |
Instance Attribute Details
#camera ⇒ Object (readonly)
Returns the value of attribute camera.
8 9 10 |
# File 'lib/dropcam/stream.rb', line 8 def camera @camera end |
Instance Method Details
#rtmp_details ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/dropcam/stream.rb', line 26 def rtmp_details { :app => "nexus", :host => "stream.dropcam.com", :playpath => @camera.uuid, :variables => { "S:" => @camera.session_token } } end |
#rtmpdump ⇒ Object
35 36 37 38 39 |
# File 'lib/dropcam/stream.rb', line 35 def rtmpdump stream_command = "rtmpdump --live --app nexus --host stream.dropcam.com --playpath " + @camera.uuid stream_command += " --conn S:" + @camera.session_token return stream_command end |
#rtsp_details ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/dropcam/stream.rb', line 12 def rtsp_details { :protocol => "rtsp", :user => "user", :password => @camera.session_token, :base => URI.parse(@camera.download_host).scheme, :path => @camera.uuid, :port => DEFAULT_RTSP_PORT } end |
#rtsp_uri ⇒ Object
22 23 24 |
# File 'lib/dropcam/stream.rb', line 22 def rtsp_uri URI.parse "rtsp://user:#{@camera.session_token}@#{URI.parse(@camera.download_host).scheme}:#{DEFAULT_RTSP_PORT}/#{@camera.uuid}" end |
#save_live(filename, duration = 30) ⇒ Object
41 42 43 44 45 |
# File 'lib/dropcam/stream.rb', line 41 def save_live(filename, duration=30) raise StandardError, "RTMPDump is not found in your PATH" unless system("which -s rtmpdump") # we add 10 seconds because it take about that amount of time to get the stream up and running with rtmpdump run_with_timeout("#{self.rtmpdump} --quiet --flv #{filename}", duration+10, 1) end |