rbcddb 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +1 -0
- data/README +33 -0
- data/Rakefile +182 -0
- data/example/example.rb +68 -0
- data/ext/cddb_conn.c +576 -0
- data/ext/cddb_conn.h +15 -0
- data/ext/cddb_disc.c +497 -0
- data/ext/cddb_disc.h +16 -0
- data/ext/cddb_mod.c +134 -0
- data/ext/cddb_mod.h +11 -0
- data/ext/cddb_rb.c +15 -0
- data/ext/cddb_track.c +327 -0
- data/ext/cddb_track.h +18 -0
- data/ext/extconf.rb +6 -0
- data/ext/usage.c +19 -0
- data/ext/usage.h +8 -0
- metadata +61 -0
data/ext/cddb_disc.c
ADDED
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
#include<ruby.h>
|
|
2
|
+
#include<cddb/cddb.h>
|
|
3
|
+
|
|
4
|
+
#include "cddb_conn.h"
|
|
5
|
+
#include "cddb_disc.h"
|
|
6
|
+
#include "cddb_track.h"
|
|
7
|
+
|
|
8
|
+
#include "usage.h"
|
|
9
|
+
|
|
10
|
+
VALUE cddb_disc_rb;
|
|
11
|
+
|
|
12
|
+
static void crb_disc_free(void *p) {
|
|
13
|
+
cddb_disc_destroy(p);
|
|
14
|
+
decLibUsage();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static VALUE crb_to_string(const char* str) {
|
|
18
|
+
if (str)
|
|
19
|
+
return rb_str_new2(str);
|
|
20
|
+
else
|
|
21
|
+
return Qnil;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
cddb_disc_t *get_cddb_disc_from_Value(VALUE self) {
|
|
25
|
+
cddb_disc_t *disc = NULL;
|
|
26
|
+
Data_Get_Struct(self,cddb_disc_t,disc);
|
|
27
|
+
return disc;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
VALUE makeValueFrom_cddb_disc_t(cddb_disc_t *disc) {
|
|
31
|
+
VALUE obj=Qnil;
|
|
32
|
+
if (disc) {
|
|
33
|
+
incLibUsage();
|
|
34
|
+
obj=Data_Wrap_Struct(cddb_disc_rb,0,crb_disc_free,disc);
|
|
35
|
+
}
|
|
36
|
+
return obj;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
VALUE _makeValueFrom_cddb_disc_t(cddb_disc_t *disc) {
|
|
40
|
+
VALUE obj=Qnil;
|
|
41
|
+
if (disc) {
|
|
42
|
+
obj=Data_Wrap_Struct(cddb_disc_rb,0,0,disc);
|
|
43
|
+
}
|
|
44
|
+
return obj;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
static VALUE crb_disc_alloc(VALUE klass)
|
|
49
|
+
{
|
|
50
|
+
VALUE obj;
|
|
51
|
+
cddb_disc_t *disc = NULL;
|
|
52
|
+
incLibUsage();
|
|
53
|
+
disc = cddb_disc_new();
|
|
54
|
+
if (disc == NULL) {
|
|
55
|
+
rb_sys_fail("out of memory, "
|
|
56
|
+
"unable to create cddb_disc structure");
|
|
57
|
+
}
|
|
58
|
+
obj=Data_Wrap_Struct(klass,0,crb_disc_free,disc);
|
|
59
|
+
return obj;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
/*
|
|
64
|
+
* call-seq:
|
|
65
|
+
* clone -> CDDB_Disc
|
|
66
|
+
*
|
|
67
|
+
* Makes an object with the same content as the current object
|
|
68
|
+
*
|
|
69
|
+
*/
|
|
70
|
+
static VALUE crb_cddb_disc_clone(VALUE self) {
|
|
71
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
72
|
+
return makeValueFrom_cddb_disc_t(cddb_disc_clone(disc));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
/*
|
|
77
|
+
* call-seq:
|
|
78
|
+
* add_track(CDDB_Track)
|
|
79
|
+
*
|
|
80
|
+
* Adds a clone of a CDDB_Track object to the object
|
|
81
|
+
*
|
|
82
|
+
*/
|
|
83
|
+
static VALUE crb_cddb_disc_add_track(VALUE self,VALUE rtrack) {
|
|
84
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
85
|
+
cddb_track_t *track=get_cddb_track_from_Value(rtrack);
|
|
86
|
+
cddb_disc_add_track(disc,cddb_track_clone(track));
|
|
87
|
+
return self;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/*
|
|
91
|
+
* call-seq:
|
|
92
|
+
* get_track(number) -> CDDB_Track
|
|
93
|
+
*
|
|
94
|
+
* Gets the specified track (not a clone)
|
|
95
|
+
* since it was already cloned when adding
|
|
96
|
+
*
|
|
97
|
+
*/
|
|
98
|
+
static VALUE crb_cddb_disc_get_track(VALUE self,VALUE track_no) {
|
|
99
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
100
|
+
cddb_track_t *track=cddb_disc_get_track(disc,NUM2INT(track_no));
|
|
101
|
+
return _makeValueFrom_cddb_track_t(track);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/*
|
|
105
|
+
* call-seq:
|
|
106
|
+
* track_first -> CDDB_Track
|
|
107
|
+
*
|
|
108
|
+
* returns the first track
|
|
109
|
+
*/
|
|
110
|
+
static VALUE crb_cddb_disc_get_track_first(VALUE self) {
|
|
111
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
112
|
+
cddb_track_t *track=cddb_disc_get_track_first(disc);
|
|
113
|
+
return _makeValueFrom_cddb_track_t(track);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/*
|
|
117
|
+
* call-seq:
|
|
118
|
+
* track_next -> CDDB_Track
|
|
119
|
+
*
|
|
120
|
+
* returns the next track or a nil object
|
|
121
|
+
*/
|
|
122
|
+
static VALUE crb_cddb_disc_get_track_next(VALUE self) {
|
|
123
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
124
|
+
cddb_track_t *track=cddb_disc_get_track_next(disc);
|
|
125
|
+
return _makeValueFrom_cddb_track_t(track);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
/*
|
|
130
|
+
* call-seq:
|
|
131
|
+
* disc_id -> number
|
|
132
|
+
*
|
|
133
|
+
* returns the number of the disc
|
|
134
|
+
*/
|
|
135
|
+
static VALUE crb_cddb_disc_get_discid(VALUE self) {
|
|
136
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
137
|
+
return UINT2NUM(cddb_disc_get_discid(disc));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/*
|
|
141
|
+
* call-seq:
|
|
142
|
+
* disc_id= number
|
|
143
|
+
*
|
|
144
|
+
* returns the number of the disc based on other values
|
|
145
|
+
*/
|
|
146
|
+
static VALUE crb_cddb_disc_set_discid(VALUE self,VALUE id) {
|
|
147
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
148
|
+
cddb_disc_set_discid(disc,NUM2UINT(id));
|
|
149
|
+
return self;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
/*
|
|
154
|
+
* call-seq:
|
|
155
|
+
* category_str -> string
|
|
156
|
+
*
|
|
157
|
+
* returns a string that represents the category of the disc
|
|
158
|
+
*/
|
|
159
|
+
static VALUE crb_cddb_disc_get_category_str(VALUE self) {
|
|
160
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
161
|
+
return crb_to_string(cddb_disc_get_category_str(disc));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/*
|
|
165
|
+
* call-seq:
|
|
166
|
+
* category_str= string
|
|
167
|
+
*
|
|
168
|
+
* set category of the disc
|
|
169
|
+
*/
|
|
170
|
+
static VALUE crb_cddb_disc_set_category_str(VALUE self,VALUE cat) {
|
|
171
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
172
|
+
cddb_disc_set_category_str(disc,STR2CSTR(cat));
|
|
173
|
+
return self;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
/*
|
|
178
|
+
* call-seq:
|
|
179
|
+
* genre-> Rb_CDDB::CAT_xxx
|
|
180
|
+
*
|
|
181
|
+
* compare with the CAT_xx constants from Rb_CDDB
|
|
182
|
+
*/
|
|
183
|
+
static VALUE crb_cddb_disc_get_genre(VALUE self) {
|
|
184
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
185
|
+
return crb_to_string(cddb_disc_get_category_str(disc));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/*
|
|
189
|
+
* call-seq:
|
|
190
|
+
* genre= Rb_CDDB::CAT_xxx
|
|
191
|
+
*
|
|
192
|
+
* use the CAT_xx constants from Rb_CDDB
|
|
193
|
+
*/
|
|
194
|
+
static VALUE crb_cddb_disc_set_genre(VALUE self,VALUE gen) {
|
|
195
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
196
|
+
cddb_disc_set_category_str(disc,STR2CSTR(gen));
|
|
197
|
+
return self;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
/*
|
|
202
|
+
* call-seq:
|
|
203
|
+
* length -> number
|
|
204
|
+
*
|
|
205
|
+
* get the length field of the disc in seconds
|
|
206
|
+
*/
|
|
207
|
+
static VALUE crb_cddb_disc_get_length(VALUE self) {
|
|
208
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
209
|
+
return INT2NUM(cddb_disc_get_length(disc));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/*
|
|
213
|
+
* call-seq:
|
|
214
|
+
* length= number
|
|
215
|
+
*
|
|
216
|
+
* set the length field of the disc in seconds
|
|
217
|
+
*
|
|
218
|
+
*/
|
|
219
|
+
static VALUE crb_cddb_disc_set_length(VALUE self,VALUE len) {
|
|
220
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
221
|
+
cddb_disc_set_length(disc,NUM2INT(len));
|
|
222
|
+
return self;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
/*
|
|
227
|
+
* call-seq:
|
|
228
|
+
* length_by_offset= number
|
|
229
|
+
*
|
|
230
|
+
* set the length field of the disc in frames
|
|
231
|
+
* to get this with rbcdio use the frameoffset (lba)
|
|
232
|
+
* of the leadout
|
|
233
|
+
*/
|
|
234
|
+
static VALUE crb_cddb_disc_set_length_by_offset(VALUE self,VALUE len) {
|
|
235
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
236
|
+
cddb_disc_set_length(disc,FRAMES_TO_SECONDS(NUM2INT(len)));
|
|
237
|
+
return self;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/*
|
|
241
|
+
* call-seq:
|
|
242
|
+
* year -> number
|
|
243
|
+
*
|
|
244
|
+
* year of the disc
|
|
245
|
+
*/
|
|
246
|
+
static VALUE crb_cddb_disc_get_year(VALUE self) {
|
|
247
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
248
|
+
return INT2NUM(cddb_disc_get_year(disc));
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/*
|
|
252
|
+
* call-seq:
|
|
253
|
+
* year= number
|
|
254
|
+
*
|
|
255
|
+
* sets the year
|
|
256
|
+
*/
|
|
257
|
+
static VALUE crb_cddb_disc_set_year(VALUE self,VALUE year) {
|
|
258
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
259
|
+
cddb_disc_set_year(disc,NUM2INT(year));
|
|
260
|
+
return self;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/*
|
|
264
|
+
* call-seq:
|
|
265
|
+
* track_count -> number
|
|
266
|
+
* the number of tracks
|
|
267
|
+
*/
|
|
268
|
+
static VALUE crb_cddb_disc_get_track_count(VALUE self) {
|
|
269
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
270
|
+
return INT2NUM(cddb_disc_get_track_count(disc));
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
/*
|
|
275
|
+
* call-seq:
|
|
276
|
+
* title -> string
|
|
277
|
+
*
|
|
278
|
+
* get the title of the disc
|
|
279
|
+
*/
|
|
280
|
+
static VALUE crb_cddb_disc_get_title(VALUE self) {
|
|
281
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
282
|
+
return crb_to_string(cddb_disc_get_title(disc));
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/*
|
|
286
|
+
* call-seq:
|
|
287
|
+
* title= string
|
|
288
|
+
*
|
|
289
|
+
* set the title of the disc
|
|
290
|
+
*/
|
|
291
|
+
static VALUE crb_cddb_disc_set_title(VALUE self,VALUE title) {
|
|
292
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
293
|
+
cddb_disc_set_title(disc,STR2CSTR(title));
|
|
294
|
+
return self;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
/*
|
|
299
|
+
* call-seq:
|
|
300
|
+
* artist -> string
|
|
301
|
+
* get the artist of the disc
|
|
302
|
+
*
|
|
303
|
+
*/
|
|
304
|
+
|
|
305
|
+
static VALUE crb_cddb_disc_get_artist(VALUE self) {
|
|
306
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
307
|
+
return crb_to_string(cddb_disc_get_artist(disc));
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/*
|
|
311
|
+
* call-seq:
|
|
312
|
+
* artist= string
|
|
313
|
+
* set the artist of the disc (tracks can have a different one)
|
|
314
|
+
*/
|
|
315
|
+
static VALUE crb_cddb_disc_set_artist(VALUE self,VALUE artist) {
|
|
316
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
317
|
+
cddb_disc_set_artist(disc,STR2CSTR(artist));
|
|
318
|
+
return self;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/*
|
|
322
|
+
* call-seq:
|
|
323
|
+
* ext_data -> string
|
|
324
|
+
* get the extra data of the disc
|
|
325
|
+
*/
|
|
326
|
+
static VALUE crb_cddb_disc_get_ext_data(VALUE self) {
|
|
327
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
328
|
+
return crb_to_string(cddb_disc_get_ext_data(disc));
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/*
|
|
332
|
+
* call-seq:
|
|
333
|
+
* ext= string
|
|
334
|
+
* set the extra data the disc
|
|
335
|
+
*/
|
|
336
|
+
static VALUE crb_cddb_disc_set_ext_data(VALUE self,VALUE ext_data) {
|
|
337
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
338
|
+
cddb_disc_set_ext_data(disc,STR2CSTR(ext_data));
|
|
339
|
+
return self;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
/*
|
|
344
|
+
* call-seq:
|
|
345
|
+
* calc_discid -> number
|
|
346
|
+
* calculate the discid and return this value
|
|
347
|
+
*/
|
|
348
|
+
static VALUE crb_cddb_calc_discid(VALUE self) {
|
|
349
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
350
|
+
cddb_disc_calc_discid(disc);
|
|
351
|
+
return UINT2NUM(cddb_disc_get_discid(disc));
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/*
|
|
355
|
+
* call-seq:
|
|
356
|
+
* print
|
|
357
|
+
*
|
|
358
|
+
* a debug method from the libcddb, it dumps the content
|
|
359
|
+
* to the STDOUT for a quick inspection, the to_hash method
|
|
360
|
+
* will be more useful in most cases
|
|
361
|
+
*/
|
|
362
|
+
static VALUE crb_cddb_print(VALUE self) {
|
|
363
|
+
cddb_disc_t *disc=get_cddb_disc_from_Value(self);
|
|
364
|
+
cddb_disc_print(disc);
|
|
365
|
+
return self;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
/*
|
|
370
|
+
* call-seq:
|
|
371
|
+
* to_hash -> Hash
|
|
372
|
+
*
|
|
373
|
+
* Gets all the fields together as a ruby Hash
|
|
374
|
+
*
|
|
375
|
+
* def to_hash
|
|
376
|
+
* return {
|
|
377
|
+
* 'disc_id' => self.disc_id,
|
|
378
|
+
* 'title' => self.title,
|
|
379
|
+
* 'artist' => self.artist,
|
|
380
|
+
* 'category_str' => self.category_str,
|
|
381
|
+
* 'genre' => self.genre,
|
|
382
|
+
* 'length' => self.length,
|
|
383
|
+
* 'year' => self.year,
|
|
384
|
+
* 'ext_data' => self.ext_data,
|
|
385
|
+
* 'track_count'=> self.track_count,
|
|
386
|
+
* }
|
|
387
|
+
* end
|
|
388
|
+
*
|
|
389
|
+
*/
|
|
390
|
+
static VALUE crb_cddb_disc_to_hash(VALUE self) {
|
|
391
|
+
VALUE hash=rb_hash_new();
|
|
392
|
+
|
|
393
|
+
rb_hash_aset(hash, rb_str_new2("disc_id"),
|
|
394
|
+
crb_cddb_disc_get_discid(self));
|
|
395
|
+
|
|
396
|
+
rb_hash_aset(hash, rb_str_new2("title"),
|
|
397
|
+
crb_cddb_disc_get_title(self));
|
|
398
|
+
|
|
399
|
+
rb_hash_aset(hash, rb_str_new2("artist"),
|
|
400
|
+
crb_cddb_disc_get_artist(self));
|
|
401
|
+
|
|
402
|
+
rb_hash_aset(hash, rb_str_new2("category_str"),
|
|
403
|
+
crb_cddb_disc_get_category_str(self));
|
|
404
|
+
|
|
405
|
+
rb_hash_aset(hash, rb_str_new2("genre"),
|
|
406
|
+
crb_cddb_disc_get_genre(self));
|
|
407
|
+
|
|
408
|
+
rb_hash_aset(hash, rb_str_new2("length"),
|
|
409
|
+
crb_cddb_disc_get_length(self));
|
|
410
|
+
|
|
411
|
+
rb_hash_aset(hash, rb_str_new2("year"),
|
|
412
|
+
crb_cddb_disc_get_year(self));
|
|
413
|
+
|
|
414
|
+
rb_hash_aset(hash, rb_str_new2("ext_data"),
|
|
415
|
+
crb_cddb_disc_get_ext_data(self));
|
|
416
|
+
|
|
417
|
+
rb_hash_aset(hash, rb_str_new2("track_count"),
|
|
418
|
+
crb_cddb_disc_get_track_count(self));
|
|
419
|
+
|
|
420
|
+
return hash;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
/*
|
|
426
|
+
* The copy from will copy all the content from another CDDB_Disc
|
|
427
|
+
* object
|
|
428
|
+
*/
|
|
429
|
+
static VALUE crb_cddb_disc_copy_from(VALUE self,VALUE source) {
|
|
430
|
+
cddb_disc_t *dst=get_cddb_disc_from_Value(self);
|
|
431
|
+
cddb_disc_t *src=get_cddb_disc_from_Value(source);
|
|
432
|
+
cddb_disc_copy(dst,src);
|
|
433
|
+
return self;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
/*
|
|
442
|
+
* Class +CDDB_Disc+ represent a disc and can contain
|
|
443
|
+
* +CDDB_Track+ object
|
|
444
|
+
*/
|
|
445
|
+
|
|
446
|
+
void init_cddb_disc() {
|
|
447
|
+
cddb_disc_rb=rb_define_class("CDDB_Disc",rb_cObject);
|
|
448
|
+
rb_define_alloc_func(cddb_disc_rb,crb_disc_alloc);
|
|
449
|
+
rb_define_method(cddb_disc_rb,"clone",
|
|
450
|
+
crb_cddb_disc_clone,1);
|
|
451
|
+
rb_define_method(cddb_disc_rb,"add_track",
|
|
452
|
+
crb_cddb_disc_add_track,1);
|
|
453
|
+
rb_define_method(cddb_disc_rb,"track",
|
|
454
|
+
crb_cddb_disc_get_track,1);
|
|
455
|
+
rb_define_method(cddb_disc_rb,"track_first",
|
|
456
|
+
crb_cddb_disc_get_track_first,0);
|
|
457
|
+
rb_define_method(cddb_disc_rb,"track_next",
|
|
458
|
+
crb_cddb_disc_get_track_next,0);
|
|
459
|
+
rb_define_method(cddb_disc_rb,"discid",
|
|
460
|
+
crb_cddb_disc_get_discid,0);
|
|
461
|
+
rb_define_method(cddb_disc_rb,"discid=",
|
|
462
|
+
crb_cddb_disc_set_discid,1);
|
|
463
|
+
rb_define_method(cddb_disc_rb,"category_str",
|
|
464
|
+
crb_cddb_disc_get_category_str,0);
|
|
465
|
+
rb_define_method(cddb_disc_rb,"category_str=",
|
|
466
|
+
crb_cddb_disc_set_category_str,1);
|
|
467
|
+
rb_define_method(cddb_disc_rb,"genre",
|
|
468
|
+
crb_cddb_disc_get_genre,0);
|
|
469
|
+
rb_define_method(cddb_disc_rb,"genre=",
|
|
470
|
+
crb_cddb_disc_set_genre,1);
|
|
471
|
+
rb_define_method(cddb_disc_rb,"length",
|
|
472
|
+
crb_cddb_disc_get_length,0);
|
|
473
|
+
rb_define_method(cddb_disc_rb,"length=",
|
|
474
|
+
crb_cddb_disc_set_length,1);
|
|
475
|
+
rb_define_method(cddb_disc_rb,"last_frame_offset=",
|
|
476
|
+
crb_cddb_disc_set_length_by_offset,1);
|
|
477
|
+
rb_define_method(cddb_disc_rb,"year",
|
|
478
|
+
crb_cddb_disc_get_year,0);
|
|
479
|
+
rb_define_method(cddb_disc_rb,"year=",
|
|
480
|
+
crb_cddb_disc_set_year,1);
|
|
481
|
+
rb_define_method(cddb_disc_rb,"track_count" ,
|
|
482
|
+
crb_cddb_disc_get_track_count,0);
|
|
483
|
+
rb_define_method(cddb_disc_rb,"title",
|
|
484
|
+
crb_cddb_disc_get_title,0);
|
|
485
|
+
rb_define_method(cddb_disc_rb,"title=",
|
|
486
|
+
crb_cddb_disc_set_title,1);
|
|
487
|
+
rb_define_method(cddb_disc_rb,"ext_data" ,
|
|
488
|
+
crb_cddb_disc_get_ext_data,0);
|
|
489
|
+
rb_define_method(cddb_disc_rb,"ext_data=", crb_cddb_disc_set_ext_data,1);
|
|
490
|
+
rb_define_method(cddb_disc_rb,"copy_from", crb_cddb_disc_copy_from,1);
|
|
491
|
+
rb_define_method(cddb_disc_rb,"calc_discid",
|
|
492
|
+
crb_cddb_calc_discid,0);
|
|
493
|
+
rb_define_method(cddb_disc_rb,"to_hash",
|
|
494
|
+
crb_cddb_disc_to_hash,0);
|
|
495
|
+
rb_define_method(cddb_disc_rb,"print",
|
|
496
|
+
crb_cddb_print,0);
|
|
497
|
+
}
|
data/ext/cddb_disc.h
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#ifndef DISC_HEADER
|
|
2
|
+
#define DISC_HEADER
|
|
3
|
+
|
|
4
|
+
#include<ruby.h>
|
|
5
|
+
#include<cddb/cddb.h>
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
extern VALUE cddb_disc_rbclass;
|
|
9
|
+
|
|
10
|
+
cddb_disc_t *get_cddb_disc_from_Value(VALUE self);
|
|
11
|
+
|
|
12
|
+
VALUE makeValueFrom_cddb_disc_t(cddb_disc_t *disc);
|
|
13
|
+
|
|
14
|
+
void init_cddb_disc();
|
|
15
|
+
|
|
16
|
+
#endif
|
data/ext/cddb_mod.c
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
#include<ruby.h>
|
|
2
|
+
#include<cddb/cddb.h>
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
VALUE cddb_mod_rb;
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* call-seq:
|
|
9
|
+
* Rb_CDDB.log_level=
|
|
10
|
+
*
|
|
11
|
+
* sets the log level to one of the Rb_CDDB::LOG_xxx values
|
|
12
|
+
*/
|
|
13
|
+
static VALUE crb_cddb_set_log_level(VALUE self,VALUE serverport) {
|
|
14
|
+
cddb_log_set_level(NUM2INT(serverport));
|
|
15
|
+
return self;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
* call-seq:
|
|
20
|
+
* frame2sec(number) -> number
|
|
21
|
+
*
|
|
22
|
+
* convert the number of frames to seconds
|
|
23
|
+
*/
|
|
24
|
+
static VALUE crb_cddb_frame2sec(VALUE self,VALUE frames) {
|
|
25
|
+
return INT2NUM(FRAMES_TO_SECONDS(NUM2INT(frames)));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
* call-seq:
|
|
30
|
+
* sec2frame(number) -> number
|
|
31
|
+
*
|
|
32
|
+
* convert a number of seconds to a number of frames
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
static VALUE crb_cddb_sec2frame(VALUE self,VALUE frames) {
|
|
36
|
+
return INT2NUM(TO_SECONDS_TO_FRAMES(NUM2INT(frames)));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/*
|
|
40
|
+
* call-seq:
|
|
41
|
+
* searchcat(number) -> number
|
|
42
|
+
*
|
|
43
|
+
* convert a number (Rb_CDDB::CAT_xxx values) to a value
|
|
44
|
+
* which can be ORed for the CDDB_Connection#search_categories= method
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
static VALUE crb_cddb_searchcat(VALUE self,VALUE cat) {
|
|
48
|
+
return INT2NUM(SEARCHCAT(NUM2INT(cat)));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
/*
|
|
54
|
+
* +Rb_CDDB+ contrains several constants and a few methods
|
|
55
|
+
* that control the entire libcddb like for instance logging
|
|
56
|
+
*
|
|
57
|
+
* the genres can be set with these constants
|
|
58
|
+
* - Rb_CDDB::CAT_DATA
|
|
59
|
+
* - Rb_CDDB::CAT_FOLK
|
|
60
|
+
* - Rb_CDDB::CAT_JAZZ
|
|
61
|
+
* - Rb_CDDB::CAT_MISC
|
|
62
|
+
* - Rb_CDDB::CAT_ROCK
|
|
63
|
+
* - Rb_CDDB::CAT_COUNTRY
|
|
64
|
+
* - Rb_CDDB::CAT_BLUES
|
|
65
|
+
* - Rb_CDDB::CAT_NEWAGE
|
|
66
|
+
* - Rb_CDDB::CAT_REGGAE
|
|
67
|
+
* - Rb_CDDB::CAT_CLASSICAL
|
|
68
|
+
* - Rb_CDDB::CAT_SOUNDTRACK
|
|
69
|
+
* - Rb_CDDB::CAT_INVALID
|
|
70
|
+
* - Rb_CDDB::CAT_LAST
|
|
71
|
+
*
|
|
72
|
+
* These values can be use to specify the log_level
|
|
73
|
+
* - Rb_CDDB::LOG_DEBUG
|
|
74
|
+
* - Rb_CDDB::LOG_INFO
|
|
75
|
+
* - Rb_CDDB::LOG_WARN
|
|
76
|
+
* - Rb_CDDB::LOG_ERROR
|
|
77
|
+
* - Rb_CDDB::LOG_CRITICAL
|
|
78
|
+
* - Rb_CDDB::LOG_NONE
|
|
79
|
+
*
|
|
80
|
+
* The search values can be used
|
|
81
|
+
* for CDDB_Connection#search_fields=
|
|
82
|
+
* - Rb_CDDB::SEARCH_NONE
|
|
83
|
+
* - Rb_CDDB::SEARCH_ARTIST
|
|
84
|
+
* - Rb_CDDB::SEARCH_TITLE
|
|
85
|
+
* - Rb_CDDB::SEARCH_TRACK
|
|
86
|
+
* - Rb_CDDB::SEARCH_OTHER
|
|
87
|
+
* - Rb_CDDB::SEARCH_ALL
|
|
88
|
+
*
|
|
89
|
+
*/
|
|
90
|
+
void init_cddb_mod() {
|
|
91
|
+
cddb_mod_rb=rb_define_module("Rb_CDDB");
|
|
92
|
+
|
|
93
|
+
rb_define_module_function(cddb_mod_rb, "log_level=",
|
|
94
|
+
crb_cddb_set_log_level,1);
|
|
95
|
+
rb_define_const(cddb_mod_rb,"CAT_DATA" ,INT2NUM(CDDB_CAT_DATA));
|
|
96
|
+
rb_define_const(cddb_mod_rb,"CAT_FOLK" ,INT2NUM(CDDB_CAT_FOLK));
|
|
97
|
+
rb_define_const(cddb_mod_rb,"CAT_JAZZ" ,INT2NUM(CDDB_CAT_JAZZ));
|
|
98
|
+
rb_define_const(cddb_mod_rb,"CAT_MISC" ,INT2NUM(CDDB_CAT_MISC));
|
|
99
|
+
rb_define_const(cddb_mod_rb,"CAT_ROCK" ,INT2NUM(CDDB_CAT_ROCK));
|
|
100
|
+
rb_define_const(cddb_mod_rb,"CAT_COUNTRY" ,INT2NUM(CDDB_CAT_COUNTRY));
|
|
101
|
+
rb_define_const(cddb_mod_rb,"CAT_BLUES" ,INT2NUM(CDDB_CAT_BLUES));
|
|
102
|
+
rb_define_const(cddb_mod_rb,"CAT_NEWAGE" ,INT2NUM(CDDB_CAT_NEWAGE));
|
|
103
|
+
rb_define_const(cddb_mod_rb,"CAT_REGGAE" ,INT2NUM(CDDB_CAT_REGGAE));
|
|
104
|
+
rb_define_const(cddb_mod_rb,"CAT_CLASSICAL" ,INT2NUM(CDDB_CAT_CLASSICAL));
|
|
105
|
+
rb_define_const(cddb_mod_rb,"CAT_SOUNDTRACK" ,INT2NUM(CDDB_CAT_SOUNDTRACK));
|
|
106
|
+
rb_define_const(cddb_mod_rb,"CAT_INVALID" ,INT2NUM(CDDB_CAT_INVALID));
|
|
107
|
+
rb_define_const(cddb_mod_rb,"CAT_LAST" ,INT2NUM(CDDB_CAT_LAST));
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
rb_define_const(cddb_mod_rb,"LOG_DEBUG" ,INT2NUM(CDDB_LOG_DEBUG));
|
|
111
|
+
rb_define_const(cddb_mod_rb,"LOG_INFO" ,INT2NUM(CDDB_LOG_INFO));
|
|
112
|
+
rb_define_const(cddb_mod_rb,"LOG_WARN" ,INT2NUM(CDDB_LOG_WARN));
|
|
113
|
+
rb_define_const(cddb_mod_rb,"LOG_ERROR" ,INT2NUM(CDDB_LOG_ERROR));
|
|
114
|
+
rb_define_const(cddb_mod_rb,"LOG_CRITICAL" ,INT2NUM(CDDB_LOG_CRITICAL));
|
|
115
|
+
rb_define_const(cddb_mod_rb,"LOG_NONE" ,INT2NUM(CDDB_LOG_NONE));
|
|
116
|
+
|
|
117
|
+
rb_define_const(cddb_mod_rb,"CACHE_OFF" ,INT2NUM(CACHE_OFF));
|
|
118
|
+
rb_define_const(cddb_mod_rb,"CACHE_ON" ,INT2NUM(CACHE_ON));
|
|
119
|
+
rb_define_const(cddb_mod_rb,"CACHE_ONLY" ,INT2NUM(CACHE_ONLY));
|
|
120
|
+
|
|
121
|
+
rb_define_const(cddb_mod_rb,"SEARCH_NONE" ,INT2NUM(SEARCH_NONE));
|
|
122
|
+
rb_define_const(cddb_mod_rb,"SEARCH_ARTIST" ,INT2NUM(SEARCH_ARTIST));
|
|
123
|
+
rb_define_const(cddb_mod_rb,"SEARCH_TITLE" ,INT2NUM(SEARCH_TITLE));
|
|
124
|
+
rb_define_const(cddb_mod_rb,"SEARCH_TRACK" ,INT2NUM(SEARCH_TRACK));
|
|
125
|
+
rb_define_const(cddb_mod_rb,"SEARCH_OTHER" ,INT2NUM(SEARCH_OTHER));
|
|
126
|
+
rb_define_const(cddb_mod_rb,"SEARCH_ALL" ,INT2NUM(SEARCH_ALL));
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
rb_define_global_function("frame2sec",crb_cddb_frame2sec,1);
|
|
131
|
+
rb_define_global_function("sec2frame",crb_cddb_sec2frame,1);
|
|
132
|
+
rb_define_global_function("searchcat",crb_cddb_searchcat,1);
|
|
133
|
+
|
|
134
|
+
}
|
data/ext/cddb_mod.h
ADDED
data/ext/cddb_rb.c
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#include<ruby.h>
|
|
2
|
+
|
|
3
|
+
#include "cddb_mod.h"
|
|
4
|
+
#include "cddb_conn.h"
|
|
5
|
+
#include "cddb_disc.h"
|
|
6
|
+
#include "cddb_track.h"
|
|
7
|
+
#include "cddb_mod.h"
|
|
8
|
+
|
|
9
|
+
void Init_rbcddb() {
|
|
10
|
+
init_cddb_conn();
|
|
11
|
+
init_cddb_disc();
|
|
12
|
+
init_cddb_track();
|
|
13
|
+
init_cddb_mod();
|
|
14
|
+
|
|
15
|
+
}
|