Skip to content

Commit 2897b56

Browse files
hillwoodrocadd-uos
authored andcommitted
Multiple fixes (#741)
* feat: Support ffmepg 7 Log: Fix build on ffmepg 7 * fix:(libcam_encoder) Add fallback definitions for FF_PROFILE_* macros Some older FFmpeg or libav versions do not define FF_PROFILE_* macros. Add conditional definitions to ensure compatibility with AV_PROFILE_* constants, fixing build errors on systems with outdated headers. Log: * fix: update function signature for GCC 15 compatibility The function 'v4l2core_check_device_list_events' signature was updated to accept 'v4l2_dev_t *' parameter instead of having no parameters. Log: This change addresses a breaking compatibility issue introduced in GCC 15, which enforces stricter type checking on function declarations and definitions. Previously, GCC allowed mismatched function declarations and definitions when parameter types differ but ultimately point to the same struct type, such as between 'struct _v4l2_dev_t *' and 'v4l2_dev_t *'. GCC 15's change (see GCC 15 release notes) now treats such mismatches as errors, requiring declarations and definitions to exactly match in parameter types. This patch aligns the declaration with the definition to fix the 'conflicting types' compilation error when building with GCC 15
1 parent d4dfa83 commit 2897b56

5 files changed

Lines changed: 44 additions & 4 deletions

File tree

3rdparty/libcam/libcam/camview.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,14 +1027,14 @@ void *capture_loop(void *data)
10271027
my_video_begin_time = v4l2core_time_get_timestamp(); /*timer count*/
10281028
/*if are not saving video start it*/
10291029
if(!get_encoder_status())
1030-
start_encoder_thread();
1030+
start_encoder_thread(data);
10311031
}
10321032

10331033
/*add a photo capture timer*/
10341034
if(my_options->photo_timer > 0)
10351035
{
10361036
my_photo_timer = NSEC_PER_SEC * my_options->photo_timer;
1037-
my_last_photo_time = v4l2core_time_get_timestamp(my_vd); /*timer count*/
1037+
my_last_photo_time = v4l2core_time_get_timestamp(); /*timer count*/
10381038
}
10391039

10401040
if(my_options->photo_npics > 0)

3rdparty/libcam/libcam/camview.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ audio_context_t *get_audio_context(void);
397397
*
398398
* returns: error code
399399
*/
400-
int start_encoder_thread();
400+
int start_encoder_thread(void *);
401401

402402
/*
403403
* stop the encoder thread

3rdparty/libcam/libcam_encoder/audio_codecs.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@
3636
#include "encoder.h"
3737
#include "load_libs.h"
3838

39+
#ifndef FF_PROFILE_UNKNOWN
40+
#define FF_PROFILE_UNKNOWN AV_PROFILE_UNKNOWN
41+
#define FF_PROFILE_AAC_MAIN AV_PROFILE_AAC_MAIN
42+
#define FF_PROFILE_AAC_LOW AV_PROFILE_AAC_LOW
43+
#define FF_PROFILE_AAC_SSR AV_PROFILE_AAC_SSR
44+
#define FF_PROFILE_AAC_LTP AV_PROFILE_AAC_LTP
45+
#endif
46+
3947
extern int verbosity;
4048

4149
/* AAC object types index: MAIN = 1; LOW = 2; SSR = 3; LTP = 4*/

