Split audio mixer into interface and implementation.
The AudioMixer is now split in a mixer and audio source interface part, which has moved to webrtc/api, and a default implementation part, which lies in webrtc/modules.
This change makes it possible to create other mixer implementations and is a first step to facilitate passing down a mixer from outside of WebRTC.
It will also create less build dependencies when the new mixer has replaced the old one.
NOTRY=True
TBR=henrik.lundin@webrtc.org
BUG=webrtc:6346
Review-Url: https://codereview.webrtc.org/2411313003
Cr-Commit-Position: refs/heads/master@{#14705}
diff --git a/.gn b/.gn
index 7a98fad..4aa7a76 100644
--- a/.gn
+++ b/.gn
@@ -20,6 +20,7 @@
# "gn check" or "gn gen --check".
# TODO(kjellander): Keep adding paths to this list as work in webrtc:5589 is done.
check_targets = [
+ "//webrtc/api:audio_mixer_api",
"//webrtc/api:rtc_stats_api",
"//webrtc/modules/audio_coding:g711_test",
"//webrtc/modules/audio_coding:g722_test",
diff --git a/webrtc/api/BUILD.gn b/webrtc/api/BUILD.gn
index 6de99f7..6424de9 100644
--- a/webrtc/api/BUILD.gn
+++ b/webrtc/api/BUILD.gn
@@ -321,6 +321,17 @@
]
}
+# GYP version: webrtc/api/api.gyp:audio_mixer_api
+rtc_source_set("audio_mixer_api") {
+ sources = [
+ "audio/audio_mixer.h",
+ ]
+
+ deps = [
+ "../base:rtc_base_approved",
+ ]
+}
+
if (rtc_include_tests) {
config("peerconnection_unittests_config") {
# The warnings below are enabled by default. Since GN orders compiler flags
diff --git a/webrtc/api/api.gyp b/webrtc/api/api.gyp
index c431e9e..8a7fe5a 100644
--- a/webrtc/api/api.gyp
+++ b/webrtc/api/api.gyp
@@ -232,5 +232,16 @@
'stats/rtcstatsreport.h',
],
}, # target rtc_stats_api
+ {
+ # GN version: webrtc/api:audio_mixer_api
+ 'target_name': 'audio_mixer_api',
+ 'type': 'static_library',
+ 'dependencies': [
+ '<(webrtc_root)/base/base.gyp:rtc_base_approved',
+ ],
+ 'sources': [
+ 'audio/audio_mixer.h',
+ ],
+ }, # target rtc_stats_api
], # targets
}
diff --git a/webrtc/modules/audio_mixer/audio_mixer.h b/webrtc/api/audio/audio_mixer.h
similarity index 81%
rename from webrtc/modules/audio_mixer/audio_mixer.h
rename to webrtc/api/audio/audio_mixer.h
index 7e58a8d..960adbb 100644
--- a/webrtc/modules/audio_mixer/audio_mixer.h
+++ b/webrtc/api/audio/audio_mixer.h
@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#ifndef WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_
-#define WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_
+#ifndef WEBRTC_API_AUDIO_AUDIO_MIXER_H_
+#define WEBRTC_API_AUDIO_AUDIO_MIXER_H_
#include <memory>
@@ -18,6 +18,9 @@
namespace webrtc {
+// WORK IN PROGRESS
+// This class is under development and is not yet intended for for use outside
+// of WebRtc/Libjingle.
class AudioMixer : public rtc::RefCountInterface {
public:
// A callback class that all mixer participants must inherit from/implement.
@@ -25,10 +28,11 @@
public:
enum class AudioFrameInfo {
kNormal, // The samples in audio_frame are valid and should be used.
- kMuted, // The samples in audio_frame should not be used, but should be
- // implicitly interpreted as zero. Other fields in audio_frame
- // may be read and should contain meaningful values.
- kError // audio_frame will not be used.
+ kMuted, // The samples in audio_frame should not be used, but
+ // should be implicitly interpreted as zero. Other
+ // fields in audio_frame may be read and should
+ // contain meaningful values.
+ kError, // The audio_frame will not be used.
};
struct AudioFrameWithInfo {
@@ -47,8 +51,8 @@
// mixer.
virtual AudioFrameWithInfo GetAudioFrameWithInfo(int sample_rate_hz) = 0;
- // A way for a mixer implementation do distinguish participants.
- virtual int ssrc() = 0;
+ // A way for a mixer implementation to distinguish participants.
+ virtual int Ssrc() = 0;
protected:
virtual ~Source() {}
@@ -75,4 +79,4 @@
};
} // namespace webrtc
-#endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_
+#endif // WEBRTC_API_AUDIO_AUDIO_MIXER_H_
diff --git a/webrtc/modules/BUILD.gn b/webrtc/modules/BUILD.gn
index d983360..6c472a3 100644
--- a/webrtc/modules/BUILD.gn
+++ b/webrtc/modules/BUILD.gn
@@ -19,7 +19,7 @@
"audio_coding",
"audio_conference_mixer",
"audio_device",
- "audio_mixer",
+ "audio_mixer:audio_mixer_impl",
"audio_processing",
"bitrate_controller",
"desktop_capture",
@@ -629,6 +629,7 @@
"../system_wrappers:system_wrappers",
"../test:rtp_test_utils",
"../test:test_common",
+ "../test:test_support",
"../test:test_support_main",
"../test:video_test_common",
"audio_coding",
@@ -645,7 +646,8 @@
"audio_coding:webrtc_opus",
"audio_conference_mixer",
"audio_device",
- "audio_mixer",
+ "audio_mixer:audio_frame_manipulator",
+ "audio_mixer:audio_mixer_impl",
"audio_processing",
"audio_processing:audioproc_test_utils",
"bitrate_controller",
diff --git a/webrtc/modules/audio_mixer/BUILD.gn b/webrtc/modules/audio_mixer/BUILD.gn
index 412b4d0..26adcf8 100644
--- a/webrtc/modules/audio_mixer/BUILD.gn
+++ b/webrtc/modules/audio_mixer/BUILD.gn
@@ -8,15 +8,12 @@
import("../../build/webrtc.gni")
-config("audio_conference_mixer_config") {
- include_dirs = [ "../../modules/include" ]
-}
-
-rtc_static_library("audio_mixer") {
+rtc_static_library("audio_mixer_impl") {
+ visibility = [
+ "../../audio:audio",
+ "../../modules/*",
+ ]
sources = [
- "audio_frame_manipulator.cc",
- "audio_frame_manipulator.h",
- "audio_mixer.h",
"audio_mixer_impl.cc",
"audio_mixer_impl.h",
"audio_source_with_mix_status.cc",
@@ -24,17 +21,36 @@
]
public = [
- "audio_mixer.h",
+ "audio_mixer_impl.h",
]
- public_configs = [ ":audio_conference_mixer_config" ]
+ public_deps = [
+ "../../api:audio_mixer_api",
+ ]
deps = [
+ ":audio_frame_manipulator",
"../..:webrtc_common",
"../../base:rtc_base_approved",
"../../modules/audio_processing",
"../../modules/utility",
"../../system_wrappers",
- "../../voice_engine:level_indicator",
+ ]
+}
+
+rtc_static_library("audio_frame_manipulator") {
+ visibility = [
+ ":*",
+ "../../modules:*",
+ ]
+
+ sources = [
+ "audio_frame_manipulator.cc",
+ "audio_frame_manipulator.h",
+ ]
+
+ deps = [
+ "../../base:rtc_base_approved",
+ "../../modules/utility",
]
}
diff --git a/webrtc/modules/audio_mixer/audio_frame_manipulator.cc b/webrtc/modules/audio_mixer/audio_frame_manipulator.cc
index 426c21b..fca9a78 100644
--- a/webrtc/modules/audio_mixer/audio_frame_manipulator.cc
+++ b/webrtc/modules/audio_mixer/audio_frame_manipulator.cc
@@ -12,7 +12,6 @@
#include "webrtc/modules/audio_mixer/audio_frame_manipulator.h"
#include "webrtc/modules/include/module_common_types.h"
#include "webrtc/modules/utility/include/audio_frame_operations.h"
-#include "webrtc/typedefs.h"
namespace webrtc {
diff --git a/webrtc/modules/audio_mixer/audio_frame_manipulator.h b/webrtc/modules/audio_mixer/audio_frame_manipulator.h
index b149bf9..20b66ca 100644
--- a/webrtc/modules/audio_mixer/audio_frame_manipulator.h
+++ b/webrtc/modules/audio_mixer/audio_frame_manipulator.h
@@ -12,7 +12,6 @@
#define WEBRTC_MODULES_AUDIO_MIXER_AUDIO_FRAME_MANIPULATOR_H_
#include "webrtc/modules/include/module_common_types.h"
-#include "webrtc/typedefs.h"
namespace webrtc {
diff --git a/webrtc/modules/audio_mixer/audio_mixer.gypi b/webrtc/modules/audio_mixer/audio_mixer.gypi
index 1ec0a4d..ee40a9c 100644
--- a/webrtc/modules/audio_mixer/audio_mixer.gypi
+++ b/webrtc/modules/audio_mixer/audio_mixer.gypi
@@ -9,24 +9,34 @@
{
'targets': [
{
- 'target_name': 'audio_mixer',
+ 'target_name': 'audio_mixer_impl',
'type': 'static_library',
'dependencies': [
+ 'audio_frame_manipulator',
'audio_processing',
'webrtc_utility',
- '<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers',
+ '<(webrtc_root)/api/api.gyp:audio_mixer_api',
'<(webrtc_root)/base/base.gyp:rtc_base_approved',
- '<(webrtc_root)/voice_engine/voice_engine.gyp:level_indicator',
+ '<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers',
],
'sources': [
- 'audio_frame_manipulator.cc',
- 'audio_frame_manipulator.h',
- 'audio_mixer.h',
'audio_mixer_impl.cc',
'audio_mixer_impl.h',
'audio_source_with_mix_status.cc',
'audio_source_with_mix_status.h',
],
},
+ {
+ 'target_name': 'audio_frame_manipulator',
+ 'type': 'static_library',
+ 'dependencies': [
+ 'webrtc_utility',
+ '<(webrtc_root)/base/base.gyp:rtc_base_approved',
+ ],
+ 'sources': [
+ 'audio_frame_manipulator.cc',
+ 'audio_frame_manipulator.h',
+ ],
+ },
], # targets
}
diff --git a/webrtc/modules/audio_mixer/audio_mixer_impl.h b/webrtc/modules/audio_mixer/audio_mixer_impl.h
index 87541ee..500bb78 100644
--- a/webrtc/modules/audio_mixer/audio_mixer_impl.h
+++ b/webrtc/modules/audio_mixer/audio_mixer_impl.h
@@ -14,14 +14,13 @@
#include <memory>
#include <vector>
+#include "webrtc/api/audio/audio_mixer.h"
#include "webrtc/base/scoped_ref_ptr.h"
#include "webrtc/base/thread_annotations.h"
#include "webrtc/base/thread_checker.h"
-#include "webrtc/modules/audio_mixer/audio_mixer.h"
#include "webrtc/modules/audio_processing/include/audio_processing.h"
#include "webrtc/modules/include/module_common_types.h"
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
-#include "webrtc/voice_engine/level_indicator.h"
#include "webrtc/voice_engine_configurations.h"
namespace webrtc {
diff --git a/webrtc/modules/audio_mixer/audio_mixer_impl_unittest.cc b/webrtc/modules/audio_mixer/audio_mixer_impl_unittest.cc
index 1e5f1fe..9147a15 100644
--- a/webrtc/modules/audio_mixer/audio_mixer_impl_unittest.cc
+++ b/webrtc/modules/audio_mixer/audio_mixer_impl_unittest.cc
@@ -14,10 +14,10 @@
#include <memory>
#include <utility>
+#include "webrtc/api/audio/audio_mixer.h"
#include "webrtc/base/bind.h"
#include "webrtc/base/thread.h"
#include "webrtc/modules/audio_mixer/audio_mixer_impl.h"
-#include "webrtc/modules/audio_mixer/audio_mixer.h"
#include "webrtc/test/gmock.h"
using testing::_;
@@ -60,7 +60,7 @@
MOCK_METHOD1(GetAudioFrameWithInfo, AudioFrameWithInfo(int sample_rate_hz));
- MOCK_METHOD0(ssrc, int());
+ MOCK_METHOD0(Ssrc, int());
AudioFrame* fake_frame() { return &fake_frame_; }
AudioFrameInfo fake_info() { return fake_audio_frame_info_; }
diff --git a/webrtc/modules/audio_mixer/audio_source_with_mix_status.h b/webrtc/modules/audio_mixer/audio_source_with_mix_status.h
index 167118f..4849d61 100644
--- a/webrtc/modules/audio_mixer/audio_source_with_mix_status.h
+++ b/webrtc/modules/audio_mixer/audio_source_with_mix_status.h
@@ -11,7 +11,7 @@
#ifndef WEBRTC_MODULES_AUDIO_MIXER_AUDIO_SOURCE_WITH_MIX_STATUS_H_
#define WEBRTC_MODULES_AUDIO_MIXER_AUDIO_SOURCE_WITH_MIX_STATUS_H_
-#include "webrtc/modules/audio_mixer/audio_mixer.h"
+#include "webrtc/api/audio/audio_mixer.h"
namespace webrtc {