mxfinfo 0.0.7 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8ce5a7260ebc7d0657a16a137f2ce53cdb7fe663
4
- data.tar.gz: fbbd22481926952429b5dc6f6a38f0ba2b2fd4cd
2
+ SHA256:
3
+ metadata.gz: '0891821de9c4eef60dde42ddc083cc6a118580768198009962ece8957726f284'
4
+ data.tar.gz: ef9540ce8dd3394e802855220eace91cb64b65fff699574daaa34a13dfff26f8
5
5
  SHA512:
6
- metadata.gz: eb70c65927e434c773ace50587b1027d6c390e6f06cbd1f92d27f5bae6a4289971507f6622a83bf97ce4a14aef0932c8b1bc8ec070cded2c9de6350bde5a294c
7
- data.tar.gz: 37e75c0627ca9792606ee3bbd8a7db8d60c03ff03144355e269ca40e8cbe7e08d40143c1201295f17785b43c7e5a8b9fc6564aae7f274d365b13beb8ca565cd4
6
+ metadata.gz: 689ea935346dfedffa75e9c14945644b42600f23a8984495034ce04ca73f2a9eea5a7d93a25ba01f64bee127be05e9b1d6f0e53fcf56bed8b7e11e354f676932
7
+ data.tar.gz: de108b7dd52c51ff567df1a3383b7403f32b09ba75e3a8df88034e73c697122d478710b93b6d2d66b171c97e6a83271859825a85a50515f68a470568a3e8b742
data/.gitignore CHANGED
@@ -15,6 +15,7 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .clangd
18
19
 
19
20
  # YARD artifacts
20
21
  .yardoc
data/Rakefile CHANGED
@@ -3,4 +3,5 @@ require 'rspec/core/rake_task'
3
3
  require 'rake/extensiontask'
4
4
 
5
5
  RSpec::Core::RakeTask.new('spec')
6
+ task spec: [:compile]
6
7
  Rake::ExtensionTask.new('mxfinfo')
@@ -0,0 +1,52 @@
1
+ [
2
+ {
3
+ "arguments": [
4
+ "gcc",
5
+ "-c",
6
+ "-I.",
7
+ "-I/home/steved/.rbenv/versions/2.5.8/include/ruby-2.5.0/x86_64-linux",
8
+ "-I/home/steved/.rbenv/versions/2.5.8/include/ruby-2.5.0/ruby/backward",
9
+ "-I/home/steved/.rbenv/versions/2.5.8/include/ruby-2.5.0",
10
+ "-I../../../../ext/mxfinfo",
11
+ "-I/opt/environments/strawberry/include/libMXF-1.0",
12
+ "--std=gnu99",
13
+ "-D_GNU_SOURCE",
14
+ "-Wall",
15
+ "-I/home/steved/.rbenv/versions/2.5.8/include",
16
+ "-fPIC",
17
+ "-O3",
18
+ "-ggdb3",
19
+ "-fPIC",
20
+ "-o",
21
+ "avid_mxf_info.o",
22
+ "../../../../ext/mxfinfo/avid_mxf_info.c"
23
+ ],
24
+ "directory": "/home/steved/Documents/projective/github/mxfinfo/tmp/x86_64-linux/mxfinfo/2.5.8",
25
+ "file": "../../../../ext/mxfinfo/avid_mxf_info.c"
26
+ },
27
+ {
28
+ "arguments": [
29
+ "gcc",
30
+ "-c",
31
+ "-I.",
32
+ "-I/home/steved/.rbenv/versions/2.5.8/include/ruby-2.5.0/x86_64-linux",
33
+ "-I/home/steved/.rbenv/versions/2.5.8/include/ruby-2.5.0/ruby/backward",
34
+ "-I/home/steved/.rbenv/versions/2.5.8/include/ruby-2.5.0",
35
+ "-I../../../../ext/mxfinfo",
36
+ "-I/opt/environments/strawberry/include/libMXF-1.0",
37
+ "--std=gnu99",
38
+ "-D_GNU_SOURCE",
39
+ "-Wall",
40
+ "-I/home/steved/.rbenv/versions/2.5.8/include",
41
+ "-fPIC",
42
+ "-O3",
43
+ "-ggdb3",
44
+ "-fPIC",
45
+ "-o",
46
+ "mxfinfo.o",
47
+ "../../../../ext/mxfinfo/mxfinfo.c"
48
+ ],
49
+ "directory": "/home/steved/Documents/projective/github/mxfinfo/tmp/x86_64-linux/mxfinfo/2.5.8",
50
+ "file": "../../../../ext/mxfinfo/mxfinfo.c"
51
+ }
52
+ ]
@@ -9,13 +9,12 @@ static
9
9
  VALUE rb_time_from_mxf_timestamp(mxfTimestamp *ts)
