Skip to content

Commit 52b6e28

Browse files
raveendra-karurestyled-commitsandy31415
authored
Add FFMPEG version check to fix build break (project-chip#40456)
* Add FFMPEG LIBAVCODEC version check. Author: Dhruvkumar <[email protected]> Signed-off-by: Raveendra Karu <[email protected]> * Refactor and cleanup. Signed-off-by: Raveendra Karu <[email protected]> * Restyled by clang-format * Address review comments from Gemini bot. Signed-off-by: Raveendra Karu <[email protected]> * Restyled by whitespace --------- Signed-off-by: Raveendra Karu <[email protected]> Co-authored-by: Restyled.io <[email protected]> Co-authored-by: Andrei Litvin <[email protected]>
1 parent b1ac5d1 commit 52b6e28

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

examples/camera-app/linux/src/pushav-clip-recorder.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ extern "C" {
3030
#include <libavutil/timestamp.h>
3131
}
3232

33+
#ifndef LIBAVCODEC_VERSION_INT
34+
#error "LIBAVCODEC_VERSION_INT not defined. Please use a version of FFmpeg/libavcodec that defines this macro."
35+
#endif
36+
3337
#define IS_H264_FRAME_NALU_HEAD(frame) \
3438
(((frame)[0] == 0x00) && ((frame)[1] == 0x00) && (((frame)[2] == 0x01) || (((frame)[2] == 0x00) && ((frame)[3] == 0x01))))
3539

@@ -391,8 +395,18 @@ int PushAVClipRecorder::AddStreamToOutput(AVMediaType type)
391395
Stop();
392396
return -1;
393397
}
398+
394399
mAudioEncoderContext->sample_rate = mAudioInfo.mSampleRate;
400+
401+
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 37, 100)
402+
ChipLogProgress(Camera, "PushAVClipRecorder using FFMPEG version < 5.1");
403+
mAudioEncoderContext->channels = mAudioInfo.mChannels;
404+
mAudioEncoderContext->channel_layout = static_cast<uint64_t>(av_get_default_channel_layout(mAudioEncoderContext->channels));
405+
#else
406+
ChipLogProgress(Camera, "PushAVClipRecorder using FFMPEG version >= 5.1");
395407
av_channel_layout_default(&mAudioEncoderContext->ch_layout, mAudioInfo.mChannels);
408+
#endif
409+
396410
mAudioEncoderContext->bit_rate = mAudioInfo.mBitRate;
397411
mAudioEncoderContext->sample_fmt = audioCodec->sample_fmts[0];
398412
mAudioEncoderContext->time_base = (AVRational){ 1, mAudioInfo.mSampleRate };

0 commit comments

Comments
 (0)