-
Notifications
You must be signed in to change notification settings - Fork 0
/
scratch.lisp
211 lines (143 loc) · 6.35 KB
/
scratch.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
(eval-when (:compile-toplevel :load-toplevel :execute)
(asdf:oos 'asdf:load-op 'iso-media))
(cl:defpackage #:iso-media-scratch
(:use #:cl #:iso-media))
(cl:in-package #:iso-media-scratch)
(defparameter *test-file*
(asdf:component-pathname
(reduce #'asdf:find-component
(list nil "iso-media" "test" "audio-test.mp4"))))
(let ((file *test-file*))
(read-iso-media-file file))
(let ((file *test-file*))
(find-child (read-iso-media-file file) "moov"))
(let ((file *test-file*))
(children
(find-child (read-iso-media-file file) "moov")))
(let ((file *test-file*))
(find-child (find-child (read-iso-media-file file) "moov") "mvhd"))
(let ((file *test-file*))
(find-child (find-child (read-iso-media-file file) "moov") "trak"))
(let ((file *test-file*))
(reduce #'find-child
(list
(read-iso-media-file file)
"moov" "trak" "mdia" "minf" "stbl")))
(let ((file *test-file*))
(children
(reduce #'find-child
(list
(read-iso-media-file file)
"moov" "trak" "mdia" "minf" "stbl" "stsd"))))
(let ((file *test-file*))
(find-child
(find-ancestor
(find-child
(reduce #'find-child
(list
(read-iso-media-file file)
"moov" "trak" "mdia" "minf" "stbl"))
"stsd")
"minf")
"smhd"))
(let ((file *test-file*))
(iso-media::audio-sample-type (read-iso-media-file file)))
#+nil
(defparameter *cc*
(read-iso-media-file
#p"/Users/sly/Music/iTunes/iTunes Music/The Clash/Live At Shea Stadium/02 London Calling \\[Live].m4a"
#+nil #p"/Volumes/iTunes_music/Archive/The Clash/Live_ From Here to Eternity/01 Complete Control.m4a"))
(defparameter *cc* (read-iso-media-file *test-file*))
(find-child (find-child *cc* "moov") "mvhd")
(map 'string #'code-char
(box-data
(reduce #'find-child (list *cc* "moov" "udta" "meta" "ilst" (concatenate 'string iso-media::*copyright-symbol-string* "ART") "data"))))
(let ((file #p"/Volumes/iTunes_music/Archive/The Clash/Live_ From Here to Eternity/01 Complete Control.m4a"))
(with-open-file (stream file :element-type '(unsigned-byte 8))
(iso-media::read-iso-media-stream stream)))
(let ((file *test-file*))
(with-open-file (stream file :element-type '(unsigned-byte 8))
(children
(iso-media::read-iso-media-stream stream))))
(map 'string #'code-char
(data
(reduce #'find-child (list *cc* "moov" "udta" "meta" "ilst" (concatenate 'string iso-media::*copyright-symbol-string* "ART") "data"))))
(reduce #'find-child (list *cc* "moov" "udta" "meta"))
(map 'list (lambda (x)
(box-type x))
(children (find-child *cc* "moov")))
(let ((file #p"/Users/sly/Music/iTunes/iTunes Music/The Clash/Live At Shea Stadium/02 London Calling \\[Live].m4a"))
(with-open-file (stream file :element-type '(unsigned-byte 8))
(iso-media::read-iso-media-stream stream)))
(defparameter *moose* (make-instance 'iso-container :children nil))
(push (make-instance 'iso-media::data-bbox :box-type "bogs"
:size (+ 8 12)
:data (map 'vector #'char-code "012345678901")
:large-size nil
:user-type nil)
(children *moose*))
(defclass foo1 ()
((slot1 :accessor slot1 :initarg :slot1 :initform nil)))
(defclass foo2 ()
((slot2 :accessor slot2 :initarg :slot2 :initform nil)))
(defclass moose (foo1 foo2)
((slot3 :accessor slot3 :initarg :slot3 :initform nil)))
(defgeneric test-it (obj)
(:method-combination progn :most-specific-last))
(defmethod test-it progn ((obj foo1))
(print 'ive-got-a-foo1))
(defmethod test-it progn ((obj foo2))
(print 'ive-got-a-foo2))
(defmethod test-it progn ((obj moose))
(print 'ive-got-a-moose))
(defparameter *moose* (make-instance 'moose))
;;;
(with-open-file (out #p"/tmp/bar" :direction :output :if-exists :supersede)
(write-string "01234567" out))
(binary-data:define-binary-class a ()
((a-slot com.gigamonkeys.binary-data.common-datatypes:iso-8859-1-char)))
(binary-data:define-binary-class b ()
((b-slot com.gigamonkeys.binary-data.common-datatypes:iso-8859-1-char)))
(binary-data:define-binary-class c (a)
((c-slot com.gigamonkeys.binary-data.common-datatypes:iso-8859-1-char)))
(compute-applicable-methods #'binary-data::write-object (list (make-instance 'c) t))
(describe
(make-instance 'c :a-slot #\a :c-slot #\c))
(describe
(with-open-file (in #p"/tmp/bar" :element-type '(unsigned-byte 8))
(binary-data:read-value 'c in)))
(binary-data:define-binary-class d (a b)
((d-slot com.gigamonkeys.binary-data.common-datatypes:iso-8859-1-char)))
(compute-applicable-methods #'binary-data::write-object (list (make-instance 'd) t))
(describe
(with-open-file (in #p"/tmp/bar" :element-type '(unsigned-byte 8))
(binary-data:read-value 'd in)))
(let ((obj (make-instance 'd :a-slot #\0 :b-slot #\1 :d-slot #\2)))
(with-open-file (in #p"/tmp/moose" :element-type '(unsigned-byte 8)
:direction :output :if-exists :supersede)
(binary-data:write-value 'd in obj)))
(binary-data:define-binary-class array-test ()
((foo (iso-media::array
:type 'com.gigamonkeys.binary-data.common-datatypes:iso-8859-1-char
:size 256))))
(let ((obj (make-instance 'array-test)))
(setf (foo obj) (make-array 256 :initial-element #\z))
(with-open-file (in #p"/tmp/moose" :element-type '(unsigned-byte 8)
:direction :output :if-exists :supersede)
(binary-data:write-value 'array-test in obj)))
(iso-media:write-iso-media-file "/tmp/foo3.mp4" *cc*)
(defparameter *pc*
(read-iso-media-file
#P "/Volumes/iTunes_music/Archive/Podcasts/Alan Watts Podcast/Buddhism as Dialogue #1.m4a"))
(defparameter *sc*
(read-iso-media-file
#P"/Volumes/iTunes_music/Archive/1998, August 8, Merriweather Post Pavillion, Columbia, MD/1998, August 8, Merriweather Post Pavillion, Columbia, MD/1-02 Shafty.m4a"))
(cl:defpackage #:iso-media-test (:use #:cl #:iso-media))
(cl:in-package #:iso-media-test)
(defparameter *tears-of-rage*
(iso-media:read-iso-media-file "/Users/sly/projects/iso-media/test/tears-of-rage.m4a"))
(setf (album-artist *tears-of-rage*) "The Band")
(write-iso-media-file "/Users/sly/projects/iso-media/test/tears-of-rage-test.m4a" *tears-of-rage*)
(defparameter *tears-of-rage-test*
(iso-media:read-iso-media-file "/Users/sly/projects/iso-media/test/tears-of-rage-test.m4a"))
(album-artist *tears-of-rage-test*)