Skip to content

Commit

Permalink
fix #528
Browse files Browse the repository at this point in the history
  • Loading branch information
kingslay committed Dec 12, 2023
1 parent 1502c63 commit 3c892b7
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion FFmpegKit
Submodule FFmpegKit updated 77 files
+1 −1 FFmpegKit.podspec
+6 −0 Package.swift
+29 −5 Plugins/BuildFFmpeg/main.swift
+36 −36 Sources/Libplacebo.xcframework/Info.plist
+1 −1 Sources/Libplacebo.xcframework/ios-arm64/Libplacebo.framework/Headers/config.h
+3 −3 Sources/Libplacebo.xcframework/ios-arm64/Libplacebo.framework/Info.plist
+ Sources/Libplacebo.xcframework/ios-arm64/Libplacebo.framework/Libplacebo
+1 −1 Sources/Libplacebo.xcframework/ios-arm64/Libplacebo.framework/Modules/module.modulemap
+1 −1 Sources/Libplacebo.xcframework/ios-arm64_x86_64-maccatalyst/Libplacebo.framework/Headers/config.h
+3 −3 Sources/Libplacebo.xcframework/ios-arm64_x86_64-maccatalyst/Libplacebo.framework/Info.plist
+ Sources/Libplacebo.xcframework/ios-arm64_x86_64-maccatalyst/Libplacebo.framework/Libplacebo
+1 −1 Sources/Libplacebo.xcframework/ios-arm64_x86_64-maccatalyst/Libplacebo.framework/Modules/module.modulemap
+1 −1 Sources/Libplacebo.xcframework/ios-arm64_x86_64-simulator/Libplacebo.framework/Headers/config.h
+3 −3 Sources/Libplacebo.xcframework/ios-arm64_x86_64-simulator/Libplacebo.framework/Info.plist
+ Sources/Libplacebo.xcframework/ios-arm64_x86_64-simulator/Libplacebo.framework/Libplacebo
+1 −1 Sources/Libplacebo.xcframework/ios-arm64_x86_64-simulator/Libplacebo.framework/Modules/module.modulemap
+1 −1 Sources/Libplacebo.xcframework/macos-arm64_x86_64/Libplacebo.framework/Headers/config.h
+3 −3 Sources/Libplacebo.xcframework/macos-arm64_x86_64/Libplacebo.framework/Info.plist
+ Sources/Libplacebo.xcframework/macos-arm64_x86_64/Libplacebo.framework/Libplacebo
+1 −1 Sources/Libplacebo.xcframework/macos-arm64_x86_64/Libplacebo.framework/Modules/module.modulemap
+1 −1 Sources/Libplacebo.xcframework/tvos-arm64_arm64e/Libplacebo.framework/Headers/config.h
+3 −3 Sources/Libplacebo.xcframework/tvos-arm64_arm64e/Libplacebo.framework/Info.plist
+ Sources/Libplacebo.xcframework/tvos-arm64_arm64e/Libplacebo.framework/Libplacebo
+1 −1 Sources/Libplacebo.xcframework/tvos-arm64_arm64e/Libplacebo.framework/Modules/module.modulemap
+1 −1 Sources/Libplacebo.xcframework/tvos-arm64_x86_64-simulator/Libplacebo.framework/Headers/config.h
+3 −3 Sources/Libplacebo.xcframework/tvos-arm64_x86_64-simulator/Libplacebo.framework/Info.plist
+ Sources/Libplacebo.xcframework/tvos-arm64_x86_64-simulator/Libplacebo.framework/Libplacebo
+1 −1 Sources/Libplacebo.xcframework/tvos-arm64_x86_64-simulator/Libplacebo.framework/Modules/module.modulemap
+1 −1 Sources/Libplacebo.xcframework/xros-arm64-simulator/Libplacebo.framework/Headers/config.h
+3 −3 Sources/Libplacebo.xcframework/xros-arm64-simulator/Libplacebo.framework/Info.plist
+ Sources/Libplacebo.xcframework/xros-arm64-simulator/Libplacebo.framework/Libplacebo
+1 −1 Sources/Libplacebo.xcframework/xros-arm64-simulator/Libplacebo.framework/Modules/module.modulemap
+1 −1 Sources/Libplacebo.xcframework/xros-arm64/Libplacebo.framework/Headers/config.h
+3 −3 Sources/Libplacebo.xcframework/xros-arm64/Libplacebo.framework/Info.plist
+ Sources/Libplacebo.xcframework/xros-arm64/Libplacebo.framework/Libplacebo
+1 −1 Sources/Libplacebo.xcframework/xros-arm64/Libplacebo.framework/Modules/module.modulemap
+138 −0 Sources/lcms2.xcframework/Info.plist
+1,997 −0 Sources/lcms2.xcframework/ios-arm64/lcms2.framework/Headers/lcms2.h
+700 −0 Sources/lcms2.xcframework/ios-arm64/lcms2.framework/Headers/lcms2_plugin.h
+32 −0 Sources/lcms2.xcframework/ios-arm64/lcms2.framework/Info.plist
+4 −0 Sources/lcms2.xcframework/ios-arm64/lcms2.framework/Modules/module.modulemap
+ Sources/lcms2.xcframework/ios-arm64/lcms2.framework/lcms2
+1,997 −0 Sources/lcms2.xcframework/ios-arm64_x86_64-maccatalyst/lcms2.framework/Headers/lcms2.h
+700 −0 Sources/lcms2.xcframework/ios-arm64_x86_64-maccatalyst/lcms2.framework/Headers/lcms2_plugin.h
+32 −0 Sources/lcms2.xcframework/ios-arm64_x86_64-maccatalyst/lcms2.framework/Info.plist
+4 −0 Sources/lcms2.xcframework/ios-arm64_x86_64-maccatalyst/lcms2.framework/Modules/module.modulemap
+ Sources/lcms2.xcframework/ios-arm64_x86_64-maccatalyst/lcms2.framework/lcms2
+1,997 −0 Sources/lcms2.xcframework/ios-arm64_x86_64-simulator/lcms2.framework/Headers/lcms2.h
+700 −0 Sources/lcms2.xcframework/ios-arm64_x86_64-simulator/lcms2.framework/Headers/lcms2_plugin.h
+32 −0 Sources/lcms2.xcframework/ios-arm64_x86_64-simulator/lcms2.framework/Info.plist
+4 −0 Sources/lcms2.xcframework/ios-arm64_x86_64-simulator/lcms2.framework/Modules/module.modulemap
+ Sources/lcms2.xcframework/ios-arm64_x86_64-simulator/lcms2.framework/lcms2
+1,997 −0 Sources/lcms2.xcframework/macos-arm64_x86_64/lcms2.framework/Headers/lcms2.h
+700 −0 Sources/lcms2.xcframework/macos-arm64_x86_64/lcms2.framework/Headers/lcms2_plugin.h
+32 −0 Sources/lcms2.xcframework/macos-arm64_x86_64/lcms2.framework/Info.plist
+4 −0 Sources/lcms2.xcframework/macos-arm64_x86_64/lcms2.framework/Modules/module.modulemap
+ Sources/lcms2.xcframework/macos-arm64_x86_64/lcms2.framework/lcms2
+1,997 −0 Sources/lcms2.xcframework/tvos-arm64_arm64e/lcms2.framework/Headers/lcms2.h
+700 −0 Sources/lcms2.xcframework/tvos-arm64_arm64e/lcms2.framework/Headers/lcms2_plugin.h
+32 −0 Sources/lcms2.xcframework/tvos-arm64_arm64e/lcms2.framework/Info.plist
+4 −0 Sources/lcms2.xcframework/tvos-arm64_arm64e/lcms2.framework/Modules/module.modulemap
+ Sources/lcms2.xcframework/tvos-arm64_arm64e/lcms2.framework/lcms2
+1,997 −0 Sources/lcms2.xcframework/tvos-arm64_x86_64-simulator/lcms2.framework/Headers/lcms2.h
+700 −0 Sources/lcms2.xcframework/tvos-arm64_x86_64-simulator/lcms2.framework/Headers/lcms2_plugin.h
+32 −0 Sources/lcms2.xcframework/tvos-arm64_x86_64-simulator/lcms2.framework/Info.plist
+4 −0 Sources/lcms2.xcframework/tvos-arm64_x86_64-simulator/lcms2.framework/Modules/module.modulemap
+ Sources/lcms2.xcframework/tvos-arm64_x86_64-simulator/lcms2.framework/lcms2
+1,997 −0 Sources/lcms2.xcframework/xros-arm64-simulator/lcms2.framework/Headers/lcms2.h
+700 −0 Sources/lcms2.xcframework/xros-arm64-simulator/lcms2.framework/Headers/lcms2_plugin.h
+32 −0 Sources/lcms2.xcframework/xros-arm64-simulator/lcms2.framework/Info.plist
+4 −0 Sources/lcms2.xcframework/xros-arm64-simulator/lcms2.framework/Modules/module.modulemap
+ Sources/lcms2.xcframework/xros-arm64-simulator/lcms2.framework/lcms2
+1,997 −0 Sources/lcms2.xcframework/xros-arm64/lcms2.framework/Headers/lcms2.h
+700 −0 Sources/lcms2.xcframework/xros-arm64/lcms2.framework/Headers/lcms2_plugin.h
+32 −0 Sources/lcms2.xcframework/xros-arm64/lcms2.framework/Info.plist
+4 −0 Sources/lcms2.xcframework/xros-arm64/lcms2.framework/Modules/module.modulemap
+ Sources/lcms2.xcframework/xros-arm64/lcms2.framework/lcms2
4 changes: 4 additions & 0 deletions Sources/KSPlayer/AVPlayer/KSPictureInPictureController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public class KSPictureInPictureController: AVPictureInPictureController {
startPictureInPicture()
delegate = view
guard KSOptions.isPipPopViewController else {
#if canImport(UIKit)
// 直接退到后台
UIControl().sendAction(#selector(URLSessionTask.suspend), to: UIApplication.shared, for: nil)
#endif
return
}
self.view = view
Expand Down
3 changes: 1 addition & 2 deletions Sources/KSPlayer/MEPlayer/FFmpegDecode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class FFmpegDecode: DecodeProtocol {
let subtitle = closedCaptionsTrack.subtitle
{
let closedCaptionsPacket = Packet()
closedCaptionsPacket.assetTrack = closedCaptionsTrack
if let corePacket = packet.corePacket {
closedCaptionsPacket.corePacket?.pointee.pts = corePacket.pointee.pts
closedCaptionsPacket.corePacket?.pointee.dts = corePacket.pointee.dts
Expand All @@ -74,7 +73,7 @@ class FFmpegDecode: DecodeProtocol {
let buffer = av_buffer_ref(sideData.pointee.buf)
closedCaptionsPacket.corePacket?.pointee.data = buffer?.pointee.data
closedCaptionsPacket.corePacket?.pointee.buf = buffer
closedCaptionsPacket.fill()
closedCaptionsPacket.assetTrack = closedCaptionsTrack
subtitle.putPacket(packet: closedCaptionsPacket)
}
if let sideData = av_frame_get_side_data(avframe, AV_FRAME_DATA_SEI_UNREGISTERED) {
Expand Down
1 change: 0 additions & 1 deletion Sources/KSPlayer/MEPlayer/MEPlayerItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,6 @@ extension MEPlayerItem {
if corePacket.pointee.size <= 0 {
return 0
}
packet.fill()
let first = assetTracks.first { $0.trackID == corePacket.pointee.stream_index }
if let first, first.isEnabled {
packet.assetTrack = first
Expand Down
36 changes: 19 additions & 17 deletions Sources/KSPlayer/MEPlayer/Model.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,19 @@ protocol MEPlayerDelegate: AnyObject {
// MARK: protocol

public protocol ObjectQueueItem {
var timebase: Timebase { get }
var timestamp: Int64 { get set }
var duration: Int64 { get set }
// byte position
var position: Int64 { get set }
var size: Int32 { get set }
}

extension ObjectQueueItem {
var seconds: TimeInterval { cmtime.seconds }
var cmtime: CMTime { timebase.cmtime(for: timestamp) }
}

public protocol FrameOutput: AnyObject {
var renderSource: OutputRenderSourceDelegate? { get set }
func pause()
Expand All @@ -67,11 +73,6 @@ protocol MEFrame: ObjectQueueItem {
var timebase: Timebase { get set }
}

extension MEFrame {
var seconds: TimeInterval { cmtime.seconds }
var cmtime: CMTime { timebase.cmtime(for: timestamp) }
}

// MARK: model

// for MEPlayer
Expand Down Expand Up @@ -196,8 +197,11 @@ final class Packet: ObjectQueueItem {
var timestamp: Int64 = 0
var position: Int64 = 0
var size: Int32 = 0
var assetTrack: FFmpegAssetTrack!
private(set) var corePacket = av_packet_alloc()
var timebase: Timebase {
assetTrack.timebase
}

var isKeyFrame: Bool {
if let corePacket {
return corePacket.pointee.flags & AV_PKT_FLAG_KEY == AV_PKT_FLAG_KEY
Expand All @@ -206,18 +210,16 @@ final class Packet: ObjectQueueItem {
}
}

var seconds: Double {
assetTrack.timebase.cmtime(for: position).seconds
}

func fill() {
guard let corePacket else {
return
var assetTrack: FFmpegAssetTrack! {
didSet {
guard let packet = corePacket?.pointee else {
return
}
timestamp = packet.pts == Int64.min ? packet.dts : packet.pts
position = packet.pos
duration = packet.duration
size = packet.size
}
timestamp = corePacket.pointee.pts == Int64.min ? corePacket.pointee.dts : corePacket.pointee.pts
position = corePacket.pointee.pos
duration = corePacket.pointee.duration
size = corePacket.pointee.size
}

deinit {
Expand Down
2 changes: 1 addition & 1 deletion Sources/KSPlayer/Metal/PixelBufferProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class PixelBuffer: PixelBufferProtocol {
let contents = buffer?.contents()
let source = bytes[i]!
var j = 0
// while 的性能比for in快。
// 性能 while > stride(from:to:by:) > for in
while j < height {
contents?.advanced(by: j * size).copyMemory(from: source.advanced(by: j * byteCount), byteCount: byteCount)
j += 1
Expand Down

0 comments on commit 3c892b7

Please sign in to comment.