(defvar partial-list nil)(defvar record-pcr nil)(defvar record-video nil)(defvar record-vtype nil)(defvar record-audio nil)(defvar record-atype nil)(defvar record-emi nil)(defvar record-dtcp nil)(defvar record-trans-video nil)(defvar record-trans-audio nil)(defvar new-record-pcr nil)(defvar new-record-video nil)(defvar new-record-audio nil)(defvar new-record-emi nil)(defvar new-record-dtcp nil)(defvar new-record-pids nil)(defvar new-transcode-pids nil)(defvar stream-open-valid nil)(defvar stream-valid-index nil)(defvar dtcpip-move-limit nil)(defvar index-program-sequence 0)(defvar content-program-sequence 0)(defvar old-dtcp nil)(defvar content-id nil)(defvar content-drm nil)(defvar req-content-id nil)(defvar stream-dir "/tmp/mnt/ustorage2")(defvar data-dir "/tmp/mnt/ustorage2")(defvar nodirect-mode t)(defvar storage-limit nil)(defvar dtcpip-move-prepare t)(defvar log-trans-request nil)(defvar stop-transcode-req nil)(defvar transcode-ready nil)(defvar encode-ready nil)(defvar force-dr nil)(defvar pmt-ex-retry 0)(defvar req-transcode nil)(defvar with-bg-rec-on-1tuner nil)(defmacro sd-format-p (format)
`(< ,format 4))(defmacro external-transcode-p ()
`(eq (get-transcode-system 'transcode) 'external))(defmacro pro3-transcode-p ()
`(eq (get-transcode-system 'transcode) 'pro3))(defmacro transcode-rec-p ()
`(and req-transcode (not force-dr)))(defmacro mpeg1-video-p (pid)
`(find-if #'(lambda (x)(and (eq ,pid (get-track-pid x))(eq (get-track-stype x) 1)))
video-track))(defun set-storage-config (sdir ddir nodirect limit dubbing-prepare)(write-content nil nil)(stream-reset-content 'stream-out)(setf stream-dir sdir)(setf data-dir ddir)(setf nodirect-mode nodirect)(setf storage-limit limit)(setf dtcpip-move-prepare dubbing-prepare))(defun write-content (x drm)(unless (or x drm)(cancel-timer 'copy-never-timer)(my-device-close 'video-mon)(my-device-close 'audio-mon))(unless (eq req-content-id x)(setf req-content-id x)(setf content-drm drm)(unless x
(setq stop-transcode-req t))(make-event 'request-content)))(defmacro set-partial-pids (sym x)
`(setf (nth 1 (assoc ,sym partial-list)) ,x))(defmacro get-partial-pids (sym)
`(nth 1 (assoc ,sym partial-list)))(defmacro set-partial-cp (sym x)
`(when (assoc ,sym partial-list)(setf (nth 2 (assoc ,sym partial-list)) ,x)))(defmacro get-partial-cp (sym)
`(nth 2 (assoc ,sym partial-list)))(defun init-partial-object (sym)(unless (assoc sym partial-list)(setf partial-list (cons (list sym nil nil) partial-list)))(set-partial-pids sym nil)(set-partial-cp sym nil))(defun request-partial (pcr video vtype audio atype emi dtcp pids transcode)(setf req-transcode transcode)(setf new-record-pcr pcr)(setf new-record-video video)(setf new-record-audio audio)(setf new-record-emi emi)(setf new-record-dtcp dtcp)(setf new-record-pids pids)(setf record-vtype vtype)(setf record-atype atype)(make-event 'record-file-check)(make-event 'encode-restart)(make-event 'transcode-req)(make-event 'partial-req))(defun cancel-partial ()(setf new-record-pids nil)(setf new-transcode-pids nil)(make-event 'transcode-req)(make-event 'partial-req))(defun get-content-duration (content-id)(if content-id
(let ((tm))(my-device-open 'stream-in-check "memin2")(setf tm (stream-content-time 'stream-in-check
:mode nodirect-mode
:stream-dir stream-dir
:data-dir data-dir
:content-id content-id))(my-device-close 'stream-in-check)(if tm
tm
0))
0))(register-device 'partial
"partial"
(get-default-prio)
#'(lambda (sig)(case sig
(LOST
(set-owner 'partial nil))(AVAILABLE
(set-owner 'partial t))(CREATE_SEQUENCE
(when (and dtcpip-move-prepare (stream-write-pmt-file 'stream-out 'partial))(setf index-program-sequence (1+ index-program-sequence))(when (>= (+ content-program-sequence index-program-sequence) 255)(setf dtcpip-move-limit t))))(SCRAMBLE_CHANGE
(make-event 'partial-req)))))(register-device 'stream-out
"stream-out"
(get-default-prio)
#'(lambda (sig)(case sig
(LOST
(set-owner 'stream-out nil))(AVAILABLE
(set-owner 'stream-out t))(STREAM_FINISH
(set-partial-pids 'partial nil)(make-event 'partial-req)(write-bytes msg-pipe SC_RES_STRM_FINISH 4 0))(STREAM_SCR_WRAP
(write-content nil)(write-bytes msg-pipe SC_RES_SCR_WRAP 4 0))(STREAM_TTS_OVF
(write-bytes msg-pipe SC_RES_HDD_OVERFLOW 4 0))(STREAM_HDD_FATAL
(write-content nil)(write-bytes msg-pipe SC_RES_HDD_FATAL 4 0))(STREAM_HDD_HANGUP
(write-content nil)(write-bytes msg-pipe SC_RES_HDD_HANGUP 4 0)))))(register-device 'stream-in-check
"stream-in"
(get-default-prio)
#'(lambda (sig)(case sig
(AVAILABLE
(stream-close 'stream-in-check)))))(register-section 'eit-for-sit
nil)(register-section 'sdt-for-sit
nil)(register-device 'tsport-ex
"tsport"
(get-default-prio)
#'(lambda (sig)))(register-section 'pat-ex
#'(lambda (data)(let ((sec) (ptr) (svcid nil) (pid nil))(setf sec (car data))(when sec
(setf ptr (nthcdr 8 sec))(do ((x 8 (+ x 4)))((or pid (> x (length sec))))(setf svcid (+ (* (first ptr) #x100) (second ptr)))(unless (eq svcid 0)(setf pid (+ (* (logand (third ptr) #x1F) #x100) (fourth ptr))))(setf ptr (nthcdr 4 ptr))))(unless (eq pid (get-section-pid 'pmt-ex))(set-partial-pids 'partial nil)(make-event 'partial-req)(set-section-valid 'pmt-ex nil)(set-section-pid 'pmt-ex pid)(make-event 'pmt-ex-reset))(set-section-valid 'pat-ex (if pid t nil))(make-event 'pat-ex-valid))))(register-section 'pmt-ex
#'(lambda (data)(let ((sec) (ptr) (len) (pids nil) (stype) (pid) (tag) (desc-len) (dtcp nil) (dtcp-cci nil))(setf sec (car data))(when sec
(setf len (+ (* (logand (nth 10 sec) #xF) #x100) (nth 11 sec)))(setq ptr (nthcdr 12 sec))(do ((z 0 (+ z (+ desc-len 2))))((>= z len))(setq tag (nth 0 ptr))(setq desc-len (nth 1 ptr))(setq ptr (nthcdr 2 ptr))(case tag
(#x88
(setq dtcp (list (nth 2 ptr) (nth 3 ptr)))(setq dtcp-cci (logand (nth 2 ptr) #x03))))(setq ptr (nthcdr desc-len ptr)))(when (and (pro3-transcode-p) (not (equal old-dtcp dtcp)))(setq old-dtcp dtcp)(setq new-transcode-pids nil)(make-event 'partial-req))(do ((z 0))((>= 4 (length ptr)))(setf stype (nth 0 ptr))(setq pid (+ (* (logand (nth 1 ptr) #x1F) #x100) (nth 2 ptr)))(setf pids (cons pid pids))(setf len (+ (* (logand (nth 3 ptr) #xF) #x100) (nth 4 ptr)))(setf ptr (nthcdr 5 ptr))(if (pro3-transcode-p)(progn
(case stype
((1 2 #x1b)(setq record-trans-video pid))((3 4 15 #x81)(setq record-trans-audio pid))))(setq record-trans-video record-video)(setq record-trans-audio record-audio))(when (and (external-transcode-p) (eq stype #x1b))(do ((x 0))((>= x len))(when (and (eq (nth x ptr) #x05)(eq (nth (+ x 2) ptr) #x48)(eq (nth (+ x 3) ptr) #x44)(eq (nth (+ x 4) ptr) #x4d)(eq (nth (+ x 5) ptr) #x56))(setf force-dr (sd-format-p (/ (logand (nth (+ x 8) ptr) #xf0) #x10))))(setf x (+ x 2 (nth (+ x 1) ptr)))))(setf ptr (nthcdr len ptr))))(unless (or (pro3-transcode-p)(and (find record-trans-video pids)(find record-trans-audio pids)(transcode-status 'transcode 'pmt-ex)))(setf pids nil))(unless pids
(setf pmt-ex-retry (1+ pmt-ex-retry)))(set-section-valid 'pmt-ex (if (or pids (>= pmt-ex-retry 10)) t nil))(make-event 'pmt-ex-valid)(setf new-transcode-pids (if (transcode-rec-p) (reverse pids) nil))(make-event 'partial-req)(make-event 'transcode-check))))(register-node 'record-file-check
#'(lambda ()(or (and (pro3-transcode-p) (transcode-rec-p))(and (eq new-record-pcr record-pcr) (eq new-record-video record-video)(eq new-record-emi record-emi) (equal new-record-dtcp record-dtcp)(or (not (device-open-p 'partial-enc))(not (device-open-p 'audio))(eq new-record-audio record-audio)))))
#'(lambda ()(setf record-pcr new-record-pcr)(setf record-video new-record-video)(setf record-audio new-record-audio)(setf record-emi new-record-emi)(setf record-dtcp new-record-dtcp)(eval-events (list 'record-file-check)))
#'(lambda ()
nil))(register-node 'transcode-check
#'(lambda ()(transcode-rec-p))
#'(lambda ()(eval-events (list 'transcode-check)))
#'(lambda ()(setf force-dr nil)))(register-node 'transcode
#'(lambda ()(and (get-partial-pids 'partial-ex) (partial-status 'partial-ex) transcode-ready))
#'(lambda ()(if (and (external-transcode-p) (mpeg1-video-p record-video))(progn
(setf force-dr t)(make-event 'partial-req)(make-event 'transcode-check))(set-partial-pids 'partial-ex new-record-pids)(if (get-partial-pids 'partial-ex)(progn
(cp-set 'cp 'partial-ex)(partial-enable 'partial-ex 'tsport)(unless log-trans-request
(setq log-trans-request t)(write-bytes msg-pipe SC_RES_TRANSCODER_INFO 4 (list 0)))(partial-start 'partial-ex
:pat 'pat
:pmt 'pmt
:espids (get-partial-pids 'partial-ex)
:pids nil
:dit nil)(when (or (not (pro3-transcode-p)) (partial-status 'partial-ex))(transcode-start 'transcode
:partial 'partial-ex
:outformat 'TRANSCODE_OUTFORMAT_TTS
:bitrate (get-transcode-bitrate 'transcode)
:profile (get-transcode-profile 'transcode)
:level (get-transcode-level 'transcode)
:encmode (get-transcode-encmode 'transcode)
:pcr record-pcr
:svcid (get-tuning-svcid)
:pmtpid pmt-*pid*
:video record-video
:audio (get-transcode-audio 'transcode)
:pes (get-transcode-pes 'transcode))))(partial-stop 'partial-ex)))(eval-events (list 'transcode-req)))
#'(lambda ()(if (pro3-transcode-p)(when stop-transcode-req
(setq log-trans-request nil)(transcode-stop 'transcode))(setq log-trans-request nil)(transcode-stop 'transcode))(setq stop-transcode-req nil)(partial-stop 'partial-ex)(let ((data nil) (log nil))(setq log (transcode-get-errlog 'transcode))(when log
(do ((x 0 (+ x 2))) ((>= x (length log)))(setq data (cons (+ (* (nth x log) #x100) (nth (+ x 1) log)) data)))(write-bytes msg-pipe SC_RES_TRANSCODER_ERROR 12 (list (reverse data)))))))(register-node 'partial-start
#'(lambda ()(and (get-partial-pids 'partial)(device-source-p 'partial (if (transcode-rec-p) 'tsport-ex 'tsport))(partial-status 'partial)))
#'(lambda ()(set-partial-pids 'partial (if (transcode-rec-p) new-transcode-pids new-record-pids))(when (and dtcpip-move-prepare dtcpip-move-limit)(set-partial-pids 'partial nil))(if (get-partial-pids 'partial)(if (transcode-rec-p)(case (get-transcode-system 'transcode)(pro3
(partial-enable 'partial 'tsport-ex)(partial-start 'partial
:pat 'pat-ex
:pmt 'pmt-ex
:overwrite "pmt-through"
:video-pid record-trans-video
:audio-pid record-trans-audio
:espids (get-partial-pids 'partial)
:pids '(#x1f)))(external
(partial-enable 'partial 'tsport-ex)(partial-start 'partial
:origin 'partial-ex
:pat 'pat-ex
:pmt 'pmt-ex
:overwrite t
:video-pid record-trans-video
:audio-pid record-trans-audio
:espids (get-partial-pids 'partial)
:pids nil))(otherwise
(partial-enable 'partial 'tsport-ex)(partial-start 'partial
:origin 'partial-enc)))(partial-enable 'partial 'tsport)(partial-start 'partial
:pat 'pat
:pmt 'pmt
:video-pid record-video
:video-stype record-vtype
:audio-pid record-audio
:audio-stype record-atype
:pcr-pid record-pcr
:espids (get-partial-pids 'partial)))(partial-stop 'partial))(eval-events (list 'partial-req)))
#'(lambda ()(partial-stop 'partial)))(register-node 'content-check
#'(lambda ()(and content-id (eq content-id req-content-id)))
#'(lambda ()(unless (eq content-id req-content-id)(setf dtcpip-move-limit nil)(setf content-program-sequence 0)(partial-reset 'partial)(when (device-open-p 'partial-enc)(partial-encode-reset 'partial-enc))(setf content-id req-content-id))(eval-events (list 'request-content)))
#'(lambda ()))(register-node 'stream-open
#'(lambda ()
t)
#'(lambda ()(setf record-pause nil)(write-bytes msg-pipe SC_RES_STRM_START 0)(stream-close 'stream-out)(stream-open 'stream-out
:mode nodirect-mode
:mode (if with-bg-rec-on-1tuner "bg-rec" nil)
:limit storage-limit
:stream-dir stream-dir
:data-dir data-dir
:content-id content-id
:drm content-drm)(setf stream-open-valid nil)(set-timer #'(lambda (x)(setf stream-open-valid t))
'stream-valid-timer
nil
1
5000))
#'(lambda ()(setf record-pause t)(write-bytes msg-pipe SC_RES_STRM_STOP 0)(stream-close 'stream-out)(cancel-timer 'stream-valid-timer)(eval-stream-valid)(if stream-valid-index
(progn
(write-bytes msg-pipe SC_RES_STRM_INVALID 8
content-id
stream-valid-index)(when (>= stream-valid-index 254)(setf dtcpip-move-limit t))(setq stream-valid-index nil)(setf content-program-sequence (+ content-program-sequence index-program-sequence))(stream-index-next 'stream-out)(setf stream-open-valid nil))(when (and content-id (eq content-id req-content-id))(stream-write-pmt-file 'stream-out nil)))(setf index-program-sequence 0)))(defun eval-stream-valid ()(when content-id
(let ((stream-index nil))(unless stream-valid-index
(setf stream-index (stream-index-get 'stream-out))(when (and stream-index
(or (> stream-index 0) stream-open-valid))(setq stream-valid-index stream-index)(write-bytes msg-pipe SC_RES_STRM_VALID 8 content-id stream-index)(cancel-timer 'stream-valid-mon))))))(register-node 'stream-valid-monitor
#'(lambda ()
t)
#'(lambda ()(when req-content-id
(set-timer (function eval-stream-valid)
'stream-valid-mon
nil
nil
1000)))
#'(lambda ()(cancel-timer 'stream-valid-mon)))(register-node 'content-time-monitor
#'(lambda ()
t)
#'(lambda ()(when req-content-id
(set-timer #'(lambda (id)(when stream-valid-index
(write-bytes msg-pipe
SC_RES_CONTENT_TIME
8
req-content-id
(get-content-duration req-content-id))))
'monitor-content-timer
nil
nil
500)))
#'(lambda ()(cancel-timer 'monitor-content-timer)))(register-node 'eit-for-sit-request
#'(lambda ()
t)
#'(lambda ()(when (get-section-pid 'eit-for-sit)(section-open 'eit-for-sit)(section-disable 'eit-for-sit)(section-filter 'eit-for-sit
:type "version"
:source 'tsport
:pid (get-section-pid 'eit-for-sit)
:length (get-section-length 'eit-for-sit)
:bufsize 4097
:filter (get-section-filter 'eit-for-sit)
:mask (get-section-mask 'eit-for-sit)
:elength (get-section-elength 'eit-for-sit)
:efilter (get-section-efilter 'eit-for-sit)
:emask (get-section-emask 'eit-for-sit))(section-enable 'eit-for-sit))(eval-events (list 'eit-for-sit-update)))
#'(lambda ()(section-close 'eit-for-sit)))(defun set-eit-for-sit-filter (pid tid tid-ex)(set-section-pid 'eit-for-sit pid)(setf (nth 0 (get-section-filter 'eit-for-sit)) (if tid tid #xff))(setf (nth 0 (get-section-mask 'eit-for-sit)) (if tid 0 #xff))(setf (nth 3 (get-section-filter 'eit-for-sit)) (if tid-ex (/ tid-ex #x100) #xff))(setf (nth 3 (get-section-mask 'eit-for-sit)) (if tid-ex 0 #xff))(setf (nth 4 (get-section-filter 'eit-for-sit)) (if tid-ex (logand tid-ex #xFF) #xff))(setf (nth 4 (get-section-mask 'eit-for-sit)) (if tid-ex 0 #xff))(make-event 'eit-for-sit-update))(register-node 'sdt-for-sit-request
#'(lambda ()
t)
#'(lambda ()(when (get-section-pid 'sdt-for-sit)(section-open 'sdt-for-sit)(section-disable 'sdt-for-sit)(section-filter 'sdt-for-sit
:type "version"
:source 'tsport
:pid (get-section-pid 'sdt-for-sit)
:length (get-section-length 'sdt-for-sit)
:filter (get-section-filter 'sdt-for-sit)
:mask (get-section-mask 'sdt-for-sit)
:elength (get-section-elength 'sdt-for-sit)
:efilter (get-section-efilter 'sdt-for-sit)
:emask (get-section-emask 'sdt-for-sit))(section-enable 'sdt-for-sit))(eval-events (list 'sdt-for-sit-update)))
#'(lambda ()(section-close 'sdt-for-sit)))(defun set-sdt-for-sit-filter (pid tid tid-ex)(set-section-pid 'sdt-for-sit pid)(setf (nth 0 (get-section-filter 'sdt-for-sit)) (if tid tid #xff))(setf (nth 0 (get-section-mask 'sdt-for-sit)) (if tid 0 #xff))(setf (nth 3 (get-section-filter 'sdt-for-sit)) (if tid-ex (/ tid-ex #x100) #xff))(setf (nth 3 (get-section-mask 'sdt-for-sit)) (if tid-ex 0 #xff))(setf (nth 4 (get-section-filter 'sdt-for-sit)) (if tid-ex (logand tid-ex #xFF) #xff))(setf (nth 4 (get-section-mask 'sdt-for-sit)) (if tid-ex 0 #xff))(make-event 'sdt-for-sit-update))(register-node 'sit-insert
#'(lambda ()
t)
#'(lambda ()(set-timer #'(lambda (x)(partial-insert-sit (if (transcode-rec-p)(case (get-transcode-system 'transcode)(pro3
'partial-ex)(external
'partial)(otherwise
'partial-enc))
'partial)
:dst (if req-transcode "limited" nil)
:svcid (get-tuning-svcid)
:eit 'eit-for-sit
:sdt 'sdt-for-sit))
'sit-timer
nil
nil
1000))
#'(lambda ()(cancel-timer 'sit-timer)))(register-device 'video-mon
"video"
1
#'(lambda (sig)(when (get-video-hook 'video-mon)(funcall (get-video-hook 'video-mon) sig))(case sig
((DECODE_SUCCESS DECODE_ERROR DECODE_SCRAMBLE)(when (device-source-p 'video-mon 'tsport)(set-video-result 'video-mon (video-status 'video-mon))(video-property 'video-mon #'(lambda (pid)(unless (eq (get-video-pid 'video-mon) pid)(set-video-pid 'video-mon pid)(make-event 'psi-update)))))))))(register-device 'audio-mon
"audio"
1
#'(lambda (sig)))(register-device 'partial-ex
"partial"
(get-default-prio)
#'(lambda (sig)))(register-device 'transcode
"transcode"
(get-default-prio)
#'(lambda (sig)(case sig
(LOST
(set-owner 'transcode nil))(AVAILABLE
(when (external-transcode-p)(setq transcode-ready t))(set-owner 'transcode t))(DEVICE_AVAILABLE
(setq transcode-ready t)(write-bytes msg-pipe SC_RES_TRANSCODER_INFO 4 (list 1))(make-event 'transcode-req))(DEVICE_BUSY
(setq transcode-ready nil)(make-event 'transcode-req))(DEVICE_RESTART
(setq transcode-ready t)(write-bytes msg-pipe SC_RES_TRANSCODER_INFO 4 (list 1))(make-event 'transcode-req))(DEVICE_RESET
(setq log-trans-request nil)(if (pro3-transcode-p)(progn
(setf new-transcode-pids nil)(make-event 'partial-req)(setq transcode-ready nil)(make-event 'transcode-req)(setq log (transcode-get-errlog 'transcode))(write-bytes msg-pipe SC_RES_TRANSCODER_INFO 8 (list 2 (if log (nth 0 log) -1)))(when (and log (eq (nth 0 log) #x2))(setq new-transcode-pids nil)(make-event 'partial-req)(write-bytes msg-pipe SC_RES_EMI_INFO 8 (list 3 0))))(let ((data nil) (log nil))(setq log (transcode-get-errlog 'transcode))(when log
(do ((x 0 (+ x 2))) ((>= x (length log)))(setq data (cons (+ (* (nth x log) #x100) (nth (+ x 1) log)) data)))(write-bytes msg-pipe SC_RES_TRANSCODER_ERROR 12 (list (reverse data)))))(setf new-transcode-pids nil)(make-event 'partial-req)(set-partial-pids 'partial-ex nil)(make-event 'transcode-req))))))(defvar transcode-list nil)(defmacro set-transcode-audio (sym pids)
`(setf (nth 1 (assoc ,sym transcode-list)) ,pids))(defmacro get-transcode-audio (sym)
`(nth 1 (assoc ,sym transcode-list)))(defmacro set-transcode-pes (sym pids)
`(setf (nth 2 (assoc ,sym transcode-list)) ,pids))(defmacro get-transcode-pes (sym)
`(nth 2 (assoc ,sym transcode-list)))(defmacro set-transcode-bitrate (sym val)
`(setf (nth 3 (assoc ,sym transcode-list)) ,val))(defmacro get-transcode-bitrate (sym)
`(nth 3 (assoc ,sym transcode-list)))(defmacro set-transcode-profile (sym val)
`(setf (nth 4 (assoc ,sym transcode-list)) ,val))(defmacro get-transcode-profile (sym)
`(nth 4 (assoc ,sym transcode-list)))(defmacro set-transcode-level (sym val)
`(setf (nth 5 (assoc ,sym transcode-list)) ,val))(defmacro get-transcode-level (sym)
`(nth 5 (assoc ,sym transcode-list)))(defmacro set-transcode-encmode (sym val)
`(setf (nth 6 (assoc ,sym transcode-list)) ,val))(defmacro get-transcode-encmode (sym)
`(nth 6 (assoc ,sym transcode-list)))(defmacro set-transcode-system (sym val)
`(setf (nth 7 (assoc ,sym transcode-list)) ,val))(defmacro get-transcode-system (sym)
`(nth 7 (assoc ,sym transcode-list)))(defun init-transcode-object (sym)(unless (assoc sym transcode-list)(setf transcode-list (cons (list sym nil nil nil nil nil nil nil) transcode-list)))(set-transcode-audio sym nil)(set-transcode-pes sym nil)(set-transcode-bitrate sym nil)(set-transcode-profile sym nil)(set-transcode-level sym nil)(set-transcode-system sym nil))(register-node 'pat-ex-request
#'(lambda ()(get-section-valid 'pat-ex))
#'(lambda ()(unless (get-section-valid 'pat-ex)(section-open 'pat-ex)(section-disable 'pat-ex)(set-section-pid 'pat-ex 0)(setf (nth 0 (get-section-filter 'pat-ex)) 0)(setf (nth 0 (get-section-mask 'pat-ex)) 0)(section-filter 'pat-ex
:type "version"
:source 'tsport-ex
:pid (get-section-pid 'pat-ex)
:length (get-section-length 'pat-ex)
:filter (get-section-filter 'pat-ex)
:mask (get-section-mask 'pat-ex)
:elength (get-section-elength 'pat-ex)
:efilter (get-section-efilter 'pat-ex)
:emask (get-section-emask 'pat-ex))(section-enable 'pat-ex)(set-timer #'(lambda (arg)(unless (transcode-status 'transcode nil)(setf force-dr t)(make-event 'partial-req)(make-event 'transcode-check)))
'psi-ex-timeout
nil
1
3000))(when (get-section-valid 'pat-ex)(set-timer #'(lambda (arg)(section-disable 'pat-ex)(section-enable 'pat-ex))
'pat-ex-monitor
nil
nil
1000))(eval-events (list 'pat-ex-valid)))
#'(lambda ()(cancel-timer 'psi-ex-timeout)(cancel-timer 'pat-ex-monitor)(section-close 'pat-ex)(set-section-valid 'pat-ex nil)))(register-node 'pmt-ex-request
#'(lambda ()(get-section-valid 'pmt-ex))
#'(lambda ()(unless (get-section-valid 'pmt-ex)(section-open 'pmt-ex)(section-disable 'pmt-ex)(setf (nth 0 (get-section-filter 'pmt-ex)) 2)(setf (nth 0 (get-section-mask 'pmt-ex)) 0)(section-filter 'pmt-ex
:type "version"
:source 'tsport-ex
:pid (get-section-pid 'pmt-ex)
:length (get-section-length 'pmt-ex)
:filter (get-section-filter 'pmt-ex)
:mask (get-section-mask 'pmt-ex)
:elength (get-section-elength 'pmt-ex)
:efilter (get-section-efilter 'pmt-ex)
:emask (get-section-emask 'pmt-ex))(section-enable 'pmt-ex))(when (get-section-valid 'pmt-ex)(set-timer #'(lambda (arg)(section-disable 'pmt-ex)(section-enable 'pmt-ex))
'pmt-ex-monitor
nil
nil
1000))(eval-events (list 'pmt-ex-valid 'pmt-ex-reset)))
#'(lambda ()(setf pmt-ex-retry 0)(cancel-timer 'pmt-ex-monitor)(section-close 'pmt-ex)(setq record-trans-video nil)(setq record-trans-audio nil)(setq old-dtcp nil)(set-section-pid 'pmt-ex nil)(set-section-valid 'pmt-ex nil)))(defvar encode-video nil)(defvar encode-vtype nil)(defvar encode-pcr nil)(defvar encode-audio nil)(defun init-encode (dev)(setf encode-video (video-pid dev))(setf encode-vtype nil)(setf encode-pcr nil)(setf encode-audio nil))(defun set-encode-video-pid (pid)(let ((prev-pid encode-video))(setf encode-video pid)(make-event 'video-enc-update)(unless (eq encode-video prev-pid)(make-event 'encode-restart))))(defun set-encode-vtype (vtype)(setf encode-vtype vtype))(defun set-encode-pcr (pcr)(setf encode-pcr pcr))(defun set-encode-audio-pid (pid)(unless (eq encode-audio pid)(setf encode-audio pid)(make-event 'encode-restart)))(register-section 'pmt-enc
nil)(register-device 'psi-enc
"psi"
(get-default-prio)
#'(lambda (sig)(case sig
(LOST
(set-owner 'psi-enc nil))(AVAILABLE
(set-owner 'psi-enc t)))))(register-device 'video-enc
"video"
(get-default-prio)
#'(lambda (sig)(case sig
(LOST
(set-owner 'video-enc nil))(AVAILABLE
(set-owner 'video-enc t))(DEVICE_BUSY
(make-event 'video-enc-busy))((DECODE_SUCCESS DECODE_ERROR DECODE_SCRAMBLE)(make-event 'video-enc-result)))))(register-device 'audio-enc
"audio"
(get-default-prio)
#'(lambda (sig)))(register-node 'video-play-enc
#'(lambda ()
t)
#'(lambda ()(when (device-open-p 'video-enc)(unless (and (eq (video-pid 'video-enc) encode-video)(eq (device-source 'video-enc) 1))(when (video-pid 'video-enc)(video-stop 'video-enc))(video-play 'video-enc
:psi 'psi-enc
:pcr encode-pcr
:codec encode-vtype
:pid encode-video)))(eval-events (list 'video-enc-update 'video-enc-busy)))
#'(lambda ()(video-stop 'video-enc)))(register-node 'decode-proc
#'(lambda ()(or (not (transcode-rec-p))(and encode-ready (eq encode-video record-video) (eq encode-audio record-audio))))
#'(lambda ()(when (and (transcode-rec-p) (eq encode-video record-video) (eq encode-audio record-audio))(unless encode-ready
(when (eq (video-status 'video-enc) 'DECODE_SUCCESS)(setf encode-ready t))))(eval-events (list 'video-enc-result 'encode-restart)))
#'(lambda ()(setf encode-ready nil)))(register-node 'encode-proc
#'(lambda ()(or (not (transcode-rec-p))(eq (partial-encode-status 'partial-enc) t)))
#'(lambda ()(when (transcode-rec-p)(if new-record-pids
(progn
(cp-set 'cp 'partial-enc)(case (partial-encode-start 'partial-enc
:pmt 'pmt
:video-dev 'video-enc
:encmode (get-transcode-encmode 'transcode)
:audio-pids (get-transcode-audio 'transcode)
:caption-pids (get-transcode-pes 'transcode)
:audio-stype record-atype)(DEVICE_RESET
(set-timer #'(lambda (arg)(setf encode-ready nil)(make-event 'encode-restart))
'encode-restart
nil
1
0))(t
(setf new-transcode-pids (partial-encode-pids 'partial-enc))(setf record-trans-video (nth 0 new-transcode-pids))(setf record-trans-audio (nth 1 new-transcode-pids)))))(partial-encode-stop 'partial-enc)))(eval-events (list 'transcode-req)))
#'(lambda ()(setf new-transcode-pids nil)(partial-encode-stop 'partial-enc)))(register-device 'partial-enc
"partial-encode"
(get-default-prio)
#'(lambda (sig)(case sig
(DEVICE_RESET
(let ((err (partial-encode-status 'partial-enc)))(when (consp err)(nconc err (list 0))(write-bytes msg-pipe SC_RES_TRANSCODER_ERROR 12 err)))(setf encode-ready nil)(make-event 'encode-restart)))))
