Support both ffmpeg versions

This commit is contained in:
Ali 2023-09-30 10:58:25 +04:00
parent 552aede716
commit a627c66538
3 changed files with 12 additions and 0 deletions

View File

@ -35,7 +35,11 @@
}
- (int32_t)channels {
#if LIBAVFORMAT_VERSION_MAJOR >= 59
return (int32_t)_impl->ch_layout.nb_channels;
#else
return (int32_t)_impl->channels;
#endif
}
- (int32_t)sampleRate {

View File

@ -45,7 +45,11 @@
}
- (int64_t)duration {
#if LIBAVFORMAT_VERSION_MAJOR >= 59
return _impl->duration;
#else
return _impl->pkt_duration;
#endif
}
- (FFMpegAVFrameColorRange)colorRange {

View File

@ -75,7 +75,11 @@
- (NSData * _Nullable)resample:(FFMpegAVFrame *)frame {
AVFrame *frameImpl = (AVFrame *)[frame impl];
#if LIBAVFORMAT_VERSION_MAJOR >= 59
int numChannels = frameImpl->ch_layout.nb_channels;
#else
int numChannels = frameImpl->channels;
#endif
if (numChannels != _currentSourceChannelCount) {
[self resetContextForChannelCount:numChannels];
}