add mythconverg-update-recordedmarkup-table-rollback

A function to rollback a transcoding. It assumes that the original
file has not been altered in any way.
This commit is contained in:
Leo Butler 2020-12-08 12:52:18 -06:00
parent a16b9aaa99
commit ea76a163a8
1 changed files with 32 additions and 2 deletions

View File

@ -398,12 +398,20 @@
(cond ((number? dur0) (roundx (* 1000 dur0)))
((string? dur1) (HH:MM:SS.x->milliseconds dur1))
(#t 0))))
(define (mythconverg-update-recordedmarkup-table rec)
(define* (mythconverg-update-recordedmarkup-table rec #:optional (continuation mysql-continue))
(let* ((chanid (recording-chanid rec))
(starttime (recording-starttime rec))
(last-i-frame (mythconverg-recordedmarkup-type34 rec))
(duration (mythconverg-recordedmarkup-type33 rec)))
(mysql-continue (simple-format #f "delete from ltbrecordedmarkup where chanid=~a and starttime=~a; insert into ltbrecordedmarkup (chanid,starttime,mark,type,data) select * from recordedmarkup where chanid=~a and starttime=~a and type>=0; delete from recordedmarkup where chanid=~a and starttime=~a and (type<=5 or type>=33); insert into recordedmarkup (chanid,starttime,mark,type,data) values (~a,~a,0,34,~a); insert into recordedmarkup (chanid,starttime,mark,type,data) values (~a,~a,0,33,~a);" chanid starttime chanid starttime chanid starttime chanid starttime last-i-frame chanid starttime duration))))
(continuation (simple-format #f "delete from ltbrecordedmarkup where chanid=~a and starttime=~a; insert into ltbrecordedmarkup (chanid,starttime,mark,type,data) select chanid,starttime,mark,type,data from recordedmarkup where chanid=~a and starttime=~a and type>=0; delete from recordedmarkup where chanid=~a and starttime=~a and (type<=5 or type>=33); insert into recordedmarkup (chanid,starttime,mark,type,data) values (~a,~a,0,34,~a); insert into recordedmarkup (chanid,starttime,mark,type,data) values (~a,~a,0,33,~a);" chanid starttime chanid starttime chanid starttime chanid starttime last-i-frame chanid starttime duration))))
;; should be identical to above, except the tables are reversed
(define (mythconverg-update-recordedmarkup-table-rollback rec)
(let ((sanitize+continue (lambda (s)
(mysql-continue (string-downcase
(regexp-substitute/global #f " recordedmarkup"
(regexp-substitute/global #f " ltbrecordedmarkup" s 'pre " RECORDEDMARKUP" 'post) 'pre " LTBRECORDEDMARKUP" 'post))))))
(mythconverg-update-recordedmarkup-table rec sanitize+continue)))
(define* (mythconverg-update-recorded-table rec tr-rec #:optional (mv? #t))
@ -433,6 +441,28 @@
(simple-format #t "mythconverg-pending-jobs: no jobs.\n") (force-output) '())
(#t (map parse-basename (cdr basenames))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ROLLBACK ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; The recording records for old+new are written to the log file after a ;;
;; transcoding. Use rollback-transcoding to rollback to the old recording. ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define* (rollback-transcoding old+new #:optional (update-database #f))
;; rec = old recording
;; tr-rec = transcoded recording
(let* ((rec (re-create-record-data (car old+new)))
(tr-rec (re-create-record-data (cadr old+new))))
(catch #t (lambda ()
;; mysql-start-transaction here
(mysql-start-transaction "")
(mythconverg-update-recorded-seek-table rec)
(mythconverg-update-recordedmarkup-table-rollback rec)
;; last arg is #f so that no mv/touch is done
(mythconverg-update-recorded-table tr-rec rec #f)
;; mysql-commit in this step
(if update-database (mythconverg-execute mysql-cmd))
(list rec tr-rec))
(lambda (key . args)
(list rec tr-rec 'error)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MAIN ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (ffmpeg-myth0 chanid starttime cut-or-skip)