mumble-ruby 0.0.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 79af7c6bca2313c1ad4cb6f2d0efd7e51c87bdbd
4
+ data.tar.gz: a0404c3814bccddf1c69a31c5f81dab76fc1d9d4
5
+ SHA512:
6
+ metadata.gz: 187c1eef9e026080cec54984d8ba6c9159c31b8a28f23c31a53e391771b25b72b0dbcff29e79c2976e7918d97d6ab58cfd07c9ac167260baf9743fee51b46339
7
+ data.tar.gz: c6838e53b31f8bd390acc090a5c96bbfb32071861e1d80317ee7c013d5c140d17cfee86e671e0722c3aae798393336cf47d3bc260ec741990ed0117eb2836c44
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ mumble_ruby_gem
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.1.0
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Matthew Perry
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc CHANGED
@@ -14,8 +14,9 @@ There is huge room for improvement in this library and I am willing to accept al
14
14
 
15
15
  == REQUIREMENTS:
16
16
 
17
- * Ruby >= 1.9.2
18
- * CELT Audio Codec Library version 0.7
17
+ * Ruby >= 2.1.0
18
+ * OPUS Audio Codec
19
+ * Murur server > 1.2.4
19
20
 
20
21
  == BASIC USAGE:
21
22
 
data/lib/mumble-ruby.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'celt-ruby'
1
+ require 'opus-ruby'
2
2
  require 'active_support/inflector.rb'
3
3
  require 'mumble-ruby/version'
4
4
  require 'mumble-ruby/messages.rb'
@@ -9,8 +9,7 @@ module Mumble
9
9
  @file = File.open(file, 'rb')
10
10
  @conn = connection
11
11
  @seq = 0
12
- @num_frames = 6
13
- @compressed_size = [@encoder.vbr_rate / 800, 127].min
12
+ @compressed_size = 960
14
13
  @pds = PacketDataStream.new
15
14
  @volume = 1.0
16
15
 
@@ -47,16 +46,13 @@ module Mumble
47
46
  @seq %= 1000000 # Keep sequence number reasonable for long runs
48
47
 
49
48
  @pds.rewind
50
- @seq += @num_frames
49
+ @seq += 1
51
50
  @pds.put_int @seq
52
51
 
53
- @num_frames.times do |i|
54
- frame = @queue.pop
55
- len = frame.size
56
- len = len | 0x80 if i < @num_frames - 1
57
- @pds.append len
58
- @pds.append_block frame
59
- end
52
+ frame = @queue.pop
53
+ len = frame.size
54
+ @pds.put_int len
55
+ @pds.append_block frame
60
56
 
61
57
  size = @pds.size
62
58
  @pds.rewind
@@ -1,17 +1,17 @@
1
1
  require 'thread'
2
+ require 'hashie'
2
3
 
3
4
  module Mumble
4
5
  class ChannelNotFound < StandardError; end
5
6
  class UserNotFound < StandardError; end
6
7
  class NoSupportedCodec < StandardError; end
7
8
 
8
- CODEC_ALPHA = 0
9
- CODEC_BETA = 3
10
-
11
9
  class Client
12
10
  attr_reader :host, :port, :username, :password, :users, :channels
13
11
 
14
- def initialize(host, port=64738, username="Ruby Client", password="")
12
+ CODEC_OPUS = 4
13
+
14
+ def initialize(host, port=64738, username="RubyClient", password="")
15
15
  @host = host
16
16
  @port = port
17
17
  @username = username
@@ -41,11 +41,11 @@ module Mumble
41
41
  end
42
42
 
43
43
  def me
44
- @users[@session]
44
+ users[@session]
45
45
  end
46
46
 
47
47
  def current_channel
48
- @channels[me.channel_id]
48
+ channels[me.channel_id]
49
49
  end
50
50
 
51
51
  def stream_raw_audio(file)
@@ -97,15 +97,16 @@ module Mumble
97
97
  end
98
98
 
99
99
  def find_user(name)
100
- @users.values.find { |u| u.name == name }
100
+ users.values.find { |u| u.name == name }
101
101
  end
102
102
 
103
103
  def find_channel(name)
104
- @channels.values.find { |u| u.name == name }
104
+ channels.values.find { |c| c.name == name }
105
105
  end
106
106
 
107
107
  private
108
108
  def spawn_thread(sym)
109
+ Thread.abort_on_exception = true
109
110
  Thread.new { loop { send sym } }
110
111
  end
111
112
 
@@ -129,31 +130,39 @@ module Mumble
129
130
  @session = message.session
130
131
  end
131
132
  on_channel_state do |message|
