chapter 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/chapter/chapter.c +10 -9
- metadata +4 -4
data/ext/chapter/chapter.c
CHANGED
@@ -24,17 +24,17 @@ rb_get_chapters(VALUE self, VALUE path) {
|
|
24
24
|
VALUE result = rb_ary_new();
|
25
25
|
for (i = 0; i < chapterCount; ++i)
|
26
26
|
{
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
27
|
+
VALUE chapter = rb_hash_new();
|
28
|
+
// print the infos
|
29
|
+
rb_hash_aset(chapter, rb_str_new2("title"), rb_str_new2(chapters[i].title));
|
30
|
+
rb_hash_aset(chapter, rb_str_new2("duration"), INT2NUM(chapters[i].duration));
|
31
|
+
rb_hash_aset(chapter, rb_str_new2("position"), INT2NUM(pos));
|
32
|
+
rb_ary_push(result, chapter);
|
33
|
+
pos = pos + chapters[i].duration;
|
35
34
|
}
|
36
35
|
// free up the memory
|
37
36
|
MP4Free(chapters);
|
37
|
+
MP4Close(file);
|
38
38
|
return result;
|
39
39
|
}
|
40
40
|
|
@@ -50,16 +50,17 @@ rb_set_chapters(VALUE self, VALUE path, VALUE chapters) {
|
|
50
50
|
uint32_t chapter_len = RARRAY_LEN(chapters);
|
51
51
|
uint32_t i;
|
52
52
|
MP4Chapter_t newChapters[chapter_len];
|
53
|
+
MP4Chapter_t *chapter = malloc(sizeof(MP4Chapter_t));
|
53
54
|
for (i = 0; i < chapter_len; i++) {
|
54
55
|
|
55
56
|
VALUE duration = rb_hash_aref(rb_ary_entry(chapters, i), rb_str_new2("duration"));
|
56
57
|
VALUE title = rb_hash_aref(rb_ary_entry(chapters, i), rb_str_new2("title"));
|
57
58
|
|
58
|
-
MP4Chapter_t *chapter = malloc(sizeof(MP4Chapter_t));
|
59
59
|
chapter->duration = NUM2UINT(duration);
|
60
60
|
strcpy(chapter->title, StringValuePtr(title));
|
61
61
|
newChapters[i] = *chapter;
|
62
62
|
}
|
63
|
+
free(chapter);
|
63
64
|
|
64
65
|
MP4SetChapters(file, &newChapters[0], chapter_len, MP4ChapterTypeQt);
|
65
66
|
MP4Close(file);
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: shoulda
|
@@ -121,7 +121,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
segments:
|
123
123
|
- 0
|
124
|
-
hash:
|
124
|
+
hash: 1293871107107134006
|
125
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
126
|
none: false
|
127
127
|
requirements:
|
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
130
|
version: '0'
|
131
131
|
requirements: []
|
132
132
|
rubyforge_project:
|
133
|
-
rubygems_version: 1.8.
|
133
|
+
rubygems_version: 1.8.23
|
134
134
|
signing_key:
|
135
135
|
specification_version: 3
|
136
136
|
summary: Read and write chapters of mp4 files
|