Refectoring #272

1
This commit is contained in:
shogo4405 2017-08-01 00:52:58 +09:00
parent 5b807a5c0d
commit d218954044
2 changed files with 11 additions and 23 deletions

View File

@ -8,19 +8,16 @@ let sampleRate:Double = 44_100
class ExampleRecorderDelegate: DefaultAVMixerRecorderDelegate {
override func didFinishWriting(_ recorder: AVMixerRecorder) {
#if os(iOS)
guard let writer:AVAssetWriter = recorder.writer, shouldSaveToPhotoLibrary
else { return }
PHPhotoLibrary.shared().performChanges({() -> Void in
PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: writer.outputURL)
}, completionHandler: { (isSuccess, error) -> Void in
do {
try FileManager.default.removeItem(at: writer.outputURL)
} catch let error {
print(error)
}
})
#endif
guard let writer:AVAssetWriter = recorder.writer, shouldSaveToPhotoLibrary else { return }
PHPhotoLibrary.shared().performChanges({() -> Void in
PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: writer.outputURL)
}, completionHandler: { (isSuccess, error) -> Void in
do {
try FileManager.default.removeItem(at: writer.outputURL)
} catch let error {
print(error)
}
})
}
}
@ -61,7 +58,7 @@ final class LiveViewController: UIViewController {
rtmpStream.audioSettings = [
"sampleRate": sampleRate
]
rtmpStream.recorderDelegate = ExampleRecorderDelegate()
rtmpStream.mixer.recorder.delegate = ExampleRecorderDelegate()
videoBitrateSlider?.value = Float(RTMPStream.defaultVideoBitrate) / 1024
audioBitrateSlider?.value = Float(RTMPStream.defaultAudioBitrate) / 1024

View File

@ -124,15 +124,6 @@ open class NetStream: NSObject {
}
}
open var recorderDelegate: AVMixerRecorderDelegate? {
get {
return self.mixer.recorder.delegate
}
set {
self.mixer.recorder.delegate = newValue
}
}
#if os(iOS) || os(macOS)
open func attachCamera(_ camera:AVCaptureDevice?, onError:((_ error:NSError) -> Void)? = nil) {
lockQueue.async {