anchor.diff:  (defmethod stream-playback-stop ((rec stream-record))
     (bt:release-lock (vacancy-lock (car (rcursor rec)))))
   
  -(defclass mjpeg-stream-record (stream-record)
  -  ((jpeg-descriptor :accessor jpeg-descriptor :initform (cl-jpeg::make-descriptor))))
  +(defclass video-stream-record (stream-record)
  +  ())
   
  -(defmethod shared-initialize :after ((rec mjpeg-stream-record) slots &key &allow-other-keys)
  -  (declare (ignorable slots))
  -  (flexi-streams:with-input-from-sequence (is +avi-dht+)
  -    (setf (jpeg::descriptor-byte-reader (jpeg-descriptor rec)) #'(lambda () (read-byte is)))
  -    (jpeg:read-dht (jpeg-descriptor rec)))
  -  (setf (buffer rec) (make-array (suggested-buffer-size rec) :element-type '(unsigned-byte 8))
  -	(jpeg:descriptor-source-cache (jpeg-descriptor rec)) (buffer rec))
  -  (initialize-ring rec (max 5 (* 1 (floor (rate rec) (scale rec)))) ;at least 5 chunks to prevent cursor deadlocks
  -		   (* (height (avi rec)) (width (avi rec)) 3) 'cl-jpeg::uint8))
  -
  -(defclass audio-stream-record (stream-record)
  -  ((compression-code :accessor compression-code)
  -   (number-of-channels :accessor number-of-channels)
  -   (sample-rate :accessor sample-rate)
  -   (average-bytes-per-second :accessor average-bytes-per-second)
  -   (block-align :accessor block-align)
  -   (significant-bits-per-sample :accessor significant-bits-per-sample)
  -   (extra-format-bytes :accessor extra-format-bytes)
  -   (extra-bytes :accessor extra-bytes)))
  -
  -(defmethod shared-initialize :after ((rec audio-stream-record) slots &key &allow-other-keys)
  -  (declare (ignorable slots))
  -  (setf  (buffer rec) (make-array (suggested-buffer-size rec) :element-type '(unsigned-byte 8))))
  -
  -(defmethod read-audio-stream-header ((rec audio-stream-record) stream)
  -  (loop for chunk = (riff:read-riff-chunk stream)
  -     when (string-equal (riff:riff-chunk-id chunk) "strf") do
  -       (flexi-streams:with-input-from-sequence (is (riff:riff-chunk-data chunk))
  -	(setf (compression-code rec) (riff:read-u2 is)
  -	     (number-of-channels rec) (riff:read-u2 is)
  -	     (sample-rate rec) (riff:read-u4 is)
  -	     (average-bytes-per-second rec) (riff:read-u4 is)
  -	     (block-align rec) (riff:read-u2 is)
  -	     (significant-bits-per-sample rec) (riff:read-u2 is))
  -	(debug-log (format nil "Audio stream with sample rate ~D at ~D bits per sample" (sample-rate rec) (significant-bits-per-sample rec)))
  -       (unless (eql (compression-code rec) +pcmi-uncompressed+)
  -	 (setf (extra-format-bytes rec) (riff:read-u2 is)
  -	       (extra-bytes rec) (make-array (extra-format-bytes rec) :element-type (stream-element-type is)))
  -	 (read-sequence (extra-bytes rec) is)))
  -       (return)))
  -
  -(defclass video-stream ()
  -  ((filename :accessor filename :initarg :filename :initform nil)))
  -
  -(defclass avi-mjpeg-stream (video-stream)
  -  ((chunk-decoder :accessor chunk-decoder)
  +(defclass av-container ()
  +  ((filename :accessor filename :initarg :filename :initform nil)
  +   (player-callback :accessor player-callback :initarg :player-callback :initform nil) ;;called once all headers are processed
      (width :accessor width :initarg :width :initform 640)
      (height :accessor height :initarg :height :initform 480)
  -   (padding :accessor padding :initform 0)
  -   (flags :accessor flags)
  -   (nstreams :accessor nstreams)
  -   (player-callback :accessor player-callback :initarg :player-callback :initform nil) ;;called once all headers are processed
      (stream-records :accessor stream-records)
      (finish :accessor finish :initform nil)
      (pause :accessor pause :initform nil)
  
positive.code:   ()
    (:report (lambda (condition stream)
  	     (declare (ignorable condition))
  	     (format stream "Unrecognized AVI file format"))))
  
  (define-condition unsupported-avi-file-format (media-decoder-error)
    ()
    (:report (lambda (condition stream)
  	     (declare (ignorable condition))
  	     (format stream "Unsupported AVI file format"))))
  
  (define-condition malformed-avi-file-format (media-decoder-error)
    ()
    (:report (lambda (condition stream)
  	     (declare (ignorable condition))
  	     (format stream "Malformed AVI file format"))))
  
  (defclass chunk ()
    ((lock :reader vacancy-lock :initform (bt:make-lock "vacancy"))
     (frame :accessor frame :initarg :frame)))
  
  (defclass stream-record ()
    ((fcc-type :accessor fcc-type)
     (fcc-handler :accessor fcc-handler)
     (flags :accessor flags)
     (priority :accessor priority)
     (language :accessor language)
     (initial-frames :accessor initial-frames)
     (scale :accessor scale)
     (rate :accessor rate)
     (start :accessor start)
     (stream-length :accessor stream-length)
     (suggested-buffer-size :accessor suggested-buffer-size)
     (quality :accessor quality)
     (sample-size :accessor sample-size)
     (frame :accessor frame)
     (index :accessor index)
     (chunk-queue :accessor chunk-queue)
     (rcursor :accessor rcursor)
     (wcursor :accessor wcursor)
     (final :accessor final :initform nil)
     (buffer :accessor buffer :type '(unsigned-byte 8))
     (avi :accessor avi :initarg :avi)))
  
  (defmethod initialize-ring ((rec stream-record) ring-length frame-size element-type)
    (setf (chunk-queue rec) (make-list ring-length))
  
negative.code: (in-package #:cl-video)
  
  (setf *print-circle* t)
  
  (defvar *debug* nil)
  
  