mp4-file.lisp 1.1 KB

123456789101112131415161718192021222324252627
  1. ;;; -*- Mode: Lisp; show-trailing-whitespace: t; Base: 10; indent-tabs: nil; Syntax: ANSI-Common-Lisp; Package: MP4-FILE; -*-
  2. ;;; Copyright (c) 2013, Mark VandenBrink. All rights reserved.
  3. (in-package #:mp4-file)
  4. (log5:defcategory cat-log-mp4-file)
  5. (defmacro log-mp4-file (&rest log-stuff) `(log5:log-for (cat-log-mp4-file) ,@log-stuff))
  6. (defclass mp4-file (base-file:base-file)
  7. ((atoms :accessor atoms :initform nil))
  8. (:documentation "Class to access m4a/mp4 files"))
  9. (defun make-mp4-file (filename read-only &key)
  10. "Convenience function to create an instance of MP4-FILE with appropriate init args"
  11. (log5:with-context "make-mp4-file"
  12. (log-mp4-file "opening ~a" filename)
  13. (let (handle)
  14. (handler-case
  15. (progn
  16. (setf handle (make-instance 'mp4-file :filename filename :endian :big-endian :read-only read-only))
  17. (with-slots (atoms) handle
  18. (log-mp4-file "getting atoms")
  19. (setf atoms (mp4-atom:find-mp4-atoms handle))))
  20. (condition (c)
  21. (warn "make-mp4-file got condition: ~a" c)
  22. (when handle (base-file:close-audio-file handle))
  23. (setf handle nil)))
  24. handle)))