10
10
  {
11
11
  /*
12
- * NOTE: This is probably not thread-safe, since struct tm*
13
- * returned by localtime is shared static.
12
+ * NOTE: This is probably not thread-safe, since struct tm* returned by localtime is shared static.
14
13
  */
15
14
  time_t t;
16
15
  time(&t);
17
16
  struct tm *tmts;
18
- tmts = localtime(&t);
17
+ tmts = gmtime(&t);
19
18
 
20
19
  tmts->tm_year = (int) ts->year - 1900;
21
20
  tmts->tm_mon = (int) ts->month - 1;
@@ -23,6 +22,7 @@ VALUE rb_time_from_mxf_timestamp(mxfTimestamp *ts)
23
22
  tmts->tm_hour = (int) ts->hour;
24
23
  tmts->tm_min = (int) ts->min;
25
24
  tmts->tm_sec = (int) ts->sec;
25
+ tmts->tm_isdst = -1;
26
26
 
27
27
  return rb_time_new(mktime(tmts), ts->qmsec);
28
28
  }
@@ -74,8 +74,12 @@ VALUE rb_str_from_label(const unsigned char *lbl, int len)
74
74
  { \
75
75
  AvidMXFInfo *info; \
76
76
  Data_Get_Struct(self, AvidMXFInfo, info); \
77
- return rb_rational_new(INT2FIX((info-> attr ).numerator), \
78
- INT2FIX((info-> attr ).denominator)); \
77
+ if((info->attr).denominator == 0) { \
78
+ return Qnil; \
79
+ } else { \
80
+ return rb_rational_new(INT2FIX((info-> attr ).numerator), \
81
+ INT2FIX((info-> attr ).denominator)); \
82
+ } \
79
83
  }
80
84
 
81
85
  #define CIO_INT_GETTER(name, attr) CIO_GENERIC_GETTER(INT2FIX, name, attr)
@@ -86,6 +90,9 @@ VALUE rb_str_from_label(const unsigned char *lbl, int len)
86
90
 
87
91
  VALUE m_mxfinfo = Qnil;
88
92
  VALUE c_infoobject = Qnil;
93
+ VALUE c_error = Qnil;
94
+ VALUE c_eNotOpAtom = Qnil;
95
+ VALUE c_eNotReadable = Qnil;
89
96
 
90
97
  static
91
98
  void cio_free(void *ptr) {
@@ -106,7 +113,7 @@ void* ami_read_info_without_gvl(void* ptr)
106
113
  return NULL;
107
114
  }
108
115
 
109
- static
116
+ static
110
117
  VALUE cio_new(VALUE class, VALUE path)
111
118
  {
112
119
  Check_Type(path, T_STRING);
@@ -129,22 +136,22 @@ VALUE cio_new(VALUE class, VALUE path)
129
136
  switch(params.result)
130
137
  {
131
138
  case -2:
132
- rb_raise(rb_eIOError, "Failed to open file.");
139
+ rb_raise(c_eNotReadable, "Failed to open file.");
133
140
  break;
134
141
  case -3:
135
- rb_raise(rb_eIOError, "Failed to read header partition.");
142
+ rb_raise(c_eNotReadable, "Failed to read header partition.");
136
143
  break;
137
144
  case -4:
138
- rb_raise(rb_eStandardError, "File is not OP-Atom.");
145
+ rb_raise(c_eNotOpAtom, "File is not OP-Atom.");
139
146
  break;
140
147
  case -1:
141
148
  default:
142
- rb_raise(rb_eStandardError, "Failed to read info.");
149
+ rb_raise(c_eNotReadable, "Failed to read info.");
143
150
  break;
144
151
  }
145
152
 
146
153
  return Qnil;
147
- }
154
+ }
148
155
  else
