Class: Sportsflix::Players::Proxies::Acestream::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/sportsflix/players/proxies/acestream.rb

Constant Summary collapse

ACESTREAM_STREAM_URI_PREFIX =
'acestream://'
ACESTREAM_PROXY_DOCKER_NAME =
'acestream'

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Client

Returns a new instance of Client.



12
13
14
15
16
17
18
19
# File 'lib/sportsflix/players/proxies/acestream.rb', line 12

def initialize(options)
  @verbose      = options[:verbose]
  @video_format = options['video-format']
  @server_ip    = options['server-ip']
  @proxy_image  = options['acestream-proxy-image']

  @executor = Sportsflix::Utils::Executor.new(options)
end

Instance Method Details

#startObject



21
22
23
24
# File 'lib/sportsflix/players/proxies/acestream.rb', line 21

def start
  @executor.run %{docker pull #{@proxy_image}}
  @executor.run %{docker run -d -t -p 8000:8000 --name #{ACESTREAM_PROXY_DOCKER_NAME} #{@proxy_image}}
end

#stopObject



26
27
28
# File 'lib/sportsflix/players/proxies/acestream.rb', line 26

def stop
  @executor.run %{docker rm -f #{ACESTREAM_PROXY_DOCKER_NAME}}
end

#url(uri) ⇒ Object



30
31
32
33
34
# File 'lib/sportsflix/players/proxies/acestream.rb', line 30

def url(uri)
  stream_uuid = uri.sub(ACESTREAM_STREAM_URI_PREFIX, '')
  machine_ip  = @server_ip || get_ip_from_host || local_ip
  "http://#{machine_ip}:8000/pid/#{stream_uuid}/stream.#{@video_format}"
end