132
- @channels[message.channel_id] = message
133
+ if channel = channels[message.channel_id]
134
+ channel.merge! message.to_hash
135
+ else
136
+ channels[message.channel_id] = Hashie::Mash.new(message.to_hash)
137
+ end
133
138
  end
134
139
  on_channel_remove do |message|
135
- @channels.delete(message.channel_id)
140
+ channels.delete(message.channel_id)
136
141
  end
137
142
  on_user_state do |message|
138
- @users[message.session] = message
143
+ if user = users[message.session]
144
+ user.merge! message.to_hash
145
+ else
146
+ users[message.session] = Hashie::Mash.new(message.to_hash)
147
+ end
139
148
  end
140
149
  on_user_remove do |message|
141
- @users.delete(message.session)
150
+ users.delete(message.session)
142
151
  end
143
152
  on_codec_version do |message|
144
- codec_negotiation(message.alpha, message.beta)
153
+ codec_negotiation(message)
145
154
  end
146
155
  end
147
156
 
148
157
  def create_encoder
149
- @encoder = Celt::Encoder.new 48000, 480, 1
150
- @encoder.prediction_request = 0
151
- @encoder.vbr_rate = 60000
158
+ @encoder = Opus::Encoder.new 48000, 480, 1
159
+ @encoder.vbr_rate = 0 # CBR
160
+ @encoder.bitrate = 32000 # 32 kbit/s
152
161
  end
153
162
 
154
163
  def version_exchange
