//
//  ZZHCustomVideoCompositionInstruction.swift
//  SwiftProject
//
//  Created by aaa on 2024/4/18.
//

import Foundation
import AVFoundation

final class ZZHCustomVideoCompositionInstruction: NSObject, AVVideoCompositionInstructionProtocol {
    // Fixed
    let enablePostProcessing: Bool = true
    let containsTweening: Bool = false
    let passthroughTrackID: CMPersistentTrackID = kCMPersistentTrackID_Invalid

    // Variable
    let timeRange: CMTimeRange
    let requiredSourceTrackIDs: [NSValue]?
    let videoTrackID: CMPersistentTrackID
    let targetSize: CGSize
    let transform: CGAffineTransform
    
    
    //后面自己添加的
    var selectedIndex:SpatialType = .parallelEyes//记录当前选择的菜单选项
    lazy var videoOriginalAsset:AVAsset = {
        let asset = AVAsset(url: sourceVideoURL!)
        return asset
    }()
    var sourceVideoURL:URL?
    var assetOutput:AVAssetReaderTrackOutput?
    
    
    init(track: AVAssetTrack, timeRange: CMTimeRange,  transform: CGAffineTransform, targetSize: CGSize,sourceVideoURL:URL) {
        self.requiredSourceTrackIDs = [NSNumber(value: track.trackID)]
        self.timeRange = timeRange
        self.videoTrackID = track.trackID
        self.transform = transform
        self.targetSize = targetSize
        self.sourceVideoURL = sourceVideoURL
        super.init()
    }
}
