webrtc_m130/examples/androidnativeapi/jni/android_call_client.cc

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

295 lines
10 KiB
C++
Raw Normal View History

/*
* Copyright 2018 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 "examples/androidnativeapi/jni/android_call_client.h"
#include <utility>
Use std::make_unique instead of absl::make_unique. WebRTC is now using C++14 so there is no need to use the Abseil version of std::make_unique. This CL has been created with the following steps: git grep -l absl::make_unique | sort | uniq > /tmp/make_unique.txt git grep -l absl::WrapUnique | sort | uniq > /tmp/wrap_unique.txt git grep -l "#include <memory>" | sort | uniq > /tmp/memory.txt diff --new-line-format="" --unchanged-line-format="" \ /tmp/make_unique.txt /tmp/wrap_unique.txt | sort | \ uniq > /tmp/only_make_unique.txt diff --new-line-format="" --unchanged-line-format="" \ /tmp/only_make_unique.txt /tmp/memory.txt | \ xargs grep -l "absl/memory" > /tmp/add-memory.txt git grep -l "\babsl::make_unique\b" | \ xargs sed -i "s/\babsl::make_unique\b/std::make_unique/g" git checkout PRESUBMIT.py abseil-in-webrtc.md cat /tmp/add-memory.txt | \ xargs sed -i \ 's/#include "absl\/memory\/memory.h"/#include <memory>/g' git cl format # Manual fix order of the new inserted #include <memory> cat /tmp/only_make_unique | xargs grep -l "#include <memory>" | \ xargs sed -i '/#include "absl\/memory\/memory.h"/d' git ls-files | grep BUILD.gn | \ xargs sed -i '/\/\/third_party\/abseil-cpp\/absl\/memory/d' python tools_webrtc/gn_check_autofix.py \ -m tryserver.webrtc -b linux_rel # Repead the gn_check_autofix step for other platforms git ls-files | grep BUILD.gn | \ xargs sed -i 's/absl\/memory:memory/absl\/memory/g' git cl format Bug: webrtc:10945 Change-Id: I3fe28ea80f4dd3ba3cf28effd151d5e1f19aff89 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/153221 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29209}
2019-09-17 17:06:18 +02:00
#include <memory>
#include "api/peer_connection_interface.h"
#include "api/rtc_event_log/rtc_event_log_factory.h"
#include "api/task_queue/default_task_queue_factory.h"
#include "examples/androidnativeapi/generated_jni/CallClient_jni.h"
#include "media/engine/internal_decoder_factory.h"
#include "media/engine/internal_encoder_factory.h"
#include "media/engine/webrtc_media_engine.h"
#include "media/engine/webrtc_media_engine_defaults.h"
#include "sdk/android/native_api/jni/java_types.h"
#include "sdk/android/native_api/video/wrapper.h"
namespace webrtc_examples {
class AndroidCallClient::PCObserver : public webrtc::PeerConnectionObserver {
public:
explicit PCObserver(AndroidCallClient* client);
void OnSignalingChange(
webrtc::PeerConnectionInterface::SignalingState new_state) override;
void OnDataChannel(
rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) override;
void OnRenegotiationNeeded() override;
void OnIceConnectionChange(
webrtc::PeerConnectionInterface::IceConnectionState new_state) override;
void OnIceGatheringChange(
webrtc::PeerConnectionInterface::IceGatheringState new_state) override;
void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override;
private:
AndroidCallClient* const client_;
};
namespace {
class CreateOfferObserver : public webrtc::CreateSessionDescriptionObserver {
public:
explicit CreateOfferObserver(
rtc::scoped_refptr<webrtc::PeerConnectionInterface> pc);
void OnSuccess(webrtc::SessionDescriptionInterface* desc) override;
void OnFailure(webrtc::RTCError error) override;
private:
const rtc::scoped_refptr<webrtc::PeerConnectionInterface> pc_;
};
class SetRemoteSessionDescriptionObserver
: public webrtc::SetRemoteDescriptionObserverInterface {
public:
void OnSetRemoteDescriptionComplete(webrtc::RTCError error) override;
};
class SetLocalSessionDescriptionObserver
: public webrtc::SetSessionDescriptionObserver {
public:
void OnSuccess() override;
void OnFailure(webrtc::RTCError error) override;
};
} // namespace
AndroidCallClient::AndroidCallClient()
Use std::make_unique instead of absl::make_unique. WebRTC is now using C++14 so there is no need to use the Abseil version of std::make_unique. This CL has been created with the following steps: git grep -l absl::make_unique | sort | uniq > /tmp/make_unique.txt git grep -l absl::WrapUnique | sort | uniq > /tmp/wrap_unique.txt git grep -l "#include <memory>" | sort | uniq > /tmp/memory.txt diff --new-line-format="" --unchanged-line-format="" \ /tmp/make_unique.txt /tmp/wrap_unique.txt | sort | \ uniq > /tmp/only_make_unique.txt diff --new-line-format="" --unchanged-line-format="" \ /tmp/only_make_unique.txt /tmp/memory.txt | \ xargs grep -l "absl/memory" > /tmp/add-memory.txt git grep -l "\babsl::make_unique\b" | \ xargs sed -i "s/\babsl::make_unique\b/std::make_unique/g" git checkout PRESUBMIT.py abseil-in-webrtc.md cat /tmp/add-memory.txt | \ xargs sed -i \ 's/#include "absl\/memory\/memory.h"/#include <memory>/g' git cl format # Manual fix order of the new inserted #include <memory> cat /tmp/only_make_unique | xargs grep -l "#include <memory>" | \ xargs sed -i '/#include "absl\/memory\/memory.h"/d' git ls-files | grep BUILD.gn | \ xargs sed -i '/\/\/third_party\/abseil-cpp\/absl\/memory/d' python tools_webrtc/gn_check_autofix.py \ -m tryserver.webrtc -b linux_rel # Repead the gn_check_autofix step for other platforms git ls-files | grep BUILD.gn | \ xargs sed -i 's/absl\/memory:memory/absl\/memory/g' git cl format Bug: webrtc:10945 Change-Id: I3fe28ea80f4dd3ba3cf28effd151d5e1f19aff89 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/153221 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29209}
2019-09-17 17:06:18 +02:00
: call_started_(false), pc_observer_(std::make_unique<PCObserver>(this)) {
thread_checker_.Detach();
CreatePeerConnectionFactory();
}
AndroidCallClient::~AndroidCallClient() = default;
void AndroidCallClient::Call(JNIEnv* env,
const webrtc::JavaRef<jobject>& local_sink,
const webrtc::JavaRef<jobject>& remote_sink) {
RTC_DCHECK_RUN_ON(&thread_checker_);
webrtc::MutexLock lock(&pc_mutex_);
if (call_started_) {
RTC_LOG(LS_WARNING) << "Call already started.";
return;
}
call_started_ = true;
local_sink_ = webrtc::JavaToNativeVideoSink(env, local_sink.obj());
remote_sink_ = webrtc::JavaToNativeVideoSink(env, remote_sink.obj());
video_source_ = webrtc::CreateJavaVideoSource(env, signaling_thread_.get(),
/* is_screencast= */ false,
/* align_timestamps= */ true);
CreatePeerConnection();
Connect();
}
Roll chromium_revision 67eba1f62b..3c3851d3ca (681379:681486) + JNI fix Change log: https://chromium.googlesource.com/chromium/src/+log/67eba1f62b..3c3851d3ca Full diff: https://chromium.googlesource.com/chromium/src/+/67eba1f62b..3c3851d3ca This CL also includes all the required updates to remove the jcaller object from the parameter list of methods that don't need it. Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/a0992bdcd3..4ee11af5ff * src/build: https://chromium.googlesource.com/chromium/src/build/+log/e36ae524d9..4ae7e91430 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/a87556eeec..429f84ccae * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/f391f81ac8..313b861b55 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/dc1d83593b..dc539d589f * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/e3614ad6f5..c10743f873 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/97c481e2cf..b74bc013c1 DEPS diff: https://chromium.googlesource.com/chromium/src/+/67eba1f62b..3c3851d3ca/DEPS No update to Clang. TBR=chromium-webrtc-autoroll@webrtc-ci.iam.gserviceaccount.com, BUG=None No-Try: True Change-Id: I284a086d320c2df7a33152098a196f5af813375a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/147261 Reviewed-by: Oleh Prypin <oprypin@webrtc.org> Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28698}
2019-07-29 15:33:57 +02:00
void AndroidCallClient::Hangup(JNIEnv* env) {
RTC_DCHECK_RUN_ON(&thread_checker_);
call_started_ = false;
{
webrtc::MutexLock lock(&pc_mutex_);
if (pc_ != nullptr) {
pc_->Close();
pc_ = nullptr;
}
}
local_sink_ = nullptr;
remote_sink_ = nullptr;
video_source_ = nullptr;
}
Roll chromium_revision 67eba1f62b..3c3851d3ca (681379:681486) + JNI fix Change log: https://chromium.googlesource.com/chromium/src/+log/67eba1f62b..3c3851d3ca Full diff: https://chromium.googlesource.com/chromium/src/+/67eba1f62b..3c3851d3ca This CL also includes all the required updates to remove the jcaller object from the parameter list of methods that don't need it. Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/a0992bdcd3..4ee11af5ff * src/build: https://chromium.googlesource.com/chromium/src/build/+log/e36ae524d9..4ae7e91430 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/a87556eeec..429f84ccae * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/f391f81ac8..313b861b55 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/dc1d83593b..dc539d589f * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/e3614ad6f5..c10743f873 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/97c481e2cf..b74bc013c1 DEPS diff: https://chromium.googlesource.com/chromium/src/+/67eba1f62b..3c3851d3ca/DEPS No update to Clang. TBR=chromium-webrtc-autoroll@webrtc-ci.iam.gserviceaccount.com, BUG=None No-Try: True Change-Id: I284a086d320c2df7a33152098a196f5af813375a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/147261 Reviewed-by: Oleh Prypin <oprypin@webrtc.org> Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28698}
2019-07-29 15:33:57 +02:00
void AndroidCallClient::Delete(JNIEnv* env) {
RTC_DCHECK_RUN_ON(&thread_checker_);
delete this;
}
webrtc::ScopedJavaLocalRef<jobject>
Roll chromium_revision 67eba1f62b..3c3851d3ca (681379:681486) + JNI fix Change log: https://chromium.googlesource.com/chromium/src/+log/67eba1f62b..3c3851d3ca Full diff: https://chromium.googlesource.com/chromium/src/+/67eba1f62b..3c3851d3ca This CL also includes all the required updates to remove the jcaller object from the parameter list of methods that don't need it. Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/a0992bdcd3..4ee11af5ff * src/build: https://chromium.googlesource.com/chromium/src/build/+log/e36ae524d9..4ae7e91430 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/a87556eeec..429f84ccae * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/f391f81ac8..313b861b55 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/dc1d83593b..dc539d589f * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/e3614ad6f5..c10743f873 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/97c481e2cf..b74bc013c1 DEPS diff: https://chromium.googlesource.com/chromium/src/+/67eba1f62b..3c3851d3ca/DEPS No update to Clang. TBR=chromium-webrtc-autoroll@webrtc-ci.iam.gserviceaccount.com, BUG=None No-Try: True Change-Id: I284a086d320c2df7a33152098a196f5af813375a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/147261 Reviewed-by: Oleh Prypin <oprypin@webrtc.org> Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28698}
2019-07-29 15:33:57 +02:00
AndroidCallClient::GetJavaVideoCapturerObserver(JNIEnv* env) {
RTC_DCHECK_RUN_ON(&thread_checker_);
return video_source_->GetJavaVideoCapturerObserver(env);
}
void AndroidCallClient::CreatePeerConnectionFactory() {
network_thread_ = rtc::Thread::CreateWithSocketServer();
network_thread_->SetName("network_thread", nullptr);
RTC_CHECK(network_thread_->Start()) << "Failed to start thread";
worker_thread_ = rtc::Thread::Create();
worker_thread_->SetName("worker_thread", nullptr);
RTC_CHECK(worker_thread_->Start()) << "Failed to start thread";
signaling_thread_ = rtc::Thread::Create();
signaling_thread_->SetName("signaling_thread", nullptr);
RTC_CHECK(signaling_thread_->Start()) << "Failed to start thread";
webrtc::PeerConnectionFactoryDependencies pcf_deps;
pcf_deps.network_thread = network_thread_.get();
pcf_deps.worker_thread = worker_thread_.get();
pcf_deps.signaling_thread = signaling_thread_.get();
pcf_deps.task_queue_factory = webrtc::CreateDefaultTaskQueueFactory();
pcf_deps.call_factory = webrtc::CreateCallFactory();
Use std::make_unique instead of absl::make_unique. WebRTC is now using C++14 so there is no need to use the Abseil version of std::make_unique. This CL has been created with the following steps: git grep -l absl::make_unique | sort | uniq > /tmp/make_unique.txt git grep -l absl::WrapUnique | sort | uniq > /tmp/wrap_unique.txt git grep -l "#include <memory>" | sort | uniq > /tmp/memory.txt diff --new-line-format="" --unchanged-line-format="" \ /tmp/make_unique.txt /tmp/wrap_unique.txt | sort | \ uniq > /tmp/only_make_unique.txt diff --new-line-format="" --unchanged-line-format="" \ /tmp/only_make_unique.txt /tmp/memory.txt | \ xargs grep -l "absl/memory" > /tmp/add-memory.txt git grep -l "\babsl::make_unique\b" | \ xargs sed -i "s/\babsl::make_unique\b/std::make_unique/g" git checkout PRESUBMIT.py abseil-in-webrtc.md cat /tmp/add-memory.txt | \ xargs sed -i \ 's/#include "absl\/memory\/memory.h"/#include <memory>/g' git cl format # Manual fix order of the new inserted #include <memory> cat /tmp/only_make_unique | xargs grep -l "#include <memory>" | \ xargs sed -i '/#include "absl\/memory\/memory.h"/d' git ls-files | grep BUILD.gn | \ xargs sed -i '/\/\/third_party\/abseil-cpp\/absl\/memory/d' python tools_webrtc/gn_check_autofix.py \ -m tryserver.webrtc -b linux_rel # Repead the gn_check_autofix step for other platforms git ls-files | grep BUILD.gn | \ xargs sed -i 's/absl\/memory:memory/absl\/memory/g' git cl format Bug: webrtc:10945 Change-Id: I3fe28ea80f4dd3ba3cf28effd151d5e1f19aff89 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/153221 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29209}
2019-09-17 17:06:18 +02:00
pcf_deps.event_log_factory = std::make_unique<webrtc::RtcEventLogFactory>(
pcf_deps.task_queue_factory.get());
cricket::MediaEngineDependencies media_deps;
media_deps.task_queue_factory = pcf_deps.task_queue_factory.get();
media_deps.video_encoder_factory =
Use std::make_unique instead of absl::make_unique. WebRTC is now using C++14 so there is no need to use the Abseil version of std::make_unique. This CL has been created with the following steps: git grep -l absl::make_unique | sort | uniq > /tmp/make_unique.txt git grep -l absl::WrapUnique | sort | uniq > /tmp/wrap_unique.txt git grep -l "#include <memory>" | sort | uniq > /tmp/memory.txt diff --new-line-format="" --unchanged-line-format="" \ /tmp/make_unique.txt /tmp/wrap_unique.txt | sort | \ uniq > /tmp/only_make_unique.txt diff --new-line-format="" --unchanged-line-format="" \ /tmp/only_make_unique.txt /tmp/memory.txt | \ xargs grep -l "absl/memory" > /tmp/add-memory.txt git grep -l "\babsl::make_unique\b" | \ xargs sed -i "s/\babsl::make_unique\b/std::make_unique/g" git checkout PRESUBMIT.py abseil-in-webrtc.md cat /tmp/add-memory.txt | \ xargs sed -i \ 's/#include "absl\/memory\/memory.h"/#include <memory>/g' git cl format # Manual fix order of the new inserted #include <memory> cat /tmp/only_make_unique | xargs grep -l "#include <memory>" | \ xargs sed -i '/#include "absl\/memory\/memory.h"/d' git ls-files | grep BUILD.gn | \ xargs sed -i '/\/\/third_party\/abseil-cpp\/absl\/memory/d' python tools_webrtc/gn_check_autofix.py \ -m tryserver.webrtc -b linux_rel # Repead the gn_check_autofix step for other platforms git ls-files | grep BUILD.gn | \ xargs sed -i 's/absl\/memory:memory/absl\/memory/g' git cl format Bug: webrtc:10945 Change-Id: I3fe28ea80f4dd3ba3cf28effd151d5e1f19aff89 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/153221 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29209}
2019-09-17 17:06:18 +02:00
std::make_unique<webrtc::InternalEncoderFactory>();
media_deps.video_decoder_factory =
Use std::make_unique instead of absl::make_unique. WebRTC is now using C++14 so there is no need to use the Abseil version of std::make_unique. This CL has been created with the following steps: git grep -l absl::make_unique | sort | uniq > /tmp/make_unique.txt git grep -l absl::WrapUnique | sort | uniq > /tmp/wrap_unique.txt git grep -l "#include <memory>" | sort | uniq > /tmp/memory.txt diff --new-line-format="" --unchanged-line-format="" \ /tmp/make_unique.txt /tmp/wrap_unique.txt | sort | \ uniq > /tmp/only_make_unique.txt diff --new-line-format="" --unchanged-line-format="" \ /tmp/only_make_unique.txt /tmp/memory.txt | \ xargs grep -l "absl/memory" > /tmp/add-memory.txt git grep -l "\babsl::make_unique\b" | \ xargs sed -i "s/\babsl::make_unique\b/std::make_unique/g" git checkout PRESUBMIT.py abseil-in-webrtc.md cat /tmp/add-memory.txt | \ xargs sed -i \ 's/#include "absl\/memory\/memory.h"/#include <memory>/g' git cl format # Manual fix order of the new inserted #include <memory> cat /tmp/only_make_unique | xargs grep -l "#include <memory>" | \ xargs sed -i '/#include "absl\/memory\/memory.h"/d' git ls-files | grep BUILD.gn | \ xargs sed -i '/\/\/third_party\/abseil-cpp\/absl\/memory/d' python tools_webrtc/gn_check_autofix.py \ -m tryserver.webrtc -b linux_rel # Repead the gn_check_autofix step for other platforms git ls-files | grep BUILD.gn | \ xargs sed -i 's/absl\/memory:memory/absl\/memory/g' git cl format Bug: webrtc:10945 Change-Id: I3fe28ea80f4dd3ba3cf28effd151d5e1f19aff89 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/153221 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29209}
2019-09-17 17:06:18 +02:00
std::make_unique<webrtc::InternalDecoderFactory>();
webrtc::SetMediaEngineDefaults(&media_deps);
pcf_deps.media_engine = cricket::CreateMediaEngine(std::move(media_deps));
RTC_LOG(LS_INFO) << "Media engine created: " << pcf_deps.media_engine.get();
pcf_ = CreateModularPeerConnectionFactory(std::move(pcf_deps));
RTC_LOG(LS_INFO) << "PeerConnectionFactory created: " << pcf_;
}
void AndroidCallClient::CreatePeerConnection() {
webrtc::MutexLock lock(&pc_mutex_);
webrtc::PeerConnectionInterface::RTCConfiguration config;
config.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan;
// Encryption has to be disabled for loopback to work.
webrtc::PeerConnectionFactoryInterface::Options options;
options.disable_encryption = true;
pcf_->SetOptions(options);
webrtc::PeerConnectionDependencies deps(pc_observer_.get());
pc_ = pcf_->CreatePeerConnectionOrError(config, std::move(deps)).MoveValue();
RTC_LOG(LS_INFO) << "PeerConnection created: " << pc_;
rtc::scoped_refptr<webrtc::VideoTrackInterface> local_video_track =
pcf_->CreateVideoTrack("video", video_source_);
local_video_track->AddOrUpdateSink(local_sink_.get(), rtc::VideoSinkWants());
pc_->AddTransceiver(local_video_track);
RTC_LOG(LS_INFO) << "Local video sink set up: " << local_video_track;
for (const rtc::scoped_refptr<webrtc::RtpTransceiverInterface>& tranceiver :
pc_->GetTransceivers()) {
rtc::scoped_refptr<webrtc::MediaStreamTrackInterface> track =
tranceiver->receiver()->track();
if (track &&
track->kind() == webrtc::MediaStreamTrackInterface::kVideoKind) {
static_cast<webrtc::VideoTrackInterface*>(track.get())
->AddOrUpdateSink(remote_sink_.get(), rtc::VideoSinkWants());
RTC_LOG(LS_INFO) << "Remote video sink set up: " << track;
break;
}
}
}
void AndroidCallClient::Connect() {
webrtc::MutexLock lock(&pc_mutex_);
pc_->CreateOffer(new rtc::RefCountedObject<CreateOfferObserver>(pc_),
webrtc::PeerConnectionInterface::RTCOfferAnswerOptions());
}
AndroidCallClient::PCObserver::PCObserver(AndroidCallClient* client)
: client_(client) {}
void AndroidCallClient::PCObserver::OnSignalingChange(
webrtc::PeerConnectionInterface::SignalingState new_state) {
RTC_LOG(LS_INFO) << "OnSignalingChange: " << new_state;
}
void AndroidCallClient::PCObserver::OnDataChannel(
rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) {
RTC_LOG(LS_INFO) << "OnDataChannel";
}
void AndroidCallClient::PCObserver::OnRenegotiationNeeded() {
RTC_LOG(LS_INFO) << "OnRenegotiationNeeded";
}
void AndroidCallClient::PCObserver::OnIceConnectionChange(
webrtc::PeerConnectionInterface::IceConnectionState new_state) {
RTC_LOG(LS_INFO) << "OnIceConnectionChange: " << new_state;
}
void AndroidCallClient::PCObserver::OnIceGatheringChange(
webrtc::PeerConnectionInterface::IceGatheringState new_state) {
RTC_LOG(LS_INFO) << "OnIceGatheringChange: " << new_state;
}
void AndroidCallClient::PCObserver::OnIceCandidate(
const webrtc::IceCandidateInterface* candidate) {
RTC_LOG(LS_INFO) << "OnIceCandidate: " << candidate->server_url();
webrtc::MutexLock lock(&client_->pc_mutex_);
RTC_DCHECK(client_->pc_ != nullptr);
client_->pc_->AddIceCandidate(candidate);
}
CreateOfferObserver::CreateOfferObserver(
rtc::scoped_refptr<webrtc::PeerConnectionInterface> pc)
: pc_(pc) {}
void CreateOfferObserver::OnSuccess(webrtc::SessionDescriptionInterface* desc) {
std::string sdp;
desc->ToString(&sdp);
RTC_LOG(LS_INFO) << "Created offer: " << sdp;
// Ownership of desc was transferred to us, now we transfer it forward.
pc_->SetLocalDescription(
new rtc::RefCountedObject<SetLocalSessionDescriptionObserver>(), desc);
// Generate a fake answer.
std::unique_ptr<webrtc::SessionDescriptionInterface> answer(
webrtc::CreateSessionDescription(webrtc::SdpType::kAnswer, sdp));
pc_->SetRemoteDescription(
std::move(answer),
new rtc::RefCountedObject<SetRemoteSessionDescriptionObserver>());
}
void CreateOfferObserver::OnFailure(webrtc::RTCError error) {
RTC_LOG(LS_INFO) << "Failed to create offer: " << ToString(error.type())
<< ": " << error.message();
}
void SetRemoteSessionDescriptionObserver::OnSetRemoteDescriptionComplete(
webrtc::RTCError error) {
RTC_LOG(LS_INFO) << "Set remote description: " << error.message();
}
void SetLocalSessionDescriptionObserver::OnSuccess() {
RTC_LOG(LS_INFO) << "Set local description success!";
}
void SetLocalSessionDescriptionObserver::OnFailure(webrtc::RTCError error) {
RTC_LOG(LS_INFO) << "Set local description failure: "
<< ToString(error.type()) << ": " << error.message();
}
Roll chromium_revision 3546854f59..2e285ebae2 (612694:613019) + fix JNI This changelist is based on Chromium autoroller CL https://webrtc-review.googlesource.com/c/src/+/112847 with additional JNI fixes needed to propagate upstream changes introduced in https://chromium.googlesource.com/chromium/src/+/c99e905516a43b083f57672a256aade7cb09b872 Change log: https://chromium.googlesource.com/chromium/src/+log/3546854f59..2e285ebae2 Full diff: https://chromium.googlesource.com/chromium/src/+/3546854f59..2e285ebae2 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/0551460b2b..62febbdbd7 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/59f4bb0792..8b1ff06550 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/0c78d113b3..2c8e8f83db * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/d387a4a97a..da3cc6c84a * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/e31ab38349..a862efe9b4 * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/1b98245e3c..6f862e54f2 * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/016601cc21..0b287c5bca * src/third_party/r8: uM1IGlYVeBYwmhwRCSMVqRvmu4YFlL7M2yLwZ1DWUvAC..ndmKWh0vZhDc2iLXEETOuWXVfafHbqwI_FcSgJJIfpoC * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/476768d37c..cc443eb2fd DEPS diff: https://chromium.googlesource.com/chromium/src/+/3546854f59..2e285ebae2/DEPS No update to Clang. No-Try: True Bug: chromium:898660 Change-Id: I8be89e16d9639d96fc09f053e29414381a486846 Reviewed-on: https://webrtc-review.googlesource.com/c/112595 Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Reviewed-by: Oleh Prypin <oprypin@webrtc.org> Commit-Queue: Artem Titarenko <artit@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25900}
2018-12-03 11:02:28 +01:00
static jlong JNI_CallClient_CreateClient(JNIEnv* env) {
return webrtc::NativeToJavaPointer(new webrtc_examples::AndroidCallClient());
}
} // namespace webrtc_examples