diff --git a/contrib/src/ffmpeg/SHA512SUMS b/contrib/src/ffmpeg/SHA512SUMS index d369d4450c61f52549322012ee79e6af84896bdd..f5d34e73853c17ff121509df1535056e216926fb 100644 --- a/contrib/src/ffmpeg/SHA512SUMS +++ b/contrib/src/ffmpeg/SHA512SUMS @@ -1 +1 @@ -3ea683f3a3cb9cd3f27c953655240ae3b5981e2103876a1c9d66fcdce02d4e0c9205aed78829de0c5577fd6414f32a662b472b329cb516fc5212381c71a9bd74 ffmpeg-n5.0.tar.gz +14d4b6d9ee60a861120c34082b61ec449235f53b93fa3c5fdca1d4b8033f34ac56ad3a4a83e8b19a4578879703b9d47c0d15a861ac10759d1f144e7e18f0ad93 ffmpeg-n6.0.tar.gz diff --git a/contrib/src/ffmpeg/libopusdec-enable-FEC.patch b/contrib/src/ffmpeg/libopusdec-enable-FEC.patch index 2e3aa3eea1e612343bab1e72cdc82520d868f413..fb9466a4fcb64d50d5efd2b19c8d8f79fcc4249d 100644 --- a/contrib/src/ffmpeg/libopusdec-enable-FEC.patch +++ b/contrib/src/ffmpeg/libopusdec-enable-FEC.patch @@ -1,8 +1,8 @@ diff --git a/libavcodec/libopusdec.c b/libavcodec/libopusdec.c -index 2a97811d18..40ee7b8fec 100644 +index 9b9a610343..8ec5bfc1ad 100644 --- a/libavcodec/libopusdec.c +++ b/libavcodec/libopusdec.c -@@ -43,6 +43,8 @@ +@@ -45,6 +45,8 @@ struct libopus_context { #ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST int apply_phase_inv; #endif @@ -11,7 +11,7 @@ index 2a97811d18..40ee7b8fec 100644 }; #define OPUS_HEAD_SIZE 19 -@@ -134,6 +136,8 @@ +@@ -141,6 +143,8 @@ static av_cold int libopus_decode_init(AVCodecContext *avc) /* Decoder delay (in samples) at 48kHz */ avc->delay = avc->internal->skip_samples = opus->pre_skip; @@ -20,10 +20,10 @@ index 2a97811d18..40ee7b8fec 100644 return 0; } -@@ -155,25 +159,81 @@ +@@ -161,27 +165,82 @@ static int libopus_decode(AVCodecContext *avc, AVFrame *frame, + int *got_frame_ptr, AVPacket *pkt) { struct libopus_context *opus = avc->priv_data; - AVFrame *frame = data; - int ret, nb_samples; + uint8_t *outptr; + int ret, nb_samples = 0, nb_lost_samples = 0, nb_samples_left; @@ -98,8 +98,8 @@ index 2a97811d18..40ee7b8fec 100644 - return ff_opus_error_to_averror(nb_samples); + opus_strerror(ret)); + return ff_opus_error_to_averror(ret); -+ } -+ + } + + nb_samples += ret; + + if (opus->decode_fec) @@ -110,10 +110,11 @@ index 2a97811d18..40ee7b8fec 100644 + } else { + opus->expected_next_pts = pkt->pts + nb_samples; + } - } - ++ } #ifndef OPUS_SET_GAIN -@@ -214,6 +274,7 @@ + { + int i = avc->ch_layout.nb_channels * nb_samples; +@@ -220,6 +279,7 @@ static const AVOption libopusdec_options[] = { #ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST { "apply_phase_inv", "Apply intensity stereo phase inversion", OFFSET(apply_phase_inv), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS }, #endif @@ -121,3 +122,6 @@ index 2a97811d18..40ee7b8fec 100644 { NULL }, }; +-- +2.34.1 + diff --git a/contrib/src/ffmpeg/nvenc-fix-reorderqueueflush-crash.patch b/contrib/src/ffmpeg/nvenc-fix-reorderqueueflush-crash.patch new file mode 100644 index 0000000000000000000000000000000000000000..acc09fcbdc72719cc52b7d2fc92fe0eb095ed3b2 --- /dev/null +++ b/contrib/src/ffmpeg/nvenc-fix-reorderqueueflush-crash.patch @@ -0,0 +1,21 @@ +--- + libavcodec/nvenc.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c +index 8a28454042..c091fe2d31 100644 +--- a/libavcodec/nvenc.c ++++ b/libavcodec/nvenc.c +@@ -1853,7 +1853,8 @@ av_cold int ff_nvenc_encode_close(AVCodecContext *avctx) + p_nvenc->nvEncEncodePicture(ctx->nvencoder, ¶ms); + } + +- reorder_queue_flush(ctx->reorder_queue); ++ if (ctx->reorder_queue) ++ reorder_queue_flush(ctx->reorder_queue); + av_fifo_freep2(&ctx->reorder_queue); + av_fifo_freep2(&ctx->output_surface_ready_queue); + av_fifo_freep2(&ctx->output_surface_queue); +-- +2.34.1 + diff --git a/contrib/src/ffmpeg/package.json b/contrib/src/ffmpeg/package.json index c042b93c31d7a6ba35e7a021b4bf17ee8bf2e82e..3418cf6d33a7bff62693fa437cb846f1ae1f990e 100644 --- a/contrib/src/ffmpeg/package.json +++ b/contrib/src/ffmpeg/package.json @@ -1,6 +1,6 @@ { "name": "ffmpeg", - "version": "n5.0", + "version": "n6.0", "url": "https://git.ffmpeg.org/gitweb/ffmpeg.git/snapshot/__VERSION__.tar.gz", "deps": [ "vpx", @@ -16,8 +16,8 @@ "libopusdec-enable-FEC.patch", "windows-configure.patch", "windows-configure-ffnvcodec.patch", - "windows-configure-libmfx.patch", - "windows-dxgi-support.patch" + "windows-dxgi-support.patch", + "nvenc-fix-reorderqueueflush-crash.patch" ], "win_patches": [ ], diff --git a/contrib/src/ffmpeg/rules.mak b/contrib/src/ffmpeg/rules.mak index d334e30d7e40fe814b4704d5ea8c8cc2002e6be4..5f6ab47aa610eff14e832057f3cbbdf803b680d8 100644 --- a/contrib/src/ffmpeg/rules.mak +++ b/contrib/src/ffmpeg/rules.mak @@ -1,4 +1,4 @@ -FFMPEG_HASH := n5.0 +FFMPEG_HASH := n6.0 FFMPEG_URL := https://git.ffmpeg.org/gitweb/ffmpeg.git/snapshot/$(FFMPEG_HASH).tar.gz PKGS+=ffmpeg @@ -366,6 +366,7 @@ ffmpeg: ffmpeg-$(FFMPEG_HASH).tar.gz $(APPLY) $(SRC)/ffmpeg/libopusenc-reload-packet-loss-at-encode.patch $(APPLY) $(SRC)/ffmpeg/ios-disable-b-frames.patch $(APPLY) $(SRC)/ffmpeg/screen-sharing-x11-fix.patch + $(APPLY) $(SRC)/ffmpeg/nvenc-fix-reorderqueueflush-crash.patch $(UPDATE_AUTOCONFIG) $(MOVE) diff --git a/contrib/src/ffmpeg/windows-configure-ffnvcodec.patch b/contrib/src/ffmpeg/windows-configure-ffnvcodec.patch index 201a8f6f4054878c05ce703bbd540f9f7a38523a..5886adf3a43cc887fc0d6077839fe4b63878941b 100644 --- a/contrib/src/ffmpeg/windows-configure-ffnvcodec.patch +++ b/contrib/src/ffmpeg/windows-configure-ffnvcodec.patch @@ -17,10 +17,10 @@ index d0fb8a1fc3..4a6defcc78 100755 -if ! disabled ffnvcodec; then - ffnv_hdr_list="ffnvcodec/nvEncodeAPI.h ffnvcodec/dynlink_cuda.h ffnvcodec/dynlink_cuviddec.h ffnvcodec/dynlink_nvcuvid.h" -- check_pkg_config ffnvcodec "ffnvcodec >= 9.1.23.1" "$ffnv_hdr_list" "" || \ -- check_pkg_config ffnvcodec "ffnvcodec >= 9.0.18.3 ffnvcodec < 9.1" "$ffnv_hdr_list" "" || \ -- check_pkg_config ffnvcodec "ffnvcodec >= 8.2.15.10 ffnvcodec < 8.3" "$ffnv_hdr_list" "" || \ -- check_pkg_config ffnvcodec "ffnvcodec >= 8.1.24.11 ffnvcodec < 8.2" "$ffnv_hdr_list" "" +- check_pkg_config ffnvcodec "ffnvcodec >= 12.0.16.0" "$ffnv_hdr_list" "" || \ +- check_pkg_config ffnvcodec "ffnvcodec >= 11.1.5.2 ffnvcodec < 12.0" "$ffnv_hdr_list" "" || \ +- check_pkg_config ffnvcodec "ffnvcodec >= 11.0.10.2 ffnvcodec < 11.1" "$ffnv_hdr_list" "" || \ +- check_pkg_config ffnvcodec "ffnvcodec >= 8.1.24.14 ffnvcodec < 8.2" "$ffnv_hdr_list" "" -fi - if enabled_all libglslang libshaderc; then diff --git a/contrib/src/ffnvcodec/package.json b/contrib/src/ffnvcodec/package.json index 0499e1a9374189ae73df7a320808d1f50a3e55f4..2e83aaa3ba1c4da65d020ee5cdf1a00348dc832e 100644 --- a/contrib/src/ffnvcodec/package.json +++ b/contrib/src/ffnvcodec/package.json @@ -1,6 +1,6 @@ { "name": "ffnvcodec", - "version": "5ee2ae591f74f53bd6028344f8690f1558a1f17a", + "version": "n11.1.5.2", "url": "https://github.com/FFmpeg/nv-codec-headers/archive/__VERSION__.tar.gz", "deps": [], "patches": [], diff --git a/contrib/src/ffnvcodec/rules.mak b/contrib/src/ffnvcodec/rules.mak index 99f47b9e912cbd951deb8e070a3d23b5b013f3e2..b6ffc4a837bc2856366b28eab9825f7721bf577a 100644 --- a/contrib/src/ffnvcodec/rules.mak +++ b/contrib/src/ffnvcodec/rules.mak @@ -1,5 +1,5 @@ # ffnvcodec -FFNVCODEC_VERSION := n11.1.5.1 +FFNVCODEC_VERSION := n11.1.5.2 FFNVCODEC_GITURL := https://git.videolan.org/git/ffmpeg/nv-codec-headers.git ifeq ($(call need_pkg,"ffnvcodec >= 8"),) diff --git a/contrib/src/media-sdk/package.json b/contrib/src/media-sdk/package.json index a238fa5996513b24dd33601dfbe3b43af4f1ac3e..c435a7c431001ca3ded14e3bc15601eeaf441e1d 100644 --- a/contrib/src/media-sdk/package.json +++ b/contrib/src/media-sdk/package.json @@ -1,10 +1,10 @@ { "name": "media-sdk", - "version": "intel-mediasdk-19.2.0", + "version": "intel-mediasdk-23.1.2", "url": "https://github.com/Intel-Media-SDK/MediaSDK/archive/__VERSION__.tar.gz", "deps": [], - "patches": [], - "win_patches": ["windows-static-lib-build.patch"], + "patches": [ "windows-static-lib-build.patch" ], + "win_patches": [], "project_paths": ["api/mfx_dispatch/windows/libmfx_vs2015.vcxproj"], "with_env" : "", "custom_scripts": { diff --git a/contrib/src/media-sdk/windows-static-lib-build.patch b/contrib/src/media-sdk/windows-static-lib-build.patch index a732824246340b57daea62e63f4dd1e3e1997bd0..e277ae64446b5f4949653611cdf91ecfc4c250b5 100644 --- a/contrib/src/media-sdk/windows-static-lib-build.patch +++ b/contrib/src/media-sdk/windows-static-lib-build.patch @@ -1,38 +1,58 @@ -From 689a7acb36963c8558db3e879e6c22dcaaa535e7 Mon Sep 17 00:00:00 2001 -From: Eden Abitbol <eden.abitbol@savoirfairelinux.com> -Date: Tue, 23 Jul 2019 11:30:49 -0400 -Subject: [PATCH] Copy build output to correct directory +From a6d3a6c54923e46eef29046b7d1578ba05aaebe1 Mon Sep 17 00:00:00 2001 +From: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com> +Date: Fri, 3 Mar 2023 19:18:28 -0300 +Subject: [PATCH] test --- - api/mfx_dispatch/windows/libmfx_vs2015.sln | 7 ++-- - .../windows/libmfx_vs2015.vcxproj | 33 +++++++++++++++++-- - 2 files changed, 35 insertions(+), 5 deletions(-) + .../windows/libmfx_vs2015.vcxproj | 36 +++++++++++++------ + 1 file changed, 26 insertions(+), 10 deletions(-) ---- a/api/mfx_dispatch/windows/libmfx_vs2015.sln -+++ b/api/mfx_dispatch/windows/libmfx_vs2015.sln -@@ -1,7 +1,7 @@ - - Microsoft Visual Studio Solution File, Format Version 12.00 --# Visual Studio 14 --VisualStudioVersion = 14.0.25420.1 -+# Visual Studio 15 -+VisualStudioVersion = 15.0.28307.757 - MinimumVisualStudioVersion = 10.0.40219.1 - Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmfx_vs2015", "libmfx_vs2015.vcxproj", "{A9F7AEFB-DC6C-49E8-8E71-5351ABDCE627}" - EndProject -@@ -25,6 +25,9 @@ Global - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -+ GlobalSection(ExtensibilityGlobals) = postSolution -+ SolutionGuid = {94706D6C-B55B-49AB-B136-337F5E9B2FA3} -+ EndGlobalSection - GlobalSection(DPCodeReviewSolutionGUID) = preSolution - DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} - EndGlobalSection +diff --git a/api/mfx_dispatch/windows/libmfx_vs2015.vcxproj b/api/mfx_dispatch/windows/libmfx_vs2015.vcxproj +index fdcdf8c0..0b8ca3bc 100644 --- a/api/mfx_dispatch/windows/libmfx_vs2015.vcxproj +++ b/api/mfx_dispatch/windows/libmfx_vs2015.vcxproj -@@ -79,7 +79,7 @@ +@@ -46,14 +46,14 @@ + <RootNamespace>libmfx</RootNamespace> + <Keyword>Win32Proj</Keyword> + <ProjectName>libmfx_vs2015</ProjectName> +- <WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion> ++ <WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <WholeProgramOptimization>false</WholeProgramOptimization> + <ConfigurationType>StaticLibrary</ConfigurationType> + <CharacterSet>Unicode</CharacterSet> +- <PlatformToolset>v141</PlatformToolset> ++ <PlatformToolset>v143</PlatformToolset> + <SpectreMitigation>Spectre</SpectreMitigation> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> +@@ -64,8 +64,8 @@ + <WholeProgramOptimization>false</WholeProgramOptimization> + <ConfigurationType>StaticLibrary</ConfigurationType> + <CharacterSet>Unicode</CharacterSet> +- <PlatformToolset>v141</PlatformToolset> +- <SpectreMitigation>Spectre</SpectreMitigation> ++ <PlatformToolset>v143</PlatformToolset> ++ <SpectreMitigation>false</SpectreMitigation> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> +@@ -73,17 +73,17 @@ + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <CharacterSet>Unicode</CharacterSet> +- <PlatformToolset>v141</PlatformToolset> ++ <PlatformToolset>v143</PlatformToolset> + <SpectreMitigation>Spectre</SpectreMitigation> + </PropertyGroup> + <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <CharacterSet>Unicode</CharacterSet> +- <PlatformToolset>v141</PlatformToolset> +- <SpectreMitigation>Spectre</SpectreMitigation> ++ <PlatformToolset>v143</PlatformToolset> ++ <SpectreMitigation>false</SpectreMitigation> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <PropertyGroup> @@ -41,7 +61,7 @@ Subject: [PATCH] Copy build output to correct directory <IntDir>$(OutDir)..\objs\$(ProjectName)\</IntDir> <IncludePath>$(MINIDDK_ROOT)\Include\um;$(MINIDDK_ROOT)\Include\shared;$(IncludePath)</IncludePath> <LibraryPath>$(MINIDDK_ROOT)\Lib\win8\um\x86;$(LibraryPath)</LibraryPath> -@@ -88,7 +88,7 @@ +@@ -92,7 +92,7 @@ <TargetName>$(ProjectName)</TargetName> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)'=='Release'"> @@ -50,7 +70,7 @@ Subject: [PATCH] Copy build output to correct directory </PropertyGroup> <ItemDefinitionGroup> <ClCompile> -@@ -199,7 +199,7 @@ +@@ -203,7 +203,7 @@ <AdditionalIncludeDirectories>include;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>WIN64;NDEBUG;_LIB;_ALLOW_MSC_VER_MISMATCH;_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH;_ALLOW_RUNTIME_LIBRARY_MISMATCH;%(PreprocessorDefinitions)</PreprocessorDefinitions> <ExceptionHandling>Async</ExceptionHandling> @@ -59,31 +79,20 @@ Subject: [PATCH] Copy build output to correct directory <BufferSecurityCheck>true</BufferSecurityCheck> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> -@@ -208,6 +208,33 @@ +@@ -212,6 +212,22 @@ <ControlFlowGuard>Guard</ControlFlowGuard> </ClCompile> <Lib /> + <Lib> -+ <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <AdditionalDependencies>Advapi32.lib</AdditionalDependencies> + </Lib> + <PostBuildEvent> + <Command>mkdir "$(OutDir)"..\..\..\..\..\..\msvc\include -+ +mkdir "$(OutDir)"..\..\..\..\..\..\msvc\include\mfx -+ +mkdir "$(OutDir)"..\..\..\..\..\..\msvc\lib -+ +mkdir "$(OutDir)"..\..\..\..\..\..\msvc\lib\x64 -+ +xcopy /S /Y "$(OutDir)"*.lib "$(OutDir)"..\..\..\..\..\..\msvc\lib\x64 -+ -+ -+ -+ +xcopy /S /Y "$(OutDir)"*.pdb "$(OutDir)"..\..\..\..\..\..\msvc\lib\x64 -+ -+ +xcopy /S /Y $(ProjectDir)..\..\..\api\include\*.h "$(OutDir)"..\..\..\..\..\..\msvc\include\mfx +</Command> + </PostBuildEvent> @@ -94,5 +103,5 @@ Subject: [PATCH] Copy build output to correct directory <ItemGroup> <ClCompile Include="src\main.cpp" /> -- -2.22.0.windows.1 +2.37.1.windows.1 diff --git a/contrib/src/x264/package.json b/contrib/src/x264/package.json index 9c06135880d432a7dd73865e136c679808bd0242..634f529710eb053e321b3c164e87fcb467ebdf84 100644 --- a/contrib/src/x264/package.json +++ b/contrib/src/x264/package.json @@ -1,6 +1,6 @@ { "name": "x264", - "version": "5fee86cae91cd7b726db7408a3ed1c4da71fb78c", + "version": "be0cb5426d4b9fecaf2e4b058466322a43f17241", "url": "https://github.com/ShiftMediaProject/x264/archive/__VERSION__.tar.gz", "deps": [], "patches": [], diff --git a/src/client/videomanager.cpp b/src/client/videomanager.cpp index 93ee6a051f6856511337f24838b2de3539d47688..7fd72eeabb5a0506382c6f7c42a737e97a008ed9 100644 --- a/src/client/videomanager.cpp +++ b/src/client/videomanager.cpp @@ -111,8 +111,7 @@ void AudioFrame::setFormat(const jami::AudioFormat& format) { auto d = pointer(); - d->channels = format.nb_channels; - d->channel_layout = av_get_default_channel_layout(format.nb_channels); + av_channel_layout_default(&d->ch_layout, format.nb_channels); d->sample_rate = format.sample_rate; d->format = format.sampleFormat; } @@ -121,7 +120,7 @@ jami::AudioFormat AudioFrame::getFormat() const { return {(unsigned) frame_->sample_rate, - (unsigned) frame_->channels, + (unsigned) frame_->ch_layout.nb_channels, (AVSampleFormat) frame_->format}; } @@ -149,7 +148,7 @@ AudioFrame::mix(const AudioFrame& frame) { auto& f = *pointer(); auto& fIn = *frame.pointer(); - if (f.channels != fIn.channels || f.format != fIn.format || f.sample_rate != fIn.sample_rate) { + if (f.ch_layout.nb_channels != fIn.ch_layout.nb_channels || f.format != fIn.format || f.sample_rate != fIn.sample_rate) { throw std::invalid_argument("Can't mix frames with different formats"); } if (f.nb_samples == 0) { @@ -160,8 +159,8 @@ AudioFrame::mix(const AudioFrame& frame) } AVSampleFormat fmt = (AVSampleFormat) f.format; bool isPlanar = av_sample_fmt_is_planar(fmt); - unsigned samplesPerChannel = isPlanar ? f.nb_samples : f.nb_samples * f.channels; - unsigned channels = isPlanar ? f.channels : 1; + unsigned samplesPerChannel = isPlanar ? f.nb_samples : f.nb_samples * f.ch_layout.nb_channels; + unsigned channels = isPlanar ? f.ch_layout.nb_channels : 1; if (fmt == AV_SAMPLE_FMT_S16 || fmt == AV_SAMPLE_FMT_S16P) { for (unsigned i = 0; i < channels; i++) { auto c = (int16_t*) f.extended_data[i]; @@ -192,8 +191,8 @@ AudioFrame::calcRMS() const double rms = 0.0; auto fmt = static_cast<AVSampleFormat>(frame_->format); bool planar = av_sample_fmt_is_planar(fmt); - int perChannel = planar ? frame_->nb_samples : frame_->nb_samples * frame_->channels; - int channels = planar ? frame_->channels : 1; + int perChannel = planar ? frame_->nb_samples : frame_->nb_samples * frame_->ch_layout.nb_channels; + int channels = planar ? frame_->ch_layout.nb_channels : 1; if (fmt == AV_SAMPLE_FMT_S16 || fmt == AV_SAMPLE_FMT_S16P) { for (int c = 0; c < channels; ++c) { auto buf = reinterpret_cast<int16_t*>(frame_->extended_data[c]); @@ -216,7 +215,7 @@ AudioFrame::calcRMS() const return 0.0; } // divide by the number of multi-byte samples - return sqrt(rms / (frame_->nb_samples * frame_->channels)); + return sqrt(rms / (frame_->nb_samples * frame_->ch_layout.nb_channels)); } #ifdef ENABLE_VIDEO diff --git a/src/debug_utils.h b/src/debug_utils.h index 3e519b7e7efbe54b53c22b9b765320d9a0e7a319..1ddcfd845759260942f3bbaa6998948d38530b00 100644 --- a/src/debug_utils.h +++ b/src/debug_utils.h @@ -123,9 +123,8 @@ public: throw std::runtime_error("Failed to allocate audio codec context"); codec_ctx_->sample_fmt = (AVSampleFormat)frame->format; - codec_ctx_->channel_layout = frame->channel_layout; + codec_ctx_->ch_layout = frame->ch_layout; codec_ctx_->sample_rate = frame->sample_rate; - codec_ctx_->channels = frame->channels; if (format_ctx_->oformat->flags & AVFMT_GLOBALHEADER) codec_ctx_->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; diff --git a/src/media/audio/audio_frame_resizer.cpp b/src/media/audio/audio_frame_resizer.cpp index a6eac9864e8a68645230a38a85f378fafa19fa01..0fc4bad9373844bc363c7bcddf840fbdea41518a 100644 --- a/src/media/audio/audio_frame_resizer.cpp +++ b/src/media/audio/audio_frame_resizer.cpp @@ -95,10 +95,10 @@ AudioFrameResizer::enqueue(std::shared_ptr<AudioFrame>&& frame) int ret = 0; auto f = frame->pointer(); - AudioFormat format(f->sample_rate, f->channels, (AVSampleFormat) f->format); + AudioFormat format(f->sample_rate, f->ch_layout.nb_channels, (AVSampleFormat) f->format); if (format != format_) { JAMI_ERR() << "Expected " << format_ << ", but got " - << AudioFormat(f->sample_rate, f->channels, (AVSampleFormat) f->format); + << AudioFormat(f->sample_rate, f->ch_layout.nb_channels, (AVSampleFormat) f->format); setFormat(format, frameSize_); } diff --git a/src/media/audio/audiobuffer.cpp b/src/media/audio/audiobuffer.cpp index 9ef33c8f1ec76b5f5f216b01618a0065fbc3493c..d3481b2f1a7ea5962ac9499a805d678429ea2aac 100644 --- a/src/media/audio/audiobuffer.cpp +++ b/src/media/audio/audiobuffer.cpp @@ -348,9 +348,9 @@ AudioBuffer::append(const AudioFrame& audioFrame) { auto frame = audioFrame.pointer(); // FIXME we assume frame is s16 interleaved - if (channels() != static_cast<unsigned>(frame->channels) + if (channels() != static_cast<unsigned>(frame->ch_layout.nb_channels) || getSampleRate() != frame->sample_rate) { - auto newFormat = AudioFormat {(unsigned) frame->sample_rate, (unsigned) frame->channels}; + auto newFormat = AudioFormat {(unsigned) frame->sample_rate, (unsigned) frame->ch_layout.nb_channels}; setFormat(newFormat); } diff --git a/src/media/audio/coreaudio/ios/corelayer.mm b/src/media/audio/coreaudio/ios/corelayer.mm index d6006de701d2fec4c7a88c954c5a00cc077fac70..b58b712c3ea687abdc5dd7b1d123997566dafe0b 100644 --- a/src/media/audio/coreaudio/ios/corelayer.mm +++ b/src/media/audio/coreaudio/ios/corelayer.mm @@ -401,7 +401,7 @@ CoreLayer::write(AudioUnitRenderActionFlags* ioActionFlags, if (auto toPlay = getPlayback(currentOutFormat, inNumberFrames)) { const auto& frame = *toPlay->pointer(); - for (unsigned i = 0; i < frame.channels; ++i) { + for (unsigned i = 0; i < frame.ch_layout.nb_channels; ++i) { std::copy_n((Float32*)frame.extended_data[i], inNumberFrames, (Float32*)ioData->mBuffers[i].mData); } } else { diff --git a/src/media/audio/jack/jacklayer.cpp b/src/media/audio/jack/jacklayer.cpp index a9d64a517225e3e45f426d13e31880b9a269d46c..a0cdfa5d4cf44647d6571a049ede58a6442facd2 100644 --- a/src/media/audio/jack/jacklayer.cpp +++ b/src/media/audio/jack/jacklayer.cpp @@ -110,7 +110,7 @@ JackLayer::write(const AudioFrame& buffer) { auto num_samples = buffer.pointer()->nb_samples; auto num_bytes = num_samples * sizeof(float); - auto channels = std::min<size_t>(out_ringbuffers_.size(), buffer.pointer()->channels); + auto channels = std::min<size_t>(out_ringbuffers_.size(), buffer.pointer()->ch_layout.nb_channels); for (size_t i = 0; i < channels; ++i) { jack_ringbuffer_write(out_ringbuffers_[i], (const char*) buffer.pointer()->extended_data[i], diff --git a/src/media/audio/opensl/opensllayer.cpp b/src/media/audio/opensl/opensllayer.cpp index 0ee84fa4648e43dc7beb4295259e231fc99920a9..e0d11b32b7141f3d83a859af2558a95f2a6920ff 100644 --- a/src/media/audio/opensl/opensllayer.cpp +++ b/src/media/audio/opensl/opensllayer.cpp @@ -267,7 +267,7 @@ OpenSLLayer::engineServicePlay() sample_buf* buf; while (player_ and freePlayBufQueue_.front(&buf)) { if (auto dat = getToPlay(hardwareFormat_, hardwareBuffSize_)) { - buf->size_ = dat->pointer()->nb_samples * dat->pointer()->channels + buf->size_ = dat->pointer()->nb_samples * dat->pointer()->ch_layout.nb_channels * sizeof(AudioSample); if (buf->size_ > buf->cap_) { JAMI_ERR("buf->size_(%zu) > buf->cap_(%zu)", buf->size_, buf->cap_); @@ -300,7 +300,7 @@ OpenSLLayer::engineServiceRing() sample_buf* buf; while (ringtone_ and freeRingBufQueue_.front(&buf)) { if (auto dat = getToRing(hardwareFormat_, hardwareBuffSize_)) { - buf->size_ = dat->pointer()->nb_samples * dat->pointer()->channels + buf->size_ = dat->pointer()->nb_samples * dat->pointer()->ch_layout.nb_channels * sizeof(AudioSample); if (buf->size_ > buf->cap_) { JAMI_ERR("buf->size_(%zu) > buf->cap_(%zu)", buf->size_, buf->cap_); diff --git a/src/media/audio/portaudio/portaudiolayer.cpp b/src/media/audio/portaudio/portaudiolayer.cpp index 40c9e2cdc1c6fd74fec652e450f1cc64b6e169a6..81f23bd37e54388d55d9480eb773cd4f8e18eb89 100644 --- a/src/media/audio/portaudio/portaudiolayer.cpp +++ b/src/media/audio/portaudio/portaudiolayer.cpp @@ -736,7 +736,7 @@ PortAudioLayer::PortAudioLayerImpl::paOutputCallback(PortAudioLayer& parent, return paContinue; } - auto nFrames = toPlay->pointer()->nb_samples * toPlay->pointer()->channels; + auto nFrames = toPlay->pointer()->nb_samples * toPlay->pointer()->ch_layout.nb_channels; std::copy_n((AudioSample*) toPlay->pointer()->extended_data[0], nFrames, outputBuffer); return paContinue; } diff --git a/src/media/audio/resampler.cpp b/src/media/audio/resampler.cpp index bce9eaa84ce3c3266ff0121c8546a148f5e37cb9..211fc135fa56663325e4db703a3eaa42736bcbe9 100644 --- a/src/media/audio/resampler.cpp +++ b/src/media/audio/resampler.cpp @@ -50,13 +50,11 @@ Resampler::reinit(const AVFrame* in, const AVFrame* out) throw std::bad_alloc(); } - av_opt_set_int(swrCtx, "ich", in->channels, 0); - av_opt_set_int(swrCtx, "icl", in->channel_layout, 0); + av_opt_set_chlayout(swrCtx, "ichl", &in->ch_layout, 0); av_opt_set_int(swrCtx, "isr", in->sample_rate, 0); av_opt_set_sample_fmt(swrCtx, "isf", static_cast<AVSampleFormat>(in->format), 0); - av_opt_set_int(swrCtx, "och", out->channels, 0); - av_opt_set_int(swrCtx, "ocl", out->channel_layout, 0); + av_opt_set_chlayout(swrCtx, "ochl", &out->ch_layout, 0); av_opt_set_int(swrCtx, "osr", out->sample_rate, 0); av_opt_set_sample_fmt(swrCtx, "osf", static_cast<AVSampleFormat>(out->format), 0); @@ -71,10 +69,10 @@ Resampler::reinit(const AVFrame* in, const AVFrame* out) * LFE downmixing is optional, so any coefficient can be used, we use +6dB for mono and * +0dB in each channel for stereo. */ - if (in->channel_layout == AV_CH_LAYOUT_5POINT1 - || in->channel_layout == AV_CH_LAYOUT_5POINT1_BACK) { + if (in->ch_layout.u.mask == AV_CH_LAYOUT_5POINT1 + || in->ch_layout.u.mask == AV_CH_LAYOUT_5POINT1_BACK) { // NOTE MSVC can't allocate dynamic size arrays on the stack - if (out->channels == 2) { + if (out->ch_layout.nb_channels == 2) { double matrix[2][6]; // L = 1.0*FL + 0.707*FC + 0.707*BL + 1.0*LFE matrix[0][0] = 1; @@ -152,8 +150,7 @@ Resampler::resample(const AudioBuffer& dataIn, AudioBuffer& dataOut) AudioFrame resampled; auto output = resampled.pointer(); output->sample_rate = dataOut.getSampleRate(); - output->channel_layout = av_get_default_channel_layout(dataOut.channels()); - output->channels = dataOut.channels(); + av_channel_layout_default(&output->ch_layout, dataOut.channels()); output->format = AV_SAMPLE_FMT_S16; if (resample(input, output) < 0) @@ -162,14 +159,14 @@ Resampler::resample(const AudioBuffer& dataIn, AudioBuffer& dataOut) dataOut.resize(output->nb_samples); dataOut.deinterleave(reinterpret_cast<const AudioSample*>(output->extended_data[0]), output->nb_samples, - output->channels); + output->ch_layout.nb_channels); } std::unique_ptr<AudioFrame> Resampler::resample(std::unique_ptr<AudioFrame>&& in, const AudioFormat& format) { if (in->pointer()->sample_rate == (int) format.sample_rate - && in->pointer()->channels == (int) format.nb_channels + && in->pointer()->ch_layout.nb_channels == (int) format.nb_channels && (AVSampleFormat) in->pointer()->format == format.sampleFormat) { return std::move(in); } @@ -191,7 +188,7 @@ Resampler::resample(std::shared_ptr<AudioFrame>&& in, const AudioFormat& format) } if (inPtr->sample_rate == (int) format.sample_rate - && inPtr->channels == (int) format.nb_channels + && inPtr->ch_layout.nb_channels == (int) format.nb_channels && (AVSampleFormat) inPtr->format == format.sampleFormat) { return std::move(in); } diff --git a/src/media/audio/resampler.h b/src/media/audio/resampler.h index 3a5bad17e3de3708ee481b6fb189b16407e9fdbc..4b798f4a2cd2da9e919ad491182b15eec21b3de8 100644 --- a/src/media/audio/resampler.h +++ b/src/media/audio/resampler.h @@ -47,7 +47,7 @@ public: * * Resample from @input format to @output format. * - * NOTE: sample_rate, channel_layout, and format should be set on @output + * NOTE: sample_rate, ch_layout, and format should be set on @output */ int resample(const AVFrame* input, AVFrame* output); diff --git a/src/media/libav_utils.cpp b/src/media/libav_utils.cpp index 3e45b1cd0efc51f892ae4021b6ed96528c664903..60cee22898a7a99633645f4d5cfb852995e99bf1 100644 --- a/src/media/libav_utils.cpp +++ b/src/media/libav_utils.cpp @@ -267,7 +267,7 @@ fillWithSilence(AVFrame* frame) int ret = av_samples_set_silence(frame->extended_data, 0, frame->nb_samples, - frame->channels, + frame->ch_layout.nb_channels, (AVSampleFormat) frame->format); if (ret < 0) JAMI_ERR() << "Failed to fill frame with silence"; diff --git a/src/media/media_decoder.cpp b/src/media/media_decoder.cpp index 64ce3d1ad108d23333ea7d84cb4105064156da6c..1bece6d9877136feb2c4c51b624a058408c82368 100644 --- a/src/media/media_decoder.cpp +++ b/src/media/media_decoder.cpp @@ -595,8 +595,6 @@ MediaDecoder::prepareDecoderContext() if (avStream_->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { if (decoderCtx_->framerate.num == 0 || decoderCtx_->framerate.den == 0) decoderCtx_->framerate = inputParams_.framerate; - if (decoderCtx_->framerate.num == 0 || decoderCtx_->framerate.den == 0) - decoderCtx_->framerate = av_inv_q(decoderCtx_->time_base); if (decoderCtx_->framerate.num == 0 || decoderCtx_->framerate.den == 0) decoderCtx_->framerate = {30, 1}; } @@ -643,6 +641,15 @@ MediaDecoder::decode(AVPacket& packet) #endif auto frame = f->pointer(); ret = avcodec_receive_frame(decoderCtx_, frame); + // time_base is not set in AVCodecContext for decoding + // fail to set it causes pts to be incorrectly computed down in the function + if (inputDecoder_->type == AVMEDIA_TYPE_VIDEO) { + decoderCtx_->time_base.num = decoderCtx_->framerate.den; + decoderCtx_->time_base.den = decoderCtx_->framerate.num; + } else { + decoderCtx_->time_base.num = 1; + decoderCtx_->time_base.den = decoderCtx_->sample_rate; + } frame->time_base = decoderCtx_->time_base; if (resolutionChangedCallback_) { if (decoderCtx_->width != width_ or decoderCtx_->height != height_) { @@ -663,11 +670,8 @@ MediaDecoder::decode(AVPacket& packet) frameFinished = 1; if (frameFinished) { - // channel layout is needed if frame will be resampled - if (!frame->channel_layout) - frame->channel_layout = av_get_default_channel_layout(frame->channels); - - frame->format = (AVPixelFormat) correctPixFmt(frame->format); + if (inputDecoder_->type == AVMEDIA_TYPE_VIDEO) + frame->format = (AVPixelFormat) correctPixFmt(frame->format); auto packetTimestamp = frame->pts; // in stream time base frame->pts = av_rescale_q_rnd(av_gettime() - startTime_, {1, AV_TIME_BASE}, diff --git a/src/media/media_encoder.cpp b/src/media/media_encoder.cpp index 1316ac442d5bbadd37a7eb6f2c4509475961a66f..b767e2f123e7ba0f357d82a1c304c86c14adf696 100644 --- a/src/media/media_encoder.cpp +++ b/src/media/media_encoder.cpp @@ -641,14 +641,11 @@ MediaEncoder::prepareEncoderContext(const AVCodec* outputCodec, bool is_video) encoderCtx->sample_rate = std::max(8000, audioOpts_.sampleRate); encoderCtx->time_base = AVRational {1, encoderCtx->sample_rate}; if (audioOpts_.nbChannels > 2 || audioOpts_.nbChannels < 1) { - encoderCtx->channels = std::clamp(audioOpts_.nbChannels, 1, 2); + audioOpts_.nbChannels = std::clamp(audioOpts_.nbChannels, 1, 2); JAMI_ERR() << "[" << encoderName - << "] Clamping invalid channel count: " << audioOpts_.nbChannels << " -> " - << encoderCtx->channels; - } else { - encoderCtx->channels = audioOpts_.nbChannels; + << "] Clamping invalid channel count: " << audioOpts_.nbChannels; } - encoderCtx->channel_layout = av_get_default_channel_layout(encoderCtx->channels); + av_channel_layout_default(&encoderCtx->ch_layout, audioOpts_.nbChannels); if (audioOpts_.frameSize) { encoderCtx->frame_size = audioOpts_.frameSize; JAMI_DBG() << "[" << encoderName << "] Frame size " << encoderCtx->frame_size; diff --git a/src/media/media_filter.cpp b/src/media/media_filter.cpp index cb5023732b40c6c3b522d62772abea5d1c4835c3..8ad37995938123281d88fe2ed62f3ee7fbb80e95 100644 --- a/src/media/media_filter.cpp +++ b/src/media/media_filter.cpp @@ -171,7 +171,7 @@ MediaFilter::feedInput(AVFrame* frame, const std::string& inputName) if (ms.format != frame->format || (ms.isVideo && (ms.width != frame->width || ms.height != frame->height)) || (!ms.isVideo - && (ms.sampleRate != frame->sample_rate || ms.nbChannels != frame->channels))) { + && (ms.sampleRate != frame->sample_rate || ms.nbChannels != frame->ch_layout.nb_channels))) { ms.update(frame); if ((ret = reinitialize()) < 0) return fail("Failed to reinitialize filter with new input parameters", ret); @@ -283,7 +283,7 @@ MediaFilter::initInputFilter(AVFilterInOut* in, const MediaStream& msp) buffersrc = avfilter_get_by_name("buffer"); } else { params->sample_rate = msp.sampleRate; - params->channel_layout = av_get_default_channel_layout(msp.nbChannels); + av_channel_layout_default(¶ms->ch_layout, msp.nbChannels); buffersrc = avfilter_get_by_name("abuffer"); } diff --git a/src/media/media_recorder.cpp b/src/media/media_recorder.cpp index efa8b0d53ec20949cdb041bc708f7928ff9334dc..58fec39906b70fc87d55891d51370285f828ecb1 100644 --- a/src/media/media_recorder.cpp +++ b/src/media/media_recorder.cpp @@ -576,7 +576,7 @@ std::string MediaRecorder::buildAudioFilter(const std::vector<MediaStream>& peers, const MediaStream& local) const { - std::string baseFilter = "aresample=osr=48000:ocl=stereo:osf=s16"; + std::string baseFilter = "aresample=osr=48000:ochl=stereo:osf=s16"; std::stringstream a; switch (peers.size()) { diff --git a/src/media/media_stream.h b/src/media/media_stream.h index 1ede1c6026dd3c9c4efdad9f99e7f3b2462f43ef..34c0ef7578ea62aa2d060da48a5de1bf561b25c0 100644 --- a/src/media/media_stream.h +++ b/src/media/media_stream.h @@ -112,7 +112,7 @@ struct MediaStream format = c->sample_fmt; isVideo = false; sampleRate = c->sample_rate; - nbChannels = c->channels; + nbChannels = c->ch_layout.nb_channels; frameSize = c->frame_size; break; default: @@ -144,7 +144,7 @@ struct MediaStream height = f->height; } else { sampleRate = f->sample_rate; - nbChannels = f->channels; + nbChannels = f->ch_layout.nb_channels; timeBase = rational<int>(1, f->sample_rate); if (!frameSize) frameSize = f->nb_samples; diff --git a/src/media/video/accel.cpp b/src/media/video/accel.cpp index 344bfbd008dd2bdc52aab8ad4b5c94acce2f55ce..bf206e39c4653b3aa100a94e2cb5cfe5e9d439ff 100644 --- a/src/media/video/accel.cpp +++ b/src/media/video/accel.cpp @@ -313,7 +313,6 @@ HardwareAccel::setDetails(AVCodecContext* codecCtx) if (type_ == CODEC_DECODER) { codecCtx->hw_device_ctx = av_buffer_ref(deviceCtx_); codecCtx->get_format = getFormatCb; - codecCtx->thread_safe_callbacks = 1; } else if (type_ == CODEC_ENCODER) { if (framesCtx_) // encoder doesn't need a device context, only a frame context diff --git a/test/unitTest/media/audio/test_audio_frame_resizer.cpp b/test/unitTest/media/audio/test_audio_frame_resizer.cpp index 5e783f264d98003ca144e8519ddf8919dfc8540a..7209a4b49bc977eae9dca71032d1d69d5bec30f8 100644 --- a/test/unitTest/media/audio/test_audio_frame_resizer.cpp +++ b/test/unitTest/media/audio/test_audio_frame_resizer.cpp @@ -74,8 +74,7 @@ AudioFrameResizerTest::getFrame(int n) auto frame = std::make_shared<AudioFrame>(); frame->pointer()->format = format_.sampleFormat; frame->pointer()->sample_rate = format_.sample_rate; - frame->pointer()->channels = format_.nb_channels; - frame->pointer()->channel_layout = av_get_default_channel_layout(format_.nb_channels); + av_channel_layout_default(&frame->pointer()->ch_layout, format_.nb_channels); frame->pointer()->nb_samples = n; CPPUNIT_ASSERT(av_frame_get_buffer(frame->pointer(), 0) >= 0); return frame; diff --git a/test/unitTest/media/audio/test_resampler.cpp b/test/unitTest/media/audio/test_resampler.cpp index 3869ab3024699b28e3fbb68c6a0b2b855d771577..ad5e4d911dedb4f2f2954631bcd0ec963a196e0a 100644 --- a/test/unitTest/media/audio/test_resampler.cpp +++ b/test/unitTest/media/audio/test_resampler.cpp @@ -98,8 +98,7 @@ ResamplerTest::testAudioFrame() auto output = out.pointer(); output->format = AV_SAMPLE_FMT_FLT; output->sample_rate = 48000; - output->channel_layout = AV_CH_LAYOUT_STEREO; - output->channels = 2; + av_channel_layout_from_mask(&output->ch_layout, AV_CH_LAYOUT_STEREO); int ret = resampler_->resample(input->pointer(), output); CPPUNIT_ASSERT_MESSAGE(libav_utils::getError(ret).c_str(), ret >= 0); diff --git a/test/unitTest/media/test_media_decoder.cpp b/test/unitTest/media/test_media_decoder.cpp index 0ce268d728a9a3fbbc700f1280fecb875a2b6d5a..1cb2ed3481d455f07d6b4038832d4d59ea89e115 100644 --- a/test/unitTest/media/test_media_decoder.cpp +++ b/test/unitTest/media/test_media_decoder.cpp @@ -81,7 +81,7 @@ MediaDecoderTest::testAudioFile() decoder_.reset(new MediaDecoder([this](const std::shared_ptr<MediaFrame>&& f) mutable { CPPUNIT_ASSERT(f->pointer()->sample_rate == decoder_->getStream().sampleRate); - CPPUNIT_ASSERT(f->pointer()->channels == decoder_->getStream().nbChannels); + CPPUNIT_ASSERT(f->pointer()->ch_layout.nb_channels == decoder_->getStream().nbChannels); })); DeviceParams dev; dev.input = filename_; diff --git a/test/unitTest/media/test_media_encoder.cpp b/test/unitTest/media/test_media_encoder.cpp index b077bdfa679651b74d82606414124fc0e661365b..483af9927c6f7a0684ed3b879d42dc90b95fbc0d 100644 --- a/test/unitTest/media/test_media_encoder.cpp +++ b/test/unitTest/media/test_media_encoder.cpp @@ -115,8 +115,7 @@ getAudioFrame(int sampleRate, int nbSamples, int nbChannels) return nullptr; frame->format = AV_SAMPLE_FMT_S16; - frame->channels = nbChannels; - frame->channel_layout = av_get_default_channel_layout(nbChannels); + av_channel_layout_default(&frame->ch_layout, nbChannels); frame->nb_samples = nbSamples; frame->sample_rate = sampleRate; diff --git a/test/unitTest/media/test_media_filter.cpp b/test/unitTest/media/test_media_filter.cpp index 1b2767c3959db33a4a5d0fecbdf2803fa344774a..8d09b2c6607dc6bc5b5086e48b7cc196ff6c23e4 100644 --- a/test/unitTest/media/test_media_filter.cpp +++ b/test/unitTest/media/test_media_filter.cpp @@ -116,13 +116,12 @@ static void fillAudioFrameProps(AVFrame* frame, const MediaStream& ms) { frame->format = ms.format; - frame->channel_layout = av_get_default_channel_layout(ms.nbChannels); + av_channel_layout_default(&frame->ch_layout, ms.nbChannels); frame->nb_samples = ms.frameSize; frame->sample_rate = ms.sampleRate; - frame->channels = ms.nbChannels; CPPUNIT_ASSERT(frame->format > AV_SAMPLE_FMT_NONE); CPPUNIT_ASSERT(frame->nb_samples > 0); - CPPUNIT_ASSERT(frame->channel_layout != 0); + CPPUNIT_ASSERT(frame->ch_layout.u.mask != 0); } void @@ -132,7 +131,6 @@ MediaFilterTest::testAudioFilter() // constants const constexpr int nbSamples = 100; - const constexpr int64_t channelLayout = AV_CH_LAYOUT_STEREO; const constexpr int sampleRate = 44100; const constexpr enum AVSampleFormat format = AV_SAMPLE_FMT_S16; @@ -140,17 +138,16 @@ MediaFilterTest::testAudioFilter() AudioFrame af; auto frame = af.pointer(); frame->format = format; - frame->channel_layout = channelLayout; + av_channel_layout_from_mask(&frame->ch_layout, AV_CH_LAYOUT_STEREO); frame->nb_samples = nbSamples; frame->sample_rate = sampleRate; - frame->channels = av_get_channel_layout_nb_channels(channelLayout); // construct the filter parameters - auto params = MediaStream("in1", format, rational<int>(1, sampleRate), sampleRate, frame->channels, nbSamples); + auto params = MediaStream("in1", format, rational<int>(1, sampleRate), sampleRate, frame->ch_layout.nb_channels, nbSamples); // allocate and fill frame buffers CPPUNIT_ASSERT(av_frame_get_buffer(frame, 0) >= 0); - fill_samples(reinterpret_cast<uint16_t*>(frame->data[0]), sampleRate, nbSamples, frame->channels, 440.0); + fill_samples(reinterpret_cast<uint16_t*>(frame->data[0]), sampleRate, nbSamples, frame->ch_layout.nb_channels, 440.0); // prepare filter std::vector<MediaStream> vec; @@ -190,17 +187,17 @@ MediaFilterTest::testAudioMixing() fillAudioFrameProps(frame1, vec[0]); frame1->pts = i * frame1->nb_samples; CPPUNIT_ASSERT(av_frame_get_buffer(frame1, 0) >= 0); - fill_samples(reinterpret_cast<uint16_t*>(frame1->data[0]), frame1->sample_rate, frame1->nb_samples, frame1->channels, 440.0, t1); + fill_samples(reinterpret_cast<uint16_t*>(frame1->data[0]), frame1->sample_rate, frame1->nb_samples, frame1->ch_layout.nb_channels, 440.0, t1); fillAudioFrameProps(frame2, vec[1]); frame2->pts = i * frame2->nb_samples; CPPUNIT_ASSERT(av_frame_get_buffer(frame2, 0) >= 0); - fill_samples(reinterpret_cast<uint16_t*>(frame2->data[0]), frame2->sample_rate, frame2->nb_samples, frame2->channels, 329.6276, t2); + fill_samples(reinterpret_cast<uint16_t*>(frame2->data[0]), frame2->sample_rate, frame2->nb_samples, frame2->ch_layout.nb_channels, 329.6276, t2); fillAudioFrameProps(frame3, vec[2]); frame3->pts = i * frame3->nb_samples; CPPUNIT_ASSERT(av_frame_get_buffer(frame3, 0) >= 0); - fill_samples(reinterpret_cast<uint16_t*>(frame3->data[0]), frame3->sample_rate, frame3->nb_samples, frame3->channels, 349.2282, t3); + fill_samples(reinterpret_cast<uint16_t*>(frame3->data[0]), frame3->sample_rate, frame3->nb_samples, frame3->ch_layout.nb_channels, 349.2282, t3); // apply filter CPPUNIT_ASSERT(filter_->feedInput(frame1, "a1") >= 0); @@ -318,17 +315,16 @@ MediaFilterTest::testReinit() AudioFrame af; auto frame = af.pointer(); frame->format = AV_SAMPLE_FMT_S16; - frame->channel_layout = AV_CH_LAYOUT_STEREO; + av_channel_layout_from_mask(&frame->ch_layout, AV_CH_LAYOUT_STEREO); frame->nb_samples = 100; frame->sample_rate = 44100; - frame->channels = 2; // construct the filter parameters with different sample rate - auto params = MediaStream("in1", frame->format, rational<int>(1, 16000), 16000, frame->channels, frame->nb_samples); + auto params = MediaStream("in1", frame->format, rational<int>(1, 16000), 16000, frame->ch_layout.nb_channels, frame->nb_samples); // allocate and fill frame buffers CPPUNIT_ASSERT(av_frame_get_buffer(frame, 0) >= 0); - fill_samples(reinterpret_cast<uint16_t*>(frame->data[0]), frame->sample_rate, frame->nb_samples, frame->channels, 440.0); + fill_samples(reinterpret_cast<uint16_t*>(frame->data[0]), frame->sample_rate, frame->nb_samples, frame->ch_layout.nb_channels, 440.0); // prepare filter std::vector<MediaStream> vec;