Skip to content

Commit

Permalink
Break out separate compile targets for various classes
Browse files Browse the repository at this point in the history
This reduces the degree of interdependency among modules related
to the PeerConnection class, and makes it easier to isolate inappropriate
external dependencies.

Bug: webrtc:11967
Change-Id: Id9777a2ab690cc349dd5842a3a95e24478144c71
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/185882
Commit-Queue: Harald Alvestrand <[email protected]>
Reviewed-by: Mirko Bonadei <[email protected]>
Cr-Commit-Position: refs/heads/master@{#32235}
  • Loading branch information
Harald Alvestrand authored and Commit Bot committed Sep 29, 2020
1 parent 8036cb7 commit 445e6b0
Show file tree
Hide file tree
Showing 8 changed files with 177 additions and 22 deletions.
2 changes: 2 additions & 0 deletions examples/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ if (is_linux || is_chromeos || is_win) {
"../api/video_codecs:video_codecs_api",
"../media:rtc_media_base",
"../p2p:rtc_p2p",
"../pc:video_track_source",
"../rtc_base:checks",
"../rtc_base/third_party/sigslot",
"../system_wrappers:field_trial",
Expand Down Expand Up @@ -822,6 +823,7 @@ if (is_win || is_android) {
"../modules/video_capture:video_capture_module",
"../pc:libjingle_peerconnection",
"../pc:peerconnection",
"../pc:video_track_source",
"../rtc_base",
"../test:platform_video_capturer",
"../test:video_test_common",
Expand Down
131 changes: 121 additions & 10 deletions pc/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ rtc_library("peerconnection") {
"data_channel_controller.h",
"data_channel_utils.cc",
"data_channel_utils.h",
"dtmf_sender.cc",
"dtmf_sender.h",
"ice_server_parsing.cc",
"ice_server_parsing.h",
"jitter_buffer_delay.cc",
Expand All @@ -178,8 +176,6 @@ rtc_library("peerconnection") {
"jsep_session_description.cc",
"local_audio_source.cc",
"local_audio_source.h",
"media_stream.cc",
"media_stream.h",
"media_stream_observer.cc",
"media_stream_observer.h",
"media_stream_track.h",
Expand All @@ -198,10 +194,6 @@ rtc_library("peerconnection") {
"rtp_data_channel.h",
"rtp_parameters_conversion.cc",
"rtp_parameters_conversion.h",
"rtp_receiver.cc",
"rtp_receiver.h",
"rtp_sender.cc",
"rtp_sender.h",
"rtp_transceiver.cc",
"rtp_transceiver.h",
"sctp_data_channel.cc",
Expand All @@ -225,16 +217,20 @@ rtc_library("peerconnection") {
"video_rtp_track_source.h",
"video_track.cc",
"video_track.h",
"video_track_source.cc",
"video_track_source.h",
"webrtc_sdp.cc",
"webrtc_sdp.h",
"webrtc_session_description_factory.cc",
"webrtc_session_description_factory.h",
]

deps = [
":dtmf_sender",
":media_stream",
":rtc_pc_base",
":rtp_receiver",
":rtp_sender",
":stats_collector_interface",
":video_track_source",
"../api:array_view",
"../api:audio_options_api",
"../api:call_api",
Expand Down Expand Up @@ -294,6 +290,113 @@ rtc_library("peerconnection") {
]
}

rtc_library("rtp_receiver") {
sources = [
"rtp_receiver.cc",
"rtp_receiver.h",
]
deps = [
":media_stream",
":video_track_source",
"../api:libjingle_peerconnection_api",
"../api:media_stream_interface",
"../api:rtp_parameters",
"../api:scoped_refptr",
"../api/crypto:frame_decryptor_interface",
"../api/video:video_frame",
"../media:rtc_media_base",
"../rtc_base:checks",
"../rtc_base:logging",
"../rtc_base:rtc_base",
"../rtc_base:rtc_base_approved",
]
absl_deps = [
"//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional",
]
}

rtc_library("rtp_sender") {
sources = [
"rtp_sender.cc",
"rtp_sender.h",
]
deps = [
":dtmf_sender",
":stats_collector_interface",
"../api:audio_options_api",
"../api:libjingle_peerconnection_api",
"../api:media_stream_interface",
"../media:rtc_media_base",
"../rtc_base:checks",
"../rtc_base:rtc_base",
"../rtc_base/synchronization:mutex",
]
absl_deps = [
"//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional",
]
}

rtc_library("dtmf_sender") {
sources = [
"dtmf_sender.cc",
"dtmf_sender.h",
]
deps = [
"../api:libjingle_peerconnection_api",
"../rtc_base:checks",
"../rtc_base:rtc_base",
]
absl_deps = [
"//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional",
]
}

rtc_library("media_stream") {
sources = [
"media_stream.cc",
"media_stream.h",
]
deps = [
"../api:libjingle_peerconnection_api",
"../api:media_stream_interface",
"../api:scoped_refptr",
"../rtc_base:checks",
"../rtc_base:refcount",
"../rtc_base:rtc_base",
]
absl_deps = [
"//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional",
]
}

rtc_library("video_track_source") {
sources = [
"video_track_source.cc",
"video_track_source.h",
]
deps = [
"../api:media_stream_interface",
"../api/video:video_frame",
"../media:rtc_media_base",
"../rtc_base:checks",
"../rtc_base:rtc_base_approved",
"../rtc_base/system:rtc_export",
]
}

rtc_source_set("stats_collector_interface") {
sources = [ "stats_collector_interface.h" ]
deps = [ "../api:media_stream_interface" ]
}

rtc_source_set("libjingle_peerconnection") {
visibility = [ "*" ]
deps = [
Expand Down Expand Up @@ -472,6 +575,9 @@ if (rtc_include_tests) {
":libjingle_peerconnection",
":peerconnection",
":rtc_pc_base",
":rtp_receiver",
":rtp_sender",
":video_track_source",
"../api:audio_options_api",
"../api:create_frame_generator",
"../api:create_peerconnection_factory",
Expand Down Expand Up @@ -569,8 +675,13 @@ if (rtc_include_tests) {
}

deps = [
":dtmf_sender",
":media_stream",
":peerconnection",
":rtc_pc_base",
":rtp_receiver",
":rtp_sender",
":video_track_source",
"../api:array_view",
"../api:audio_options_api",
"../api:create_peerconnection_factory",
Expand Down
7 changes: 3 additions & 4 deletions pc/rtp_sender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
#include "api/audio_options.h"
#include "api/media_stream_interface.h"
#include "media/base/media_engine.h"
#include "pc/peer_connection.h"
#include "pc/stats_collector.h"
#include "pc/stats_collector_interface.h"
#include "rtc_base/checks.h"
#include "rtc_base/helpers.h"
#include "rtc_base/location.h"
Expand Down Expand Up @@ -418,7 +417,7 @@ void LocalAudioSinkAdapter::SetSink(cricket::AudioSource::Sink* sink) {
rtc::scoped_refptr<AudioRtpSender> AudioRtpSender::Create(
rtc::Thread* worker_thread,
const std::string& id,
StatsCollector* stats,
StatsCollectorInterface* stats,
SetStreamsObserver* set_streams_observer) {
return rtc::scoped_refptr<AudioRtpSender>(
new rtc::RefCountedObject<AudioRtpSender>(worker_thread, id, stats,
Expand All @@ -427,7 +426,7 @@ rtc::scoped_refptr<AudioRtpSender> AudioRtpSender::Create(

AudioRtpSender::AudioRtpSender(rtc::Thread* worker_thread,
const std::string& id,
StatsCollector* stats,
StatsCollectorInterface* stats,
SetStreamsObserver* set_streams_observer)
: RtpSenderBase(worker_thread, id, set_streams_observer),
stats_(stats),
Expand Down
8 changes: 4 additions & 4 deletions pc/rtp_sender.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

namespace webrtc {

class StatsCollector;
class StatsCollectorInterface;

bool UnimplementedRtpParameterHasValue(const RtpParameters& parameters);

Expand Down Expand Up @@ -257,7 +257,7 @@ class AudioRtpSender : public DtmfProviderInterface, public RtpSenderBase {
static rtc::scoped_refptr<AudioRtpSender> Create(
rtc::Thread* worker_thread,
const std::string& id,
StatsCollector* stats,
StatsCollectorInterface* stats,
SetStreamsObserver* set_streams_observer);
virtual ~AudioRtpSender();

Expand All @@ -281,7 +281,7 @@ class AudioRtpSender : public DtmfProviderInterface, public RtpSenderBase {
protected:
AudioRtpSender(rtc::Thread* worker_thread,
const std::string& id,
StatsCollector* stats,
StatsCollectorInterface* stats,
SetStreamsObserver* set_streams_observer);

void SetSend() override;
Expand All @@ -303,7 +303,7 @@ class AudioRtpSender : public DtmfProviderInterface, public RtpSenderBase {
}
sigslot::signal0<> SignalDestroyed;

StatsCollector* stats_ = nullptr;
StatsCollectorInterface* stats_ = nullptr;
rtc::scoped_refptr<DtmfSenderInterface> dtmf_sender_proxy_;
bool cached_track_enabled_ = false;

Expand Down
1 change: 0 additions & 1 deletion pc/stats_collector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <vector>

#include "pc/channel.h"
#include "pc/peer_connection.h"
#include "rtc_base/checks.h"
#include "rtc_base/third_party/base64/base64.h"
#include "system_wrappers/include/field_trial.h"
Expand Down
9 changes: 6 additions & 3 deletions pc/stats_collector.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "api/stats_types.h"
#include "p2p/base/port.h"
#include "pc/peer_connection_internal.h"
#include "pc/stats_collector_interface.h"
#include "rtc_base/network_constants.h"
#include "rtc_base/ssl_certificate.h"

Expand All @@ -44,7 +45,7 @@ const char* AdapterTypeToStatsType(rtc::AdapterType type);
// A mapping between track ids and their StatsReport.
typedef std::map<std::string, StatsReport*> TrackIdMap;

class StatsCollector {
class StatsCollector : public StatsCollectorInterface {
public:
// The caller is responsible for ensuring that the pc outlives the
// StatsCollector instance.
Expand All @@ -57,11 +58,13 @@ class StatsCollector {
void AddTrack(MediaStreamTrackInterface* track);

// Adds a local audio track that is used for getting some voice statistics.
void AddLocalAudioTrack(AudioTrackInterface* audio_track, uint32_t ssrc);
void AddLocalAudioTrack(AudioTrackInterface* audio_track,
uint32_t ssrc) override;

// Removes a local audio tracks that is used for getting some voice
// statistics.
void RemoveLocalAudioTrack(AudioTrackInterface* audio_track, uint32_t ssrc);
void RemoveLocalAudioTrack(AudioTrackInterface* audio_track,
uint32_t ssrc) override;

// Gather statistics from the session and store them for future use.
void UpdateStats(PeerConnectionInterface::StatsOutputLevel level);
Expand Down
40 changes: 40 additions & 0 deletions pc/stats_collector_interface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2020 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.
*/

// This file contains an interface for the (obsolete) StatsCollector class that
// is used by compilation units that do not wish to depend on the StatsCollector
// implementation.

#ifndef PC_STATS_COLLECTOR_INTERFACE_H_
#define PC_STATS_COLLECTOR_INTERFACE_H_

#include <stdint.h>

#include "api/media_stream_interface.h"

namespace webrtc {

class StatsCollectorInterface {
public:
virtual ~StatsCollectorInterface() {}

// Adds a local audio track that is used for getting some voice statistics.
virtual void AddLocalAudioTrack(AudioTrackInterface* audio_track,
uint32_t ssrc) = 0;

// Removes a local audio tracks that is used for getting some voice
// statistics.
virtual void RemoveLocalAudioTrack(AudioTrackInterface* audio_track,
uint32_t ssrc) = 0;
};

} // namespace webrtc

#endif // PC_STATS_COLLECTOR_INTERFACE_H_
1 change: 1 addition & 0 deletions test/pc/e2e/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ if (!build_with_chromium) {
"../../../api:peer_connection_quality_test_fixture_api",
"../../../api/video:video_frame",
"../../../pc:peerconnection",
"../../../pc:video_track_source",
]
absl_deps = [ "//third_party/abseil-cpp/absl/types:variant" ]
}
Expand Down

0 comments on commit 445e6b0

Please sign in to comment.