librtmp 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/CHANGELOG.md +10 -0
- data/README.md +7 -1
- data/lib/librtmp/ffi/rtmp.rb +1 -1
- data/lib/librtmp/ffi.rb +0 -6
- data/lib/librtmp/streamer.rb +63 -0
- data/lib/librtmp/version.rb +2 -2
- data/lib/librtmp.rb +3 -1
- data/librtmp.gemspec +2 -2
- data/spec/spec_helper.rb +0 -0
- metadata +20 -5
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
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
|
data/lib/librtmp/ffi/rtmp.rb
CHANGED
@@ -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, [
|
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
@@ -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
|
data/lib/librtmp/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Librtmp
|
2
|
-
VERSION = '0.1.
|
3
|
-
end
|
2
|
+
VERSION = '0.1.1'
|
3
|
+
end
|
data/lib/librtmp.rb
CHANGED
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
|
-
|
22
|
-
|
21
|
+
s.add_development_dependency "rspec"
|
22
|
+
|
23
23
|
s.add_runtime_dependency "ffi"
|
24
24
|
end
|
data/spec/spec_helper.rb
ADDED
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.
|
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-
|
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: &
|
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: *
|
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
|