2017-09-26 16:20:19 -07:00
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "pc/peer_connection_wrapper.h"
|
2017-09-26 16:20:19 -07:00
|
|
|
|
2018-11-28 16:47:49 +01:00
|
|
|
#include <stdint.h>
|
2019-07-05 19:08:33 +02:00
|
|
|
|
2017-09-26 16:20:19 -07:00
|
|
|
#include <memory>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <utility>
|
2017-10-30 09:57:42 -07:00
|
|
|
#include <vector>
|
2017-09-26 16:20:19 -07:00
|
|
|
|
2019-03-21 14:37:36 +01:00
|
|
|
#include "api/function_view.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "api/set_remote_description_observer_interface.h"
|
|
|
|
|
#include "pc/sdp_utils.h"
|
|
|
|
|
#include "pc/test/fake_video_track_source.h"
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "rtc_base/checks.h"
|
2017-09-26 16:20:19 -07:00
|
|
|
#include "rtc_base/gunit.h"
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "rtc_base/logging.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "rtc_base/ref_counted_object.h"
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "test/gtest.h"
|
2017-09-26 16:20:19 -07:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2018-01-25 13:58:07 -08:00
|
|
|
using RTCOfferAnswerOptions = PeerConnectionInterface::RTCOfferAnswerOptions;
|
|
|
|
|
|
2017-09-26 16:20:19 -07:00
|
|
|
namespace {
|
2017-10-23 09:39:20 -07:00
|
|
|
const uint32_t kDefaultTimeout = 10000U;
|
2017-09-26 16:20:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PeerConnectionWrapper::PeerConnectionWrapper(
|
|
|
|
|
rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory,
|
|
|
|
|
rtc::scoped_refptr<PeerConnectionInterface> pc,
|
|
|
|
|
std::unique_ptr<MockPeerConnectionObserver> observer)
|
2017-11-13 11:50:33 +01:00
|
|
|
: pc_factory_(std::move(pc_factory)),
|
|
|
|
|
observer_(std::move(observer)),
|
|
|
|
|
pc_(std::move(pc)) {
|
2017-09-26 16:20:19 -07:00
|
|
|
RTC_DCHECK(pc_factory_);
|
|
|
|
|
RTC_DCHECK(pc_);
|
|
|
|
|
RTC_DCHECK(observer_);
|
|
|
|
|
observer_->SetPeerConnectionInterface(pc_.get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PeerConnectionWrapper::~PeerConnectionWrapper() = default;
|
|
|
|
|
|
|
|
|
|
PeerConnectionFactoryInterface* PeerConnectionWrapper::pc_factory() {
|
|
|
|
|
return pc_factory_.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PeerConnectionInterface* PeerConnectionWrapper::pc() {
|
|
|
|
|
return pc_.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MockPeerConnectionObserver* PeerConnectionWrapper::observer() {
|
|
|
|
|
return observer_.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<SessionDescriptionInterface>
|
|
|
|
|
PeerConnectionWrapper::CreateOffer() {
|
2018-01-25 13:58:07 -08:00
|
|
|
return CreateOffer(RTCOfferAnswerOptions());
|
2017-09-26 16:20:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<SessionDescriptionInterface> PeerConnectionWrapper::CreateOffer(
|
2017-10-20 15:30:51 -07:00
|
|
|
const PeerConnectionInterface::RTCOfferAnswerOptions& options,
|
|
|
|
|
std::string* error_out) {
|
|
|
|
|
return CreateSdp(
|
|
|
|
|
[this, options](CreateSessionDescriptionObserver* observer) {
|
|
|
|
|
pc()->CreateOffer(observer, options);
|
|
|
|
|
},
|
|
|
|
|
error_out);
|
2017-09-26 16:20:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<SessionDescriptionInterface>
|
|
|
|
|
PeerConnectionWrapper::CreateOfferAndSetAsLocal() {
|
2018-01-25 13:58:07 -08:00
|
|
|
return CreateOfferAndSetAsLocal(RTCOfferAnswerOptions());
|
2017-10-20 15:30:51 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<SessionDescriptionInterface>
|
|
|
|
|
PeerConnectionWrapper::CreateOfferAndSetAsLocal(
|
|
|
|
|
const PeerConnectionInterface::RTCOfferAnswerOptions& options) {
|
|
|
|
|
auto offer = CreateOffer(options);
|
2017-09-26 16:20:19 -07:00
|
|
|
if (!offer) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
EXPECT_TRUE(SetLocalDescription(CloneSessionDescription(offer.get())));
|
|
|
|
|
return offer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<SessionDescriptionInterface>
|
|
|
|
|
PeerConnectionWrapper::CreateAnswer() {
|
2018-01-25 13:58:07 -08:00
|
|
|
return CreateAnswer(RTCOfferAnswerOptions());
|
2017-09-26 16:20:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<SessionDescriptionInterface>
|
|
|
|
|
PeerConnectionWrapper::CreateAnswer(
|
2017-10-20 15:30:51 -07:00
|
|
|
const PeerConnectionInterface::RTCOfferAnswerOptions& options,
|
|
|
|
|
std::string* error_out) {
|
|
|
|
|
return CreateSdp(
|
|
|
|
|
[this, options](CreateSessionDescriptionObserver* observer) {
|
|
|
|
|
pc()->CreateAnswer(observer, options);
|
|
|
|
|
},
|
|
|
|
|
error_out);
|
2017-09-26 16:20:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<SessionDescriptionInterface>
|
|
|
|
|
PeerConnectionWrapper::CreateAnswerAndSetAsLocal() {
|
2018-01-25 13:58:07 -08:00
|
|
|
return CreateAnswerAndSetAsLocal(RTCOfferAnswerOptions());
|
2017-10-20 15:30:51 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<SessionDescriptionInterface>
|
|
|
|
|
PeerConnectionWrapper::CreateAnswerAndSetAsLocal(
|
|
|
|
|
const PeerConnectionInterface::RTCOfferAnswerOptions& options) {
|
|
|
|
|
auto answer = CreateAnswer(options);
|
2017-09-26 16:20:19 -07:00
|
|
|
if (!answer) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
EXPECT_TRUE(SetLocalDescription(CloneSessionDescription(answer.get())));
|
|
|
|
|
return answer;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-09 18:29:44 +03:00
|
|
|
std::unique_ptr<SessionDescriptionInterface>
|
|
|
|
|
PeerConnectionWrapper::CreateRollback() {
|
|
|
|
|
return CreateSessionDescription(SdpType::kRollback, "");
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-26 16:20:19 -07:00
|
|
|
std::unique_ptr<SessionDescriptionInterface> PeerConnectionWrapper::CreateSdp(
|
2017-11-13 11:50:33 +01:00
|
|
|
rtc::FunctionView<void(CreateSessionDescriptionObserver*)> fn,
|
2017-10-20 15:30:51 -07:00
|
|
|
std::string* error_out) {
|
2017-09-26 16:20:19 -07:00
|
|
|
rtc::scoped_refptr<MockCreateSessionDescriptionObserver> observer(
|
|
|
|
|
new rtc::RefCountedObject<MockCreateSessionDescriptionObserver>());
|
|
|
|
|
fn(observer);
|
2017-10-23 09:39:20 -07:00
|
|
|
EXPECT_EQ_WAIT(true, observer->called(), kDefaultTimeout);
|
2017-10-20 15:30:51 -07:00
|
|
|
if (error_out && !observer->result()) {
|
|
|
|
|
*error_out = observer->error();
|
|
|
|
|
}
|
2017-09-26 16:20:19 -07:00
|
|
|
return observer->MoveDescription();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool PeerConnectionWrapper::SetLocalDescription(
|
2017-10-20 15:30:51 -07:00
|
|
|
std::unique_ptr<SessionDescriptionInterface> desc,
|
|
|
|
|
std::string* error_out) {
|
|
|
|
|
return SetSdp(
|
|
|
|
|
[this, &desc](SetSessionDescriptionObserver* observer) {
|
|
|
|
|
pc()->SetLocalDescription(observer, desc.release());
|
|
|
|
|
},
|
|
|
|
|
error_out);
|
2017-09-26 16:20:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool PeerConnectionWrapper::SetRemoteDescription(
|
2017-10-20 15:30:51 -07:00
|
|
|
std::unique_ptr<SessionDescriptionInterface> desc,
|
|
|
|
|
std::string* error_out) {
|
|
|
|
|
return SetSdp(
|
|
|
|
|
[this, &desc](SetSessionDescriptionObserver* observer) {
|
|
|
|
|
pc()->SetRemoteDescription(observer, desc.release());
|
|
|
|
|
},
|
|
|
|
|
error_out);
|
2017-09-26 16:20:19 -07:00
|
|
|
}
|
|
|
|
|
|
Reland "SetRemoteDescriptionObserverInterface added."
Description for changes from the original CL:
Calling legacy SRD, implemented using
SetRemoteDescriptionObserverAdapter wrapping the old observer, was
meant to have the exact same behavior as the legacy SRD implementation
which invokes the callbacks in a Post.
However, in the CL that landed and got reverted (PS1), the Adapter had
its own message handler, and callbacks would be invoked even if the PC
was destroyed.
In PS2 I've changed the Adapter to use the PeerConnection's message
handler. If the PC is destroyed, the callback will not be invoked.
This gives identical behavior to before this CL, and the legacy
behavior is covered by a new unittest.
I changed the adapter to be an implementation detail of
peerconnection.cc, therefor some stuff was moved, and the only tests
covering this is now in peerconnection_rtp_unittest.cc.
This is a reland of 6c7ec32bd63ab2b45d4d83ae1de817ee946b4d72
Original change's description:
> SetRemoteDescriptionObserverInterface added.
>
> The new observer replaced SetSessionDescriptionObserver for
> SetRemoteDescription. Unlike SetSessionDescriptionObserver,
> SetRemoteDescriptionObserverInterface is invoked synchronously so
> that the you can rely on the state of the PeerConnection to represent
> the result of the SetRemoteDescription call in the callback.
>
> The new observer succeeds or fails with an RTCError.
>
> This deprecates the need for PeerConnectionObserver::OnAdd/RemoveTrack
> and SetSessionDescriptionObserver, with the benefit that all media
> object changes can be processed in a single callback by the application
> in a synchronous callback. This will help Chromium keep objects in-sync
> across layers and threads in a non-racy and straight-forward way, see
> design doc (Proposal 2):
> https://docs.google.com/a/google.com/document/d/1-cDDC82mgU5zrHacfFz720p3xwRtuBkOPSRchh07Ho0/edit?usp=sharing
>
> An adapter for SetSessionDescriptionObserver is added to allow calling
> the old SetRemoteDescription signature and get the old behavior
> (OnSuccess/OnFailure callback in a Post) until third parties switch.
>
> Bug: webrtc:8473
> Change-Id: I3d4eb60da6dd34615f2c9f384aeaf4634e648c99
> Reviewed-on: https://webrtc-review.googlesource.com/17523
> Commit-Queue: Henrik Boström <hbos@webrtc.org>
> Reviewed-by: Peter Thatcher <pthatcher@webrtc.org>
> Reviewed-by: Guido Urdaneta <guidou@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#20841}
TBR=pthatcher@webrtc.org
Bug: webrtc:8473
Change-Id: If2b1a1929663b0e77fcc9c2ebeef043e6f73adf5
Reviewed-on: https://webrtc-review.googlesource.com/25640
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Guido Urdaneta <guidou@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20854}
2017-11-23 17:48:32 +01:00
|
|
|
bool PeerConnectionWrapper::SetRemoteDescription(
|
|
|
|
|
std::unique_ptr<SessionDescriptionInterface> desc,
|
|
|
|
|
RTCError* error_out) {
|
Revert "[Perfect Negotiation] Implement non-racy version of SetLocalDescription."
This reverts commit d4089cae47334a4228b69d6bb23f2e49ebb7496e.
Reason for revert: Breaks chromium WPT that is timing sensitive to onicegatheringstatechanges.
This CL accidentally moved the MaybeStartGatheringIceCandidates to after completing the SLD call. The fix is to move it back. I'll do that in a re-land.
Original change's description:
> [Perfect Negotiation] Implement non-racy version of SetLocalDescription.
>
> BACKGROUND
>
> When SLD is invoked with SetSessionDescriptionObserver, the observer is
> called by posting a message back to the execution thread, delaying the
> call. This delay is "artificial" - it's not necessary; the operation is
> already complete. It's a post from the signaling thread to the signaling
> thread. The rationale for the post was to avoid the observer making
> recursive calls back into the PeerConnection. The problem with this is
> that by the time the observer is called, the PeerConnection could
> already have executed other operations and modified its states.
>
> This causes the referenced bug: one can have a race where SLD is
> resolved "too late" (after a pending SRD is executed) and the signaling
> state observed when SLD resolves doesn't make sense.
>
> When implementing Unified Plan, we fixed similar issues for SRD by
> adding a version that takes SetRemoteDescriptionObserverInterface as
> argument instead of SetSessionDescriptionObserver. The new version did
> not have the delay. The old version had to be kept around not to break
> downstream projects that had dependencies both on he delay and on
> allowing the PC to be destroyed midst-operation without informing its
> observers.
>
> THIS CL
>
> This does the old SRD fix for SLD as well: A new observer interface is
> added, SetLocalDescriptionObserverInterface, and
> PeerConnection::SetLocalDescription() is overloaded. If you call it with
> the old observer, you get the delay, but if you call it with the new
> observer, you don't get a delay.
>
> - SetLocalDescriptionObserverInterface is added.
> - SetLocalDescription is overloaded.
> - The adapter for SetSessionDescriptionObserver that causes the delay
> previously only used for SRD is updated to handle both SLD and SRD.
> - FakeSetLocalDescriptionObserver is added and
> MockSetRemoteDescriptionObserver is renamed "Fake...".
>
> Bug: chromium:1071733
> Change-Id: I920368e648bede481058ac22f5b8794752a220b3
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/179100
> Commit-Queue: Henrik Boström <hbos@webrtc.org>
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31798}
TBR=hbos@webrtc.org,hta@webrtc.org
Change-Id: Ie1e1ecc49f3b1d7a7e230db6d36decbc4cbe8c86
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:1071733
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/180480
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31802}
2020-07-29 09:46:40 +00:00
|
|
|
rtc::scoped_refptr<MockSetRemoteDescriptionObserver> observer =
|
|
|
|
|
new MockSetRemoteDescriptionObserver();
|
Reland "SetRemoteDescriptionObserverInterface added."
Description for changes from the original CL:
Calling legacy SRD, implemented using
SetRemoteDescriptionObserverAdapter wrapping the old observer, was
meant to have the exact same behavior as the legacy SRD implementation
which invokes the callbacks in a Post.
However, in the CL that landed and got reverted (PS1), the Adapter had
its own message handler, and callbacks would be invoked even if the PC
was destroyed.
In PS2 I've changed the Adapter to use the PeerConnection's message
handler. If the PC is destroyed, the callback will not be invoked.
This gives identical behavior to before this CL, and the legacy
behavior is covered by a new unittest.
I changed the adapter to be an implementation detail of
peerconnection.cc, therefor some stuff was moved, and the only tests
covering this is now in peerconnection_rtp_unittest.cc.
This is a reland of 6c7ec32bd63ab2b45d4d83ae1de817ee946b4d72
Original change's description:
> SetRemoteDescriptionObserverInterface added.
>
> The new observer replaced SetSessionDescriptionObserver for
> SetRemoteDescription. Unlike SetSessionDescriptionObserver,
> SetRemoteDescriptionObserverInterface is invoked synchronously so
> that the you can rely on the state of the PeerConnection to represent
> the result of the SetRemoteDescription call in the callback.
>
> The new observer succeeds or fails with an RTCError.
>
> This deprecates the need for PeerConnectionObserver::OnAdd/RemoveTrack
> and SetSessionDescriptionObserver, with the benefit that all media
> object changes can be processed in a single callback by the application
> in a synchronous callback. This will help Chromium keep objects in-sync
> across layers and threads in a non-racy and straight-forward way, see
> design doc (Proposal 2):
> https://docs.google.com/a/google.com/document/d/1-cDDC82mgU5zrHacfFz720p3xwRtuBkOPSRchh07Ho0/edit?usp=sharing
>
> An adapter for SetSessionDescriptionObserver is added to allow calling
> the old SetRemoteDescription signature and get the old behavior
> (OnSuccess/OnFailure callback in a Post) until third parties switch.
>
> Bug: webrtc:8473
> Change-Id: I3d4eb60da6dd34615f2c9f384aeaf4634e648c99
> Reviewed-on: https://webrtc-review.googlesource.com/17523
> Commit-Queue: Henrik Boström <hbos@webrtc.org>
> Reviewed-by: Peter Thatcher <pthatcher@webrtc.org>
> Reviewed-by: Guido Urdaneta <guidou@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#20841}
TBR=pthatcher@webrtc.org
Bug: webrtc:8473
Change-Id: If2b1a1929663b0e77fcc9c2ebeef043e6f73adf5
Reviewed-on: https://webrtc-review.googlesource.com/25640
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Guido Urdaneta <guidou@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20854}
2017-11-23 17:48:32 +01:00
|
|
|
pc()->SetRemoteDescription(std::move(desc), observer);
|
|
|
|
|
EXPECT_EQ_WAIT(true, observer->called(), kDefaultTimeout);
|
|
|
|
|
bool ok = observer->error().ok();
|
|
|
|
|
if (error_out)
|
|
|
|
|
*error_out = std::move(observer->error());
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-26 16:20:19 -07:00
|
|
|
bool PeerConnectionWrapper::SetSdp(
|
2017-11-13 11:50:33 +01:00
|
|
|
rtc::FunctionView<void(SetSessionDescriptionObserver*)> fn,
|
2017-10-20 15:30:51 -07:00
|
|
|
std::string* error_out) {
|
2017-09-26 16:20:19 -07:00
|
|
|
rtc::scoped_refptr<MockSetSessionDescriptionObserver> observer(
|
|
|
|
|
new rtc::RefCountedObject<MockSetSessionDescriptionObserver>());
|
|
|
|
|
fn(observer);
|
2017-10-23 09:39:20 -07:00
|
|
|
EXPECT_EQ_WAIT(true, observer->called(), kDefaultTimeout);
|
2017-10-20 15:30:51 -07:00
|
|
|
if (error_out && !observer->result()) {
|
|
|
|
|
*error_out = observer->error();
|
2017-09-26 16:20:19 -07:00
|
|
|
}
|
|
|
|
|
return observer->result();
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-22 16:02:54 -08:00
|
|
|
bool PeerConnectionWrapper::ExchangeOfferAnswerWith(
|
|
|
|
|
PeerConnectionWrapper* answerer) {
|
2018-01-25 13:58:07 -08:00
|
|
|
return ExchangeOfferAnswerWith(answerer, RTCOfferAnswerOptions(),
|
|
|
|
|
RTCOfferAnswerOptions());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool PeerConnectionWrapper::ExchangeOfferAnswerWith(
|
|
|
|
|
PeerConnectionWrapper* answerer,
|
|
|
|
|
const PeerConnectionInterface::RTCOfferAnswerOptions& offer_options,
|
|
|
|
|
const PeerConnectionInterface::RTCOfferAnswerOptions& answer_options) {
|
2017-12-22 16:02:54 -08:00
|
|
|
RTC_DCHECK(answerer);
|
|
|
|
|
if (answerer == this) {
|
|
|
|
|
RTC_LOG(LS_ERROR) << "Cannot exchange offer/answer with ourself!";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2018-01-25 13:58:07 -08:00
|
|
|
auto offer = CreateOffer(offer_options);
|
2017-12-22 16:02:54 -08:00
|
|
|
EXPECT_TRUE(offer);
|
|
|
|
|
if (!offer) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
bool set_local_offer =
|
|
|
|
|
SetLocalDescription(CloneSessionDescription(offer.get()));
|
|
|
|
|
EXPECT_TRUE(set_local_offer);
|
|
|
|
|
if (!set_local_offer) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
bool set_remote_offer = answerer->SetRemoteDescription(std::move(offer));
|
|
|
|
|
EXPECT_TRUE(set_remote_offer);
|
|
|
|
|
if (!set_remote_offer) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2018-01-25 13:58:07 -08:00
|
|
|
auto answer = answerer->CreateAnswer(answer_options);
|
2017-12-22 16:02:54 -08:00
|
|
|
EXPECT_TRUE(answer);
|
|
|
|
|
if (!answer) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
bool set_local_answer =
|
|
|
|
|
answerer->SetLocalDescription(CloneSessionDescription(answer.get()));
|
|
|
|
|
EXPECT_TRUE(set_local_answer);
|
|
|
|
|
if (!set_local_answer) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
bool set_remote_answer = SetRemoteDescription(std::move(answer));
|
|
|
|
|
EXPECT_TRUE(set_remote_answer);
|
|
|
|
|
return set_remote_answer;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-27 13:01:52 -08:00
|
|
|
rtc::scoped_refptr<RtpTransceiverInterface>
|
|
|
|
|
PeerConnectionWrapper::AddTransceiver(cricket::MediaType media_type) {
|
|
|
|
|
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> result =
|
|
|
|
|
pc()->AddTransceiver(media_type);
|
|
|
|
|
EXPECT_EQ(RTCErrorType::NONE, result.error().type());
|
|
|
|
|
return result.MoveValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverInterface>
|
|
|
|
|
PeerConnectionWrapper::AddTransceiver(cricket::MediaType media_type,
|
|
|
|
|
const RtpTransceiverInit& init) {
|
|
|
|
|
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> result =
|
|
|
|
|
pc()->AddTransceiver(media_type, init);
|
|
|
|
|
EXPECT_EQ(RTCErrorType::NONE, result.error().type());
|
|
|
|
|
return result.MoveValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverInterface>
|
|
|
|
|
PeerConnectionWrapper::AddTransceiver(
|
|
|
|
|
rtc::scoped_refptr<MediaStreamTrackInterface> track) {
|
|
|
|
|
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> result =
|
|
|
|
|
pc()->AddTransceiver(track);
|
|
|
|
|
EXPECT_EQ(RTCErrorType::NONE, result.error().type());
|
|
|
|
|
return result.MoveValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverInterface>
|
|
|
|
|
PeerConnectionWrapper::AddTransceiver(
|
|
|
|
|
rtc::scoped_refptr<MediaStreamTrackInterface> track,
|
|
|
|
|
const RtpTransceiverInit& init) {
|
|
|
|
|
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> result =
|
|
|
|
|
pc()->AddTransceiver(track, init);
|
|
|
|
|
EXPECT_EQ(RTCErrorType::NONE, result.error().type());
|
|
|
|
|
return result.MoveValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rtc::scoped_refptr<AudioTrackInterface> PeerConnectionWrapper::CreateAudioTrack(
|
|
|
|
|
const std::string& label) {
|
|
|
|
|
return pc_factory()->CreateAudioTrack(label, nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rtc::scoped_refptr<VideoTrackInterface> PeerConnectionWrapper::CreateVideoTrack(
|
|
|
|
|
const std::string& label) {
|
2018-05-29 09:13:57 +02:00
|
|
|
return pc_factory()->CreateVideoTrack(label, FakeVideoTrackSource::Create());
|
2017-11-27 13:01:52 -08:00
|
|
|
}
|
|
|
|
|
|
2018-01-05 17:10:52 -08:00
|
|
|
rtc::scoped_refptr<RtpSenderInterface> PeerConnectionWrapper::AddTrack(
|
|
|
|
|
rtc::scoped_refptr<MediaStreamTrackInterface> track,
|
2018-03-02 11:34:10 -08:00
|
|
|
const std::vector<std::string>& stream_ids) {
|
2018-01-05 17:10:52 -08:00
|
|
|
RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> result =
|
2018-03-02 11:34:10 -08:00
|
|
|
pc()->AddTrack(track, stream_ids);
|
2018-01-05 17:10:52 -08:00
|
|
|
EXPECT_EQ(RTCErrorType::NONE, result.error().type());
|
|
|
|
|
return result.MoveValue();
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-20 15:30:51 -07:00
|
|
|
rtc::scoped_refptr<RtpSenderInterface> PeerConnectionWrapper::AddAudioTrack(
|
|
|
|
|
const std::string& track_label,
|
2018-03-02 11:34:10 -08:00
|
|
|
const std::vector<std::string>& stream_ids) {
|
|
|
|
|
return AddTrack(CreateAudioTrack(track_label), stream_ids);
|
2017-09-26 16:20:19 -07:00
|
|
|
}
|
|
|
|
|
|
2017-10-20 15:30:51 -07:00
|
|
|
rtc::scoped_refptr<RtpSenderInterface> PeerConnectionWrapper::AddVideoTrack(
|
|
|
|
|
const std::string& track_label,
|
2018-03-02 11:34:10 -08:00
|
|
|
const std::vector<std::string>& stream_ids) {
|
|
|
|
|
return AddTrack(CreateVideoTrack(track_label), stream_ids);
|
2017-10-20 15:30:51 -07:00
|
|
|
}
|
|
|
|
|
|
2017-12-28 16:38:23 -08:00
|
|
|
rtc::scoped_refptr<DataChannelInterface>
|
|
|
|
|
PeerConnectionWrapper::CreateDataChannel(const std::string& label) {
|
|
|
|
|
return pc()->CreateDataChannel(label, nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-20 15:30:51 -07:00
|
|
|
PeerConnectionInterface::SignalingState
|
|
|
|
|
PeerConnectionWrapper::signaling_state() {
|
|
|
|
|
return pc()->signaling_state();
|
2017-09-26 16:20:19 -07:00
|
|
|
}
|
|
|
|
|
|
2017-10-13 11:13:35 -07:00
|
|
|
bool PeerConnectionWrapper::IsIceGatheringDone() {
|
2017-10-23 09:39:20 -07:00
|
|
|
return observer()->ice_gathering_complete_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool PeerConnectionWrapper::IsIceConnected() {
|
|
|
|
|
return observer()->ice_connected_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rtc::scoped_refptr<const webrtc::RTCStatsReport>
|
|
|
|
|
PeerConnectionWrapper::GetStats() {
|
|
|
|
|
rtc::scoped_refptr<webrtc::MockRTCStatsCollectorCallback> callback(
|
|
|
|
|
new rtc::RefCountedObject<webrtc::MockRTCStatsCollectorCallback>());
|
|
|
|
|
pc()->GetStats(callback);
|
|
|
|
|
EXPECT_TRUE_WAIT(callback->called(), kDefaultTimeout);
|
|
|
|
|
return callback->report();
|
2017-10-13 11:13:35 -07:00
|
|
|
}
|
|
|
|
|
|
2017-09-26 16:20:19 -07:00
|
|
|
} // namespace webrtc
|