Skip to content

Commit c1d3ba8

Browse files
authored
Merge pull request #103 from iamAzeem/support-for-chap-and-ctoc-frames
Added support for CTOC and CHAP frames.
2 parents 4982ea7 + 95c1f4f commit c1d3ba8

File tree

5 files changed

+2715
-685
lines changed

5 files changed

+2715
-685
lines changed

ext/taglib_base/includes.i

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
%{
2020
#include <taglib/tstring.h>
2121
#include <taglib/tstringlist.h>
22+
#include <taglib/tbytevector.h>
23+
#include <taglib/tbytevectorlist.h>
2224
#include <taglib/tfile.h>
2325

2426
#if defined(HAVE_RUBY_ENCODING_H) && HAVE_RUBY_ENCODING_H
@@ -88,6 +90,28 @@ TagLib::StringList ruby_array_to_taglib_string_list(VALUE ary) {
8890
return result;
8991
}
9092

93+
VALUE taglib_bytevectorlist_to_ruby_array(const TagLib::ByteVectorList & list) {
94+
VALUE ary = rb_ary_new2(list.size());
95+
for (TagLib::ByteVectorList::ConstIterator it = list.begin(); it != list.end(); it++) {
96+
VALUE s = taglib_bytevector_to_ruby_string(*it);
97+
rb_ary_push(ary, s);
98+
}
99+
return ary;
100+
}
101+
102+
TagLib::ByteVectorList ruby_array_to_taglib_bytevectorlist(VALUE ary) {
103+
TagLib::ByteVectorList result = TagLib::ByteVectorList();
104+
if (NIL_P(ary)) {
105+
return result;
106+
}
107+
for (long i = 0; i < RARRAY_LEN(ary); i++) {
108+
VALUE e = rb_ary_entry(ary, i);
109+
TagLib::ByteVector s = ruby_string_to_taglib_bytevector(e);
110+
result.append(s);
111+
}
112+
return result;
113+
}
114+
91115
VALUE taglib_filename_to_ruby_string(TagLib::FileName filename) {
92116
VALUE result;
93117
#ifdef _WIN32

ext/taglib_base/taglib_base.i

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
%{
33
#include <taglib/taglib.h>
44
#include <taglib/tbytevector.h>
5+
#include <taglib/tbytevectorlist.h>
56
#include <taglib/tlist.h>
67
#include <taglib/fileref.h>
78
#include <taglib/tag.h>
@@ -12,6 +13,7 @@
1213
namespace TagLib {
1314
class StringList;
1415
class ByteVector;
16+
class ByteVectorList;
1517

1618
class String {
1719
public:
@@ -57,6 +59,22 @@ namespace TagLib {
5759
}
5860
%typemap(typecheck) const TagLib::ByteVector & = char *;
5961

62+
// ByteVectorList
63+
%typemap(out) TagLib::ByteVectorList {
64+
$result = taglib_bytevectorlist_to_ruby_array($1);
65+
}
66+
%typemap(out) TagLib::ByteVectorList * {
67+
$result = taglib_bytevectorlist_to_ruby_array(*($1));
68+
}
69+
%typemap(in) TagLib::ByteVectorList & (TagLib::ByteVectorList tmp) {
70+
tmp = ruby_array_to_taglib_bytevectorlist($input);
71+
$1 = &tmp;
72+
}
73+
%typemap(in) TagLib::ByteVectorList * (TagLib::ByteVectorList tmp) {
74+
tmp = ruby_array_to_taglib_bytevectorlist($input);
75+
$1 = &tmp;
76+
}
77+
6078
// String
6179
%typemap(out) TagLib::String {
6280
$result = taglib_string_to_ruby_string($1);

ext/taglib_id3v2/taglib_id3v2.i

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
#include <taglib/id3v2tag.h>
66
#include <taglib/id3v2header.h>
77

8+
#include <taglib/tbytevectorlist.h>
9+
810
#include <taglib/attachedpictureframe.h>
11+
#include <taglib/chapterframe.h>
912
#include <taglib/commentsframe.h>
1013
#include <taglib/generalencapsulatedobjectframe.h>
1114
#include <taglib/popularimeterframe.h>
1215
#include <taglib/privateframe.h>
1316
#include <taglib/relativevolumeframe.h>
17+
#include <taglib/tableofcontentsframe.h>
1418
#include <taglib/textidentificationframe.h>
1519
#include <taglib/uniquefileidentifierframe.h>
1620
#include <taglib/unknownframe.h>
@@ -36,8 +40,12 @@ VALUE taglib_id3v2_frame_to_ruby_object(const TagLib::ID3v2::Frame *frame) {
3640
ti = SWIGTYPE_p_TagLib__ID3v2__UnknownFrame;
3741
else if (id == "APIC")
3842
ti = SWIGTYPE_p_TagLib__ID3v2__AttachedPictureFrame;
43+
else if (id == "CHAP")
44+
ti = SWIGTYPE_p_TagLib__ID3v2__ChapterFrame;
3945
else if (id == "COMM")
4046
ti = SWIGTYPE_p_TagLib__ID3v2__CommentsFrame;
47+
else if (id == "CTOC")
48+
ti = SWIGTYPE_p_TagLib__ID3v2__TableOfContentsFrame;
4149
else if (id == "GEOB")
4250
ti = SWIGTYPE_p_TagLib__ID3v2__GeneralEncapsulatedObjectFrame;
4351
else if (id == "POPM")
@@ -126,12 +134,21 @@ VALUE taglib_id3v2_framelist_to_ruby_array(TagLib::ID3v2::FrameList *list) {
126134
%include <taglib/attachedpictureframe.h>
127135

128136
// Ignore the unified property interface.
137+
%ignore TagLib::ID3v2::ChapterFrame::asProperties;
129138
%ignore TagLib::ID3v2::CommentsFrame::asProperties;
139+
%ignore TagLib::ID3v2::TableOfContentsFrame::asProperties;
140+
141+
%rename("element_id=") TagLib::ID3v2::ChapterFrame::setElementID(const ByteVector &eID);
142+
%include <taglib/chapterframe.h>
130143

131144
%include <taglib/commentsframe.h>
132145
%include <taglib/generalencapsulatedobjectframe.h>
133146
%include <taglib/popularimeterframe.h>
134147
%include <taglib/privateframe.h>
148+
149+
%rename("element_id=") TagLib::ID3v2::TableOfContentsFrame::setElementID(const ByteVector &eID);
150+
%include <taglib/tableofcontentsframe.h>
151+
135152
%include <taglib/textidentificationframe.h>
136153

137154
// Ignore the unified property interface.

0 commit comments

Comments
 (0)