Class: Openplay::Client
- Inherits:
-
Object
- Object
- Openplay::Client
- Defined in:
- lib/openplay/client.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#list ⇒ Object
List available servers.
-
#throw ⇒ Object
Throw video to a particular server.
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/openplay/client.rb', line 8 def initialize(={}) if [:hostname] server = get_server_by_hostname([:hostname]) raise "No server found with hostname #{[:hostname]}" unless server @host = server.ip @port = server.port else @host = [:host] @port = [:port] end @resolution = [:resolution] || screen_resolution end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
6 7 8 |
# File 'lib/openplay/client.rb', line 6 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
6 7 8 |
# File 'lib/openplay/client.rb', line 6 def port @port end |
Instance Method Details
#list ⇒ Object
List available servers
34 35 36 |
# File 'lib/openplay/client.rb', line 34 def list DiscoversServers.find_servers end |
#throw ⇒ Object
Throw video to a particular server
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/openplay/client.rb', line 22 def throw = [] << "-framerate ntsc" << "-video_size #{@resolution}" << "-f x11grab -i #{ENV['DISPLAY']}" << "-f alsa -i pulse" << "-vcodec libx264 -tune zerolatency -crf 26 -preset ultrafast" << "-f mpegts udp://#{host}:#{port}?pkt_size=#{packet_size}" `ffmpeg #{.join(' ')}` end |