Explorar el Código

added picture/cover-art support

Mark VandenBrink hace 12 años
padre
commit
7affda07f8
Se han modificado 4 ficheros con 30 adiciones y 5 borrados
  1. 14 1
      abstract-tag.lisp
  2. 10 0
      id3-frame.lisp
  3. 1 1
      mp4-atom.lisp
  4. 5 3
      packages.lisp

+ 14 - 1
abstract-tag.lisp

@@ -56,7 +56,15 @@
                               (push f found-frames))))
     (nreverse found-frames)))
 
-;;; The following probably should be macro-ized in the future---lots of cut/paste going on...
+(defmethod cover ((me mp3-file-stream))
+  (declare #.utils:*standard-optimize-settings*)
+  (let ((pictures)
+        (frames (get-frames me '("PIC" "APIC"))))
+    (when frames
+      (dolist (f frames)
+        (push (picture-info f) pictures)))
+    pictures))
+
 (defmethod album ((me mp3-file-stream))
   (declare #.utils:*standard-optimize-settings*)
   (let ((frames (get-frames me '("TAL" "TALB"))))
@@ -252,6 +260,7 @@
             (compilation (compilation me))
             (composer (composer me))
             (copyright (copyright me))
+            (cover (cover me))
             (disk (disk me))
             (encoder (encoder me))
             (genre (genre me))
@@ -272,6 +281,7 @@
         (when compilation (format t "~4tcompilation: ~a~%" compilation))
         (when composer (format t "~4tcomposer: ~a~%" composer))
         (when copyright (format t "~4tcopyright: ~a~%" copyright))
+        (when cover (format t "~4tcover: ~a~%" cover))
         (when disk (format t "~4tdisk: ~a~%" disk))
         (when encoder (format t "~4tencoder: ~a~%" encoder))
         (when genre (format t "~4tgenre: ~a~%" genre))
@@ -290,6 +300,7 @@
 (defmethod comment      ((me mp4-file-stream)) (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-comment+))
 (defmethod composer     ((me mp4-file-stream)) (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-composer+))
 (defmethod copyright    ((me mp4-file-stream)) (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-copyright+))
+(defmethod cover        ((me mp4-file-stream)) (length (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-cover-art+)))
 (defmethod year         ((me mp4-file-stream)) (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-year+))
 (defmethod encoder      ((me mp4-file-stream)) (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-encoder+))
 (defmethod groups       ((me mp4-file-stream)) (mp4-atom:tag-get-value (mp4-atoms me) mp4-atom:+itunes-groups+))
@@ -330,6 +341,7 @@
             (compilation (compilation me))
             (composer (composer me))
             (copyright (copyright me))
+            (cover (cover me))
             (disk (disk me))
             (encoder (encoder me))
             (genre (genre me))
@@ -350,6 +362,7 @@
         (format t "~4tcompilation: ~[no~;yes;unknown~]~%" (if compilation compilation 2))
         (when composer (format t "~4tcomposer: ~a~%" composer))
         (when copyright (format t "~4tcopyright: ~a~%" copyright))
+        (when cover (format t "~4tcover: Size: :~d~%" cover))
         (when disk (format t "~4tdisk: ~a~%" disk))
         (when encoder (format t "~4tencoder: ~a~%" encoder))
         (when genre (format t "~4tgenre: ~a~%" genre))

+ 10 - 0
id3-frame.lisp

@@ -457,6 +457,11 @@ NB: 2.3 and 2.4 extended flags are different..."
     (format stream "frame-pic: ~a,  encoding ~d, img-format type: <~a>, picture type: ~d (~a), description <~a>, data: ~a"
             (vpprint-frame-header me) encoding img-format type (get-picture-type type) desc (printable-array data))))
 
+(defmethod picture-info ((me frame-pic))
+  "Used by ABSTRACT-TAG interface to report data about V2.2 cover art"
+  (with-slots (encoding img-format type desc data) me
+    (format nil "Size: ~:d" (length data))))
+
 ;; Version 2, 3, or 4 generic text-info frames
 ;; Text information identifier  "T00" - "TZZ", excluding "TXX", or "T000 - TZZZ", excluding "TXXX"
 ;; Text encoding                $xx
@@ -718,6 +723,11 @@ NB: 2.3 and 2.4 extended flags are different..."
     (format stream "frame-apic: ~a, encoding ~d, mime type: ~a, picture type: ~d (~a), description <~a>, data: ~a"
             (vpprint-frame-header me) encoding mime type (get-picture-type type) desc (printable-array data))))
 
+(defmethod picture-info ((me frame-apic))
+  "Used by ABSTRACT-TAG interface to report data about V2.3/4 cover art"
+  (with-slots (encoding mime type desc data) me
+    (format nil "Size: ~:d" (length data))))
+
 ;;; V23/V24 COMM frames
 ;;; <Header for 'Comment', ID: "COMM">
 ;;; Text encoding           $xx

+ 1 - 1
mp4-atom.lisp

@@ -82,7 +82,7 @@
 (defconstant +itunes-track-n+        (mk-mp4-atom-type #\t  #\r #\k #\n) "octet: yet another track number")
 (defconstant +itunes-writer+         (mk-mp4-atom-type #xa9 #\w #\r #\t) "text: who wrote the song")
 (defconstant +itunes-year+           (mk-mp4-atom-type #xa9 #\d #\a #\y) "text: year album was released")
-(defconstant +itunes-ilst-data+      (mk-mp4-atom-type #\d #\a #\t #\a) "Carries the actual data under an ilst atom")
+(defconstant +itunes-ilst-data+      (mk-mp4-atom-type #\d #\a #\t #\a)  "carries the actual data under an ilst atom")
 
 (defconstant +m4-ftyp+               (mk-mp4-atom-type #\f #\t #\y #\p) "This should be the first atom type found in file")
 

+ 5 - 3
packages.lisp

@@ -72,9 +72,11 @@
   (:use #:common-lisp #:audio-streams #:utils))
 
 (defpackage #:id3-frame
-  (:export #:id3-frame #:find-id3-frames #:id3-frame-condition #:vpprint #:header #:get-frame-info #:is-valid-mp3-file
-           #:encoding #:lang #:desc #:val #:comment #:artist #:album #:year #:comment #:year
-           #:map-id3-frames #:frames #:year #:title #:genre #:id #:v21-tag-header #:info #:version)
+  (:export #:id3-frame #:find-id3-frames #:id3-frame-condition #:vpprint #:header
+           #:get-frame-info #:is-valid-mp3-file #:encoding #:lang #:desc #:val
+           #:comment #:artist #:album #:year #:comment #:year #:map-id3-frames
+           #:frames #:year #:title #:genre #:id #:v21-tag-header #:info #:version
+           #:picture-info)
   (:use #:common-lisp #:audio-streams #:utils #:iso-639-2))
 
 ;; (defpackage #:mp3-tag