raop-client 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,11 @@
1
1
  = Net::RAOP::Client CHANGELOG
2
2
 
3
+ == 0.1.1
4
+
5
+ * Fixing a bug with setting volume.
6
+ * Added options and flush methods
7
+ * Using IO#write instead of IO#syswrite
8
+
3
9
  == 0.1.0
4
10
 
5
11
  * Birthday!
@@ -6,6 +6,8 @@ require 'raop'
6
6
 
7
7
  raop = Net::RAOP::Client.new(ARGV[0])
8
8
  raop.connect
9
+ raop.volume = -10
9
10
  raop.play $stdin
11
+ sleep 10
10
12
  raop.disconnect
11
13
 
@@ -4,7 +4,7 @@ require 'socket'
4
4
  class Net::RAOP::Client
5
5
  ##
6
6
  # The version of Net::RAOP::Client you're using
7
- VERSION = '0.1.0'
7
+ VERSION = '0.1.1'
8
8
 
9
9
  ##
10
10
  # Create a new Net::RAOP::Client to connect to +host+ Airport Express
@@ -55,8 +55,8 @@ class Net::RAOP::Client
55
55
  ##
56
56
  # Set the +volume+ on the Airport Express. -144 is quiet, 0 is loud.
57
57
  def volume=(volume)
58
- volume = 0 + volume if volume < 0
59
- raise ArgumentError if volume < 0 || volume > 144
58
+ volume = volume.abs
59
+ raise ArgumentError if volume > 144
60
60
  params = Net::RTSP::SetParameter.new(@session_id,
61
61
  { :volume => "-#{volume}".to_i }
62
62
  )
@@ -78,6 +78,15 @@ class Net::RAOP::Client
78
78
  end
79
79
 
80
80
  private
81
+ def flush
82
+ puts @seq
83
+ @rtsp_client.request(Net::RTSP::Flush.new(@session_id, @seq))
84
+ end
85
+
86
+ def options
87
+ @rtsp_client.request(Net::RTSP::Options.new)
88
+ end
89
+
81
90
  @@data_cache = {}
82
91
  def send_sample(sample, pos = 0, count = sample.length)
83
92
  # FIXME do we really need +pos+ or +count+?
@@ -103,7 +112,7 @@ class Net::RAOP::Client
103
112
  @aes_crypt.update(sample.slice(0, crypt_length)) +
104
113
  sample.slice(crypt_length, sample.length)
105
114
 
106
- @data_socket.syswrite(data)
115
+ @data_socket.write(data)
107
116
  end
108
117
 
109
118
  def rsa_encrypt(plain_text)
@@ -105,9 +105,9 @@ module Net
105
105
  end
106
106
 
107
107
  private
108
- def write_header(sock, client_id, cseq)
108
+ def write_header(sock, client_id, cseq, url = nil)
109
109
  self['Content-Length'] = @body.length.to_s if @body
110
- url = sprintf("rtsp://%s/%s", sock.io.addr.last, client_id)
110
+ url ||= sprintf("rtsp://%s/%s", sock.io.addr.last, client_id)
111
111
  buf = "#{@method} #{url} RTSP/1.0\r\n" +
112
112
  "CSeq: #{cseq}\r\n"
113
113
  each_capitalized do |k,v|
@@ -124,12 +124,40 @@ module Net
124
124
  end
125
125
  end
126
126
 
127
+ class GetParameter < RTSPGenericRequest
128
+ def initialize(session_id, parameters)
129
+ super('GET_PARAMETER')
130
+ self['Content-Type'] = 'text/parameters'
131
+ self['Session'] = session_id
132
+ @body = parameters.join("\r\n") + "\r\n"
133
+ end
134
+ end
135
+
136
+ class Options < RTSPGenericRequest
137
+ def initialize
138
+ super('OPTIONS')
139
+ end
140
+
141
+ private
142
+ def write_header(sock, client_id, cseq, url = nil)
143
+ super(sock, client_id, cseq, '*')
144
+ end
145
+ end
146
+
127
147
  class Teardown < RTSPGenericRequest
128
148
  def initialize
129
149
  super('TEARDOWN')
130
150
  end
131
151
  end
132
152
 
153
+ class Flush < RTSPGenericRequest
154
+ def initialize(session_id, seq)
155
+ super('Flush')
156
+ self['Session'] = session_id
157
+ self['RTP-Info'] = "seq=0;rtptime=0"
158
+ end
159
+ end
160
+
133
161
  class SetParameter < RTSPGenericRequest
134
162
  def initialize(session_id, opts = {})
135
163
  super('SET_PARAMETER')
@@ -146,7 +174,7 @@ module Net
146
174
  def initialize(session_id)
147
175
  super('RECORD')
148
176
  self['Range'] = 'npt=0-'
149
- self['RTP-Info'] = 'seq=0;rtptime=0'
177
+ self['RTP-Info'] = "seq=0;rtptime=0"
150
178
  self['Session'] = session_id
151
179
  end
152
180
  end
@@ -167,6 +195,7 @@ module Net
167
195
  self['Apple-Challenge'] = sac.gsub(/[=\s]/, '')
168
196
  end
169
197
 
198
+ private
170
199
  def write_header(sock, client_id, cseq)
171
200
  @body = sprintf(
172
201
  "v=0\r\n" +
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: raop-client
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.0
7
- date: 2007-06-14 00:00:00 -07:00
6
+ version: 0.1.1
7
+ date: 2007-06-17 00:00:00 -07:00
8
8
  summary: Airport Express streaming music client
9
9
  require_paths:
10
10
  - lib