dont export by default in the library.
allow this happen in the application level.
This commit is contained in:
parent
80539cd85d
commit
0884690f11
|
@ -2,9 +2,28 @@ import HaishinKit
|
|||
import UIKit
|
||||
import XCGLogger
|
||||
import AVFoundation
|
||||
import Photos
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
final class LiveViewController: UIViewController {
|
||||
var rtmpConnection:RTMPConnection = RTMPConnection()
|
||||
var rtmpStream:RTMPStream!
|
||||
|
@ -42,6 +61,7 @@ final class LiveViewController: UIViewController {
|
|||
rtmpStream.audioSettings = [
|
||||
"sampleRate": sampleRate
|
||||
]
|
||||
rtmpStream.recorderDelegate = ExampleRecorderDelegate()
|
||||
|
||||
videoBitrateSlider?.value = Float(RTMPStream.defaultVideoBitrate) / 1024
|
||||
audioBitrateSlider?.value = Float(RTMPStream.defaultAudioBitrate) / 1024
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
import Foundation
|
||||
import AVFoundation
|
||||
#if os(iOS)
|
||||
import Photos
|
||||
#endif
|
||||
|
||||
public protocol AVMixerRecorderDelegate: class {
|
||||
var moviesDirectory:URL { get }
|
||||
|
@ -251,20 +248,6 @@ extension DefaultAVMixerRecorderDelegate: AVMixerRecorderDelegate {
|
|||
}
|
||||
|
||||
open 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 as NSError {
|
||||
logger.error("\(error)")
|
||||
}
|
||||
})
|
||||
#endif
|
||||
}
|
||||
|
||||
open func didStartRunning(_ recorder: AVMixerRecorder) {
|
||||
|
|
|
@ -124,6 +124,15 @@ 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 {
|
||||
|
|
Loading…
Reference in New Issue