2013-01-29 12:09:21 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_AUDIO_CODING_NETEQ_NETEQ_IMPL_H_
|
|
|
|
|
#define MODULES_AUDIO_CODING_NETEQ_NETEQ_IMPL_H_
|
2013-01-29 12:09:21 +00:00
|
|
|
|
Reland "Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.""
This reverts commit fab3460a821abe336ab610c6d6dfc0d392dac263.
Reason for revert: fix downstream instead
Original change's description:
> Revert "Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.""
>
> This reverts commit 9973933d2e606d64fcdc753acb9ba3afd6e30569.
>
> Reason for revert: breaking downstream projects and not reviewed by direct owners
>
> Original change's description:
> > Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker."
> >
> > This reverts commit 24192c267a40eb7d6b1850489ccdbf7a84f8ff0f.
> >
> > Reason for revert: Analyzed the performance regression in more detail.
> >
> > Most of the regression comes from the extra RtpPacketInfos-related memory allocations in every `NetEq::GetAudio()` call. Commit 1796a820f60cb9429bf4bcf13a40a41794ac8fb0 has removed roughly 2/3rds of the extra allocations from the impacted perf tests. Remaining perf impact is expected to be about "8 microseconds of CPU time per second" on the Linux benchmarking machines and "15 us per second" on Windows/Mac.
> >
> > There are options to optimize further but they are unlikely worth doing. Note for example that `NetEqPerformanceTest` uses the PCM codec while the real-world use cases would likely use the much heavier Opus codec. The numbers from `OpusSpeedTest` and `NetEqPerformanceTest` suggest that Opus decoding is about 10x as expensive as NetEq overall.
> >
> > Original change's description:
> > > Revert "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker."
> > >
> > > This reverts commit 3e8ef940fe86cf6285afb80e68d2a0bedc631b9f.
> > >
> > > Reason for revert: This CL causes a performance regression in NetEq, see https://bugs.chromium.org/p/chromium/issues/detail?id=982260.
> > >
> > > Original change's description:
> > > > Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.
> > > >
> > > > This change adds the plumbing of RtpPacketInfo from ChannelReceive::OnRtpPacket() to ChannelReceive::GetAudioFrameWithInfo() for audio. It is a step towards replacing the non-spec compliant ContributingSources that updates itself at packet-receive time, with the spec-compliant SourceTracker that will update itself at frame-delivery-to-track time.
> > > >
> > > > Bug: webrtc:10668
> > > > Change-Id: I03385d6865bbc7bfbef7634f88de820a934f787a
> > > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/139890
> > > > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > > > Reviewed-by: Minyue Li <minyue@webrtc.org>
> > > > Commit-Queue: Chen Xing <chxg@google.com>
> > > > Cr-Commit-Position: refs/heads/master@{#28434}
> > >
> > > TBR=kwiberg@webrtc.org,stefan@webrtc.org,minyue@webrtc.org,chxg@google.com
> > >
> > > Bug: webrtc:10668, chromium:982260
> > > Change-Id: I5e2cfde78c59d1123e21869564d76ed3f6193a5c
> > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/145339
> > > Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
> > > Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
> > > Cr-Commit-Position: refs/heads/master@{#28561}
> >
> > TBR=kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
> >
> > # Not skipping CQ checks because original CL landed > 1 day ago.
> >
> > Bug: webrtc:10668, chromium:982260
> > Change-Id: Ie375a0b327ee368317bf3a04b2f1415c3a974470
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146707
> > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > Commit-Queue: Chen Xing <chxg@google.com>
> > Cr-Commit-Position: refs/heads/master@{#28664}
>
> TBR=kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
>
> Change-Id: I652cb0814d83b514d3bee34e65ca3bb693099b22
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:10668, chromium:982260
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146712
> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#28671}
TBR=alessiob@webrtc.org,kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
Change-Id: Id43b7b3da79b4f48004b41767482bae1c1fa1e16
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:10668, chromium:982260
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146713
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28672}
2019-07-24 16:47:02 +00:00
|
|
|
#include <map>
|
2016-02-14 09:28:33 -08:00
|
|
|
#include <memory>
|
2015-12-09 06:20:58 -08:00
|
|
|
#include <string>
|
Reland "Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.""
This reverts commit fab3460a821abe336ab610c6d6dfc0d392dac263.
Reason for revert: fix downstream instead
Original change's description:
> Revert "Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.""
>
> This reverts commit 9973933d2e606d64fcdc753acb9ba3afd6e30569.
>
> Reason for revert: breaking downstream projects and not reviewed by direct owners
>
> Original change's description:
> > Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker."
> >
> > This reverts commit 24192c267a40eb7d6b1850489ccdbf7a84f8ff0f.
> >
> > Reason for revert: Analyzed the performance regression in more detail.
> >
> > Most of the regression comes from the extra RtpPacketInfos-related memory allocations in every `NetEq::GetAudio()` call. Commit 1796a820f60cb9429bf4bcf13a40a41794ac8fb0 has removed roughly 2/3rds of the extra allocations from the impacted perf tests. Remaining perf impact is expected to be about "8 microseconds of CPU time per second" on the Linux benchmarking machines and "15 us per second" on Windows/Mac.
> >
> > There are options to optimize further but they are unlikely worth doing. Note for example that `NetEqPerformanceTest` uses the PCM codec while the real-world use cases would likely use the much heavier Opus codec. The numbers from `OpusSpeedTest` and `NetEqPerformanceTest` suggest that Opus decoding is about 10x as expensive as NetEq overall.
> >
> > Original change's description:
> > > Revert "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker."
> > >
> > > This reverts commit 3e8ef940fe86cf6285afb80e68d2a0bedc631b9f.
> > >
> > > Reason for revert: This CL causes a performance regression in NetEq, see https://bugs.chromium.org/p/chromium/issues/detail?id=982260.
> > >
> > > Original change's description:
> > > > Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.
> > > >
> > > > This change adds the plumbing of RtpPacketInfo from ChannelReceive::OnRtpPacket() to ChannelReceive::GetAudioFrameWithInfo() for audio. It is a step towards replacing the non-spec compliant ContributingSources that updates itself at packet-receive time, with the spec-compliant SourceTracker that will update itself at frame-delivery-to-track time.
> > > >
> > > > Bug: webrtc:10668
> > > > Change-Id: I03385d6865bbc7bfbef7634f88de820a934f787a
> > > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/139890
> > > > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > > > Reviewed-by: Minyue Li <minyue@webrtc.org>
> > > > Commit-Queue: Chen Xing <chxg@google.com>
> > > > Cr-Commit-Position: refs/heads/master@{#28434}
> > >
> > > TBR=kwiberg@webrtc.org,stefan@webrtc.org,minyue@webrtc.org,chxg@google.com
> > >
> > > Bug: webrtc:10668, chromium:982260
> > > Change-Id: I5e2cfde78c59d1123e21869564d76ed3f6193a5c
> > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/145339
> > > Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
> > > Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
> > > Cr-Commit-Position: refs/heads/master@{#28561}
> >
> > TBR=kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
> >
> > # Not skipping CQ checks because original CL landed > 1 day ago.
> >
> > Bug: webrtc:10668, chromium:982260
> > Change-Id: Ie375a0b327ee368317bf3a04b2f1415c3a974470
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146707
> > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > Commit-Queue: Chen Xing <chxg@google.com>
> > Cr-Commit-Position: refs/heads/master@{#28664}
>
> TBR=kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
>
> Change-Id: I652cb0814d83b514d3bee34e65ca3bb693099b22
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:10668, chromium:982260
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146712
> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#28671}
TBR=alessiob@webrtc.org,kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
Change-Id: Id43b7b3da79b4f48004b41767482bae1c1fa1e16
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:10668, chromium:982260
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146713
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28672}
2019-07-24 16:47:02 +00:00
|
|
|
#include <utility>
|
|
|
|
|
#include <vector>
|
2015-12-09 06:20:58 -08:00
|
|
|
|
2018-06-19 13:26:36 +02:00
|
|
|
#include "absl/types/optional.h"
|
2018-04-12 22:44:09 +02:00
|
|
|
#include "api/audio/audio_frame.h"
|
2019-10-31 14:38:11 +01:00
|
|
|
#include "api/neteq/neteq.h"
|
|
|
|
|
#include "api/neteq/neteq_controller.h"
|
|
|
|
|
#include "api/neteq/neteq_controller_factory.h"
|
|
|
|
|
#include "api/neteq/tick_timer.h"
|
Reland "Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.""
This reverts commit fab3460a821abe336ab610c6d6dfc0d392dac263.
Reason for revert: fix downstream instead
Original change's description:
> Revert "Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.""
>
> This reverts commit 9973933d2e606d64fcdc753acb9ba3afd6e30569.
>
> Reason for revert: breaking downstream projects and not reviewed by direct owners
>
> Original change's description:
> > Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker."
> >
> > This reverts commit 24192c267a40eb7d6b1850489ccdbf7a84f8ff0f.
> >
> > Reason for revert: Analyzed the performance regression in more detail.
> >
> > Most of the regression comes from the extra RtpPacketInfos-related memory allocations in every `NetEq::GetAudio()` call. Commit 1796a820f60cb9429bf4bcf13a40a41794ac8fb0 has removed roughly 2/3rds of the extra allocations from the impacted perf tests. Remaining perf impact is expected to be about "8 microseconds of CPU time per second" on the Linux benchmarking machines and "15 us per second" on Windows/Mac.
> >
> > There are options to optimize further but they are unlikely worth doing. Note for example that `NetEqPerformanceTest` uses the PCM codec while the real-world use cases would likely use the much heavier Opus codec. The numbers from `OpusSpeedTest` and `NetEqPerformanceTest` suggest that Opus decoding is about 10x as expensive as NetEq overall.
> >
> > Original change's description:
> > > Revert "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker."
> > >
> > > This reverts commit 3e8ef940fe86cf6285afb80e68d2a0bedc631b9f.
> > >
> > > Reason for revert: This CL causes a performance regression in NetEq, see https://bugs.chromium.org/p/chromium/issues/detail?id=982260.
> > >
> > > Original change's description:
> > > > Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.
> > > >
> > > > This change adds the plumbing of RtpPacketInfo from ChannelReceive::OnRtpPacket() to ChannelReceive::GetAudioFrameWithInfo() for audio. It is a step towards replacing the non-spec compliant ContributingSources that updates itself at packet-receive time, with the spec-compliant SourceTracker that will update itself at frame-delivery-to-track time.
> > > >
> > > > Bug: webrtc:10668
> > > > Change-Id: I03385d6865bbc7bfbef7634f88de820a934f787a
> > > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/139890
> > > > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > > > Reviewed-by: Minyue Li <minyue@webrtc.org>
> > > > Commit-Queue: Chen Xing <chxg@google.com>
> > > > Cr-Commit-Position: refs/heads/master@{#28434}
> > >
> > > TBR=kwiberg@webrtc.org,stefan@webrtc.org,minyue@webrtc.org,chxg@google.com
> > >
> > > Bug: webrtc:10668, chromium:982260
> > > Change-Id: I5e2cfde78c59d1123e21869564d76ed3f6193a5c
> > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/145339
> > > Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
> > > Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
> > > Cr-Commit-Position: refs/heads/master@{#28561}
> >
> > TBR=kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
> >
> > # Not skipping CQ checks because original CL landed > 1 day ago.
> >
> > Bug: webrtc:10668, chromium:982260
> > Change-Id: Ie375a0b327ee368317bf3a04b2f1415c3a974470
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146707
> > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > Commit-Queue: Chen Xing <chxg@google.com>
> > Cr-Commit-Position: refs/heads/master@{#28664}
>
> TBR=kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
>
> Change-Id: I652cb0814d83b514d3bee34e65ca3bb693099b22
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:10668, chromium:982260
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146712
> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#28671}
TBR=alessiob@webrtc.org,kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
Change-Id: Id43b7b3da79b4f48004b41767482bae1c1fa1e16
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:10668, chromium:982260
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146713
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28672}
2019-07-24 16:47:02 +00:00
|
|
|
#include "api/rtp_packet_info.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_coding/neteq/audio_multi_vector.h"
|
2018-04-10 15:10:26 +02:00
|
|
|
#include "modules/audio_coding/neteq/expand_uma_logger.h"
|
2018-10-23 12:03:01 +02:00
|
|
|
#include "modules/audio_coding/neteq/packet.h"
|
2023-11-27 13:20:27 +01:00
|
|
|
#include "modules/audio_coding/neteq/packet_buffer.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_coding/neteq/random_vector.h"
|
|
|
|
|
#include "modules/audio_coding/neteq/statistics_calculator.h"
|
2020-07-07 15:53:34 +02:00
|
|
|
#include "rtc_base/synchronization/mutex.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/thread_annotations.h"
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
// Forward declarations.
|
2013-09-18 12:19:50 +00:00
|
|
|
class Accelerate;
|
2013-01-29 12:09:21 +00:00
|
|
|
class BackgroundNoise;
|
Reland "Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.""
This reverts commit fab3460a821abe336ab610c6d6dfc0d392dac263.
Reason for revert: fix downstream instead
Original change's description:
> Revert "Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.""
>
> This reverts commit 9973933d2e606d64fcdc753acb9ba3afd6e30569.
>
> Reason for revert: breaking downstream projects and not reviewed by direct owners
>
> Original change's description:
> > Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker."
> >
> > This reverts commit 24192c267a40eb7d6b1850489ccdbf7a84f8ff0f.
> >
> > Reason for revert: Analyzed the performance regression in more detail.
> >
> > Most of the regression comes from the extra RtpPacketInfos-related memory allocations in every `NetEq::GetAudio()` call. Commit 1796a820f60cb9429bf4bcf13a40a41794ac8fb0 has removed roughly 2/3rds of the extra allocations from the impacted perf tests. Remaining perf impact is expected to be about "8 microseconds of CPU time per second" on the Linux benchmarking machines and "15 us per second" on Windows/Mac.
> >
> > There are options to optimize further but they are unlikely worth doing. Note for example that `NetEqPerformanceTest` uses the PCM codec while the real-world use cases would likely use the much heavier Opus codec. The numbers from `OpusSpeedTest` and `NetEqPerformanceTest` suggest that Opus decoding is about 10x as expensive as NetEq overall.
> >
> > Original change's description:
> > > Revert "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker."
> > >
> > > This reverts commit 3e8ef940fe86cf6285afb80e68d2a0bedc631b9f.
> > >
> > > Reason for revert: This CL causes a performance regression in NetEq, see https://bugs.chromium.org/p/chromium/issues/detail?id=982260.
> > >
> > > Original change's description:
> > > > Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.
> > > >
> > > > This change adds the plumbing of RtpPacketInfo from ChannelReceive::OnRtpPacket() to ChannelReceive::GetAudioFrameWithInfo() for audio. It is a step towards replacing the non-spec compliant ContributingSources that updates itself at packet-receive time, with the spec-compliant SourceTracker that will update itself at frame-delivery-to-track time.
> > > >
> > > > Bug: webrtc:10668
> > > > Change-Id: I03385d6865bbc7bfbef7634f88de820a934f787a
> > > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/139890
> > > > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > > > Reviewed-by: Minyue Li <minyue@webrtc.org>
> > > > Commit-Queue: Chen Xing <chxg@google.com>
> > > > Cr-Commit-Position: refs/heads/master@{#28434}
> > >
> > > TBR=kwiberg@webrtc.org,stefan@webrtc.org,minyue@webrtc.org,chxg@google.com
> > >
> > > Bug: webrtc:10668, chromium:982260
> > > Change-Id: I5e2cfde78c59d1123e21869564d76ed3f6193a5c
> > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/145339
> > > Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
> > > Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
> > > Cr-Commit-Position: refs/heads/master@{#28561}
> >
> > TBR=kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
> >
> > # Not skipping CQ checks because original CL landed > 1 day ago.
> >
> > Bug: webrtc:10668, chromium:982260
> > Change-Id: Ie375a0b327ee368317bf3a04b2f1415c3a974470
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146707
> > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > Commit-Queue: Chen Xing <chxg@google.com>
> > Cr-Commit-Position: refs/heads/master@{#28664}
>
> TBR=kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
>
> Change-Id: I652cb0814d83b514d3bee34e65ca3bb693099b22
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:10668, chromium:982260
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146712
> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#28671}
TBR=alessiob@webrtc.org,kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
Change-Id: Id43b7b3da79b4f48004b41767482bae1c1fa1e16
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:10668, chromium:982260
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146713
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28672}
2019-07-24 16:47:02 +00:00
|
|
|
class Clock;
|
2013-01-29 12:09:21 +00:00
|
|
|
class ComfortNoise;
|
|
|
|
|
class DecoderDatabase;
|
|
|
|
|
class DtmfBuffer;
|
|
|
|
|
class DtmfToneGenerator;
|
|
|
|
|
class Expand;
|
2013-09-18 12:19:50 +00:00
|
|
|
class Merge;
|
2016-06-08 06:43:41 -07:00
|
|
|
class NackTracker;
|
2013-09-18 12:19:50 +00:00
|
|
|
class Normal;
|
2016-09-22 02:06:28 -07:00
|
|
|
class RedPayloadSplitter;
|
2013-09-18 12:19:50 +00:00
|
|
|
class PreemptiveExpand;
|
2013-01-29 12:09:21 +00:00
|
|
|
class RandomVector;
|
|
|
|
|
class SyncBuffer;
|
|
|
|
|
class TimestampScaler;
|
2014-01-14 10:18:45 +00:00
|
|
|
struct AccelerateFactory;
|
2013-01-29 12:09:21 +00:00
|
|
|
struct DtmfEvent;
|
2014-01-14 10:18:45 +00:00
|
|
|
struct ExpandFactory;
|
|
|
|
|
struct PreemptiveExpandFactory;
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
class NetEqImpl : public webrtc::NetEq {
|
|
|
|
|
public:
|
2019-08-07 18:15:08 +02:00
|
|
|
enum class OutputType {
|
|
|
|
|
kNormalSpeech,
|
|
|
|
|
kPLC,
|
|
|
|
|
kCNG,
|
|
|
|
|
kPLCCNG,
|
|
|
|
|
kVadPassive,
|
|
|
|
|
kCodecPLC
|
|
|
|
|
};
|
2016-03-08 02:37:57 -08:00
|
|
|
|
2017-06-14 12:29:03 +02:00
|
|
|
enum ErrorCodes {
|
|
|
|
|
kNoError = 0,
|
|
|
|
|
kOtherError,
|
|
|
|
|
kUnknownRtpPayloadType,
|
|
|
|
|
kDecoderNotFound,
|
|
|
|
|
kInvalidPointer,
|
|
|
|
|
kAccelerateError,
|
|
|
|
|
kPreemptiveExpandError,
|
|
|
|
|
kComfortNoiseErrorCode,
|
|
|
|
|
kDecoderErrorCode,
|
|
|
|
|
kOtherDecoderError,
|
|
|
|
|
kInvalidOperation,
|
|
|
|
|
kDtmfParsingError,
|
|
|
|
|
kDtmfInsertError,
|
|
|
|
|
kSampleUnderrun,
|
|
|
|
|
kDecodedTooMuch,
|
|
|
|
|
kRedundancySplitError,
|
|
|
|
|
kPacketBufferCorruption
|
|
|
|
|
};
|
|
|
|
|
|
2016-04-26 12:19:34 -07:00
|
|
|
struct Dependencies {
|
|
|
|
|
// The constructor populates the Dependencies struct with the default
|
|
|
|
|
// implementations of the objects. They can all be replaced by the user
|
|
|
|
|
// before sending the struct to the NetEqImpl constructor. However, there
|
|
|
|
|
// are dependencies between some of the classes inside the struct, so
|
|
|
|
|
// swapping out one may make it necessary to re-create another one.
|
2019-10-31 14:38:11 +01:00
|
|
|
Dependencies(const NetEq::Config& config,
|
|
|
|
|
Clock* clock,
|
|
|
|
|
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory,
|
|
|
|
|
const NetEqControllerFactory& controller_factory);
|
2016-04-26 12:19:34 -07:00
|
|
|
~Dependencies();
|
|
|
|
|
|
Reland "Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.""
This reverts commit fab3460a821abe336ab610c6d6dfc0d392dac263.
Reason for revert: fix downstream instead
Original change's description:
> Revert "Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.""
>
> This reverts commit 9973933d2e606d64fcdc753acb9ba3afd6e30569.
>
> Reason for revert: breaking downstream projects and not reviewed by direct owners
>
> Original change's description:
> > Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker."
> >
> > This reverts commit 24192c267a40eb7d6b1850489ccdbf7a84f8ff0f.
> >
> > Reason for revert: Analyzed the performance regression in more detail.
> >
> > Most of the regression comes from the extra RtpPacketInfos-related memory allocations in every `NetEq::GetAudio()` call. Commit 1796a820f60cb9429bf4bcf13a40a41794ac8fb0 has removed roughly 2/3rds of the extra allocations from the impacted perf tests. Remaining perf impact is expected to be about "8 microseconds of CPU time per second" on the Linux benchmarking machines and "15 us per second" on Windows/Mac.
> >
> > There are options to optimize further but they are unlikely worth doing. Note for example that `NetEqPerformanceTest` uses the PCM codec while the real-world use cases would likely use the much heavier Opus codec. The numbers from `OpusSpeedTest` and `NetEqPerformanceTest` suggest that Opus decoding is about 10x as expensive as NetEq overall.
> >
> > Original change's description:
> > > Revert "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker."
> > >
> > > This reverts commit 3e8ef940fe86cf6285afb80e68d2a0bedc631b9f.
> > >
> > > Reason for revert: This CL causes a performance regression in NetEq, see https://bugs.chromium.org/p/chromium/issues/detail?id=982260.
> > >
> > > Original change's description:
> > > > Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.
> > > >
> > > > This change adds the plumbing of RtpPacketInfo from ChannelReceive::OnRtpPacket() to ChannelReceive::GetAudioFrameWithInfo() for audio. It is a step towards replacing the non-spec compliant ContributingSources that updates itself at packet-receive time, with the spec-compliant SourceTracker that will update itself at frame-delivery-to-track time.
> > > >
> > > > Bug: webrtc:10668
> > > > Change-Id: I03385d6865bbc7bfbef7634f88de820a934f787a
> > > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/139890
> > > > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > > > Reviewed-by: Minyue Li <minyue@webrtc.org>
> > > > Commit-Queue: Chen Xing <chxg@google.com>
> > > > Cr-Commit-Position: refs/heads/master@{#28434}
> > >
> > > TBR=kwiberg@webrtc.org,stefan@webrtc.org,minyue@webrtc.org,chxg@google.com
> > >
> > > Bug: webrtc:10668, chromium:982260
> > > Change-Id: I5e2cfde78c59d1123e21869564d76ed3f6193a5c
> > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/145339
> > > Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
> > > Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
> > > Cr-Commit-Position: refs/heads/master@{#28561}
> >
> > TBR=kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
> >
> > # Not skipping CQ checks because original CL landed > 1 day ago.
> >
> > Bug: webrtc:10668, chromium:982260
> > Change-Id: Ie375a0b327ee368317bf3a04b2f1415c3a974470
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146707
> > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > Commit-Queue: Chen Xing <chxg@google.com>
> > Cr-Commit-Position: refs/heads/master@{#28664}
>
> TBR=kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
>
> Change-Id: I652cb0814d83b514d3bee34e65ca3bb693099b22
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:10668, chromium:982260
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146712
> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#28671}
TBR=alessiob@webrtc.org,kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
Change-Id: Id43b7b3da79b4f48004b41767482bae1c1fa1e16
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:10668, chromium:982260
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146713
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28672}
2019-07-24 16:47:02 +00:00
|
|
|
Clock* const clock;
|
2016-04-26 12:19:34 -07:00
|
|
|
std::unique_ptr<TickTimer> tick_timer;
|
2019-03-05 16:59:03 +01:00
|
|
|
std::unique_ptr<StatisticsCalculator> stats;
|
2016-04-26 12:19:34 -07:00
|
|
|
std::unique_ptr<DecoderDatabase> decoder_database;
|
|
|
|
|
std::unique_ptr<DtmfBuffer> dtmf_buffer;
|
|
|
|
|
std::unique_ptr<DtmfToneGenerator> dtmf_tone_generator;
|
|
|
|
|
std::unique_ptr<PacketBuffer> packet_buffer;
|
2019-10-24 15:20:39 +02:00
|
|
|
std::unique_ptr<NetEqController> neteq_controller;
|
2016-09-22 02:06:28 -07:00
|
|
|
std::unique_ptr<RedPayloadSplitter> red_payload_splitter;
|
2016-04-26 12:19:34 -07:00
|
|
|
std::unique_ptr<TimestampScaler> timestamp_scaler;
|
|
|
|
|
std::unique_ptr<AccelerateFactory> accelerate_factory;
|
|
|
|
|
std::unique_ptr<ExpandFactory> expand_factory;
|
|
|
|
|
std::unique_ptr<PreemptiveExpandFactory> preemptive_expand_factory;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Creates a new NetEqImpl object.
|
2014-08-07 12:27:37 +00:00
|
|
|
NetEqImpl(const NetEq::Config& config,
|
2016-04-26 12:19:34 -07:00
|
|
|
Dependencies&& deps,
|
2014-04-11 18:47:55 +00:00
|
|
|
bool create_components = true);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2015-04-09 15:44:22 +02:00
|
|
|
~NetEqImpl() override;
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2022-01-21 09:49:39 +09:00
|
|
|
NetEqImpl(const NetEqImpl&) = delete;
|
|
|
|
|
NetEqImpl& operator=(const NetEqImpl&) = delete;
|
|
|
|
|
|
2019-10-10 14:23:00 +02:00
|
|
|
// Inserts a new packet into NetEq. Returns 0 on success, -1 on failure.
|
2024-05-27 13:22:22 +00:00
|
|
|
int InsertPacket(const RTPHeader& rtp_header,
|
2024-05-30 11:05:40 +00:00
|
|
|
rtc::ArrayView<const uint8_t> payload) override;
|
2013-01-29 12:09:21 +00:00
|
|
|
|
Handle padded audio packets correctly
RTP packets can be padded with extra data at the end of the payload. The usable
payload length of the packet should then be reduced with the padding length,
since the padding must be discarded. This was not the case; instead, the entire
payload, including padding data, was forwarded to the audio channel and in the
end to the decoder.
A special case of padding is packets which are empty except for the padding.
That is, they carry no usable payload. These packets are sometimes used for
probing the network and were discarded in
RTPReceiverAudio::ParseAudioCodecSpecific. The result is that NetEq never sees
those empty packets, just the holes in the sequence number series; this can
throw off the target buffer calculations.
With this change, the empty (after removing the padding) packets are let through,
all the way down to NetEq, to a new method called NetEq::InsertEmptyPacket. This
method notifies the DelayManager that an empty packet was received.
BUG=webrtc:7610, webrtc:7625
Review-Url: https://codereview.webrtc.org/2870043003
Cr-Commit-Position: refs/heads/master@{#18083}
2017-05-10 07:38:01 -07:00
|
|
|
void InsertEmptyPacket(const RTPHeader& rtp_header) override;
|
|
|
|
|
|
2018-09-03 11:49:27 +02:00
|
|
|
int GetAudio(
|
|
|
|
|
AudioFrame* audio_frame,
|
2024-05-06 16:46:48 +02:00
|
|
|
bool* muted = nullptr,
|
2021-06-09 19:30:41 +02:00
|
|
|
int* current_sample_rate_hz = nullptr,
|
2019-10-31 14:38:11 +01:00
|
|
|
absl::optional<Operation> action_override = absl::nullopt) override;
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2017-03-27 07:15:49 -07:00
|
|
|
void SetCodecs(const std::map<int, SdpAudioFormat>& codecs) override;
|
|
|
|
|
|
2016-10-04 09:33:27 -07:00
|
|
|
bool RegisterPayloadType(int rtp_payload_type,
|
|
|
|
|
const SdpAudioFormat& audio_format) override;
|
|
|
|
|
|
2021-07-28 20:00:17 +02:00
|
|
|
// Removes `rtp_payload_type` from the codec database. Returns 0 on success,
|
2013-01-29 12:09:21 +00:00
|
|
|
// -1 on failure.
|
2015-03-04 12:58:35 +00:00
|
|
|
int RemovePayloadType(uint8_t rtp_payload_type) override;
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2016-09-20 04:02:25 -07:00
|
|
|
void RemoveAllPayloadTypes() override;
|
|
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
bool SetMinimumDelay(int delay_ms) override;
|
2013-08-16 23:44:24 +00:00
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
bool SetMaximumDelay(int delay_ms) override;
|
2013-08-16 23:44:24 +00:00
|
|
|
|
2019-02-05 13:49:26 +01:00
|
|
|
bool SetBaseMinimumDelayMs(int delay_ms) override;
|
|
|
|
|
|
|
|
|
|
int GetBaseMinimumDelayMs() const override;
|
|
|
|
|
|
2017-11-29 09:14:04 +01:00
|
|
|
int TargetDelayMs() const override;
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2016-08-22 15:39:53 -07:00
|
|
|
int FilteredCurrentDelayMs() const override;
|
|
|
|
|
|
2021-07-28 20:00:17 +02:00
|
|
|
// Writes the current network statistics to `stats`. The statistics are reset
|
2013-01-29 12:09:21 +00:00
|
|
|
// after the call.
|
2015-03-04 12:58:35 +00:00
|
|
|
int NetworkStatistics(NetEqNetworkStatistics* stats) override;
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2020-09-14 10:47:50 +02:00
|
|
|
NetEqNetworkStatistics CurrentNetworkStatistics() const override;
|
|
|
|
|
|
2017-08-24 17:15:13 -07:00
|
|
|
NetEqLifetimeStatistics GetLifetimeStatistics() const override;
|
|
|
|
|
|
2018-09-13 14:39:55 +02:00
|
|
|
NetEqOperationsAndState GetOperationsAndState() const override;
|
|
|
|
|
|
2018-06-19 13:26:36 +02:00
|
|
|
absl::optional<uint32_t> GetPlayoutTimestamp() const override;
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2015-11-23 06:49:25 -08:00
|
|
|
int last_output_sample_rate_hz() const override;
|
|
|
|
|
|
2019-10-11 09:37:42 +02:00
|
|
|
absl::optional<DecoderFormat> GetDecoderFormat(
|
2016-09-23 02:19:43 -07:00
|
|
|
int payload_type) const override;
|
2016-09-21 10:55:15 -07:00
|
|
|
|
2013-01-29 12:09:21 +00:00
|
|
|
// Flushes both the packet buffer and the sync buffer.
|
2015-03-04 12:58:35 +00:00
|
|
|
void FlushBuffers() override;
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2015-10-29 05:36:24 -07:00
|
|
|
void EnableNack(size_t max_nack_list_size) override;
|
|
|
|
|
|
|
|
|
|
void DisableNack() override;
|
|
|
|
|
|
|
|
|
|
std::vector<uint16_t> GetNackList(int64_t round_trip_time_ms) const override;
|
2013-09-11 18:45:02 +00:00
|
|
|
|
2017-04-26 07:47:32 -07:00
|
|
|
int SyncBufferSizeMs() const override;
|
|
|
|
|
|
2014-04-07 21:21:45 +00:00
|
|
|
// This accessor method is only intended for testing purposes.
|
2014-09-10 22:14:59 +00:00
|
|
|
const SyncBuffer* sync_buffer_for_test() const;
|
2019-10-31 14:38:11 +01:00
|
|
|
Operation last_operation_for_test() const;
|
2014-04-07 21:21:45 +00:00
|
|
|
|
2014-04-11 18:47:55 +00:00
|
|
|
protected:
|
2013-01-29 12:09:21 +00:00
|
|
|
static const int kOutputSizeMs = 10;
|
2016-05-02 04:46:11 -07:00
|
|
|
static const size_t kMaxFrameSize = 5760; // 120 ms @ 48 kHz.
|
2013-01-29 12:09:21 +00:00
|
|
|
// TODO(hlundin): Provide a better value for kSyncBufferSize.
|
2016-05-03 13:32:05 -07:00
|
|
|
// Current value is kMaxFrameSize + 60 ms * 48 kHz, which is enough for
|
|
|
|
|
// calculating correlations of current frame against history.
|
|
|
|
|
static const size_t kSyncBufferSize = kMaxFrameSize + 60 * 48;
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
// Inserts a new packet into NetEq. This is used by the InsertPacket method
|
|
|
|
|
// above. Returns 0 on success, otherwise an error code.
|
|
|
|
|
// TODO(hlundin): Merge this with InsertPacket above?
|
2017-04-24 15:56:56 +02:00
|
|
|
int InsertPacketInternal(const RTPHeader& rtp_header,
|
2024-05-30 11:05:40 +00:00
|
|
|
rtc::ArrayView<const uint8_t> payload)
|
2020-07-07 15:53:34 +02:00
|
|
|
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2023-11-27 13:20:27 +01:00
|
|
|
// Returns true if the payload type changed (this should be followed by
|
|
|
|
|
// resetting various state). Returns false if the current payload type is
|
|
|
|
|
// unknown or equal to `payload_type`.
|
|
|
|
|
bool MaybeChangePayloadType(uint8_t payload_type)
|
|
|
|
|
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
|
|
|
|
|
2021-07-28 20:00:17 +02:00
|
|
|
// Delivers 10 ms of audio data. The data is written to `audio_frame`.
|
2013-01-30 07:37:20 +00:00
|
|
|
// Returns 0 on success, otherwise an error code.
|
2018-09-03 11:49:27 +02:00
|
|
|
int GetAudioInternal(AudioFrame* audio_frame,
|
2019-10-31 14:38:11 +01:00
|
|
|
absl::optional<Operation> action_override)
|
2020-07-07 15:53:34 +02:00
|
|
|
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
// Provides a decision to the GetAudioInternal method. The decision what to
|
2021-07-28 20:00:17 +02:00
|
|
|
// do is written to `operation`. Packets to decode are written to
|
|
|
|
|
// `packet_list`, and a DTMF event to play is written to `dtmf_event`. When
|
|
|
|
|
// DTMF should be played, `play_dtmf` is set to true by the method.
|
2013-01-29 12:09:21 +00:00
|
|
|
// Returns 0 on success, otherwise an error code.
|
2019-10-31 14:38:11 +01:00
|
|
|
int GetDecision(Operation* operation,
|
2013-01-29 12:09:21 +00:00
|
|
|
PacketList* packet_list,
|
|
|
|
|
DtmfEvent* dtmf_event,
|
2018-09-03 11:49:27 +02:00
|
|
|
bool* play_dtmf,
|
2019-10-31 14:38:11 +01:00
|
|
|
absl::optional<Operation> action_override)
|
2020-07-07 15:53:34 +02:00
|
|
|
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2021-07-28 20:00:17 +02:00
|
|
|
// Decodes the speech packets in `packet_list`, and writes the results to
|
|
|
|
|
// `decoded_buffer`, which is allocated to hold `decoded_buffer_length`
|
|
|
|
|
// elements. The length of the decoded data is written to `decoded_length`.
|
2013-01-29 12:09:21 +00:00
|
|
|
// The speech type -- speech or (codec-internal) comfort noise -- is written
|
2021-07-28 20:00:17 +02:00
|
|
|
// to `speech_type`. If `packet_list` contains any SID frames for RFC 3389
|
2013-01-29 12:09:21 +00:00
|
|
|
// comfort noise, those are not decoded.
|
2014-03-18 11:49:22 +00:00
|
|
|
int Decode(PacketList* packet_list,
|
2019-10-31 14:38:11 +01:00
|
|
|
Operation* operation,
|
2014-03-18 11:49:22 +00:00
|
|
|
int* decoded_length,
|
|
|
|
|
AudioDecoder::SpeechType* speech_type)
|
2020-07-07 15:53:34 +02:00
|
|
|
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2015-09-23 15:20:39 +02:00
|
|
|
// Sub-method to Decode(). Performs codec internal CNG.
|
2017-09-07 07:53:45 -07:00
|
|
|
int DecodeCng(AudioDecoder* decoder,
|
|
|
|
|
int* decoded_length,
|
2015-09-23 15:20:39 +02:00
|
|
|
AudioDecoder::SpeechType* speech_type)
|
2020-07-07 15:53:34 +02:00
|
|
|
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
2015-09-23 15:20:39 +02:00
|
|
|
|
2013-01-29 12:09:21 +00:00
|
|
|
// Sub-method to Decode(). Performs the actual decoding.
|
2014-03-18 11:49:22 +00:00
|
|
|
int DecodeLoop(PacketList* packet_list,
|
2019-10-31 14:38:11 +01:00
|
|
|
const Operation& operation,
|
2014-03-18 11:49:22 +00:00
|
|
|
AudioDecoder* decoder,
|
|
|
|
|
int* decoded_length,
|
|
|
|
|
AudioDecoder::SpeechType* speech_type)
|
2020-07-07 15:53:34 +02:00
|
|
|
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
// Sub-method which calls the Normal class to perform the normal operation.
|
2014-03-18 11:49:22 +00:00
|
|
|
void DoNormal(const int16_t* decoded_buffer,
|
|
|
|
|
size_t decoded_length,
|
|
|
|
|
AudioDecoder::SpeechType speech_type,
|
2020-07-07 15:53:34 +02:00
|
|
|
bool play_dtmf) RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
// Sub-method which calls the Merge class to perform the merge operation.
|
2014-03-18 11:49:22 +00:00
|
|
|
void DoMerge(int16_t* decoded_buffer,
|
|
|
|
|
size_t decoded_length,
|
|
|
|
|
AudioDecoder::SpeechType speech_type,
|
2020-07-07 15:53:34 +02:00
|
|
|
bool play_dtmf) RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2020-07-07 15:53:34 +02:00
|
|
|
bool DoCodecPlc() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
2018-09-05 18:14:52 +02:00
|
|
|
|
2013-01-29 12:09:21 +00:00
|
|
|
// Sub-method which calls the Expand class to perform the expand operation.
|
2020-07-07 15:53:34 +02:00
|
|
|
int DoExpand(bool play_dtmf) RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
// Sub-method which calls the Accelerate class to perform the accelerate
|
|
|
|
|
// operation.
|
2014-03-18 11:49:22 +00:00
|
|
|
int DoAccelerate(int16_t* decoded_buffer,
|
|
|
|
|
size_t decoded_length,
|
|
|
|
|
AudioDecoder::SpeechType speech_type,
|
2015-05-27 14:33:29 +02:00
|
|
|
bool play_dtmf,
|
2020-07-07 15:53:34 +02:00
|
|
|
bool fast_accelerate) RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
// Sub-method which calls the PreemptiveExpand class to perform the
|
|
|
|
|
// preemtive expand operation.
|
2014-03-18 11:49:22 +00:00
|
|
|
int DoPreemptiveExpand(int16_t* decoded_buffer,
|
|
|
|
|
size_t decoded_length,
|
|
|
|
|
AudioDecoder::SpeechType speech_type,
|
2020-07-07 15:53:34 +02:00
|
|
|
bool play_dtmf) RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
// Sub-method which calls the ComfortNoise class to generate RFC 3389 comfort
|
2021-07-28 20:00:17 +02:00
|
|
|
// noise. `packet_list` can either contain one SID frame to update the
|
2013-01-29 12:09:21 +00:00
|
|
|
// noise parameters, or no payload at all, in which case the previously
|
|
|
|
|
// received parameters are used.
|
2014-03-18 11:49:22 +00:00
|
|
|
int DoRfc3389Cng(PacketList* packet_list, bool play_dtmf)
|
2020-07-07 15:53:34 +02:00
|
|
|
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
// Calls the audio decoder to generate codec-internal comfort noise when
|
|
|
|
|
// no packet was received.
|
2015-09-23 15:20:39 +02:00
|
|
|
void DoCodecInternalCng(const int16_t* decoded_buffer, size_t decoded_length)
|
2020-07-07 15:53:34 +02:00
|
|
|
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
// Calls the DtmfToneGenerator class to generate DTMF tones.
|
2014-03-18 11:49:22 +00:00
|
|
|
int DoDtmf(const DtmfEvent& dtmf_event, bool* play_dtmf)
|
2020-07-07 15:53:34 +02:00
|
|
|
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2021-07-28 20:00:17 +02:00
|
|
|
// Overdub DTMF on top of `output`.
|
2014-03-18 11:49:22 +00:00
|
|
|
int DtmfOverdub(const DtmfEvent& dtmf_event,
|
|
|
|
|
size_t num_channels,
|
2020-07-07 15:53:34 +02:00
|
|
|
int16_t* output) const RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2021-07-28 20:00:17 +02:00
|
|
|
// Extracts packets from `packet_buffer_` to produce at least
|
|
|
|
|
// `required_samples` samples. The packets are inserted into `packet_list`.
|
2013-01-29 12:09:21 +00:00
|
|
|
// Returns the number of samples that the packets in the list will produce, or
|
|
|
|
|
// -1 in case of an error.
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
int ExtractPackets(size_t required_samples, PacketList* packet_list)
|
2020-07-07 15:53:34 +02:00
|
|
|
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
// Resets various variables and objects to new values based on the sample rate
|
2021-07-28 20:00:17 +02:00
|
|
|
// `fs_hz` and `channels` number audio channels.
|
2014-03-18 11:49:22 +00:00
|
|
|
void SetSampleRateAndChannels(int fs_hz, size_t channels)
|
2020-07-07 15:53:34 +02:00
|
|
|
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
// Returns the output type for the audio produced by the latest call to
|
|
|
|
|
// GetAudio().
|
2020-07-07 15:53:34 +02:00
|
|
|
OutputType LastOutputType() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
2014-03-18 11:49:22 +00:00
|
|
|
|
2014-04-11 18:47:55 +00:00
|
|
|
// Updates Expand and Merge.
|
|
|
|
|
virtual void UpdatePlcComponents(int fs_hz, size_t channels)
|
2020-07-07 15:53:34 +02:00
|
|
|
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
2014-04-11 18:47:55 +00:00
|
|
|
|
2020-09-14 10:47:50 +02:00
|
|
|
NetEqNetworkStatistics CurrentNetworkStatisticsInternal() const
|
|
|
|
|
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
|
|
|
|
|
2024-02-05 11:30:21 +01:00
|
|
|
NetEqController::PacketArrivedInfo ToPacketArrivedInfo(
|
|
|
|
|
const Packet& packet) const RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
|
|
|
|
|
Reland "Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.""
This reverts commit fab3460a821abe336ab610c6d6dfc0d392dac263.
Reason for revert: fix downstream instead
Original change's description:
> Revert "Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.""
>
> This reverts commit 9973933d2e606d64fcdc753acb9ba3afd6e30569.
>
> Reason for revert: breaking downstream projects and not reviewed by direct owners
>
> Original change's description:
> > Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker."
> >
> > This reverts commit 24192c267a40eb7d6b1850489ccdbf7a84f8ff0f.
> >
> > Reason for revert: Analyzed the performance regression in more detail.
> >
> > Most of the regression comes from the extra RtpPacketInfos-related memory allocations in every `NetEq::GetAudio()` call. Commit 1796a820f60cb9429bf4bcf13a40a41794ac8fb0 has removed roughly 2/3rds of the extra allocations from the impacted perf tests. Remaining perf impact is expected to be about "8 microseconds of CPU time per second" on the Linux benchmarking machines and "15 us per second" on Windows/Mac.
> >
> > There are options to optimize further but they are unlikely worth doing. Note for example that `NetEqPerformanceTest` uses the PCM codec while the real-world use cases would likely use the much heavier Opus codec. The numbers from `OpusSpeedTest` and `NetEqPerformanceTest` suggest that Opus decoding is about 10x as expensive as NetEq overall.
> >
> > Original change's description:
> > > Revert "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker."
> > >
> > > This reverts commit 3e8ef940fe86cf6285afb80e68d2a0bedc631b9f.
> > >
> > > Reason for revert: This CL causes a performance regression in NetEq, see https://bugs.chromium.org/p/chromium/issues/detail?id=982260.
> > >
> > > Original change's description:
> > > > Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.
> > > >
> > > > This change adds the plumbing of RtpPacketInfo from ChannelReceive::OnRtpPacket() to ChannelReceive::GetAudioFrameWithInfo() for audio. It is a step towards replacing the non-spec compliant ContributingSources that updates itself at packet-receive time, with the spec-compliant SourceTracker that will update itself at frame-delivery-to-track time.
> > > >
> > > > Bug: webrtc:10668
> > > > Change-Id: I03385d6865bbc7bfbef7634f88de820a934f787a
> > > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/139890
> > > > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > > > Reviewed-by: Minyue Li <minyue@webrtc.org>
> > > > Commit-Queue: Chen Xing <chxg@google.com>
> > > > Cr-Commit-Position: refs/heads/master@{#28434}
> > >
> > > TBR=kwiberg@webrtc.org,stefan@webrtc.org,minyue@webrtc.org,chxg@google.com
> > >
> > > Bug: webrtc:10668, chromium:982260
> > > Change-Id: I5e2cfde78c59d1123e21869564d76ed3f6193a5c
> > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/145339
> > > Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
> > > Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
> > > Cr-Commit-Position: refs/heads/master@{#28561}
> >
> > TBR=kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
> >
> > # Not skipping CQ checks because original CL landed > 1 day ago.
> >
> > Bug: webrtc:10668, chromium:982260
> > Change-Id: Ie375a0b327ee368317bf3a04b2f1415c3a974470
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146707
> > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > Commit-Queue: Chen Xing <chxg@google.com>
> > Cr-Commit-Position: refs/heads/master@{#28664}
>
> TBR=kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
>
> Change-Id: I652cb0814d83b514d3bee34e65ca3bb693099b22
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:10668, chromium:982260
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146712
> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#28671}
TBR=alessiob@webrtc.org,kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
Change-Id: Id43b7b3da79b4f48004b41767482bae1c1fa1e16
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:10668, chromium:982260
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146713
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28672}
2019-07-24 16:47:02 +00:00
|
|
|
Clock* const clock_;
|
|
|
|
|
|
2020-07-07 15:53:34 +02:00
|
|
|
mutable Mutex mutex_;
|
|
|
|
|
const std::unique_ptr<TickTimer> tick_timer_ RTC_GUARDED_BY(mutex_);
|
2016-02-14 09:28:33 -08:00
|
|
|
const std::unique_ptr<DecoderDatabase> decoder_database_
|
2020-07-07 15:53:34 +02:00
|
|
|
RTC_GUARDED_BY(mutex_);
|
|
|
|
|
const std::unique_ptr<DtmfBuffer> dtmf_buffer_ RTC_GUARDED_BY(mutex_);
|
2016-02-14 09:28:33 -08:00
|
|
|
const std::unique_ptr<DtmfToneGenerator> dtmf_tone_generator_
|
2020-07-07 15:53:34 +02:00
|
|
|
RTC_GUARDED_BY(mutex_);
|
|
|
|
|
const std::unique_ptr<PacketBuffer> packet_buffer_ RTC_GUARDED_BY(mutex_);
|
2016-09-22 02:06:28 -07:00
|
|
|
const std::unique_ptr<RedPayloadSplitter> red_payload_splitter_
|
2020-07-07 15:53:34 +02:00
|
|
|
RTC_GUARDED_BY(mutex_);
|
2016-02-14 09:28:33 -08:00
|
|
|
const std::unique_ptr<TimestampScaler> timestamp_scaler_
|
2020-07-07 15:53:34 +02:00
|
|
|
RTC_GUARDED_BY(mutex_);
|
|
|
|
|
const std::unique_ptr<ExpandFactory> expand_factory_ RTC_GUARDED_BY(mutex_);
|
2016-02-14 09:28:33 -08:00
|
|
|
const std::unique_ptr<AccelerateFactory> accelerate_factory_
|
2020-07-07 15:53:34 +02:00
|
|
|
RTC_GUARDED_BY(mutex_);
|
2016-02-14 09:28:33 -08:00
|
|
|
const std::unique_ptr<PreemptiveExpandFactory> preemptive_expand_factory_
|
2020-07-07 15:53:34 +02:00
|
|
|
RTC_GUARDED_BY(mutex_);
|
|
|
|
|
const std::unique_ptr<StatisticsCalculator> stats_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<BackgroundNoise> background_noise_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
std::unique_ptr<NetEqController> controller_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
std::unique_ptr<AudioMultiVector> algorithm_buffer_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
std::unique_ptr<SyncBuffer> sync_buffer_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
std::unique_ptr<Expand> expand_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
std::unique_ptr<Normal> normal_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
std::unique_ptr<Merge> merge_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
std::unique_ptr<Accelerate> accelerate_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
std::unique_ptr<PreemptiveExpand> preemptive_expand_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
RandomVector random_vector_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
std::unique_ptr<ComfortNoise> comfort_noise_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
int fs_hz_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
int fs_mult_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
int last_output_sample_rate_hz_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
size_t output_size_samples_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
size_t decoder_frame_length_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
Mode last_mode_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
Operation last_operation_ RTC_GUARDED_BY(mutex_);
|
2023-03-29 15:42:19 +02:00
|
|
|
absl::optional<AudioDecoder::SpeechType> last_decoded_type_
|
|
|
|
|
RTC_GUARDED_BY(mutex_);
|
2020-07-07 15:53:34 +02:00
|
|
|
size_t decoded_buffer_length_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
std::unique_ptr<int16_t[]> decoded_buffer_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
uint32_t playout_timestamp_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
bool new_codec_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
uint32_t timestamp_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
bool reset_decoder_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
absl::optional<uint8_t> current_rtp_payload_type_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
absl::optional<uint8_t> current_cng_rtp_payload_type_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
bool first_packet_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
bool enable_fast_accelerate_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
std::unique_ptr<NackTracker> nack_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
bool nack_enabled_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
const bool enable_muted_state_ RTC_GUARDED_BY(mutex_);
|
2016-05-03 08:18:47 -07:00
|
|
|
std::unique_ptr<TickTimer::Stopwatch> generated_noise_stopwatch_
|
2020-07-07 15:53:34 +02:00
|
|
|
RTC_GUARDED_BY(mutex_);
|
|
|
|
|
std::vector<RtpPacketInfo> last_decoded_packet_infos_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
ExpandUmaLogger expand_uma_logger_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
ExpandUmaLogger speech_expand_uma_logger_ RTC_GUARDED_BY(mutex_);
|
|
|
|
|
bool no_time_stretching_ RTC_GUARDED_BY(mutex_); // Only used for test.
|
|
|
|
|
rtc::BufferT<int16_t> concealment_audio_ RTC_GUARDED_BY(mutex_);
|
2013-01-29 12:09:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_AUDIO_CODING_NETEQ_NETEQ_IMPL_H_
|