rairtame 1.0.0 → 1.0.1

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: e92a8765ee301bec0af608a68824428112c1ac4e
4
- data.tar.gz: 1140a3d68939f7035bb90de4a4033099d0dd51ca
3
+ metadata.gz: 9c0b4924eaef60d4bfca86a321c3012f5cf1a869
4
+ data.tar.gz: d60ff3d8e1add80c089c6844953b86847674f976
5
5
  SHA512:
6
- metadata.gz: 08a6bf82444dd5377d57ed06da9785c4b5bce3a93fa149ba00635d412c410583a2623cd05a4c3c025b40222f639fcd53eefe281b00184b540f60314ed7d0be9f
7
- data.tar.gz: 30eae0ee452baafdf042d404cb5d4fe40a809e33a7959185af5d02eb18bd5453d26fc337c16a7695b9c568c9d69f9e1f614cb350d05288a55d5915b7f4b6ffc9
6
+ metadata.gz: 45492f65d282fb1a0cb6b6d427990987c01a67673f60d1bc22458356e00bbe7981e2cb06561b8afc2f838c7689e586dfd7de47e3e2689702031589b90e37328a
7
+ data.tar.gz: ac7e7fb49617cb545bbe1627ea0ce7d0c5111fa74bf91436d58b6cffe68dd2d92f7fdec34403d13486749880389846336d6687114f4b0bd3f96fdda1eecdfe4f
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Rairtame
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/rairtame.svg)](http://badge.fury.io/rb/rairtame)
4
+
3
5
  Rairtame is a library and CLI utility to interact with the `airtame-streamer` JSON-RPC API.
4
6
 
5
7
  It allows to easily control the `airtame-streamer` daemon, which is in charge of capturing and streaming video to an [AIRTAME dongle](http://airtame.com).
data/bin/rairtame CHANGED
@@ -93,17 +93,24 @@ module Rairtame
93
93
  :method => :buffer=
94
94
  },
95
95
  :fluent => {
96
- :short => 'Enable or disable fluent video',
97
- :long => 'Enables or disables the fluent video streaming feature',
96
+ :short => 'Enable or disable fluent video playback',
97
+ :long => 'Enables or disables the fluent video playback (jitterbuffer)',
98
98
  :arg => 'on/off',
99
99
  :allowed => ['on', 'off'],
100
- :method => :video_jitterbuffer=
100
+ :method => :video_jitterbuffer=
101
101
  },
102
- :state => {
103
- :short => 'Show streamer\'s state',
104
- :long => 'Prints streamer\'s state in a pretty way',
102
+ :reliable => {
103
+ :short => 'Enable or disable reliability',
104
+ :long => 'Enables or disables the reliable transport option',
105
+ :arg => 'on/off',
106
+ :allowed => ['on', 'off'],
107
+ :method => :reliable_transport=
108
+ },
109
+ :status => {
110
+ :short => 'Show streamer\'s status',
111
+ :long => 'Prints streamer\'s status in a pretty way',
105
112
  :arg => nil,
106
- :method => :pretty_state
113
+ :method => :pretty_status
107
114
  }
108
115
  }
109
116
 
@@ -113,14 +120,14 @@ module Rairtame
113
120
  def setup
114
121
  program_desc <<EOF
115
122
  A Ruby interface to the airtame-streamer JSON-RPC API, which allows
116
- to stream to an AIRTAME dongle.
123
+ to stream to an AIRTAME dongle.
117
124
  EOF
118
125
 
119
126
  switch [:v, :verbose]
120
127
  switch [:c, :color], :default_value => true
121
128
  flag [:streamer_host], :default_value => 'localhost'
122
129
  flag [:config_file]
123
-
130
+
124
131
  pre do |global_options, command, options, args|
125
132
  @client = Rairtame::Client.new(global_options)
126
133
  String.disable_colorization = !global_options[:color]
@@ -82,13 +82,52 @@ module Rairtame
82
82
  rpc_call(:closeStreamer)
83
83
  end
84
84
 
85
- def state
85
+ def status
86
86
  rpc_call(:getState)
87
87
  end
88
-
89
- def pretty_state
90
- rpc_call(:getState)
88
+ alias :state :status
89
+
90
+ def pretty_status
91
+ puts
92
+ puts "AIRTAME status:"
93
+ puts "---------------"
94
+ state = rpc_call(:getState)['result']
95
+ if state['state'] == 'not initialized'
96
+ puts "Not initialized"
97
+ elsif state['current_mode']
98
+ mode_str = case state['current_mode']
99
+ when 0 then "video"
100
+ when 1 then "work"
101
+ when 2 then "present"
102
+ when 3 then "manual"
103
+ else "unknown"
104
+ end
105
+ fluent = state['remote_settings']['video_jb_flags'] == '1' ? "yes" : "no"
106
+ reliable = state['reliable_transport'] == '1' ? "yes" : "no"
107
+ puts "Mode: #{mode_str}"
108
+ puts "FPS: #{state['video_fps']}"
109
+ puts "Reliability: #{reliable}"
110
+ puts "Fluent playback: #{fluent}"
111
+ puts "Clients:"
112
+ puts " -- No clients connected" if state['clients'].empty?
113
+ state['clients'].each do |client|
114
+ c = client['channel']
115
+ str = "#{c['IP']}: "
116
+ str << "Sent #{(c['bytes_sent'] / 1024.0 / 1024.0).round(2)} MB. "
117
+ str << "Recv: #{(c['bytes_received'] / 1024.0).round(2)} KB. "
118
+ str << "Packet loss: #{c['packet_loss'].to_f.round(2)}. "
119
+ str << "Avg latency: #{c['avg_latency']}"
120
+ puts " -- #{str}"
121
+ end
122
+ state
123
+ else
124
+ puts "Unkown response"
125
+ end
126
+ puts
127
+ puts "(run with -v to see the raw response)"
128
+ state
91
129
  end
130
+ alias :pretty_state :pretty_status
92
131
 
93
132
  def framerate=(v)
94
133
  rpc_call(:setStreamerSettings, 'framerate', v.to_s)
@@ -118,20 +157,12 @@ module Rairtame
118
157
 
119
158
  def video=(v)
120
159
  # TODO: Read av flags first and keep the audio
121
- value = case v
122
- when "on" then "1"
123
- when "off" then "0"
124
- end
125
- rpc_call(:setStreamerSettings, 'av_flags', value)
160
+ rpc_call(:setStreamerSettings, 'av_flags', on_off_to_1_0(v))
126
161
  end
127
162
 
128
163
  # fluent video
129
164
  def video_jitterbuffer=(v)
130
- value = case v
131
- when "on" then "1"
132
- when "off" then "0"
133
- end
134
- rpc_call(:setStreamerSettings, 'video_jb_flags', value)
165
+ rpc_call(:setStreamerSettings, 'video_jb_flags', on_off_to_1_0(v))
135
166
  end
136
167
 
137
168
  # unused
@@ -146,12 +177,28 @@ module Rairtame
146
177
  end
147
178
 
148
179
  def reliable_transport=(v)
149
- warn "Not implemented"
150
- nil
180
+ rpc_call(:setStreamerSettings, 'reliable_transport',
181
+ on_off_to_true_false(v))
151
182
  end
152
183
 
153
184
  private
154
185
 
186
+ def on_off_to_1_0(value)
187
+ case value
188
+ when "off" then "0"
189
+ when "on" then "1"
190
+ else value
191
+ end
192
+ end
193
+
194
+ def on_off_to_true_false(value)
195
+ case value
196
+ when "off" then "false"
197
+ when "on" then "true"
198
+ else value
199
+ end
200
+ end
201
+
155
202
  def log_command(method, params)
156
203
  return unless @verbose
157
204
  puts "Sending command: [#{method} | #{params}]"
@@ -160,7 +207,7 @@ module Rairtame
160
207
  def log_response(r)
161
208
  # log anyway
162
209
  return unless @verbose
163
- is_error = JsonRpcClient.is_error?(r)
210
+ is_error = Jsonrpctcp::Client.is_error?(r)
164
211
  if is_error then warn "Received error:"
165
212
  else puts "Received response:" end
166
213
  pp r
@@ -15,5 +15,5 @@
15
15
  # along with Rairtame. If not, see <http://www.gnu.org/licenses/>
16
16
 
17
17
  module Rairtame
18
- VERSION = "1.0.0"
18
+ VERSION = "1.0.1"
19
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rairtame
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hector Sanjuan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-04 00:00:00.000000000 Z
11
+ date: 2015-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler