Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit 579c3f1

Browse files
committed
Enabling unbundling of audio/video
1 parent 96a492b commit 579c3f1

File tree

6 files changed

+70
-16
lines changed

6 files changed

+70
-16
lines changed

talk/owt/sdk/base/globalconfiguration.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ int GlobalConfiguration::screen_min_ = 0;
2929
int GlobalConfiguration::screen_max_ = 0;
3030
int GlobalConfiguration::data_min_ = 0;
3131
int GlobalConfiguration::data_max_ = 0;
32+
bool GlobalConfiguration::pre_decode_dump_enabled_ = false;
3233
} // namespace base
3334
}

talk/owt/sdk/base/peerconnectionchannel.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "webrtc/api/peer_connection_interface.h"
88
#include "webrtc/rtc_base/logging.h"
99
#include "webrtc/rtc_base/thread.h"
10+
#include "webrtc/system_wrappers/include/field_trial.h"
11+
1012
using namespace rtc;
1113
namespace owt {
1214
namespace base {
@@ -32,7 +34,10 @@ bool PeerConnectionChannel::InitializePeerConnection() {
3234
configuration_.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan;
3335
configuration_.media_config.enable_dscp = true;
3436
// Johny: This must not be set if we use seperate AV channels.
35-
//configuration_.bundle_policy = webrtc::PeerConnectionInterface::BundlePolicy::kBundlePolicyMaxBundle;
37+
if (!webrtc::field_trial::IsEnabled("OWT-IceUnbundle")) {
38+
configuration_.bundle_policy =
39+
webrtc::PeerConnectionInterface::BundlePolicy::kBundlePolicyMaxBundle;
40+
}
3641
peer_connection_ =
3742
(factory_->CreatePeerConnection(configuration_, this)).get();
3843
if (!peer_connection_.get()) {

talk/owt/sdk/base/peerconnectiondependencyfactory.cc

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "webrtc/modules/audio_device/include/audio_device_factory.h"
1818
#endif
1919
#include "webrtc/modules/audio_processing/include/audio_processing.h"
20+
#include "webrtc/p2p/client/basic_port_allocator.h"
2021
#include "webrtc/rtc_base/bind.h"
2122
#include "webrtc/rtc_base/ssl_adapter.h"
2223
#include "webrtc/rtc_base/thread.h"
@@ -108,16 +109,12 @@ void PeerConnectionDependencyFactory::
108109
video_max > video_min) || (screen_min > 0 && screen_max > screen_min) ||
109110
(data_min > 0 && data_max > data_min)) {
110111
field_trial_ += "OWT-IceUnbundle/Enabled/";
111-
field_trial_ +=
112-
"OWT-Ice-PortRanges/audioMin:" + std::to_string(audio_min) +
113-
",audioMax:" + std::to_string(audio_max) +
114-
",videoMin:" + std::to_string(video_min) +
115-
",videoMax:" + std::to_string(video_max) +
116-
",screenMin:" + std::to_string(screen_min) +
117-
",screenMax:" + std::to_string(screen_max) +
118-
",dataMin:" + std::to_string(data_min) +
119-
",dataMax:" + std::to_string(data_max) + "/";
120112
}
113+
bool pre_decode_dump = GlobalConfiguration::GetPreDecodeDumpEnabled();
114+
if (pre_decode_dump) {
115+
field_trial_ += "WebRTC-DecoderDataDumpDirectory/./";
116+
}
117+
121118
// Set H.264 temporal layers. Ideally it should be set via RtpSenderParam
122119
int h264_temporal_layers = GlobalConfiguration::GetH264TemporalLayers();
123120
field_trial_ +=
@@ -141,6 +138,10 @@ void PeerConnectionDependencyFactory::
141138
network_thread->Start())
142139
<< "Failed to start threads";
143140

141+
network_manager_ = std::make_shared<rtc::BasicNetworkManager>();
142+
packet_socket_factory_ =
143+
std::make_shared<rtc::BasicPacketSocketFactory>(network_thread.get());
144+
144145
// Use webrtc::VideoEn(De)coderFactory on iOS.
145146
std::unique_ptr<webrtc::VideoEncoderFactory> encoder_factory;
146147
std::unique_ptr<webrtc::VideoDecoderFactory> decoder_factory;
@@ -216,7 +217,29 @@ scoped_refptr<webrtc::PeerConnectionInterface>
216217
PeerConnectionDependencyFactory::CreatePeerConnectionOnCurrentThread(
217218
const webrtc::PeerConnectionInterface::RTCConfiguration& config,
218219
webrtc::PeerConnectionObserver* observer) {
219-
return (pc_factory_->CreatePeerConnection(config, nullptr, nullptr, observer))
220+
std::unique_ptr<cricket::PortAllocator> port_allocator;
221+
port_allocator.reset(new cricket::BasicPortAllocator(
222+
network_manager_.get(), packet_socket_factory_.get()));
223+
// Handle port ranges.
224+
int audio_min, audio_max, video_min, video_max, screen_min, screen_max,
225+
data_min, data_max;
226+
GlobalConfiguration::GetPortRanges(audio_min, audio_max, video_min, video_max,
227+
screen_min, screen_max, data_min,
228+
data_max);
229+
if (audio_min > 0 && audio_max > audio_min) {
230+
port_allocator->SetAudioPortRange(audio_min, audio_max);
231+
}
232+
if (video_min > 0 && video_max > video_min) {
233+
port_allocator->SetVideoPortRange(video_min, video_max);
234+
}
235+
if (screen_min > 0 && screen_max > screen_min) {
236+
port_allocator->SetScreenPortRange(screen_min, screen_max);
237+
}
238+
if (data_min > 0 && data_max > data_min) {
239+
port_allocator->SetDataPortRange(data_min, data_max);
240+
}
241+
return (pc_factory_->CreatePeerConnection(config, std::move(port_allocator),
242+
nullptr, observer))
220243
.get();
221244
}
222245
void PeerConnectionDependencyFactory::CreatePeerConnectionFactory() {

talk/owt/sdk/base/peerconnectiondependencyfactory.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#endif
1313
#include "webrtc/sdk/media_constraints.h"
1414
#include "webrtc/rtc_base/bind.h"
15+
#include "webrtc/rtc_base/network.h"
16+
#include "webrtc/p2p/base/basic_packet_socket_factory.h"
1517
namespace owt {
1618
namespace base {
1719
using webrtc::MediaStreamInterface;
@@ -94,6 +96,8 @@ class PeerConnectionDependencyFactory : public rtc::RefCountInterface {
9496
std::unique_ptr<webrtc::ScopedCOMInitializer> com_initializer_;
9597
std::unique_ptr<webrtc::TaskQueueFactory> task_queue_factory_;
9698
#endif
99+
std::shared_ptr<rtc::BasicNetworkManager> network_manager_;
100+
std::shared_ptr<rtc::BasicPacketSocketFactory> packet_socket_factory_;
97101
};
98102
}
99103
} // namespace owt

talk/owt/sdk/include/cpp/owt/base/globalconfiguration.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ class GlobalConfiguration {
103103
data_max_ = data_max;
104104
}
105105

106+
/**
107+
@brief This function enables stream dump before decoder.
108+
*/
109+
static void SetPreDecodeDumpEnabled(bool enabled) {
110+
pre_decode_dump_enabled_ = enabled;
111+
}
112+
106113
/**
107114
@brief This function sets the temporal layers for H.264.
108115
@@ -198,6 +205,7 @@ class GlobalConfiguration {
198205
static bool GetCustomizedAudioInputEnabled() {
199206
return audio_frame_generator_ ? true : false;
200207
}
208+
201209
static void GetPortRanges(int& audio_min,
202210
int& audio_max,
203211
int& video_min,
@@ -217,6 +225,7 @@ class GlobalConfiguration {
217225
data_min = data_min_;
218226
data_max = data_max_;
219227
}
228+
220229
static int audio_min_;
221230
static int audio_max_;
222231
static int video_min_;
@@ -225,6 +234,12 @@ class GlobalConfiguration {
225234
static int screen_max_;
226235
static int data_min_;
227236
static int data_max_;
237+
238+
static bool GetPreDecodeDumpEnabled() {
239+
return pre_decode_dump_enabled_;
240+
}
241+
242+
static bool pre_decode_dump_enabled_;
228243
/**
229244
@brief This function gets whether auto echo cancellation is enabled or not.
230245
@return true or false.

talk/owt/sdk/p2p/p2ppeerconnectionchannel.cc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "talk/owt/sdk/p2p/p2ppeerconnectionchannel.h"
1111
#include "webrtc/rtc_base/logging.h"
1212
#include "webrtc/api/task_queue/default_task_queue_factory.h"
13-
13+
#include "webrtc/system_wrappers/include/field_trial.h"
1414
using namespace rtc;
1515
namespace owt {
1616
namespace p2p {
@@ -284,8 +284,11 @@ void P2PPeerConnectionChannel::CreateOffer() {
284284
std::bind(
285285
&P2PPeerConnectionChannel::OnCreateSessionDescriptionFailure,
286286
this, std::placeholders::_1));
287-
peer_connection_->CreateOffer(
288-
observer, webrtc::PeerConnectionInterface::RTCOfferAnswerOptions());
287+
bool rtp_no_mux = webrtc::field_trial::IsEnabled("OWT-IceUnbundle");
288+
auto offer_answer_options =
289+
webrtc::PeerConnectionInterface::RTCOfferAnswerOptions();
290+
offer_answer_options.use_rtp_mux = !rtp_no_mux;
291+
peer_connection_->CreateOffer(observer, offer_answer_options);
289292
}
290293
void P2PPeerConnectionChannel::CreateAnswer() {
291294
RTC_LOG(LS_INFO) << "Create answer.";
@@ -297,8 +300,11 @@ void P2PPeerConnectionChannel::CreateAnswer() {
297300
std::bind(
298301
&P2PPeerConnectionChannel::OnCreateSessionDescriptionFailure,
299302
this, std::placeholders::_1));
300-
peer_connection_->CreateAnswer(
301-
observer, webrtc::PeerConnectionInterface::RTCOfferAnswerOptions());
303+
bool rtp_no_mux = webrtc::field_trial::IsEnabled("OWT-IceUnbundle");
304+
auto offer_answer_options =
305+
webrtc::PeerConnectionInterface::RTCOfferAnswerOptions();
306+
offer_answer_options.use_rtp_mux = !rtp_no_mux;
307+
peer_connection_->CreateAnswer(observer, offer_answer_options);
302308
}
303309
void P2PPeerConnectionChannel::SendSignalingMessage(
304310
const Json::Value& data,

0 commit comments

Comments
 (0)