3rdparty/libcam/libcam_encoder/encoder.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,12 +745,24 @@ static encoder_audio_context_t *encoder_audio_init(encoder_context_t *encoder_ct
745745
audio_codec_data->codec_context->flags |= audio_defaults->flags;
746746

747747
audio_codec_data->codec_context->sample_rate = encoder_ctx->audio_samprate;
748+
#if LIBAVFORMAT_VERSION_MAJOR < 61
748749
audio_codec_data->codec_context->channels = encoder_ctx->audio_channels;
750+
#else
751+
av_channel_layout_default(&audio_codec_data->codec_context->ch_layout,
752+
encoder_ctx->audio_channels);
753+
#endif
749754

755+
#if LIBAVFORMAT_VERSION_MAJOR < 61
750756
if(encoder_ctx->audio_channels < 2)
751757
audio_codec_data->codec_context->channel_layout = AV_CH_LAYOUT_MONO;
752758
else
753759
audio_codec_data->codec_context->channel_layout = AV_CH_LAYOUT_STEREO;
760+
#else
761+
if(encoder_ctx->audio_channels < 2)
762+
av_channel_layout_default(&audio_codec_data->codec_context->ch_layout, 1);
763+
else
764+
av_channel_layout_default(&audio_codec_data->codec_context->ch_layout, 2);
765+
#endif
754766

755767
audio_codec_data->codec_context->cutoff = 0; /*automatic*/
756768

@@ -905,7 +917,11 @@ static encoder_audio_context_t *encoder_audio_init(encoder_context_t *encoder_ct
905917
audio_codec_data->frame->nb_samples = frame_size;
906918
audio_codec_data->frame->format = audio_defaults->sample_format;
907919

920+
#if LIBAVFORMAT_VERSION_MAJOR < 61
908921
audio_codec_data->frame->channel_layout = audio_codec_data->codec_context->channel_layout;
922+
#else
923+
av_channel_layout_copy(&audio_codec_data->frame->ch_layout, &audio_codec_data->codec_context->ch_layout);
924+
#endif
909925

910926
/*set codec data in encoder context*/
911927
enc_audio_ctx->codec_data = (void *) audio_codec_data;
@@ -1763,7 +1779,11 @@ int encoder_encode_audio(encoder_context_t *encoder_ctx, void *audio_data)
17631779

17641780
int buffer_size = getAvutil()->m_av_samples_get_buffer_size(
17651781
NULL,
1782+
#if LIBAVFORMAT_VERSION_MAJOR < 61
17661783
audio_codec_data->codec_context->channels,
1784+
#else
1785+
audio_codec_data->codec_context->ch_layout.nb_channels,
1786+
#endif
17671787
audio_codec_data->frame->nb_samples,
17681788
audio_codec_data->codec_context->sample_fmt,
17691789
align);
@@ -1772,7 +1792,11 @@ int encoder_encode_audio(encoder_context_t *encoder_ctx, void *audio_data)
17721792
{
17731793
fprintf(stderr, "ENCODER: (encoder_encode_audio) av_samples_get_buffer_size error (%d): chan(%d) nb_samp(%d) samp_fmt(%d)\n",
17741794
buffer_size,
1795+
#if LIBAVFORMAT_VERSION_MAJOR < 61
17751796
audio_codec_data->codec_context->channels,
1797+
#else
1798+
audio_codec_data->codec_context->ch_layout.nb_channels,
1799+
#endif
17761800
audio_codec_data->frame->nb_samples,
17771801
audio_codec_data->codec_context->sample_fmt);
17781802

@@ -1783,7 +1807,11 @@ int encoder_encode_audio(encoder_context_t *encoder_ctx, void *audio_data)
17831807
/*set the data pointers in frame*/
17841808
ret = getLoadLibsInstance()->m_avcodec_fill_audio_frame(
17851809
audio_codec_data->frame,
1810+
#if LIBAVFORMAT_VERSION_MAJOR < 61
17861811
audio_codec_data->codec_context->channels,
1812+
#else
1813+
audio_codec_data->codec_context->ch_layout.nb_channels,
1814+
#endif
17871815
audio_codec_data->codec_context->sample_fmt,
17881816
(const uint8_t *) audio_data,
17891817
buffer_size,
@@ -1793,7 +1821,11 @@ int encoder_encode_audio(encoder_context_t *encoder_ctx, void *audio_data)
17931821
{
17941822
fprintf(stderr, "ENCODER: (encoder_encode_audio) avcodec_fill_audio_frame error (%d): chan(%d) nb_samp(%d) samp_fmt(%d) buff(%d bytes)\n",
17951823
ret,
1824+
#if LIBAVFORMAT_VERSION_MAJOR < 61
17961825
audio_codec_data->codec_context->channels,
1826+
#else
1827+
audio_codec_data->codec_context->ch_layout.nb_channels,
1828+
#endif
17971829
audio_codec_data->frame->nb_samples,
17981830
audio_codec_data->codec_context->sample_fmt,
17991831
buffer_size);

3rdparty/libcam/libcam_v4l2core/gviewv4l2core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ int v4l2core_get_device_index(const char *videodevice);
629629
*
630630
* returns: true(1) if device list was updated, false(0) otherwise
631631
*/
632-
int v4l2core_check_device_list_events();
632+
int v4l2core_check_device_list_events(v4l2_dev_t *vd);
633633

634634
/*
635635
* check for control events

0 commit comments

Comments
 (0)