mediainfo-native 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/mediainfo_native/MediaInfoDLL.h +4 -0
- data/ext/mediainfo_native/basestream.cpp +11 -14
- data/ext/mediainfo_native/basestream.h +14 -3
- data/ext/mediainfo_native/extconf.rb +13 -3
- data/ext/mediainfo_native/mediainfo_wrapper.cpp +37 -25
- data/ext/mediainfo_native/mediainfo_wrapper.h +6 -7
- data/ext/mediainfo_native/unicode.cpp +15 -0
- data/ext/mediainfo_native/unicode.h +10 -0
- data/lib/mediainfo-native/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f64beab22d1edc8263d33f3e97f7bf8da57749a7
|
4
|
+
data.tar.gz: 1b9344a3f4e2b334a4fb9ddd8a94446b84716dc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09d1198564b03a3e6d9a2457a1852ce0ebf248cf36b073258fe7ce6967ffb691ba45e3525c66cce8dc61b817f209f39f57e18ad958fcbf5e1e6aa5b9dc77ff02
|
7
|
+
data.tar.gz: de2b77e3187849a19c84d66bd5b12307604537a9949aa3cceec7bc849d4d31d2f220f6c77d1d9abf646d4fb80b6fc9171494ce81609ec43a917b4ecf0fd43a8e
|
@@ -15,6 +15,10 @@
|
|
15
15
|
#ifndef MediaInfoDLLH
|
16
16
|
#define MediaInfoDLLH
|
17
17
|
|
18
|
+
|
19
|
+
#undef UNICODE
|
20
|
+
#undef _UNICODE
|
21
|
+
|
18
22
|
//***************************************************************************
|
19
23
|
// Platforms (from libzen)
|
20
24
|
//***************************************************************************
|
@@ -1,4 +1,3 @@
|
|
1
|
-
#include "MediaInfoDLL.h"
|
2
1
|
#include "basestream.h"
|
3
2
|
#include "mediainfo_wrapper.h"
|
4
3
|
|
@@ -27,28 +26,28 @@ extern "C"
|
|
27
26
|
|
28
27
|
}
|
29
28
|
|
30
|
-
VALUE stream_klasses[
|
29
|
+
VALUE stream_klasses[STREAM_TYPE_MAX];
|
31
30
|
|
32
31
|
void Init_BaseStream(VALUE mMediaInfoNative)
|
33
32
|
{
|
34
33
|
VALUE cBaseStream = rb_define_class_under(mMediaInfoNative, "BaseStream", rb_cObject);
|
35
34
|
|
36
|
-
stream_klasses[
|
37
|
-
stream_klasses[
|
38
|
-
stream_klasses[
|
39
|
-
stream_klasses[
|
40
|
-
stream_klasses[
|
41
|
-
stream_klasses[
|
42
|
-
stream_klasses[
|
35
|
+
stream_klasses[GENERAL] = rb_define_class_under(mMediaInfoNative, "GeneralStream", cBaseStream);
|
36
|
+
stream_klasses[VIDEO] = rb_define_class_under(mMediaInfoNative, "VideoStream", cBaseStream);
|
37
|
+
stream_klasses[AUDIO] = rb_define_class_under(mMediaInfoNative, "AudioStream", cBaseStream);
|
38
|
+
stream_klasses[TEXT] = rb_define_class_under(mMediaInfoNative, "TextStream", cBaseStream);
|
39
|
+
stream_klasses[OTHER] = rb_define_class_under(mMediaInfoNative, "OtherStream", cBaseStream);
|
40
|
+
stream_klasses[IMAGE] = rb_define_class_under(mMediaInfoNative, "ImageStream", cBaseStream);
|
41
|
+
stream_klasses[MENU] = rb_define_class_under(mMediaInfoNative, "MenuStream", cBaseStream);
|
43
42
|
|
44
|
-
for(unsigned int st = 0; st <
|
43
|
+
for(unsigned int st = 0; st < STREAM_TYPE_MAX; ++st) {
|
45
44
|
rb_define_method(stream_klasses[st], "lookup", (VALUE(*)(...)) bs_lookup, 1);
|
46
45
|
}
|
47
46
|
}
|
48
47
|
|
49
48
|
/* ************************** BaseStream ************************************ */
|
50
49
|
|
51
|
-
BaseStream::BaseStream(
|
50
|
+
BaseStream::BaseStream(StreamType _type, unsigned int _idx, MediaInfoWrapper* _wrapper)
|
52
51
|
: valid(true), type(_type), idx(_idx), wrapper(_wrapper)
|
53
52
|
{
|
54
53
|
}
|
@@ -80,9 +79,7 @@ VALUE BaseStream::lookup(VALUE key) const
|
|
80
79
|
if(!valid)
|
81
80
|
rb_raise(rb_eStandardError, "stream is invalid");
|
82
81
|
|
83
|
-
|
84
|
-
MediaInfoDLL::String mi_key(StringValueCStr(key));
|
85
|
-
return rb_str_new2(wrapper->getMediaInfo()->Get(type, idx, mi_key).c_str());
|
82
|
+
return wrapper->get(type, idx, key);
|
86
83
|
}
|
87
84
|
|
88
85
|
} /* namespace MediaInfoNative */
|
@@ -2,17 +2,28 @@
|
|
2
2
|
#define MEDIAINFO_NATIVE_BASESTREAM_H
|
3
3
|
|
4
4
|
#include <ruby.h>
|
5
|
-
#include "MediaInfoDLL.h"
|
6
5
|
|
7
6
|
namespace MediaInfoNative
|
8
7
|
{
|
9
8
|
|
9
|
+
enum StreamType
|
10
|
+
{
|
11
|
+
GENERAL,
|
12
|
+
VIDEO,
|
13
|
+
AUDIO,
|
14
|
+
TEXT,
|
15
|
+
OTHER,
|
16
|
+
IMAGE,
|
17
|
+
MENU,
|
18
|
+
STREAM_TYPE_MAX
|
19
|
+
};
|
20
|
+
|
10
21
|
class MediaInfoWrapper;
|
11
22
|
|
12
23
|
class BaseStream
|
13
24
|
{
|
14
25
|
public:
|
15
|
-
BaseStream(
|
26
|
+
BaseStream(StreamType _type, unsigned int _idx, MediaInfoWrapper* _wrapper);
|
16
27
|
~BaseStream();
|
17
28
|
void notifyOfWrapperDestruction();
|
18
29
|
void invalidate();
|
@@ -22,7 +33,7 @@ public:
|
|
22
33
|
|
23
34
|
private:
|
24
35
|
bool valid;
|
25
|
-
const
|
36
|
+
const StreamType type;
|
26
37
|
const unsigned int idx;
|
27
38
|
MediaInfoWrapper* wrapper;
|
28
39
|
};
|
@@ -1,7 +1,17 @@
|
|
1
1
|
require 'mkmf'
|
2
2
|
|
3
|
-
unless
|
4
|
-
abort 'Failed to locate
|
3
|
+
unless (mediainfo_cfg = pkg_config('libmediainfo'))
|
4
|
+
abort 'Failed to locate pkg-config file for libmediainfo.'
|
5
5
|
end
|
6
6
|
|
7
|
-
|
7
|
+
unless have_library('mediainfo')
|
8
|
+
abort 'Failed to test-link against libmediainfo.'
|
9
|
+
end
|
10
|
+
|
11
|
+
location = (mediainfo_cfg.detect { |flag| flag =~ /^-L/ }).gsub('-L', '')
|
12
|
+
$LDFLAGS << " -Wl,-rpath,#{location}"
|
13
|
+
message "embedding path to library into libmediainfo.so: #{location}\n"
|
14
|
+
|
15
|
+
with_cppflags("#{(mediainfo_cfg.detect { |flag| flag =~ /^-I/ })}") do
|
16
|
+
create_makefile('mediainfo_native')
|
17
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#include "MediaInfoDLL.h"
|
2
2
|
#include "mediainfo_wrapper.h"
|
3
|
-
#include "
|
3
|
+
#include "unicode.h"
|
4
4
|
|
5
5
|
namespace MediaInfoNative
|
6
6
|
{
|
@@ -87,6 +87,31 @@ void Init_MediaInfoWrapper(VALUE mMediaInfoNative)
|
|
87
87
|
#define CHECK_OPEN \
|
88
88
|
if(!file_opened) rb_raise(rb_eStandardError, "no file opened")
|
89
89
|
|
90
|
+
MediaInfoDLL::stream_t convertToMediaInfoStreamType(StreamType type)
|
91
|
+
{
|
92
|
+
switch(type) {
|
93
|
+
case GENERAL:
|
94
|
+
return MediaInfoDLL::Stream_General;
|
95
|
+
case VIDEO:
|
96
|
+
return MediaInfoDLL::Stream_Video;
|
97
|
+
case AUDIO:
|
98
|
+
return MediaInfoDLL::Stream_Audio;
|
99
|
+
case TEXT:
|
100
|
+
return MediaInfoDLL::Stream_Text;
|
101
|
+
case OTHER:
|
102
|
+
return MediaInfoDLL::Stream_Other;
|
103
|
+
case IMAGE:
|
104
|
+
return MediaInfoDLL::Stream_Image;
|
105
|
+
case MENU:
|
106
|
+
return MediaInfoDLL::Stream_Menu;
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
MediaInfoDLL::stream_t convertToMediaInfoStreamType(unsigned int type)
|
111
|
+
{
|
112
|
+
return convertToMediaInfoStreamType((StreamType) type);
|
113
|
+
}
|
114
|
+
|
90
115
|
MediaInfoWrapper::MediaInfoWrapper()
|
91
116
|
: file_opened(false)
|
92
117
|
{
|
@@ -114,7 +139,7 @@ void MediaInfoWrapper::open(VALUE path)
|
|
114
139
|
if(file_opened)
|
115
140
|
rb_raise(rb_eStandardError, "already opened a file");
|
116
141
|
|
117
|
-
MediaInfoDLL::String mi_path(
|
142
|
+
MediaInfoDLL::String mi_path = value_to_ansi_string(path);
|
118
143
|
|
119
144
|
if(mi->Open(mi_path) != 1)
|
120
145
|
rb_raise(rb_eStandardError, "failed to open");
|
@@ -140,9 +165,9 @@ VALUE MediaInfoWrapper::wrapStreams()
|
|
140
165
|
CHECK_OPEN;
|
141
166
|
|
142
167
|
VALUE ary = rb_ary_new();
|
143
|
-
for(unsigned int st = 0; st < ((unsigned int)
|
144
|
-
for(unsigned int count = 0; count < mi->Count_Get((
|
145
|
-
BaseStream* bs = new BaseStream((
|
168
|
+
for(unsigned int st = 0; st < ((unsigned int) STREAM_TYPE_MAX); ++st) {
|
169
|
+
for(unsigned int count = 0; count < mi->Count_Get(convertToMediaInfoStreamType(st)); ++count) {
|
170
|
+
BaseStream* bs = new BaseStream((StreamType) st, count, this);
|
146
171
|
rb_ary_push(ary, bs->wrap());
|
147
172
|
}
|
148
173
|
}
|
@@ -150,11 +175,17 @@ VALUE MediaInfoWrapper::wrapStreams()
|
|
150
175
|
return ary;
|
151
176
|
}
|
152
177
|
|
178
|
+
VALUE MediaInfoWrapper::get(StreamType type, unsigned int idx, VALUE key) const
|
179
|
+
{
|
180
|
+
MediaInfoDLL::String mi_key(value_to_ansi_string(key));
|
181
|
+
return ansi_string_to_value(mi->Get(convertToMediaInfoStreamType(type), idx, mi_key));
|
182
|
+
}
|
183
|
+
|
153
184
|
VALUE MediaInfoWrapper::inform() const
|
154
185
|
{
|
155
186
|
CHECK_OPEN;
|
156
187
|
|
157
|
-
return
|
188
|
+
return ansi_string_to_value(mi->Inform());
|
158
189
|
}
|
159
190
|
|
160
191
|
void MediaInfoWrapper::notifyOfStreamDestruction(BaseStream* stream)
|
@@ -162,23 +193,4 @@ void MediaInfoWrapper::notifyOfStreamDestruction(BaseStream* stream)
|
|
162
193
|
streams.remove(stream);
|
163
194
|
}
|
164
195
|
|
165
|
-
MediaInfoDLL::MediaInfo* MediaInfoWrapper::getMediaInfo()
|
166
|
-
{
|
167
|
-
return mi;
|
168
|
-
}
|
169
|
-
|
170
|
-
void MediaInfoWrapper::lzld() const
|
171
|
-
{
|
172
|
-
/*
|
173
|
-
* NOTE: Due to the weird manual way of lazy runtime linking
|
174
|
-
* used in MediaInfoDLL.h, this useless function is needed
|
175
|
-
* to tell the compiler to load the MediaInfo_Get symbol
|
176
|
-
* from the shared library (probably on MediaInfoWrapper
|
177
|
-
* class instantiation). If this is commented out, calls
|
178
|
-
* to Get() in the BaseStream will fail with a segmentation
|
179
|
-
* fault.
|
180
|
-
*/
|
181
|
-
mi->Get((MediaInfoDLL::stream_t) 0, 0, "");
|
182
|
-
}
|
183
|
-
|
184
196
|
} /* namespace MediaInfoNative */
|
@@ -3,13 +3,13 @@
|
|
3
3
|
|
4
4
|
#include <list>
|
5
5
|
#include <ruby.h>
|
6
|
-
#include "
|
6
|
+
#include "basestream.h"
|
7
|
+
|
8
|
+
namespace MediaInfoDLL { class MediaInfo; }
|
7
9
|
|
8
10
|
namespace MediaInfoNative
|
9
11
|
{
|
10
12
|
|
11
|
-
class BaseStream;
|
12
|
-
|
13
13
|
class MediaInfoWrapper
|
14
14
|
{
|
15
15
|
public:
|
@@ -19,17 +19,16 @@ public:
|
|
19
19
|
void open(VALUE path);
|
20
20
|
void close();
|
21
21
|
VALUE wrapStreams();
|
22
|
+
|
22
23
|
VALUE inform() const;
|
24
|
+
VALUE get(StreamType type, unsigned int idx, VALUE key) const;
|
23
25
|
|
24
26
|
void notifyOfStreamDestruction(BaseStream* stream);
|
25
|
-
MediaInfoDLL::MediaInfo* getMediaInfo();
|
26
27
|
|
27
28
|
private:
|
28
|
-
void lzld() const;
|
29
|
-
|
30
29
|
bool file_opened;
|
31
30
|
MediaInfoDLL::MediaInfo* mi;
|
32
|
-
std::list<BaseStream*>
|
31
|
+
std::list<BaseStream*> streams;
|
33
32
|
};
|
34
33
|
|
35
34
|
void Init_MediaInfoWrapper(VALUE mMediaInfoNative);
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#include <ruby.h>
|
2
|
+
#include <ruby/encoding.h>
|
3
|
+
#include "unicode.h"
|
4
|
+
|
5
|
+
MediaInfoDLL::String value_to_ansi_string(VALUE s)
|
6
|
+
{
|
7
|
+
rb_encoding* enc = rb_enc_find("ANSI");
|
8
|
+
VALUE exported = rb_str_export_to_enc(s, enc);
|
9
|
+
return MediaInfoDLL::String(StringValueCStr(exported));
|
10
|
+
}
|
11
|
+
|
12
|
+
VALUE ansi_string_to_value(MediaInfoDLL::String s)
|
13
|
+
{
|
14
|
+
return rb_external_str_new_with_enc(s.c_str(), s.length(), rb_enc_find("ANSI"));
|
15
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#ifndef MEDIAINFO_NATIVE_UNICODE_H
|
2
|
+
#define MEDIAINFO_NATIVE_UNICODE_H
|
3
|
+
|
4
|
+
#include <ruby.h>
|
5
|
+
#include "MediaInfoDLL.h"
|
6
|
+
|
7
|
+
MediaInfoDLL::String value_to_ansi_string(VALUE s);
|
8
|
+
VALUE ansi_string_to_value(MediaInfoDLL::String s);
|
9
|
+
|
10
|
+
#endif /* MEDIAINFO_NATIVE_UNICODE_H */
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mediainfo-native
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- FlavourSys Technology GmbH
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -57,7 +57,9 @@ files:
|
|
57
57
|
- lib/mediainfo-native/streams/text.rb
|
58
58
|
- lib/mediainfo-native/streams/general.rb
|
59
59
|
- lib/mediainfo-native/mediainfo.rb
|
60
|
+
- ext/mediainfo_native/unicode.cpp
|
60
61
|
- ext/mediainfo_native/MediaInfoDLL.h
|
62
|
+
- ext/mediainfo_native/unicode.h
|
61
63
|
- ext/mediainfo_native/extconf.rb
|
62
64
|
- ext/mediainfo_native/mediainfo_wrapper.cpp
|
63
65
|
- ext/mediainfo_native/basestream.h
|