build: move libcc patches to electron repo (#14104)

In the GN build, libchromiumcontent is no longer a distinct library, but
merely a container for a set of scripts and patches. Maintaining those
patches in a separate repository is tedious and error-prone, so merge
them into the main repo.

Once this is merged and GN is the default way to build Electron, the
libchromiumcontent repository can be archived.
This commit is contained in:
Jeremy Apthorp 2018-09-13 22:02:16 -07:00 committed by GitHub
parent 9e85bdb02c
commit 76c5f5cc8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
147 changed files with 86931 additions and 6 deletions

View file

@ -0,0 +1,15 @@
repo: src/third_party/webrtc
patches:
-
author: null
file: webrtc-desktop_capturer_mac.patch
description: null
-
author: null
file: webrtc-rwlock_null.patch
description: null
-
author: Nitish Sakhawalkar <nitsakh@icloud.com>
file: disable-warning-win.patch
description:
Disable windows warning

View file

@ -0,0 +1,18 @@
a157e080931581b5f6f3f9bc580a137e6062e45b
diff --git a/modules/video_coding/rtp_frame_reference_finder.cc b/modules/video_coding/rtp_frame_reference_finder.cc
index be05e56070..09b2593531 100644
--- a/modules/video_coding/rtp_frame_reference_finder.cc
+++ b/modules/video_coding/rtp_frame_reference_finder.cc
@@ -533,6 +533,12 @@ bool RtpFrameReferenceFinder::MissingRequiredFrameVp9(uint16_t picture_id,
size_t gof_idx = diff % info.gof->num_frames_in_gof;
size_t temporal_idx = info.gof->temporal_idx[gof_idx];
+ if (temporal_idx >= kMaxTemporalLayers) {
+ RTC_LOG(LS_WARNING) << "At most " << kMaxTemporalLayers << " temporal "
+ << "layers are supported.";
+ return true;
+ }
+
// For every reference this frame has, check if there is a frame missing in
// the interval (|ref_pid|, |picture_id|) in any of the lower temporal
// layers. If so, we are missing a required frame.

View file

@ -0,0 +1,16 @@
diff --git a/rtc_base/thread.cc b/rtc_base/thread.cc
index 1bc0c0cd8..51208e4f0 100644
--- a/rtc_base/thread.cc
+++ b/rtc_base/thread.cc
@@ -23,7 +23,10 @@
#include "rtc_base/stringutils.h"
#include "rtc_base/timeutils.h"
#include "rtc_base/trace_event.h"
-
+#ifdef _WIN32
+//Warning on windows because ThreadManager destructor never returns
+#pragma warning(disable:4722)
+#endif
namespace rtc {
ThreadManager* ThreadManager::Instance() {

View file

@ -0,0 +1,117 @@
diff --git a/modules/desktop_capture/mac/screen_capturer_mac.mm b/modules/desktop_capture/mac/screen_capturer_mac.mm
index df18777226..6a1e3da6ab 100644
--- a/modules/desktop_capture/mac/screen_capturer_mac.mm
+++ b/modules/desktop_capture/mac/screen_capturer_mac.mm
@@ -16,6 +16,7 @@
#include "rtc_base/checks.h"
#include "rtc_base/constructormagic.h"
#include "rtc_base/logging.h"
+#include "rtc_base/synchronization/rw_lock_wrapper.h"
#include "rtc_base/timeutils.h"
#include "sdk/objc/Framework/Classes/Common/scoped_cftyperef.h"
@@ -28,18 +29,31 @@ namespace webrtc {
// destroy itself once it's done.
class DisplayStreamManager {
public:
- int GetUniqueId() { return ++unique_id_generator_; }
- void DestroyStream(int unique_id) {
- auto it = display_stream_wrappers_.find(unique_id);
- RTC_CHECK(it != display_stream_wrappers_.end());
- RTC_CHECK(!it->second.active);
- CFRelease(it->second.stream);
- display_stream_wrappers_.erase(it);
+ DisplayStreamManager() : rw_lock_(RWLockWrapper::CreateRWLock()) {}
+ RWLockWrapper* GetLock() {return rw_lock_.get();};
- if (ready_for_self_destruction_ && display_stream_wrappers_.empty()) delete this;
+ int GetUniqueId() {
+ WriteLockScoped scoped_display_stream_manager_lock(*rw_lock_);
+ return ++unique_id_generator_;
+ }
+ void DestroyStream(int unique_id) {
+ bool finalize;
+ {
+ WriteLockScoped scoped_display_stream_manager_lock(*rw_lock_);
+ auto it = display_stream_wrappers_.find(unique_id);
+ RTC_CHECK(it != display_stream_wrappers_.end());
+ RTC_CHECK(!it->second.active);
+ CFRelease(it->second.stream);
+ display_stream_wrappers_.erase(it);
+ finalize = ready_for_self_destruction_ && display_stream_wrappers_.empty();
+ }
+ if (finalize) {
+ delete this;
+ }
}
void SaveStream(int unique_id, CGDisplayStreamRef stream) {
+ WriteLockScoped scoped_display_stream_manager_lock(*rw_lock_);
RTC_CHECK(unique_id <= unique_id_generator_);
DisplayStreamWrapper wrapper;
wrapper.stream = stream;
@@ -47,6 +61,7 @@ class DisplayStreamManager {
}
void UnregisterActiveStreams() {
+ WriteLockScoped scoped_display_stream_manager_lock(*rw_lock_);
for (auto& pair : display_stream_wrappers_) {
DisplayStreamWrapper& wrapper = pair.second;
if (wrapper.active) {
@@ -61,12 +76,23 @@ class DisplayStreamManager {
void PrepareForSelfDestruction() {
ready_for_self_destruction_ = true;
- if (display_stream_wrappers_.empty()) delete this;
+ bool finalize;
+ {
+ WriteLockScoped scoped_display_stream_manager_lock(*rw_lock_);
+ ready_for_self_destruction_ = true;
+ finalize = display_stream_wrappers_.empty();
+ }
+ if (finalize) {
+ delete this;
+ }
}
// Once the DisplayStreamManager is ready for destruction, the
// ScreenCapturerMac is no longer present. Any updates should be ignored.
- bool ShouldIgnoreUpdates() { return ready_for_self_destruction_; }
+ // Note: not thread-safe! Acquire and release a lock manually.
+ bool ShouldIgnoreUpdates() {
+ return ready_for_self_destruction_;
+ }
private:
struct DisplayStreamWrapper {
@@ -81,6 +107,7 @@ class DisplayStreamManager {
std::map<int, DisplayStreamWrapper> display_stream_wrappers_;
int unique_id_generator_ = 0;
bool ready_for_self_destruction_ = false;
+ std::unique_ptr<RWLockWrapper> rw_lock_;
};
namespace {
@@ -507,8 +534,6 @@ bool ScreenCapturerMac::RegisterRefreshAndMoveHandlers() {
return;
}
- if (manager->ShouldIgnoreUpdates()) return;
-
// Only pay attention to frame updates.
if (status != kCGDisplayStreamFrameStatusFrameComplete) return;
@@ -518,7 +543,12 @@ bool ScreenCapturerMac::RegisterRefreshAndMoveHandlers() {
if (count != 0) {
// According to CGDisplayStream.h, it's safe to call
// CGDisplayStreamStop() from within the callback.
- ScreenRefresh(count, rects, display_origin);
+ manager->GetLock()->AcquireLockShared();
+ bool screen_capturer_mac_invalidated = manager->ShouldIgnoreUpdates();
+ if (!screen_capturer_mac_invalidated) {
+ ScreenRefresh(count, rects, display_origin);
+ }
+ manager->GetLock()->ReleaseLockShared();
}
};

View file

@ -0,0 +1,36 @@
diff --git a/rtc_base/synchronization/rw_lock_wrapper.cc b/rtc_base/synchronization/rw_lock_wrapper.cc
index c8cd17edb8..50c6e25ad9 100644
--- a/rtc_base/synchronization/rw_lock_wrapper.cc
+++ b/rtc_base/synchronization/rw_lock_wrapper.cc
@@ -11,6 +11,9 @@
#include "rtc_base/synchronization/rw_lock_wrapper.h"
#include <assert.h>
+#include <stdlib.h>
+
+#include "system_wrappers/include/sleep.h"
#if defined(_WIN32)
#include "rtc_base/synchronization/rw_lock_win.h"
@@ -21,11 +23,19 @@
namespace webrtc {
RWLockWrapper* RWLockWrapper::CreateRWLock() {
+ RWLockWrapper* rw_lock_ptr;
#ifdef _WIN32
- return RWLockWin::Create();
+ rw_lock_ptr = RWLockWin::Create();
#else
- return RWLockPosix::Create();
+ rw_lock_ptr = RWLockPosix::Create();
#endif
+ if (rw_lock_ptr != NULL) {
+ return rw_lock_ptr;
+ } else {
+ int msec_wait = 10 + (rand() % 90);
+ SleepMs(msec_wait);
+ return CreateRWLock();
+ }
}
} // namespace webrtc