taglib-ruby 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +1 -1
- data/CHANGES.md +11 -0
- data/LICENSE.txt +0 -2
- data/README.md +7 -9
- data/docs/taglib/base.rb +35 -7
- data/docs/taglib/id3v2.rb +37 -5
- data/docs/taglib/mp4.rb +267 -0
- data/docs/taglib/mpeg.rb +23 -8
- data/ext/taglib_base/includes.i +2 -2
- data/ext/taglib_base/taglib_base.i +3 -0
- data/ext/taglib_base/taglib_base_wrap.cxx +11 -12
- data/ext/taglib_flac/taglib_flac_wrap.cxx +21 -25
- data/ext/taglib_id3v1/taglib_id3v1_wrap.cxx +4 -8
- data/ext/taglib_id3v2/taglib_id3v2.i +3 -0
- data/ext/taglib_id3v2/taglib_id3v2_wrap.cxx +528 -69
- data/ext/taglib_mp4/extconf.rb +4 -0
- data/ext/taglib_mp4/taglib_mp4.i +225 -0
- data/ext/taglib_mp4/taglib_mp4_wrap.cxx +4830 -0
- data/ext/taglib_mpeg/taglib_mpeg.i +15 -0
- data/ext/taglib_mpeg/taglib_mpeg_wrap.cxx +174 -88
- data/ext/taglib_ogg/taglib_ogg_wrap.cxx +2 -6
- data/ext/taglib_vorbis/taglib_vorbis_wrap.cxx +8 -12
- data/lib/taglib.rb +1 -0
- data/lib/taglib/mp4.rb +33 -0
- data/lib/taglib/version.rb +2 -2
- data/taglib-ruby.gemspec +19 -3
- data/tasks/ext.rake +3 -0
- data/tasks/swig.rake +6 -1
- data/test/base_test.rb +11 -0
- data/test/data/Makefile +5 -2
- data/test/data/flac-create.cpp +2 -22
- data/test/data/get_picture_data.cpp +22 -0
- data/test/data/mp4-create.cpp +38 -0
- data/test/data/mp4.m4a +0 -0
- data/test/fileref_write_test.rb +9 -0
- data/test/flac_file_test.rb +2 -1
- data/test/id3v2_header_test.rb +61 -0
- data/test/id3v2_write_test.rb +17 -0
- data/test/mp4_file_test.rb +51 -0
- data/test/mp4_file_write_test.rb +66 -0
- data/test/mp4_items_test.rb +183 -0
- metadata +39 -8
@@ -1885,7 +1885,7 @@ TagLib::ByteVector ruby_string_to_taglib_bytevector(VALUE s) {
|
|
1885
1885
|
if (NIL_P(s)) {
|
1886
1886
|
return TagLib::ByteVector::null;
|
1887
1887
|
} else {
|
1888
|
-
return TagLib::ByteVector(RSTRING_PTR(s), RSTRING_LEN(s));
|
1888
|
+
return TagLib::ByteVector(RSTRING_PTR(StringValue(s)), RSTRING_LEN(s));
|
1889
1889
|
}
|
1890
1890
|
}
|
1891
1891
|
|
@@ -1903,7 +1903,7 @@ TagLib::String ruby_string_to_taglib_string(VALUE s) {
|
|
1903
1903
|
if (NIL_P(s)) {
|
1904
1904
|
return TagLib::String::null;
|
1905
1905
|
} else {
|
1906
|
-
return TagLib::String(RSTRING_PTR(CONVERT_TO_UTF8(s)), TagLib::String::UTF8);
|
1906
|
+
return TagLib::String(RSTRING_PTR(CONVERT_TO_UTF8(StringValue(s))), TagLib::String::UTF8);
|
1907
1907
|
}
|
1908
1908
|
}
|
1909
1909
|
|
@@ -2076,11 +2076,7 @@ SWIGINTERN int
|
|
2076
2076
|
SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc)
|
2077
2077
|
{
|
2078
2078
|
if (TYPE(obj) == T_STRING) {
|
2079
|
-
#if defined(StringValuePtr)
|
2080
2079
|
char *cstr = StringValuePtr(obj);
|
2081
|
-
#else
|
2082
|
-
char *cstr = STR2CSTR(obj);
|
2083
|
-
#endif
|
2084
2080
|
size_t size = RSTRING_LEN(obj) + 1;
|
2085
2081
|
if (cptr) {
|
2086
2082
|
if (alloc) {
|
@@ -2161,12 +2157,12 @@ _wrap_new_Properties__SWIG_0(int argc, VALUE *argv, VALUE self) {
|
|
2161
2157
|
}
|
2162
2158
|
res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_TagLib__Vorbis__File, 0 | 0 );
|
2163
2159
|
if (!SWIG_IsOK(res1)) {
|
2164
|
-
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "TagLib::Vorbis::File *","
|
2160
|
+
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "TagLib::Vorbis::File *","Properties", 1, argv[0] ));
|
2165
2161
|
}
|
2166
2162
|
arg1 = reinterpret_cast< TagLib::Vorbis::File * >(argp1);
|
2167
2163
|
ecode2 = SWIG_AsVal_int(argv[1], &val2);
|
2168
2164
|
if (!SWIG_IsOK(ecode2)) {
|
2169
|
-
SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "TagLib::AudioProperties::ReadStyle","
|
2165
|
+
SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "TagLib::AudioProperties::ReadStyle","Properties", 2, argv[1] ));
|
2170
2166
|
}
|
2171
2167
|
arg2 = static_cast< TagLib::AudioProperties::ReadStyle >(val2);
|
2172
2168
|
result = (TagLib::Vorbis::Properties *)new TagLib::Vorbis::Properties(arg1,arg2);
|
@@ -2207,7 +2203,7 @@ _wrap_new_Properties__SWIG_1(int argc, VALUE *argv, VALUE self) {
|
|
2207
2203
|
}
|
2208
2204
|
res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_TagLib__Vorbis__File, 0 | 0 );
|
2209
2205
|
if (!SWIG_IsOK(res1)) {
|
2210
|
-
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "TagLib::Vorbis::File *","
|
2206
|
+
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "TagLib::Vorbis::File *","Properties", 1, argv[0] ));
|
2211
2207
|
}
|
2212
2208
|
arg1 = reinterpret_cast< TagLib::Vorbis::File * >(argp1);
|
2213
2209
|
result = (TagLib::Vorbis::Properties *)new TagLib::Vorbis::Properties(arg1);
|
@@ -2485,12 +2481,12 @@ _wrap_new_File__SWIG_0(int argc, VALUE *argv, VALUE self) {
|
|
2485
2481
|
}
|
2486
2482
|
ecode2 = SWIG_AsVal_bool(argv[1], &val2);
|
2487
2483
|
if (!SWIG_IsOK(ecode2)) {
|
2488
|
-
SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "bool","
|
2484
|
+
SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "bool","File", 2, argv[1] ));
|
2489
2485
|
}
|
2490
2486
|
arg2 = static_cast< bool >(val2);
|
2491
2487
|
ecode3 = SWIG_AsVal_int(argv[2], &val3);
|
2492
2488
|
if (!SWIG_IsOK(ecode3)) {
|
2493
|
-
SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "TagLib::Vorbis::Properties::ReadStyle","
|
2489
|
+
SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "TagLib::Vorbis::Properties::ReadStyle","File", 3, argv[2] ));
|
2494
2490
|
}
|
2495
2491
|
arg3 = static_cast< TagLib::Vorbis::Properties::ReadStyle >(val3);
|
2496
2492
|
result = (TagLib::Vorbis::File *)new TagLib::Vorbis::File(arg1,arg2,arg3);
|
@@ -2521,7 +2517,7 @@ _wrap_new_File__SWIG_1(int argc, VALUE *argv, VALUE self) {
|
|
2521
2517
|
}
|
2522
2518
|
ecode2 = SWIG_AsVal_bool(argv[1], &val2);
|
2523
2519
|
if (!SWIG_IsOK(ecode2)) {
|
2524
|
-
SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "bool","
|
2520
|
+
SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "bool","File", 2, argv[1] ));
|
2525
2521
|
}
|
2526
2522
|
arg2 = static_cast< bool >(val2);
|
2527
2523
|
result = (TagLib::Vorbis::File *)new TagLib::Vorbis::File(arg1,arg2);
|
data/lib/taglib.rb
CHANGED
data/lib/taglib/mp4.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'taglib_mp4'
|
2
|
+
|
3
|
+
module TagLib::MP4
|
4
|
+
|
5
|
+
class File
|
6
|
+
extend ::TagLib::FileOpenable
|
7
|
+
end
|
8
|
+
|
9
|
+
class Tag
|
10
|
+
remove_method :save
|
11
|
+
end
|
12
|
+
|
13
|
+
class Item
|
14
|
+
def self.from_int_pair(ary)
|
15
|
+
if !(ary.is_a? Array)
|
16
|
+
raise ArgumentError, 'argument should be an array'
|
17
|
+
elsif ary.length != 2
|
18
|
+
raise ArgumentError, 'argument should have exactly two elements'
|
19
|
+
else
|
20
|
+
new(*ary)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class ItemListMap
|
26
|
+
alias :clear :_clear
|
27
|
+
alias :insert :_insert
|
28
|
+
alias :[] :fetch
|
29
|
+
remove_method :_clear
|
30
|
+
remove_method :_insert
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
data/lib/taglib/version.rb
CHANGED
data/taglib-ruby.gemspec
CHANGED
@@ -7,9 +7,9 @@ require 'taglib/version'
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "taglib-ruby"
|
9
9
|
s.version = TagLib::Version::STRING
|
10
|
-
s.authors = ["Robin Stocker"]
|
10
|
+
s.authors = ["Robin Stocker", "Jacob Vosmaer"]
|
11
11
|
s.email = ["robin@nibor.org"]
|
12
|
-
s.homepage = "http://robinst.github.
|
12
|
+
s.homepage = "http://robinst.github.io/taglib-ruby/"
|
13
13
|
s.licenses = ["MIT"]
|
14
14
|
s.summary = "Ruby interface for the taglib C++ library"
|
15
15
|
s.description = <<DESC
|
@@ -23,10 +23,11 @@ DESC
|
|
23
23
|
s.require_paths = ["lib"]
|
24
24
|
s.requirements = ["taglib (libtag1-dev in Debian/Ubuntu, taglib-devel in Fedora/RHEL)"]
|
25
25
|
|
26
|
-
s.add_development_dependency 'bundler', '~> 1.
|
26
|
+
s.add_development_dependency 'bundler', '~> 1.2'
|
27
27
|
s.add_development_dependency 'rake-compiler', '~> 0.8'
|
28
28
|
s.add_development_dependency 'shoulda-context', '~> 1.0'
|
29
29
|
s.add_development_dependency 'yard', '~> 0.7'
|
30
|
+
s.add_development_dependency 'kramdown', '~> 1.0'
|
30
31
|
|
31
32
|
s.extensions = [
|
32
33
|
"ext/taglib_base/extconf.rb",
|
@@ -36,6 +37,7 @@ DESC
|
|
36
37
|
"ext/taglib_ogg/extconf.rb",
|
37
38
|
"ext/taglib_vorbis/extconf.rb",
|
38
39
|
"ext/taglib_flac/extconf.rb",
|
40
|
+
"ext/taglib_mp4/extconf.rb",
|
39
41
|
]
|
40
42
|
s.extra_rdoc_files = [
|
41
43
|
"CHANGES.md",
|
@@ -55,6 +57,7 @@ DESC
|
|
55
57
|
"docs/taglib/flac.rb",
|
56
58
|
"docs/taglib/id3v1.rb",
|
57
59
|
"docs/taglib/id3v2.rb",
|
60
|
+
"docs/taglib/mp4.rb",
|
58
61
|
"docs/taglib/mpeg.rb",
|
59
62
|
"docs/taglib/ogg.rb",
|
60
63
|
"docs/taglib/vorbis.rb",
|
@@ -63,6 +66,7 @@ DESC
|
|
63
66
|
"ext/taglib_base/includes.i",
|
64
67
|
"ext/taglib_base/taglib_base.i",
|
65
68
|
"ext/taglib_base/taglib_base_wrap.cxx",
|
69
|
+
"ext/taglib_flac/extconf.rb",
|
66
70
|
"ext/taglib_flac/taglib_flac.i",
|
67
71
|
"ext/taglib_flac/taglib_flac_wrap.cxx",
|
68
72
|
"ext/taglib_id3v1/extconf.rb",
|
@@ -72,6 +76,9 @@ DESC
|
|
72
76
|
"ext/taglib_id3v2/relativevolumeframe.i",
|
73
77
|
"ext/taglib_id3v2/taglib_id3v2.i",
|
74
78
|
"ext/taglib_id3v2/taglib_id3v2_wrap.cxx",
|
79
|
+
"ext/taglib_mp4/extconf.rb",
|
80
|
+
"ext/taglib_mp4/taglib_mp4.i",
|
81
|
+
"ext/taglib_mp4/taglib_mp4_wrap.cxx",
|
75
82
|
"ext/taglib_mpeg/extconf.rb",
|
76
83
|
"ext/taglib_mpeg/taglib_mpeg.i",
|
77
84
|
"ext/taglib_mpeg/taglib_mpeg_wrap.cxx",
|
@@ -88,6 +95,7 @@ DESC
|
|
88
95
|
"lib/taglib/flac.rb",
|
89
96
|
"lib/taglib/id3v1.rb",
|
90
97
|
"lib/taglib/id3v2.rb",
|
98
|
+
"lib/taglib/mp4.rb",
|
91
99
|
"lib/taglib/mpeg.rb",
|
92
100
|
"lib/taglib/ogg.rb",
|
93
101
|
"lib/taglib/version.rb",
|
@@ -97,15 +105,19 @@ DESC
|
|
97
105
|
"tasks/ext.rake",
|
98
106
|
"tasks/gemspec_check.rake",
|
99
107
|
"tasks/swig.rake",
|
108
|
+
"test/base_test.rb",
|
100
109
|
"test/data/Makefile",
|
101
110
|
"test/data/add-relative-volume.cpp",
|
102
111
|
"test/data/crash.mp3",
|
103
112
|
"test/data/flac-create.cpp",
|
104
113
|
"test/data/flac.flac",
|
114
|
+
"test/data/get_picture_data.cpp",
|
105
115
|
"test/data/globe_east_540.jpg",
|
106
116
|
"test/data/globe_east_90.jpg",
|
107
117
|
"test/data/id3v1-create.cpp",
|
108
118
|
"test/data/id3v1.mp3",
|
119
|
+
"test/data/mp4-create.cpp",
|
120
|
+
"test/data/mp4.m4a",
|
109
121
|
"test/data/relative-volume.mp3",
|
110
122
|
"test/data/sample.mp3",
|
111
123
|
"test/data/unicode.mp3",
|
@@ -119,11 +131,15 @@ DESC
|
|
119
131
|
"test/flac_file_write_test.rb",
|
120
132
|
"test/id3v1_tag_test.rb",
|
121
133
|
"test/id3v2_frames_test.rb",
|
134
|
+
"test/id3v2_header_test.rb",
|
122
135
|
"test/id3v2_memory_test.rb",
|
123
136
|
"test/id3v2_relative_volume_test.rb",
|
124
137
|
"test/id3v2_tag_test.rb",
|
125
138
|
"test/id3v2_unicode_test.rb",
|
126
139
|
"test/id3v2_write_test.rb",
|
140
|
+
"test/mp4_file_test.rb",
|
141
|
+
"test/mp4_file_write_test.rb",
|
142
|
+
"test/mp4_items_test.rb",
|
127
143
|
"test/mpeg_file_test.rb",
|
128
144
|
"test/tag_test.rb",
|
129
145
|
"test/unicode_filename_test.rb",
|
data/tasks/ext.rake
CHANGED
@@ -46,6 +46,9 @@ end
|
|
46
46
|
Rake::ExtensionTask.new("taglib_flac", $gemspec) do |ext|
|
47
47
|
configure_cross_compile(ext)
|
48
48
|
end
|
49
|
+
Rake::ExtensionTask.new("taglib_mp4", $gemspec) do |ext|
|
50
|
+
configure_cross_compile(ext)
|
51
|
+
end
|
49
52
|
|
50
53
|
task :cross => [:taglib] do
|
51
54
|
# Mkmf just uses "g++" as C++ compiler, despite what's in rbconfig.rb.
|
data/tasks/swig.rake
CHANGED
@@ -5,7 +5,7 @@ def run_swig(mod)
|
|
5
5
|
if swig.empty?
|
6
6
|
swig = `which swig2.0`.chomp
|
7
7
|
end
|
8
|
-
sh "cd ext/#{mod} && #{swig} -c++ -ruby -autorename -initname #{mod} -I/usr/include #{mod}.i"
|
8
|
+
sh "cd ext/#{mod} && #{swig} -c++ -ruby -autorename -initname #{mod} -I/usr/local/include -I/usr/include #{mod}.i"
|
9
9
|
end
|
10
10
|
|
11
11
|
task :swig =>
|
@@ -16,6 +16,7 @@ task :swig =>
|
|
16
16
|
'ext/taglib_ogg/taglib_ogg_wrap.cxx',
|
17
17
|
'ext/taglib_vorbis/taglib_vorbis_wrap.cxx',
|
18
18
|
'ext/taglib_flac/taglib_flac_wrap.cxx',
|
19
|
+
'ext/taglib_mp4/taglib_mp4_wrap.cxx',
|
19
20
|
]
|
20
21
|
|
21
22
|
base_dependencies = ['ext/taglib_base/taglib_base.i', 'ext/taglib_base/includes.i']
|
@@ -47,3 +48,7 @@ end
|
|
47
48
|
file 'ext/taglib_flac/taglib_flac_wrap.cxx' => ['ext/taglib_flac/taglib_flac.i'] + base_dependencies do
|
48
49
|
run_swig('taglib_flac')
|
49
50
|
end
|
51
|
+
|
52
|
+
file 'ext/taglib_mp4/taglib_mp4_wrap.cxx' => ['ext/taglib_mp4/taglib_mp4.i'] + base_dependencies do
|
53
|
+
run_swig('taglib_mp4')
|
54
|
+
end
|
data/test/base_test.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'helper')
|
2
|
+
|
3
|
+
class BaseTest < Test::Unit::TestCase
|
4
|
+
context "TagLib" do
|
5
|
+
should "contain version constants" do
|
6
|
+
assert TagLib::TAGLIB_MAJOR_VERSION.is_a? Integer
|
7
|
+
assert TagLib::TAGLIB_MINOR_VERSION.is_a? Integer
|
8
|
+
assert TagLib::TAGLIB_PATCH_VERSION.is_a? Integer
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/test/data/Makefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
.PHONY: all clean
|
2
2
|
|
3
|
-
all:: add-relative-volume id3v1-create vorbis-create flac-create
|
3
|
+
all:: add-relative-volume id3v1-create vorbis-create flac-create mp4-create
|
4
4
|
|
5
5
|
add-relative-volume: add-relative-volume.cpp
|
6
6
|
g++ -o $@ $< -ltag -I/usr/include/taglib
|
@@ -14,5 +14,8 @@ vorbis-create: vorbis-create.cpp
|
|
14
14
|
flac-create: flac-create.cpp
|
15
15
|
g++ -o $@ $< -ltag -I/usr/include/taglib
|
16
16
|
|
17
|
+
mp4-create: mp4-create.cpp
|
18
|
+
g++ -o $@ $< -ltag -I/usr/include/taglib
|
19
|
+
|
17
20
|
clean::
|
18
|
-
-rm add-relative-volume id3v1-create vorbis-create flac-create
|
21
|
+
-rm add-relative-volume id3v1-create vorbis-create flac-create mp4-create
|
data/test/data/flac-create.cpp
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
#include <iostream>
|
2
|
-
#include <fstream>
|
3
2
|
#include <stdlib.h>
|
4
3
|
|
5
4
|
#include <taglib/taglib.h>
|
6
5
|
#include <taglib/flacfile.h>
|
7
6
|
#include <taglib/xiphcomment.h>
|
8
7
|
|
9
|
-
|
8
|
+
#include "get_picture_data.cpp"
|
10
9
|
|
11
|
-
|
10
|
+
using namespace TagLib;
|
12
11
|
|
13
12
|
int main(int argc, char **argv) {
|
14
13
|
if (argc != 2) {
|
@@ -58,23 +57,4 @@ int main(int argc, char **argv) {
|
|
58
57
|
file.save();
|
59
58
|
}
|
60
59
|
|
61
|
-
ByteVector getPictureData(const char *filename) {
|
62
|
-
std::ifstream is;
|
63
|
-
is.open(filename, std::ios::binary);
|
64
|
-
|
65
|
-
is.seekg(0, std::ios::end);
|
66
|
-
int length = is.tellg();
|
67
|
-
is.seekg(0, std::ios::beg);
|
68
|
-
|
69
|
-
char *buffer = new char[length];
|
70
|
-
|
71
|
-
is.read(buffer, length);
|
72
|
-
is.close();
|
73
|
-
|
74
|
-
ByteVector result(buffer, length);
|
75
|
-
delete[] buffer;
|
76
|
-
|
77
|
-
return result;
|
78
|
-
}
|
79
|
-
|
80
60
|
// vim: set filetype=cpp sw=2 ts=2 expandtab:
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#include <fstream>
|
2
|
+
|
3
|
+
using namespace TagLib;
|
4
|
+
|
5
|
+
ByteVector getPictureData(const char *filename) {
|
6
|
+
std::ifstream is;
|
7
|
+
is.open(filename, std::ios::binary);
|
8
|
+
|
9
|
+
is.seekg(0, std::ios::end);
|
10
|
+
int length = is.tellg();
|
11
|
+
is.seekg(0, std::ios::beg);
|
12
|
+
|
13
|
+
char *buffer = new char[length];
|
14
|
+
|
15
|
+
is.read(buffer, length);
|
16
|
+
is.close();
|
17
|
+
|
18
|
+
ByteVector result(buffer, length);
|
19
|
+
delete[] buffer;
|
20
|
+
|
21
|
+
return result;
|
22
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#include <iostream>
|
2
|
+
#include <stdlib.h>
|
3
|
+
|
4
|
+
#include <taglib/taglib.h>
|
5
|
+
#include <taglib/mp4file.h>
|
6
|
+
|
7
|
+
#include "get_picture_data.cpp"
|
8
|
+
|
9
|
+
using namespace TagLib;
|
10
|
+
|
11
|
+
int main(int argc, char **argv) {
|
12
|
+
if (argc != 2) {
|
13
|
+
std::cout << "usage: " << argv[0] << " file.m4a" << std::endl;
|
14
|
+
exit(1);
|
15
|
+
}
|
16
|
+
char *filename = argv[1];
|
17
|
+
|
18
|
+
MP4::File file(filename);
|
19
|
+
MP4::Tag *tag = file.tag();
|
20
|
+
|
21
|
+
tag->setTitle("Title");
|
22
|
+
tag->setArtist("Artist");
|
23
|
+
tag->setAlbum("Album");
|
24
|
+
tag->setComment("Comment");
|
25
|
+
tag->setGenre("Pop");
|
26
|
+
tag->setYear(2011);
|
27
|
+
tag->setTrack(7);
|
28
|
+
|
29
|
+
ByteVector data = getPictureData("globe_east_90.jpg");
|
30
|
+
MP4::CoverArt cover_art = MP4::CoverArt(MP4::CoverArt::JPEG, data);
|
31
|
+
MP4::CoverArtList cover_art_list = MP4::CoverArtList();
|
32
|
+
cover_art_list.append(cover_art);
|
33
|
+
tag->itemListMap().insert("covr", MP4::Item(cover_art_list));
|
34
|
+
|
35
|
+
file.save();
|
36
|
+
}
|
37
|
+
|
38
|
+
// vim: set filetype=cpp sw=2 ts=2 expandtab:
|
data/test/data/mp4.m4a
ADDED
Binary file
|
data/test/fileref_write_test.rb
CHANGED
@@ -27,6 +27,15 @@ class TestFileRefWrite < Test::Unit::TestCase
|
|
27
27
|
written_file.close
|
28
28
|
end
|
29
29
|
|
30
|
+
should "not segfault when setting int" do
|
31
|
+
begin
|
32
|
+
@file.tag.title = 42
|
33
|
+
flunk("Should have raised a TypeError")
|
34
|
+
rescue TypeError
|
35
|
+
# this is good
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
30
39
|
teardown do
|
31
40
|
if @file
|
32
41
|
@file.close
|
data/test/flac_file_test.rb
CHANGED
@@ -44,7 +44,8 @@ class FlacFileTest < Test::Unit::TestCase
|
|
44
44
|
|
45
45
|
should "contain flac-specific information" do
|
46
46
|
assert_equal 16, @properties.sample_width
|
47
|
-
|
47
|
+
s = ["78d19b86df2cd488b35957e6bd884968"].pack('H*')
|
48
|
+
assert_equal s, @properties.signature
|
48
49
|
end
|
49
50
|
end
|
50
51
|
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'helper')
|
2
|
+
|
3
|
+
class TestID3v2Header < Test::Unit::TestCase
|
4
|
+
context "The sample.mp3 file" do
|
5
|
+
setup do
|
6
|
+
read_properties = false
|
7
|
+
@file = TagLib::MPEG::File.new("test/data/sample.mp3", read_properties)
|
8
|
+
@tag = @file.id3v2_tag
|
9
|
+
end
|
10
|
+
|
11
|
+
should "have a ID3v2 header" do
|
12
|
+
assert_not_nil @tag.header
|
13
|
+
end
|
14
|
+
|
15
|
+
context "header" do
|
16
|
+
setup do
|
17
|
+
@header = @tag.header
|
18
|
+
end
|
19
|
+
|
20
|
+
should "have a major version" do
|
21
|
+
assert_equal 3, @header.major_version
|
22
|
+
end
|
23
|
+
|
24
|
+
should "have a revision number" do
|
25
|
+
assert_equal 0, @header.revision_number
|
26
|
+
end
|
27
|
+
|
28
|
+
should "have a tag size" do
|
29
|
+
assert_equal 63478, @header.tag_size
|
30
|
+
end
|
31
|
+
|
32
|
+
should "not have a footer" do
|
33
|
+
assert_equal false, @header.footer_present
|
34
|
+
end
|
35
|
+
|
36
|
+
should "not have an extended header" do
|
37
|
+
assert_equal false, @header.extended_header
|
38
|
+
end
|
39
|
+
|
40
|
+
context "changing the major version" do
|
41
|
+
|
42
|
+
setup do
|
43
|
+
@header.major_version = 4
|
44
|
+
end
|
45
|
+
|
46
|
+
should "have a different major verson" do
|
47
|
+
assert_equal 4, @header.major_version
|
48
|
+
end
|
49
|
+
|
50
|
+
teardown do
|
51
|
+
@header.major_version = 3
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
teardown do
|
57
|
+
@file.close
|
58
|
+
@file = nil
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|