Rename AVMixerRecorder -> AVRecorder
This commit is contained in:
parent
23c4ccd054
commit
dbfde710bb
|
@ -6,8 +6,8 @@ import VideoToolbox
|
|||
|
||||
let sampleRate: Double = 44_100
|
||||
|
||||
class ExampleRecorderDelegate: DefaultAVMixerRecorderDelegate {
|
||||
override func didFinishWriting(_ recorder: AVMixerRecorder) {
|
||||
class ExampleRecorderDelegate: DefaultAVRecorderDelegate {
|
||||
override func didFinishWriting(_ recorder: AVRecorder) {
|
||||
guard let writer: AVAssetWriter = recorder.writer else { return }
|
||||
PHPhotoLibrary.shared().performChanges({() -> Void in
|
||||
PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: writer.outputURL)
|
||||
|
|
|
@ -164,7 +164,7 @@ final class AudioConverter: NSObject {
|
|||
}
|
||||
var lockQueue = DispatchQueue(label: "com.haishinkit.HaishinKit.AudioConverter.lock")
|
||||
weak var delegate: AudioConverterDelegate?
|
||||
internal(set) var isRunning: Bool = false
|
||||
private(set) var isRunning: Bool = false
|
||||
private var maximumBuffers: Int = AudioConverter.defaultMaximumBuffers
|
||||
private var bufferListSize: Int = AudioConverter.defaultBufferListSize
|
||||
private var currentBufferList: UnsafeMutableAudioBufferListPointer?
|
||||
|
|
|
@ -131,7 +131,7 @@ final class H264Encoder: NSObject {
|
|||
}
|
||||
weak var delegate: VideoEncoderDelegate?
|
||||
|
||||
internal(set) var isRunning: Bool = false
|
||||
private(set) var isRunning: Bool = false
|
||||
private var supportedProperty: [AnyHashable: Any]? {
|
||||
didSet {
|
||||
guard logger.isEnabledFor(level: .info) else {
|
||||
|
|
|
@ -61,11 +61,11 @@ public class AVMixer: NSObject {
|
|||
}
|
||||
}
|
||||
#endif
|
||||
private var _recorder: AVMixerRecorder?
|
||||
private var _recorder: AVRecorder?
|
||||
/// The recorder instance.
|
||||
public var recorder: AVMixerRecorder! {
|
||||
public var recorder: AVRecorder! {
|
||||
if _recorder == nil {
|
||||
_recorder = AVMixerRecorder()
|
||||
_recorder = AVRecorder()
|
||||
}
|
||||
return _recorder
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
import AVFoundation
|
||||
|
||||
public protocol AVMixerRecorderDelegate: class {
|
||||
public protocol AVRecorderDelegate: class {
|
||||
var moviesDirectory: URL { get }
|
||||
|
||||
func rotateFile(_ recorder: AVMixerRecorder, withPresentationTimeStamp: CMTime, mediaType: AVMediaType)
|
||||
func getPixelBufferAdaptor(_ recorder: AVMixerRecorder, withWriterInput: AVAssetWriterInput?) -> AVAssetWriterInputPixelBufferAdaptor?
|
||||
func getWriterInput(_ recorder: AVMixerRecorder, mediaType: AVMediaType, sourceFormatHint: CMFormatDescription?) -> AVAssetWriterInput?
|
||||
func didStartRunning(_ recorder: AVMixerRecorder)
|
||||
func didStopRunning(_ recorder: AVMixerRecorder)
|
||||
func didFinishWriting(_ recorder: AVMixerRecorder)
|
||||
func rotateFile(_ recorder: AVRecorder, withPresentationTimeStamp: CMTime, mediaType: AVMediaType)
|
||||
func getPixelBufferAdaptor(_ recorder: AVRecorder, withWriterInput: AVAssetWriterInput?) -> AVAssetWriterInputPixelBufferAdaptor?
|
||||
func getWriterInput(_ recorder: AVRecorder, mediaType: AVMediaType, sourceFormatHint: CMFormatDescription?) -> AVAssetWriterInput?
|
||||
func didStartRunning(_ recorder: AVRecorder)
|
||||
func didStopRunning(_ recorder: AVRecorder)
|
||||
func didFinishWriting(_ recorder: AVRecorder)
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
open class AVMixerRecorder: NSObject {
|
||||
open class AVRecorder: NSObject {
|
||||
|
||||
public static let defaultOutputSettings: [AVMediaType: [String: Any]] = [
|
||||
.audio: [
|
||||
|
@ -29,11 +29,11 @@ open class AVMixerRecorder: NSObject {
|
|||
|
||||
open var writer: AVAssetWriter?
|
||||
open var fileName: String?
|
||||
open weak var delegate: AVMixerRecorderDelegate?
|
||||
open weak var delegate: AVRecorderDelegate?
|
||||
open var writerInputs: [AVMediaType: AVAssetWriterInput] = [:]
|
||||
open var outputSettings: [AVMediaType: [String: Any]] = AVMixerRecorder.defaultOutputSettings
|
||||
open var outputSettings: [AVMediaType: [String: Any]] = AVRecorder.defaultOutputSettings
|
||||
open var pixelBufferAdaptor: AVAssetWriterInputPixelBufferAdaptor?
|
||||
public let lockQueue = DispatchQueue(label: "com.haishinkit.HaishinKit.AVMixerRecorder.lock")
|
||||
public let lockQueue = DispatchQueue(label: "com.haishinkit.HaishinKit.AVRecorder.lock")
|
||||
public private(set) var isRunning: Bool = false
|
||||
fileprivate(set) var sourceTime = CMTime.zero
|
||||
|
||||
|
@ -46,12 +46,12 @@ open class AVMixerRecorder: NSObject {
|
|||
|
||||
override public init() {
|
||||
super.init()
|
||||
delegate = DefaultAVMixerRecorderDelegate()
|
||||
delegate = DefaultAVRecorderDelegate()
|
||||
}
|
||||
|
||||
final func appendSampleBuffer(_ sampleBuffer: CMSampleBuffer, mediaType: AVMediaType) {
|
||||
lockQueue.async {
|
||||
guard let delegate: AVMixerRecorderDelegate = self.delegate, self.isRunning else {
|
||||
guard let delegate: AVRecorderDelegate = self.delegate, self.isRunning else {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ open class AVMixerRecorder: NSObject {
|
|||
|
||||
final func appendPixelBuffer(_ pixelBuffer: CVPixelBuffer, withPresentationTime: CMTime) {
|
||||
lockQueue.async {
|
||||
guard let delegate: AVMixerRecorderDelegate = self.delegate, self.isRunning else {
|
||||
guard let delegate: AVRecorderDelegate = self.delegate, self.isRunning else {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ open class AVMixerRecorder: NSObject {
|
|||
}
|
||||
}
|
||||
|
||||
extension AVMixerRecorder: Running {
|
||||
extension AVRecorder: Running {
|
||||
// MARK: Running
|
||||
public func startRunning() {
|
||||
lockQueue.async {
|
||||
|
@ -148,7 +148,7 @@ extension AVMixerRecorder: Running {
|
|||
}
|
||||
|
||||
// MARK: -
|
||||
open class DefaultAVMixerRecorderDelegate: NSObject {
|
||||
open class DefaultAVRecorderDelegate: NSObject {
|
||||
open var duration: Int64 = 0
|
||||
open var dateFormat: String = "-yyyyMMdd-HHmmss"
|
||||
|
||||
|
@ -167,9 +167,9 @@ open class DefaultAVMixerRecorderDelegate: NSObject {
|
|||
}
|
||||
|
||||
@objc
|
||||
extension DefaultAVMixerRecorderDelegate: AVMixerRecorderDelegate {
|
||||
// MARK: AVMixerRecorderDelegate
|
||||
open func rotateFile(_ recorder: AVMixerRecorder, withPresentationTimeStamp: CMTime, mediaType: AVMediaType) {
|
||||
extension DefaultAVRecorderDelegate: AVRecorderDelegate {
|
||||
// MARK: AVRecorderDelegate
|
||||
open func rotateFile(_ recorder: AVRecorder, withPresentationTimeStamp: CMTime, mediaType: AVMediaType) {
|
||||
guard clockReference == mediaType && rotateTime.value < withPresentationTimeStamp.value else {
|
||||
return
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ extension DefaultAVMixerRecorderDelegate: AVMixerRecorderDelegate {
|
|||
recorder.sourceTime = withPresentationTimeStamp
|
||||
}
|
||||
|
||||
open func getPixelBufferAdaptor(_ recorder: AVMixerRecorder, withWriterInput: AVAssetWriterInput?) -> AVAssetWriterInputPixelBufferAdaptor? {
|
||||
open func getPixelBufferAdaptor(_ recorder: AVRecorder, withWriterInput: AVAssetWriterInput?) -> AVAssetWriterInputPixelBufferAdaptor? {
|
||||
guard recorder.pixelBufferAdaptor == nil else {
|
||||
return recorder.pixelBufferAdaptor
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ extension DefaultAVMixerRecorderDelegate: AVMixerRecorderDelegate {
|
|||
return adaptor
|
||||
}
|
||||
|
||||
open func getWriterInput(_ recorder: AVMixerRecorder, mediaType: AVMediaType, sourceFormatHint: CMFormatDescription?) -> AVAssetWriterInput? {
|
||||
open func getWriterInput(_ recorder: AVRecorder, mediaType: AVMediaType, sourceFormatHint: CMFormatDescription?) -> AVAssetWriterInput? {
|
||||
guard recorder.writerInputs[mediaType] == nil else {
|
||||
return recorder.writerInputs[mediaType]
|
||||
}
|
||||
|
@ -247,13 +247,13 @@ extension DefaultAVMixerRecorderDelegate: AVMixerRecorderDelegate {
|
|||
return input
|
||||
}
|
||||
|
||||
open func didFinishWriting(_ recorder: AVMixerRecorder) {
|
||||
open func didFinishWriting(_ recorder: AVRecorder) {
|
||||
}
|
||||
|
||||
open func didStartRunning(_ recorder: AVMixerRecorder) {
|
||||
open func didStartRunning(_ recorder: AVRecorder) {
|
||||
}
|
||||
|
||||
open func didStopRunning(_ recorder: AVMixerRecorder) {
|
||||
open func didStopRunning(_ recorder: AVRecorder) {
|
||||
rotateTime = CMTime.zero
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue