Support building WebRTC without audio and video.
This CL makes the WebRTC more modular and allows the users to build WebRTC without audio and video(DataChannel only). The BUILD files in call/, logging/, media/ and pc/ are modified to support modular WebRTC. The dependencies on Call and RtcEventLog are removed from the PeerConnection. Instead of being created internally, they would be passed in by the PeerConnectionFactory. Add the CreateModularPeerConnectionFactory function which allow the users to create a PeerConnectionFactory with the modules they need. If the users want to build WebRTC without audio and video, they can pass in null pointers for modules they don't need. (MediaEngine, VideoEncoderFactory etc.) BUG=webrtc:7613 Review-Url: https://codereview.webrtc.org/2854123003 Cr-Commit-Position: refs/heads/master@{#18617}
This commit is contained in:
parent
beae92c784
commit
38ede13042
@ -15,6 +15,8 @@ specific_include_rules = {
|
||||
# TODO(ossu): Remove this exception when {builtin_,}audio_encoder_factory.h
|
||||
# has moved to api/.
|
||||
"peerconnectioninterface\.h": [
|
||||
"+webrtc/call/callfactoryinterface.h",
|
||||
"+webrtc/logging/rtc_event_log/rtc_event_log_factory_interface.h",
|
||||
"+webrtc/modules/audio_coding/codecs/audio_encoder_factory.h",
|
||||
"+webrtc/modules/audio_coding/codecs/builtin_audio_encoder_factory.h",
|
||||
],
|
||||
|
||||
@ -23,10 +23,16 @@
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/optional.h"
|
||||
// TODO(zhihuang): Remove unrelated headers once downstream applications stop
|
||||
// relying on them; they were previously transitively included by
|
||||
// mediachannel.h, which is no longer a dependency of this file.
|
||||
#include "webrtc/base/ratetracker.h"
|
||||
#include "webrtc/base/refcount.h"
|
||||
#include "webrtc/base/scoped_ref_ptr.h"
|
||||
#include "webrtc/base/optional.h"
|
||||
#include "webrtc/media/base/mediachannel.h"
|
||||
#include "webrtc/base/thread.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/media/base/streamparams.h"
|
||||
#include "webrtc/media/base/videosinkinterface.h"
|
||||
#include "webrtc/media/base/videosourceinterface.h"
|
||||
|
||||
|
||||
@ -90,6 +90,8 @@
|
||||
#include "webrtc/base/rtccertificategenerator.h"
|
||||
#include "webrtc/base/socketaddress.h"
|
||||
#include "webrtc/base/sslstreamadapter.h"
|
||||
#include "webrtc/call/callfactoryinterface.h"
|
||||
#include "webrtc/logging/rtc_event_log/rtc_event_log_factory_interface.h"
|
||||
#include "webrtc/media/base/mediachannel.h"
|
||||
#include "webrtc/media/base/videocapturer.h"
|
||||
#include "webrtc/p2p/base/portallocator.h"
|
||||
@ -100,6 +102,7 @@ class Thread;
|
||||
}
|
||||
|
||||
namespace cricket {
|
||||
class MediaEngineInterface;
|
||||
class WebRtcVideoDecoderFactory;
|
||||
class WebRtcVideoEncoderFactory;
|
||||
}
|
||||
@ -107,6 +110,7 @@ class WebRtcVideoEncoderFactory;
|
||||
namespace webrtc {
|
||||
class AudioDeviceModule;
|
||||
class AudioMixer;
|
||||
class CallFactoryInterface;
|
||||
class MediaConstraintsInterface;
|
||||
|
||||
// MediaStream container interface.
|
||||
@ -1126,6 +1130,51 @@ CreatePeerConnectionFactory(
|
||||
default_adm, encoder_factory, decoder_factory);
|
||||
}
|
||||
|
||||
// This is a lower-level version of the CreatePeerConnectionFactory functions
|
||||
// above. It's implemented in the "peerconnection" build target, whereas the
|
||||
// above methods are only implemented in the broader "libjingle_peerconnection"
|
||||
// build target, which pulls in the implementations of every module webrtc may
|
||||
// use.
|
||||
//
|
||||
// If an application knows it will only require certain modules, it can reduce
|
||||
// webrtc's impact on its binary size by depending only on the "peerconnection"
|
||||
// target and the modules the application requires, using
|
||||
// CreateModularPeerConnectionFactory instead of one of the
|
||||
// CreatePeerConnectionFactory methods above. For example, if an application
|
||||
// only uses WebRTC for audio, it can pass in null pointers for the
|
||||
// video-specific interfaces, and omit the corresponding modules from its
|
||||
// build.
|
||||
//
|
||||
// If |network_thread| or |worker_thread| are null, the PeerConnectionFactory
|
||||
// will create the necessary thread internally. If |signaling_thread| is null,
|
||||
// the PeerConnectionFactory will use the thread on which this method is called
|
||||
// as the signaling thread, wrapping it in an rtc::Thread object if needed.
|
||||
//
|
||||
// If non-null, a reference is added to |default_adm|, and ownership of
|
||||
// |video_encoder_factory| and |video_decoder_factory| is transferred to the
|
||||
// returned factory.
|
||||
//
|
||||
// TODO(deadbeef): Use rtc::scoped_refptr<> and std::unique_ptr<> to make this
|
||||
// ownership transfer and ref counting more obvious.
|
||||
//
|
||||
// TODO(deadbeef): Encapsulate these modules in a struct, so that when a new
|
||||
// module is inevitably exposed, we can just add a field to the struct instead
|
||||
// of adding a whole new CreateModularPeerConnectionFactory overload.
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface>
|
||||
CreateModularPeerConnectionFactory(
|
||||
rtc::Thread* network_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
rtc::Thread* signaling_thread,
|
||||
AudioDeviceModule* default_adm,
|
||||
rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
|
||||
rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
|
||||
cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
|
||||
cricket::WebRtcVideoDecoderFactory* video_decoder_factory,
|
||||
rtc::scoped_refptr<AudioMixer> audio_mixer,
|
||||
std::unique_ptr<cricket::MediaEngineInterface> media_engine,
|
||||
std::unique_ptr<CallFactoryInterface> call_factory,
|
||||
std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory);
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_API_PEERCONNECTIONINTERFACE_H_
|
||||
|
||||
@ -15,6 +15,7 @@ rtc_source_set("call_interfaces") {
|
||||
"audio_send_stream.h",
|
||||
"audio_state.h",
|
||||
"call.h",
|
||||
"callfactoryinterface.h",
|
||||
"flexfec_receive_stream.h",
|
||||
"syncable.cc",
|
||||
"syncable.h",
|
||||
@ -71,6 +72,8 @@ rtc_static_library("call") {
|
||||
sources = [
|
||||
"bitrate_allocator.cc",
|
||||
"call.cc",
|
||||
"callfactory.cc",
|
||||
"callfactory.h",
|
||||
"flexfec_receive_stream_impl.cc",
|
||||
"flexfec_receive_stream_impl.h",
|
||||
]
|
||||
|
||||
@ -60,8 +60,6 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
const int Call::Config::kDefaultStartBitrateBps = 300000;
|
||||
|
||||
namespace {
|
||||
|
||||
// TODO(nisse): This really begs for a shared context struct.
|
||||
|
||||
@ -80,7 +80,7 @@ class Call {
|
||||
RTC_DCHECK(event_log);
|
||||
}
|
||||
|
||||
static const int kDefaultStartBitrateBps;
|
||||
static constexpr int kDefaultStartBitrateBps = 300000;
|
||||
|
||||
// Bitrate config used until valid bitrate estimates are calculated. Also
|
||||
// used to cap total bitrate used. This comes from the remote connection.
|
||||
|
||||
25
webrtc/call/callfactory.cc
Normal file
25
webrtc/call/callfactory.cc
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2017 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.
|
||||
*/
|
||||
|
||||
#include "webrtc/call/callfactory.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
Call* CallFactory::CreateCall(const Call::Config& config) {
|
||||
return Call::Create(config);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallFactoryInterface> CreateCallFactory() {
|
||||
return std::unique_ptr<CallFactoryInterface>(new CallFactory());
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
26
webrtc/call/callfactory.h
Normal file
26
webrtc/call/callfactory.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2017 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.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_CALL_CALLFACTORY_H_
|
||||
#define WEBRTC_CALL_CALLFACTORY_H_
|
||||
|
||||
#include "webrtc/call/callfactoryinterface.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class CallFactory : public CallFactoryInterface {
|
||||
~CallFactory() override {}
|
||||
|
||||
Call* CreateCall(const Call::Config& config) override;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_CALL_CALLFACTORY_H_
|
||||
34
webrtc/call/callfactoryinterface.h
Normal file
34
webrtc/call/callfactoryinterface.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 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.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_CALL_CALLFACTORYINTERFACE_H_
|
||||
#define WEBRTC_CALL_CALLFACTORYINTERFACE_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/call/call.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// This interface exists to allow webrtc to be optionally built without media
|
||||
// support (i.e., if only being used for data channels). PeerConnectionFactory
|
||||
// is constructed with a CallFactoryInterface, which may or may not be null.
|
||||
class CallFactoryInterface {
|
||||
public:
|
||||
virtual ~CallFactoryInterface() {}
|
||||
|
||||
virtual Call* CreateCall(const Call::Config& config) = 0;
|
||||
};
|
||||
|
||||
std::unique_ptr<CallFactoryInterface> CreateCallFactory();
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_CALL_CALLFACTORYINTERFACE_H_
|
||||
@ -24,7 +24,6 @@ rtc_static_library("common_video") {
|
||||
"h264/h264_common.h",
|
||||
"h264/pps_parser.cc",
|
||||
"h264/pps_parser.h",
|
||||
"h264/profile_level_id.cc",
|
||||
"h264/profile_level_id.h",
|
||||
"h264/sps_parser.cc",
|
||||
"h264/sps_parser.h",
|
||||
@ -60,6 +59,7 @@ rtc_static_library("common_video") {
|
||||
"..:webrtc_common",
|
||||
"../base:rtc_base",
|
||||
"../base:rtc_task_queue",
|
||||
"../media:rtc_media_base",
|
||||
"../modules:module_api",
|
||||
"../system_wrappers",
|
||||
]
|
||||
|
||||
@ -11,92 +11,9 @@
|
||||
#ifndef WEBRTC_COMMON_VIDEO_H264_PROFILE_LEVEL_ID_H_
|
||||
#define WEBRTC_COMMON_VIDEO_H264_PROFILE_LEVEL_ID_H_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "webrtc/media/base/h264_profile_level_id.h"
|
||||
|
||||
#include "webrtc/base/optional.h"
|
||||
#include "webrtc/common_types.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace H264 {
|
||||
|
||||
// Map containting SDP codec parameters.
|
||||
typedef std::map<std::string, std::string> CodecParameterMap;
|
||||
|
||||
// All values are equal to ten times the level number, except level 1b which is
|
||||
// special.
|
||||
enum Level {
|
||||
kLevel1_b = 0,
|
||||
kLevel1 = 10,
|
||||
kLevel1_1 = 11,
|
||||
kLevel1_2 = 12,
|
||||
kLevel1_3 = 13,
|
||||
kLevel2 = 20,
|
||||
kLevel2_1 = 21,
|
||||
kLevel2_2 = 22,
|
||||
kLevel3 = 30,
|
||||
kLevel3_1 = 31,
|
||||
kLevel3_2 = 32,
|
||||
kLevel4 = 40,
|
||||
kLevel4_1 = 41,
|
||||
kLevel4_2 = 42,
|
||||
kLevel5 = 50,
|
||||
kLevel5_1 = 51,
|
||||
kLevel5_2 = 52
|
||||
};
|
||||
|
||||
struct ProfileLevelId {
|
||||
ProfileLevelId(Profile profile, Level level)
|
||||
: profile(profile), level(level) {}
|
||||
Profile profile;
|
||||
Level level;
|
||||
};
|
||||
|
||||
// Parse profile level id that is represented as a string of 3 hex bytes.
|
||||
// Nothing will be returned if the string is not a recognized H264
|
||||
// profile level id.
|
||||
rtc::Optional<ProfileLevelId> ParseProfileLevelId(const char* str);
|
||||
|
||||
// Parse profile level id that is represented as a string of 3 hex bytes
|
||||
// contained in an SDP key-value map. A default profile level id will be
|
||||
// returned if the profile-level-id key is missing. Nothing will be returned if
|
||||
// the key is present but the string is invalid.
|
||||
rtc::Optional<ProfileLevelId> ParseSdpProfileLevelId(
|
||||
const CodecParameterMap& params);
|
||||
|
||||
// Given that a decoder supports up to a given frame size (in pixels) at up to a
|
||||
// given number of frames per second, return the highest H.264 level where it
|
||||
// can guarantee that it will be able to support all valid encoded streams that
|
||||
// are within that level.
|
||||
rtc::Optional<Level> SupportedLevel(int max_frame_pixel_count, float max_fps);
|
||||
|
||||
// Returns canonical string representation as three hex bytes of the profile
|
||||
// level id, or returns nothing for invalid profile level ids.
|
||||
rtc::Optional<std::string> ProfileLevelIdToString(
|
||||
const ProfileLevelId& profile_level_id);
|
||||
|
||||
// Generate codec parameters that will be used as answer in an SDP negotiation
|
||||
// based on local supported parameters and remote offered parameters. Both
|
||||
// |local_supported_params|, |remote_offered_params|, and |answer_params|
|
||||
// represent sendrecv media descriptions, i.e they are a mix of both encode and
|
||||
// decode capabilities. In theory, when the profile in |local_supported_params|
|
||||
// represent a strict superset of the profile in |remote_offered_params|, we
|
||||
// could limit the profile in |answer_params| to the profile in
|
||||
// |remote_offered_params|. However, to simplify the code, each supported H264
|
||||
// profile should be listed explicitly in the list of local supported codecs,
|
||||
// even if they are redundant. Then each local codec in the list should be
|
||||
// tested one at a time against the remote codec, and only when the profiles are
|
||||
// equal should this function be called. Therefore, this function does not need
|
||||
// to handle profile intersection, and the profile of |local_supported_params|
|
||||
// and |remote_offered_params| must be equal before calling this function. The
|
||||
// parameters that are used when negotiating are the level part of
|
||||
// profile-level-id and level-asymmetry-allowed.
|
||||
void GenerateProfileLevelIdForAnswer(
|
||||
const CodecParameterMap& local_supported_params,
|
||||
const CodecParameterMap& remote_offered_params,
|
||||
CodecParameterMap* answer_params);
|
||||
|
||||
} // namespace H264
|
||||
} // namespace webrtc
|
||||
// TODO(zhihuang): Delete this file once dependent applications switch to
|
||||
// including "webrtc/media/base/h264_profile_level_id.h" directly.
|
||||
|
||||
#endif // WEBRTC_COMMON_VIDEO_H264_PROFILE_LEVEL_ID_H_
|
||||
|
||||
@ -25,6 +25,7 @@ group("logging") {
|
||||
rtc_source_set("rtc_event_log_api") {
|
||||
sources = [
|
||||
"rtc_event_log/rtc_event_log.h",
|
||||
"rtc_event_log/rtc_event_log_factory_interface.h",
|
||||
]
|
||||
deps = [
|
||||
"..:video_stream_api",
|
||||
@ -36,6 +37,8 @@ rtc_source_set("rtc_event_log_api") {
|
||||
rtc_static_library("rtc_event_log_impl") {
|
||||
sources = [
|
||||
"rtc_event_log/rtc_event_log.cc",
|
||||
"rtc_event_log/rtc_event_log_factory.cc",
|
||||
"rtc_event_log/rtc_event_log_factory.h",
|
||||
"rtc_event_log/rtc_event_log_helper_thread.cc",
|
||||
"rtc_event_log/rtc_event_log_helper_thread.h",
|
||||
]
|
||||
|
||||
@ -580,15 +580,6 @@ bool RtcEventLog::ParseRtcEventLog(const std::string& file_name,
|
||||
|
||||
#endif // ENABLE_RTC_EVENT_LOG
|
||||
|
||||
bool RtcEventLogNullImpl::StartLogging(rtc::PlatformFile platform_file,
|
||||
int64_t max_size_bytes) {
|
||||
// The platform_file is open and needs to be closed.
|
||||
if (!rtc::ClosePlatformFile(platform_file)) {
|
||||
LOG(LS_ERROR) << "Can't close file.";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// RtcEventLog member functions.
|
||||
std::unique_ptr<RtcEventLog> RtcEventLog::Create() {
|
||||
#ifdef ENABLE_RTC_EVENT_LOG
|
||||
|
||||
@ -189,7 +189,9 @@ class RtcEventLogNullImpl : public RtcEventLog {
|
||||
return false;
|
||||
}
|
||||
bool StartLogging(rtc::PlatformFile platform_file,
|
||||
int64_t max_size_bytes) override;
|
||||
int64_t max_size_bytes) override {
|
||||
return false;
|
||||
}
|
||||
void StopLogging() override {}
|
||||
void LogVideoReceiveStreamConfig(
|
||||
const rtclog::StreamConfig& config) override {}
|
||||
|
||||
25
webrtc/logging/rtc_event_log/rtc_event_log_factory.cc
Normal file
25
webrtc/logging/rtc_event_log/rtc_event_log_factory.cc
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2017 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.
|
||||
*/
|
||||
|
||||
#include "webrtc/logging/rtc_event_log/rtc_event_log_factory.h"
|
||||
|
||||
#include "webrtc/logging/rtc_event_log/rtc_event_log.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
std::unique_ptr<RtcEventLog> RtcEventLogFactory::CreateRtcEventLog() {
|
||||
return RtcEventLog::Create();
|
||||
}
|
||||
|
||||
std::unique_ptr<RtcEventLogFactoryInterface> CreateRtcEventLogFactory() {
|
||||
return std::unique_ptr<RtcEventLogFactoryInterface>(new RtcEventLogFactory());
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
30
webrtc/logging/rtc_event_log/rtc_event_log_factory.h
Normal file
30
webrtc/logging/rtc_event_log/rtc_event_log_factory.h
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2017 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.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_FACTORY_H_
|
||||
#define WEBRTC_LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_FACTORY_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/logging/rtc_event_log/rtc_event_log_factory_interface.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class RtcEventLogFactory : public RtcEventLogFactoryInterface {
|
||||
public:
|
||||
~RtcEventLogFactory() override {}
|
||||
|
||||
std::unique_ptr<RtcEventLog> CreateRtcEventLog() override;
|
||||
};
|
||||
|
||||
std::unique_ptr<RtcEventLogFactoryInterface> CreateRtcEventLogFactory();
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_FACTORY_H_
|
||||
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 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.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_FACTORY_INTERFACE_H_
|
||||
#define WEBRTC_LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_FACTORY_INTERFACE_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/logging/rtc_event_log/rtc_event_log.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// This interface exists to allow webrtc to be optionally built without
|
||||
// RtcEventLog support. A PeerConnectionFactory is constructed with an
|
||||
// RtcEventLogFactoryInterface, which may or may not be null.
|
||||
class RtcEventLogFactoryInterface {
|
||||
public:
|
||||
virtual ~RtcEventLogFactoryInterface() {}
|
||||
|
||||
virtual std::unique_ptr<RtcEventLog> CreateRtcEventLog() = 0;
|
||||
};
|
||||
|
||||
std::unique_ptr<RtcEventLogFactoryInterface> CreateRtcEventLogFactory();
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_FACTORY_INTERFACE_H_
|
||||
@ -23,12 +23,21 @@ config("rtc_media_defines_config") {
|
||||
]
|
||||
}
|
||||
|
||||
rtc_static_library("rtc_media_base") {
|
||||
config("rtc_media_warnings_config") {
|
||||
# GN orders flags on a target before flags from configs. The default config
|
||||
# adds these flags so to cancel them out they need to come from a config and
|
||||
# cannot be on the target directly.
|
||||
if (!is_win) {
|
||||
cflags = [ "-Wno-deprecated-declarations" ]
|
||||
}
|
||||
}
|
||||
|
||||
rtc_source_set("rtc_media_base") {
|
||||
# TODO(kjellander): Remove (bugs.webrtc.org/6828)
|
||||
# Enabling GN check triggers cyclic dependency error:
|
||||
# //webrtc/media:rtc_media_base ->
|
||||
# //webrtc/pc:rtc_pc ->
|
||||
# //webrtc/media:media ->
|
||||
# //webrtc/pc:rtc_pc_base ->
|
||||
# //webrtc/media:rtc_data ->
|
||||
# //webrtc/media:rtc_media_base
|
||||
check_includes = false
|
||||
defines = []
|
||||
@ -42,6 +51,8 @@ rtc_static_library("rtc_media_base") {
|
||||
"base/codec.h",
|
||||
"base/cryptoparams.h",
|
||||
"base/device.h",
|
||||
"base/h264_profile_level_id.cc",
|
||||
"base/h264_profile_level_id.h",
|
||||
"base/mediachannel.h",
|
||||
"base/mediaconstants.cc",
|
||||
"base/mediaconstants.h",
|
||||
@ -87,13 +98,8 @@ rtc_static_library("rtc_media_base") {
|
||||
deps += [
|
||||
"..:webrtc_common",
|
||||
"../api:libjingle_peerconnection_api",
|
||||
"../api:video_frame_api",
|
||||
"../api/audio_codecs:audio_codecs_api",
|
||||
"../api/audio_codecs:builtin_audio_encoder_factory",
|
||||
"../base:rtc_base",
|
||||
"../base:rtc_base_approved",
|
||||
"../call:call_interfaces",
|
||||
"../common_video:common_video",
|
||||
"../p2p",
|
||||
]
|
||||
|
||||
@ -102,14 +108,7 @@ rtc_static_library("rtc_media_base") {
|
||||
}
|
||||
}
|
||||
|
||||
rtc_static_library("rtc_media") {
|
||||
# TODO(kjellander): Remove (bugs.webrtc.org/6828)
|
||||
# Enabling GN check triggers cyclic dependency error:
|
||||
# //webrtc/media:media ->
|
||||
# //webrtc/media:rtc_media ->
|
||||
# //webrtc/pc:rtc_pc ->
|
||||
# //webrtc/media:media
|
||||
check_includes = false
|
||||
rtc_static_library("rtc_audio_video") {
|
||||
defines = []
|
||||
libs = []
|
||||
deps = []
|
||||
@ -145,15 +144,9 @@ rtc_static_library("rtc_media") {
|
||||
"engine/webrtcvoe.h",
|
||||
"engine/webrtcvoiceengine.cc",
|
||||
"engine/webrtcvoiceengine.h",
|
||||
"sctp/sctptransportinternal.h",
|
||||
]
|
||||
|
||||
if (rtc_enable_sctp) {
|
||||
sources += [
|
||||
"sctp/sctptransport.cc",
|
||||
"sctp/sctptransport.h",
|
||||
]
|
||||
}
|
||||
configs += [ ":rtc_media_warnings_config" ]
|
||||
|
||||
if (!build_with_chromium && is_clang) {
|
||||
# Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
|
||||
@ -191,15 +184,6 @@ rtc_static_library("rtc_media") {
|
||||
include_dirs += [ "$rtc_libyuv_dir/include" ]
|
||||
}
|
||||
|
||||
if (rtc_enable_sctp && rtc_build_usrsctp) {
|
||||
include_dirs += [
|
||||
# TODO(jiayl): move this into the public_configs of
|
||||
# //third_party/usrsctp/BUILD.gn.
|
||||
"//third_party/usrsctp/usrsctplib",
|
||||
]
|
||||
deps += [ "//third_party/usrsctp" ]
|
||||
}
|
||||
|
||||
public_configs = []
|
||||
if (build_with_chromium) {
|
||||
deps += [ "../modules/video_capture:video_capture" ]
|
||||
@ -214,15 +198,19 @@ rtc_static_library("rtc_media") {
|
||||
}
|
||||
deps += [
|
||||
":rtc_media_base",
|
||||
"..:video_stream_api",
|
||||
"..:webrtc_common",
|
||||
"../api:call_api",
|
||||
"../api:libjingle_peerconnection_api",
|
||||
"../api:transport_api",
|
||||
"../api:video_frame_api",
|
||||
"../api/audio_codecs:audio_codecs_api",
|
||||
"../api/audio_codecs:builtin_audio_decoder_factory",
|
||||
"../api/audio_codecs:builtin_audio_encoder_factory",
|
||||
"../api/video_codecs:video_codecs_api",
|
||||
"../base:rtc_base",
|
||||
"../base:rtc_base_approved",
|
||||
"../base:rtc_task_queue",
|
||||
"../call",
|
||||
"../common_video:common_video",
|
||||
"../modules/audio_coding:rent_a_codec",
|
||||
@ -236,12 +224,68 @@ rtc_static_library("rtc_media") {
|
||||
"../modules/video_coding:webrtc_vp8",
|
||||
"../modules/video_coding:webrtc_vp9",
|
||||
"../p2p:rtc_p2p",
|
||||
"../pc:rtc_pc_base",
|
||||
"../system_wrappers",
|
||||
"../video",
|
||||
"../voice_engine",
|
||||
]
|
||||
}
|
||||
|
||||
rtc_static_library("rtc_data") {
|
||||
defines = []
|
||||
deps = []
|
||||
|
||||
if (rtc_enable_sctp) {
|
||||
sources = [
|
||||
"sctp/sctptransport.cc",
|
||||
"sctp/sctptransport.h",
|
||||
"sctp/sctptransportinternal.h",
|
||||
]
|
||||
}
|
||||
|
||||
configs += [ ":rtc_media_warnings_config" ]
|
||||
|
||||
if (!build_with_chromium && is_clang) {
|
||||
# Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
|
||||
suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
|
||||
}
|
||||
|
||||
if (is_win) {
|
||||
cflags = [
|
||||
"/wd4245", # conversion from "int" to "size_t", signed/unsigned mismatch.
|
||||
"/wd4267", # conversion from "size_t" to "int", possible loss of data.
|
||||
"/wd4389", # signed/unsigned mismatch.
|
||||
]
|
||||
}
|
||||
|
||||
if (rtc_enable_sctp && rtc_build_usrsctp) {
|
||||
include_dirs = [
|
||||
# TODO(jiayl): move this into the public_configs of
|
||||
# //third_party/usrsctp/BUILD.gn.
|
||||
"//third_party/usrsctp/usrsctplib",
|
||||
]
|
||||
deps += [ "//third_party/usrsctp" ]
|
||||
}
|
||||
|
||||
deps += [
|
||||
":rtc_media_base",
|
||||
"..:webrtc_common",
|
||||
"../api:call_api",
|
||||
"../api:transport_api",
|
||||
"../base:rtc_base",
|
||||
"../base:rtc_base_approved",
|
||||
"../p2p:rtc_p2p",
|
||||
"../system_wrappers",
|
||||
]
|
||||
}
|
||||
|
||||
rtc_source_set("rtc_media") {
|
||||
public_deps = [
|
||||
":rtc_audio_video",
|
||||
":rtc_data",
|
||||
]
|
||||
}
|
||||
|
||||
if (rtc_include_tests) {
|
||||
config("rtc_unittest_main_config") {
|
||||
# GN orders flags on a target before flags from configs. The default config
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/stringencode.h"
|
||||
#include "webrtc/base/stringutils.h"
|
||||
#include "webrtc/common_video/h264/profile_level_id.h"
|
||||
#include "webrtc/media/base/h264_profile_level_id.h"
|
||||
|
||||
namespace cricket {
|
||||
|
||||
|
||||
@ -424,6 +424,10 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
|
||||
sink_ = std::move(sink);
|
||||
}
|
||||
|
||||
virtual std::vector<webrtc::RtpSource> GetSources(uint32_t ssrc) const {
|
||||
return std::vector<webrtc::RtpSource>();
|
||||
}
|
||||
|
||||
private:
|
||||
class VoiceChannelAudioSink : public AudioSource::Sink {
|
||||
public:
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
||||
* Copyright (c) 2017 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
|
||||
@ -8,7 +8,7 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/common_video/h264/profile_level_id.h"
|
||||
#include "webrtc/media/base/h264_profile_level_id.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@ -33,14 +33,9 @@ const uint8_t kConstraintSet3Flag = 0x10;
|
||||
// will return 0b10110000. constexpr is used so that the pattern table in
|
||||
// kProfilePatterns is statically initialized.
|
||||
constexpr uint8_t ByteMaskString(char c, const char (&str)[9]) {
|
||||
return (str[0] == c) << 7
|
||||
| (str[1] == c) << 6
|
||||
| (str[2] == c) << 5
|
||||
| (str[3] == c) << 4
|
||||
| (str[4] == c) << 3
|
||||
| (str[5] == c) << 2
|
||||
| (str[6] == c) << 1
|
||||
| (str[7] == c) << 0;
|
||||
return (str[0] == c) << 7 | (str[1] == c) << 6 | (str[2] == c) << 5 |
|
||||
(str[3] == c) << 4 | (str[4] == c) << 3 | (str[5] == c) << 2 |
|
||||
(str[6] == c) << 1 | (str[7] == c) << 0;
|
||||
}
|
||||
|
||||
// Class for matching bit patterns such as "x1xx0000" where 'x' is allowed to be
|
||||
102
webrtc/media/base/h264_profile_level_id.h
Normal file
102
webrtc/media/base/h264_profile_level_id.h
Normal file
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2017 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.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MEDIA_BASE_H264_PROFILE_LEVEL_ID_H_
|
||||
#define WEBRTC_MEDIA_BASE_H264_PROFILE_LEVEL_ID_H_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "webrtc/base/optional.h"
|
||||
#include "webrtc/common_types.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace H264 {
|
||||
|
||||
// Map containting SDP codec parameters.
|
||||
typedef std::map<std::string, std::string> CodecParameterMap;
|
||||
|
||||
// All values are equal to ten times the level number, except level 1b which is
|
||||
// special.
|
||||
enum Level {
|
||||
kLevel1_b = 0,
|
||||
kLevel1 = 10,
|
||||
kLevel1_1 = 11,
|
||||
kLevel1_2 = 12,
|
||||
kLevel1_3 = 13,
|
||||
kLevel2 = 20,
|
||||
kLevel2_1 = 21,
|
||||
kLevel2_2 = 22,
|
||||
kLevel3 = 30,
|
||||
kLevel3_1 = 31,
|
||||
kLevel3_2 = 32,
|
||||
kLevel4 = 40,
|
||||
kLevel4_1 = 41,
|
||||
kLevel4_2 = 42,
|
||||
kLevel5 = 50,
|
||||
kLevel5_1 = 51,
|
||||
kLevel5_2 = 52
|
||||
};
|
||||
|
||||
struct ProfileLevelId {
|
||||
ProfileLevelId(Profile profile, Level level)
|
||||
: profile(profile), level(level) {}
|
||||
Profile profile;
|
||||
Level level;
|
||||
};
|
||||
|
||||
// Parse profile level id that is represented as a string of 3 hex bytes.
|
||||
// Nothing will be returned if the string is not a recognized H264
|
||||
// profile level id.
|
||||
rtc::Optional<ProfileLevelId> ParseProfileLevelId(const char* str);
|
||||
|
||||
// Parse profile level id that is represented as a string of 3 hex bytes
|
||||
// contained in an SDP key-value map. A default profile level id will be
|
||||
// returned if the profile-level-id key is missing. Nothing will be returned if
|
||||
// the key is present but the string is invalid.
|
||||
rtc::Optional<ProfileLevelId> ParseSdpProfileLevelId(
|
||||
const CodecParameterMap& params);
|
||||
|
||||
// Given that a decoder supports up to a given frame size (in pixels) at up to a
|
||||
// given number of frames per second, return the highest H.264 level where it
|
||||
// can guarantee that it will be able to support all valid encoded streams that
|
||||
// are within that level.
|
||||
rtc::Optional<Level> SupportedLevel(int max_frame_pixel_count, float max_fps);
|
||||
|
||||
// Returns canonical string representation as three hex bytes of the profile
|
||||
// level id, or returns nothing for invalid profile level ids.
|
||||
rtc::Optional<std::string> ProfileLevelIdToString(
|
||||
const ProfileLevelId& profile_level_id);
|
||||
|
||||
// Generate codec parameters that will be used as answer in an SDP negotiation
|
||||
// based on local supported parameters and remote offered parameters. Both
|
||||
// |local_supported_params|, |remote_offered_params|, and |answer_params|
|
||||
// represent sendrecv media descriptions, i.e they are a mix of both encode and
|
||||
// decode capabilities. In theory, when the profile in |local_supported_params|
|
||||
// represent a strict superset of the profile in |remote_offered_params|, we
|
||||
// could limit the profile in |answer_params| to the profile in
|
||||
// |remote_offered_params|. However, to simplify the code, each supported H264
|
||||
// profile should be listed explicitly in the list of local supported codecs,
|
||||
// even if they are redundant. Then each local codec in the list should be
|
||||
// tested one at a time against the remote codec, and only when the profiles are
|
||||
// equal should this function be called. Therefore, this function does not need
|
||||
// to handle profile intersection, and the profile of |local_supported_params|
|
||||
// and |remote_offered_params| must be equal before calling this function. The
|
||||
// parameters that are used when negotiating are the level part of
|
||||
// profile-level-id and level-asymmetry-allowed.
|
||||
void GenerateProfileLevelIdForAnswer(
|
||||
const CodecParameterMap& local_supported_params,
|
||||
const CodecParameterMap& remote_offered_params,
|
||||
CodecParameterMap* answer_params);
|
||||
|
||||
} // namespace H264
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MEDIA_BASE_H264_PROFILE_LEVEL_ID_H_
|
||||
@ -16,6 +16,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/api/rtpparameters.h"
|
||||
#include "webrtc/api/rtpreceiverinterface.h"
|
||||
#include "webrtc/base/basictypes.h"
|
||||
#include "webrtc/base/buffer.h"
|
||||
#include "webrtc/base/copyonwritebuffer.h"
|
||||
@ -1000,6 +1001,8 @@ class VoiceMediaChannel : public MediaChannel {
|
||||
virtual void SetRawAudioSink(
|
||||
uint32_t ssrc,
|
||||
std::unique_ptr<webrtc::AudioSinkInterface> sink) = 0;
|
||||
|
||||
virtual std::vector<webrtc::RtpSource> GetSources(uint32_t ssrc) const = 0;
|
||||
};
|
||||
|
||||
// TODO(deadbeef): Rename to VideoSenderParameters, since they're intended to
|
||||
|
||||
@ -222,7 +222,7 @@ class WebRtcVoiceMediaChannel final : public VoiceMediaChannel,
|
||||
uint32_t ssrc,
|
||||
std::unique_ptr<webrtc::AudioSinkInterface> sink) override;
|
||||
|
||||
std::vector<webrtc::RtpSource> GetSources(uint32_t ssrc) const;
|
||||
std::vector<webrtc::RtpSource> GetSources(uint32_t ssrc) const override;
|
||||
|
||||
// implements Transport interface
|
||||
bool SendRtp(const uint8_t* data,
|
||||
|
||||
@ -25,7 +25,7 @@ config("rtc_pc_config") {
|
||||
}
|
||||
}
|
||||
|
||||
rtc_static_library("rtc_pc") {
|
||||
rtc_static_library("rtc_pc_base") {
|
||||
defines = []
|
||||
sources = [
|
||||
"audiomonitor.cc",
|
||||
@ -59,8 +59,9 @@ rtc_static_library("rtc_pc") {
|
||||
"../api:libjingle_peerconnection_api",
|
||||
"../api:ortc_api",
|
||||
"../base:rtc_base",
|
||||
"../common_video:common_video",
|
||||
"../media",
|
||||
"../base:rtc_task_queue",
|
||||
"../media:rtc_data",
|
||||
"../media:rtc_media_base",
|
||||
"../p2p:rtc_p2p",
|
||||
]
|
||||
|
||||
@ -76,6 +77,16 @@ rtc_static_library("rtc_pc") {
|
||||
}
|
||||
}
|
||||
|
||||
rtc_source_set("rtc_pc") {
|
||||
public_deps = [
|
||||
":rtc_pc_base",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"../media:rtc_audio_video",
|
||||
]
|
||||
}
|
||||
|
||||
config("libjingle_peerconnection_warnings_config") {
|
||||
# GN orders flags on a target before flags from configs. The default config
|
||||
# adds these flags so to cancel them out they need to come from a config and
|
||||
@ -85,7 +96,7 @@ config("libjingle_peerconnection_warnings_config") {
|
||||
}
|
||||
}
|
||||
|
||||
rtc_static_library("libjingle_peerconnection") {
|
||||
rtc_static_library("peerconnection") {
|
||||
cflags = []
|
||||
sources = [
|
||||
"audiotrack.cc",
|
||||
@ -146,19 +157,17 @@ rtc_static_library("libjingle_peerconnection") {
|
||||
}
|
||||
|
||||
deps = [
|
||||
":rtc_pc",
|
||||
":rtc_pc_base",
|
||||
"..:webrtc_common",
|
||||
"../api:call_api",
|
||||
"../api:rtc_stats_api",
|
||||
"../api/audio_codecs:builtin_audio_decoder_factory",
|
||||
"../api/audio_codecs:builtin_audio_encoder_factory",
|
||||
"../api/video_codecs:video_codecs_api",
|
||||
"../base:rtc_base",
|
||||
"../base:rtc_base_approved",
|
||||
"../call",
|
||||
"../call:call_interfaces",
|
||||
"../logging:rtc_event_log_api",
|
||||
"../media",
|
||||
"../modules/audio_device:audio_device",
|
||||
"../media:rtc_data",
|
||||
"../media:rtc_media_base",
|
||||
"../p2p:rtc_p2p",
|
||||
"../stats",
|
||||
"../system_wrappers:system_wrappers",
|
||||
@ -167,6 +176,48 @@ rtc_static_library("libjingle_peerconnection") {
|
||||
public_deps = [
|
||||
"../api:libjingle_peerconnection_api",
|
||||
]
|
||||
}
|
||||
|
||||
# This target implements CreatePeerConnectionFactory methods that will create a
|
||||
# PeerConnection will full functionality (audio, video and data). Applications
|
||||
# that wish to reduce their binary size by ommitting functionality they don't
|
||||
# need should use CreateModularCreatePeerConnectionFactory instead, using the
|
||||
# "peerconnection" build target and other targets specific to their
|
||||
# requrements. See comment in peerconnectionfactoryinterface.h.
|
||||
rtc_source_set("create_pc_factory") {
|
||||
sources = [
|
||||
"createpeerconnectionfactory.cc",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"../api:audio_mixer_api",
|
||||
"../api:libjingle_peerconnection_api",
|
||||
"../api/audio_codecs:audio_codecs_api",
|
||||
"../api/audio_codecs:builtin_audio_decoder_factory",
|
||||
"../api/audio_codecs:builtin_audio_encoder_factory",
|
||||
"../base:rtc_base",
|
||||
"../base:rtc_base_approved",
|
||||
"../call",
|
||||
"../call:call_interfaces",
|
||||
"../logging:rtc_event_log_api",
|
||||
"../media:rtc_audio_video",
|
||||
"../modules/audio_device:audio_device",
|
||||
]
|
||||
|
||||
configs += [ ":libjingle_peerconnection_warnings_config" ]
|
||||
|
||||
if (!build_with_chromium && is_clang) {
|
||||
# Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
|
||||
suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
|
||||
}
|
||||
}
|
||||
|
||||
rtc_source_set("libjingle_peerconnection") {
|
||||
public_deps = [
|
||||
":create_pc_factory",
|
||||
":peerconnection",
|
||||
"../api:libjingle_peerconnection_api",
|
||||
]
|
||||
|
||||
if (rtc_use_quic) {
|
||||
sources += [
|
||||
@ -271,6 +322,8 @@ if (rtc_include_tests) {
|
||||
"../base:rtc_base",
|
||||
"../base:rtc_base_approved",
|
||||
"../base:rtc_base_tests_utils",
|
||||
"../call:call_interfaces",
|
||||
"../logging:rtc_event_log_api",
|
||||
"../media:rtc_media",
|
||||
"../media:rtc_media_tests_utils",
|
||||
"../modules/audio_device:audio_device",
|
||||
|
||||
@ -23,7 +23,9 @@
|
||||
#include "webrtc/base/trace_event.h"
|
||||
#include "webrtc/media/base/mediaconstants.h"
|
||||
#include "webrtc/media/base/rtputils.h"
|
||||
#include "webrtc/media/engine/webrtcvoiceengine.h"
|
||||
// Adding 'nogncheck' to disable the gn include headers check to support modular
|
||||
// WebRTC build targets.
|
||||
#include "webrtc/media/engine/webrtcvoiceengine.h" // nogncheck
|
||||
#include "webrtc/p2p/base/packettransportinternal.h"
|
||||
#include "webrtc/pc/channelmanager.h"
|
||||
|
||||
@ -1575,9 +1577,12 @@ bool VoiceChannel::GetStats(VoiceMediaInfo* stats) {
|
||||
|
||||
std::vector<webrtc::RtpSource> VoiceChannel::GetSources(uint32_t ssrc) const {
|
||||
return worker_thread()->Invoke<std::vector<webrtc::RtpSource>>(
|
||||
RTC_FROM_HERE,
|
||||
Bind(&WebRtcVoiceMediaChannel::GetSources,
|
||||
static_cast<WebRtcVoiceMediaChannel*>(media_channel()), ssrc));
|
||||
RTC_FROM_HERE, Bind(&VoiceChannel::GetSources_w, this, ssrc));
|
||||
}
|
||||
|
||||
std::vector<webrtc::RtpSource> VoiceChannel::GetSources_w(uint32_t ssrc) const {
|
||||
RTC_DCHECK(worker_thread()->IsCurrent());
|
||||
return media_channel()->GetSources(ssrc);
|
||||
}
|
||||
|
||||
void VoiceChannel::StartMediaMonitor(int cms) {
|
||||
|
||||
@ -471,6 +471,7 @@ class VoiceChannel : public BaseChannel {
|
||||
bool GetStats(VoiceMediaInfo* stats);
|
||||
|
||||
std::vector<webrtc::RtpSource> GetSources(uint32_t ssrc) const;
|
||||
std::vector<webrtc::RtpSource> GetSources_w(uint32_t ssrc) const;
|
||||
|
||||
// Monitoring functions
|
||||
sigslot::signal2<VoiceChannel*, const std::vector<ConnectionInfo>&>
|
||||
|
||||
@ -89,21 +89,33 @@ bool ChannelManager::SetVideoRtxEnabled(bool enable) {
|
||||
|
||||
void ChannelManager::GetSupportedAudioSendCodecs(
|
||||
std::vector<AudioCodec>* codecs) const {
|
||||
if (!media_engine_) {
|
||||
return;
|
||||
}
|
||||
*codecs = media_engine_->audio_send_codecs();
|
||||
}
|
||||
|
||||
void ChannelManager::GetSupportedAudioReceiveCodecs(
|
||||
std::vector<AudioCodec>* codecs) const {
|
||||
if (!media_engine_) {
|
||||
return;
|
||||
}
|
||||
*codecs = media_engine_->audio_recv_codecs();
|
||||
}
|
||||
|
||||
void ChannelManager::GetSupportedAudioRtpHeaderExtensions(
|
||||
RtpHeaderExtensions* ext) const {
|
||||
if (!media_engine_) {
|
||||
return;
|
||||
}
|
||||
*ext = media_engine_->GetAudioCapabilities().header_extensions;
|
||||
}
|
||||
|
||||
void ChannelManager::GetSupportedVideoCodecs(
|
||||
std::vector<VideoCodec>* codecs) const {
|
||||
if (!media_engine_) {
|
||||
return;
|
||||
}
|
||||
codecs->clear();
|
||||
|
||||
std::vector<VideoCodec> video_codecs = media_engine_->video_codecs();
|
||||
@ -118,11 +130,17 @@ void ChannelManager::GetSupportedVideoCodecs(
|
||||
|
||||
void ChannelManager::GetSupportedVideoRtpHeaderExtensions(
|
||||
RtpHeaderExtensions* ext) const {
|
||||
if (!media_engine_) {
|
||||
return;
|
||||
}
|
||||
*ext = media_engine_->GetVideoCapabilities().header_extensions;
|
||||
}
|
||||
|
||||
void ChannelManager::GetSupportedDataCodecs(
|
||||
std::vector<DataCodec>* codecs) const {
|
||||
if (!data_media_engine_) {
|
||||
return;
|
||||
}
|
||||
*codecs = data_media_engine_->data_codecs();
|
||||
}
|
||||
|
||||
@ -148,7 +166,10 @@ bool ChannelManager::Init() {
|
||||
|
||||
bool ChannelManager::InitMediaEngine_w() {
|
||||
RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
|
||||
return media_engine_->Init();
|
||||
if (media_engine_) {
|
||||
return media_engine_->Init();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChannelManager::Terminate() {
|
||||
@ -223,6 +244,9 @@ VoiceChannel* ChannelManager::CreateVoiceChannel_w(
|
||||
RTC_DCHECK(initialized_);
|
||||
RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
|
||||
RTC_DCHECK(nullptr != call);
|
||||
if (!media_engine_) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
VoiceMediaChannel* media_channel = media_engine_->CreateChannel(
|
||||
call, media_config, options);
|
||||
|
||||
112
webrtc/pc/createpeerconnectionfactory.cc
Normal file
112
webrtc/pc/createpeerconnectionfactory.cc
Normal file
@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright 2017 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.
|
||||
*/
|
||||
|
||||
#include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h"
|
||||
#include "webrtc/api/audio_codecs/builtin_audio_encoder_factory.h"
|
||||
#include "webrtc/api/peerconnectioninterface.h"
|
||||
#include "webrtc/base/bind.h"
|
||||
#include "webrtc/base/scoped_ref_ptr.h"
|
||||
#include "webrtc/base/thread.h"
|
||||
#include "webrtc/call/callfactoryinterface.h"
|
||||
#include "webrtc/logging/rtc_event_log/rtc_event_log_factory_interface.h"
|
||||
#include "webrtc/media/engine/webrtcmediaengine.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
|
||||
rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
|
||||
rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory) {
|
||||
return CreatePeerConnectionFactoryWithAudioMixer(
|
||||
nullptr /*network_thread*/, nullptr /*worker_thread*/,
|
||||
nullptr /*signaling_thread*/, nullptr /*default_adm*/,
|
||||
audio_encoder_factory, audio_decoder_factory,
|
||||
nullptr /*video_encoder_factory*/, nullptr /*video_decoder_factory*/,
|
||||
nullptr /*audio_mixer*/);
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface>
|
||||
CreatePeerConnectionFactory() {
|
||||
return CreatePeerConnectionFactory(CreateBuiltinAudioEncoderFactory(),
|
||||
CreateBuiltinAudioDecoderFactory());
|
||||
}
|
||||
|
||||
// Note: all the other CreatePeerConnectionFactory variants just end up calling
|
||||
// this, ultimately.
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface>
|
||||
CreatePeerConnectionFactoryWithAudioMixer(
|
||||
rtc::Thread* network_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
rtc::Thread* signaling_thread,
|
||||
AudioDeviceModule* default_adm,
|
||||
rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
|
||||
rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
|
||||
cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
|
||||
cricket::WebRtcVideoDecoderFactory* video_decoder_factory,
|
||||
rtc::scoped_refptr<AudioMixer> audio_mixer) {
|
||||
std::unique_ptr<cricket::MediaEngineInterface> media_engine(
|
||||
cricket::WebRtcMediaEngineFactory::Create(
|
||||
default_adm, audio_encoder_factory, audio_decoder_factory,
|
||||
video_encoder_factory, video_decoder_factory, audio_mixer));
|
||||
|
||||
std::unique_ptr<CallFactoryInterface> call_factory = CreateCallFactory();
|
||||
|
||||
std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory =
|
||||
CreateRtcEventLogFactory();
|
||||
|
||||
return CreateModularPeerConnectionFactory(
|
||||
network_thread, worker_thread, signaling_thread, default_adm,
|
||||
audio_encoder_factory, audio_decoder_factory, video_encoder_factory,
|
||||
video_decoder_factory, audio_mixer, std::move(media_engine),
|
||||
std::move(call_factory), std::move(event_log_factory));
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface>
|
||||
CreatePeerConnectionFactoryWithAudioMixer(
|
||||
rtc::Thread* network_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
rtc::Thread* signaling_thread,
|
||||
AudioDeviceModule* default_adm,
|
||||
cricket::WebRtcVideoEncoderFactory* encoder_factory,
|
||||
cricket::WebRtcVideoDecoderFactory* decoder_factory,
|
||||
rtc::scoped_refptr<AudioMixer> audio_mixer) {
|
||||
return CreatePeerConnectionFactoryWithAudioMixer(
|
||||
network_thread, worker_thread, signaling_thread, default_adm,
|
||||
CreateBuiltinAudioEncoderFactory(), CreateBuiltinAudioDecoderFactory(),
|
||||
encoder_factory, decoder_factory, audio_mixer);
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
|
||||
rtc::Thread* network_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
rtc::Thread* signaling_thread,
|
||||
AudioDeviceModule* default_adm,
|
||||
cricket::WebRtcVideoEncoderFactory* encoder_factory,
|
||||
cricket::WebRtcVideoDecoderFactory* decoder_factory) {
|
||||
return CreatePeerConnectionFactoryWithAudioMixer(
|
||||
network_thread, worker_thread, signaling_thread, default_adm,
|
||||
encoder_factory, decoder_factory, nullptr);
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
|
||||
rtc::Thread* network_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
rtc::Thread* signaling_thread,
|
||||
AudioDeviceModule* default_adm,
|
||||
rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
|
||||
rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
|
||||
cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
|
||||
cricket::WebRtcVideoDecoderFactory* video_decoder_factory) {
|
||||
return CreatePeerConnectionFactoryWithAudioMixer(
|
||||
network_thread, worker_thread, signaling_thread, default_adm,
|
||||
audio_encoder_factory, audio_decoder_factory, video_encoder_factory,
|
||||
video_decoder_factory, nullptr);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@ -25,8 +25,8 @@
|
||||
#include "webrtc/base/optional.h"
|
||||
#include "webrtc/base/stringutils.h"
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/common_video/h264/profile_level_id.h"
|
||||
#include "webrtc/media/base/cryptoparams.h"
|
||||
#include "webrtc/media/base/h264_profile_level_id.h"
|
||||
#include "webrtc/media/base/mediaconstants.h"
|
||||
#include "webrtc/p2p/base/p2pconstants.h"
|
||||
#include "webrtc/pc/channelmanager.h"
|
||||
|
||||
@ -391,17 +391,20 @@ bool ParseConstraintsForAnswer(const MediaConstraintsInterface* constraints,
|
||||
return mandatory_constraints_satisfied == constraints->GetMandatory().size();
|
||||
}
|
||||
|
||||
PeerConnection::PeerConnection(PeerConnectionFactory* factory)
|
||||
PeerConnection::PeerConnection(PeerConnectionFactory* factory,
|
||||
std::unique_ptr<RtcEventLog> event_log,
|
||||
std::unique_ptr<Call> call)
|
||||
: factory_(factory),
|
||||
observer_(NULL),
|
||||
uma_observer_(NULL),
|
||||
event_log_(RtcEventLog::Create()),
|
||||
event_log_(std::move(event_log)),
|
||||
signaling_state_(kStable),
|
||||
ice_connection_state_(kIceConnectionNew),
|
||||
ice_gathering_state_(kIceGatheringNew),
|
||||
rtcp_cname_(GenerateRtcpCname()),
|
||||
local_streams_(StreamCollection::Create()),
|
||||
remote_streams_(StreamCollection::Create()) {}
|
||||
remote_streams_(StreamCollection::Create()),
|
||||
call_(std::move(call)) {}
|
||||
|
||||
PeerConnection::~PeerConnection() {
|
||||
TRACE_EVENT0("webrtc", "PeerConnection::~PeerConnection");
|
||||
@ -460,10 +463,6 @@ bool PeerConnection::Initialize(
|
||||
return false;
|
||||
}
|
||||
|
||||
// Call must be constructed on the worker thread.
|
||||
factory_->worker_thread()->Invoke<void>(
|
||||
RTC_FROM_HERE, rtc::Bind(&PeerConnection::CreateCall_w,
|
||||
this));
|
||||
|
||||
session_.reset(new WebRtcSession(
|
||||
call_.get(), factory_->channel_manager(), configuration.media_config,
|
||||
@ -2375,21 +2374,4 @@ void PeerConnection::StopRtcEventLog_w() {
|
||||
}
|
||||
}
|
||||
|
||||
void PeerConnection::CreateCall_w() {
|
||||
RTC_DCHECK(!call_);
|
||||
|
||||
const int kMinBandwidthBps = 30000;
|
||||
const int kStartBandwidthBps = 300000;
|
||||
const int kMaxBandwidthBps = 2000000;
|
||||
|
||||
webrtc::Call::Config call_config(event_log_.get());
|
||||
call_config.audio_state =
|
||||
factory_->channel_manager() ->media_engine()->GetAudioState();
|
||||
call_config.bitrate_config.min_bitrate_bps = kMinBandwidthBps;
|
||||
call_config.bitrate_config.start_bitrate_bps = kStartBandwidthBps;
|
||||
call_config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps;
|
||||
|
||||
call_.reset(webrtc::Call::Create(call_config));
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -61,7 +61,9 @@ class PeerConnection : public PeerConnectionInterface,
|
||||
public rtc::MessageHandler,
|
||||
public sigslot::has_slots<> {
|
||||
public:
|
||||
explicit PeerConnection(PeerConnectionFactory* factory);
|
||||
explicit PeerConnection(PeerConnectionFactory* factory,
|
||||
std::unique_ptr<RtcEventLog> event_log,
|
||||
std::unique_ptr<Call> call);
|
||||
|
||||
bool Initialize(
|
||||
const PeerConnectionInterface::RTCConfiguration& configuration,
|
||||
@ -392,9 +394,6 @@ class PeerConnection : public PeerConnectionInterface,
|
||||
// This function should only be called from the worker thread.
|
||||
void StopRtcEventLog_w();
|
||||
|
||||
// Creates the |*call_| object. Must only be called from the worker thread.
|
||||
void CreateCall_w();
|
||||
|
||||
// Storing the factory as a scoped reference pointer ensures that the memory
|
||||
// in the PeerConnectionFactoryImpl remains available as long as the
|
||||
// PeerConnection is running. It is passed to PeerConnection as a raw pointer.
|
||||
|
||||
@ -12,8 +12,6 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h"
|
||||
#include "webrtc/api/audio_codecs/builtin_audio_encoder_factory.h"
|
||||
#include "webrtc/api/mediaconstraintsinterface.h"
|
||||
#include "webrtc/api/mediastreamproxy.h"
|
||||
#include "webrtc/api/mediastreamtrackproxy.h"
|
||||
@ -22,10 +20,15 @@
|
||||
#include "webrtc/api/videosourceproxy.h"
|
||||
#include "webrtc/base/bind.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/media/engine/webrtcmediaengine.h"
|
||||
#include "webrtc/media/engine/webrtcvideodecoderfactory.h"
|
||||
#include "webrtc/media/engine/webrtcvideoencoderfactory.h"
|
||||
#include "webrtc/modules/audio_device/include/audio_device.h"
|
||||
#include "webrtc/logging/rtc_event_log/rtc_event_log.h"
|
||||
// Adding 'nogncheck' to disable the gn include headers check to support modular
|
||||
// WebRTC build targets.
|
||||
// TODO(zhihuang): This wouldn't be necessary if the interface and
|
||||
// implementation of the media engine were in separate build targets.
|
||||
#include "webrtc/media/engine/webrtcmediaengine.h" // nogncheck
|
||||
#include "webrtc/media/engine/webrtcvideodecoderfactory.h" // nogncheck
|
||||
#include "webrtc/media/engine/webrtcvideoencoderfactory.h" // nogncheck
|
||||
#include "webrtc/modules/audio_device/include/audio_device.h" // nogncheck
|
||||
#include "webrtc/p2p/base/basicpacketsocketfactory.h"
|
||||
#include "webrtc/p2p/client/basicportallocator.h"
|
||||
#include "webrtc/pc/audiotrack.h"
|
||||
@ -37,58 +40,8 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
|
||||
rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
|
||||
rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory) {
|
||||
rtc::scoped_refptr<PeerConnectionFactory> pc_factory(
|
||||
new rtc::RefCountedObject<PeerConnectionFactory>(audio_encoder_factory,
|
||||
audio_decoder_factory));
|
||||
|
||||
RTC_CHECK(rtc::Thread::Current() == pc_factory->signaling_thread());
|
||||
// The signaling thread is the current thread so we can
|
||||
// safely call Initialize directly.
|
||||
if (!pc_factory->Initialize()) {
|
||||
return nullptr;
|
||||
}
|
||||
return PeerConnectionFactoryProxy::Create(pc_factory->signaling_thread(),
|
||||
pc_factory);
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface>
|
||||
CreatePeerConnectionFactory() {
|
||||
return CreatePeerConnectionFactory(CreateBuiltinAudioEncoderFactory(),
|
||||
CreateBuiltinAudioDecoderFactory());
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
|
||||
rtc::Thread* network_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
rtc::Thread* signaling_thread,
|
||||
AudioDeviceModule* default_adm,
|
||||
rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
|
||||
rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
|
||||
cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
|
||||
cricket::WebRtcVideoDecoderFactory* video_decoder_factory) {
|
||||
return CreatePeerConnectionFactoryWithAudioMixer(
|
||||
network_thread, worker_thread, signaling_thread, default_adm,
|
||||
audio_encoder_factory, audio_decoder_factory, video_encoder_factory,
|
||||
video_decoder_factory, nullptr);
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
|
||||
rtc::Thread* network_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
rtc::Thread* signaling_thread,
|
||||
AudioDeviceModule* default_adm,
|
||||
cricket::WebRtcVideoEncoderFactory* encoder_factory,
|
||||
cricket::WebRtcVideoDecoderFactory* decoder_factory) {
|
||||
return CreatePeerConnectionFactoryWithAudioMixer(
|
||||
network_thread, worker_thread, signaling_thread, default_adm,
|
||||
encoder_factory, decoder_factory, nullptr);
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface>
|
||||
CreatePeerConnectionFactoryWithAudioMixer(
|
||||
CreateModularPeerConnectionFactory(
|
||||
rtc::Thread* network_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
rtc::Thread* signaling_thread,
|
||||
@ -97,56 +50,28 @@ CreatePeerConnectionFactoryWithAudioMixer(
|
||||
rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
|
||||
cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
|
||||
cricket::WebRtcVideoDecoderFactory* video_decoder_factory,
|
||||
rtc::scoped_refptr<AudioMixer> audio_mixer) {
|
||||
rtc::scoped_refptr<AudioMixer> audio_mixer,
|
||||
std::unique_ptr<cricket::MediaEngineInterface> media_engine,
|
||||
std::unique_ptr<CallFactoryInterface> call_factory,
|
||||
std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory) {
|
||||
rtc::scoped_refptr<PeerConnectionFactory> pc_factory(
|
||||
new rtc::RefCountedObject<PeerConnectionFactory>(
|
||||
network_thread, worker_thread, signaling_thread, default_adm,
|
||||
audio_encoder_factory, audio_decoder_factory, video_encoder_factory,
|
||||
video_decoder_factory, audio_mixer));
|
||||
video_decoder_factory, audio_mixer, std::move(media_engine),
|
||||
std::move(call_factory), std::move(event_log_factory)));
|
||||
|
||||
// Call Initialize synchronously but make sure it is executed on
|
||||
// |signaling_thread|.
|
||||
MethodCall0<PeerConnectionFactory, bool> call(
|
||||
pc_factory.get(), &PeerConnectionFactory::Initialize);
|
||||
bool result = call.Marshal(RTC_FROM_HERE, signaling_thread);
|
||||
bool result = call.Marshal(RTC_FROM_HERE, pc_factory->signaling_thread());
|
||||
|
||||
if (!result) {
|
||||
return nullptr;
|
||||
}
|
||||
return PeerConnectionFactoryProxy::Create(signaling_thread, pc_factory);
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface>
|
||||
CreatePeerConnectionFactoryWithAudioMixer(
|
||||
rtc::Thread* network_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
rtc::Thread* signaling_thread,
|
||||
AudioDeviceModule* default_adm,
|
||||
cricket::WebRtcVideoEncoderFactory* encoder_factory,
|
||||
cricket::WebRtcVideoDecoderFactory* decoder_factory,
|
||||
rtc::scoped_refptr<AudioMixer> audio_mixer) {
|
||||
return CreatePeerConnectionFactoryWithAudioMixer(
|
||||
network_thread, worker_thread, signaling_thread, default_adm,
|
||||
CreateBuiltinAudioEncoderFactory(), CreateBuiltinAudioDecoderFactory(),
|
||||
encoder_factory, decoder_factory, audio_mixer);
|
||||
}
|
||||
|
||||
PeerConnectionFactory::PeerConnectionFactory(
|
||||
rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory,
|
||||
rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory)
|
||||
: owns_ptrs_(true),
|
||||
wraps_current_thread_(false),
|
||||
network_thread_(rtc::Thread::CreateWithSocketServer().release()),
|
||||
worker_thread_(rtc::Thread::Create().release()),
|
||||
signaling_thread_(rtc::Thread::Current()),
|
||||
audio_encoder_factory_(audio_encoder_factory),
|
||||
audio_decoder_factory_(audio_decoder_factory) {
|
||||
if (!signaling_thread_) {
|
||||
signaling_thread_ = rtc::ThreadManager::Instance()->WrapCurrentThread();
|
||||
wraps_current_thread_ = true;
|
||||
}
|
||||
network_thread_->Start();
|
||||
worker_thread_->Start();
|
||||
return PeerConnectionFactoryProxy::Create(pc_factory->signaling_thread(),
|
||||
pc_factory);
|
||||
}
|
||||
|
||||
PeerConnectionFactory::PeerConnectionFactory(
|
||||
@ -158,9 +83,11 @@ PeerConnectionFactory::PeerConnectionFactory(
|
||||
rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory,
|
||||
cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
|
||||
cricket::WebRtcVideoDecoderFactory* video_decoder_factory,
|
||||
rtc::scoped_refptr<AudioMixer> audio_mixer)
|
||||
: owns_ptrs_(false),
|
||||
wraps_current_thread_(false),
|
||||
rtc::scoped_refptr<AudioMixer> audio_mixer,
|
||||
std::unique_ptr<cricket::MediaEngineInterface> media_engine,
|
||||
std::unique_ptr<webrtc::CallFactoryInterface> call_factory,
|
||||
std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory)
|
||||
: wraps_current_thread_(false),
|
||||
network_thread_(network_thread),
|
||||
worker_thread_(worker_thread),
|
||||
signaling_thread_(signaling_thread),
|
||||
@ -169,10 +96,32 @@ PeerConnectionFactory::PeerConnectionFactory(
|
||||
audio_decoder_factory_(audio_decoder_factory),
|
||||
video_encoder_factory_(video_encoder_factory),
|
||||
video_decoder_factory_(video_decoder_factory),
|
||||
external_audio_mixer_(audio_mixer) {
|
||||
RTC_DCHECK(network_thread);
|
||||
RTC_DCHECK(worker_thread);
|
||||
RTC_DCHECK(signaling_thread);
|
||||
external_audio_mixer_(audio_mixer),
|
||||
media_engine_(std::move(media_engine)),
|
||||
call_factory_(std::move(call_factory)),
|
||||
event_log_factory_(std::move(event_log_factory)) {
|
||||
if (!network_thread_) {
|
||||
owned_network_thread_ = rtc::Thread::CreateWithSocketServer();
|
||||
owned_network_thread_->Start();
|
||||
network_thread_ = owned_network_thread_.get();
|
||||
}
|
||||
|
||||
if (!worker_thread_) {
|
||||
owned_worker_thread_ = rtc::Thread::Create();
|
||||
owned_worker_thread_->Start();
|
||||
worker_thread_ = owned_worker_thread_.get();
|
||||
}
|
||||
|
||||
if (!signaling_thread_) {
|
||||
signaling_thread_ = rtc::Thread::Current();
|
||||
if (!signaling_thread_) {
|
||||
// If this thread isn't already wrapped by an rtc::Thread, create a
|
||||
// wrapper and own it in this class.
|
||||
signaling_thread_ = rtc::ThreadManager::Instance()->WrapCurrentThread();
|
||||
wraps_current_thread_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Currently there is no way creating an external adm in
|
||||
// libjingle source tree. So we can 't currently assert if this is NULL.
|
||||
// RTC_DCHECK(default_adm != NULL);
|
||||
@ -187,12 +136,8 @@ PeerConnectionFactory::~PeerConnectionFactory() {
|
||||
default_socket_factory_ = nullptr;
|
||||
default_network_manager_ = nullptr;
|
||||
|
||||
if (owns_ptrs_) {
|
||||
if (wraps_current_thread_)
|
||||
rtc::ThreadManager::Instance()->UnwrapCurrentThread();
|
||||
delete worker_thread_;
|
||||
delete network_thread_;
|
||||
}
|
||||
if (wraps_current_thread_)
|
||||
rtc::ThreadManager::Instance()->UnwrapCurrentThread();
|
||||
}
|
||||
|
||||
bool PeerConnectionFactory::Initialize() {
|
||||
@ -210,14 +155,8 @@ bool PeerConnectionFactory::Initialize() {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::unique_ptr<cricket::MediaEngineInterface> media_engine(
|
||||
cricket::WebRtcMediaEngineFactory::Create(
|
||||
default_adm_.get(), audio_encoder_factory_, audio_decoder_factory_,
|
||||
video_encoder_factory_.get(), video_decoder_factory_.get(),
|
||||
external_audio_mixer_));
|
||||
|
||||
channel_manager_.reset(new cricket::ChannelManager(
|
||||
std::move(media_engine), worker_thread_, network_thread_));
|
||||
std::move(media_engine_), worker_thread_, network_thread_));
|
||||
|
||||
channel_manager_->SetVideoRtxEnabled(true);
|
||||
if (!channel_manager_->Init()) {
|
||||
@ -321,8 +260,18 @@ PeerConnectionFactory::CreatePeerConnection(
|
||||
RTC_FROM_HERE, rtc::Bind(&cricket::PortAllocator::SetNetworkIgnoreMask,
|
||||
allocator.get(), options_.network_ignore_mask));
|
||||
|
||||
std::unique_ptr<RtcEventLog> event_log(new RtcEventLogNullImpl());
|
||||
if (event_log_factory_) {
|
||||
event_log = event_log_factory_->CreateRtcEventLog();
|
||||
}
|
||||
|
||||
std::unique_ptr<Call> call = worker_thread_->Invoke<std::unique_ptr<Call>>(
|
||||
RTC_FROM_HERE,
|
||||
rtc::Bind(&PeerConnectionFactory::CreateCall_w, this, event_log.get()));
|
||||
|
||||
rtc::scoped_refptr<PeerConnection> pc(
|
||||
new rtc::RefCountedObject<PeerConnection>(this));
|
||||
new rtc::RefCountedObject<PeerConnection>(this, std::move(event_log),
|
||||
std::move(call)));
|
||||
|
||||
if (!pc->Initialize(configuration, std::move(allocator),
|
||||
std::move(cert_generator), observer)) {
|
||||
@ -382,4 +331,22 @@ rtc::Thread* PeerConnectionFactory::network_thread() {
|
||||
return network_thread_;
|
||||
}
|
||||
|
||||
std::unique_ptr<Call> PeerConnectionFactory::CreateCall_w(
|
||||
RtcEventLog* event_log) {
|
||||
const int kMinBandwidthBps = 30000;
|
||||
const int kStartBandwidthBps = 300000;
|
||||
const int kMaxBandwidthBps = 2000000;
|
||||
|
||||
webrtc::Call::Config call_config(event_log);
|
||||
if (!channel_manager_->media_engine() || !call_factory_) {
|
||||
return nullptr;
|
||||
}
|
||||
call_config.audio_state = channel_manager_->media_engine()->GetAudioState();
|
||||
call_config.bitrate_config.min_bitrate_bps = kMinBandwidthBps;
|
||||
call_config.bitrate_config.start_bitrate_bps = kStartBandwidthBps;
|
||||
call_config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps;
|
||||
|
||||
return std::unique_ptr<Call>(call_factory_->CreateCall(call_config));
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -105,9 +105,6 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface {
|
||||
const Options& options() const { return options_; }
|
||||
|
||||
protected:
|
||||
PeerConnectionFactory(
|
||||
rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory,
|
||||
rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory);
|
||||
PeerConnectionFactory(
|
||||
rtc::Thread* network_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
@ -117,15 +114,21 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface {
|
||||
rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory,
|
||||
cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
|
||||
cricket::WebRtcVideoDecoderFactory* video_decoder_factory,
|
||||
rtc::scoped_refptr<AudioMixer> audio_mixer);
|
||||
rtc::scoped_refptr<AudioMixer> audio_mixer,
|
||||
std::unique_ptr<cricket::MediaEngineInterface> media_engine,
|
||||
std::unique_ptr<webrtc::CallFactoryInterface> call_factory,
|
||||
std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory);
|
||||
virtual ~PeerConnectionFactory();
|
||||
|
||||
private:
|
||||
bool owns_ptrs_;
|
||||
std::unique_ptr<Call> CreateCall_w(RtcEventLog* event_log);
|
||||
|
||||
bool wraps_current_thread_;
|
||||
rtc::Thread* network_thread_;
|
||||
rtc::Thread* worker_thread_;
|
||||
rtc::Thread* signaling_thread_;
|
||||
std::unique_ptr<rtc::Thread> owned_network_thread_;
|
||||
std::unique_ptr<rtc::Thread> owned_worker_thread_;
|
||||
Options options_;
|
||||
// External Audio device used for audio playback.
|
||||
rtc::scoped_refptr<AudioDeviceModule> default_adm_;
|
||||
@ -143,6 +146,9 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface {
|
||||
// External audio mixer. This can be NULL. In that case, internal audio mixer
|
||||
// will be created and used.
|
||||
rtc::scoped_refptr<AudioMixer> external_audio_mixer_;
|
||||
std::unique_ptr<cricket::MediaEngineInterface> media_engine_;
|
||||
std::unique_ptr<webrtc::CallFactoryInterface> call_factory_;
|
||||
std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
#include "webrtc/base/thread.h"
|
||||
#include "webrtc/base/virtualsocketserver.h"
|
||||
#include "webrtc/media/base/fakevideocapturer.h"
|
||||
#include "webrtc/media/engine/webrtcmediaengine.h"
|
||||
#include "webrtc/media/sctp/sctptransportinternal.h"
|
||||
#include "webrtc/p2p/base/fakeportallocator.h"
|
||||
#include "webrtc/pc/audiotrack.h"
|
||||
@ -641,10 +642,54 @@ class MockPeerConnectionObserver : public PeerConnectionObserver {
|
||||
// exercised by these unittest.
|
||||
class PeerConnectionFactoryForTest : public webrtc::PeerConnectionFactory {
|
||||
public:
|
||||
PeerConnectionFactoryForTest()
|
||||
: webrtc::PeerConnectionFactory(
|
||||
webrtc::CreateBuiltinAudioEncoderFactory(),
|
||||
webrtc::CreateBuiltinAudioDecoderFactory()) {}
|
||||
static rtc::scoped_refptr<PeerConnectionFactoryForTest>
|
||||
CreatePeerConnectionFactoryForTest() {
|
||||
auto audio_encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory();
|
||||
auto audio_decoder_factory = webrtc::CreateBuiltinAudioDecoderFactory();
|
||||
|
||||
auto media_engine = std::unique_ptr<cricket::MediaEngineInterface>(
|
||||
cricket::WebRtcMediaEngineFactory::Create(
|
||||
nullptr, audio_encoder_factory, audio_decoder_factory, nullptr,
|
||||
nullptr, nullptr));
|
||||
|
||||
std::unique_ptr<webrtc::CallFactoryInterface> call_factory =
|
||||
webrtc::CreateCallFactory();
|
||||
|
||||
std::unique_ptr<webrtc::RtcEventLogFactoryInterface> event_log_factory =
|
||||
webrtc::CreateRtcEventLogFactory();
|
||||
|
||||
return new rtc::RefCountedObject<PeerConnectionFactoryForTest>(
|
||||
rtc::Thread::Current(), rtc::Thread::Current(), rtc::Thread::Current(),
|
||||
nullptr, audio_encoder_factory, audio_decoder_factory, nullptr, nullptr,
|
||||
nullptr, std::move(media_engine), std::move(call_factory),
|
||||
std::move(event_log_factory));
|
||||
}
|
||||
|
||||
PeerConnectionFactoryForTest(
|
||||
rtc::Thread* network_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
rtc::Thread* signaling_thread,
|
||||
webrtc::AudioDeviceModule* default_adm,
|
||||
rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory,
|
||||
rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory,
|
||||
cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
|
||||
cricket::WebRtcVideoDecoderFactory* video_decoder_factory,
|
||||
rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer,
|
||||
std::unique_ptr<cricket::MediaEngineInterface> media_engine,
|
||||
std::unique_ptr<webrtc::CallFactoryInterface> call_factory,
|
||||
std::unique_ptr<webrtc::RtcEventLogFactoryInterface> event_log_factory)
|
||||
: webrtc::PeerConnectionFactory(network_thread,
|
||||
worker_thread,
|
||||
signaling_thread,
|
||||
default_adm,
|
||||
audio_encoder_factory,
|
||||
audio_decoder_factory,
|
||||
video_encoder_factory,
|
||||
video_decoder_factory,
|
||||
audio_mixer,
|
||||
std::move(media_engine),
|
||||
std::move(call_factory),
|
||||
std::move(event_log_factory)) {}
|
||||
|
||||
cricket::TransportController* CreateTransportController(
|
||||
cricket::PortAllocator* port_allocator,
|
||||
@ -673,7 +718,7 @@ class PeerConnectionInterfaceTest : public testing::Test {
|
||||
nullptr, nullptr, nullptr);
|
||||
ASSERT_TRUE(pc_factory_);
|
||||
pc_factory_for_test_ =
|
||||
new rtc::RefCountedObject<PeerConnectionFactoryForTest>();
|
||||
PeerConnectionFactoryForTest::CreatePeerConnectionFactoryForTest();
|
||||
pc_factory_for_test_->Initialize();
|
||||
}
|
||||
|
||||
@ -3367,7 +3412,7 @@ TEST_F(PeerConnectionInterfaceTest, SetBitrateCurrentLessThanImplicitMin) {
|
||||
class PeerConnectionMediaConfigTest : public testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
pcf_ = new rtc::RefCountedObject<PeerConnectionFactoryForTest>();
|
||||
pcf_ = PeerConnectionFactoryForTest::CreatePeerConnectionFactoryForTest();
|
||||
pcf_->Initialize();
|
||||
}
|
||||
const cricket::MediaConfig TestCreatePeerConnection(
|
||||
|
||||
@ -22,7 +22,9 @@
|
||||
#include "webrtc/api/rtpsenderinterface.h"
|
||||
#include "webrtc/base/basictypes.h"
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/media/base/audiosource.h"
|
||||
// Adding 'nogncheck' to disable the gn include headers check to support modular
|
||||
// WebRTC build targets.
|
||||
#include "webrtc/media/base/audiosource.h" // nogncheck
|
||||
#include "webrtc/pc/channel.h"
|
||||
#include "webrtc/pc/dtmfsender.h"
|
||||
#include "webrtc/pc/statscollector.h"
|
||||
|
||||
@ -13,6 +13,9 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/thread.h"
|
||||
#include "webrtc/call/call.h"
|
||||
#include "webrtc/logging/rtc_event_log/rtc_event_log.h"
|
||||
#include "webrtc/pc/peerconnection.h"
|
||||
#include "webrtc/test/gmock.h"
|
||||
|
||||
@ -23,8 +26,19 @@ class FakePeerConnectionFactory
|
||||
: public rtc::RefCountedObject<webrtc::PeerConnectionFactory> {
|
||||
public:
|
||||
FakePeerConnectionFactory()
|
||||
: rtc::RefCountedObject<webrtc::PeerConnectionFactory>(nullptr, nullptr) {
|
||||
}
|
||||
: rtc::RefCountedObject<webrtc::PeerConnectionFactory>(
|
||||
rtc::Thread::Current(),
|
||||
rtc::Thread::Current(),
|
||||
rtc::Thread::Current(),
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
std::unique_ptr<cricket::MediaEngineInterface>(),
|
||||
std::unique_ptr<webrtc::CallFactoryInterface>(),
|
||||
std::unique_ptr<RtcEventLogFactoryInterface>()) {}
|
||||
};
|
||||
|
||||
class MockPeerConnection
|
||||
@ -32,7 +46,9 @@ class MockPeerConnection
|
||||
public:
|
||||
MockPeerConnection()
|
||||
: rtc::RefCountedObject<webrtc::PeerConnection>(
|
||||
new FakePeerConnectionFactory()) {}
|
||||
new FakePeerConnectionFactory(),
|
||||
std::unique_ptr<RtcEventLog>(),
|
||||
std::unique_ptr<Call>()) {}
|
||||
MOCK_METHOD0(local_streams,
|
||||
rtc::scoped_refptr<StreamCollectionInterface>());
|
||||
MOCK_METHOD0(remote_streams,
|
||||
|
||||
@ -1901,7 +1901,8 @@ Call::Stats WebRtcSession::GetCallStats() {
|
||||
return worker_thread()->Invoke<Call::Stats>(
|
||||
RTC_FROM_HERE, rtc::Bind(&WebRtcSession::GetCallStats, this));
|
||||
}
|
||||
RTC_DCHECK(call_);
|
||||
if (!call_)
|
||||
return Call::Stats();
|
||||
return call_->GetStats();
|
||||
}
|
||||
|
||||
|
||||
@ -12,6 +12,8 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "webrtc/base/logging.h"
|
||||
|
||||
namespace {
|
||||
// MediaCodec wants resolution to be divisible by 2.
|
||||
const int kRequiredResolutionAlignment = 2;
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
*/
|
||||
|
||||
#include "webrtc/api/videosourceproxy.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/sdk/android/src/jni/androidvideotracksource.h"
|
||||
#include "webrtc/sdk/android/src/jni/classreferenceholder.h"
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user