149
156
  {
150
157
  VALUE tdata = Data_Wrap_Struct(class, 0, cio_free, info);
@@ -205,7 +212,7 @@ VALUE cio_get_material_package_uid(VALUE self)
205
212
  unsigned char *uid = (unsigned char*) &info->materialPackageUID;
206
213
 
207
214
  VALUE ary = rb_ary_new2(32);
208
- for(unsigned int i = 0; i < 32; i++)
215
+ for(unsigned int i = 0; i < 32; i++)
209
216
  {
210
217
  rb_ary_store(ary, i, CHR2FIX(uid[i]));
211
218
  }
@@ -238,7 +245,7 @@ VALUE cio_get_aspect_ratio(VALUE self)
238
245
  if(info->isVideo && info->aspectRatio.denominator != 0)
239
246
  {
240
247
  return rb_rational_new(INT2FIX(info->aspectRatio.numerator),
241
- INT2FIX(info->aspectRatio.denominator));
248
+ INT2FIX(info->aspectRatio.denominator));
242
249
  }
243
250
  else
244
251
  {
@@ -286,12 +293,16 @@ VALUE cio_get_clip_track_string(VALUE self)
286
293
 
287
294
  void Init_mxfinfo()
288
295
  {
289
- m_mxfinfo = rb_define_module("MXFInfo");
296
+ m_mxfinfo = rb_define_module("MXFInfo");
297
+
298
+ c_error = rb_define_class_under(m_mxfinfo, "Error", rb_eStandardError);
299
+ c_eNotOpAtom = rb_define_class_under(c_error, "NotOpAtom", c_error);
300
+ c_eNotReadable = rb_define_class_under(c_error, "NotReadable", c_error);
290
301
 
291
302
  c_infoobject = rb_define_class_under(m_mxfinfo, "InfoObject", rb_cObject);
292
303
  rb_define_singleton_method(c_infoobject, "new", cio_new, 1);
293
-
294
- rb_define_method(c_infoobject, "clip_name", cio_get_clip_name, 0);
304
+
305
+ rb_define_method(c_infoobject, "_clip_name", cio_get_clip_name, 0);
295
306
  rb_define_method(c_infoobject, "project_name", cio_get_project_name, 0);
296
307
  rb_define_method(c_infoobject, "clip_created", cio_get_clip_created, 0);
297
308
  rb_define_method(c_infoobject, "project_edit_rate", cio_get_project_edit_rate, 0);
@@ -302,7 +313,7 @@ void Init_mxfinfo()
302
313
  /* int numUserComments */
303
314
  /* AvidTaggedValue *materialPackageAttributes */
304
315
  /* int numMaterialPackageAttributes */
305
-
316
+
306
317
  rb_define_method(c_infoobject, "num_video_tracks", cio_get_num_video_tracks, 0);
307
318
  rb_define_method(c_infoobject, "num_audio_tracks", cio_get_num_audio_tracks, 0);
308
319
  rb_define_method(c_infoobject, "tracks_string", cio_get_tracks_string, 0);
data/lib/mxfinfo.rb CHANGED
@@ -3,12 +3,19 @@ require 'mxfinfo/version.rb'
3
3
 
4
4
  module MXFInfo
5
5
  def self.scan(path)
6
+ io = IO.new(2)
7
+ stderr = io.dup
8
+ io.reopen(IO::NULL)
6
9
  InfoObject.new path
10
+ rescue => e
11
+ io.reopen stderr
12
+ stderr.close
13
+ raise e
7
14
  end
8
15
 
9
16
  class InfoObject
10
17
  alias_method :videotracks, :num_video_tracks
11
- alias_method :v_tracks, :num_video_tracks
18
+ alias_method :v_tracks, :num_video_tracks
12
19
  alias_method :video_tracks, :num_video_tracks
13
20
  alias_method :audiotracks, :num_audio_tracks
14
21
  alias_method :audio_tracks, :num_audio_tracks
@@ -20,18 +27,14 @@ module MXFInfo
20
27
  alias_method :channelcount, :channel_count
21
28
  alias_method :c_count, :channel_count
22
29
  alias_method :file_package_uid, :file_source_package_uid
30
+ alias_method :clip_edit_rate, :project_edit_rate
23
31
 
24
32
  def render_file?
25
33
  physical_package_name == "Precompute Source Mob"
26
34
  end
27
35
 
28
- alias_method :essence_type_orig, :essence_type
29
- def essence_type
30
- result = self.send(:essence_type_orig)
31
- if result.start_with?("DNxHD")
32
- result.gsub!(/ \(\d+\)/, "")
33
- end
34
- result
36
+ def clip_name
37
+ _clip_name.force_encoding('UTF-8')
35
38
  end
36
39
  end
37
40
  end
@@ -1,4 +1,3 @@
1
1
  module MXFInfo
2
- VERSION = '0.0.7'
2
+ VERSION = '0.2.0'.freeze
3
3
  end
4
-
data/mxfinfo.gemspec CHANGED
@@ -1,14 +1,14 @@
1
- require File.expand_path('../lib/mxfinfo/version', __FILE__)
1
+ require File.expand_path('lib/mxfinfo/version', __dir__)
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.authors = ['Steve Dierker', 'Malte Rohde']
5
- gem.email = ['technology@flavoursys.com']
6
- gem.description = %q{MXFinfo is a gem that wraps avidmxfinfo from libmxf in a native ruby extension.}
7
- gem.summary = %q{MXFinfo is a gem that wraps avidmxfinfo from libmxf in a native ruby extension.}
8
- gem.homepage = 'http://github.com/flavoursys/mxfinfo'
5
+ gem.email = ['technology@projective.io']
6
+ gem.description = 'MXFinfo is a gem that wraps avidmxfinfo from libmxf in a native ruby extension.'
7
+ gem.summary = 'MXFinfo is a gem that wraps avidmxfinfo from libmxf in a native ruby extension.'
8
+ gem.homepage = 'http://github.com/projectivetech/mxfinfo'
9
9
 
10
- gem.files = `git ls-files`.split($\)
11
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
10
+ gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
11
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
12
12
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
13
13
  gem.extensions = ['ext/mxfinfo/extconf.rb']
14
14
  gem.name = 'mxfinfo'
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
18
18
 
19
19
  gem.required_ruby_version = '>= 1.9.3'
20
20
 
21
- gem.add_development_dependency 'rspec', '~> 2.14'
22
21
  gem.add_development_dependency 'rake-compiler', '~> 0.9'
22
+ gem.add_development_dependency 'rspec', '~> 3'
23
+ gem.add_development_dependency 'rspec-its', '1.2.0'
23
24
  end
24
-
@@ -1,29 +1,30 @@
1
1
  require 'spec_helper'
2
+ require 'time'
2
3
 
3
4
  describe 'MXFInfo::InfoObject' do
4
- context 'when created from an valid MXF file' do
5
+ context 'with a valid MXF file' do
5
6
  subject do
6
- MXFInfo.scan File.expand_path('../fixtures/IMG_0395.MOV.A14DC7130D.mxf', __FILE__)
7
+ MXFInfo.scan File.expand_path('fixtures/IMG_0395.MOV.A14DC7130D.mxf', __dir__)
7
8
  end
8
9
 
9
10
  its(:project_name) { should eq('Ballerinas_zippy') }
10
11
  its(:clip_name) { should eq('IMG_0395.MOV') }
11
12
  its(:clip_created_at) { should eq(Time.parse('2011-05-08 22:02:53.000')) }
12
- its(:project_edit_rate) { should eq((25/1)) }
13
+ its(:project_edit_rate) { should eq((25 / 1)) }
13
14
  its(:clip_duration) { should eq(287) }
15
+ its(:clip_edit_rate) { should eq((25 / 1)) }
14
16
  its(:video_tracks) { should eq(1) }
15
17
  its(:audio_tracks) { should eq(1) }
16
18
  its(:clip_track_string) { should eq('V1 A1') }
17
19
  its(:essence_type) { should eq('PCM') }
18
20
  its(:essence_label) { should eq('060e2b34040101010d01030102060200') }
19
21
  its(:track_number) { should eq(1) }
20
- its(:edit_rate) { should eq((48000/1)) }
21
- its(:track_duration) { should eq(551040) }
22
- its(:segment_duration) { should eq(551040) }
22
+ its(:edit_rate) { should eq((48_000 / 1)) }
23
+ its(:track_duration) { should eq(551_040) }
24
+ its(:segment_duration) { should eq(551_040) }
23
25
  its(:segment_offset) { should eq(0) }
24
26
  its(:start_timecode) { should eq(0) }
25
- # its_converted(:start_timecode) { should eq('00:00:00:00') }
26
- its(:audio_sampling_rate) { should eq((48000/1)) }
27
+ its(:audio_sampling_rate) { should eq((48_000 / 1)) }
27
28
  its(:quantization_bits) { should eq(16) }
28
29
  its(:channel_count) { should eq(1) }
29
30
  its(:material_package_uid) { should eq('060a2b340101010101010f00130000004dc7130d05831a0a060e2b347f7f2a80') }
@@ -32,11 +33,5 @@ describe 'MXFInfo::InfoObject' do
32
33
  its(:physical_package_type) { should eq(:import) }
33
34
  its(:physical_package_name) { should eq('IMG_0395.MOV') }
34
35
  its(:physical_package_locator) { should eq('file:///Macintosh%20HD/Users/susannehassepass/Desktop/London%201video/IMG_0395.MOV') }
35
-
36
- # Left-overs from the previous version (0.3.6) of mxfinfo
37
-
38
- # its(:unc_path) { should('Macintosh HD:Users:susannehassepass:Desktop:London 1video:IMG_0395.MOV') }
39
- # => Isn't exported from libmxf.
40
-
41
36
  end
42
- end
37
+ end
data/spec/mxfinfo_spec.rb CHANGED
@@ -20,7 +20,11 @@ describe 'MXFInfo' do
20
20
  it 'should return an InfoObject instance' do
21
21
  expect(MXFInfo.scan File.expand_path('../fixtures/IMG_0395.MOV.A14DC7130D.mxf', __FILE__)).to be_a(MXFInfo::InfoObject)
22
22
  end
23
- end
23
+
24
+ it 'should return an UTF-8 clip_name' do
25
+ expect(MXFInfo.scan(File.expand_path('../fixtures/IMG_0395.MOV.A14DC7130D.mxf', __FILE__)).clip_name.encoding).to eq(Encoding::UTF_8)
26
+ end
27
+ end
24
28
  end
25
29
  end
26
30
 
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'mxfinfo'
2
+ require 'rspec/its'
2
3
 
3
4
  RSpec.configure do |config|
4
5
  config.order = 'random'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mxfinfo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Dierker
@@ -9,40 +9,54 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-17 00:00:00.000000000 Z
12
+ date: 2021-03-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rspec
15
+ name: rake-compiler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '2.14'
20
+ version: '0.9'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '2.14'
27
+ version: '0.9'
28
28
  - !ruby/object:Gem::Dependency
29
- name: rake-compiler
29
+ name: rspec
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '0.9'
34
+ version: '3'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '0.9'
41
+ version: '3'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec-its
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '='
47
+ - !ruby/object:Gem::Version
48
+ version: 1.2.0
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '='
54
+ - !ruby/object:Gem::Version
55
+ version: 1.2.0
42
56
  description: MXFinfo is a gem that wraps avidmxfinfo from libmxf in a native ruby
43
57
  extension.
44
58
  email:
45
- - technology@flavoursys.com
59
+ - technology@projective.io
46
60
  executables: []
47
61
  extensions:
48
62
  - ext/mxfinfo/extconf.rb
@@ -53,6 +67,7 @@ files:
53
67
  - LICENSE
54
68
  - README.md
55
69
  - Rakefile
70
+ - compile_commands.json
56
71
  - ext/mxfinfo/avid_mxf_info.c
57
72
  - ext/mxfinfo/avid_mxf_info.h
58
73
  - ext/mxfinfo/extconf.rb
@@ -65,7 +80,7 @@ files:
65
80
  - spec/info_object_spec.rb
66
81
  - spec/mxfinfo_spec.rb
67
82
  - spec/spec_helper.rb
68
- homepage: http://github.com/flavoursys/mxfinfo
83
+ homepage: http://github.com/projectivetech/mxfinfo
69
84
  licenses:
70
85
  - MIT
71
86
  metadata: {}
@@ -85,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
100
  version: '0'
86
101
  requirements: []
87
102
  rubyforge_project:
88
- rubygems_version: 2.2.2
103
+ rubygems_version: 2.7.6.2
89
104
  signing_key:
90
105
  specification_version: 4
91
106
  summary: MXFinfo is a gem that wraps avidmxfinfo from libmxf in a native ruby extension.