155
164
  send_version({
156
- version: encode_version(1, 2, 3),
165
+ version: encode_version(1, 2, 5),
157
166
  release: "mumble-ruby #{Mumble::VERSION}",
158
167
  os: %x{uname -o}.strip,
159
168
  os_version: %x{uname -v}.strip
@@ -164,15 +173,12 @@ module Mumble
164
173
  send_authenticate({
165
174
  username: @username,
166
175
  password: @password,
167
- celt_versions: [@encoder.bitstream_version]
176
+ opus: true
168
177
  })
169
178
  end
170
179
 
171
- def codec_negotiation(alpha, beta)
172
- @codec = case @encoder.bitstream_version
173
- when alpha then Mumble::CODEC_ALPHA
174
- when beta then Mumble::CODEC_BETA
175
- end
180
+ def codec_negotiation(message)
181
+ @codec = CODEC_OPUS if message.opus
176
182
  end
177
183
 
178
184
  def channel_id(channel)
@@ -191,7 +197,7 @@ module Mumble
191
197
 
192
198
  def user_session(user)
193
199
  id = case user
194
- when Messages::ChannelState
200
+ when Messages::UserState
195
201
  user.session
196
202
  when Fixnum
197
203
  user
@@ -11,7 +11,7 @@ module Mumble
11
11
  end
12
12
 
13
13
  def connect
14
- context = OpenSSL::SSL::SSLContext.new
14
+ context = OpenSSL::SSL::SSLContext.new(:TLSv1)
15
15
  context.verify_mode = OpenSSL::SSL::VERIFY_NONE
16
16
  tcp_sock = TCPSocket.new @host, @port
17
17
  @sock = OpenSSL::SSL::SSLSocket.new tcp_sock, context
@@ -53,12 +53,12 @@ module Mumble
53
53
  private
54
54
  def send_data(data)
55
55
  @write_lock.synchronize do
56
- @sock.syswrite data
56
+ @sock.write data
57
57
  end
58
58
  end
59
59
 
60
60
  def read_data(len)
61
- @sock.sysread len
61
+ @sock.read len
62
62
  end
63
63
 
64
64
  def message(obj)
@@ -1,5 +1,5 @@
1
1
  ### Generated by rprotoc. DO NOT EDIT!
2
- ### <proto file: Mumble.proto>
2
+ ### <proto file: mumble.proto>
3
3
 
4
4
  require 'protobuf/message/message'
5
5
  require 'protobuf/message/enum'
@@ -8,7 +8,7 @@ require 'protobuf/message/extend'
8
8
 
9
9
  module Mumble
10
10
  module Messages
11
- ::Protobuf::OPTIONS[:optimize_for] = :SPEED
11
+ ::Protobuf::OPTIONS[:"optimize_for"] = :SPEED
12
12
  HEADER_FORMAT = "nN"
13
13
 
14
14
  @@sym_to_type = {
@@ -36,7 +36,8 @@ module Mumble
36
36
  codec_version: 21,
37
37
  user_stats: 22,
38
38
  request_blob: 23,
39
- server_config: 24
39
+ server_config: 24,
40
+ suggest_config: 25
40
41
  }
41
42
 
42
43
  @@type_to_sym = @@sym_to_type.invert
@@ -78,6 +79,7 @@ module Mumble
78
79
  optional :string, :password, 2
79
80
  repeated :string, :tokens, 3
80
81
  repeated :int32, :celt_versions, 4
82
+ optional :bool, :opus, 5, :default => false
81
83
  end
82
84
  class Ping < ::Protobuf::Message
83
85
  defined_in __FILE__
@@ -123,6 +125,12 @@ module Mumble
123
125
  optional :uint32, :max_bandwidth, 2
124
126
  optional :string, :welcome_text, 3
125
127
  optional :uint64, :permissions, 4
128
+ end
129
+ class SuggestConfig < ::Protobuf::Message
130
+ defined_in __FILE__
131
+ optional :uint32, :version, 1
132
+ optional :bool, :positional, 2
133
+ optional :bool, :push_to_talk, 3
126
134
  end
127
135
  class ChannelRemove < ::Protobuf::Message
128
136
  defined_in __FILE__
@@ -207,6 +215,7 @@ module Mumble
207
215
  MissingCertificate = value(:MissingCertificate, 7)
208
216
  UserName = value(:UserName, 8)
209
217
  ChannelFull = value(:ChannelFull, 9)
218
+ NestingLimit = value(:NestingLimit, 10)
210
219
  end
211
220
  optional :uint32, :permission, 1
212
221
  optional :uint32, :channel_id, 2
@@ -254,7 +263,7 @@ module Mumble
254
263
  optional :bytes, :client_nonce, 2
255
264
  optional :bytes, :server_nonce, 3
256
265
  end
257
- class ContextActionAdd < ::Protobuf::Message
266
+ class ContextActionModify < ::Protobuf::Message
258
267
  defined_in __FILE__
259
268
  class Context < ::Protobuf::Enum
260
269
  defined_in __FILE__
@@ -262,9 +271,15 @@ module Mumble
262
271
  Channel = value(:Channel, 2)
263
272
  User = value(:User, 4)
264
273
  end
274
+ class Operation < ::Protobuf::Enum
275
+ defined_in __FILE__
276
+ Add = value(:Add, 0)
277
+ Remove = value(:Remove, 1)
278
+ end
265
279
  required :string, :action, 1
266
- required :string, :text, 2
280
+ optional :string, :text, 2
267
281
  optional :uint32, :context, 3
282
+ optional :Operation, :operation, 4
268
283
  end
269
284
  class ContextAction < ::Protobuf::Message
270
285
  defined_in __FILE__
@@ -305,6 +320,7 @@ module Mumble
305
320
  required :int32, :alpha, 1
306
321
  required :int32, :beta, 2
307
322
  required :bool, :prefer_alpha, 3, :default => true
323
+ optional :bool, :opus, 4, :default => false
308
324
  end
309
325
  class UserStats < ::Protobuf::Message
310
326
  defined_in __FILE__
@@ -333,6 +349,13 @@ module Mumble
333
349
  optional :uint32, :onlinesecs, 16
334
350
  optional :uint32, :idlesecs, 17
335
351
  optional :bool, :strong_certificate, 18, :default => false
352
+ optional :bool, :opus, 19, :default => false
353
+ end
354
+ class SuggestConfig < ::Protobuf::Message
355
+ defined_in __FILE__
356
+ optional :uint32, :version, 1
357
+ optional :bool, :positional, 2
358
+ optional :bool, :push_to_talk, 3
336
359
  end
337
360
  class RequestBlob < ::Protobuf::Message
338
361
  defined_in __FILE__
@@ -18,6 +18,7 @@ message Authenticate {
18
18
  optional string password = 2;
19
19
  repeated string tokens = 3;
20
20
  repeated int32 celt_versions = 4;
21
+ optional bool opus = 5 [default = false];
21
22
  }
22
23
 
23
24
  message Ping {
@@ -144,6 +145,7 @@ message PermissionDenied {
144
145
  MissingCertificate = 7;
145
146
  UserName = 8;
146
147
  ChannelFull = 9;
148
+ NestingLimit = 10;
147
149
  }
148
150
  optional uint32 permission = 1;
149
151
  optional uint32 channel_id = 2;
@@ -190,15 +192,20 @@ message CryptSetup {
190
192
  optional bytes server_nonce = 3;
191
193
  }
192
194
 
193
- message ContextActionAdd {
195
+ message ContextActionModify {
194
196
  enum Context {
195
197
  Server = 0x01;
196
198
  Channel = 0x02;
197
199
  User = 0x04;
198
200
  }
201
+ enum Operation {
202
+ Add = 0;
203
+ Remove = 1;
204
+ }
199
205
  required string action = 1;
200
- required string text = 2;
206
+ optional string text = 2;
201
207
  optional uint32 context = 3;
208
+ optional Operation operation = 4;
202
209
  }
203
210
 
204
211
  message ContextAction {
@@ -237,6 +244,7 @@ message CodecVersion {
237
244
  required int32 alpha = 1;
238
245
  required int32 beta = 2;
239
246
  required bool prefer_alpha = 3 [default = true];
247
+ optional bool opus = 4 [default = false];
240
248
  }
241
249
 
242
250
  message UserStats {
@@ -267,6 +275,13 @@ message UserStats {
267
275
  optional uint32 onlinesecs = 16;
268
276
  optional uint32 idlesecs = 17;
269
277
  optional bool strong_certificate = 18 [default = false];
278
+ optional bool opus = 19 [default = false];
279
+ }
280
+
281
+ message SuggestConfig {
282
+ optional uint32 version = 1;
283
+ optional bool positional = 2;
284
+ optional bool push_to_talk = 3;
270
285
  }
271
286
 
272
287
  message RequestBlob {
@@ -1,3 +1,3 @@
1
1
  module Mumble
2
- VERSION = "0.0.3"
2
+ VERSION = "1.0.0"
3
3
  end
data/mumble-ruby.gemspec CHANGED
@@ -16,6 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.version = Mumble::VERSION
17
17
 
18
18
  gem.add_dependency "activesupport"
19
- gem.add_dependency "celt-ruby"
20
19
  gem.add_dependency "ruby_protobuf"
20
+ gem.add_dependency "hashie"
21
+ gem.add_dependency "opus-ruby"
21
22
  end
metadata CHANGED
@@ -1,49 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumble-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Matthew Perry
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-04-28 00:00:00.000000000 Z
11
+ date: 2014-02-23 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activesupport
16
- requirement: &16063820 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *16063820
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
25
27
  - !ruby/object:Gem::Dependency
26
- name: celt-ruby
27
- requirement: &16063320 !ruby/object:Gem::Requirement
28
- none: false
28
+ name: ruby_protobuf
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ! '>='
31
+ - - ">="
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *16063320
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
36
41
  - !ruby/object:Gem::Dependency
37
- name: ruby_protobuf
38
- requirement: &16062600 !ruby/object:Gem::Requirement
39
- none: false
42
+ name: hashie
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: opus-ruby
57
+ requirement: !ruby/object:Gem::Requirement
40
58
  requirements:
41
- - - ! '>='
59
+ - - ">="
42
60
  - !ruby/object:Gem::Version
43
61
  version: '0'
44
62
  type: :runtime
45
63
  prerelease: false
46
- version_requirements: *16062600
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
47
69
  description: Ruby API for interacting with a mumble server
48
70
  email:
49
71
  - perrym5@rpi.edu
@@ -51,9 +73,11 @@ executables: []
51
73
  extensions: []
52
74
  extra_rdoc_files: []
53
75
  files:
54
- - .gitignore
55
- - .rvmrc
76
+ - ".gitignore"
77
+ - ".ruby-gemset"
78
+ - ".ruby-version"
56
79
  - Gemfile
80
+ - LICENSE.txt
57
81
  - README.rdoc
58
82
  - Rakefile
59
83
  - lib/mumble-ruby.rb
@@ -67,26 +91,25 @@ files:
67
91
  - mumble-ruby.gemspec
68
92
  homepage: http://www.github.com/perrym5/mumble-ruby
69
93
  licenses: []
94
+ metadata: {}
70
95
  post_install_message:
71
96
  rdoc_options: []
72
97
  require_paths:
73
98
  - lib
74
99
  required_ruby_version: !ruby/object:Gem::Requirement
75
- none: false
76
100
  requirements:
77
- - - ! '>='
101
+ - - ">="
78
102
  - !ruby/object:Gem::Version
79
103
  version: '0'
80
104
  required_rubygems_version: !ruby/object:Gem::Requirement
81
- none: false
82
105
  requirements:
83
- - - ! '>='
106
+ - - ">="
84
107
  - !ruby/object:Gem::Version
85
108
  version: '0'
86
109
  requirements: []
87
110
  rubyforge_project:
88
- rubygems_version: 1.8.10
111
+ rubygems_version: 2.2.2
89
112
  signing_key:
90
- specification_version: 3
113
+ specification_version: 4
91
114
  summary: Implements the mumble VOIP protocol in ruby for more easily writing clients.
92
115
  test_files: []
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use --create ruby-1.9.3-p0@mumble_ruby_gem