Module: Pili
- Defined in:
- lib/pili/hub.rb,
lib/pili/rpc.rb,
lib/pili/auth.rb,
lib/pili/client.rb,
lib/pili/config.rb,
lib/pili/stream.rb,
lib/pili/version.rb,
lib/pili/exception.rb
Defined Under Namespace
Modules: Config Classes: Client, Hub, Mac, RPCError, ResourceConflict, ResourceNotExist, Stream, StreamInfo
Constant Summary collapse
- VERSION =
"2.0.2"
Class Method Summary collapse
-
.hdl_play_url(domain, hub, stream_key) ⇒ Object
生成 HDL 直播地址.
-
.hls_play_url(domain, hub, stream_key) ⇒ Object
生成 HLS 直播地址.
-
.rtmp_play_url(domain, hub, stream_key) ⇒ Object
生成 RTMP 直播地址.
-
.rtmp_publish_url(domain, hub, stream_key, mac, expire_after_seconds) ⇒ Object
生成 RTMP 推流地址.
-
.snapshot_play_url(domain, hub, stream_key) ⇒ Object
生成截图直播地址.
Class Method Details
.hdl_play_url(domain, hub, stream_key) ⇒ Object
生成 HDL 直播地址.
39 40 41 |
# File 'lib/pili/client.rb', line 39 def hdl_play_url(domain, hub, stream_key) "http://#{domain}/#{hub}/#{stream_key}.flv" end |
.hls_play_url(domain, hub, stream_key) ⇒ Object
生成 HLS 直播地址.
34 35 36 |
# File 'lib/pili/client.rb', line 34 def hls_play_url(domain, hub, stream_key) "http://#{domain}/#{hub}/#{stream_key}.m3u8" end |
.rtmp_play_url(domain, hub, stream_key) ⇒ Object
生成 RTMP 直播地址.
29 30 31 |
# File 'lib/pili/client.rb', line 29 def rtmp_play_url(domain, hub, stream_key) "rtmp://#{domain}/#{hub}/#{stream_key}" end |
.rtmp_publish_url(domain, hub, stream_key, mac, expire_after_seconds) ⇒ Object
生成 RTMP 推流地址. expire_after_seconds 表示 URL 在多久之后失效.
21 22 23 24 25 26 |
# File 'lib/pili/client.rb', line 21 def rtmp_publish_url(domain, hub, stream_key, mac, expire_after_seconds) expire = Time.new.to_i + expire_after_seconds path = "/#{hub}/#{stream_key}?e=#{expire}" token = mac.sign(path) "rtmp://#{domain}#{path}&token=#{token}" end |
.snapshot_play_url(domain, hub, stream_key) ⇒ Object
生成截图直播地址.
44 45 46 |
# File 'lib/pili/client.rb', line 44 def snapshot_play_url(domain, hub, stream_key) "http://#{domain}/#{hub}/#{stream_key}.jpg" end |