libmediainfo 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +3 -0
- data/.gitignore +27 -0
- data/.rspec +1 -0
- data/.yardopts +1 -0
- data/ChangeLog.md +8 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +675 -0
- data/README.md +38 -0
- data/Rakefile +51 -0
- data/example/dump_everything.rb +28 -0
- data/example/specific_fields.rb +49 -0
- data/ext/mediainfo/api.c +39 -0
- data/ext/mediainfo/api.h +21 -0
- data/ext/mediainfo/common.h +19 -0
- data/ext/mediainfo/constants.c +61 -0
- data/ext/mediainfo/constants.h +11 -0
- data/ext/mediainfo/extconf.rb +20 -0
- data/ext/mediainfo/libmediainfo.c +17 -0
- data/ext/mediainfo/libmediainfo.h +6 -0
- data/ext/mediainfo/mediainfo.c +384 -0
- data/ext/mediainfo/mediainfo.h +33 -0
- data/ext/mediainfo/stream_type.c +171 -0
- data/ext/mediainfo/stream_type.h +26 -0
- data/ext/mediainfo/track.c +205 -0
- data/ext/mediainfo/track.h +24 -0
- data/ext/mediainfo/unicode.c +76 -0
- data/ext/mediainfo/unicode.h +24 -0
- data/lib/mediainfo.rb +1 -0
- data/lib/mediainfo/version.rb +71 -0
- data/libmediainfo.gemspec +30 -0
- data/spec/libmediainfo_spec.rb +30 -0
- data/spec/spec_helper.rb +5 -0
- metadata +195 -0
@@ -0,0 +1,76 @@
|
|
1
|
+
#include <stdbool.h>
|
2
|
+
#include <string.h>
|
3
|
+
#include <wchar.h>
|
4
|
+
|
5
|
+
#include "common.h"
|
6
|
+
#include "unicode.h"
|
7
|
+
|
8
|
+
VALUE
|
9
|
+
mediainfo_chars_to_rstring(const MediaInfo_Char *str)
|
10
|
+
{
|
11
|
+
VALUE rstring;
|
12
|
+
char *rstr;
|
13
|
+
|
14
|
+
#ifdef MINFO_EXT_UNI
|
15
|
+
size_t len = wcstombs(NULL, str, 0);
|
16
|
+
rstr = alloca(len + 1);
|
17
|
+
if ((size_t)-1 == wcstombs(rstr, str, len)) {
|
18
|
+
rb_raise(rb_eEncodingError, "could not convert given wchar_t* string to char* as used by libmediainfo");
|
19
|
+
}
|
20
|
+
rstr[len] = L'\0';
|
21
|
+
#else
|
22
|
+
rstr = str;
|
23
|
+
#endif
|
24
|
+
|
25
|
+
rstring = rb_str_new2(rstr);
|
26
|
+
|
27
|
+
return rstring;
|
28
|
+
}
|
29
|
+
|
30
|
+
MediaInfo_Char *
|
31
|
+
rstring_to_mediainfo_chars(VALUE rstring)
|
32
|
+
{
|
33
|
+
MediaInfo_Char *mi_str;
|
34
|
+
char *rstr = RSTRING_PTR(rstring);
|
35
|
+
|
36
|
+
#ifdef MINFO_EXT_UNI
|
37
|
+
size_t len = mbstowcs(NULL, rstr, 0);
|
38
|
+
mi_str = xmalloc(sizeof(MediaInfo_Char) * (len + 1));
|
39
|
+
if ((size_t)-1 == mbstowcs(mi_str, rstr, len)) {
|
40
|
+
rb_raise(rb_eEncodingError, "could not convert given char* string to wchar_t* as needed by libmediainfo");
|
41
|
+
}
|
42
|
+
mi_str[len] = L'\0';
|
43
|
+
#else
|
44
|
+
mi_str = rstr;
|
45
|
+
#endif
|
46
|
+
|
47
|
+
return mi_str;
|
48
|
+
}
|
49
|
+
|
50
|
+
|
51
|
+
VALUE
|
52
|
+
mediainfo_string_to_rb(const MediaInfo_Char *str)
|
53
|
+
{
|
54
|
+
bool isnum = true;
|
55
|
+
const MediaInfo_Char *p;
|
56
|
+
for (p = str; *p; p++) {
|
57
|
+
if (!MINFO_EXT_ISDIGIT(*p)) {
|
58
|
+
isnum = false;
|
59
|
+
break;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
if (isnum) {
|
64
|
+
if (p == str) {
|
65
|
+
return Qnil;
|
66
|
+
} else {
|
67
|
+
return LL2NUM(MINFO_EXT_STRTOLL(str, NULL, 10));
|
68
|
+
}
|
69
|
+
} else {
|
70
|
+
#ifdef MINFO_EXT_UNI
|
71
|
+
return mediainfo_chars_to_rstring(str);
|
72
|
+
#else
|
73
|
+
return rb_str_new2(str);
|
74
|
+
#endif
|
75
|
+
}
|
76
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#ifndef GEM_MEDIAINFO_UNICODE_H
|
2
|
+
#define GEM_MEDIAINFO_UNICODE_H
|
3
|
+
|
4
|
+
#if defined(UNICODE) || defined (_UNICODE)
|
5
|
+
# define MINFO_EXT_UNI 1
|
6
|
+
# define MINFO_EXT_FMT "%S"
|
7
|
+
# define MINFO_EXT_STRLEN wcslen
|
8
|
+
# define MINFO_EXT_STRTOLL wcstoll
|
9
|
+
# define MINFO_EXT_ISDIGIT iswdigit
|
10
|
+
# define RSTRING_TO_MINFO_FREE(x) xfree(x)
|
11
|
+
#else
|
12
|
+
# undef MINFO_EXT_UNI
|
13
|
+
# define MINFO_EXT_FMT "%s"
|
14
|
+
# define MINFO_EXT_STRLEN strlen
|
15
|
+
# define MINFO_EXT_STRTOLL strtoll
|
16
|
+
# define MINFO_EXT_ISDIGIT isdigit
|
17
|
+
# define RSTRING_TO_MINFO_FREE(x)
|
18
|
+
#endif
|
19
|
+
|
20
|
+
VALUE mediainfo_chars_to_rstring(const MediaInfo_Char *str);
|
21
|
+
MediaInfo_Char * rstring_to_mediainfo_chars(VALUE rstring);
|
22
|
+
VALUE mediainfo_string_to_rb(const MediaInfo_Char *str);
|
23
|
+
|
24
|
+
#endif /*GEM_MEDIAINFO_UNICODE_H*/
|
data/lib/mediainfo.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'mediainfo/mediainfo'
|
@@ -0,0 +1,71 @@
|
|
1
|
+
class MediaInfo
|
2
|
+
# Probably overkill, but why. This is all a thin wrapper around
|
3
|
+
# the string in VERSION::STRING
|
4
|
+
module VERSION
|
5
|
+
extend Comparable
|
6
|
+
|
7
|
+
# The major version number of the gem. Anything that depends on
|
8
|
+
# on this gem is likely to break when this changes.
|
9
|
+
MAJOR = 1
|
10
|
+
|
11
|
+
# The minor version number. Changes here could break external
|
12
|
+
# dependencies on rare occasions, but effort will be taken to
|
13
|
+
# avoid that. New features usually increment this value.
|
14
|
+
MINOR = 0
|
15
|
+
|
16
|
+
# The patch-level version number. Changes here should never
|
17
|
+
# break anything, and usually represent bugfixes.
|
18
|
+
PATCH = 0
|
19
|
+
|
20
|
+
# The whole version number, in array form.
|
21
|
+
SIGNATURE = [MAJOR, MINOR, PATCH]
|
22
|
+
|
23
|
+
# The whole version number, in gemspec-compatible string form.
|
24
|
+
# When in doubt, you probably want this version.
|
25
|
+
STRING = SIGNATURE.join '.'
|
26
|
+
|
27
|
+
# the VERSION module itself
|
28
|
+
# @return [String] the version number
|
29
|
+
def inspect
|
30
|
+
STRING.inspect
|
31
|
+
end
|
32
|
+
alias_method :to_s, :inspect
|
33
|
+
|
34
|
+
# @param other [Types] description
|
35
|
+
# @return [-1] If 'self' sorts before 'other'
|
36
|
+
# @return [0] If 'self' sorts equal with 'other'
|
37
|
+
# @return [1] If 'self' sorts after 'other'
|
38
|
+
def <=>(other)
|
39
|
+
other = other.split('.').map { |i| i.to_i } if other.respond_to? :split
|
40
|
+
SIGNATURE <=> Array(other)
|
41
|
+
end
|
42
|
+
|
43
|
+
# @!group Delegating Into STRING
|
44
|
+
|
45
|
+
# @return [Int] is a thin wrapper around String
|
46
|
+
def hash
|
47
|
+
STRING.hash
|
48
|
+
end
|
49
|
+
|
50
|
+
# @param meth [Symbol] a method name
|
51
|
+
# @return [Boolean]
|
52
|
+
def respond_to?(meth, *)
|
53
|
+
meth.to_s !~ /^__|^to_str$/ and STRING.respond_to? meth unless super
|
54
|
+
end
|
55
|
+
|
56
|
+
def method_missing(meth, *args, &block)
|
57
|
+
return super unless STRING.respond_to?(meth)
|
58
|
+
STRING.send(meth, *args, &block)
|
59
|
+
end
|
60
|
+
|
61
|
+
# @!endgroup
|
62
|
+
|
63
|
+
module_function :hash, :<=>, :inspect, :to_s, :respond_to?, :method_missing
|
64
|
+
end
|
65
|
+
|
66
|
+
# provides easy-access to VERSION in the main gem scope
|
67
|
+
# @return [Libmediainfo::VERSION] the main VERSION
|
68
|
+
def version
|
69
|
+
VERSION
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
4
|
+
require 'mediainfo/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "libmediainfo"
|
8
|
+
gem.version = MediaInfo::VERSION::STRING
|
9
|
+
gem.summary = "Ruby bindings for libmediainfo.so"
|
10
|
+
gem.description = "Ruby bindings for MediaInfo using libmediainfo.so"
|
11
|
+
gem.license = "GPL-3"
|
12
|
+
gem.authors = ["Brent Sanders"]
|
13
|
+
gem.email = "pdkl95@thoughtnoise.net"
|
14
|
+
gem.homepage = "https://github.com/pdkl95/ruby-libmediainfo#readme"
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split($/)
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.require_paths = ['lib']
|
20
|
+
|
21
|
+
gem.extensions << "ext/mediainfo/extconf.rb"
|
22
|
+
|
23
|
+
gem.add_development_dependency 'bundler', '~> 1.2'
|
24
|
+
gem.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
gem.add_development_dependency 'redcarpet', '~> 2.2'
|
26
|
+
gem.add_development_dependency 'rspec', '~> 2.11'
|
27
|
+
gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
|
28
|
+
gem.add_development_dependency 'yard', '~> 0.8'
|
29
|
+
gem.add_development_dependency 'rake-compiler', '~> 0.8.1'
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'libmediainfo'
|
3
|
+
require 'libmediainfo/version'
|
4
|
+
|
5
|
+
describe Libmediainfo do
|
6
|
+
describe "Libmediainfo::VERSION" do
|
7
|
+
subject { Libmediainfo::VERSION }
|
8
|
+
it { should_not be_empty }
|
9
|
+
describe "Libmediainfo::VERSION::MAJOR" do
|
10
|
+
subject { Libmediainfo::VERSION::MAJOR }
|
11
|
+
it { should be_instance_of(Fixnum) }
|
12
|
+
it { should >= 0 }
|
13
|
+
end
|
14
|
+
describe "Libmediainfo::VERSION::MINOR" do
|
15
|
+
subject { Libmediainfo::VERSION::MINOR }
|
16
|
+
it { should be_instance_of(Fixnum) }
|
17
|
+
it { should >= 0 }
|
18
|
+
end
|
19
|
+
describe "Libmediainfo::VERSION::PATCH" do
|
20
|
+
subject { Libmediainfo::VERSION::PATCH }
|
21
|
+
it { should be_instance_of(Fixnum) }
|
22
|
+
it { should >= 0 }
|
23
|
+
end
|
24
|
+
describe "Libmediainfo::VERSION::STRING" do
|
25
|
+
subject { Libmediainfo::VERSION::STRING }
|
26
|
+
it { should be_instance_of(String) }
|
27
|
+
it { should match(/^\d+\.\d+\.\d+$/) }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,195 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: libmediainfo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Brent Sanders
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
type: :development
|
16
|
+
name: bundler
|
17
|
+
prerelease: false
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '1.2'
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.2'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
type: :development
|
32
|
+
name: rake
|
33
|
+
prerelease: false
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ~>
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '10.0'
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '10.0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
type: :development
|
48
|
+
name: redcarpet
|
49
|
+
prerelease: false
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '2.2'
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.2'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
type: :development
|
64
|
+
name: rspec
|
65
|
+
prerelease: false
|
66
|
+
requirement: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ~>
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '2.11'
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '2.11'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
type: :development
|
80
|
+
name: rubygems-tasks
|
81
|
+
prerelease: false
|
82
|
+
requirement: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ~>
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0.2'
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0.2'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
type: :development
|
96
|
+
name: yard
|
97
|
+
prerelease: false
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.8'
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0.8'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
type: :development
|
112
|
+
name: rake-compiler
|
113
|
+
prerelease: false
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ~>
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: 0.8.1
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 0.8.1
|
126
|
+
description: Ruby bindings for MediaInfo using libmediainfo.so
|
127
|
+
email: pdkl95@thoughtnoise.net
|
128
|
+
executables: []
|
129
|
+
extensions:
|
130
|
+
- ext/mediainfo/extconf.rb
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- .document
|
134
|
+
- .gitignore
|
135
|
+
- .rspec
|
136
|
+
- .yardopts
|
137
|
+
- ChangeLog.md
|
138
|
+
- Gemfile
|
139
|
+
- LICENSE.txt
|
140
|
+
- README.md
|
141
|
+
- Rakefile
|
142
|
+
- example/dump_everything.rb
|
143
|
+
- example/specific_fields.rb
|
144
|
+
- ext/mediainfo/api.c
|
145
|
+
- ext/mediainfo/api.h
|
146
|
+
- ext/mediainfo/common.h
|
147
|
+
- ext/mediainfo/constants.c
|
148
|
+
- ext/mediainfo/constants.h
|
149
|
+
- ext/mediainfo/extconf.rb
|
150
|
+
- ext/mediainfo/libmediainfo.c
|
151
|
+
- ext/mediainfo/libmediainfo.h
|
152
|
+
- ext/mediainfo/mediainfo.c
|
153
|
+
- ext/mediainfo/mediainfo.h
|
154
|
+
- ext/mediainfo/stream_type.c
|
155
|
+
- ext/mediainfo/stream_type.h
|
156
|
+
- ext/mediainfo/track.c
|
157
|
+
- ext/mediainfo/track.h
|
158
|
+
- ext/mediainfo/unicode.c
|
159
|
+
- ext/mediainfo/unicode.h
|
160
|
+
- lib/mediainfo.rb
|
161
|
+
- lib/mediainfo/version.rb
|
162
|
+
- libmediainfo.gemspec
|
163
|
+
- spec/libmediainfo_spec.rb
|
164
|
+
- spec/spec_helper.rb
|
165
|
+
homepage: https://github.com/pdkl95/ruby-libmediainfo#readme
|
166
|
+
licenses:
|
167
|
+
- GPL-3
|
168
|
+
post_install_message:
|
169
|
+
rdoc_options: []
|
170
|
+
require_paths:
|
171
|
+
- lib
|
172
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
173
|
+
none: false
|
174
|
+
requirements:
|
175
|
+
- - ! '>='
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '0'
|
178
|
+
segments:
|
179
|
+
- 0
|
180
|
+
hash: -3544071016448866791
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
+
none: false
|
183
|
+
requirements:
|
184
|
+
- - ! '>='
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
187
|
+
requirements: []
|
188
|
+
rubyforge_project:
|
189
|
+
rubygems_version: 1.8.23
|
190
|
+
signing_key:
|
191
|
+
specification_version: 3
|
192
|
+
summary: Ruby bindings for libmediainfo.so
|
193
|
+
test_files:
|
194
|
+
- spec/libmediainfo_spec.rb
|
195
|
+
- spec/spec_helper.rb
|