add TSWriterDelegate

This commit is contained in:
shogo4405 2018-11-24 21:22:36 +09:00
parent fa877229ab
commit d25f233bcc
9 changed files with 17 additions and 13 deletions

View File

@ -8,7 +8,7 @@ protocol AudioEncoderDelegate: class {
// MARK: -
/**
- seealse:
- https: //developer.apple.com/library/ios/technotes/tn2236/_index.html
- https://developer.apple.com/library/ios/technotes/tn2236/_index.html
*/
final class AACEncoder: NSObject {
enum Error: Swift.Error {

View File

@ -154,7 +154,7 @@ final class H264Encoder: NSObject {
private var invalidateSession: Bool = true
private var lastImageBuffer: CVImageBuffer?
// @see: https: //developer.apple.com/library/mac/releasenotes/General/APIDiffsMacOSX10_8/VideoToolbox.html
// @see: https://developer.apple.com/library/mac/releasenotes/General/APIDiffsMacOSX10_8/VideoToolbox.html
private var properties: [NSString: NSObject] {
let isBaseline: Bool = profileLevel.contains("Baseline")
var properties: [NSString: NSObject] = [

View File

@ -1,5 +1,5 @@
/**
- seealso: https: //tools.ietf.org/html/draft-pantos-http-live-streaming-19
- seealso: https://tools.ietf.org/html/draft-pantos-http-live-streaming-19
*/
struct M3U {
static let header: String = "#EXTM3U"

View File

@ -1,7 +1,7 @@
import Foundation
/**
- seealso: https: //en.wikipedia.org/wiki/Program-specific_information
- seealso: https://en.wikipedia.org/wiki/Program-specific_information
*/
protocol PSIPointer {
var pointerField: UInt8 { get set }

View File

@ -1,7 +1,8 @@
import CoreMedia
import Foundation
protocol TSWriterDelegate: class {
public protocol TSWriterDelegate: class {
func didOutput(_ data: Data)
}
public class TSWriter {
@ -36,6 +37,8 @@ public class TSWriter {
var segmentMaxCount: Int = TSWriter.defaultSegmentMaxCount
var segmentDuration: Double = TSWriter.defaultSegmentDuration
public weak var delegate: TSWriterDelegate?
private(set) var PAT: ProgramAssociationSpecific = {
let PAT: ProgramAssociationSpecific = ProgramAssociationSpecific()
PAT.programs = [1: TSWriter.defaultPMTPID]
@ -92,6 +95,7 @@ public class TSWriter {
}
nstry({
self.delegate?.didOutput(bytes)
self.currentFileHandle?.write(bytes)
}, { exception in
self.currentFileHandle?.write(bytes)
@ -139,6 +143,7 @@ public class TSWriter {
}
nstry({
self.delegate?.didOutput(bytes)
self.currentFileHandle?.write(bytes)
}, { exception in
self.currentFileHandle?.write(bytes)
@ -224,6 +229,7 @@ public class TSWriter {
}
nstry({
self.delegate?.didOutput(bytes)
self.currentFileHandle?.write(bytes)
}, { exception in
logger.warn("\(exception)")

View File

@ -1,6 +1,6 @@
import AVFoundation
/**
- seealso: https: //en.wikipedia.org/wiki/MPEG_transport_stream#Packet
- seealso: https://en.wikipedia.org/wiki/MPEG_transport_stream#Packet
*/
struct TSPacket {
static let size: Int = 188

View File

@ -160,7 +160,7 @@ open class NetStream: NSObject {
}
#endif
open func appendSampleBuffer(_ sampleBuffer: CMSampleBuffer, withType: CMSampleBufferType, options: [NSObject: AnyObject]? = nil) {
open func appendSampleBuffer(_ sampleBuffer: CMSampleBuffer, withType: AVMediaType, options: [NSObject: AnyObject]? = nil) {
switch withType {
case .audio:
mixer.audioIO.lockQueue.async {
@ -170,6 +170,8 @@ open class NetStream: NSObject {
mixer.videoIO.lockQueue.async {
self.mixer.videoIO.appendSampleBuffer(sampleBuffer)
}
default:
break
}
}

View File

@ -2,7 +2,3 @@ import Logboard
let logger: Logboard = Logboard.with(HaishinKitIdentifier)
public enum CMSampleBufferType: String {
case video
case audio
}

View File

@ -4,8 +4,8 @@ import Foundation
Message Digest Algorithm 5
- seealso:
- https: //ja.wikipedia.org/wiki/MD5
- https: //www.ietf.org/rfc/rfc1321.txt
- https://ja.wikipedia.org/wiki/MD5
- https://www.ietf.org/rfc/rfc1321.txt
*/
final class MD5 {