Refactoring

This commit is contained in:
shogo4405 2017-03-26 15:52:22 +09:00
parent ee32633c40
commit 64ddb15b92
3 changed files with 10 additions and 11 deletions

View File

@ -12,15 +12,15 @@ protocol VideoDecoderDelegate: class {
final class H264Decoder {
#if os(iOS)
static let defaultAttributes:[NSString: AnyObject] = [
kCVPixelBufferPixelFormatTypeKey: Int(kCVPixelFormatType_32BGRA) as AnyObject,
kCVPixelBufferPixelFormatTypeKey: NSNumber(value: kCVPixelFormatType_32BGRA),
kCVPixelBufferIOSurfacePropertiesKey: [:] as AnyObject,
kCVPixelBufferOpenGLESCompatibilityKey: true as AnyObject,
kCVPixelBufferOpenGLESCompatibilityKey: NSNumber(booleanLiteral: true),
]
#else
static let defaultAttributes:[NSString: AnyObject] = [
kCVPixelBufferPixelFormatTypeKey: Int(kCVPixelFormatType_32BGRA) as AnyObject,
kCVPixelBufferPixelFormatTypeKey: NSNumber(value: kCVPixelFormatType_32BGRA),
kCVPixelBufferIOSurfacePropertiesKey: [:] as AnyObject,
kCVPixelBufferOpenGLCompatibilityKey: true as AnyObject,
kCVPixelBufferOpenGLCompatibilityKey: NSNumber(booleanLiteral: true),
]
#endif

View File

@ -31,12 +31,12 @@ final class H264Encoder: NSObject {
#if os(iOS)
static let defaultAttributes:[NSString: AnyObject] = [
kCVPixelBufferIOSurfacePropertiesKey: [:] as AnyObject,
kCVPixelBufferOpenGLESCompatibilityKey: true as AnyObject,
kCVPixelBufferOpenGLESCompatibilityKey: NSNumber(booleanLiteral: true),
]
#else
static let defaultAttributes:[NSString: AnyObject] = [
kCVPixelBufferIOSurfacePropertiesKey: [:] as AnyObject,
kCVPixelBufferOpenGLCompatibilityKey: true as AnyObject,
kCVPixelBufferOpenGLCompatibilityKey: NSNumber(booleanLiteral: true),
]
#endif
static let defaultDataRateLimits:[Int] = [0, 0]
@ -195,8 +195,8 @@ final class H264Encoder: NSObject {
#if os(OSX)
if (enabledHardwareEncoder) {
properties[kVTVideoEncoderSpecification_EncoderID] = "com.apple.videotoolbox.videoencoder.h264.gva" as NSObject
properties["EnableHardwareAcceleratedVideoEncoder"] = true as NSObject
properties["RequireHardwareAcceleratedVideoEncoder"] = true as NSObject
properties["EnableHardwareAcceleratedVideoEncoder"] = NSNumber(booleanLiteral: true)
properties["RequireHardwareAcceleratedVideoEncoder"] = NSNumber(booleanLiteral: true)
}
#endif

View File

@ -663,9 +663,8 @@ final class RTMPVideoMessage: RTMPMessage {
decodeTimeStamp: kCMTimeInvalid
)
let bytes:[UInt8] = Array(payload[FLVTagType.video.headerSize..<payload.count])
var sample:[UInt8] = bytes
let sampleSize:Int = bytes.count
var sample:[UInt8] = Array<UInt8>(payload[FLVTagType.video.headerSize..<payload.count])
let sampleSize:Int = sample.count
var blockBuffer:CMBlockBuffer?
guard CMBlockBufferCreateWithMemoryBlock(
kCFAllocatorDefault, &sample, sampleSize, kCFAllocatorNull, nil, 0, sampleSize, 0, &blockBuffer) == noErr else {