librtmp 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  .bundle
4
4
  .config
5
5
  coverage
6
+ Gemfile.lock
6
7
  InstalledFiles
7
8
  lib/bundler/man
8
9
  pkg
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ v0.1.1
2
+ ======
3
+
4
+ * Added Streamer class to encapsulate the most common use cases of a RTMP
5
+ client.
6
+
7
+ v0.1.0
8
+ ======
9
+
10
+ * Initial implementation of FFI interface to librtmp.
data/README.md CHANGED
@@ -1,4 +1,10 @@
1
1
  ruby-librtmp
2
2
  ============
3
3
 
4
- Ruby bindings to librtmp (from rtmpdump)
4
+ Ruby bindings to librtmp (from rtmpdump). Provides a Streamer class to stream
5
+ data to and from an RTMP server, such as Flash Media Server or Wowza.
6
+
7
+ Limitations
8
+ -----------
9
+
10
+ * Authentication is not currently supported
@@ -209,7 +209,7 @@ module Librtmp
209
209
 
210
210
  attach_function :RTMP_Init, [RTMP], :void
211
211
  attach_function :RTMP_Close, [RTMP], :void
212
- attach_function :RTMP_Alloc, [RTMP], RTMP
212
+ attach_function :RTMP_Alloc, [], RTMP
213
213
  attach_function :RTMP_Free, [RTMP], :void
214
214
  attach_function :RTMP_EnableWrite, [RTMP], :void
215
215
 
data/lib/librtmp/ffi.rb CHANGED
@@ -1,7 +1 @@
1
- require 'librtmp/ffi/amf'
2
1
  require 'librtmp/ffi/rtmp'
3
-
4
- module Librtmp
5
- module FFI
6
- end
7
- end
@@ -0,0 +1,63 @@
1
+ require 'librtmp/ffi'
2
+
3
+ module Librtmp
4
+ class Streamer
5
+ attr_reader :url
6
+ attr_reader :writable
7
+ attr_reader :session
8
+
9
+ def initialize()
10
+ @session = nil
11
+ end
12
+
13
+ def writable?
14
+ @writable
15
+ end
16
+
17
+ def connect(connection_url, connection_writable = false)
18
+ @url = connection_url
19
+ @writable = connection_writable
20
+
21
+ setup_session
22
+
23
+ FFI::RTMP_EnableWrite(@session_ptr) if writable?
24
+
25
+ unless FFI::RTMP_Connect(@session_ptr, nil)
26
+ raise 'Unable to connect to RTMP server'
27
+ end
28
+
29
+ unless FFI::RTMP_ConnectStream(@session_ptr, 0)
30
+ raise 'Unable to connect to RTMP stream'
31
+ end
32
+ end
33
+
34
+ def send(data)
35
+ if data.is_a?(Hash)
36
+ # TODO Handle conversion of Hash to AMF Object
37
+ else
38
+ chunk = data.to_s
39
+ chunk_size = chunk.bytes.to_a.size
40
+
41
+ FFI::RTMP_Write(@session_ptr, chunk, chunk_size)
42
+ end
43
+ end
44
+
45
+ def disconnect
46
+ FFI::RTMP_Close(@session_ptr)
47
+ FFI::RTMP_Free(@session_ptr)
48
+ end
49
+
50
+ private
51
+ def setup_session
52
+ @session_ptr = FFI::RTMP_Alloc()
53
+ FFI::RTMP_Init(@session_ptr)
54
+
55
+ unless FFI::RTMP_SetupURL(@session_ptr, self.url)
56
+ FFI::RTMP_Free(@session_ptr)
57
+ raise 'Unable to setup RTMP session'
58
+ end
59
+
60
+ @session = FFI::RTMP.new @session_ptr
61
+ end
62
+ end
63
+ end
@@ -1,3 +1,3 @@
1
1
  module Librtmp
2
- VERSION = '0.1.0'
3
- end
2
+ VERSION = '0.1.1'
3
+ end
data/lib/librtmp.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'librtmp/version'
2
2
 
3
+ require 'librtmp/streamer'
4
+
3
5
  module Librtmp
4
-
6
+
5
7
  end
data/librtmp.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- # specify any dependencies here; for example:
22
- # s.add_development_dependency "rspec"
21
+ s.add_development_dependency "rspec"
22
+
23
23
  s.add_runtime_dependency "ffi"
24
24
  end
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: librtmp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-19 00:00:00.000000000 Z
12
+ date: 2012-04-23 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &70213899045000 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70213899045000
14
25
  - !ruby/object:Gem::Dependency
15
26
  name: ffi
16
- requirement: &70190125709880 !ruby/object:Gem::Requirement
27
+ requirement: &70213899044520 !ruby/object:Gem::Requirement
17
28
  none: false
18
29
  requirements:
19
30
  - - ! '>='
@@ -21,7 +32,7 @@ dependencies:
21
32
  version: '0'
22
33
  type: :runtime
23
34
  prerelease: false
24
- version_requirements: *70190125709880
35
+ version_requirements: *70213899044520
25
36
  description: Provides a wrapper for the librtmp library in Ruby to allow use of the
26
37
  RTMP streaming protocols
27
38
  email:
@@ -32,6 +43,7 @@ extra_rdoc_files: []
32
43
  files:
33
44
  - .gitignore
34
45
  - .rvmrc
46
+ - CHANGELOG.md
35
47
  - Gemfile
36
48
  - README.md
37
49
  - Rakefile
@@ -39,8 +51,10 @@ files:
39
51
  - lib/librtmp/ffi.rb
40
52
  - lib/librtmp/ffi/amf.rb
41
53
  - lib/librtmp/ffi/rtmp.rb
54
+ - lib/librtmp/streamer.rb
42
55
  - lib/librtmp/version.rb
43
56
  - librtmp.gemspec
57
+ - spec/spec_helper.rb
44
58
  homepage: http://github.com/plainprograms/ruby-librtmp
45
59
  licenses: []
46
60
  post_install_message:
@@ -65,4 +79,5 @@ rubygems_version: 1.8.12
65
79
  signing_key:
66
80
  specification_version: 3
67
81
  summary: Wraps the librtmp library from rtmpdump with Ruby
68
- test_files: []
82
+ test_files:
83
+ - spec/spec_helper.rb