Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding options and flush methods

git-svn-id: svn://rubyforge.org/var/svn/raop/trunk@14 55bd698d-9d04-498c-8937-980560813b27
  • Loading branch information...
commit 7f8657c79e3afa9c43de6af0ee17a8e7a2d8d9dc 1 parent 415328b
aaronp authored
View
1  CHANGELOG.txt
@@ -3,6 +3,7 @@
== 0.1.1
* Fixing a bug with setting volume.
+* Added options and flush methods
== 0.1.0
View
2  examples/read_stdin.rb
@@ -6,6 +6,8 @@
raop = Net::RAOP::Client.new(ARGV[0])
raop.connect
+raop.volume = -10
raop.play $stdin
+sleep 10
raop.disconnect
View
9 lib/raop/client.rb
@@ -78,6 +78,15 @@ def disconnect
end
private
+ def flush
+ puts @seq
+ @rtsp_client.request(Net::RTSP::Flush.new(@session_id, @seq))
+ end
+
+ def options
+ @rtsp_client.request(Net::RTSP::Options.new)
+ end
+
@@data_cache = {}
def send_sample(sample, pos = 0, count = sample.length)
# FIXME do we really need +pos+ or +count+?
View
35 lib/raop/rtsp.rb
@@ -105,9 +105,9 @@ def exec(sock, client_id, cseq)
end
private
- def write_header(sock, client_id, cseq)
+ def write_header(sock, client_id, cseq, url = nil)
self['Content-Length'] = @body.length.to_s if @body
- url = sprintf("rtsp://%s/%s", sock.io.addr.last, client_id)
+ url ||= sprintf("rtsp://%s/%s", sock.io.addr.last, client_id)
buf = "#{@method} #{url} RTSP/1.0\r\n" +
"CSeq: #{cseq}\r\n"
each_capitalized do |k,v|
@@ -124,12 +124,40 @@ def write_body(sock)
end
end
+ class GetParameter < RTSPGenericRequest
+ def initialize(session_id, parameters)
+ super('GET_PARAMETER')
+ self['Content-Type'] = 'text/parameters'
+ self['Session'] = session_id
+ @body = parameters.join("\r\n") + "\r\n"
+ end
+ end
+
+ class Options < RTSPGenericRequest
+ def initialize
+ super('OPTIONS')
+ end
+
+ private
+ def write_header(sock, client_id, cseq, url = nil)
+ super(sock, client_id, cseq, '*')
+ end
+ end
+
class Teardown < RTSPGenericRequest
def initialize
super('TEARDOWN')
end
end
+ class Flush < RTSPGenericRequest
+ def initialize(session_id, seq)
+ super('Flush')
+ self['Session'] = session_id
+ self['RTP-Info'] = "seq=0;rtptime=0"
+ end
+ end
+
class SetParameter < RTSPGenericRequest
def initialize(session_id, opts = {})
super('SET_PARAMETER')
@@ -146,7 +174,7 @@ class Record < RTSPGenericRequest
def initialize(session_id)
super('RECORD')
self['Range'] = 'npt=0-'
- self['RTP-Info'] = 'seq=0;rtptime=0'
+ self['RTP-Info'] = "seq=0;rtptime=0"
self['Session'] = session_id
end
end
@@ -167,6 +195,7 @@ def initialize(sac, key, iv)
self['Apple-Challenge'] = sac.gsub(/[=\s]/, '')
end
+ private
def write_header(sock, client_id, cseq)
@body = sprintf(
"v=0\r\n" +
Please sign in to comment.
Something went wrong with that request. Please try again.