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}
This commit is contained in:
aleloi 2016-10-20 05:06:39 -07:00 committed by Commit bot
parent 76648da8dc
commit 201dfe90a7
12 changed files with 87 additions and 35 deletions

1
.gn
View File

@ -20,6 +20,7 @@ secondary_source = "//build/secondary/"
# "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",

View File

@ -321,6 +321,17 @@ rtc_source_set("rtc_stats_api") {
]
}
# 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

View File

@ -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
}

View File

@ -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 @@ class AudioMixer : public rtc::RefCountInterface {
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 @@ class AudioMixer : public rtc::RefCountInterface {
// 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 @@ class AudioMixer : public rtc::RefCountInterface {
};
} // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_H_
#endif // WEBRTC_API_AUDIO_AUDIO_MIXER_H_

View File

@ -19,7 +19,7 @@ group("modules") {
"audio_coding",
"audio_conference_mixer",
"audio_device",
"audio_mixer",
"audio_mixer:audio_mixer_impl",
"audio_processing",
"bitrate_controller",
"desktop_capture",
@ -629,6 +629,7 @@ if (rtc_include_tests) {
"../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 @@ if (rtc_include_tests) {
"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",

View File

@ -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 @@ rtc_static_library("audio_mixer") {
]
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",
]
}

View File

@ -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 {

View File

@ -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 {

View File

@ -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
}

View File

@ -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 {

View File

@ -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 @@ class MockMixerAudioSource : public AudioMixer::Source {
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_; }

View File

@ -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 {