pili 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bdaa7674765c108d9c5188d267b4bc6c52a6ed82
4
- data.tar.gz: fed41e06d022b17ac10951ec91a9ff293d3b2d66
3
+ metadata.gz: bf5d334a509a06baeeb43e0d89f0937f4e96a3db
4
+ data.tar.gz: 04bcbfcffe3cb15134b1aadb2db0ecc59a8166c7
5
5
  SHA512:
6
- metadata.gz: afaf9fe81e1fe2670820ca592b6ff7a917b972b7a1d7abda20cc58a7b810cb5389ea43709984217c589010a41740f4ca634b100c95762fc01f4417118a9c56d6
7
- data.tar.gz: dfea20eb80debda99461065a384f983aa8f5db98df1999200fe8fe6017b3a3c14b76be3e47dbfc36630e2cab605fa99e47740152c06ddf5169ee308c68caa3f2
6
+ metadata.gz: 460b40e5b5a7fa7088d87faf4e89b0f57e1203c676f4e5947fc621bcb3f4cb0f6915d3edb52918c862e51c45db366ffec5a3f9a9a61383d3c8c3194b992989f2
7
+ data.tar.gz: a4638145b882b29acb14e6f39119fa80e20919bbbfa6a9d47f78fbfcab31e6e494c260a094de9160b6913dbe7e20343140d77f3946f6a2f1b3e125018ecde243
data/lib/pili/config.rb CHANGED
@@ -6,11 +6,11 @@ module Pili
6
6
  DEFAULT_OPTIONS = {
7
7
  :api_version => "v1",
8
8
  :api_scheme => "http",
9
- :api_host => "pili.qiniuapi.com",
9
+ :api_host => "pili.qiniuapi.com"
10
10
 
11
- :rtmp_publish_host => "pub.z1.glb.pili.qiniup.com",
12
- :rtmp_play_host => "live.z1.glb.pili.qiniucdn.com",
13
- :hls_play_host => "hls.z1.glb.pili.qiniuapi.com"#,
11
+ # :rtmp_publish_host => "pub.z1.glb.pili.qiniup.com",
12
+ # :rtmp_play_host => "live.z1.glb.pili.qiniucdn.com",
13
+ # :hls_play_host => "hls.z1.glb.pili.qiniuapi.com",
14
14
 
15
15
  # :access_key => "",
16
16
  # :secret_key => ""
@@ -40,18 +40,6 @@ module Pili
40
40
  settings[:secret_key]
41
41
  end
42
42
 
43
- def rtmp_publish_host
44
- settings[:rtmp_publish_host]
45
- end
46
-
47
- def rtmp_play_host
48
- settings[:rtmp_play_host]
49
- end
50
-
51
- def hls_play_host
52
- settings[:hls_play_host]
53
- end
54
-
55
43
  end
56
44
  end
57
45
  end
data/lib/pili/utils.rb CHANGED
@@ -8,6 +8,11 @@ module Pili
8
8
  arg.to_s.strip.length == 0
9
9
  end
10
10
 
11
+ def get_stream_hub_and_title(stream_id)
12
+ a = stream_id.split(".")
13
+ [a[1], a[2]]
14
+ end
15
+
11
16
  end
12
17
  end
13
18
  end
data/lib/pili/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pili
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/pili.rb CHANGED
@@ -85,54 +85,50 @@ module Pili
85
85
  end
86
86
 
87
87
 
88
- def get_stream_publish_url(stream_id, publish_key, publish_security, nonce = nil)
88
+ def get_stream_publish_url(publish_host, stream_id, publish_key, publish_security, nonce = nil)
89
89
  nonce = nonce.to_i
90
90
  nonce = (Time.now.to_f * 1000.0).to_i if nonce == 0
91
91
 
92
- a = stream_id.split(".")
93
- hub, title = a[1], a[2]
92
+ hub, title = Utils.get_stream_hub_and_title(stream_id)
94
93
 
95
94
  if publish_security == "static"
96
- return "rtmp://#{Config.rtmp_publish_host}/#{hub}/#{title}?key=#{publish_key}"
95
+ return "rtmp://#{publish_host}/#{hub}/#{title}?key=#{publish_key}"
97
96
  else
98
97
  token = Auth.sign(publish_key, "/#{hub}/#{title}?nonce=#{nonce}")
99
- return "rtmp://#{Config.rtmp_publish_host}/#{hub}/#{title}?nonce=#{nonce}&token=#{token}"
98
+ return "rtmp://#{publish_host}/#{hub}/#{title}?nonce=#{nonce}&token=#{token}"
100
99
  end
101
100
  end
102
101
 
103
102
 
104
- def get_stream_rtmp_live_url(stream_id, preset = nil)
105
- a = stream_id.split(".")
106
- hub, title = a[1], a[2]
103
+ def get_stream_rtmp_live_url(play_host, stream_id, preset = nil)
104
+ hub, title = Utils.get_stream_hub_and_title(stream_id)
107
105
 
108
106
  if Utils.blank? preset
109
- return "rtmp://#{Config.rtmp_play_host}/#{hub}/#{title}"
107
+ return "rtmp://#{play_host}/#{hub}/#{title}"
110
108
  else
111
- return "rtmp://#{Config.rtmp_play_host}/#{hub}/#{title}@#{preset}"
109
+ return "rtmp://#{play_host}/#{hub}/#{title}@#{preset}"
112
110
  end
113
111
  end
114
112
 
115
113
 
116
- def get_stream_hls_live_url(stream_id, preset = nil)
117
- a = stream_id.split(".")
118
- hub, title = a[1], a[2]
114
+ def get_stream_hls_live_url(play_host, stream_id, preset = nil)
115
+ hub, title = Utils.get_stream_hub_and_title(stream_id)
119
116
 
120
117
  if Utils.blank? preset
121
- return "http://#{Config.hls_play_host}/#{hub}/#{title}.m3u8"
118
+ return "http://#{play_host}/#{hub}/#{title}.m3u8"
122
119
  else
123
- return "http://#{Config.hls_play_host}/#{hub}/#{title}@#{preset}.m3u8"
120
+ return "http://#{play_host}/#{hub}/#{title}@#{preset}.m3u8"
124
121
  end
125
122
  end
126
123
 
127
124
 
128
- def get_stream_hls_playback_url(stream_id, start_second, end_second, preset = nil)
129
- a = stream_id.split(".")
130
- hub, title = a[1], a[2]
125
+ def get_stream_hls_playback_url(play_host, stream_id, start_second, end_second, preset = nil)
126
+ hub, title = Utils.get_stream_hub_and_title(stream_id)
131
127
 
132
128
  if Utils.blank? preset
133
- return "http://#{Config.hls_play_host}/#{hub}/#{title}.m3u8?start=#{start_second}&end=#{end_second}"
129
+ return "http://#{play_host}/#{hub}/#{title}.m3u8?start=#{start_second}&end=#{end_second}"
134
130
  else
135
- return "http://#{Config.hls_play_host}/#{hub}/#{title}@#{preset}.m3u8?start=#{start_second}&end=#{end_second}"
131
+ return "http://#{play_host}/#{hub}/#{title}@#{preset}.m3u8?start=#{start_second}&end=#{end_second}"
136
132
  end
137
133
  end
138
134
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pili
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miclle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-29 00:00:00.000000000 Z
11
+ date: 2015-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler