From af36b3cad1b16ebc4035b2b8a7e4deede125625f Mon Sep 17 00:00:00 2001 From: Ali <> Date: Mon, 2 Oct 2023 17:55:00 +0400 Subject: [PATCH] Port AVERROR_EOF --- .../Public/FFMpegBinding/FFMpegAVIOContext.h | 2 ++ submodules/FFMpegBinding/Sources/FFMpegAVIOContext.m | 2 ++ .../Sources/FFMpegMediaFrameSourceContext.swift | 8 ++++---- submodules/MediaPlayer/Sources/SoftwareVideoSource.swift | 2 +- .../Sources/UniversalSoftwareVideoSource.swift | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/submodules/FFMpegBinding/Public/FFMpegBinding/FFMpegAVIOContext.h b/submodules/FFMpegBinding/Public/FFMpegBinding/FFMpegAVIOContext.h index 4aebfa02df..8f4f8314b1 100644 --- a/submodules/FFMpegBinding/Public/FFMpegBinding/FFMpegAVIOContext.h +++ b/submodules/FFMpegBinding/Public/FFMpegBinding/FFMpegAVIOContext.h @@ -4,6 +4,8 @@ NS_ASSUME_NONNULL_BEGIN #define FFMPEG_AVSEEK_SIZE 0x10000 +extern int FFMPEG_CONSTANT_AVERROR_EOF; + @interface FFMpegAVIOContext : NSObject - (instancetype _Nullable)initWithBufferSize:(int32_t)bufferSize opaqueContext:(void * const)opaqueContext readPacket:(int (* _Nullable)(void * _Nullable opaque, uint8_t * _Nullable buf, int buf_size))readPacket writePacket:(int (* _Nullable)(void * _Nullable opaque, uint8_t * _Nullable buf, int buf_size))writePacket seek:(int64_t (*)(void * _Nullable opaque, int64_t offset, int whence))seek isSeekable:(bool)isSeekable; diff --git a/submodules/FFMpegBinding/Sources/FFMpegAVIOContext.m b/submodules/FFMpegBinding/Sources/FFMpegAVIOContext.m index 3473ed7ff5..b0e54a15ac 100644 --- a/submodules/FFMpegBinding/Sources/FFMpegAVIOContext.m +++ b/submodules/FFMpegBinding/Sources/FFMpegAVIOContext.m @@ -2,6 +2,8 @@ #import "libavformat/avformat.h" +int FFMPEG_CONSTANT_AVERROR_EOF = AVERROR_EOF; + @interface FFMpegAVIOContext () { AVIOContext *_impl; } diff --git a/submodules/MediaPlayer/Sources/FFMpegMediaFrameSourceContext.swift b/submodules/MediaPlayer/Sources/FFMpegMediaFrameSourceContext.swift index b52a8e0522..db27df800e 100644 --- a/submodules/MediaPlayer/Sources/FFMpegMediaFrameSourceContext.swift +++ b/submodules/MediaPlayer/Sources/FFMpegMediaFrameSourceContext.swift @@ -85,7 +85,7 @@ private func readPacketCallback(userData: UnsafeMutableRawPointer?, buffer: Unsa } if totalCount > maximumFetchSize { context.readingError = true - return 0 + return FFMPEG_CONSTANT_AVERROR_EOF } } @@ -118,7 +118,7 @@ private func readPacketCallback(userData: UnsafeMutableRawPointer?, buffer: Unsa disposable.dispose() if !completedRequest { context.readingError = true - return 0 + return FFMPEG_CONSTANT_AVERROR_EOF } } } @@ -176,7 +176,7 @@ private func readPacketCallback(userData: UnsafeMutableRawPointer?, buffer: Unsa disposable.dispose() if !completedRequest { context.readingError = true - return 0 + return FFMPEG_CONSTANT_AVERROR_EOF } } } @@ -192,7 +192,7 @@ private func readPacketCallback(userData: UnsafeMutableRawPointer?, buffer: Unsa if context.closed { context.readingError = true - return 0 + return FFMPEG_CONSTANT_AVERROR_EOF } return fetchedCount } diff --git a/submodules/MediaPlayer/Sources/SoftwareVideoSource.swift b/submodules/MediaPlayer/Sources/SoftwareVideoSource.swift index a9dad5d9f1..ecb1620c4b 100644 --- a/submodules/MediaPlayer/Sources/SoftwareVideoSource.swift +++ b/submodules/MediaPlayer/Sources/SoftwareVideoSource.swift @@ -13,7 +13,7 @@ private func readPacketCallback(userData: UnsafeMutableRawPointer?, buffer: Unsa if let fd = context.fd { return Int32(read(fd, buffer, Int(bufferSize))) } - return 0 + return FFMPEG_CONSTANT_AVERROR_EOF } private func seekCallback(userData: UnsafeMutableRawPointer?, offset: Int64, whence: Int32) -> Int64 { diff --git a/submodules/MediaPlayer/Sources/UniversalSoftwareVideoSource.swift b/submodules/MediaPlayer/Sources/UniversalSoftwareVideoSource.swift index 0605e03568..8b581bc6b6 100644 --- a/submodules/MediaPlayer/Sources/UniversalSoftwareVideoSource.swift +++ b/submodules/MediaPlayer/Sources/UniversalSoftwareVideoSource.swift @@ -71,7 +71,7 @@ private func readPacketCallback(userData: UnsafeMutableRawPointer?, buffer: Unsa context.readingOffset += Int64(fetchedCount) return fetchedCount } else { - return 0 + return FFMPEG_CONSTANT_AVERROR_EOF } }