Bug 1928110 - Vendor libwebrtc from 0549950113

We already cherry-picked this when we vendored 37458ce40a.

Upstream commit: https://webrtc.googlesource.com/src/+/054995011389d5adaf82804ea667d0727eb8002e
    Revert "Per defaul probe max to 2x current BWE if max total allocated bitrate change"

    This reverts commit 37458ce40a1741f9d5358d49fe49beed20140502.

    Reason for revert: Will be wired up as an experiment instead.

    Original change's description:
    > Per defaul probe max to 2x current BWE if max total allocated bitrate change
    >
    > This aligns to probe limits in ALR for example.
    >
    > Bug: webrtc:369044000, b/369021234
    > Change-Id: I3823b308cf97a8b7060b35b2ac38864e75d6f983
    > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/363301
    > Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
    > Reviewed-by: Diep Bui <diepbp@webrtc.org>
    > Commit-Queue: Per Kjellander <perkj@webrtc.org>
    > Cr-Commit-Position: refs/heads/main@{#43074}

    Bug: webrtc:369044000, b/369021234
    Change-Id: I22b457254c9c21d2d951af2bda01a349ef83b3c7
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/364242
    Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
    Commit-Queue: Per Kjellander <perkj@webrtc.org>
    Commit-Queue: Ranveer Aggarwal‎ <ranvr@webrtc.org>
    Reviewed-by: Diep Bui <diepbp@webrtc.org>
    Cr-Commit-Position: refs/heads/main@{#43130}
This commit is contained in:
Michael Froman 2024-11-25 20:53:29 -06:00
parent 956670cab2
commit 40d6fe3605
138 changed files with 48267 additions and 48349 deletions

View File

@ -33183,3 +33183,6 @@ b3ac753f26
# MOZ_LIBWEBRTC_SRC=/home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
# base of lastest vendoring
00ff9dd4e4
# MOZ_LIBWEBRTC_SRC=/home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
# base of lastest vendoring
0549950113

View File

@ -22148,3 +22148,5 @@ libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc
libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-11-19T18:43:55.053670.
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-11-19T18:44:53.237751.
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-11-19T18:45:51.946485.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,43 +1,34 @@
From: Nico Grunbaum <na-g@nostrum.com>
Date: Sat, 13 Feb 2021 04:20:00 -0800
Subject: Bug 1654112 - Add pid_t to desktop_capture_types.h; r=pehrsons
From: Michael Froman <mfroman@mozilla.com>
Date: Fri, 9 Jul 2021 18:14:00 -0500
Subject: Bug 1654112 - mutex changes to fix tsan errors. r=ng
Upstreaming bug 1697385
Also includes:
Bug 1654112 - Clarifying prev. rev that moved pid_t into the global namespace; r=dminor
Differential Revision: https://phabricator.services.mozilla.com/D107897
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/539b69f0e21118a1898f1ef689577c7193ff7be7
Differential Revision: https://phabricator.services.mozilla.com/D119674
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/3d5503acf9a4b22e02c4300f29e4fbfed406ea2c
---
modules/desktop_capture/desktop_capture_types.h | 4 ++++
modules/video_capture/video_capture.h | 1 +
2 files changed, 5 insertions(+)
rtc_base/logging.cc | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/modules/desktop_capture/desktop_capture_types.h b/modules/desktop_capture/desktop_capture_types.h
index a4e3e897fd..e777a45f92 100644
--- a/modules/desktop_capture/desktop_capture_types.h
+++ b/modules/desktop_capture/desktop_capture_types.h
@@ -13,6 +13,10 @@
diff --git a/rtc_base/logging.cc b/rtc_base/logging.cc
index ad2303735e..9c2d3b0a39 100644
--- a/rtc_base/logging.cc
+++ b/rtc_base/logging.cc
@@ -275,8 +275,8 @@ void LogMessage::LogTimestamps(bool on) {
}
#include <stdint.h>
void LogMessage::LogToDebug(LoggingSeverity min_sev) {
- g_dbg_sev = min_sev;
webrtc::MutexLock lock(&GetLoggingLock());
+ g_dbg_sev = min_sev;
UpdateMinLogSeverity();
}
+#ifdef XP_WIN // Moving this into the global namespace
+typedef int pid_t; // matching what used to be in
+#endif // video_capture_defines.h
+
namespace webrtc {
@@ -460,6 +460,9 @@ void LogMessage::OutputToDebug(const LogLineRef& log_line) {
enum class CaptureType { kWindow, kScreen, kAnyScreenContent };
diff --git a/modules/video_capture/video_capture.h b/modules/video_capture/video_capture.h
index f31b239c71..7279bed476 100644
--- a/modules/video_capture/video_capture.h
+++ b/modules/video_capture/video_capture.h
@@ -13,6 +13,7 @@
#include "api/video/video_rotation.h"
#include "api/video/video_sink_interface.h"
+#include "modules/desktop_capture/desktop_capture_types.h"
#include "modules/video_capture/raw_video_sink_interface.h"
#include "modules/video_capture/video_capture_defines.h"
#include <set>
// static
bool LogMessage::IsNoop(LoggingSeverity severity) {
+ // Added MutexLock to fix tsan warnings on accessing g_dbg_sev. (mjf)
+ // See https://bugs.chromium.org/p/chromium/issues/detail?id=1228729
+ webrtc::MutexLock lock(&GetLoggingLock());
if (severity >= g_dbg_sev || severity >= g_min_sev)
return false;
return streams_empty_.load(std::memory_order_relaxed);

View File

@ -1,34 +1,46 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Fri, 9 Jul 2021 18:14:00 -0500
Subject: Bug 1654112 - mutex changes to fix tsan errors. r=ng
From: Dan Minor <dminor@mozilla.com>
Date: Wed, 18 Nov 2020 13:33:00 -0500
Subject: Bug 1654112 - Suppress -Wclass-varargs warning in logging.h. r=ng
Differential Revision: https://phabricator.services.mozilla.com/D119674
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/3d5503acf9a4b22e02c4300f29e4fbfed406ea2c
This needs some investigation to see why we get this warning when it is not
present upstream.
Since both were doing the same thing for different compiler chains,
also includes:
Bug 1654112 - linux build fix (pragmas) for base-toolchains* . r=ng
Differential Revision: https://phabricator.services.mozilla.com/D130086
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8d832e832ffe513246c0763a56376a8022b2447b
---
rtc_base/logging.cc | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
rtc_base/logging.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/rtc_base/logging.cc b/rtc_base/logging.cc
index ad2303735e..9c2d3b0a39 100644
--- a/rtc_base/logging.cc
+++ b/rtc_base/logging.cc
@@ -275,8 +275,8 @@ void LogMessage::LogTimestamps(bool on) {
}
diff --git a/rtc_base/logging.h b/rtc_base/logging.h
index afc5613fe4..c5287f3c15 100644
--- a/rtc_base/logging.h
+++ b/rtc_base/logging.h
@@ -48,6 +48,14 @@
#ifndef RTC_BASE_LOGGING_H_
#define RTC_BASE_LOGGING_H_
void LogMessage::LogToDebug(LoggingSeverity min_sev) {
- g_dbg_sev = min_sev;
webrtc::MutexLock lock(&GetLoggingLock());
+ g_dbg_sev = min_sev;
UpdateMinLogSeverity();
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wvarargs"
+
+#if defined(__clang__)
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wclass-varargs"
+#endif
+
#include <errno.h>
@@ -460,6 +460,9 @@ void LogMessage::OutputToDebug(const LogLineRef& log_line) {
#include <atomic>
@@ -773,4 +781,9 @@ inline const char* AdaptString(const std::string& str) {
// static
bool LogMessage::IsNoop(LoggingSeverity severity) {
+ // Added MutexLock to fix tsan warnings on accessing g_dbg_sev. (mjf)
+ // See https://bugs.chromium.org/p/chromium/issues/detail?id=1228729
+ webrtc::MutexLock lock(&GetLoggingLock());
if (severity >= g_dbg_sev || severity >= g_min_sev)
return false;
return streams_empty_.load(std::memory_order_relaxed);
} // namespace rtc
+#pragma GCC diagnostic pop
+#if defined(__clang__)
+# pragma clang diagnostic pop
+#endif
+
#endif // RTC_BASE_LOGGING_H_

View File

@ -1,46 +1,49 @@
From: Dan Minor <dminor@mozilla.com>
Date: Wed, 18 Nov 2020 13:33:00 -0500
Subject: Bug 1654112 - Suppress -Wclass-varargs warning in logging.h. r=ng
Date: Tue, 27 Mar 2018 15:43:00 -0400
Subject: Bug 1376873 - Disable Mid support in RtpDemuxer; r=mjf
This needs some investigation to see why we get this warning when it is not
present upstream.
The only use of Mid in the current webrtc.org code is in the unit tests.
RtpStreamReceiverController only allows adding sinks using SSRCs. Because
of this, we'll end up dropping packets in the RtpDemuxer with the current
code as none of our Mids will be recognized.
Since both were doing the same thing for different compiler chains,
also includes:
Bug 1654112 - linux build fix (pragmas) for base-toolchains* . r=ng
Tip of webrtc.org fully supports using Mids, so we'll be able to enable this
code again after the next update.
Differential Revision: https://phabricator.services.mozilla.com/D130086
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8d832e832ffe513246c0763a56376a8022b2447b
Differential Revision: https://phabricator.services.mozilla.com/D7442
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b3ba8452e77105c72f6ddbc49cbe5a53dbea1507
---
rtc_base/logging.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
call/rtp_demuxer.cc | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/rtc_base/logging.h b/rtc_base/logging.h
index afc5613fe4..c5287f3c15 100644
--- a/rtc_base/logging.h
+++ b/rtc_base/logging.h
@@ -48,6 +48,14 @@
#ifndef RTC_BASE_LOGGING_H_
#define RTC_BASE_LOGGING_H_
diff --git a/call/rtp_demuxer.cc b/call/rtp_demuxer.cc
index 5dce864e7a..90a156f588 100644
--- a/call/rtp_demuxer.cc
+++ b/call/rtp_demuxer.cc
@@ -282,13 +282,17 @@ RtpPacketSinkInterface* RtpDemuxer::ResolveSink(
// RSID and RRID are routed to the same sinks. If an RSID is specified on a
// repair packet, it should be ignored and the RRID should be used.
std::string packet_mid, packet_rsid;
- bool has_mid = use_mid_ && packet.GetExtension<RtpMid>(&packet_mid);
+ //bool has_mid = use_mid_ && packet.GetExtension<RtpMid>(&packet_mid);
bool has_rsid = packet.GetExtension<RepairedRtpStreamId>(&packet_rsid);
if (!has_rsid) {
has_rsid = packet.GetExtension<RtpStreamId>(&packet_rsid);
}
uint32_t ssrc = packet.Ssrc();
+ // Mid support is half-baked in branch 64. RtpStreamReceiverController only
+ // supports adding sinks by ssrc, so our mids will never show up in
+ // known_mids_, causing us to drop packets here.
+#if 0
// The BUNDLE spec says to drop any packets with unknown MIDs, even if the
// SSRC is known/latched.
if (has_mid && known_mids_.find(packet_mid) == known_mids_.end()) {
@@ -362,6 +366,7 @@ RtpPacketSinkInterface* RtpDemuxer::ResolveSink(
}
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wvarargs"
+
+#if defined(__clang__)
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wclass-varargs"
+#endif
+
#include <errno.h>
#include <atomic>
@@ -773,4 +781,9 @@ inline const char* AdaptString(const std::string& str) {
} // namespace rtc
+#pragma GCC diagnostic pop
+#if defined(__clang__)
+# pragma clang diagnostic pop
+#endif
+
#endif // RTC_BASE_LOGGING_H_
// We trust signaled SSRC more than payload type which is likely to conflict
// between streams.
const auto ssrc_sink_it = sink_by_ssrc_.find(ssrc);

View File

@ -1,49 +1,139 @@
From: Dan Minor <dminor@mozilla.com>
Date: Tue, 27 Mar 2018 15:43:00 -0400
Subject: Bug 1376873 - Disable Mid support in RtpDemuxer; r=mjf
Date: Wed, 7 Feb 2018 15:00:00 -0500
Subject: Bug 1376873 - Fix GetRTCPSenderReport; r=ng
The only use of Mid in the current webrtc.org code is in the unit tests.
RtpStreamReceiverController only allows adding sinks using SSRCs. Because
of this, we'll end up dropping packets in the RtpDemuxer with the current
code as none of our Mids will be recognized.
Tip of webrtc.org fully supports using Mids, so we'll be able to enable this
code again after the next update.
Differential Revision: https://phabricator.services.mozilla.com/D7442
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b3ba8452e77105c72f6ddbc49cbe5a53dbea1507
Differential Revision: https://phabricator.services.mozilla.com/D7431
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b55b0368d9f21849fa465fa9b3f028285c9ea6ae
---
call/rtp_demuxer.cc | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
call/video_receive_stream.h | 3 +++
modules/rtp_rtcp/source/rtcp_receiver.cc | 7 +++++++
modules/rtp_rtcp/source/rtcp_receiver.h | 4 ++++
modules/rtp_rtcp/source/rtp_rtcp_impl.cc | 5 +++++
modules/rtp_rtcp/source/rtp_rtcp_impl.h | 3 +++
modules/rtp_rtcp/source/rtp_rtcp_impl2.cc | 5 +++++
modules/rtp_rtcp/source/rtp_rtcp_impl2.h | 3 +++
modules/rtp_rtcp/source/rtp_rtcp_interface.h | 4 ++++
8 files changed, 34 insertions(+)
diff --git a/call/rtp_demuxer.cc b/call/rtp_demuxer.cc
index 5dce864e7a..90a156f588 100644
--- a/call/rtp_demuxer.cc
+++ b/call/rtp_demuxer.cc
@@ -282,13 +282,17 @@ RtpPacketSinkInterface* RtpDemuxer::ResolveSink(
// RSID and RRID are routed to the same sinks. If an RSID is specified on a
// repair packet, it should be ignored and the RRID should be used.
std::string packet_mid, packet_rsid;
- bool has_mid = use_mid_ && packet.GetExtension<RtpMid>(&packet_mid);
+ //bool has_mid = use_mid_ && packet.GetExtension<RtpMid>(&packet_mid);
bool has_rsid = packet.GetExtension<RepairedRtpStreamId>(&packet_rsid);
if (!has_rsid) {
has_rsid = packet.GetExtension<RtpStreamId>(&packet_rsid);
}
uint32_t ssrc = packet.Ssrc();
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index 3b09c2d78c..8b8caba840 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -169,6 +169,9 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
RtcpPacketTypeCounter rtcp_packet_type_counts;
std::optional<RtpReceiveStats> rtx_rtp_stats;
+ // Mid support is half-baked in branch 64. RtpStreamReceiverController only
+ // supports adding sinks by ssrc, so our mids will never show up in
+ // known_mids_, causing us to drop packets here.
+#if 0
// The BUNDLE spec says to drop any packets with unknown MIDs, even if the
// SSRC is known/latched.
if (has_mid && known_mids_.find(packet_mid) == known_mids_.end()) {
@@ -362,6 +366,7 @@ RtpPacketSinkInterface* RtpDemuxer::ResolveSink(
}
}
+ uint32_t rtcp_sender_packets_sent;
+ uint32_t rtcp_sender_octets_sent;
+
// Timing frame info: all important timestamps for a full lifetime of a
// single 'timing frame'.
std::optional<webrtc::TimingFrameInfo> timing_frame_info;
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc
index 6116470735..959b5d1dce 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.cc
+++ b/modules/rtp_rtcp/source/rtcp_receiver.cc
@@ -387,6 +387,13 @@ RTCPReceiver::ConsumeReceivedXrReferenceTimeInfo() {
return last_xr_rtis;
}
+#endif
// We trust signaled SSRC more than payload type which is likely to conflict
// between streams.
const auto ssrc_sink_it = sink_by_ssrc_.find(ssrc);
+void RTCPReceiver::RemoteRTCPSenderInfo(uint32_t* packet_count,
+ uint32_t* octet_count) const {
+ MutexLock lock(&rtcp_receiver_lock_);
+ *packet_count = remote_sender_packet_count_;
+ *octet_count = remote_sender_octet_count_;
+}
+
std::vector<ReportBlockData> RTCPReceiver::GetLatestReportBlockData() const {
std::vector<ReportBlockData> result;
MutexLock lock(&rtcp_receiver_lock_);
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.h b/modules/rtp_rtcp/source/rtcp_receiver.h
index 766a808044..2551534b9f 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.h
+++ b/modules/rtp_rtcp/source/rtcp_receiver.h
@@ -123,6 +123,10 @@ class RTCPReceiver final {
std::vector<rtcp::ReceiveTimeInfo> ConsumeReceivedXrReferenceTimeInfo();
+ // Get received sender packet and octet counts
+ void RemoteRTCPSenderInfo(uint32_t* packet_count,
+ uint32_t* octet_count) const;
+
std::optional<TimeDelta> AverageRtt() const;
std::optional<TimeDelta> LastRtt() const;
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
index 568b1e22d2..eb39112671 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
@@ -515,6 +515,11 @@ void ModuleRtpRtcpImpl::GetSendStreamDataCounters(
}
// Received RTCP report.
+void ModuleRtpRtcpImpl::RemoteRTCPSenderInfo(uint32_t* packet_count,
+ uint32_t* octet_count) const {
+ return rtcp_receiver_.RemoteRTCPSenderInfo(packet_count, octet_count);
+}
+
std::vector<ReportBlockData> ModuleRtpRtcpImpl::GetLatestReportBlockData()
const {
return rtcp_receiver_.GetLatestReportBlockData();
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.h b/modules/rtp_rtcp/source/rtp_rtcp_impl.h
index 94035ddb02..446882ea67 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.h
@@ -203,6 +203,9 @@ class ABSL_DEPRECATED("") ModuleRtpRtcpImpl
StreamDataCounters* rtp_counters,
StreamDataCounters* rtx_counters) const override;
+ void RemoteRTCPSenderInfo(uint32_t* packet_count,
+ uint32_t* octet_count) const override;
+
// A snapshot of the most recent Report Block with additional data of
// interest to statistics. Used to implement RTCRemoteInboundRtpStreamStats.
// Within this list, the `ReportBlockData::source_ssrc()`, which is the SSRC
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
index fe21008cf1..dbf523dee7 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
@@ -526,6 +526,11 @@ void ModuleRtpRtcpImpl2::GetSendStreamDataCounters(
}
// Received RTCP report.
+void ModuleRtpRtcpImpl2::RemoteRTCPSenderInfo(uint32_t* packet_count,
+ uint32_t* octet_count) const {
+ return rtcp_receiver_.RemoteRTCPSenderInfo(packet_count, octet_count);
+}
+
std::vector<ReportBlockData> ModuleRtpRtcpImpl2::GetLatestReportBlockData()
const {
return rtcp_receiver_.GetLatestReportBlockData();
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
index 57139e2242..1b2afac61f 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
@@ -198,6 +198,9 @@ class ModuleRtpRtcpImpl2 final : public RtpRtcpInterface,
StreamDataCounters* rtp_counters,
StreamDataCounters* rtx_counters) const override;
+ void RemoteRTCPSenderInfo(uint32_t* packet_count,
+ uint32_t* octet_count) const override;
+
// A snapshot of the most recent Report Block with additional data of
// interest to statistics. Used to implement RTCRemoteInboundRtpStreamStats.
// Within this list, the `ReportBlockData::source_ssrc()`, which is the SSRC
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_interface.h b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
index dd34cf7e3e..377f1c27d7 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_interface.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
@@ -399,6 +399,10 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface {
StreamDataCounters* rtp_counters,
StreamDataCounters* rtx_counters) const = 0;
+
+ // Returns packet count and octet count from RTCP sender report.
+ virtual void RemoteRTCPSenderInfo(uint32_t* packet_count,
+ uint32_t* octet_count) const = 0;
// A snapshot of Report Blocks with additional data of interest to statistics.
// Within this list, the sender-source SSRC pair is unique and per-pair the
// ReportBlockData represents the latest Report Block that was received for

View File

@ -1,139 +1,145 @@
From: Dan Minor <dminor@mozilla.com>
Date: Wed, 7 Feb 2018 15:00:00 -0500
Subject: Bug 1376873 - Fix GetRTCPSenderReport; r=ng
From: Nico Grunbaum <na-g@nostrum.com>
Date: Fri, 5 Jun 2020 11:41:00 +0000
Subject: Bug 1615191 - P0 - implement remoteTimestamp for
RTCRemoteOutboundRtpStreamStats in libwebrtc;r=dminor
Differential Revision: https://phabricator.services.mozilla.com/D7431
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b55b0368d9f21849fa465fa9b3f028285c9ea6ae
Differential Revision: https://phabricator.services.mozilla.com/D78004
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/cd901e96d23e004e4bee19b96c8c2f1ca3b42830
This patch also absorbs two additional patches that collapse into using ms for the remote timestamp:
Bug 1654112 - Plumb RemoteRTCPSenderInfo through also for audio and change unit to ms. r=ng
Bug 1654112 - Replace custom upstream code for remote received audio stats with cherry-pick. r=ng
---
call/video_receive_stream.h | 3 +++
modules/rtp_rtcp/source/rtcp_receiver.cc | 7 +++++++
modules/rtp_rtcp/source/rtcp_receiver.h | 4 ++++
modules/rtp_rtcp/source/rtp_rtcp_impl.cc | 5 +++++
modules/rtp_rtcp/source/rtp_rtcp_impl.h | 3 +++
modules/rtp_rtcp/source/rtp_rtcp_impl2.cc | 5 +++++
modules/rtp_rtcp/source/rtp_rtcp_impl2.h | 3 +++
modules/rtp_rtcp/source/rtp_rtcp_interface.h | 4 ++++
8 files changed, 34 insertions(+)
call/video_receive_stream.h | 1 +
modules/rtp_rtcp/source/rtcp_receiver.cc | 4 +++-
modules/rtp_rtcp/source/rtcp_receiver.h | 3 ++-
modules/rtp_rtcp/source/rtp_rtcp_impl.cc | 6 ++++--
modules/rtp_rtcp/source/rtp_rtcp_impl.h | 3 ++-
modules/rtp_rtcp/source/rtp_rtcp_impl2.cc | 6 ++++--
modules/rtp_rtcp/source/rtp_rtcp_impl2.h | 3 ++-
modules/rtp_rtcp/source/rtp_rtcp_interface.h | 5 +++--
8 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index 3b09c2d78c..8b8caba840 100644
index 8b8caba840..f69b03a166 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -169,6 +169,9 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
RtcpPacketTypeCounter rtcp_packet_type_counts;
std::optional<RtpReceiveStats> rtx_rtp_stats;
@@ -171,6 +171,7 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
uint32_t rtcp_sender_packets_sent;
uint32_t rtcp_sender_octets_sent;
+ int64_t rtcp_sender_ntp_timestamp_ms;
+ uint32_t rtcp_sender_packets_sent;
+ uint32_t rtcp_sender_octets_sent;
+
// Timing frame info: all important timestamps for a full lifetime of a
// single 'timing frame'.
std::optional<webrtc::TimingFrameInfo> timing_frame_info;
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc
index 6116470735..959b5d1dce 100644
index 959b5d1dce..85c892767d 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.cc
+++ b/modules/rtp_rtcp/source/rtcp_receiver.cc
@@ -387,6 +387,13 @@ RTCPReceiver::ConsumeReceivedXrReferenceTimeInfo() {
return last_xr_rtis;
@@ -388,10 +388,12 @@ RTCPReceiver::ConsumeReceivedXrReferenceTimeInfo() {
}
+void RTCPReceiver::RemoteRTCPSenderInfo(uint32_t* packet_count,
+ uint32_t* octet_count) const {
+ MutexLock lock(&rtcp_receiver_lock_);
+ *packet_count = remote_sender_packet_count_;
+ *octet_count = remote_sender_octet_count_;
+}
+
std::vector<ReportBlockData> RTCPReceiver::GetLatestReportBlockData() const {
std::vector<ReportBlockData> result;
void RTCPReceiver::RemoteRTCPSenderInfo(uint32_t* packet_count,
- uint32_t* octet_count) const {
+ uint32_t* octet_count,
+ int64_t* ntp_timestamp_ms) const {
MutexLock lock(&rtcp_receiver_lock_);
*packet_count = remote_sender_packet_count_;
*octet_count = remote_sender_octet_count_;
+ *ntp_timestamp_ms = remote_sender_ntp_time_.ToMs();
}
std::vector<ReportBlockData> RTCPReceiver::GetLatestReportBlockData() const {
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.h b/modules/rtp_rtcp/source/rtcp_receiver.h
index 766a808044..2551534b9f 100644
index 2551534b9f..029fc3a5e2 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.h
+++ b/modules/rtp_rtcp/source/rtcp_receiver.h
@@ -123,6 +123,10 @@ class RTCPReceiver final {
@@ -125,7 +125,8 @@ class RTCPReceiver final {
std::vector<rtcp::ReceiveTimeInfo> ConsumeReceivedXrReferenceTimeInfo();
// Get received sender packet and octet counts
void RemoteRTCPSenderInfo(uint32_t* packet_count,
- uint32_t* octet_count) const;
+ uint32_t* octet_count,
+ int64_t* ntp_timestamp_ms) const;
+ // Get received sender packet and octet counts
+ void RemoteRTCPSenderInfo(uint32_t* packet_count,
+ uint32_t* octet_count) const;
+
std::optional<TimeDelta> AverageRtt() const;
std::optional<TimeDelta> LastRtt() const;
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
index 568b1e22d2..eb39112671 100644
index eb39112671..69b6636d3a 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
@@ -515,6 +515,11 @@ void ModuleRtpRtcpImpl::GetSendStreamDataCounters(
}
@@ -516,8 +516,10 @@ void ModuleRtpRtcpImpl::GetSendStreamDataCounters(
// Received RTCP report.
+void ModuleRtpRtcpImpl::RemoteRTCPSenderInfo(uint32_t* packet_count,
+ uint32_t* octet_count) const {
+ return rtcp_receiver_.RemoteRTCPSenderInfo(packet_count, octet_count);
+}
+
void ModuleRtpRtcpImpl::RemoteRTCPSenderInfo(uint32_t* packet_count,
- uint32_t* octet_count) const {
- return rtcp_receiver_.RemoteRTCPSenderInfo(packet_count, octet_count);
+ uint32_t* octet_count,
+ int64_t* ntp_timestamp_ms) const {
+ return rtcp_receiver_.RemoteRTCPSenderInfo(packet_count, octet_count,
+ ntp_timestamp_ms);
}
std::vector<ReportBlockData> ModuleRtpRtcpImpl::GetLatestReportBlockData()
const {
return rtcp_receiver_.GetLatestReportBlockData();
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.h b/modules/rtp_rtcp/source/rtp_rtcp_impl.h
index 94035ddb02..446882ea67 100644
index 446882ea67..2ad73523db 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.h
@@ -203,6 +203,9 @@ class ABSL_DEPRECATED("") ModuleRtpRtcpImpl
StreamDataCounters* rtp_counters,
@@ -204,7 +204,8 @@ class ABSL_DEPRECATED("") ModuleRtpRtcpImpl
StreamDataCounters* rtx_counters) const override;
+ void RemoteRTCPSenderInfo(uint32_t* packet_count,
+ uint32_t* octet_count) const override;
+
void RemoteRTCPSenderInfo(uint32_t* packet_count,
- uint32_t* octet_count) const override;
+ uint32_t* octet_count,
+ int64_t* ntp_timestamp_ms) const override;
// A snapshot of the most recent Report Block with additional data of
// interest to statistics. Used to implement RTCRemoteInboundRtpStreamStats.
// Within this list, the `ReportBlockData::source_ssrc()`, which is the SSRC
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
index fe21008cf1..dbf523dee7 100644
index dbf523dee7..32258b9c2b 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
@@ -526,6 +526,11 @@ void ModuleRtpRtcpImpl2::GetSendStreamDataCounters(
}
@@ -527,8 +527,10 @@ void ModuleRtpRtcpImpl2::GetSendStreamDataCounters(
// Received RTCP report.
+void ModuleRtpRtcpImpl2::RemoteRTCPSenderInfo(uint32_t* packet_count,
+ uint32_t* octet_count) const {
+ return rtcp_receiver_.RemoteRTCPSenderInfo(packet_count, octet_count);
+}
+
void ModuleRtpRtcpImpl2::RemoteRTCPSenderInfo(uint32_t* packet_count,
- uint32_t* octet_count) const {
- return rtcp_receiver_.RemoteRTCPSenderInfo(packet_count, octet_count);
+ uint32_t* octet_count,
+ int64_t* ntp_timestamp_ms) const {
+ return rtcp_receiver_.RemoteRTCPSenderInfo(packet_count, octet_count,
+ ntp_timestamp_ms);
}
std::vector<ReportBlockData> ModuleRtpRtcpImpl2::GetLatestReportBlockData()
const {
return rtcp_receiver_.GetLatestReportBlockData();
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
index 57139e2242..1b2afac61f 100644
index 1b2afac61f..625ec14c8d 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
@@ -198,6 +198,9 @@ class ModuleRtpRtcpImpl2 final : public RtpRtcpInterface,
StreamDataCounters* rtp_counters,
@@ -199,7 +199,8 @@ class ModuleRtpRtcpImpl2 final : public RtpRtcpInterface,
StreamDataCounters* rtx_counters) const override;
+ void RemoteRTCPSenderInfo(uint32_t* packet_count,
+ uint32_t* octet_count) const override;
+
void RemoteRTCPSenderInfo(uint32_t* packet_count,
- uint32_t* octet_count) const override;
+ uint32_t* octet_count,
+ int64_t* ntp_timestamp_ms) const override;
// A snapshot of the most recent Report Block with additional data of
// interest to statistics. Used to implement RTCRemoteInboundRtpStreamStats.
// Within this list, the `ReportBlockData::source_ssrc()`, which is the SSRC
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_interface.h b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
index dd34cf7e3e..377f1c27d7 100644
index 377f1c27d7..8ee991330f 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_interface.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
@@ -399,6 +399,10 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface {
StreamDataCounters* rtp_counters,
@@ -400,9 +400,10 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface {
StreamDataCounters* rtx_counters) const = 0;
+
+ // Returns packet count and octet count from RTCP sender report.
+ virtual void RemoteRTCPSenderInfo(uint32_t* packet_count,
+ uint32_t* octet_count) const = 0;
- // Returns packet count and octet count from RTCP sender report.
+ // Returns packet count, octet count, and timestamp from RTCP sender report.
virtual void RemoteRTCPSenderInfo(uint32_t* packet_count,
- uint32_t* octet_count) const = 0;
+ uint32_t* octet_count,
+ int64_t* ntp_timestamp_ms) const = 0;
// A snapshot of Report Blocks with additional data of interest to statistics.
// Within this list, the sender-source SSRC pair is unique and per-pair the
// ReportBlockData represents the latest Report Block that was received for

View File

@ -1,145 +1,65 @@
From: Nico Grunbaum <na-g@nostrum.com>
Date: Fri, 5 Jun 2020 11:41:00 +0000
Subject: Bug 1615191 - P0 - implement remoteTimestamp for
RTCRemoteOutboundRtpStreamStats in libwebrtc;r=dminor
From: Dan Minor <dminor@mozilla.com>
Date: Tue, 31 Jul 2018 13:32:00 -0400
Subject: Bug 1376873 - OS X desktop capture fixes; r=pehrsons
Differential Revision: https://phabricator.services.mozilla.com/D78004
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/cd901e96d23e004e4bee19b96c8c2f1ca3b42830
This patch also absorbs two additional patches that collapse into using ms for the remote timestamp:
Bug 1654112 - Plumb RemoteRTCPSenderInfo through also for audio and change unit to ms. r=ng
Bug 1654112 - Replace custom upstream code for remote received audio stats with cherry-pick. r=ng
Differential Revision: https://phabricator.services.mozilla.com/D7464
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/02c038eca65c1218b56fdf8937fdeab3d8767fe6
---
call/video_receive_stream.h | 1 +
modules/rtp_rtcp/source/rtcp_receiver.cc | 4 +++-
modules/rtp_rtcp/source/rtcp_receiver.h | 3 ++-
modules/rtp_rtcp/source/rtp_rtcp_impl.cc | 6 ++++--
modules/rtp_rtcp/source/rtp_rtcp_impl.h | 3 ++-
modules/rtp_rtcp/source/rtp_rtcp_impl2.cc | 6 ++++--
modules/rtp_rtcp/source/rtp_rtcp_impl2.h | 3 ++-
modules/rtp_rtcp/source/rtp_rtcp_interface.h | 5 +++--
8 files changed, 21 insertions(+), 10 deletions(-)
modules/desktop_capture/mac/screen_capturer_mac.h | 7 +++++++
modules/desktop_capture/mac/screen_capturer_mac.mm | 4 +++-
modules/desktop_capture/mouse_cursor_monitor_mac.mm | 2 +-
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index 8b8caba840..f69b03a166 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -171,6 +171,7 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
diff --git a/modules/desktop_capture/mac/screen_capturer_mac.h b/modules/desktop_capture/mac/screen_capturer_mac.h
index 7e38b5bd08..e4a2cc2fc9 100644
--- a/modules/desktop_capture/mac/screen_capturer_mac.h
+++ b/modules/desktop_capture/mac/screen_capturer_mac.h
@@ -113,6 +113,13 @@ class ScreenCapturerMac final : public DesktopCapturer {
uint32_t rtcp_sender_packets_sent;
uint32_t rtcp_sender_octets_sent;
+ int64_t rtcp_sender_ntp_timestamp_ms;
// Start, CaptureFrame and destructor have to called in the same thread.
SequenceChecker thread_checker_;
+
+ // Used to force CaptureFrame to update it's screen configuration
+ // and reregister event handlers. This ensure that this
+ // occurs on the ScreenCapture thread. Read and written from
+ // both the VideoCapture thread and ScreenCapture thread.
+ // Protected by desktop_config_monitor_.
+ bool update_screen_configuration_ = false;
};
// Timing frame info: all important timestamps for a full lifetime of a
// single 'timing frame'.
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc
index 959b5d1dce..85c892767d 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.cc
+++ b/modules/rtp_rtcp/source/rtcp_receiver.cc
@@ -388,10 +388,12 @@ RTCPReceiver::ConsumeReceivedXrReferenceTimeInfo() {
}
} // namespace webrtc
diff --git a/modules/desktop_capture/mac/screen_capturer_mac.mm b/modules/desktop_capture/mac/screen_capturer_mac.mm
index e6746578ad..3b4edd230b 100644
--- a/modules/desktop_capture/mac/screen_capturer_mac.mm
+++ b/modules/desktop_capture/mac/screen_capturer_mac.mm
@@ -185,6 +185,7 @@ void ScreenCapturerMac::Start(Callback* callback) {
current_display_);
void RTCPReceiver::RemoteRTCPSenderInfo(uint32_t* packet_count,
- uint32_t* octet_count) const {
+ uint32_t* octet_count,
+ int64_t* ntp_timestamp_ms) const {
MutexLock lock(&rtcp_receiver_lock_);
*packet_count = remote_sender_packet_count_;
*octet_count = remote_sender_octet_count_;
+ *ntp_timestamp_ms = remote_sender_ntp_time_.ToMs();
}
callback_ = callback;
+ update_screen_configuration_ = false;
// Start and operate CGDisplayStream handler all from capture thread.
if (!RegisterRefreshAndMoveHandlers()) {
RTC_LOG(LS_ERROR) << "Failed to register refresh and move handlers.";
@@ -205,7 +206,8 @@ void ScreenCapturerMac::CaptureFrame() {
}
std::vector<ReportBlockData> RTCPReceiver::GetLatestReportBlockData() const {
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.h b/modules/rtp_rtcp/source/rtcp_receiver.h
index 2551534b9f..029fc3a5e2 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.h
+++ b/modules/rtp_rtcp/source/rtcp_receiver.h
@@ -125,7 +125,8 @@ class RTCPReceiver final {
MacDesktopConfiguration new_config = desktop_config_monitor_->desktop_configuration();
- if (!desktop_config_.Equals(new_config)) {
+ if (update_screen_configuration_ || !desktop_config_.Equals(new_config)) {
+ update_screen_configuration_ = false;
desktop_config_ = new_config;
// If the display configuraiton has changed then refresh capturer data
// structures. Occasionally, the refresh and move handlers are lost when
diff --git a/modules/desktop_capture/mouse_cursor_monitor_mac.mm b/modules/desktop_capture/mouse_cursor_monitor_mac.mm
index 3db4332cd1..512103ab5e 100644
--- a/modules/desktop_capture/mouse_cursor_monitor_mac.mm
+++ b/modules/desktop_capture/mouse_cursor_monitor_mac.mm
@@ -133,7 +133,7 @@ void MouseCursorMonitorMac::CaptureImage(float scale) {
NSSize nssize = [nsimage size]; // DIP size
// Get received sender packet and octet counts
void RemoteRTCPSenderInfo(uint32_t* packet_count,
- uint32_t* octet_count) const;
+ uint32_t* octet_count,
+ int64_t* ntp_timestamp_ms) const;
// No need to caputre cursor image if it's unchanged since last capture.
- if ([[nsimage TIFFRepresentation] isEqual:[last_cursor_ TIFFRepresentation]]) return;
+ if (last_cursor_ && [[nsimage TIFFRepresentation] isEqual:[last_cursor_ TIFFRepresentation]]) return;
last_cursor_ = nsimage;
std::optional<TimeDelta> AverageRtt() const;
std::optional<TimeDelta> LastRtt() const;
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
index eb39112671..69b6636d3a 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
@@ -516,8 +516,10 @@ void ModuleRtpRtcpImpl::GetSendStreamDataCounters(
// Received RTCP report.
void ModuleRtpRtcpImpl::RemoteRTCPSenderInfo(uint32_t* packet_count,
- uint32_t* octet_count) const {
- return rtcp_receiver_.RemoteRTCPSenderInfo(packet_count, octet_count);
+ uint32_t* octet_count,
+ int64_t* ntp_timestamp_ms) const {
+ return rtcp_receiver_.RemoteRTCPSenderInfo(packet_count, octet_count,
+ ntp_timestamp_ms);
}
std::vector<ReportBlockData> ModuleRtpRtcpImpl::GetLatestReportBlockData()
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.h b/modules/rtp_rtcp/source/rtp_rtcp_impl.h
index 446882ea67..2ad73523db 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.h
@@ -204,7 +204,8 @@ class ABSL_DEPRECATED("") ModuleRtpRtcpImpl
StreamDataCounters* rtx_counters) const override;
void RemoteRTCPSenderInfo(uint32_t* packet_count,
- uint32_t* octet_count) const override;
+ uint32_t* octet_count,
+ int64_t* ntp_timestamp_ms) const override;
// A snapshot of the most recent Report Block with additional data of
// interest to statistics. Used to implement RTCRemoteInboundRtpStreamStats.
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
index dbf523dee7..32258b9c2b 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
@@ -527,8 +527,10 @@ void ModuleRtpRtcpImpl2::GetSendStreamDataCounters(
// Received RTCP report.
void ModuleRtpRtcpImpl2::RemoteRTCPSenderInfo(uint32_t* packet_count,
- uint32_t* octet_count) const {
- return rtcp_receiver_.RemoteRTCPSenderInfo(packet_count, octet_count);
+ uint32_t* octet_count,
+ int64_t* ntp_timestamp_ms) const {
+ return rtcp_receiver_.RemoteRTCPSenderInfo(packet_count, octet_count,
+ ntp_timestamp_ms);
}
std::vector<ReportBlockData> ModuleRtpRtcpImpl2::GetLatestReportBlockData()
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
index 1b2afac61f..625ec14c8d 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
@@ -199,7 +199,8 @@ class ModuleRtpRtcpImpl2 final : public RtpRtcpInterface,
StreamDataCounters* rtx_counters) const override;
void RemoteRTCPSenderInfo(uint32_t* packet_count,
- uint32_t* octet_count) const override;
+ uint32_t* octet_count,
+ int64_t* ntp_timestamp_ms) const override;
// A snapshot of the most recent Report Block with additional data of
// interest to statistics. Used to implement RTCRemoteInboundRtpStreamStats.
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_interface.h b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
index 377f1c27d7..8ee991330f 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_interface.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
@@ -400,9 +400,10 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface {
StreamDataCounters* rtx_counters) const = 0;
- // Returns packet count and octet count from RTCP sender report.
+ // Returns packet count, octet count, and timestamp from RTCP sender report.
virtual void RemoteRTCPSenderInfo(uint32_t* packet_count,
- uint32_t* octet_count) const = 0;
+ uint32_t* octet_count,
+ int64_t* ntp_timestamp_ms) const = 0;
// A snapshot of Report Blocks with additional data of interest to statistics.
// Within this list, the sender-source SSRC pair is unique and per-pair the
// ReportBlockData represents the latest Report Block that was received for
DesktopSize size(round(nssize.width * scale),

View File

@ -1,65 +1,53 @@
From: Dan Minor <dminor@mozilla.com>
Date: Tue, 31 Jul 2018 13:32:00 -0400
Subject: Bug 1376873 - OS X desktop capture fixes; r=pehrsons
From: "Byron Campen [:bwc]" <docfaraday@gmail.com>
Date: Fri, 12 Feb 2021 14:27:00 +0000
Subject: Bug 1654112 - Get OS X build working.
r=ng,firefox-build-system-reviewers,glandium
Differential Revision: https://phabricator.services.mozilla.com/D7464
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/02c038eca65c1218b56fdf8937fdeab3d8767fe6
* Pull in sdk/objc/base and sdk/objc/helpers
* Add gclient_args.gni to keep build happy.
* Add a missing include path for libyuv
* Support .m files in build.
Differential Revision: https://phabricator.services.mozilla.com/D105015
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/9314046d89ebc0836a50ab7addece71abbf0b5e4
---
modules/desktop_capture/mac/screen_capturer_mac.h | 7 +++++++
modules/desktop_capture/mac/screen_capturer_mac.mm | 4 +++-
modules/desktop_capture/mouse_cursor_monitor_mac.mm | 2 +-
3 files changed, 11 insertions(+), 2 deletions(-)
modules/desktop_capture/mac/screen_capturer_mac.mm | 3 ++-
modules/desktop_capture/mac/window_list_utils.cc | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/modules/desktop_capture/mac/screen_capturer_mac.h b/modules/desktop_capture/mac/screen_capturer_mac.h
index 7e38b5bd08..e4a2cc2fc9 100644
--- a/modules/desktop_capture/mac/screen_capturer_mac.h
+++ b/modules/desktop_capture/mac/screen_capturer_mac.h
@@ -113,6 +113,13 @@ class ScreenCapturerMac final : public DesktopCapturer {
// Start, CaptureFrame and destructor have to called in the same thread.
SequenceChecker thread_checker_;
+
+ // Used to force CaptureFrame to update it's screen configuration
+ // and reregister event handlers. This ensure that this
+ // occurs on the ScreenCapture thread. Read and written from
+ // both the VideoCapture thread and ScreenCapture thread.
+ // Protected by desktop_config_monitor_.
+ bool update_screen_configuration_ = false;
};
} // namespace webrtc
diff --git a/modules/desktop_capture/mac/screen_capturer_mac.mm b/modules/desktop_capture/mac/screen_capturer_mac.mm
index e6746578ad..3b4edd230b 100644
index 3b4edd230b..c734d72c75 100644
--- a/modules/desktop_capture/mac/screen_capturer_mac.mm
+++ b/modules/desktop_capture/mac/screen_capturer_mac.mm
@@ -185,6 +185,7 @@ void ScreenCapturerMac::Start(Callback* callback) {
current_display_);
callback_ = callback;
+ update_screen_configuration_ = false;
// Start and operate CGDisplayStream handler all from capture thread.
if (!RegisterRefreshAndMoveHandlers()) {
RTC_LOG(LS_ERROR) << "Failed to register refresh and move handlers.";
@@ -205,7 +206,8 @@ void ScreenCapturerMac::CaptureFrame() {
@@ -279,7 +279,8 @@ bool ScreenCapturerMac::GetSourceList(SourceList* screens) {
for (MacDisplayConfigurations::iterator it = desktop_config_.displays.begin();
it != desktop_config_.displays.end();
++it) {
- screens->push_back({it->id, std::string()});
+ Source value = {it->id, 0, std::string()};
+ screens->push_back(value);
}
MacDesktopConfiguration new_config = desktop_config_monitor_->desktop_configuration();
- if (!desktop_config_.Equals(new_config)) {
+ if (update_screen_configuration_ || !desktop_config_.Equals(new_config)) {
+ update_screen_configuration_ = false;
desktop_config_ = new_config;
// If the display configuraiton has changed then refresh capturer data
// structures. Occasionally, the refresh and move handlers are lost when
diff --git a/modules/desktop_capture/mouse_cursor_monitor_mac.mm b/modules/desktop_capture/mouse_cursor_monitor_mac.mm
index 3db4332cd1..512103ab5e 100644
--- a/modules/desktop_capture/mouse_cursor_monitor_mac.mm
+++ b/modules/desktop_capture/mouse_cursor_monitor_mac.mm
@@ -133,7 +133,7 @@ void MouseCursorMonitorMac::CaptureImage(float scale) {
NSSize nssize = [nsimage size]; // DIP size
// No need to caputre cursor image if it's unchanged since last capture.
- if ([[nsimage TIFFRepresentation] isEqual:[last_cursor_ TIFFRepresentation]]) return;
+ if (last_cursor_ && [[nsimage TIFFRepresentation] isEqual:[last_cursor_ TIFFRepresentation]]) return;
last_cursor_ = nsimage;
DesktopSize size(round(nssize.width * scale),
return true;
}
diff --git a/modules/desktop_capture/mac/window_list_utils.cc b/modules/desktop_capture/mac/window_list_utils.cc
index 5d881662ea..989ec7ea54 100644
--- a/modules/desktop_capture/mac/window_list_utils.cc
+++ b/modules/desktop_capture/mac/window_list_utils.cc
@@ -198,7 +198,7 @@ bool GetWindowList(DesktopCapturer::SourceList* windows,
// the check in the map. Also skip the window if owner name is
// empty too.
if (!owner_name.empty() && (itr == pid_itr_map.end())) {
- sources.push_back(DesktopCapturer::Source{window_id, owner_name});
+ sources.push_back(DesktopCapturer::Source{window_id, pid, owner_name});
RTC_DCHECK(!sources.empty());
// Get an iterator on the last valid element in the source list.
std::list<DesktopCapturer::Source>::const_iterator last_source =
@@ -209,7 +209,7 @@ bool GetWindowList(DesktopCapturer::SourceList* windows,
pid, last_source));
}
} else {
- sources.push_back(DesktopCapturer::Source{window_id, title});
+ sources.push_back(DesktopCapturer::Source{window_id, pid, title});
// Once the window with empty title has been removed no other empty
// windows are allowed for the same pid.
if (itr != pid_itr_map.end() && (itr->second != sources.end())) {

View File

@ -1,53 +1,23 @@
From: "Byron Campen [:bwc]" <docfaraday@gmail.com>
Date: Fri, 12 Feb 2021 14:27:00 +0000
Subject: Bug 1654112 - Get OS X build working.
r=ng,firefox-build-system-reviewers,glandium
From: Dan Minor <dminor@mozilla.com>
Date: Mon, 13 Aug 2018 08:34:00 -0400
Subject: Bug 1376873 - Allow single channel opus; r=padenot
* Pull in sdk/objc/base and sdk/objc/helpers
* Add gclient_args.gni to keep build happy.
* Add a missing include path for libyuv
* Support .m files in build.
Differential Revision: https://phabricator.services.mozilla.com/D105015
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/9314046d89ebc0836a50ab7addece71abbf0b5e4
Differential Revision: https://phabricator.services.mozilla.com/D7469
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/92a7c3eee9f0c80ffbf79fdab8f8f2b8f6bd7701
---
modules/desktop_capture/mac/screen_capturer_mac.mm | 3 ++-
modules/desktop_capture/mac/window_list_utils.cc | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)
modules/audio_coding/codecs/opus/audio_encoder_opus.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/desktop_capture/mac/screen_capturer_mac.mm b/modules/desktop_capture/mac/screen_capturer_mac.mm
index 3b4edd230b..c734d72c75 100644
--- a/modules/desktop_capture/mac/screen_capturer_mac.mm
+++ b/modules/desktop_capture/mac/screen_capturer_mac.mm
@@ -279,7 +279,8 @@ bool ScreenCapturerMac::GetSourceList(SourceList* screens) {
for (MacDisplayConfigurations::iterator it = desktop_config_.displays.begin();
it != desktop_config_.displays.end();
++it) {
- screens->push_back({it->id, std::string()});
+ Source value = {it->id, 0, std::string()};
+ screens->push_back(value);
diff --git a/modules/audio_coding/codecs/opus/audio_encoder_opus.cc b/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
index 288ee84a4c..fb1d700deb 100644
--- a/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
+++ b/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
@@ -231,7 +231,7 @@ AudioCodecInfo AudioEncoderOpusImpl::QueryAudioEncoder(
std::optional<AudioEncoderOpusConfig> AudioEncoderOpusImpl::SdpToConfig(
const SdpAudioFormat& format) {
if (!absl::EqualsIgnoreCase(format.name, "opus") ||
- format.clockrate_hz != kRtpTimestampRateHz || format.num_channels != 2) {
+ format.clockrate_hz != kRtpTimestampRateHz) {
return std::nullopt;
}
return true;
}
diff --git a/modules/desktop_capture/mac/window_list_utils.cc b/modules/desktop_capture/mac/window_list_utils.cc
index 5d881662ea..989ec7ea54 100644
--- a/modules/desktop_capture/mac/window_list_utils.cc
+++ b/modules/desktop_capture/mac/window_list_utils.cc
@@ -198,7 +198,7 @@ bool GetWindowList(DesktopCapturer::SourceList* windows,
// the check in the map. Also skip the window if owner name is
// empty too.
if (!owner_name.empty() && (itr == pid_itr_map.end())) {
- sources.push_back(DesktopCapturer::Source{window_id, owner_name});
+ sources.push_back(DesktopCapturer::Source{window_id, pid, owner_name});
RTC_DCHECK(!sources.empty());
// Get an iterator on the last valid element in the source list.
std::list<DesktopCapturer::Source>::const_iterator last_source =
@@ -209,7 +209,7 @@ bool GetWindowList(DesktopCapturer::SourceList* windows,
pid, last_source));
}
} else {
- sources.push_back(DesktopCapturer::Source{window_id, title});
+ sources.push_back(DesktopCapturer::Source{window_id, pid, title});
// Once the window with empty title has been removed no other empty
// windows are allowed for the same pid.
if (itr != pid_itr_map.end() && (itr->second != sources.end())) {

View File

@ -1,23 +1,42 @@
From: Dan Minor <dminor@mozilla.com>
Date: Mon, 13 Aug 2018 08:34:00 -0400
Subject: Bug 1376873 - Allow single channel opus; r=padenot
Date: Wed, 19 Sep 2018 15:06:00 -0400
Subject: Bug 1376873 - Fix up rotation in video_capture_impl.cc; r=pehrsons
Differential Revision: https://phabricator.services.mozilla.com/D7469
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/92a7c3eee9f0c80ffbf79fdab8f8f2b8f6bd7701
This fixes a bug in the upstream code introduced when they removed the
ConvertToI420 helper method from webrtc_libyuv.cc. The buffer size is
passed into libyuv::ConvertI420 incorrectly when rotation is applied, which
causes bad rendering and instabilities.
Differential Revision: https://phabricator.services.mozilla.com/D7478
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c56cb66f86518dfb046c642ebeb07cf51c23a3cb
---
modules/audio_coding/codecs/opus/audio_encoder_opus.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
modules/video_capture/video_capture_impl.cc | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/modules/audio_coding/codecs/opus/audio_encoder_opus.cc b/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
index 288ee84a4c..fb1d700deb 100644
--- a/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
+++ b/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
@@ -231,7 +231,7 @@ AudioCodecInfo AudioEncoderOpusImpl::QueryAudioEncoder(
std::optional<AudioEncoderOpusConfig> AudioEncoderOpusImpl::SdpToConfig(
const SdpAudioFormat& format) {
if (!absl::EqualsIgnoreCase(format.name, "opus") ||
- format.clockrate_hz != kRtpTimestampRateHz || format.num_channels != 2) {
+ format.clockrate_hz != kRtpTimestampRateHz) {
return std::nullopt;
diff --git a/modules/video_capture/video_capture_impl.cc b/modules/video_capture/video_capture_impl.cc
index 51282183f5..afd6ba4d0a 100644
--- a/modules/video_capture/video_capture_impl.cc
+++ b/modules/video_capture/video_capture_impl.cc
@@ -218,12 +218,21 @@ int32_t VideoCaptureImpl::IncomingFrame(uint8_t* videoFrame,
}
}
+ int dst_width = buffer->width();
+ int dst_height = buffer->height();
+
+ // LibYuv expects pre-rotation_mode values for dst.
+ // Stride values should correspond to the destination values.
+ if (rotation_mode == libyuv::kRotate90 || rotation_mode == libyuv::kRotate270) {
+ std::swap(dst_width, dst_height);
+ }
+
const int conversionResult = libyuv::ConvertToI420(
videoFrame, videoFrameLength, buffer.get()->MutableDataY(),
buffer.get()->StrideY(), buffer.get()->MutableDataU(),
buffer.get()->StrideU(), buffer.get()->MutableDataV(),
buffer.get()->StrideV(), 0, 0, // No Cropping
- width, height, target_width, target_height, rotation_mode,
+ width, height, dst_width, dst_height, rotation_mode,
ConvertVideoType(frameInfo.videoType));
if (conversionResult != 0) {
RTC_LOG(LS_ERROR) << "Failed to convert capture frame from type "

View File

@ -1,42 +1,150 @@
From: Dan Minor <dminor@mozilla.com>
Date: Wed, 19 Sep 2018 15:06:00 -0400
Subject: Bug 1376873 - Fix up rotation in video_capture_impl.cc; r=pehrsons
From: Jan Beich <jbeich@FreeBSD.org>
Date: Fri, 12 Oct 2018 12:56:00 -0400
Subject: Bug 1376873 - Unbreak WebRTC 64 build on BSDs. r=dminor f=gaston
This fixes a bug in the upstream code introduced when they removed the
ConvertToI420 helper method from webrtc_libyuv.cc. The buffer size is
passed into libyuv::ConvertI420 incorrectly when rotation is applied, which
causes bad rendering and instabilities.
Also includes:
Bug 1554949 - Fix WebRTC build failure with newer linux kernel. r=dminor
Differential Revision: https://phabricator.services.mozilla.com/D7478
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c56cb66f86518dfb046c642ebeb07cf51c23a3cb
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a636ecdcb91afb1c5d436bbcbd87da4f10f7df78
---
modules/video_capture/video_capture_impl.cc | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
modules/video_capture/linux/device_info_linux.cc | 6 ++++++
modules/video_capture/linux/device_info_v4l2.cc | 8 +++++++-
modules/video_capture/linux/video_capture_linux.cc | 9 ++++++++-
rtc_base/byte_order.h | 2 ++
rtc_base/physical_socket_server.cc | 7 +++++--
system_wrappers/source/cpu_info.cc | 4 ++--
6 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/modules/video_capture/video_capture_impl.cc b/modules/video_capture/video_capture_impl.cc
index 51282183f5..afd6ba4d0a 100644
--- a/modules/video_capture/video_capture_impl.cc
+++ b/modules/video_capture/video_capture_impl.cc
@@ -218,12 +218,21 @@ int32_t VideoCaptureImpl::IncomingFrame(uint8_t* videoFrame,
}
}
diff --git a/modules/video_capture/linux/device_info_linux.cc b/modules/video_capture/linux/device_info_linux.cc
index 4f8b7c059b..56da475bf3 100644
--- a/modules/video_capture/linux/device_info_linux.cc
+++ b/modules/video_capture/linux/device_info_linux.cc
@@ -16,7 +16,13 @@
#include <sys/ioctl.h>
#include <unistd.h>
// v4l includes
+#if defined(__NetBSD__) || defined(__OpenBSD__) // WEBRTC_BSD
+#include <sys/videoio.h>
+#elif defined(__sun)
+#include <sys/videodev2.h>
+#else
#include <linux/videodev2.h>
+#endif
+ int dst_width = buffer->width();
+ int dst_height = buffer->height();
+
+ // LibYuv expects pre-rotation_mode values for dst.
+ // Stride values should correspond to the destination values.
+ if (rotation_mode == libyuv::kRotate90 || rotation_mode == libyuv::kRotate270) {
+ std::swap(dst_width, dst_height);
+ }
+
const int conversionResult = libyuv::ConvertToI420(
videoFrame, videoFrameLength, buffer.get()->MutableDataY(),
buffer.get()->StrideY(), buffer.get()->MutableDataU(),
buffer.get()->StrideU(), buffer.get()->MutableDataV(),
buffer.get()->StrideV(), 0, 0, // No Cropping
- width, height, target_width, target_height, rotation_mode,
+ width, height, dst_width, dst_height, rotation_mode,
ConvertVideoType(frameInfo.videoType));
if (conversionResult != 0) {
RTC_LOG(LS_ERROR) << "Failed to convert capture frame from type "
#include <vector>
diff --git a/modules/video_capture/linux/device_info_v4l2.cc b/modules/video_capture/linux/device_info_v4l2.cc
index 7397a10625..19b32f16b9 100644
--- a/modules/video_capture/linux/device_info_v4l2.cc
+++ b/modules/video_capture/linux/device_info_v4l2.cc
@@ -18,7 +18,13 @@
#include <sys/ioctl.h>
#include <unistd.h>
// v4l includes
+#if defined(__NetBSD__) || defined(__OpenBSD__) // WEBRTC_BSD
+#include <sys/videoio.h>
+#elif defined(__sun)
+#include <sys/videodev2.h>
+#else
#include <linux/videodev2.h>
+#endif
#include <vector>
@@ -209,8 +215,8 @@ DeviceInfoV4l2::DeviceInfoV4l2() : DeviceInfoImpl()
{
_inotifyEventThread->Start();
}
-}
#endif
+}
int32_t DeviceInfoV4l2::Init() {
return 0;
diff --git a/modules/video_capture/linux/video_capture_linux.cc b/modules/video_capture/linux/video_capture_linux.cc
index a2ea218a8b..23a8f4f3f3 100644
--- a/modules/video_capture/linux/video_capture_linux.cc
+++ b/modules/video_capture/linux/video_capture_linux.cc
@@ -10,7 +10,6 @@
#include <errno.h>
#include <fcntl.h>
-#include <linux/videodev2.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
@@ -18,6 +17,14 @@
#include <sys/select.h>
#include <time.h>
#include <unistd.h>
+// v4l includes
+#if defined(__NetBSD__) || defined(__OpenBSD__) // WEBRTC_BSD
+#include <sys/videoio.h>
+#elif defined(__sun)
+#include <sys/videodev2.h>
+#else
+#include <linux/videodev2.h>
+#endif
#include <new>
#include <string>
diff --git a/rtc_base/byte_order.h b/rtc_base/byte_order.h
index ed7c75996f..be49d1b9e1 100644
--- a/rtc_base/byte_order.h
+++ b/rtc_base/byte_order.h
@@ -90,6 +90,8 @@
#error WEBRTC_ARCH_BIG_ENDIAN or WEBRTC_ARCH_LITTLE_ENDIAN must be defined.
#endif // defined(WEBRTC_ARCH_LITTLE_ENDIAN)
+#elif defined(WEBRTC_BSD) && !defined(__OpenBSD__)
+#include <sys/endian.h>
#elif defined(WEBRTC_POSIX)
#include <endian.h>
#else
diff --git a/rtc_base/physical_socket_server.cc b/rtc_base/physical_socket_server.cc
index 71da31ecec..9b8584e74f 100644
--- a/rtc_base/physical_socket_server.cc
+++ b/rtc_base/physical_socket_server.cc
@@ -74,7 +74,10 @@ typedef void* SockOptArg;
#endif // WEBRTC_POSIX
-#if defined(WEBRTC_POSIX) && !defined(WEBRTC_MAC) && !defined(__native_client__)
+#if defined(WEBRTC_POSIX) && !defined(WEBRTC_MAC) && !defined(WEBRTC_BSD) && !defined(__native_client__)
+#if defined(WEBRTC_LINUX)
+#include <linux/sockios.h>
+#endif
int64_t GetSocketRecvTimestamp(int socket) {
struct timeval tv_ioctl;
@@ -697,7 +700,7 @@ int PhysicalSocket::TranslateOption(Option opt, int* slevel, int* sopt) {
*slevel = IPPROTO_IP;
*sopt = IP_DONTFRAGMENT;
break;
-#elif defined(WEBRTC_MAC) || defined(BSD) || defined(__native_client__)
+#elif defined(WEBRTC_MAC) || defined(WEBRTC_BSD) || defined(__native_client__)
RTC_LOG(LS_WARNING) << "Socket::OPT_DONTFRAGMENT not supported.";
return -1;
#elif defined(WEBRTC_POSIX)
diff --git a/system_wrappers/source/cpu_info.cc b/system_wrappers/source/cpu_info.cc
index eff720371a..94aed09c48 100644
--- a/system_wrappers/source/cpu_info.cc
+++ b/system_wrappers/source/cpu_info.cc
@@ -12,7 +12,7 @@
#if defined(WEBRTC_WIN)
#include <windows.h>
-#elif defined(WEBRTC_LINUX)
+#elif defined(WEBRTC_LINUX) || defined(WEBRTC_BSD)
#include <unistd.h>
#elif defined(WEBRTC_MAC)
#include <sys/sysctl.h>
@@ -30,7 +30,7 @@ static int DetectNumberOfCores() {
SYSTEM_INFO si;
GetNativeSystemInfo(&si);
number_of_cores = static_cast<int>(si.dwNumberOfProcessors);
-#elif defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID)
+#elif defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID) || defined(WEBRTC_BSD)
number_of_cores = static_cast<int>(sysconf(_SC_NPROCESSORS_ONLN));
if (number_of_cores <= 0) {
RTC_LOG(LS_ERROR) << "Failed to get number of cores";

View File

@ -1,150 +1,29 @@
From: Jan Beich <jbeich@FreeBSD.org>
Date: Fri, 12 Oct 2018 12:56:00 -0400
Subject: Bug 1376873 - Unbreak WebRTC 64 build on BSDs. r=dminor f=gaston
From: Jed Davis <jld@mozilla.com>
Date: Sun, 17 Nov 2019 03:40:00 +0000
Subject: Bug 1545504 - Strengthen bounds check in WebRTC PhysicalSocketServer.
r=jesup
Also includes:
Bug 1554949 - Fix WebRTC build failure with newer linux kernel. r=dminor
PhysicalSocketServer isn't currently used by Mozilla's WebRTC
integration, but just in case, let's make sure that this array index is
bounds-checked in actual use, not just in debug builds (which tend to
never see realistic test conditions).
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a636ecdcb91afb1c5d436bbcbd87da4f10f7df78
Differential Revision: https://phabricator.services.mozilla.com/D52745
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2b079067648bfe0d064a334bf19bdcc233e26b6e
---
modules/video_capture/linux/device_info_linux.cc | 6 ++++++
modules/video_capture/linux/device_info_v4l2.cc | 8 +++++++-
modules/video_capture/linux/video_capture_linux.cc | 9 ++++++++-
rtc_base/byte_order.h | 2 ++
rtc_base/physical_socket_server.cc | 7 +++++--
system_wrappers/source/cpu_info.cc | 4 ++--
6 files changed, 30 insertions(+), 6 deletions(-)
rtc_base/physical_socket_server.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/video_capture/linux/device_info_linux.cc b/modules/video_capture/linux/device_info_linux.cc
index 4f8b7c059b..56da475bf3 100644
--- a/modules/video_capture/linux/device_info_linux.cc
+++ b/modules/video_capture/linux/device_info_linux.cc
@@ -16,7 +16,13 @@
#include <sys/ioctl.h>
#include <unistd.h>
// v4l includes
+#if defined(__NetBSD__) || defined(__OpenBSD__) // WEBRTC_BSD
+#include <sys/videoio.h>
+#elif defined(__sun)
+#include <sys/videodev2.h>
+#else
#include <linux/videodev2.h>
+#endif
#include <vector>
diff --git a/modules/video_capture/linux/device_info_v4l2.cc b/modules/video_capture/linux/device_info_v4l2.cc
index 7397a10625..19b32f16b9 100644
--- a/modules/video_capture/linux/device_info_v4l2.cc
+++ b/modules/video_capture/linux/device_info_v4l2.cc
@@ -18,7 +18,13 @@
#include <sys/ioctl.h>
#include <unistd.h>
// v4l includes
+#if defined(__NetBSD__) || defined(__OpenBSD__) // WEBRTC_BSD
+#include <sys/videoio.h>
+#elif defined(__sun)
+#include <sys/videodev2.h>
+#else
#include <linux/videodev2.h>
+#endif
#include <vector>
@@ -209,8 +215,8 @@ DeviceInfoV4l2::DeviceInfoV4l2() : DeviceInfoImpl()
{
_inotifyEventThread->Start();
}
-}
#endif
+}
int32_t DeviceInfoV4l2::Init() {
return 0;
diff --git a/modules/video_capture/linux/video_capture_linux.cc b/modules/video_capture/linux/video_capture_linux.cc
index a2ea218a8b..23a8f4f3f3 100644
--- a/modules/video_capture/linux/video_capture_linux.cc
+++ b/modules/video_capture/linux/video_capture_linux.cc
@@ -10,7 +10,6 @@
#include <errno.h>
#include <fcntl.h>
-#include <linux/videodev2.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
@@ -18,6 +17,14 @@
#include <sys/select.h>
#include <time.h>
#include <unistd.h>
+// v4l includes
+#if defined(__NetBSD__) || defined(__OpenBSD__) // WEBRTC_BSD
+#include <sys/videoio.h>
+#elif defined(__sun)
+#include <sys/videodev2.h>
+#else
+#include <linux/videodev2.h>
+#endif
#include <new>
#include <string>
diff --git a/rtc_base/byte_order.h b/rtc_base/byte_order.h
index ed7c75996f..be49d1b9e1 100644
--- a/rtc_base/byte_order.h
+++ b/rtc_base/byte_order.h
@@ -90,6 +90,8 @@
#error WEBRTC_ARCH_BIG_ENDIAN or WEBRTC_ARCH_LITTLE_ENDIAN must be defined.
#endif // defined(WEBRTC_ARCH_LITTLE_ENDIAN)
+#elif defined(WEBRTC_BSD) && !defined(__OpenBSD__)
+#include <sys/endian.h>
#elif defined(WEBRTC_POSIX)
#include <endian.h>
#else
diff --git a/rtc_base/physical_socket_server.cc b/rtc_base/physical_socket_server.cc
index 71da31ecec..9b8584e74f 100644
index 9b8584e74f..5a75fbb707 100644
--- a/rtc_base/physical_socket_server.cc
+++ b/rtc_base/physical_socket_server.cc
@@ -74,7 +74,10 @@ typedef void* SockOptArg;
@@ -1548,7 +1548,7 @@ bool PhysicalSocketServer::WaitSelect(int cmsWait, bool process_io) {
int fd = pdispatcher->GetDescriptor();
// "select"ing a file descriptor that is equal to or larger than
// FD_SETSIZE will result in undefined behavior.
- RTC_DCHECK_LT(fd, FD_SETSIZE);
+ RTC_CHECK_LT(fd, FD_SETSIZE);
if (fd > fdmax)
fdmax = fd;
#endif // WEBRTC_POSIX
-#if defined(WEBRTC_POSIX) && !defined(WEBRTC_MAC) && !defined(__native_client__)
+#if defined(WEBRTC_POSIX) && !defined(WEBRTC_MAC) && !defined(WEBRTC_BSD) && !defined(__native_client__)
+#if defined(WEBRTC_LINUX)
+#include <linux/sockios.h>
+#endif
int64_t GetSocketRecvTimestamp(int socket) {
struct timeval tv_ioctl;
@@ -697,7 +700,7 @@ int PhysicalSocket::TranslateOption(Option opt, int* slevel, int* sopt) {
*slevel = IPPROTO_IP;
*sopt = IP_DONTFRAGMENT;
break;
-#elif defined(WEBRTC_MAC) || defined(BSD) || defined(__native_client__)
+#elif defined(WEBRTC_MAC) || defined(WEBRTC_BSD) || defined(__native_client__)
RTC_LOG(LS_WARNING) << "Socket::OPT_DONTFRAGMENT not supported.";
return -1;
#elif defined(WEBRTC_POSIX)
diff --git a/system_wrappers/source/cpu_info.cc b/system_wrappers/source/cpu_info.cc
index eff720371a..94aed09c48 100644
--- a/system_wrappers/source/cpu_info.cc
+++ b/system_wrappers/source/cpu_info.cc
@@ -12,7 +12,7 @@
#if defined(WEBRTC_WIN)
#include <windows.h>
-#elif defined(WEBRTC_LINUX)
+#elif defined(WEBRTC_LINUX) || defined(WEBRTC_BSD)
#include <unistd.h>
#elif defined(WEBRTC_MAC)
#include <sys/sysctl.h>
@@ -30,7 +30,7 @@ static int DetectNumberOfCores() {
SYSTEM_INFO si;
GetNativeSystemInfo(&si);
number_of_cores = static_cast<int>(si.dwNumberOfProcessors);
-#elif defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID)
+#elif defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID) || defined(WEBRTC_BSD)
number_of_cores = static_cast<int>(sysconf(_SC_NPROCESSORS_ONLN));
if (number_of_cores <= 0) {
RTC_LOG(LS_ERROR) << "Failed to get number of cores";

View File

@ -1,29 +1,46 @@
From: Jed Davis <jld@mozilla.com>
Date: Sun, 17 Nov 2019 03:40:00 +0000
Subject: Bug 1545504 - Strengthen bounds check in WebRTC PhysicalSocketServer.
r=jesup
From: Dan Minor <dminor@mozilla.com>
Date: Mon, 5 Nov 2018 10:33:00 -0500
Subject: Bug 1376873 - Reduce thread stack size in platform_thread.cc; r=bwc
PhysicalSocketServer isn't currently used by Mozilla's WebRTC
integration, but just in case, let's make sure that this array index is
bounds-checked in actual use, not just in debug builds (which tend to
never see realistic test conditions).
Summary:
The current default stack size of 1M results in intermittent OOMs on win32
builds while running web-platform tests. The value of 256k was chosen for
consistency with the default value used elsewhere in Gecko, which is defined in
nsIThreadManager.idl.
Differential Revision: https://phabricator.services.mozilla.com/D52745
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2b079067648bfe0d064a334bf19bdcc233e26b6e
Reviewers: bwc
Tags: #secure-revision
Bug #: 1376873
Differential Revision: https://phabricator.services.mozilla.com/D11090
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/e83c311e5293902be4db4ecea17cff87c633f7cf
---
rtc_base/physical_socket_server.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
rtc_base/platform_thread.cc | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/rtc_base/physical_socket_server.cc b/rtc_base/physical_socket_server.cc
index 9b8584e74f..5a75fbb707 100644
--- a/rtc_base/physical_socket_server.cc
+++ b/rtc_base/physical_socket_server.cc
@@ -1548,7 +1548,7 @@ bool PhysicalSocketServer::WaitSelect(int cmsWait, bool process_io) {
int fd = pdispatcher->GetDescriptor();
// "select"ing a file descriptor that is equal to or larger than
// FD_SETSIZE will result in undefined behavior.
- RTC_DCHECK_LT(fd, FD_SETSIZE);
+ RTC_CHECK_LT(fd, FD_SETSIZE);
if (fd > fdmax)
fdmax = fd;
diff --git a/rtc_base/platform_thread.cc b/rtc_base/platform_thread.cc
index 6af1f3f616..f75ce8c3dc 100644
--- a/rtc_base/platform_thread.cc
+++ b/rtc_base/platform_thread.cc
@@ -191,15 +191,17 @@ PlatformThread PlatformThread::SpawnThread(
// Set the reserved stack stack size to 1M, which is the default on Windows
// and Linux.
DWORD thread_id = 0;
+ // Mozilla: Set to 256kb for consistency with nsIThreadManager.idl
PlatformThread::Handle handle = ::CreateThread(
- nullptr, 1024 * 1024, &RunPlatformThread, start_thread_function_ptr,
+ nullptr, 256 * 1024, &RunPlatformThread, start_thread_function_ptr,
STACK_SIZE_PARAM_IS_A_RESERVATION, &thread_id);
RTC_CHECK(handle) << "CreateThread failed";
#else
pthread_attr_t attr;
pthread_attr_init(&attr);
// Set the stack stack size to 1M.
- pthread_attr_setstacksize(&attr, 1024 * 1024);
+ // Mozilla: Set to 256kb for consistency with nsIThreadManager.idl
+ pthread_attr_setstacksize(&attr, 256 * 1024);
pthread_attr_setdetachstate(
&attr, joinable ? PTHREAD_CREATE_JOINABLE : PTHREAD_CREATE_DETACHED);
PlatformThread::Handle handle;

View File

@ -1,46 +1,34 @@
From: Dan Minor <dminor@mozilla.com>
Date: Mon, 5 Nov 2018 10:33:00 -0500
Subject: Bug 1376873 - Reduce thread stack size in platform_thread.cc; r=bwc
Date: Thu, 31 Jan 2019 15:37:00 -0500
Subject: Bug 1524208 - Calculate stride based upon target_width in
video_capture_impl.cc; r=pehrsons
Summary:
The current default stack size of 1M results in intermittent OOMs on win32
builds while running web-platform tests. The value of 256k was chosen for
consistency with the default value used elsewhere in Gecko, which is defined in
nsIThreadManager.idl.
Reviewers: bwc
Tags: #secure-revision
Bug #: 1376873
Differential Revision: https://phabricator.services.mozilla.com/D11090
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/e83c311e5293902be4db4ecea17cff87c633f7cf
Differential Revision: https://phabricator.services.mozilla.com/D18270
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/51d12094d825c4c4467cb132d03d4f3cad4b1b82
---
rtc_base/platform_thread.cc | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
modules/video_capture/video_capture_impl.cc | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/rtc_base/platform_thread.cc b/rtc_base/platform_thread.cc
index 6af1f3f616..f75ce8c3dc 100644
--- a/rtc_base/platform_thread.cc
+++ b/rtc_base/platform_thread.cc
@@ -191,15 +191,17 @@ PlatformThread PlatformThread::SpawnThread(
// Set the reserved stack stack size to 1M, which is the default on Windows
// and Linux.
DWORD thread_id = 0;
+ // Mozilla: Set to 256kb for consistency with nsIThreadManager.idl
PlatformThread::Handle handle = ::CreateThread(
- nullptr, 1024 * 1024, &RunPlatformThread, start_thread_function_ptr,
+ nullptr, 256 * 1024, &RunPlatformThread, start_thread_function_ptr,
STACK_SIZE_PARAM_IS_A_RESERVATION, &thread_id);
RTC_CHECK(handle) << "CreateThread failed";
#else
pthread_attr_t attr;
pthread_attr_init(&attr);
// Set the stack stack size to 1M.
- pthread_attr_setstacksize(&attr, 1024 * 1024);
+ // Mozilla: Set to 256kb for consistency with nsIThreadManager.idl
+ pthread_attr_setstacksize(&attr, 256 * 1024);
pthread_attr_setdetachstate(
&attr, joinable ? PTHREAD_CREATE_JOINABLE : PTHREAD_CREATE_DETACHED);
PlatformThread::Handle handle;
diff --git a/modules/video_capture/video_capture_impl.cc b/modules/video_capture/video_capture_impl.cc
index afd6ba4d0a..1a12020b64 100644
--- a/modules/video_capture/video_capture_impl.cc
+++ b/modules/video_capture/video_capture_impl.cc
@@ -180,8 +180,6 @@ int32_t VideoCaptureImpl::IncomingFrame(uint8_t* videoFrame,
}
}
- int stride_y = width;
- int stride_uv = (width + 1) / 2;
int target_width = width;
int target_height = abs(height);
@@ -194,6 +192,9 @@ int32_t VideoCaptureImpl::IncomingFrame(uint8_t* videoFrame,
}
}
+ int stride_y = target_width;
+ int stride_uv = (target_width + 1) / 2;
+
// Setting absolute height (in case it was negative).
// In Windows, the image starts bottom left, instead of top left.
// Setting a negative source height, inverts the image (within LibYuv).

View File

@ -1,34 +1,44 @@
From: Dan Minor <dminor@mozilla.com>
Date: Thu, 31 Jan 2019 15:37:00 -0500
Subject: Bug 1524208 - Calculate stride based upon target_width in
video_capture_impl.cc; r=pehrsons
Date: Fri, 29 Mar 2019 18:43:00 +0000
Subject: Bug 1539220 - Prefer non-RGB24 capabilities when available;
r=pehrsons
Differential Revision: https://phabricator.services.mozilla.com/D18270
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/51d12094d825c4c4467cb132d03d4f3cad4b1b82
We've hit a number of problems with handling of RGB24 video capture on
Windows. This adds a check that will ignore any RGB24 capture capabilities
when determining a best match if there are other capabilities available to
workaround the problems.
Differential Revision: https://phabricator.services.mozilla.com/D25449
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c12307f3817bec87712ab5930493c3135c76b0a0
---
modules/video_capture/video_capture_impl.cc | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
modules/video_capture/device_info_impl.cc | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/modules/video_capture/video_capture_impl.cc b/modules/video_capture/video_capture_impl.cc
index afd6ba4d0a..1a12020b64 100644
--- a/modules/video_capture/video_capture_impl.cc
+++ b/modules/video_capture/video_capture_impl.cc
@@ -180,8 +180,6 @@ int32_t VideoCaptureImpl::IncomingFrame(uint8_t* videoFrame,
}
}
diff --git a/modules/video_capture/device_info_impl.cc b/modules/video_capture/device_info_impl.cc
index 7cccdb51a7..2a6afb3147 100644
--- a/modules/video_capture/device_info_impl.cc
+++ b/modules/video_capture/device_info_impl.cc
@@ -100,10 +100,23 @@ int32_t DeviceInfoImpl::GetBestMatchedCapability(
const int32_t numberOfCapabilies =
static_cast<int32_t>(_captureCapabilities.size());
- int stride_y = width;
- int stride_uv = (width + 1) / 2;
int target_width = width;
int target_height = abs(height);
@@ -194,6 +192,9 @@ int32_t VideoCaptureImpl::IncomingFrame(uint8_t* videoFrame,
}
}
+ int stride_y = target_width;
+ int stride_uv = (target_width + 1) / 2;
+ bool hasNonRGB24Capability = false;
for (int32_t tmp = 0; tmp < numberOfCapabilies;
++tmp) // Loop through all capabilities
{
VideoCaptureCapability& capability = _captureCapabilities[tmp];
+ if (capability.videoType != VideoType::kRGB24) {
+ hasNonRGB24Capability = true;
+ }
+ }
+
// Setting absolute height (in case it was negative).
// In Windows, the image starts bottom left, instead of top left.
// Setting a negative source height, inverts the image (within LibYuv).
+ for (int32_t tmp = 0; tmp < numberOfCapabilies;
+ ++tmp) // Loop through all capabilities
+ {
+ VideoCaptureCapability& capability = _captureCapabilities[tmp];
+ if (hasNonRGB24Capability && capability.videoType == VideoType::kRGB24) {
+ continue;
+ }
const int32_t diffWidth = capability.width - requested.width;
const int32_t diffHeight = capability.height - requested.height;

View File

@ -1,44 +1,93 @@
From: Dan Minor <dminor@mozilla.com>
Date: Fri, 29 Mar 2019 18:43:00 +0000
Subject: Bug 1539220 - Prefer non-RGB24 capabilities when available;
r=pehrsons
Date: Tue, 17 Sep 2019 06:47:00 +0000
Subject: Bug 1581193 - Fix devicechange event on Windows; r=achronop
We've hit a number of problems with handling of RGB24 video capture on
Windows. This adds a check that will ignore any RGB24 capture capabilities
when determining a best match if there are other capabilities available to
workaround the problems.
This restores the code for generating devicechange events that was
accidentally removed as part of updating the Windows video capture code
in Bug 1552755.
Differential Revision: https://phabricator.services.mozilla.com/D25449
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c12307f3817bec87712ab5930493c3135c76b0a0
Differential Revision: https://phabricator.services.mozilla.com/D46033
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/840c4edafa021eeac6a7e6ae0e828d0adcfea92e
---
modules/video_capture/device_info_impl.cc | 13 +++++++++++++
1 file changed, 13 insertions(+)
.../video_capture/windows/device_info_ds.cc | 39 +++++++++++++++++++
.../video_capture/windows/device_info_ds.h | 3 ++
2 files changed, 42 insertions(+)
diff --git a/modules/video_capture/device_info_impl.cc b/modules/video_capture/device_info_impl.cc
index 7cccdb51a7..2a6afb3147 100644
--- a/modules/video_capture/device_info_impl.cc
+++ b/modules/video_capture/device_info_impl.cc
@@ -100,10 +100,23 @@ int32_t DeviceInfoImpl::GetBestMatchedCapability(
const int32_t numberOfCapabilies =
static_cast<int32_t>(_captureCapabilities.size());
diff --git a/modules/video_capture/windows/device_info_ds.cc b/modules/video_capture/windows/device_info_ds.cc
index d0d274cb02..460ef3b7b9 100644
--- a/modules/video_capture/windows/device_info_ds.cc
+++ b/modules/video_capture/windows/device_info_ds.cc
@@ -20,6 +20,29 @@
namespace webrtc {
namespace videocapturemodule {
+ bool hasNonRGB24Capability = false;
for (int32_t tmp = 0; tmp < numberOfCapabilies;
++tmp) // Loop through all capabilities
{
VideoCaptureCapability& capability = _captureCapabilities[tmp];
+ if (capability.videoType != VideoType::kRGB24) {
+ hasNonRGB24Capability = true;
+LRESULT CALLBACK WndProc(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
+{
+ DeviceInfoDS* pParent;
+ if (uiMsg == WM_CREATE)
+ {
+ pParent = (DeviceInfoDS*)((LPCREATESTRUCT)lParam)->lpCreateParams;
+ SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)pParent);
+ }
+ }
+ else if (uiMsg == WM_DESTROY)
+ {
+ SetWindowLongPtr(hWnd, GWLP_USERDATA, NULL);
+ }
+ else if (uiMsg == WM_DEVICECHANGE)
+ {
+ pParent = (DeviceInfoDS*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
+ if (pParent)
+ {
+ pParent->DeviceChange();
+ }
+ }
+ return DefWindowProc(hWnd, uiMsg, wParam, lParam);
+}
+
+ for (int32_t tmp = 0; tmp < numberOfCapabilies;
+ ++tmp) // Loop through all capabilities
+ {
+ VideoCaptureCapability& capability = _captureCapabilities[tmp];
+ if (hasNonRGB24Capability && capability.videoType == VideoType::kRGB24) {
+ continue;
+ }
// static
DeviceInfoDS* DeviceInfoDS::Create() {
DeviceInfoDS* dsInfo = new DeviceInfoDS();
@@ -77,6 +100,18 @@ DeviceInfoDS::DeviceInfoDS()
<< rtc::ToHex(hr);
}
}
+
+ _hInstance = reinterpret_cast<HINSTANCE>(GetModuleHandle(NULL));
+ _wndClass = {0};
+ _wndClass.lpfnWndProc = &WndProc;
+ _wndClass.lpszClassName = TEXT("DeviceInfoDS");
+ _wndClass.hInstance = _hInstance;
+
+ if (RegisterClass(&_wndClass)) {
+ _hwnd = CreateWindow(_wndClass.lpszClassName, NULL, 0, CW_USEDEFAULT,
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL,
+ NULL, _hInstance, this);
+ }
}
const int32_t diffWidth = capability.width - requested.width;
const int32_t diffHeight = capability.height - requested.height;
DeviceInfoDS::~DeviceInfoDS() {
@@ -85,6 +120,10 @@ DeviceInfoDS::~DeviceInfoDS() {
if (_CoUninitializeIsRequired) {
CoUninitialize();
}
+ if (_hwnd != NULL) {
+ DestroyWindow(_hwnd);
+ }
+ UnregisterClass(_wndClass.lpszClassName, _hInstance);
}
int32_t DeviceInfoDS::Init() {
diff --git a/modules/video_capture/windows/device_info_ds.h b/modules/video_capture/windows/device_info_ds.h
index 1b52645cde..dc7b9b1a24 100644
--- a/modules/video_capture/windows/device_info_ds.h
+++ b/modules/video_capture/windows/device_info_ds.h
@@ -93,6 +93,9 @@ class DeviceInfoDS : public DeviceInfoImpl {
IEnumMoniker* _dsMonikerDevEnum;
bool _CoUninitializeIsRequired;
std::vector<VideoCaptureCapabilityWindows> _captureCapabilitiesWindows;
+ HWND _hwnd;
+ WNDCLASS _wndClass;
+ HINSTANCE _hInstance;
};
} // namespace videocapturemodule
} // namespace webrtc

View File

@ -1,93 +1,94 @@
From: Dan Minor <dminor@mozilla.com>
Date: Tue, 17 Sep 2019 06:47:00 +0000
Subject: Bug 1581193 - Fix devicechange event on Windows; r=achronop
From: Alex Chronopoulos <achronop@gmail.com>
Date: Tue, 17 Sep 2019 14:31:00 +0000
Subject: Bug 1581806 - Trigger devicechange event for audio and video input
devices only. r=dminor
This restores the code for generating devicechange events that was
accidentally removed as part of updating the Windows video capture code
in Bug 1552755.
After Bug 1581193 devicechange notifications were triggered with any device change, not just video and audio devices. This patch limits down the notifications to only video and audio input devices change.
Differential Revision: https://phabricator.services.mozilla.com/D46033
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/840c4edafa021eeac6a7e6ae0e828d0adcfea92e
Differential Revision: https://phabricator.services.mozilla.com/D46147
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/1feec83ee6f92a35de0d4b27ebea04e68a0d7ef0
---
.../video_capture/windows/device_info_ds.cc | 39 +++++++++++++++++++
.../video_capture/windows/device_info_ds.h | 3 ++
2 files changed, 42 insertions(+)
.../video_capture/windows/device_info_ds.cc | 29 +++++++++++++++++--
.../video_capture/windows/device_info_ds.h | 1 +
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/modules/video_capture/windows/device_info_ds.cc b/modules/video_capture/windows/device_info_ds.cc
index d0d274cb02..460ef3b7b9 100644
index 460ef3b7b9..a7eca19bbf 100644
--- a/modules/video_capture/windows/device_info_ds.cc
+++ b/modules/video_capture/windows/device_info_ds.cc
@@ -20,6 +20,29 @@
@@ -20,6 +20,18 @@
namespace webrtc {
namespace videocapturemodule {
+LRESULT CALLBACK WndProc(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
+BOOL isCaptureDevice(DEV_BROADCAST_HDR *pHdr)
+{
+ DeviceInfoDS* pParent;
+ if (uiMsg == WM_CREATE)
+ {
+ pParent = (DeviceInfoDS*)((LPCREATESTRUCT)lParam)->lpCreateParams;
+ SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)pParent);
+ }
+ else if (uiMsg == WM_DESTROY)
+ {
+ SetWindowLongPtr(hWnd, GWLP_USERDATA, NULL);
+ }
+ else if (uiMsg == WM_DEVICECHANGE)
+ {
+ pParent = (DeviceInfoDS*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
+ if (pParent)
+ {
+ pParent->DeviceChange();
+ }
+ }
+ return DefWindowProc(hWnd, uiMsg, wParam, lParam);
+ if (pHdr == NULL) {
+ return FALSE;
+ }
+ if (pHdr->dbch_devicetype != DBT_DEVTYP_DEVICEINTERFACE) {
+ return FALSE;
+ }
+ DEV_BROADCAST_DEVICEINTERFACE* pDi = (DEV_BROADCAST_DEVICEINTERFACE*)pHdr;
+ return pDi->dbcc_classguid == KSCATEGORY_CAPTURE;
+}
+
// static
DeviceInfoDS* DeviceInfoDS::Create() {
DeviceInfoDS* dsInfo = new DeviceInfoDS();
@@ -77,6 +100,18 @@ DeviceInfoDS::DeviceInfoDS()
<< rtc::ToHex(hr);
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
DeviceInfoDS* pParent;
@@ -35,7 +47,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
else if (uiMsg == WM_DEVICECHANGE)
{
pParent = (DeviceInfoDS*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
- if (pParent)
+ if (pParent && isCaptureDevice((PDEV_BROADCAST_HDR)lParam))
{
pParent->DeviceChange();
}
@@ -56,7 +68,8 @@ DeviceInfoDS* DeviceInfoDS::Create() {
DeviceInfoDS::DeviceInfoDS()
: _dsDevEnum(NULL),
_dsMonikerDevEnum(NULL),
- _CoUninitializeIsRequired(true) {
+ _CoUninitializeIsRequired(true),
+ _hdevnotify(NULL) {
// 1) Initialize the COM library (make Windows load the DLLs).
//
// CoInitializeEx must be called at least once, and is usually called only
@@ -111,6 +124,14 @@ DeviceInfoDS::DeviceInfoDS()
_hwnd = CreateWindow(_wndClass.lpszClassName, NULL, 0, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL,
NULL, _hInstance, this);
+
+ DEV_BROADCAST_DEVICEINTERFACE di = { 0 };
+ di.dbcc_size = sizeof(di);
+ di.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
+ di.dbcc_classguid = KSCATEGORY_CAPTURE;
+
+ _hdevnotify = RegisterDeviceNotification(_hwnd, &di,
+ DEVICE_NOTIFY_WINDOW_HANDLE);
}
+
+ _hInstance = reinterpret_cast<HINSTANCE>(GetModuleHandle(NULL));
+ _wndClass = {0};
+ _wndClass.lpfnWndProc = &WndProc;
+ _wndClass.lpszClassName = TEXT("DeviceInfoDS");
+ _wndClass.hInstance = _hInstance;
+
+ if (RegisterClass(&_wndClass)) {
+ _hwnd = CreateWindow(_wndClass.lpszClassName, NULL, 0, CW_USEDEFAULT,
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL,
+ NULL, _hInstance, this);
+ }
}
DeviceInfoDS::~DeviceInfoDS() {
@@ -85,6 +120,10 @@ DeviceInfoDS::~DeviceInfoDS() {
@@ -120,6 +141,10 @@ DeviceInfoDS::~DeviceInfoDS() {
if (_CoUninitializeIsRequired) {
CoUninitialize();
}
+ if (_hwnd != NULL) {
+ DestroyWindow(_hwnd);
+ if (_hdevnotify)
+ {
+ UnregisterDeviceNotification(_hdevnotify);
+ }
+ UnregisterClass(_wndClass.lpszClassName, _hInstance);
}
int32_t DeviceInfoDS::Init() {
if (_hwnd != NULL) {
DestroyWindow(_hwnd);
}
diff --git a/modules/video_capture/windows/device_info_ds.h b/modules/video_capture/windows/device_info_ds.h
index 1b52645cde..dc7b9b1a24 100644
index dc7b9b1a24..ed2a726d6f 100644
--- a/modules/video_capture/windows/device_info_ds.h
+++ b/modules/video_capture/windows/device_info_ds.h
@@ -93,6 +93,9 @@ class DeviceInfoDS : public DeviceInfoImpl {
IEnumMoniker* _dsMonikerDevEnum;
bool _CoUninitializeIsRequired;
std::vector<VideoCaptureCapabilityWindows> _captureCapabilitiesWindows;
+ HWND _hwnd;
+ WNDCLASS _wndClass;
+ HINSTANCE _hInstance;
@@ -96,6 +96,7 @@ class DeviceInfoDS : public DeviceInfoImpl {
HWND _hwnd;
WNDCLASS _wndClass;
HINSTANCE _hInstance;
+ HDEVNOTIFY _hdevnotify;
};
} // namespace videocapturemodule
} // namespace webrtc

View File

@ -1,94 +1,95 @@
From: Alex Chronopoulos <achronop@gmail.com>
Date: Tue, 17 Sep 2019 14:31:00 +0000
Subject: Bug 1581806 - Trigger devicechange event for audio and video input
devices only. r=dminor
Date: Wed, 18 Sep 2019 13:16:00 +0000
Subject: Bug 1572281 - Remove audio device change notifications from video
capture in Linux. r=dminor
After Bug 1581193 devicechange notifications were triggered with any device change, not just video and audio devices. This patch limits down the notifications to only video and audio input devices change.
Video capture used to provide device change notifications for audio and video devices. From now on, CubebDeviceEnumerator will provide audio device change notifications thus video capture is updated to notify only changes of the video device. This is the Linux part.
Differential Revision: https://phabricator.services.mozilla.com/D46147
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/1feec83ee6f92a35de0d4b27ebea04e68a0d7ef0
Differential Revision: https://phabricator.services.mozilla.com/D46272
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/7bf7263db30b794139332691f4fbc98b4bfcfdd7
---
.../video_capture/windows/device_info_ds.cc | 29 +++++++++++++++++--
.../video_capture/windows/device_info_ds.h | 1 +
2 files changed, 28 insertions(+), 2 deletions(-)
.../video_capture/linux/device_info_v4l2.cc | 28 ++-----------------
1 file changed, 3 insertions(+), 25 deletions(-)
diff --git a/modules/video_capture/windows/device_info_ds.cc b/modules/video_capture/windows/device_info_ds.cc
index 460ef3b7b9..a7eca19bbf 100644
--- a/modules/video_capture/windows/device_info_ds.cc
+++ b/modules/video_capture/windows/device_info_ds.cc
@@ -20,6 +20,18 @@
namespace webrtc {
namespace videocapturemodule {
+BOOL isCaptureDevice(DEV_BROADCAST_HDR *pHdr)
+{
+ if (pHdr == NULL) {
+ return FALSE;
+ }
+ if (pHdr->dbch_devicetype != DBT_DEVTYP_DEVICEINTERFACE) {
+ return FALSE;
+ }
+ DEV_BROADCAST_DEVICEINTERFACE* pDi = (DEV_BROADCAST_DEVICEINTERFACE*)pHdr;
+ return pDi->dbcc_classguid == KSCATEGORY_CAPTURE;
+}
+
LRESULT CALLBACK WndProc(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
diff --git a/modules/video_capture/linux/device_info_v4l2.cc b/modules/video_capture/linux/device_info_v4l2.cc
index 19b32f16b9..f77d791033 100644
--- a/modules/video_capture/linux/device_info_v4l2.cc
+++ b/modules/video_capture/linux/device_info_v4l2.cc
@@ -62,7 +62,7 @@ namespace videocapturemodule {
void DeviceInfoV4l2::HandleEvent(inotify_event* event, int fd)
{
DeviceInfoDS* pParent;
@@ -35,7 +47,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
else if (uiMsg == WM_DEVICECHANGE)
{
pParent = (DeviceInfoDS*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
- if (pParent)
+ if (pParent && isCaptureDevice((PDEV_BROADCAST_HDR)lParam))
{
pParent->DeviceChange();
if (event->mask & IN_CREATE) {
- if (fd == _fd_v4l || fd == _fd_snd) {
+ if (fd == _fd_v4l) {
DeviceChange();
} else if ((event->mask & IN_ISDIR) && (fd == _fd_dev)) {
if (_wd_v4l < 0) {
@@ -74,25 +74,15 @@ void DeviceInfoV4l2::HandleEvent(inotify_event* event, int fd)
DeviceChange();
}
}
- if (_wd_snd < 0) {
- usleep(5*1000);
- _wd_snd = inotify_add_watch(_fd_snd, "/dev/snd/by-path/", IN_CREATE | IN_DELETE | IN_DELETE_SELF);
- if (_wd_snd >= 0) {
- DeviceChange();
- }
- }
}
@@ -56,7 +68,8 @@ DeviceInfoDS* DeviceInfoDS::Create() {
DeviceInfoDS::DeviceInfoDS()
: _dsDevEnum(NULL),
_dsMonikerDevEnum(NULL),
- _CoUninitializeIsRequired(true) {
+ _CoUninitializeIsRequired(true),
+ _hdevnotify(NULL) {
// 1) Initialize the COM library (make Windows load the DLLs).
//
// CoInitializeEx must be called at least once, and is usually called only
@@ -111,6 +124,14 @@ DeviceInfoDS::DeviceInfoDS()
_hwnd = CreateWindow(_wndClass.lpszClassName, NULL, 0, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL,
NULL, _hInstance, this);
+
+ DEV_BROADCAST_DEVICEINTERFACE di = { 0 };
+ di.dbcc_size = sizeof(di);
+ di.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
+ di.dbcc_classguid = KSCATEGORY_CAPTURE;
+
+ _hdevnotify = RegisterDeviceNotification(_hwnd, &di,
+ DEVICE_NOTIFY_WINDOW_HANDLE);
}
} else if (event->mask & IN_DELETE) {
- if (fd == _fd_v4l || fd == _fd_snd) {
+ if (fd == _fd_v4l) {
DeviceChange();
}
} else if (event->mask & IN_DELETE_SELF) {
if (fd == _fd_v4l) {
inotify_rm_watch(_fd_v4l, _wd_v4l);
_wd_v4l = -1;
- } else if (fd == _fd_snd) {
- inotify_rm_watch(_fd_snd, _wd_snd);
- _wd_snd = -1;
} else {
assert(false);
}
@@ -159,11 +149,6 @@ int DeviceInfoV4l2::ProcessInotifyEvents()
break;
}
}
- if (EventCheck(_fd_snd) > 0) {
- if (HandleEvents(_fd_snd) < 0) {
- break;
- }
- }
}
return 0;
}
@@ -176,11 +161,9 @@ void DeviceInfoV4l2::InotifyEventThread(void* obj)
void DeviceInfoV4l2::InotifyProcess()
{
_fd_v4l = inotify_init();
- _fd_snd = inotify_init();
_fd_dev = inotify_init();
- if (_fd_v4l >= 0 && _fd_snd >= 0 && _fd_dev >= 0) {
+ if (_fd_v4l >= 0 && _fd_dev >= 0) {
_wd_v4l = inotify_add_watch(_fd_v4l, "/dev/v4l/by-path/", IN_CREATE | IN_DELETE | IN_DELETE_SELF);
- _wd_snd = inotify_add_watch(_fd_snd, "/dev/snd/by-path/", IN_CREATE | IN_DELETE | IN_DELETE_SELF);
_wd_dev = inotify_add_watch(_fd_dev, "/dev/", IN_CREATE);
ProcessInotifyEvents();
@@ -120,6 +141,10 @@ DeviceInfoDS::~DeviceInfoDS() {
if (_CoUninitializeIsRequired) {
CoUninitialize();
}
+ if (_hdevnotify)
+ {
+ UnregisterDeviceNotification(_hdevnotify);
+ }
if (_hwnd != NULL) {
DestroyWindow(_hwnd);
}
diff --git a/modules/video_capture/windows/device_info_ds.h b/modules/video_capture/windows/device_info_ds.h
index dc7b9b1a24..ed2a726d6f 100644
--- a/modules/video_capture/windows/device_info_ds.h
+++ b/modules/video_capture/windows/device_info_ds.h
@@ -96,6 +96,7 @@ class DeviceInfoDS : public DeviceInfoImpl {
HWND _hwnd;
WNDCLASS _wndClass;
HINSTANCE _hInstance;
+ HDEVNOTIFY _hdevnotify;
};
} // namespace videocapturemodule
} // namespace webrtc
@@ -188,16 +171,11 @@ void DeviceInfoV4l2::InotifyProcess()
inotify_rm_watch(_fd_v4l, _wd_v4l);
}
- if (_wd_snd >= 0) {
- inotify_rm_watch(_fd_snd, _wd_snd);
- }
-
if (_wd_dev >= 0) {
inotify_rm_watch(_fd_dev, _wd_dev);
}
close(_fd_v4l);
- close(_fd_snd);
close(_fd_dev);
}
}

View File

@ -1,95 +1,53 @@
From: Alex Chronopoulos <achronop@gmail.com>
Date: Wed, 18 Sep 2019 13:16:00 +0000
Date: Wed, 18 Sep 2019 13:12:00 +0000
Subject: Bug 1572281 - Remove audio device change notifications from video
capture in Linux. r=dminor
capture in Windows. r=dminor
Video capture used to provide device change notifications for audio and video devices. From now on, CubebDeviceEnumerator will provide audio device change notifications thus video capture is updated to notify only changes of the video device. This is the Linux part.
Video capture used to provide device change notifications for audio and video devices. From now on, CubebDeviceEnumerator will provide audio device change notifications thus video capture is updated to notify only changes of the video device. This is the windows part.
Differential Revision: https://phabricator.services.mozilla.com/D46272
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/7bf7263db30b794139332691f4fbc98b4bfcfdd7
Differential Revision: https://phabricator.services.mozilla.com/D46274
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a5c23245837ebdd99532e8bfaca05774c5c96d9d
---
.../video_capture/linux/device_info_v4l2.cc | 28 ++-----------------
1 file changed, 3 insertions(+), 25 deletions(-)
modules/video_capture/windows/device_info_ds.cc | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/modules/video_capture/linux/device_info_v4l2.cc b/modules/video_capture/linux/device_info_v4l2.cc
index 19b32f16b9..f77d791033 100644
--- a/modules/video_capture/linux/device_info_v4l2.cc
+++ b/modules/video_capture/linux/device_info_v4l2.cc
@@ -62,7 +62,7 @@ namespace videocapturemodule {
void DeviceInfoV4l2::HandleEvent(inotify_event* event, int fd)
diff --git a/modules/video_capture/windows/device_info_ds.cc b/modules/video_capture/windows/device_info_ds.cc
index a7eca19bbf..9d22f42f4d 100644
--- a/modules/video_capture/windows/device_info_ds.cc
+++ b/modules/video_capture/windows/device_info_ds.cc
@@ -20,7 +20,7 @@
namespace webrtc {
namespace videocapturemodule {
-BOOL isCaptureDevice(DEV_BROADCAST_HDR *pHdr)
+BOOL isVideoDevice(DEV_BROADCAST_HDR *pHdr)
{
if (event->mask & IN_CREATE) {
- if (fd == _fd_v4l || fd == _fd_snd) {
+ if (fd == _fd_v4l) {
DeviceChange();
} else if ((event->mask & IN_ISDIR) && (fd == _fd_dev)) {
if (_wd_v4l < 0) {
@@ -74,25 +74,15 @@ void DeviceInfoV4l2::HandleEvent(inotify_event* event, int fd)
DeviceChange();
}
}
- if (_wd_snd < 0) {
- usleep(5*1000);
- _wd_snd = inotify_add_watch(_fd_snd, "/dev/snd/by-path/", IN_CREATE | IN_DELETE | IN_DELETE_SELF);
- if (_wd_snd >= 0) {
- DeviceChange();
- }
- }
}
} else if (event->mask & IN_DELETE) {
- if (fd == _fd_v4l || fd == _fd_snd) {
+ if (fd == _fd_v4l) {
DeviceChange();
}
} else if (event->mask & IN_DELETE_SELF) {
if (fd == _fd_v4l) {
inotify_rm_watch(_fd_v4l, _wd_v4l);
_wd_v4l = -1;
- } else if (fd == _fd_snd) {
- inotify_rm_watch(_fd_snd, _wd_snd);
- _wd_snd = -1;
} else {
assert(false);
}
@@ -159,11 +149,6 @@ int DeviceInfoV4l2::ProcessInotifyEvents()
break;
}
}
- if (EventCheck(_fd_snd) > 0) {
- if (HandleEvents(_fd_snd) < 0) {
- break;
- }
- }
}
return 0;
if (pHdr == NULL) {
return FALSE;
@@ -29,7 +29,7 @@ BOOL isCaptureDevice(DEV_BROADCAST_HDR *pHdr)
return FALSE;
}
DEV_BROADCAST_DEVICEINTERFACE* pDi = (DEV_BROADCAST_DEVICEINTERFACE*)pHdr;
- return pDi->dbcc_classguid == KSCATEGORY_CAPTURE;
+ return pDi->dbcc_classguid == KSCATEGORY_VIDEO_CAMERA;
}
@@ -176,11 +161,9 @@ void DeviceInfoV4l2::InotifyEventThread(void* obj)
void DeviceInfoV4l2::InotifyProcess()
{
_fd_v4l = inotify_init();
- _fd_snd = inotify_init();
_fd_dev = inotify_init();
- if (_fd_v4l >= 0 && _fd_snd >= 0 && _fd_dev >= 0) {
+ if (_fd_v4l >= 0 && _fd_dev >= 0) {
_wd_v4l = inotify_add_watch(_fd_v4l, "/dev/v4l/by-path/", IN_CREATE | IN_DELETE | IN_DELETE_SELF);
- _wd_snd = inotify_add_watch(_fd_snd, "/dev/snd/by-path/", IN_CREATE | IN_DELETE | IN_DELETE_SELF);
_wd_dev = inotify_add_watch(_fd_dev, "/dev/", IN_CREATE);
ProcessInotifyEvents();
@@ -188,16 +171,11 @@ void DeviceInfoV4l2::InotifyProcess()
inotify_rm_watch(_fd_v4l, _wd_v4l);
LRESULT CALLBACK WndProc(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
@@ -47,7 +47,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
else if (uiMsg == WM_DEVICECHANGE)
{
pParent = (DeviceInfoDS*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
- if (pParent && isCaptureDevice((PDEV_BROADCAST_HDR)lParam))
+ if (pParent && isVideoDevice((PDEV_BROADCAST_HDR)lParam))
{
pParent->DeviceChange();
}
@@ -128,7 +128,7 @@ DeviceInfoDS::DeviceInfoDS()
DEV_BROADCAST_DEVICEINTERFACE di = { 0 };
di.dbcc_size = sizeof(di);
di.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
- di.dbcc_classguid = KSCATEGORY_CAPTURE;
+ di.dbcc_classguid = KSCATEGORY_VIDEO_CAMERA;
- if (_wd_snd >= 0) {
- inotify_rm_watch(_fd_snd, _wd_snd);
- }
-
if (_wd_dev >= 0) {
inotify_rm_watch(_fd_dev, _wd_dev);
}
close(_fd_v4l);
- close(_fd_snd);
close(_fd_dev);
}
}
_hdevnotify = RegisterDeviceNotification(_hwnd, &di,
DEVICE_NOTIFY_WINDOW_HANDLE);

View File

@ -1,53 +1,65 @@
From: Alex Chronopoulos <achronop@gmail.com>
Date: Wed, 18 Sep 2019 13:12:00 +0000
Subject: Bug 1572281 - Remove audio device change notifications from video
capture in Windows. r=dminor
From: Wang Qing <wangqing-hf@loongson.cn>
Date: Wed, 25 Sep 2019 14:15:00 +0000
Subject: Bug 1579834 - [WebRTC] Add mips64 support; r=dminor
Video capture used to provide device change notifications for audio and video devices. From now on, CubebDeviceEnumerator will provide audio device change notifications thus video capture is updated to notify only changes of the video device. This is the windows part.
Differential Revision: https://phabricator.services.mozilla.com/D46274
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a5c23245837ebdd99532e8bfaca05774c5c96d9d
Differential Revision: https://phabricator.services.mozilla.com/D45620
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/1387b2c480b55ecca3fbdf62bd7649dafc62438d
---
modules/video_capture/windows/device_info_ds.cc | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc | 2 +-
modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc | 8 ++++++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/modules/video_capture/windows/device_info_ds.cc b/modules/video_capture/windows/device_info_ds.cc
index a7eca19bbf..9d22f42f4d 100644
--- a/modules/video_capture/windows/device_info_ds.cc
+++ b/modules/video_capture/windows/device_info_ds.cc
@@ -20,7 +20,7 @@
namespace webrtc {
namespace videocapturemodule {
diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc
index fc6cad6167..06422aaf5a 100644
--- a/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc
+++ b/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc
@@ -47,7 +47,7 @@ const char kVp8PostProcArmFieldTrial[] = "WebRTC-VP8-Postproc-Config-Arm";
const char kVp8PostProcFieldTrial[] = "WebRTC-VP8-Postproc-Config";
-BOOL isCaptureDevice(DEV_BROADCAST_HDR *pHdr)
+BOOL isVideoDevice(DEV_BROADCAST_HDR *pHdr)
{
if (pHdr == NULL) {
return FALSE;
@@ -29,7 +29,7 @@ BOOL isCaptureDevice(DEV_BROADCAST_HDR *pHdr)
return FALSE;
}
DEV_BROADCAST_DEVICEINTERFACE* pDi = (DEV_BROADCAST_DEVICEINTERFACE*)pHdr;
- return pDi->dbcc_classguid == KSCATEGORY_CAPTURE;
+ return pDi->dbcc_classguid == KSCATEGORY_VIDEO_CAMERA;
#if defined(WEBRTC_ARCH_ARM) || defined(WEBRTC_ARCH_ARM64) || \
- defined(WEBRTC_ANDROID)
+ defined(WEBRTC_ANDROID) || defined(WEBRTC_ARCH_MIPS)
constexpr bool kIsArm = true;
#else
constexpr bool kIsArm = false;
diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
index 7edd3feb48..52511cc884 100644
--- a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
+++ b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
@@ -746,7 +746,7 @@ int LibvpxVp8Encoder::InitEncode(const VideoCodec* inst,
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
@@ -47,7 +47,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
else if (uiMsg == WM_DEVICECHANGE)
{
pParent = (DeviceInfoDS*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
- if (pParent && isCaptureDevice((PDEV_BROADCAST_HDR)lParam))
+ if (pParent && isVideoDevice((PDEV_BROADCAST_HDR)lParam))
{
pParent->DeviceChange();
}
@@ -128,7 +128,7 @@ DeviceInfoDS::DeviceInfoDS()
DEV_BROADCAST_DEVICEINTERFACE di = { 0 };
di.dbcc_size = sizeof(di);
di.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
- di.dbcc_classguid = KSCATEGORY_CAPTURE;
+ di.dbcc_classguid = KSCATEGORY_VIDEO_CAMERA;
_hdevnotify = RegisterDeviceNotification(_hwnd, &di,
DEVICE_NOTIFY_WINDOW_HANDLE);
int LibvpxVp8Encoder::GetCpuSpeed(int width, int height) {
-#ifdef MOBILE_ARM
+#if defined(MOBILE_ARM) || defined(WEBRTC_ARCH_MIPS)
// On mobile platform, use a lower speed setting for lower resolutions for
// CPUs with 4 or more cores.
RTC_DCHECK_GT(number_of_cores_, 0);
@@ -774,6 +774,8 @@ int LibvpxVp8Encoder::GetCpuSpeed(int width, int height) {
int LibvpxVp8Encoder::NumberOfThreads(int width, int height, int cpus) {
#if defined(WEBRTC_ANDROID)
if (android_specific_threading_settings_) {
+#endif
+#if defined(WEBRTC_ANDROID) || defined(WEBRTC_ARCH_MIPS)
if (width * height >= 320 * 180) {
if (cpus >= 4) {
// 3 threads for CPUs with 4 and more cores since most of times only 4
@@ -786,7 +788,9 @@ int LibvpxVp8Encoder::NumberOfThreads(int width, int height, int cpus) {
}
}
return 1;
+#if defined(WEBRTC_ANDROID)
}
+#endif
#elif defined(WEBRTC_IOS)
std::string trial_string =
env_.field_trials().Lookup(kVP8IosMaxNumberOfThreadFieldTrial);
@@ -844,7 +848,7 @@ int LibvpxVp8Encoder::InitAndSetControlSettings() {
// for getting the denoised frame from the encoder and using that
// when encoding lower resolution streams. Would it work with the
// multi-res encoding feature?
-#ifdef MOBILE_ARM
+#if defined(MOBILE_ARM) || defined(WEBRTC_ARCH_MIPS)
denoiserState denoiser_state = kDenoiserOnYOnly;
#else
denoiserState denoiser_state = kDenoiserOnAdaptive;

View File

@ -1,65 +1,26 @@
From: Wang Qing <wangqing-hf@loongson.cn>
Date: Wed, 25 Sep 2019 14:15:00 +0000
Subject: Bug 1579834 - [WebRTC] Add mips64 support; r=dminor
From: Dan Minor <dminor@mozilla.com>
Date: Wed, 9 Oct 2019 20:12:00 +0000
Subject: Bug 1587159 - Fix undefined shift in g722_encode.c; r=ng
Differential Revision: https://phabricator.services.mozilla.com/D45620
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/1387b2c480b55ecca3fbdf62bd7649dafc62438d
Left shifting a negative value results in undefined behaviour. It is safer to
multiply in this case.
Differential Revision: https://phabricator.services.mozilla.com/D48751
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/385d660fac359c907986e08d1d89ab5a353f30b2
---
modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc | 2 +-
modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc | 8 ++++++--
2 files changed, 7 insertions(+), 3 deletions(-)
modules/third_party/g722/g722_encode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc
index fc6cad6167..06422aaf5a 100644
--- a/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc
+++ b/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc
@@ -47,7 +47,7 @@ const char kVp8PostProcArmFieldTrial[] = "WebRTC-VP8-Postproc-Config-Arm";
const char kVp8PostProcFieldTrial[] = "WebRTC-VP8-Postproc-Config";
diff --git a/modules/third_party/g722/g722_encode.c b/modules/third_party/g722/g722_encode.c
index 10a5bcfe7c..fedf9f5961 100644
--- a/modules/third_party/g722/g722_encode.c
+++ b/modules/third_party/g722/g722_encode.c
@@ -74,7 +74,7 @@ static void block4(G722EncoderState *s, int band, int d)
/* Block 4, UPPOL2 */
for (i = 0; i < 3; i++)
s->band[band].sg[i] = s->band[band].p[i] >> 15;
- wd1 = saturate(s->band[band].a[1] << 2);
+ wd1 = saturate(s->band[band].a[1] * 4);
#if defined(WEBRTC_ARCH_ARM) || defined(WEBRTC_ARCH_ARM64) || \
- defined(WEBRTC_ANDROID)
+ defined(WEBRTC_ANDROID) || defined(WEBRTC_ARCH_MIPS)
constexpr bool kIsArm = true;
#else
constexpr bool kIsArm = false;
diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
index 7edd3feb48..52511cc884 100644
--- a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
+++ b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
@@ -746,7 +746,7 @@ int LibvpxVp8Encoder::InitEncode(const VideoCodec* inst,
}
int LibvpxVp8Encoder::GetCpuSpeed(int width, int height) {
-#ifdef MOBILE_ARM
+#if defined(MOBILE_ARM) || defined(WEBRTC_ARCH_MIPS)
// On mobile platform, use a lower speed setting for lower resolutions for
// CPUs with 4 or more cores.
RTC_DCHECK_GT(number_of_cores_, 0);
@@ -774,6 +774,8 @@ int LibvpxVp8Encoder::GetCpuSpeed(int width, int height) {
int LibvpxVp8Encoder::NumberOfThreads(int width, int height, int cpus) {
#if defined(WEBRTC_ANDROID)
if (android_specific_threading_settings_) {
+#endif
+#if defined(WEBRTC_ANDROID) || defined(WEBRTC_ARCH_MIPS)
if (width * height >= 320 * 180) {
if (cpus >= 4) {
// 3 threads for CPUs with 4 and more cores since most of times only 4
@@ -786,7 +788,9 @@ int LibvpxVp8Encoder::NumberOfThreads(int width, int height, int cpus) {
}
}
return 1;
+#if defined(WEBRTC_ANDROID)
}
+#endif
#elif defined(WEBRTC_IOS)
std::string trial_string =
env_.field_trials().Lookup(kVP8IosMaxNumberOfThreadFieldTrial);
@@ -844,7 +848,7 @@ int LibvpxVp8Encoder::InitAndSetControlSettings() {
// for getting the denoised frame from the encoder and using that
// when encoding lower resolution streams. Would it work with the
// multi-res encoding feature?
-#ifdef MOBILE_ARM
+#if defined(MOBILE_ARM) || defined(WEBRTC_ARCH_MIPS)
denoiserState denoiser_state = kDenoiserOnYOnly;
#else
denoiserState denoiser_state = kDenoiserOnAdaptive;
wd2 = (s->band[band].sg[0] == s->band[band].sg[1]) ? -wd1 : wd1;
if (wd2 > 32767)

View File

@ -1,26 +1,145 @@
From: Dan Minor <dminor@mozilla.com>
Date: Wed, 9 Oct 2019 20:12:00 +0000
Subject: Bug 1587159 - Fix undefined shift in g722_encode.c; r=ng
From: Gabriele Svelto <gsvelto@mozilla.com>
Date: Mon, 28 Oct 2019 23:26:00 +0000
Subject: Bug 1590984 - Use poll() instead of select() in WebRTC code r=drno
Left shifting a negative value results in undefined behaviour. It is safer to
multiply in this case.
The use of select() was leading to crashes when the file descriptor value was
larger than FD_SETSIZE. Recent versions of glibc have checks in the FD_CLR(),
FD_SET() and FD_ISSET() macros that will abort() the program instead of doing
an out-of-bounds access. poll() doesn't have limitations on the file
descriptor values and provides behavior that is otherwise identical to
select() thus solving the problem.
Differential Revision: https://phabricator.services.mozilla.com/D48751
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/385d660fac359c907986e08d1d89ab5a353f30b2
Differential Revision: https://phabricator.services.mozilla.com/D50798
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/59fb6760bb6785a6f8a51be6fc66bf04cfba3e16
---
modules/third_party/g722/g722_encode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
.../video_capture/linux/device_info_linux.cc | 1 +
.../video_capture/linux/device_info_v4l2.cc | 16 +++++-----
.../linux/video_capture_linux.cc | 1 +
.../video_capture/linux/video_capture_v4l2.cc | 29 +++++++++++--------
4 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/modules/third_party/g722/g722_encode.c b/modules/third_party/g722/g722_encode.c
index 10a5bcfe7c..fedf9f5961 100644
--- a/modules/third_party/g722/g722_encode.c
+++ b/modules/third_party/g722/g722_encode.c
@@ -74,7 +74,7 @@ static void block4(G722EncoderState *s, int band, int d)
/* Block 4, UPPOL2 */
for (i = 0; i < 3; i++)
s->band[band].sg[i] = s->band[band].p[i] >> 15;
- wd1 = saturate(s->band[band].a[1] << 2);
+ wd1 = saturate(s->band[band].a[1] * 4);
diff --git a/modules/video_capture/linux/device_info_linux.cc b/modules/video_capture/linux/device_info_linux.cc
index 56da475bf3..cae63c7c2d 100644
--- a/modules/video_capture/linux/device_info_linux.cc
+++ b/modules/video_capture/linux/device_info_linux.cc
@@ -10,6 +10,7 @@
wd2 = (s->band[band].sg[0] == s->band[band].sg[1]) ? -wd1 : wd1;
if (wd2 > 32767)
#include <errno.h>
#include <fcntl.h>
+#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/modules/video_capture/linux/device_info_v4l2.cc b/modules/video_capture/linux/device_info_v4l2.cc
index f77d791033..a2435bcd4f 100644
--- a/modules/video_capture/linux/device_info_v4l2.cc
+++ b/modules/video_capture/linux/device_info_v4l2.cc
@@ -12,6 +12,7 @@
#include <errno.h>
#include <fcntl.h>
+#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -91,16 +92,13 @@ void DeviceInfoV4l2::HandleEvent(inotify_event* event, int fd)
int DeviceInfoV4l2::EventCheck(int fd)
{
- struct timeval timeout;
- fd_set rfds;
+ struct pollfd fds = {
+ .fd = fd,
+ .events = POLLIN,
+ .revents = 0
+ };
- timeout.tv_sec = 0;
- timeout.tv_usec = 100000;
-
- FD_ZERO(&rfds);
- FD_SET(fd, &rfds);
-
- return select(fd+1, &rfds, NULL, NULL, &timeout);
+ return poll(&fds, 1, 100);
}
int DeviceInfoV4l2::HandleEvents(int fd)
diff --git a/modules/video_capture/linux/video_capture_linux.cc b/modules/video_capture/linux/video_capture_linux.cc
index 23a8f4f3f3..b2c206d775 100644
--- a/modules/video_capture/linux/video_capture_linux.cc
+++ b/modules/video_capture/linux/video_capture_linux.cc
@@ -10,6 +10,7 @@
#include <errno.h>
#include <fcntl.h>
+#include <poll.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
diff --git a/modules/video_capture/linux/video_capture_v4l2.cc b/modules/video_capture/linux/video_capture_v4l2.cc
index 377c1ec878..a2e362bb94 100644
--- a/modules/video_capture/linux/video_capture_v4l2.cc
+++ b/modules/video_capture/linux/video_capture_v4l2.cc
@@ -12,7 +12,7 @@
#include <errno.h>
#include <fcntl.h>
-#include <linux/videodev2.h>
+#include <poll.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
@@ -20,6 +20,14 @@
#include <sys/select.h>
#include <time.h>
#include <unistd.h>
+// v4l includes
+#if defined(__NetBSD__) || defined(__OpenBSD__) // WEBRTC_BSD
+#include <sys/videoio.h>
+#elif defined(__sun)
+#include <sys/videodev2.h>
+#else
+#include <linux/videodev2.h>
+#endif
#include <new>
#include <string>
@@ -414,16 +422,13 @@ bool VideoCaptureModuleV4L2::CaptureProcess() {
RTC_CHECK_RUNS_SERIALIZED(&capture_checker_);
int retVal = 0;
- fd_set rSet;
- struct timeval timeout;
+ struct pollfd rSet;
- FD_ZERO(&rSet);
- FD_SET(_deviceFd, &rSet);
- timeout.tv_sec = 1;
- timeout.tv_usec = 0;
+ rSet.fd = _deviceFd;
+ rSet.events = POLLIN;
+ rSet.revents = 0;
- // _deviceFd written only in StartCapture, when this thread isn't running.
- retVal = select(_deviceFd + 1, &rSet, NULL, NULL, &timeout);
+ retVal = poll(&rSet, 1, 1000);
{
MutexLock lock(&capture_lock_);
@@ -433,12 +438,12 @@ bool VideoCaptureModuleV4L2::CaptureProcess() {
}
if (retVal < 0 && errno != EINTR) { // continue if interrupted
- // select failed
+ // poll failed
return false;
} else if (retVal == 0) {
- // select timed out
+ // poll timed out
return true;
- } else if (!FD_ISSET(_deviceFd, &rSet)) {
+ } else if (!(rSet.revents & POLLIN)) {
// not event on camera handle
return true;
}

View File

@ -1,145 +1,25 @@
From: Gabriele Svelto <gsvelto@mozilla.com>
Date: Mon, 28 Oct 2019 23:26:00 +0000
Subject: Bug 1590984 - Use poll() instead of select() in WebRTC code r=drno
From: Dan Minor <dminor@mozilla.com>
Date: Tue, 11 Feb 2020 17:04:00 +0000
Subject: Bug 1578073 - Fix warning: [cast] redundant cast to int; r=ng
The use of select() was leading to crashes when the file descriptor value was
larger than FD_SETSIZE. Recent versions of glibc have checks in the FD_CLR(),
FD_SET() and FD_ISSET() macros that will abort() the program instead of doing
an out-of-bounds access. poll() doesn't have limitations on the file
descriptor values and provides behavior that is otherwise identical to
select() thus solving the problem.
Differential Revision: https://phabricator.services.mozilla.com/D50798
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/59fb6760bb6785a6f8a51be6fc66bf04cfba3e16
Differential Revision: https://phabricator.services.mozilla.com/D61852
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/82877c8a864072c03f45234c6649645ed609e098
---
.../video_capture/linux/device_info_linux.cc | 1 +
.../video_capture/linux/device_info_v4l2.cc | 16 +++++-----
.../linux/video_capture_linux.cc | 1 +
.../video_capture/linux/video_capture_v4l2.cc | 29 +++++++++++--------
4 files changed, 26 insertions(+), 21 deletions(-)
sdk/android/api/org/webrtc/TextureBufferImpl.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/modules/video_capture/linux/device_info_linux.cc b/modules/video_capture/linux/device_info_linux.cc
index 56da475bf3..cae63c7c2d 100644
--- a/modules/video_capture/linux/device_info_linux.cc
+++ b/modules/video_capture/linux/device_info_linux.cc
@@ -10,6 +10,7 @@
diff --git a/sdk/android/api/org/webrtc/TextureBufferImpl.java b/sdk/android/api/org/webrtc/TextureBufferImpl.java
index 7e2bed84fc..43470d6e39 100644
--- a/sdk/android/api/org/webrtc/TextureBufferImpl.java
+++ b/sdk/android/api/org/webrtc/TextureBufferImpl.java
@@ -136,8 +136,8 @@ public class TextureBufferImpl implements VideoFrame.TextureBuffer {
cropAndScaleMatrix.preScale(cropWidth / (float) width, cropHeight / (float) height);
#include <errno.h>
#include <fcntl.h>
+#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/modules/video_capture/linux/device_info_v4l2.cc b/modules/video_capture/linux/device_info_v4l2.cc
index f77d791033..a2435bcd4f 100644
--- a/modules/video_capture/linux/device_info_v4l2.cc
+++ b/modules/video_capture/linux/device_info_v4l2.cc
@@ -12,6 +12,7 @@
return applyTransformMatrix(cropAndScaleMatrix,
- (int) Math.round(unscaledWidth * cropWidth / (float) width),
- (int) Math.round(unscaledHeight * cropHeight / (float) height), scaleWidth, scaleHeight);
+ Math.round(unscaledWidth * cropWidth / (float) width),
+ Math.round(unscaledHeight * cropHeight / (float) height), scaleWidth, scaleHeight);
}
#include <errno.h>
#include <fcntl.h>
+#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -91,16 +92,13 @@ void DeviceInfoV4l2::HandleEvent(inotify_event* event, int fd)
int DeviceInfoV4l2::EventCheck(int fd)
{
- struct timeval timeout;
- fd_set rfds;
+ struct pollfd fds = {
+ .fd = fd,
+ .events = POLLIN,
+ .revents = 0
+ };
- timeout.tv_sec = 0;
- timeout.tv_usec = 100000;
-
- FD_ZERO(&rfds);
- FD_SET(fd, &rfds);
-
- return select(fd+1, &rfds, NULL, NULL, &timeout);
+ return poll(&fds, 1, 100);
}
int DeviceInfoV4l2::HandleEvents(int fd)
diff --git a/modules/video_capture/linux/video_capture_linux.cc b/modules/video_capture/linux/video_capture_linux.cc
index 23a8f4f3f3..b2c206d775 100644
--- a/modules/video_capture/linux/video_capture_linux.cc
+++ b/modules/video_capture/linux/video_capture_linux.cc
@@ -10,6 +10,7 @@
#include <errno.h>
#include <fcntl.h>
+#include <poll.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
diff --git a/modules/video_capture/linux/video_capture_v4l2.cc b/modules/video_capture/linux/video_capture_v4l2.cc
index 377c1ec878..a2e362bb94 100644
--- a/modules/video_capture/linux/video_capture_v4l2.cc
+++ b/modules/video_capture/linux/video_capture_v4l2.cc
@@ -12,7 +12,7 @@
#include <errno.h>
#include <fcntl.h>
-#include <linux/videodev2.h>
+#include <poll.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
@@ -20,6 +20,14 @@
#include <sys/select.h>
#include <time.h>
#include <unistd.h>
+// v4l includes
+#if defined(__NetBSD__) || defined(__OpenBSD__) // WEBRTC_BSD
+#include <sys/videoio.h>
+#elif defined(__sun)
+#include <sys/videodev2.h>
+#else
+#include <linux/videodev2.h>
+#endif
#include <new>
#include <string>
@@ -414,16 +422,13 @@ bool VideoCaptureModuleV4L2::CaptureProcess() {
RTC_CHECK_RUNS_SERIALIZED(&capture_checker_);
int retVal = 0;
- fd_set rSet;
- struct timeval timeout;
+ struct pollfd rSet;
- FD_ZERO(&rSet);
- FD_SET(_deviceFd, &rSet);
- timeout.tv_sec = 1;
- timeout.tv_usec = 0;
+ rSet.fd = _deviceFd;
+ rSet.events = POLLIN;
+ rSet.revents = 0;
- // _deviceFd written only in StartCapture, when this thread isn't running.
- retVal = select(_deviceFd + 1, &rSet, NULL, NULL, &timeout);
+ retVal = poll(&rSet, 1, 1000);
{
MutexLock lock(&capture_lock_);
@@ -433,12 +438,12 @@ bool VideoCaptureModuleV4L2::CaptureProcess() {
}
if (retVal < 0 && errno != EINTR) { // continue if interrupted
- // select failed
+ // poll failed
return false;
} else if (retVal == 0) {
- // select timed out
+ // poll timed out
return true;
- } else if (!FD_ISSET(_deviceFd, &rSet)) {
+ } else if (!(rSet.revents & POLLIN)) {
// not event on camera handle
return true;
}
@Override

View File

@ -1,25 +1,40 @@
From: Dan Minor <dminor@mozilla.com>
Date: Tue, 11 Feb 2020 17:04:00 +0000
Subject: Bug 1578073 - Fix warning: [cast] redundant cast to int; r=ng
Date: Tue, 11 Feb 2020 17:07:00 +0000
Subject: Bug 1578073 - Remove native calls in Histogram.java; r=ng
Differential Revision: https://phabricator.services.mozilla.com/D61852
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/82877c8a864072c03f45234c6649645ed609e098
Getting the JNI calls here to work requires a good amount of webrtc.org
machinery. It might be worth setting that up the next time we do an upstream
merge, but for now, it is a lot simpler to just remove the affected code,
given that we are not interested in collecting this data anyway.
Differential Revision: https://phabricator.services.mozilla.com/D61860
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/7a9b07dec9f9d435416b06829fa5063aca3a476e
---
sdk/android/api/org/webrtc/TextureBufferImpl.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
sdk/android/src/java/org/webrtc/Histogram.java | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/sdk/android/api/org/webrtc/TextureBufferImpl.java b/sdk/android/api/org/webrtc/TextureBufferImpl.java
index 7e2bed84fc..43470d6e39 100644
--- a/sdk/android/api/org/webrtc/TextureBufferImpl.java
+++ b/sdk/android/api/org/webrtc/TextureBufferImpl.java
@@ -136,8 +136,8 @@ public class TextureBufferImpl implements VideoFrame.TextureBuffer {
cropAndScaleMatrix.preScale(cropWidth / (float) width, cropHeight / (float) height);
return applyTransformMatrix(cropAndScaleMatrix,
- (int) Math.round(unscaledWidth * cropWidth / (float) width),
- (int) Math.round(unscaledHeight * cropHeight / (float) height), scaleWidth, scaleHeight);
+ Math.round(unscaledWidth * cropWidth / (float) width),
+ Math.round(unscaledHeight * cropHeight / (float) height), scaleWidth, scaleHeight);
diff --git a/sdk/android/src/java/org/webrtc/Histogram.java b/sdk/android/src/java/org/webrtc/Histogram.java
index 877986134a..c1d2d61a71 100644
--- a/sdk/android/src/java/org/webrtc/Histogram.java
+++ b/sdk/android/src/java/org/webrtc/Histogram.java
@@ -27,18 +27,13 @@ class Histogram {
}
@Override
static public Histogram createCounts(String name, int min, int max, int bucketCount) {
- return new Histogram(nativeCreateCounts(name, min, max, bucketCount));
+ return new Histogram(0);
}
static public Histogram createEnumeration(String name, int max) {
- return new Histogram(nativeCreateEnumeration(name, max));
+ return new Histogram(0);
}
public void addSample(int sample) {
- nativeAddSample(handle, sample);
}
-
- private static native long nativeCreateCounts(String name, int min, int max, int bucketCount);
- private static native long nativeCreateEnumeration(String name, int max);
- private static native void nativeAddSample(long handle, int sample);
}

View File

@ -1,40 +1,33 @@
From: Dan Minor <dminor@mozilla.com>
Date: Tue, 11 Feb 2020 17:07:00 +0000
Subject: Bug 1578073 - Remove native calls in Histogram.java; r=ng
Date: Wed, 12 Feb 2020 17:19:00 +0000
Subject: Bug 1578073 - Suppress MissingPermission lint in Camera2Session;
r=snorp
Getting the JNI calls here to work requires a good amount of webrtc.org
machinery. It might be worth setting that up the next time we do an upstream
merge, but for now, it is a lot simpler to just remove the affected code,
given that we are not interested in collecting this data anyway.
Depends on D61861
Differential Revision: https://phabricator.services.mozilla.com/D61860
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/7a9b07dec9f9d435416b06829fa5063aca3a476e
Differential Revision: https://phabricator.services.mozilla.com/D62457
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/722c4a6d1dad867f9ce47fe96d71b5dedb4cbaa8
---
sdk/android/src/java/org/webrtc/Histogram.java | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
sdk/android/src/java/org/webrtc/Camera2Session.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sdk/android/src/java/org/webrtc/Histogram.java b/sdk/android/src/java/org/webrtc/Histogram.java
index 877986134a..c1d2d61a71 100644
--- a/sdk/android/src/java/org/webrtc/Histogram.java
+++ b/sdk/android/src/java/org/webrtc/Histogram.java
@@ -27,18 +27,13 @@ class Histogram {
diff --git a/sdk/android/src/java/org/webrtc/Camera2Session.java b/sdk/android/src/java/org/webrtc/Camera2Session.java
index dec97a2c25..d5ee80c73e 100644
--- a/sdk/android/src/java/org/webrtc/Camera2Session.java
+++ b/sdk/android/src/java/org/webrtc/Camera2Session.java
@@ -10,6 +10,7 @@
package org.webrtc;
+import android.annotation.SuppressLint;
import android.content.Context;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCaptureSession;
@@ -347,6 +348,7 @@ class Camera2Session implements CameraSession {
Logging.d(TAG, "Using capture format: " + captureFormat);
}
static public Histogram createCounts(String name, int min, int max, int bucketCount) {
- return new Histogram(nativeCreateCounts(name, min, max, bucketCount));
+ return new Histogram(0);
}
+ @SuppressLint("MissingPermission")
private void openCamera() {
checkIsOnCameraThread();
static public Histogram createEnumeration(String name, int max) {
- return new Histogram(nativeCreateEnumeration(name, max));
+ return new Histogram(0);
}
public void addSample(int sample) {
- nativeAddSample(handle, sample);
}
-
- private static native long nativeCreateCounts(String name, int min, int max, int bucketCount);
- private static native long nativeCreateEnumeration(String name, int max);
- private static native void nativeAddSample(long handle, int sample);
}

View File

@ -1,33 +1,87 @@
From: Dan Minor <dminor@mozilla.com>
Date: Wed, 12 Feb 2020 17:19:00 +0000
Subject: Bug 1578073 - Suppress MissingPermission lint in Camera2Session;
r=snorp
Date: Wed, 8 Jul 2020 17:35:00 +0000
Subject: Bug 1650572 - Check V4L2_CAP_DEVICE_CAPS before accessing
device_caps; r=ng
Depends on D61861
The capabilities field is for the physical device, device_caps is for the
specific /dev/videoX device that has been opened. The device_caps field is
only populated if V4L2_CAP_DEVICE_CAPS is set, so we should check that, and
fall back to capabilities if it is not set.
Differential Revision: https://phabricator.services.mozilla.com/D62457
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/722c4a6d1dad867f9ce47fe96d71b5dedb4cbaa8
Differential Revision: https://phabricator.services.mozilla.com/D82377
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b5acbf536c46a66c939a61bde34ad93b1977a604
---
sdk/android/src/java/org/webrtc/Camera2Session.java | 2 ++
1 file changed, 2 insertions(+)
modules/video_capture/linux/device_info_v4l2.cc | 17 ++++++++++++-----
modules/video_capture/linux/device_info_v4l2.h | 3 +++
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/sdk/android/src/java/org/webrtc/Camera2Session.java b/sdk/android/src/java/org/webrtc/Camera2Session.java
index dec97a2c25..d5ee80c73e 100644
--- a/sdk/android/src/java/org/webrtc/Camera2Session.java
+++ b/sdk/android/src/java/org/webrtc/Camera2Session.java
@@ -10,6 +10,7 @@
diff --git a/modules/video_capture/linux/device_info_v4l2.cc b/modules/video_capture/linux/device_info_v4l2.cc
index a2435bcd4f..cd0ba6e3df 100644
--- a/modules/video_capture/linux/device_info_v4l2.cc
+++ b/modules/video_capture/linux/device_info_v4l2.cc
@@ -220,8 +220,7 @@ uint32_t DeviceInfoV4l2::NumberOfDevices() {
snprintf(device, sizeof(device), "/dev/video%d", n);
if ((fd = open(device, O_RDONLY)) != -1) {
// query device capabilities and make sure this is a video capture device
- if (ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0 ||
- !(cap.device_caps & V4L2_CAP_VIDEO_CAPTURE)) {
+ if (ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0 || !IsVideoCaptureDevice(&cap)) {
close(fd);
continue;
}
@@ -252,8 +251,7 @@ int32_t DeviceInfoV4l2::GetDeviceName(uint32_t deviceNumber,
snprintf(device, sizeof(device), "/dev/video%d", n);
if ((fd = open(device, O_RDONLY)) != -1) {
// query device capabilities and make sure this is a video capture device
- if (ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0 ||
- !(cap.device_caps & V4L2_CAP_VIDEO_CAPTURE)) {
+ if (ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0 || !IsVideoCaptureDevice(&cap)) {
close(fd);
continue;
}
@@ -331,7 +329,7 @@ int32_t DeviceInfoV4l2::CreateCapabilityMap(const char* deviceUniqueIdUTF8) {
struct v4l2_capability cap;
if (ioctl(fd, VIDIOC_QUERYCAP, &cap) == 0) {
// skip devices without video capture capability
- if (!(cap.device_caps & V4L2_CAP_VIDEO_CAPTURE)) {
+ if (!IsVideoCaptureDevice(&cap)) {
continue;
}
package org.webrtc;
@@ -393,6 +391,15 @@ bool DeviceInfoV4l2::IsDeviceNameMatches(const char* name,
return false;
}
+import android.annotation.SuppressLint;
import android.content.Context;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCaptureSession;
@@ -347,6 +348,7 @@ class Camera2Session implements CameraSession {
Logging.d(TAG, "Using capture format: " + captureFormat);
}
+bool DeviceInfoV4l2::IsVideoCaptureDevice(struct v4l2_capability* cap)
+{
+ if (cap->capabilities & V4L2_CAP_DEVICE_CAPS) {
+ return cap->device_caps & V4L2_CAP_VIDEO_CAPTURE;
+ } else {
+ return cap->capabilities & V4L2_CAP_VIDEO_CAPTURE;
+ }
+}
+
int32_t DeviceInfoV4l2::FillCapabilities(int fd) {
// set image format
struct v4l2_format video_fmt;
diff --git a/modules/video_capture/linux/device_info_v4l2.h b/modules/video_capture/linux/device_info_v4l2.h
index 95432a509d..e3c2395f49 100644
--- a/modules/video_capture/linux/device_info_v4l2.h
+++ b/modules/video_capture/linux/device_info_v4l2.h
@@ -18,6 +18,8 @@
#include "rtc_base/platform_thread.h"
#include <sys/inotify.h>
+ @SuppressLint("MissingPermission")
private void openCamera() {
checkIsOnCameraThread();
+struct v4l2_capability;
+
namespace webrtc {
namespace videocapturemodule {
class DeviceInfoV4l2 : public DeviceInfoImpl {
@@ -49,6 +51,7 @@ class DeviceInfoV4l2 : public DeviceInfoImpl {
private:
bool IsDeviceNameMatches(const char* name, const char* deviceUniqueIdUTF8);
+ bool IsVideoCaptureDevice(struct v4l2_capability* cap);
#ifdef WEBRTC_LINUX
void HandleEvent(inotify_event* event, int fd);

View File

@ -1,87 +1,64 @@
From: Dan Minor <dminor@mozilla.com>
Date: Wed, 8 Jul 2020 17:35:00 +0000
Subject: Bug 1650572 - Check V4L2_CAP_DEVICE_CAPS before accessing
device_caps; r=ng
From: Paul Adenot <paul@paul.cx>
Date: Wed, 4 Nov 2020 13:03:00 +0000
Subject: Bug 1675042 - Put IR camera last in the device selection list, so
that they are never the default. r=dminor
The capabilities field is for the physical device, device_caps is for the
specific /dev/videoX device that has been opened. The device_caps field is
only populated if V4L2_CAP_DEVICE_CAPS is set, so we should check that, and
fall back to capabilities if it is not set.
Differential Revision: https://phabricator.services.mozilla.com/D82377
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b5acbf536c46a66c939a61bde34ad93b1977a604
Differential Revision: https://phabricator.services.mozilla.com/D95764
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/754900ff2a2b1c32878baf3c76d7c0e8219419ff
---
modules/video_capture/linux/device_info_v4l2.cc | 17 ++++++++++++-----
modules/video_capture/linux/device_info_v4l2.h | 3 +++
2 files changed, 15 insertions(+), 5 deletions(-)
sdk/android/api/org/webrtc/Camera1Enumerator.java | 5 +++++
sdk/android/api/org/webrtc/Camera2Enumerator.java | 12 ++++++++++++
sdk/android/api/org/webrtc/CameraEnumerator.java | 1 +
3 files changed, 18 insertions(+)
diff --git a/modules/video_capture/linux/device_info_v4l2.cc b/modules/video_capture/linux/device_info_v4l2.cc
index a2435bcd4f..cd0ba6e3df 100644
--- a/modules/video_capture/linux/device_info_v4l2.cc
+++ b/modules/video_capture/linux/device_info_v4l2.cc
@@ -220,8 +220,7 @@ uint32_t DeviceInfoV4l2::NumberOfDevices() {
snprintf(device, sizeof(device), "/dev/video%d", n);
if ((fd = open(device, O_RDONLY)) != -1) {
// query device capabilities and make sure this is a video capture device
- if (ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0 ||
- !(cap.device_caps & V4L2_CAP_VIDEO_CAPTURE)) {
+ if (ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0 || !IsVideoCaptureDevice(&cap)) {
close(fd);
continue;
}
@@ -252,8 +251,7 @@ int32_t DeviceInfoV4l2::GetDeviceName(uint32_t deviceNumber,
snprintf(device, sizeof(device), "/dev/video%d", n);
if ((fd = open(device, O_RDONLY)) != -1) {
// query device capabilities and make sure this is a video capture device
- if (ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0 ||
- !(cap.device_caps & V4L2_CAP_VIDEO_CAPTURE)) {
+ if (ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0 || !IsVideoCaptureDevice(&cap)) {
close(fd);
continue;
}
@@ -331,7 +329,7 @@ int32_t DeviceInfoV4l2::CreateCapabilityMap(const char* deviceUniqueIdUTF8) {
struct v4l2_capability cap;
if (ioctl(fd, VIDIOC_QUERYCAP, &cap) == 0) {
// skip devices without video capture capability
- if (!(cap.device_caps & V4L2_CAP_VIDEO_CAPTURE)) {
+ if (!IsVideoCaptureDevice(&cap)) {
continue;
}
diff --git a/sdk/android/api/org/webrtc/Camera1Enumerator.java b/sdk/android/api/org/webrtc/Camera1Enumerator.java
index fb1a21f323..4a1aacdb05 100644
--- a/sdk/android/api/org/webrtc/Camera1Enumerator.java
+++ b/sdk/android/api/org/webrtc/Camera1Enumerator.java
@@ -63,6 +63,11 @@ public class Camera1Enumerator implements CameraEnumerator {
return info != null && info.facing == android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK;
}
@@ -393,6 +391,15 @@ bool DeviceInfoV4l2::IsDeviceNameMatches(const char* name,
return false;
}
+bool DeviceInfoV4l2::IsVideoCaptureDevice(struct v4l2_capability* cap)
+{
+ if (cap->capabilities & V4L2_CAP_DEVICE_CAPS) {
+ return cap->device_caps & V4L2_CAP_VIDEO_CAPTURE;
+ } else {
+ return cap->capabilities & V4L2_CAP_VIDEO_CAPTURE;
+ @Override
+ public boolean isInfrared(String deviceName) {
+ return false;
+ }
+}
+
int32_t DeviceInfoV4l2::FillCapabilities(int fd) {
// set image format
struct v4l2_format video_fmt;
diff --git a/modules/video_capture/linux/device_info_v4l2.h b/modules/video_capture/linux/device_info_v4l2.h
index 95432a509d..e3c2395f49 100644
--- a/modules/video_capture/linux/device_info_v4l2.h
+++ b/modules/video_capture/linux/device_info_v4l2.h
@@ -18,6 +18,8 @@
#include "rtc_base/platform_thread.h"
#include <sys/inotify.h>
@Override
public List<CaptureFormat> getSupportedFormats(String deviceName) {
return getSupportedFormats(getCameraIndex(deviceName));
diff --git a/sdk/android/api/org/webrtc/Camera2Enumerator.java b/sdk/android/api/org/webrtc/Camera2Enumerator.java
index 456d8cd060..44e239ad8e 100644
--- a/sdk/android/api/org/webrtc/Camera2Enumerator.java
+++ b/sdk/android/api/org/webrtc/Camera2Enumerator.java
@@ -74,6 +74,18 @@ public class Camera2Enumerator implements CameraEnumerator {
== CameraMetadata.LENS_FACING_BACK;
}
+struct v4l2_capability;
+ @Override
+ public boolean isInfrared(String deviceName) {
+ CameraCharacteristics characteristics = getCameraCharacteristics(deviceName);
+
namespace webrtc {
namespace videocapturemodule {
class DeviceInfoV4l2 : public DeviceInfoImpl {
@@ -49,6 +51,7 @@ class DeviceInfoV4l2 : public DeviceInfoImpl {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ Integer colors = characteristics.get(CameraCharacteristics.SENSOR_INFO_COLOR_FILTER_ARRANGEMENT);
+ return colors != null && colors.equals(CameraCharacteristics.SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_NIR);
+ }
+
+ return false;
+ }
+
@Nullable
@Override
public List<CaptureFormat> getSupportedFormats(String deviceName) {
diff --git a/sdk/android/api/org/webrtc/CameraEnumerator.java b/sdk/android/api/org/webrtc/CameraEnumerator.java
index dc954b62e0..db34d542c8 100644
--- a/sdk/android/api/org/webrtc/CameraEnumerator.java
+++ b/sdk/android/api/org/webrtc/CameraEnumerator.java
@@ -18,6 +18,7 @@ public interface CameraEnumerator {
public String[] getDeviceNames();
public boolean isFrontFacing(String deviceName);
public boolean isBackFacing(String deviceName);
+ public boolean isInfrared(String deviceName);
public List<CaptureFormat> getSupportedFormats(String deviceName);
private:
bool IsDeviceNameMatches(const char* name, const char* deviceUniqueIdUTF8);
+ bool IsVideoCaptureDevice(struct v4l2_capability* cap);
#ifdef WEBRTC_LINUX
void HandleEvent(inotify_event* event, int fd);
public CameraVideoCapturer createCapturer(

View File

@ -1,64 +1,22 @@
From: Paul Adenot <paul@paul.cx>
Date: Wed, 4 Nov 2020 13:03:00 +0000
Subject: Bug 1675042 - Put IR camera last in the device selection list, so
that they are never the default. r=dminor
From: Jan-Ivar Bruaroey <jib@mozilla.com>
Date: Fri, 18 Aug 2023 13:26:37 -0500
Subject: Bug 1701809: Close dev/video* driver file descriptors after camera
access on linux. r=ng
Differential Revision: https://phabricator.services.mozilla.com/D95764
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/754900ff2a2b1c32878baf3c76d7c0e8219419ff
Differential Revision: https://phabricator.services.mozilla.com/D110589
---
sdk/android/api/org/webrtc/Camera1Enumerator.java | 5 +++++
sdk/android/api/org/webrtc/Camera2Enumerator.java | 12 ++++++++++++
sdk/android/api/org/webrtc/CameraEnumerator.java | 1 +
3 files changed, 18 insertions(+)
modules/video_capture/linux/device_info_v4l2.cc | 1 +
1 file changed, 1 insertion(+)
diff --git a/sdk/android/api/org/webrtc/Camera1Enumerator.java b/sdk/android/api/org/webrtc/Camera1Enumerator.java
index fb1a21f323..4a1aacdb05 100644
--- a/sdk/android/api/org/webrtc/Camera1Enumerator.java
+++ b/sdk/android/api/org/webrtc/Camera1Enumerator.java
@@ -63,6 +63,11 @@ public class Camera1Enumerator implements CameraEnumerator {
return info != null && info.facing == android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK;
}
diff --git a/modules/video_capture/linux/device_info_v4l2.cc b/modules/video_capture/linux/device_info_v4l2.cc
index cd0ba6e3df..c5d33ff9a4 100644
--- a/modules/video_capture/linux/device_info_v4l2.cc
+++ b/modules/video_capture/linux/device_info_v4l2.cc
@@ -330,6 +330,7 @@ int32_t DeviceInfoV4l2::CreateCapabilityMap(const char* deviceUniqueIdUTF8) {
if (ioctl(fd, VIDIOC_QUERYCAP, &cap) == 0) {
// skip devices without video capture capability
if (!IsVideoCaptureDevice(&cap)) {
+ close(fd);
continue;
}
+ @Override
+ public boolean isInfrared(String deviceName) {
+ return false;
+ }
+
@Override
public List<CaptureFormat> getSupportedFormats(String deviceName) {
return getSupportedFormats(getCameraIndex(deviceName));
diff --git a/sdk/android/api/org/webrtc/Camera2Enumerator.java b/sdk/android/api/org/webrtc/Camera2Enumerator.java
index 456d8cd060..44e239ad8e 100644
--- a/sdk/android/api/org/webrtc/Camera2Enumerator.java
+++ b/sdk/android/api/org/webrtc/Camera2Enumerator.java
@@ -74,6 +74,18 @@ public class Camera2Enumerator implements CameraEnumerator {
== CameraMetadata.LENS_FACING_BACK;
}
+ @Override
+ public boolean isInfrared(String deviceName) {
+ CameraCharacteristics characteristics = getCameraCharacteristics(deviceName);
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ Integer colors = characteristics.get(CameraCharacteristics.SENSOR_INFO_COLOR_FILTER_ARRANGEMENT);
+ return colors != null && colors.equals(CameraCharacteristics.SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_NIR);
+ }
+
+ return false;
+ }
+
@Nullable
@Override
public List<CaptureFormat> getSupportedFormats(String deviceName) {
diff --git a/sdk/android/api/org/webrtc/CameraEnumerator.java b/sdk/android/api/org/webrtc/CameraEnumerator.java
index dc954b62e0..db34d542c8 100644
--- a/sdk/android/api/org/webrtc/CameraEnumerator.java
+++ b/sdk/android/api/org/webrtc/CameraEnumerator.java
@@ -18,6 +18,7 @@ public interface CameraEnumerator {
public String[] getDeviceNames();
public boolean isFrontFacing(String deviceName);
public boolean isBackFacing(String deviceName);
+ public boolean isInfrared(String deviceName);
public List<CaptureFormat> getSupportedFormats(String deviceName);
public CameraVideoCapturer createCapturer(

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,27 +1,130 @@
From: Dan Minor <dminor@mozilla.com>
Date: Tue, 1 Dec 2020 09:36:00 -0500
Subject: Bug 1654112 - Disable creating av1 encoder and decoder. r=ng
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 18 Jan 2021 11:04:00 +0100
Subject: Bug 1654112 - Include RtcpPacketTypeCounter in audio send stats, to
not regress nackCount. r=ng
Differential Revision: https://phabricator.services.mozilla.com/D130089
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/ef548d7758c7de6e78d38af299c2296bf9d20ec9
This is similar to how it's already included for video send.
Differential Revision: https://phabricator.services.mozilla.com/D102273
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/d380a43d59f4f7cbc001f4eab9b63ee993b32cd8
---
media/engine/internal_decoder_factory.cc | 2 ++
1 file changed, 2 insertions(+)
audio/audio_send_stream.cc | 1 +
audio/channel_send.cc | 31 +++++++++++++++++++++++++++++++
audio/channel_send.h | 1 +
call/audio_send_stream.h | 2 ++
4 files changed, 35 insertions(+)
diff --git a/media/engine/internal_decoder_factory.cc b/media/engine/internal_decoder_factory.cc
index 33fed924df..5b91209aba 100644
--- a/media/engine/internal_decoder_factory.cc
+++ b/media/engine/internal_decoder_factory.cc
@@ -50,10 +50,12 @@ std::vector<SdpVideoFormat> InternalDecoderFactory::GetSupportedFormats()
for (const SdpVideoFormat& h264_format : SupportedH264DecoderCodecs())
formats.push_back(h264_format);
diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc
index 6e5bd18fef..831e6c2815 100644
--- a/audio/audio_send_stream.cc
+++ b/audio/audio_send_stream.cc
@@ -413,6 +413,7 @@ webrtc::AudioSendStream::Stats AudioSendStream::GetStats(
stats.target_bitrate_bps = channel_send_->GetTargetBitrate();
+#if !defined(WEBRTC_MOZILLA_BUILD)
if (kDav1dIsIncluded) {
formats.push_back(SdpVideoFormat::AV1Profile0());
formats.push_back(SdpVideoFormat::AV1Profile1());
}
+#endif
webrtc::CallSendStatistics call_stats = channel_send_->GetRTCPStatistics();
+ stats.rtcp_packet_type_counts = call_stats.rtcp_packet_type_counts;
stats.payload_bytes_sent = call_stats.payload_bytes_sent;
stats.header_and_padding_bytes_sent =
call_stats.header_and_padding_bytes_sent;
diff --git a/audio/channel_send.cc b/audio/channel_send.cc
index fa8a42146c..70d3eaabbd 100644
--- a/audio/channel_send.cc
+++ b/audio/channel_send.cc
@@ -57,6 +57,31 @@ constexpr int64_t kMinRetransmissionWindowMs = 30;
class RtpPacketSenderProxy;
class TransportSequenceNumberProxy;
return formats;
}
+class RtcpCounterObserver : public RtcpPacketTypeCounterObserver {
+ public:
+ explicit RtcpCounterObserver(uint32_t ssrc) : ssrc_(ssrc) {}
+
+ void RtcpPacketTypesCounterUpdated(
+ uint32_t ssrc, const RtcpPacketTypeCounter& packet_counter) override {
+ if (ssrc_ != ssrc) {
+ return;
+ }
+
+ MutexLock lock(&mutex_);
+ packet_counter_ = packet_counter;
+ }
+
+ RtcpPacketTypeCounter GetCounts() {
+ MutexLock lock(&mutex_);
+ return packet_counter_;
+ }
+
+ private:
+ Mutex mutex_;
+ const uint32_t ssrc_;
+ RtcpPacketTypeCounter packet_counter_;
+};
+
class AudioBitrateAccountant {
public:
void RegisterPacketOverhead(int packet_byte_overhead) {
@@ -261,6 +286,8 @@ class ChannelSend : public ChannelSendInterface,
bool input_mute_ RTC_GUARDED_BY(volume_settings_mutex_) = false;
bool previous_frame_muted_ RTC_GUARDED_BY(encoder_queue_checker_) = false;
+ const std::unique_ptr<RtcpCounterObserver> rtcp_counter_observer_;
+
PacketRouter* packet_router_ RTC_GUARDED_BY(&worker_thread_checker_) =
nullptr;
const std::unique_ptr<RtpPacketSenderProxy> rtp_packet_pacer_proxy_;
@@ -472,6 +499,7 @@ ChannelSend::ChannelSend(
RtpTransportControllerSendInterface* transport_controller)
: env_(env),
ssrc_(ssrc),
+ rtcp_counter_observer_(new RtcpCounterObserver(ssrc)),
rtp_packet_pacer_proxy_(new RtpPacketSenderProxy()),
retransmission_rate_limiter_(
new RateLimiter(&env_.clock(), kMaxRetransmissionWindowMs)),
@@ -493,6 +521,8 @@ ChannelSend::ChannelSend(
configuration.paced_sender = rtp_packet_pacer_proxy_.get();
configuration.rtt_stats = rtcp_rtt_stats;
+ configuration.rtcp_packet_type_counter_observer =
+ rtcp_counter_observer_.get();
if (env_.field_trials().IsDisabled("WebRTC-DisableRtxRateLimiter")) {
configuration.retransmission_rate_limiter =
retransmission_rate_limiter_.get();
@@ -760,6 +790,7 @@ CallSendStatistics ChannelSend::GetRTCPStatistics() const {
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
CallSendStatistics stats = {0};
stats.rttMs = GetRTT();
+ stats.rtcp_packet_type_counts = rtcp_counter_observer_->GetCounts();
StreamDataCounters rtp_stats;
StreamDataCounters rtx_stats;
diff --git a/audio/channel_send.h b/audio/channel_send.h
index 02215e49cb..a1b09feb5e 100644
--- a/audio/channel_send.h
+++ b/audio/channel_send.h
@@ -41,6 +41,7 @@ struct CallSendStatistics {
TimeDelta total_packet_send_delay = TimeDelta::Zero();
// https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-retransmittedpacketssent
uint64_t retransmitted_packets_sent;
+ RtcpPacketTypeCounter rtcp_packet_type_counts;
// A snapshot of Report Blocks with additional data of interest to statistics.
// Within this list, the sender-source SSRC pair is unique and per-pair the
// ReportBlockData represents the latest Report Block that was received for
diff --git a/call/audio_send_stream.h b/call/audio_send_stream.h
index c60526771e..949bb32a88 100644
--- a/call/audio_send_stream.h
+++ b/call/audio_send_stream.h
@@ -32,6 +32,7 @@
#include "api/units/time_delta.h"
#include "call/audio_sender.h"
#include "modules/rtp_rtcp/include/report_block_data.h"
+#include "modules/rtp_rtcp/include/rtcp_statistics.h"
namespace webrtc {
@@ -66,6 +67,7 @@ class AudioSendStream : public AudioSender {
ANAStats ana_statistics;
AudioProcessingStats apm_statistics;
+ RtcpPacketTypeCounter rtcp_packet_type_counts;
int64_t target_bitrate_bps = 0;
// A snapshot of Report Blocks with additional data of interest to

View File

@ -1,130 +1,39 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 18 Jan 2021 11:04:00 +0100
Subject: Bug 1654112 - Include RtcpPacketTypeCounter in audio send stats, to
not regress nackCount. r=ng
Date: Fri, 19 Feb 2021 13:45:00 +0100
Subject: Bug 1654112 - libwebrtc: Add a REMB on/off switch to
VideoReceiveStream. r=ng
This is similar to how it's already included for video send.
Differential Revision: https://phabricator.services.mozilla.com/D102273
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/d380a43d59f4f7cbc001f4eab9b63ee993b32cd8
Differential Revision: https://phabricator.services.mozilla.com/D105774
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/7330681cf4de6d8dd868cc661cbdd6679bbc07b3
---
audio/audio_send_stream.cc | 1 +
audio/channel_send.cc | 31 +++++++++++++++++++++++++++++++
audio/channel_send.h | 1 +
call/audio_send_stream.h | 2 ++
4 files changed, 35 insertions(+)
call/video_receive_stream.h | 3 +++
video/rtp_video_stream_receiver2.cc | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc
index 6e5bd18fef..831e6c2815 100644
--- a/audio/audio_send_stream.cc
+++ b/audio/audio_send_stream.cc
@@ -413,6 +413,7 @@ webrtc::AudioSendStream::Stats AudioSendStream::GetStats(
stats.target_bitrate_bps = channel_send_->GetTargetBitrate();
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index f69b03a166..f68368567c 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -236,6 +236,9 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
// disabled.
KeyFrameReqMethod keyframe_method = KeyFrameReqMethod::kPliRtcp;
webrtc::CallSendStatistics call_stats = channel_send_->GetRTCPStatistics();
+ stats.rtcp_packet_type_counts = call_stats.rtcp_packet_type_counts;
stats.payload_bytes_sent = call_stats.payload_bytes_sent;
stats.header_and_padding_bytes_sent =
call_stats.header_and_padding_bytes_sent;
diff --git a/audio/channel_send.cc b/audio/channel_send.cc
index fa8a42146c..70d3eaabbd 100644
--- a/audio/channel_send.cc
+++ b/audio/channel_send.cc
@@ -57,6 +57,31 @@ constexpr int64_t kMinRetransmissionWindowMs = 30;
class RtpPacketSenderProxy;
class TransportSequenceNumberProxy;
+class RtcpCounterObserver : public RtcpPacketTypeCounterObserver {
+ public:
+ explicit RtcpCounterObserver(uint32_t ssrc) : ssrc_(ssrc) {}
+ // See draft-alvestrand-rmcat-remb for information.
+ bool remb = false;
+
+ void RtcpPacketTypesCounterUpdated(
+ uint32_t ssrc, const RtcpPacketTypeCounter& packet_counter) override {
+ if (ssrc_ != ssrc) {
+ return;
+ }
+
+ MutexLock lock(&mutex_);
+ packet_counter_ = packet_counter;
+ }
+
+ RtcpPacketTypeCounter GetCounts() {
+ MutexLock lock(&mutex_);
+ return packet_counter_;
+ }
+
+ private:
+ Mutex mutex_;
+ const uint32_t ssrc_;
+ RtcpPacketTypeCounter packet_counter_;
+};
+
class AudioBitrateAccountant {
public:
void RegisterPacketOverhead(int packet_byte_overhead) {
@@ -261,6 +286,8 @@ class ChannelSend : public ChannelSendInterface,
bool input_mute_ RTC_GUARDED_BY(volume_settings_mutex_) = false;
bool previous_frame_muted_ RTC_GUARDED_BY(encoder_queue_checker_) = false;
bool tmmbr = false;
+ const std::unique_ptr<RtcpCounterObserver> rtcp_counter_observer_;
+
PacketRouter* packet_router_ RTC_GUARDED_BY(&worker_thread_checker_) =
nullptr;
const std::unique_ptr<RtpPacketSenderProxy> rtp_packet_pacer_proxy_;
@@ -472,6 +499,7 @@ ChannelSend::ChannelSend(
RtpTransportControllerSendInterface* transport_controller)
: env_(env),
ssrc_(ssrc),
+ rtcp_counter_observer_(new RtcpCounterObserver(ssrc)),
rtp_packet_pacer_proxy_(new RtpPacketSenderProxy()),
retransmission_rate_limiter_(
new RateLimiter(&env_.clock(), kMaxRetransmissionWindowMs)),
@@ -493,6 +521,8 @@ ChannelSend::ChannelSend(
configuration.paced_sender = rtp_packet_pacer_proxy_.get();
configuration.rtt_stats = rtcp_rtt_stats;
+ configuration.rtcp_packet_type_counter_observer =
+ rtcp_counter_observer_.get();
if (env_.field_trials().IsDisabled("WebRTC-DisableRtxRateLimiter")) {
configuration.retransmission_rate_limiter =
retransmission_rate_limiter_.get();
@@ -760,6 +790,7 @@ CallSendStatistics ChannelSend::GetRTCPStatistics() const {
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
CallSendStatistics stats = {0};
stats.rttMs = GetRTT();
+ stats.rtcp_packet_type_counts = rtcp_counter_observer_->GetCounts();
StreamDataCounters rtp_stats;
StreamDataCounters rtx_stats;
diff --git a/audio/channel_send.h b/audio/channel_send.h
index 02215e49cb..a1b09feb5e 100644
--- a/audio/channel_send.h
+++ b/audio/channel_send.h
@@ -41,6 +41,7 @@ struct CallSendStatistics {
TimeDelta total_packet_send_delay = TimeDelta::Zero();
// https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-retransmittedpacketssent
uint64_t retransmitted_packets_sent;
+ RtcpPacketTypeCounter rtcp_packet_type_counts;
// A snapshot of Report Blocks with additional data of interest to statistics.
// Within this list, the sender-source SSRC pair is unique and per-pair the
// ReportBlockData represents the latest Report Block that was received for
diff --git a/call/audio_send_stream.h b/call/audio_send_stream.h
index c60526771e..949bb32a88 100644
--- a/call/audio_send_stream.h
+++ b/call/audio_send_stream.h
@@ -32,6 +32,7 @@
#include "api/units/time_delta.h"
#include "call/audio_sender.h"
#include "modules/rtp_rtcp/include/report_block_data.h"
+#include "modules/rtp_rtcp/include/rtcp_statistics.h"
namespace webrtc {
@@ -66,6 +67,7 @@ class AudioSendStream : public AudioSender {
ANAStats ana_statistics;
AudioProcessingStats apm_statistics;
+ RtcpPacketTypeCounter rtcp_packet_type_counts;
int64_t target_bitrate_bps = 0;
// A snapshot of Report Blocks with additional data of interest to
// See LntfConfig for description.
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index d6c859f535..23c3d3f6eb 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -1244,7 +1244,7 @@ void RtpVideoStreamReceiver2::StartReceive() {
// Change REMB candidate egibility.
packet_router_->RemoveReceiveRtpModule(rtp_rtcp_.get());
packet_router_->AddReceiveRtpModule(rtp_rtcp_.get(),
- /*remb_candidate=*/true);
+ /*remb_candidate=*/config_.rtp.remb);
}
receiving_ = true;
}

View File

@ -1,39 +1,38 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Fri, 19 Feb 2021 13:45:00 +0100
Subject: Bug 1654112 - libwebrtc: Add a REMB on/off switch to
VideoReceiveStream. r=ng
From: Nico Grunbaum <na-g@nostrum.com>
Date: Wed, 10 Feb 2021 12:24:00 -0800
Subject: Bug 1654112 - Use newer thread run callback, and adapt
PlatformUIThread; r=pehrsons
Differential Revision: https://phabricator.services.mozilla.com/D105774
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/7330681cf4de6d8dd868cc661cbdd6679bbc07b3
Differential Revision: https://phabricator.services.mozilla.com/D107879
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/bb6417a4cfac1416a8e2565bd68b66c40be4827b
---
call/video_receive_stream.h | 3 +++
video/rtp_video_stream_receiver2.cc | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
rtc_base/platform_thread.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index f69b03a166..f68368567c 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -236,6 +236,9 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
// disabled.
KeyFrameReqMethod keyframe_method = KeyFrameReqMethod::kPliRtcp;
diff --git a/rtc_base/platform_thread.h b/rtc_base/platform_thread.h
index cfc9d17af4..eeaa052d27 100644
--- a/rtc_base/platform_thread.h
+++ b/rtc_base/platform_thread.h
@@ -22,8 +22,13 @@
#include "absl/strings/string_view.h"
#include "rtc_base/platform_thread_types.h"
+ // See draft-alvestrand-rmcat-remb for information.
+ bool remb = false;
+#include "rtc_base/deprecated/recursive_critical_section.h"
+
bool tmmbr = false;
namespace rtc {
// See LntfConfig for description.
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index d6c859f535..23c3d3f6eb 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -1244,7 +1244,7 @@ void RtpVideoStreamReceiver2::StartReceive() {
// Change REMB candidate egibility.
packet_router_->RemoveReceiveRtpModule(rtp_rtcp_.get());
packet_router_->AddReceiveRtpModule(rtp_rtcp_.get(),
- /*remb_candidate=*/true);
+ /*remb_candidate=*/config_.rtp.remb);
}
receiving_ = true;
}
+// Bug 1691641
+class PlatformUIThread;
+
enum class ThreadPriority {
kLow = 1,
kNormal,
@@ -114,6 +119,8 @@ class PlatformThread final {
std::optional<Handle> handle_;
bool joinable_ = false;
+ // Bug 1691641
+ friend PlatformUIThread;
};
} // namespace rtc

View File

@ -1,38 +1,54 @@
From: Nico Grunbaum <na-g@nostrum.com>
Date: Wed, 10 Feb 2021 12:24:00 -0800
Subject: Bug 1654112 - Use newer thread run callback, and adapt
PlatformUIThread; r=pehrsons
Date: Thu, 18 Feb 2021 17:23:00 -0800
Subject: Bug 1654112 - fix device_info_ds pid and Windows constants includes;
r=pehrsons
Differential Revision: https://phabricator.services.mozilla.com/D107879
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/bb6417a4cfac1416a8e2565bd68b66c40be4827b
Upstreaming bug 1697385
Differential Revision: https://phabricator.services.mozilla.com/D107899
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/24809d566449907edea49ea47528065ad0f76910
---
rtc_base/platform_thread.h | 7 +++++++
1 file changed, 7 insertions(+)
modules/video_capture/windows/device_info_ds.cc | 3 ++-
modules/video_capture/windows/device_info_ds.h | 6 +++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/rtc_base/platform_thread.h b/rtc_base/platform_thread.h
index cfc9d17af4..eeaa052d27 100644
--- a/rtc_base/platform_thread.h
+++ b/rtc_base/platform_thread.h
@@ -22,8 +22,13 @@
#include "absl/strings/string_view.h"
#include "rtc_base/platform_thread_types.h"
diff --git a/modules/video_capture/windows/device_info_ds.cc b/modules/video_capture/windows/device_info_ds.cc
index 9d22f42f4d..f6927281f3 100644
--- a/modules/video_capture/windows/device_info_ds.cc
+++ b/modules/video_capture/windows/device_info_ds.cc
@@ -172,7 +172,8 @@ int32_t DeviceInfoDS::GetDeviceName(uint32_t deviceNumber,
char* deviceUniqueIdUTF8,
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8,
- uint32_t productUniqueIdUTF8Length) {
+ uint32_t productUniqueIdUTF8Length,
+ pid_t* pid) {
MutexLock lock(&_apiLock);
const int32_t result = GetDeviceInfo(
deviceNumber, deviceNameUTF8, deviceNameLength, deviceUniqueIdUTF8,
diff --git a/modules/video_capture/windows/device_info_ds.h b/modules/video_capture/windows/device_info_ds.h
index ed2a726d6f..e6dfaed366 100644
--- a/modules/video_capture/windows/device_info_ds.h
+++ b/modules/video_capture/windows/device_info_ds.h
@@ -12,8 +12,11 @@
#define MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_DEVICE_INFO_DS_H_
+#include "rtc_base/deprecated/recursive_critical_section.h"
+
namespace rtc {
#include <dshow.h>
+#include <Ks.h>
+#include <dbt.h>
+// Bug 1691641
+class PlatformUIThread;
+
enum class ThreadPriority {
kLow = 1,
kNormal,
@@ -114,6 +119,8 @@ class PlatformThread final {
#include "modules/video_capture/device_info_impl.h"
+#include "modules/video_capture/video_capture.h"
#include "modules/video_capture/video_capture_impl.h"
std::optional<Handle> handle_;
bool joinable_ = false;
+ // Bug 1691641
+ friend PlatformUIThread;
};
namespace webrtc {
@@ -47,7 +50,8 @@ class DeviceInfoDS : public DeviceInfoImpl {
char* deviceUniqueIdUTF8,
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8,
- uint32_t productUniqueIdUTF8Length) override;
+ uint32_t productUniqueIdUTF8Length,
+ pid_t* pid) override;
} // namespace rtc
/*
* Display OS /capture device specific settings dialog

View File

@ -1,54 +1,47 @@
From: Nico Grunbaum <na-g@nostrum.com>
Date: Thu, 18 Feb 2021 17:23:00 -0800
Subject: Bug 1654112 - fix device_info_ds pid and Windows constants includes;
r=pehrsons
From: "Byron Campen [:bwc]" <docfaraday@gmail.com>
Date: Thu, 29 Apr 2021 18:25:00 +0000
Subject: Bug 1654112 - Work around the old (<1.5) libxrandr headers on our
build machines. r=mjf,ng
Upstreaming bug 1697385
Differential Revision: https://phabricator.services.mozilla.com/D107899
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/24809d566449907edea49ea47528065ad0f76910
Differential Revision: https://phabricator.services.mozilla.com/D113830
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c91f12b557a1d23b468c75c4f2fc00eb0f8d541a
---
modules/video_capture/windows/device_info_ds.cc | 3 ++-
modules/video_capture/windows/device_info_ds.h | 6 +++++-
2 files changed, 7 insertions(+), 2 deletions(-)
X11/extensions/Xrandr.h | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
create mode 100644 X11/extensions/Xrandr.h
diff --git a/modules/video_capture/windows/device_info_ds.cc b/modules/video_capture/windows/device_info_ds.cc
index 9d22f42f4d..f6927281f3 100644
--- a/modules/video_capture/windows/device_info_ds.cc
+++ b/modules/video_capture/windows/device_info_ds.cc
@@ -172,7 +172,8 @@ int32_t DeviceInfoDS::GetDeviceName(uint32_t deviceNumber,
char* deviceUniqueIdUTF8,
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8,
- uint32_t productUniqueIdUTF8Length) {
+ uint32_t productUniqueIdUTF8Length,
+ pid_t* pid) {
MutexLock lock(&_apiLock);
const int32_t result = GetDeviceInfo(
deviceNumber, deviceNameUTF8, deviceNameLength, deviceUniqueIdUTF8,
diff --git a/modules/video_capture/windows/device_info_ds.h b/modules/video_capture/windows/device_info_ds.h
index ed2a726d6f..e6dfaed366 100644
--- a/modules/video_capture/windows/device_info_ds.h
+++ b/modules/video_capture/windows/device_info_ds.h
@@ -12,8 +12,11 @@
#define MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_DEVICE_INFO_DS_H_
#include <dshow.h>
+#include <Ks.h>
+#include <dbt.h>
#include "modules/video_capture/device_info_impl.h"
+#include "modules/video_capture/video_capture.h"
#include "modules/video_capture/video_capture_impl.h"
namespace webrtc {
@@ -47,7 +50,8 @@ class DeviceInfoDS : public DeviceInfoImpl {
char* deviceUniqueIdUTF8,
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8,
- uint32_t productUniqueIdUTF8Length) override;
+ uint32_t productUniqueIdUTF8Length,
+ pid_t* pid) override;
/*
* Display OS /capture device specific settings dialog
diff --git a/X11/extensions/Xrandr.h b/X11/extensions/Xrandr.h
new file mode 100644
index 0000000000..876e8b4c7f
--- /dev/null
+++ b/X11/extensions/Xrandr.h
@@ -0,0 +1,29 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// Hack to compensate for the old (<1.5) Xrandr development headers on
+// Mozilla's build boxes.
+
+#ifndef _XRANDR_H_WRAPPER_HACK_
+#define _XRANDR_H_WRAPPER_HACK_
+
+#include_next <X11/extensions/Xrandr.h>
+
+#if RANDR_MAJOR == 1 && RANDR_MINOR < 5 // defined in randr.h
+typedef struct _XRRMonitorInfo {
+ Atom name;
+ Bool primary;
+ Bool automatic;
+ int noutput;
+ int x;
+ int y;
+ int width;
+ int height;
+ int mwidth;
+ int mheight;
+ RROutput *outputs;
+} XRRMonitorInfo;
+#endif
+
+#endif // _XRANDR_H_WRAPPER_HACK_

View File

@ -1,47 +1,62 @@
From: "Byron Campen [:bwc]" <docfaraday@gmail.com>
Date: Thu, 29 Apr 2021 18:25:00 +0000
Subject: Bug 1654112 - Work around the old (<1.5) libxrandr headers on our
build machines. r=mjf,ng
From: Michael Froman <mfroman@mozilla.com>
Date: Fri, 16 Apr 2021 17:35:00 -0500
Subject: Bug 1654112 - General build fixes for paths and naming changes. r=ng
Differential Revision: https://phabricator.services.mozilla.com/D113830
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c91f12b557a1d23b468c75c4f2fc00eb0f8d541a
Differential Revision: https://phabricator.services.mozilla.com/D113438
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/99b99cca6b7b2c2ebffb5472457a4f927bda11c4
---
X11/extensions/Xrandr.h | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
create mode 100644 X11/extensions/Xrandr.h
modules/video_capture/video_capture_impl.h | 6 ++++--
rtc_base/system/warn_current_thread_is_deadlocked.h | 2 +-
sdk/android/api/org/webrtc/VideoCodecInfo.java | 2 +-
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/X11/extensions/Xrandr.h b/X11/extensions/Xrandr.h
new file mode 100644
index 0000000000..876e8b4c7f
--- /dev/null
+++ b/X11/extensions/Xrandr.h
@@ -0,0 +1,29 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
diff --git a/modules/video_capture/video_capture_impl.h b/modules/video_capture/video_capture_impl.h
index e46e050609..dcc93fd3a0 100644
--- a/modules/video_capture/video_capture_impl.h
+++ b/modules/video_capture/video_capture_impl.h
@@ -97,6 +97,10 @@ class RTC_EXPORT VideoCaptureImpl : public VideoCaptureModule {
rtc::RaceChecker capture_checker_;
// current Device unique name;
char* _deviceUniqueId RTC_GUARDED_BY(api_checker_);
+
+// Hack to compensate for the old (<1.5) Xrandr development headers on
+// Mozilla's build boxes.
+
+#ifndef _XRANDR_H_WRAPPER_HACK_
+#define _XRANDR_H_WRAPPER_HACK_
+
+#include_next <X11/extensions/Xrandr.h>
+
+#if RANDR_MAJOR == 1 && RANDR_MINOR < 5 // defined in randr.h
+typedef struct _XRRMonitorInfo {
+ Atom name;
+ Bool primary;
+ Bool automatic;
+ int noutput;
+ int x;
+ int y;
+ int width;
+ int height;
+ int mwidth;
+ int mheight;
+ RROutput *outputs;
+} XRRMonitorInfo;
+#endif
+
+#endif // _XRANDR_H_WRAPPER_HACK_
+ // moved DeliverCapturedFrame to protected for VideoCaptureAndroid (mjf)
+ int32_t DeliverCapturedFrame(VideoFrame& captureFrame)
+ RTC_EXCLUSIVE_LOCKS_REQUIRED(api_lock_);
Mutex api_lock_;
// Should be set by platform dependent code in StartCapture.
VideoCaptureCapability _requestedCapability RTC_GUARDED_BY(api_checker_);
@@ -104,8 +108,6 @@ class RTC_EXPORT VideoCaptureImpl : public VideoCaptureModule {
private:
void UpdateFrameCount();
uint32_t CalculateFrameRate(int64_t now_ns);
- int32_t DeliverCapturedFrame(VideoFrame& captureFrame)
- RTC_EXCLUSIVE_LOCKS_REQUIRED(api_lock_);
void DeliverRawFrame(uint8_t* videoFrame,
size_t videoFrameLength,
const VideoCaptureCapability& frameInfo,
diff --git a/rtc_base/system/warn_current_thread_is_deadlocked.h b/rtc_base/system/warn_current_thread_is_deadlocked.h
index 4a0ba9dc09..eac12022ed 100644
--- a/rtc_base/system/warn_current_thread_is_deadlocked.h
+++ b/rtc_base/system/warn_current_thread_is_deadlocked.h
@@ -13,7 +13,7 @@
namespace webrtc {
-#if defined(WEBRTC_ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
+#if defined(WEBRTC_ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD) && !defined(MOZ_WIDGET_ANDROID)
void WarnThatTheCurrentThreadIsProbablyDeadlocked();
#else
inline void WarnThatTheCurrentThreadIsProbablyDeadlocked() {}
diff --git a/sdk/android/api/org/webrtc/VideoCodecInfo.java b/sdk/android/api/org/webrtc/VideoCodecInfo.java
index 4f97cf74cf..363be347b5 100644
--- a/sdk/android/api/org/webrtc/VideoCodecInfo.java
+++ b/sdk/android/api/org/webrtc/VideoCodecInfo.java
@@ -80,7 +80,7 @@ public class VideoCodecInfo {
}
@CalledByNative
- Map getParams() {
+ Map<String, String> getParams() {
return params;
}
}

View File

@ -1,62 +1,35 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Fri, 16 Apr 2021 17:35:00 -0500
Subject: Bug 1654112 - General build fixes for paths and naming changes. r=ng
Date: Fri, 25 Jun 2021 15:12:00 -0500
Subject: Bug 1654112 - Mirror Bug 1714577 - Part 3 - Register WebRTC threads
with the Gecko Profiler. r=ng
Differential Revision: https://phabricator.services.mozilla.com/D113438
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/99b99cca6b7b2c2ebffb5472457a4f927bda11c4
Differential Revision: https://phabricator.services.mozilla.com/D119412
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/d881b16dd8a6813feb5ce1516c2a7ebe0270e72d
---
modules/video_capture/video_capture_impl.h | 6 ++++--
rtc_base/system/warn_current_thread_is_deadlocked.h | 2 +-
sdk/android/api/org/webrtc/VideoCodecInfo.java | 2 +-
3 files changed, 6 insertions(+), 4 deletions(-)
rtc_base/platform_thread.cc | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/modules/video_capture/video_capture_impl.h b/modules/video_capture/video_capture_impl.h
index e46e050609..dcc93fd3a0 100644
--- a/modules/video_capture/video_capture_impl.h
+++ b/modules/video_capture/video_capture_impl.h
@@ -97,6 +97,10 @@ class RTC_EXPORT VideoCaptureImpl : public VideoCaptureModule {
rtc::RaceChecker capture_checker_;
// current Device unique name;
char* _deviceUniqueId RTC_GUARDED_BY(api_checker_);
diff --git a/rtc_base/platform_thread.cc b/rtc_base/platform_thread.cc
index f75ce8c3dc..81e115b568 100644
--- a/rtc_base/platform_thread.cc
+++ b/rtc_base/platform_thread.cc
@@ -19,6 +19,8 @@
#include "rtc_base/checks.h"
+#include "MicroGeckoProfiler.h"
+
+ // moved DeliverCapturedFrame to protected for VideoCaptureAndroid (mjf)
+ int32_t DeliverCapturedFrame(VideoFrame& captureFrame)
+ RTC_EXCLUSIVE_LOCKS_REQUIRED(api_lock_);
Mutex api_lock_;
// Should be set by platform dependent code in StartCapture.
VideoCaptureCapability _requestedCapability RTC_GUARDED_BY(api_checker_);
@@ -104,8 +108,6 @@ class RTC_EXPORT VideoCaptureImpl : public VideoCaptureModule {
private:
void UpdateFrameCount();
uint32_t CalculateFrameRate(int64_t now_ns);
- int32_t DeliverCapturedFrame(VideoFrame& captureFrame)
- RTC_EXCLUSIVE_LOCKS_REQUIRED(api_lock_);
void DeliverRawFrame(uint8_t* videoFrame,
size_t videoFrameLength,
const VideoCaptureCapability& frameInfo,
diff --git a/rtc_base/system/warn_current_thread_is_deadlocked.h b/rtc_base/system/warn_current_thread_is_deadlocked.h
index 4a0ba9dc09..eac12022ed 100644
--- a/rtc_base/system/warn_current_thread_is_deadlocked.h
+++ b/rtc_base/system/warn_current_thread_is_deadlocked.h
@@ -13,7 +13,7 @@
namespace rtc {
namespace {
namespace webrtc {
-#if defined(WEBRTC_ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
+#if defined(WEBRTC_ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD) && !defined(MOZ_WIDGET_ANDROID)
void WarnThatTheCurrentThreadIsProbablyDeadlocked();
#else
inline void WarnThatTheCurrentThreadIsProbablyDeadlocked() {}
diff --git a/sdk/android/api/org/webrtc/VideoCodecInfo.java b/sdk/android/api/org/webrtc/VideoCodecInfo.java
index 4f97cf74cf..363be347b5 100644
--- a/sdk/android/api/org/webrtc/VideoCodecInfo.java
+++ b/sdk/android/api/org/webrtc/VideoCodecInfo.java
@@ -80,7 +80,7 @@ public class VideoCodecInfo {
}
@CalledByNative
- Map getParams() {
+ Map<String, String> getParams() {
return params;
}
}
@@ -183,6 +185,10 @@ PlatformThread PlatformThread::SpawnThread(
new std::function<void()>([thread_function = std::move(thread_function),
name = std::string(name), attributes] {
rtc::SetCurrentThreadName(name.c_str());
+
+ char stacktop;
+ AutoRegisterProfiler profiler(name.c_str(), &stacktop);
+
SetPriority(attributes.priority);
thread_function();
});

View File

@ -1,35 +1,297 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Fri, 25 Jun 2021 15:12:00 -0500
Subject: Bug 1654112 - Mirror Bug 1714577 - Part 3 - Register WebRTC threads
with the Gecko Profiler. r=ng
From: Nico Grunbaum <na-g@nostrum.com>
Date: Wed, 14 Jul 2021 22:26:00 +0000
Subject: Bug 1654112 - deconflate the target and host architectures in
libwebrtc build files; r=mjf
Differential Revision: https://phabricator.services.mozilla.com/D119412
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/d881b16dd8a6813feb5ce1516c2a7ebe0270e72d
Differential Revision: https://phabricator.services.mozilla.com/D119707
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/58f47eacaf10d12e21dff7362743b6f4cdd1696b
---
rtc_base/platform_thread.cc | 6 ++++++
1 file changed, 6 insertions(+)
BUILD.gn | 6 +++---
common_audio/BUILD.gn | 16 ++++++++--------
common_audio/third_party/ooura/BUILD.gn | 6 +++---
common_audio/third_party/spl_sqrt_floor/BUILD.gn | 4 ++--
modules/audio_processing/aec3/BUILD.gn | 6 +++---
modules/audio_processing/aecm/BUILD.gn | 4 ++--
modules/audio_processing/agc/BUILD.gn | 2 +-
modules/audio_processing/agc2/rnn_vad/BUILD.gn | 2 +-
modules/audio_processing/ns/BUILD.gn | 2 +-
modules/desktop_capture/BUILD.gn | 2 +-
webrtc.gni | 4 ++--
11 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/rtc_base/platform_thread.cc b/rtc_base/platform_thread.cc
index f75ce8c3dc..81e115b568 100644
--- a/rtc_base/platform_thread.cc
+++ b/rtc_base/platform_thread.cc
@@ -19,6 +19,8 @@
diff --git a/BUILD.gn b/BUILD.gn
index 0ec7001941..87881380da 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -443,12 +443,12 @@ config("common_config") {
}
}
#include "rtc_base/checks.h"
- if (current_cpu == "arm64") {
+ if (target_cpu == "arm64") {
defines += [ "WEBRTC_ARCH_ARM64" ]
defines += [ "WEBRTC_HAS_NEON" ]
}
+#include "MicroGeckoProfiler.h"
+
namespace rtc {
namespace {
- if (current_cpu == "arm") {
+ if (target_cpu == "arm") {
defines += [ "WEBRTC_ARCH_ARM" ]
if (arm_version >= 7) {
defines += [ "WEBRTC_ARCH_ARM_V7" ]
@@ -458,7 +458,7 @@ config("common_config") {
}
}
@@ -183,6 +185,10 @@ PlatformThread PlatformThread::SpawnThread(
new std::function<void()>([thread_function = std::move(thread_function),
name = std::string(name), attributes] {
rtc::SetCurrentThreadName(name.c_str());
+
+ char stacktop;
+ AutoRegisterProfiler profiler(name.c_str(), &stacktop);
+
SetPriority(attributes.priority);
thread_function();
});
- if (current_cpu == "mipsel") {
+ if (target_cpu == "mipsel") {
defines += [ "MIPS32_LE" ]
if (mips_float_abi == "hard") {
defines += [ "MIPS_FPU_LE" ]
diff --git a/common_audio/BUILD.gn b/common_audio/BUILD.gn
index 66895ccd0e..f6d06f6ad9 100644
--- a/common_audio/BUILD.gn
+++ b/common_audio/BUILD.gn
@@ -66,7 +66,7 @@ rtc_library("common_audio") {
deps += [ ":common_audio_neon" ]
}
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (target_cpu == "x86" || target_cpu == "x64") {
deps += [ ":common_audio_sse2" ]
deps += [ ":common_audio_avx2" ]
}
@@ -88,7 +88,7 @@ rtc_source_set("mock_common_audio") {
rtc_source_set("common_audio_c_arm_asm") {
sources = []
deps = []
- if (current_cpu == "arm") {
+ if (target_cpu == "arm") {
sources += [ "signal_processing/complex_bit_reverse_arm.S" ]
if (arm_version >= 7) {
@@ -152,7 +152,7 @@ rtc_library("common_audio_c") {
"vad/webrtc_vad.c",
]
- if (current_cpu == "mipsel") {
+ if (target_cpu == "mipsel") {
sources += [
"signal_processing/complex_bit_reverse_mips.c",
"signal_processing/complex_fft_mips.c",
@@ -170,7 +170,7 @@ rtc_library("common_audio_c") {
sources += [ "signal_processing/complex_fft.c" ]
}
- if (current_cpu != "arm" && current_cpu != "mipsel") {
+ if (target_cpu != "arm" && target_cpu != "mipsel") {
sources += [
"signal_processing/complex_bit_reverse.c",
"signal_processing/filter_ar_fast_q12.c",
@@ -231,7 +231,7 @@ rtc_library("fir_filter_factory") {
"../rtc_base/system:arch",
"../system_wrappers",
]
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (target_cpu == "x86" || target_cpu == "x64") {
deps += [ ":common_audio_sse2" ]
deps += [ ":common_audio_avx2" ]
}
@@ -240,7 +240,7 @@ rtc_library("fir_filter_factory") {
}
}
-if (current_cpu == "x86" || current_cpu == "x64") {
+if (target_cpu == "x86" || target_cpu == "x64") {
rtc_library("common_audio_sse2") {
sources = [
"fir_filter_sse.cc",
@@ -289,7 +289,7 @@ if (rtc_build_with_neon) {
"resampler/sinc_resampler_neon.cc",
]
- if (current_cpu != "arm64") {
+ if (target_cpu != "arm64") {
# Enable compilation for the NEON instruction set.
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
@@ -312,7 +312,7 @@ if (rtc_build_with_neon) {
"signal_processing/min_max_operations_neon.c",
]
- if (current_cpu != "arm64") {
+ if (target_cpu != "arm64") {
# Enable compilation for the NEON instruction set.
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
diff --git a/common_audio/third_party/ooura/BUILD.gn b/common_audio/third_party/ooura/BUILD.gn
index 0cdf98e591..a0ddf777db 100644
--- a/common_audio/third_party/ooura/BUILD.gn
+++ b/common_audio/third_party/ooura/BUILD.gn
@@ -20,7 +20,7 @@ rtc_library("fft_size_128") {
]
cflags = []
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (target_cpu == "x86" || target_cpu == "x64") {
sources += [
"fft_size_128/ooura_fft_sse2.cc",
"fft_size_128/ooura_fft_tables_neon_sse2.h",
@@ -38,14 +38,14 @@ rtc_library("fft_size_128") {
deps += [ "../../../common_audio" ]
- if (current_cpu != "arm64") {
+ if (target_cpu != "arm64") {
# Enable compilation for the NEON instruction set.
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags += [ "-mfpu=neon" ]
}
}
- if (current_cpu == "mipsel" && mips_float_abi == "hard") {
+ if (target_cpu == "mipsel" && mips_float_abi == "hard") {
sources += [ "fft_size_128/ooura_fft_mips.cc" ]
}
}
diff --git a/common_audio/third_party/spl_sqrt_floor/BUILD.gn b/common_audio/third_party/spl_sqrt_floor/BUILD.gn
index ac862c65a8..e66ed2796e 100644
--- a/common_audio/third_party/spl_sqrt_floor/BUILD.gn
+++ b/common_audio/third_party/spl_sqrt_floor/BUILD.gn
@@ -12,11 +12,11 @@ rtc_library("spl_sqrt_floor") {
visibility = [ "../..:common_audio_c" ]
sources = [ "spl_sqrt_floor.h" ]
deps = []
- if (current_cpu == "arm") {
+ if (target_cpu == "arm") {
sources += [ "spl_sqrt_floor_arm.S" ]
deps += [ "../../../rtc_base/system:asm_defines" ]
- } else if (current_cpu == "mipsel") {
+ } else if (target_cpu == "mipsel") {
sources += [ "spl_sqrt_floor_mips.c" ]
} else {
sources += [ "spl_sqrt_floor.c" ]
diff --git a/modules/audio_processing/aec3/BUILD.gn b/modules/audio_processing/aec3/BUILD.gn
index 39e24c9324..411c0d27ca 100644
--- a/modules/audio_processing/aec3/BUILD.gn
+++ b/modules/audio_processing/aec3/BUILD.gn
@@ -123,7 +123,7 @@ rtc_library("aec3") {
]
defines = []
- if (rtc_build_with_neon && current_cpu != "arm64") {
+ if (rtc_build_with_neon && target_cpu != "arm64") {
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
}
@@ -159,7 +159,7 @@ rtc_library("aec3") {
"//third_party/abseil-cpp/absl/strings:string_view",
]
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (target_cpu == "x86" || target_cpu == "x64") {
deps += [ ":aec3_avx2" ]
}
}
@@ -249,7 +249,7 @@ rtc_source_set("fft_data") {
]
}
-if (current_cpu == "x86" || current_cpu == "x64") {
+if (target_cpu == "x86" || target_cpu == "x64") {
rtc_library("aec3_avx2") {
configs += [ "..:apm_debug_dump" ]
sources = [
diff --git a/modules/audio_processing/aecm/BUILD.gn b/modules/audio_processing/aecm/BUILD.gn
index 80f2901049..a77f04aba5 100644
--- a/modules/audio_processing/aecm/BUILD.gn
+++ b/modules/audio_processing/aecm/BUILD.gn
@@ -29,14 +29,14 @@ rtc_library("aecm_core") {
if (rtc_build_with_neon) {
sources += [ "aecm_core_neon.cc" ]
- if (current_cpu != "arm64") {
+ if (target_cpu != "arm64") {
# Enable compilation for the NEON instruction set.
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags += [ "-mfpu=neon" ]
}
}
- if (current_cpu == "mipsel") {
+ if (target_cpu == "mipsel") {
sources += [ "aecm_core_mips.cc" ]
} else {
sources += [ "aecm_core_c.cc" ]
diff --git a/modules/audio_processing/agc/BUILD.gn b/modules/audio_processing/agc/BUILD.gn
index f5bb27217a..b8363ad79e 100644
--- a/modules/audio_processing/agc/BUILD.gn
+++ b/modules/audio_processing/agc/BUILD.gn
@@ -82,7 +82,7 @@ rtc_library("legacy_agc") {
]
if (rtc_build_with_neon) {
- if (current_cpu != "arm64") {
+ if (target_cpu != "arm64") {
# Enable compilation for the NEON instruction set.
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
diff --git a/modules/audio_processing/agc2/rnn_vad/BUILD.gn b/modules/audio_processing/agc2/rnn_vad/BUILD.gn
index 47b9466a44..f99fe509d1 100644
--- a/modules/audio_processing/agc2/rnn_vad/BUILD.gn
+++ b/modules/audio_processing/agc2/rnn_vad/BUILD.gn
@@ -18,7 +18,7 @@ rtc_library("rnn_vad") {
]
defines = []
- if (rtc_build_with_neon && current_cpu != "arm64") {
+ if (rtc_build_with_neon && target_cpu != "arm64") {
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
}
diff --git a/modules/audio_processing/ns/BUILD.gn b/modules/audio_processing/ns/BUILD.gn
index 31ad61156d..6587fd14f3 100644
--- a/modules/audio_processing/ns/BUILD.gn
+++ b/modules/audio_processing/ns/BUILD.gn
@@ -43,7 +43,7 @@ rtc_static_library("ns") {
]
defines = []
- if (rtc_build_with_neon && current_cpu != "arm64") {
+ if (rtc_build_with_neon && target_cpu != "arm64") {
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
}
diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn
index e39700419d..1047f30ee4 100644
--- a/modules/desktop_capture/BUILD.gn
+++ b/modules/desktop_capture/BUILD.gn
@@ -10,7 +10,7 @@ import("//build/config/linux/gtk/gtk.gni")
import("//build/config/ui.gni")
import("../../webrtc.gni")
-use_desktop_capture_differ_sse2 = current_cpu == "x86" || current_cpu == "x64"
+use_desktop_capture_differ_sse2 = target_cpu == "x86" || target_cpu == "x64"
config("x11_config") {
if (rtc_use_x11_extensions) {
diff --git a/webrtc.gni b/webrtc.gni
index 98c1dd279f..156c3d3985 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -172,13 +172,13 @@ declare_args() {
# Selects fixed-point code where possible.
rtc_prefer_fixed_point = false
- if (current_cpu == "arm" || current_cpu == "arm64") {
+ if (target_cpu == "arm" || target_cpu == "arm64") {
rtc_prefer_fixed_point = true
}
# Determines whether NEON code will be built.
rtc_build_with_neon =
- (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
+ (target_cpu == "arm" && arm_use_neon) || target_cpu == "arm64"
# Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
# all platforms except Android and iOS. Because FFmpeg can be built

View File

@ -1,297 +1,300 @@
From: Nico Grunbaum <na-g@nostrum.com>
Date: Wed, 14 Jul 2021 22:26:00 +0000
Subject: Bug 1654112 - deconflate the target and host architectures in
libwebrtc build files; r=mjf
From: "Byron Campen [:bwc]" <docfaraday@gmail.com>
Date: Fri, 19 Feb 2021 15:56:00 -0600
Subject: Bug 1654112 - Get RTCP BYE and RTP timeout handling working again
(from Bug 1595479) r=mjf,dminor
Differential Revision: https://phabricator.services.mozilla.com/D119707
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/58f47eacaf10d12e21dff7362743b6f4cdd1696b
Differential Revision: https://phabricator.services.mozilla.com/D106145
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/d0b311007c033e83824f5f6996a70ab9e870f31f
---
BUILD.gn | 6 +++---
common_audio/BUILD.gn | 16 ++++++++--------
common_audio/third_party/ooura/BUILD.gn | 6 +++---
common_audio/third_party/spl_sqrt_floor/BUILD.gn | 4 ++--
modules/audio_processing/aec3/BUILD.gn | 6 +++---
modules/audio_processing/aecm/BUILD.gn | 4 ++--
modules/audio_processing/agc/BUILD.gn | 2 +-
modules/audio_processing/agc2/rnn_vad/BUILD.gn | 2 +-
modules/audio_processing/ns/BUILD.gn | 2 +-
modules/desktop_capture/BUILD.gn | 2 +-
webrtc.gni | 4 ++--
11 files changed, 27 insertions(+), 27 deletions(-)
audio/audio_receive_stream.cc | 4 +++-
audio/channel_receive.cc | 12 ++++++++----
audio/channel_receive.h | 4 +++-
call/audio_receive_stream.h | 3 +++
call/video_receive_stream.cc | 2 ++
call/video_receive_stream.h | 3 +++
modules/rtp_rtcp/include/rtp_rtcp_defines.h | 8 ++++++++
modules/rtp_rtcp/source/rtcp_receiver.cc | 18 ++++++++++++++++--
modules/rtp_rtcp/source/rtcp_receiver.h | 1 +
modules/rtp_rtcp/source/rtp_rtcp_interface.h | 3 +++
video/rtp_video_stream_receiver2.cc | 7 +++++--
11 files changed, 55 insertions(+), 10 deletions(-)
diff --git a/BUILD.gn b/BUILD.gn
index 0ec7001941..87881380da 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -443,12 +443,12 @@ config("common_config") {
}
}
diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc
index bf2da5dd18..cd6ed5fbdd 100644
--- a/audio/audio_receive_stream.cc
+++ b/audio/audio_receive_stream.cc
@@ -43,6 +43,8 @@ std::string AudioReceiveStreamInterface::Config::Rtp::ToString() const {
<< (rtcp_mode == RtcpMode::kCompound
? "compound"
: (rtcp_mode == RtcpMode::kReducedSize ? "reducedSize" : "off"));
+ ss << ", rtcp_event_observer: "
+ << (rtcp_event_observer ? "(rtcp_event_observer)" : "nullptr");
ss << '}';
return ss.str();
}
@@ -76,7 +78,7 @@ std::unique_ptr<voe::ChannelReceiveInterface> CreateChannelReceive(
config.jitter_buffer_min_delay_ms, config.enable_non_sender_rtt,
config.decoder_factory, config.codec_pair_id,
std::move(config.frame_decryptor), config.crypto_options,
- std::move(config.frame_transformer));
+ std::move(config.frame_transformer), config.rtp.rtcp_event_observer);
}
} // namespace
- if (current_cpu == "arm64") {
+ if (target_cpu == "arm64") {
defines += [ "WEBRTC_ARCH_ARM64" ]
defines += [ "WEBRTC_HAS_NEON" ]
}
diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc
index ca5f916ea4..9559683041 100644
--- a/audio/channel_receive.cc
+++ b/audio/channel_receive.cc
@@ -109,7 +109,8 @@ class ChannelReceive : public ChannelReceiveInterface,
std::optional<AudioCodecPairId> codec_pair_id,
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor,
const webrtc::CryptoOptions& crypto_options,
- rtc::scoped_refptr<FrameTransformerInterface> frame_transformer);
+ rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
+ RtcpEventObserver* rtcp_event_observer);
~ChannelReceive() override;
- if (current_cpu == "arm") {
+ if (target_cpu == "arm") {
defines += [ "WEBRTC_ARCH_ARM" ]
if (arm_version >= 7) {
defines += [ "WEBRTC_ARCH_ARM_V7" ]
@@ -458,7 +458,7 @@ config("common_config") {
}
}
void SetSink(AudioSinkInterface* sink) override;
@@ -553,7 +554,8 @@ ChannelReceive::ChannelReceive(
std::optional<AudioCodecPairId> codec_pair_id,
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor,
const webrtc::CryptoOptions& crypto_options,
- rtc::scoped_refptr<FrameTransformerInterface> frame_transformer)
+ rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
+ RtcpEventObserver* rtcp_event_observer)
: env_(env),
worker_thread_(TaskQueueBase::Current()),
rtp_receive_statistics_(ReceiveStatistics::Create(&env_.clock())),
@@ -591,6 +593,7 @@ ChannelReceive::ChannelReceive(
configuration.local_media_ssrc = local_ssrc;
configuration.rtcp_packet_type_counter_observer = this;
configuration.non_sender_rtt_measurement = enable_non_sender_rtt;
+ configuration.rtcp_event_observer = rtcp_event_observer;
- if (current_cpu == "mipsel") {
+ if (target_cpu == "mipsel") {
defines += [ "MIPS32_LE" ]
if (mips_float_abi == "hard") {
defines += [ "MIPS_FPU_LE" ]
diff --git a/common_audio/BUILD.gn b/common_audio/BUILD.gn
index 66895ccd0e..f6d06f6ad9 100644
--- a/common_audio/BUILD.gn
+++ b/common_audio/BUILD.gn
@@ -66,7 +66,7 @@ rtc_library("common_audio") {
deps += [ ":common_audio_neon" ]
}
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (target_cpu == "x86" || target_cpu == "x64") {
deps += [ ":common_audio_sse2" ]
deps += [ ":common_audio_avx2" ]
}
@@ -88,7 +88,7 @@ rtc_source_set("mock_common_audio") {
rtc_source_set("common_audio_c_arm_asm") {
sources = []
deps = []
- if (current_cpu == "arm") {
+ if (target_cpu == "arm") {
sources += [ "signal_processing/complex_bit_reverse_arm.S" ]
if (arm_version >= 7) {
@@ -152,7 +152,7 @@ rtc_library("common_audio_c") {
"vad/webrtc_vad.c",
]
- if (current_cpu == "mipsel") {
+ if (target_cpu == "mipsel") {
sources += [
"signal_processing/complex_bit_reverse_mips.c",
"signal_processing/complex_fft_mips.c",
@@ -170,7 +170,7 @@ rtc_library("common_audio_c") {
sources += [ "signal_processing/complex_fft.c" ]
}
- if (current_cpu != "arm" && current_cpu != "mipsel") {
+ if (target_cpu != "arm" && target_cpu != "mipsel") {
sources += [
"signal_processing/complex_bit_reverse.c",
"signal_processing/filter_ar_fast_q12.c",
@@ -231,7 +231,7 @@ rtc_library("fir_filter_factory") {
"../rtc_base/system:arch",
"../system_wrappers",
]
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (target_cpu == "x86" || target_cpu == "x64") {
deps += [ ":common_audio_sse2" ]
deps += [ ":common_audio_avx2" ]
}
@@ -240,7 +240,7 @@ rtc_library("fir_filter_factory") {
}
if (frame_transformer)
InitFrameTransformerDelegate(std::move(frame_transformer));
@@ -1214,13 +1217,14 @@ std::unique_ptr<ChannelReceiveInterface> CreateChannelReceive(
std::optional<AudioCodecPairId> codec_pair_id,
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor,
const webrtc::CryptoOptions& crypto_options,
- rtc::scoped_refptr<FrameTransformerInterface> frame_transformer) {
+ rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
+ RtcpEventObserver* rtcp_event_observer) {
return std::make_unique<ChannelReceive>(
env, neteq_factory, audio_device_module, rtcp_send_transport, local_ssrc,
remote_ssrc, jitter_buffer_max_packets, jitter_buffer_fast_playout,
jitter_buffer_min_delay_ms, enable_non_sender_rtt, decoder_factory,
codec_pair_id, std::move(frame_decryptor), crypto_options,
- std::move(frame_transformer));
+ std::move(frame_transformer), rtcp_event_observer);
}
-if (current_cpu == "x86" || current_cpu == "x64") {
+if (target_cpu == "x86" || target_cpu == "x64") {
rtc_library("common_audio_sse2") {
sources = [
"fir_filter_sse.cc",
@@ -289,7 +289,7 @@ if (rtc_build_with_neon) {
"resampler/sinc_resampler_neon.cc",
]
} // namespace voe
diff --git a/audio/channel_receive.h b/audio/channel_receive.h
index 4e2048daac..bebafc12a7 100644
--- a/audio/channel_receive.h
+++ b/audio/channel_receive.h
@@ -29,6 +29,7 @@
#include "call/rtp_packet_sink_interface.h"
#include "call/syncable.h"
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
+#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "modules/rtp_rtcp/source/source_tracker.h"
- if (current_cpu != "arm64") {
+ if (target_cpu != "arm64") {
# Enable compilation for the NEON instruction set.
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
@@ -312,7 +312,7 @@ if (rtc_build_with_neon) {
"signal_processing/min_max_operations_neon.c",
]
// TODO(solenberg, nisse): This file contains a few NOLINT marks, to silence
@@ -183,7 +184,8 @@ std::unique_ptr<ChannelReceiveInterface> CreateChannelReceive(
std::optional<AudioCodecPairId> codec_pair_id,
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor,
const webrtc::CryptoOptions& crypto_options,
- rtc::scoped_refptr<FrameTransformerInterface> frame_transformer);
+ rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
+ RtcpEventObserver* rtcp_event_observer);
- if (current_cpu != "arm64") {
+ if (target_cpu != "arm64") {
# Enable compilation for the NEON instruction set.
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
diff --git a/common_audio/third_party/ooura/BUILD.gn b/common_audio/third_party/ooura/BUILD.gn
index 0cdf98e591..a0ddf777db 100644
--- a/common_audio/third_party/ooura/BUILD.gn
+++ b/common_audio/third_party/ooura/BUILD.gn
@@ -20,7 +20,7 @@ rtc_library("fft_size_128") {
]
cflags = []
} // namespace voe
} // namespace webrtc
diff --git a/call/audio_receive_stream.h b/call/audio_receive_stream.h
index d91e68caa9..3200c68817 100644
--- a/call/audio_receive_stream.h
+++ b/call/audio_receive_stream.h
@@ -21,6 +21,7 @@
#include "api/audio_codecs/audio_decoder_factory.h"
#include "api/audio_codecs/audio_format.h"
#include "api/call/transport.h"
+#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "api/crypto/crypto_options.h"
#include "api/crypto/frame_decryptor_interface.h"
#include "api/frame_transformer_interface.h"
@@ -126,6 +127,8 @@ class AudioReceiveStreamInterface : public MediaReceiveStreamInterface {
// See NackConfig for description.
NackConfig nack;
RtcpMode rtcp_mode = RtcpMode::kCompound;
+
+ RtcpEventObserver* rtcp_event_observer = nullptr;
} rtp;
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (target_cpu == "x86" || target_cpu == "x64") {
sources += [
"fft_size_128/ooura_fft_sse2.cc",
"fft_size_128/ooura_fft_tables_neon_sse2.h",
@@ -38,14 +38,14 @@ rtc_library("fft_size_128") {
deps += [ "../../../common_audio" ]
- if (current_cpu != "arm64") {
+ if (target_cpu != "arm64") {
# Enable compilation for the NEON instruction set.
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags += [ "-mfpu=neon" ]
}
}
- if (current_cpu == "mipsel" && mips_float_abi == "hard") {
+ if (target_cpu == "mipsel" && mips_float_abi == "hard") {
sources += [ "fft_size_128/ooura_fft_mips.cc" ]
// Receive-side RTT.
diff --git a/call/video_receive_stream.cc b/call/video_receive_stream.cc
index c03b053113..04e34ff579 100644
--- a/call/video_receive_stream.cc
+++ b/call/video_receive_stream.cc
@@ -169,6 +169,8 @@ std::string VideoReceiveStreamInterface::Config::Rtp::ToString() const {
ss << pt << ", ";
}
ss << '}';
+ ss << ", rtcp_event_observer: "
+ << (rtcp_event_observer ? "(rtcp_event_observer)" : "nullptr");
ss << '}';
return ss.str();
}
diff --git a/common_audio/third_party/spl_sqrt_floor/BUILD.gn b/common_audio/third_party/spl_sqrt_floor/BUILD.gn
index ac862c65a8..e66ed2796e 100644
--- a/common_audio/third_party/spl_sqrt_floor/BUILD.gn
+++ b/common_audio/third_party/spl_sqrt_floor/BUILD.gn
@@ -12,11 +12,11 @@ rtc_library("spl_sqrt_floor") {
visibility = [ "../..:common_audio_c" ]
sources = [ "spl_sqrt_floor.h" ]
deps = []
- if (current_cpu == "arm") {
+ if (target_cpu == "arm") {
sources += [ "spl_sqrt_floor_arm.S" ]
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index f68368567c..4b1bcc5227 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -22,6 +22,7 @@
#include <vector>
deps += [ "../../../rtc_base/system:asm_defines" ]
- } else if (current_cpu == "mipsel") {
+ } else if (target_cpu == "mipsel") {
sources += [ "spl_sqrt_floor_mips.c" ]
} else {
sources += [ "spl_sqrt_floor.c" ]
diff --git a/modules/audio_processing/aec3/BUILD.gn b/modules/audio_processing/aec3/BUILD.gn
index 39e24c9324..411c0d27ca 100644
--- a/modules/audio_processing/aec3/BUILD.gn
+++ b/modules/audio_processing/aec3/BUILD.gn
@@ -123,7 +123,7 @@ rtc_library("aec3") {
]
#include "api/call/transport.h"
+#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "api/crypto/crypto_options.h"
#include "api/crypto/frame_decryptor_interface.h"
#include "api/frame_transformer_interface.h"
@@ -267,6 +268,8 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
// meta data is expected to be present in generic frame descriptor
// RTP header extension).
std::set<int> raw_payload_types;
+
+ RtcpEventObserver* rtcp_event_observer = nullptr;
} rtp;
defines = []
- if (rtc_build_with_neon && current_cpu != "arm64") {
+ if (rtc_build_with_neon && target_cpu != "arm64") {
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
// Transport for outgoing packets (RTCP).
diff --git a/modules/rtp_rtcp/include/rtp_rtcp_defines.h b/modules/rtp_rtcp/include/rtp_rtcp_defines.h
index eb4d1d019c..2bdfe53ab9 100644
--- a/modules/rtp_rtcp/include/rtp_rtcp_defines.h
+++ b/modules/rtp_rtcp/include/rtp_rtcp_defines.h
@@ -184,6 +184,14 @@ class NetworkLinkRtcpObserver {
virtual void OnRttUpdate(Timestamp receive_time, TimeDelta rtt) {}
};
+class RtcpEventObserver {
+ public:
+ virtual void OnRtcpBye() = 0;
+ virtual void OnRtcpTimeout() = 0;
+
+ virtual ~RtcpEventObserver() {}
+};
+
// NOTE! `kNumMediaTypes` must be kept in sync with RtpPacketMediaType!
static constexpr size_t kNumMediaTypes = 5;
enum class RtpPacketMediaType : size_t {
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc
index 85c892767d..349a9a673e 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.cc
+++ b/modules/rtp_rtcp/source/rtcp_receiver.cc
@@ -168,6 +168,7 @@ RTCPReceiver::RTCPReceiver(const Environment& env,
rtp_rtcp_(owner),
registered_ssrcs_(false, config),
network_link_rtcp_observer_(config.network_link_rtcp_observer),
+ rtcp_event_observer_(config.rtcp_event_observer),
rtcp_intra_frame_observer_(config.intra_frame_callback),
rtcp_loss_notification_observer_(config.rtcp_loss_notification_observer),
network_state_estimate_observer_(config.network_state_estimate_observer),
@@ -198,6 +199,7 @@ RTCPReceiver::RTCPReceiver(const Environment& env,
rtp_rtcp_(owner),
registered_ssrcs_(true, config),
network_link_rtcp_observer_(config.network_link_rtcp_observer),
+ rtcp_event_observer_(config.rtcp_event_observer),
rtcp_intra_frame_observer_(config.intra_frame_callback),
rtcp_loss_notification_observer_(config.rtcp_loss_notification_observer),
network_state_estimate_observer_(config.network_state_estimate_observer),
@@ -811,6 +813,10 @@ bool RTCPReceiver::HandleBye(const CommonHeader& rtcp_block) {
return false;
}
@@ -159,7 +159,7 @@ rtc_library("aec3") {
"//third_party/abseil-cpp/absl/strings:string_view",
]
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (target_cpu == "x86" || target_cpu == "x64") {
deps += [ ":aec3_avx2" ]
}
}
@@ -249,7 +249,7 @@ rtc_source_set("fft_data") {
]
+ if (rtcp_event_observer_) {
+ rtcp_event_observer_->OnRtcpBye();
+ }
+
// Clear our lists.
rtts_.erase(bye.sender_ssrc());
EraseIf(received_report_blocks_, [&](const auto& elem) {
@@ -1248,12 +1254,20 @@ std::vector<rtcp::TmmbItem> RTCPReceiver::TmmbrReceived() {
}
-if (current_cpu == "x86" || current_cpu == "x64") {
+if (target_cpu == "x86" || target_cpu == "x64") {
rtc_library("aec3_avx2") {
configs += [ "..:apm_debug_dump" ]
sources = [
diff --git a/modules/audio_processing/aecm/BUILD.gn b/modules/audio_processing/aecm/BUILD.gn
index 80f2901049..a77f04aba5 100644
--- a/modules/audio_processing/aecm/BUILD.gn
+++ b/modules/audio_processing/aecm/BUILD.gn
@@ -29,14 +29,14 @@ rtc_library("aecm_core") {
if (rtc_build_with_neon) {
sources += [ "aecm_core_neon.cc" ]
bool RTCPReceiver::RtcpRrTimeoutLocked(Timestamp now) {
- return ResetTimestampIfExpired(now, last_received_rb_, report_interval_);
+ bool result = ResetTimestampIfExpired(now, last_received_rb_, report_interval_);
+ if (result && rtcp_event_observer_) {
+ rtcp_event_observer_->OnRtcpTimeout();
+ }
+ return result;
}
- if (current_cpu != "arm64") {
+ if (target_cpu != "arm64") {
# Enable compilation for the NEON instruction set.
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags += [ "-mfpu=neon" ]
}
}
bool RTCPReceiver::RtcpRrSequenceNumberTimeoutLocked(Timestamp now) {
- return ResetTimestampIfExpired(now, last_increased_sequence_number_,
+ bool result = ResetTimestampIfExpired(now, last_increased_sequence_number_,
report_interval_);
+ if (result && rtcp_event_observer_) {
+ rtcp_event_observer_->OnRtcpTimeout();
+ }
+ return result;
}
- if (current_cpu == "mipsel") {
+ if (target_cpu == "mipsel") {
sources += [ "aecm_core_mips.cc" ]
} else {
sources += [ "aecm_core_c.cc" ]
diff --git a/modules/audio_processing/agc/BUILD.gn b/modules/audio_processing/agc/BUILD.gn
index f5bb27217a..b8363ad79e 100644
--- a/modules/audio_processing/agc/BUILD.gn
+++ b/modules/audio_processing/agc/BUILD.gn
@@ -82,7 +82,7 @@ rtc_library("legacy_agc") {
]
} // namespace webrtc
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.h b/modules/rtp_rtcp/source/rtcp_receiver.h
index 029fc3a5e2..33aa986e8b 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.h
+++ b/modules/rtp_rtcp/source/rtcp_receiver.h
@@ -371,6 +371,7 @@ class RTCPReceiver final {
RegisteredSsrcs registered_ssrcs_;
if (rtc_build_with_neon) {
- if (current_cpu != "arm64") {
+ if (target_cpu != "arm64") {
# Enable compilation for the NEON instruction set.
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
diff --git a/modules/audio_processing/agc2/rnn_vad/BUILD.gn b/modules/audio_processing/agc2/rnn_vad/BUILD.gn
index 47b9466a44..f99fe509d1 100644
--- a/modules/audio_processing/agc2/rnn_vad/BUILD.gn
+++ b/modules/audio_processing/agc2/rnn_vad/BUILD.gn
@@ -18,7 +18,7 @@ rtc_library("rnn_vad") {
]
NetworkLinkRtcpObserver* const network_link_rtcp_observer_;
+ RtcpEventObserver* const rtcp_event_observer_;
RtcpIntraFrameObserver* const rtcp_intra_frame_observer_;
RtcpLossNotificationObserver* const rtcp_loss_notification_observer_;
NetworkStateEstimateObserver* const network_state_estimate_observer_;
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_interface.h b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
index 8ee991330f..3cfd0d4d01 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_interface.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
@@ -70,6 +70,9 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface {
// bandwidth estimation related message.
NetworkLinkRtcpObserver* network_link_rtcp_observer = nullptr;
defines = []
- if (rtc_build_with_neon && current_cpu != "arm64") {
+ if (rtc_build_with_neon && target_cpu != "arm64") {
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
}
diff --git a/modules/audio_processing/ns/BUILD.gn b/modules/audio_processing/ns/BUILD.gn
index 31ad61156d..6587fd14f3 100644
--- a/modules/audio_processing/ns/BUILD.gn
+++ b/modules/audio_processing/ns/BUILD.gn
@@ -43,7 +43,7 @@ rtc_static_library("ns") {
]
+ // Called when we receive a RTCP bye or timeout
+ RtcpEventObserver* rtcp_event_observer = nullptr;
+
NetworkStateEstimateObserver* network_state_estimate_observer = nullptr;
defines = []
- if (rtc_build_with_neon && current_cpu != "arm64") {
+ if (rtc_build_with_neon && target_cpu != "arm64") {
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
}
diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn
index e39700419d..1047f30ee4 100644
--- a/modules/desktop_capture/BUILD.gn
+++ b/modules/desktop_capture/BUILD.gn
@@ -10,7 +10,7 @@ import("//build/config/linux/gtk/gtk.gni")
import("//build/config/ui.gni")
import("../../webrtc.gni")
// DEPRECATED, transport_feedback_callback is no longer invoked by the RTP
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index 23c3d3f6eb..931c29d8c8 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -82,7 +82,8 @@ std::unique_ptr<ModuleRtpRtcpImpl2> CreateRtpRtcpModule(
RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer,
RtcpCnameCallback* rtcp_cname_callback,
bool non_sender_rtt_measurement,
- uint32_t local_ssrc) {
+ uint32_t local_ssrc,
+ RtcpEventObserver* rtcp_event_observer) {
RtpRtcpInterface::Configuration configuration;
configuration.audio = false;
configuration.receiver_only = true;
@@ -93,6 +94,7 @@ std::unique_ptr<ModuleRtpRtcpImpl2> CreateRtpRtcpModule(
rtcp_packet_type_counter_observer;
configuration.rtcp_cname_callback = rtcp_cname_callback;
configuration.local_media_ssrc = local_ssrc;
+ configuration.rtcp_event_observer = rtcp_event_observer;
configuration.non_sender_rtt_measurement = non_sender_rtt_measurement;
-use_desktop_capture_differ_sse2 = current_cpu == "x86" || current_cpu == "x64"
+use_desktop_capture_differ_sse2 = target_cpu == "x86" || target_cpu == "x64"
config("x11_config") {
if (rtc_use_x11_extensions) {
diff --git a/webrtc.gni b/webrtc.gni
index 98c1dd279f..156c3d3985 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -172,13 +172,13 @@ declare_args() {
# Selects fixed-point code where possible.
rtc_prefer_fixed_point = false
- if (current_cpu == "arm" || current_cpu == "arm64") {
+ if (target_cpu == "arm" || target_cpu == "arm64") {
rtc_prefer_fixed_point = true
}
# Determines whether NEON code will be built.
rtc_build_with_neon =
- (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
+ (target_cpu == "arm" && arm_use_neon) || target_cpu == "arm64"
# Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
# all platforms except Android and iOS. Because FFmpeg can be built
auto rtp_rtcp = std::make_unique<ModuleRtpRtcpImpl2>(env, configuration);
@@ -266,7 +268,8 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2(
rtcp_packet_type_counter_observer,
rtcp_cname_callback,
config_.rtp.rtcp_xr.receiver_reference_time_report,
- config_.rtp.local_ssrc)),
+ config_.rtp.local_ssrc,
+ config_.rtp.rtcp_event_observer)),
nack_periodic_processor_(nack_periodic_processor),
complete_frame_callback_(complete_frame_callback),
keyframe_request_method_(config_.rtp.keyframe_method),

View File

@ -1,300 +1,29 @@
From: "Byron Campen [:bwc]" <docfaraday@gmail.com>
Date: Fri, 19 Feb 2021 15:56:00 -0600
Subject: Bug 1654112 - Get RTCP BYE and RTP timeout handling working again
(from Bug 1595479) r=mjf,dminor
Date: Fri, 12 Mar 2021 08:53:00 -0600
Subject: Bug 1654112 - libwebrtc modification: Init some stats that were being
passed to us uninitialized. r=ng
Differential Revision: https://phabricator.services.mozilla.com/D106145
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/d0b311007c033e83824f5f6996a70ab9e870f31f
Differential Revision: https://phabricator.services.mozilla.com/D108673
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c385bb870413b925af48df97aa1f2b80a26e78d2
---
audio/audio_receive_stream.cc | 4 +++-
audio/channel_receive.cc | 12 ++++++++----
audio/channel_receive.h | 4 +++-
call/audio_receive_stream.h | 3 +++
call/video_receive_stream.cc | 2 ++
call/video_receive_stream.h | 3 +++
modules/rtp_rtcp/include/rtp_rtcp_defines.h | 8 ++++++++
modules/rtp_rtcp/source/rtcp_receiver.cc | 18 ++++++++++++++++--
modules/rtp_rtcp/source/rtcp_receiver.h | 1 +
modules/rtp_rtcp/source/rtp_rtcp_interface.h | 3 +++
video/rtp_video_stream_receiver2.cc | 7 +++++--
11 files changed, 55 insertions(+), 10 deletions(-)
call/video_receive_stream.h | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc
index bf2da5dd18..cd6ed5fbdd 100644
--- a/audio/audio_receive_stream.cc
+++ b/audio/audio_receive_stream.cc
@@ -43,6 +43,8 @@ std::string AudioReceiveStreamInterface::Config::Rtp::ToString() const {
<< (rtcp_mode == RtcpMode::kCompound
? "compound"
: (rtcp_mode == RtcpMode::kReducedSize ? "reducedSize" : "off"));
+ ss << ", rtcp_event_observer: "
+ << (rtcp_event_observer ? "(rtcp_event_observer)" : "nullptr");
ss << '}';
return ss.str();
}
@@ -76,7 +78,7 @@ std::unique_ptr<voe::ChannelReceiveInterface> CreateChannelReceive(
config.jitter_buffer_min_delay_ms, config.enable_non_sender_rtt,
config.decoder_factory, config.codec_pair_id,
std::move(config.frame_decryptor), config.crypto_options,
- std::move(config.frame_transformer));
+ std::move(config.frame_transformer), config.rtp.rtcp_event_observer);
}
} // namespace
diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc
index ca5f916ea4..9559683041 100644
--- a/audio/channel_receive.cc
+++ b/audio/channel_receive.cc
@@ -109,7 +109,8 @@ class ChannelReceive : public ChannelReceiveInterface,
std::optional<AudioCodecPairId> codec_pair_id,
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor,
const webrtc::CryptoOptions& crypto_options,
- rtc::scoped_refptr<FrameTransformerInterface> frame_transformer);
+ rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
+ RtcpEventObserver* rtcp_event_observer);
~ChannelReceive() override;
void SetSink(AudioSinkInterface* sink) override;
@@ -553,7 +554,8 @@ ChannelReceive::ChannelReceive(
std::optional<AudioCodecPairId> codec_pair_id,
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor,
const webrtc::CryptoOptions& crypto_options,
- rtc::scoped_refptr<FrameTransformerInterface> frame_transformer)
+ rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
+ RtcpEventObserver* rtcp_event_observer)
: env_(env),
worker_thread_(TaskQueueBase::Current()),
rtp_receive_statistics_(ReceiveStatistics::Create(&env_.clock())),
@@ -591,6 +593,7 @@ ChannelReceive::ChannelReceive(
configuration.local_media_ssrc = local_ssrc;
configuration.rtcp_packet_type_counter_observer = this;
configuration.non_sender_rtt_measurement = enable_non_sender_rtt;
+ configuration.rtcp_event_observer = rtcp_event_observer;
if (frame_transformer)
InitFrameTransformerDelegate(std::move(frame_transformer));
@@ -1214,13 +1217,14 @@ std::unique_ptr<ChannelReceiveInterface> CreateChannelReceive(
std::optional<AudioCodecPairId> codec_pair_id,
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor,
const webrtc::CryptoOptions& crypto_options,
- rtc::scoped_refptr<FrameTransformerInterface> frame_transformer) {
+ rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
+ RtcpEventObserver* rtcp_event_observer) {
return std::make_unique<ChannelReceive>(
env, neteq_factory, audio_device_module, rtcp_send_transport, local_ssrc,
remote_ssrc, jitter_buffer_max_packets, jitter_buffer_fast_playout,
jitter_buffer_min_delay_ms, enable_non_sender_rtt, decoder_factory,
codec_pair_id, std::move(frame_decryptor), crypto_options,
- std::move(frame_transformer));
+ std::move(frame_transformer), rtcp_event_observer);
}
} // namespace voe
diff --git a/audio/channel_receive.h b/audio/channel_receive.h
index 4e2048daac..bebafc12a7 100644
--- a/audio/channel_receive.h
+++ b/audio/channel_receive.h
@@ -29,6 +29,7 @@
#include "call/rtp_packet_sink_interface.h"
#include "call/syncable.h"
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
+#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "modules/rtp_rtcp/source/source_tracker.h"
// TODO(solenberg, nisse): This file contains a few NOLINT marks, to silence
@@ -183,7 +184,8 @@ std::unique_ptr<ChannelReceiveInterface> CreateChannelReceive(
std::optional<AudioCodecPairId> codec_pair_id,
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor,
const webrtc::CryptoOptions& crypto_options,
- rtc::scoped_refptr<FrameTransformerInterface> frame_transformer);
+ rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
+ RtcpEventObserver* rtcp_event_observer);
} // namespace voe
} // namespace webrtc
diff --git a/call/audio_receive_stream.h b/call/audio_receive_stream.h
index d91e68caa9..3200c68817 100644
--- a/call/audio_receive_stream.h
+++ b/call/audio_receive_stream.h
@@ -21,6 +21,7 @@
#include "api/audio_codecs/audio_decoder_factory.h"
#include "api/audio_codecs/audio_format.h"
#include "api/call/transport.h"
+#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "api/crypto/crypto_options.h"
#include "api/crypto/frame_decryptor_interface.h"
#include "api/frame_transformer_interface.h"
@@ -126,6 +127,8 @@ class AudioReceiveStreamInterface : public MediaReceiveStreamInterface {
// See NackConfig for description.
NackConfig nack;
RtcpMode rtcp_mode = RtcpMode::kCompound;
+
+ RtcpEventObserver* rtcp_event_observer = nullptr;
} rtp;
// Receive-side RTT.
diff --git a/call/video_receive_stream.cc b/call/video_receive_stream.cc
index c03b053113..04e34ff579 100644
--- a/call/video_receive_stream.cc
+++ b/call/video_receive_stream.cc
@@ -169,6 +169,8 @@ std::string VideoReceiveStreamInterface::Config::Rtp::ToString() const {
ss << pt << ", ";
}
ss << '}';
+ ss << ", rtcp_event_observer: "
+ << (rtcp_event_observer ? "(rtcp_event_observer)" : "nullptr");
ss << '}';
return ss.str();
}
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index f68368567c..4b1bcc5227 100644
index 4b1bcc5227..ef23484414 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -22,6 +22,7 @@
#include <vector>
@@ -170,9 +170,10 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
RtcpPacketTypeCounter rtcp_packet_type_counts;
std::optional<RtpReceiveStats> rtx_rtp_stats;
#include "api/call/transport.h"
+#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "api/crypto/crypto_options.h"
#include "api/crypto/frame_decryptor_interface.h"
#include "api/frame_transformer_interface.h"
@@ -267,6 +268,8 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
// meta data is expected to be present in generic frame descriptor
// RTP header extension).
std::set<int> raw_payload_types;
+
+ RtcpEventObserver* rtcp_event_observer = nullptr;
} rtp;
- uint32_t rtcp_sender_packets_sent;
- uint32_t rtcp_sender_octets_sent;
- int64_t rtcp_sender_ntp_timestamp_ms;
+ // Mozilla modification: Init these three.
+ uint32_t rtcp_sender_packets_sent = 0;
+ uint32_t rtcp_sender_octets_sent = 0;
+ int64_t rtcp_sender_ntp_timestamp_ms = 0;
// Transport for outgoing packets (RTCP).
diff --git a/modules/rtp_rtcp/include/rtp_rtcp_defines.h b/modules/rtp_rtcp/include/rtp_rtcp_defines.h
index eb4d1d019c..2bdfe53ab9 100644
--- a/modules/rtp_rtcp/include/rtp_rtcp_defines.h
+++ b/modules/rtp_rtcp/include/rtp_rtcp_defines.h
@@ -184,6 +184,14 @@ class NetworkLinkRtcpObserver {
virtual void OnRttUpdate(Timestamp receive_time, TimeDelta rtt) {}
};
+class RtcpEventObserver {
+ public:
+ virtual void OnRtcpBye() = 0;
+ virtual void OnRtcpTimeout() = 0;
+
+ virtual ~RtcpEventObserver() {}
+};
+
// NOTE! `kNumMediaTypes` must be kept in sync with RtpPacketMediaType!
static constexpr size_t kNumMediaTypes = 5;
enum class RtpPacketMediaType : size_t {
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc
index 85c892767d..349a9a673e 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.cc
+++ b/modules/rtp_rtcp/source/rtcp_receiver.cc
@@ -168,6 +168,7 @@ RTCPReceiver::RTCPReceiver(const Environment& env,
rtp_rtcp_(owner),
registered_ssrcs_(false, config),
network_link_rtcp_observer_(config.network_link_rtcp_observer),
+ rtcp_event_observer_(config.rtcp_event_observer),
rtcp_intra_frame_observer_(config.intra_frame_callback),
rtcp_loss_notification_observer_(config.rtcp_loss_notification_observer),
network_state_estimate_observer_(config.network_state_estimate_observer),
@@ -198,6 +199,7 @@ RTCPReceiver::RTCPReceiver(const Environment& env,
rtp_rtcp_(owner),
registered_ssrcs_(true, config),
network_link_rtcp_observer_(config.network_link_rtcp_observer),
+ rtcp_event_observer_(config.rtcp_event_observer),
rtcp_intra_frame_observer_(config.intra_frame_callback),
rtcp_loss_notification_observer_(config.rtcp_loss_notification_observer),
network_state_estimate_observer_(config.network_state_estimate_observer),
@@ -811,6 +813,10 @@ bool RTCPReceiver::HandleBye(const CommonHeader& rtcp_block) {
return false;
}
+ if (rtcp_event_observer_) {
+ rtcp_event_observer_->OnRtcpBye();
+ }
+
// Clear our lists.
rtts_.erase(bye.sender_ssrc());
EraseIf(received_report_blocks_, [&](const auto& elem) {
@@ -1248,12 +1254,20 @@ std::vector<rtcp::TmmbItem> RTCPReceiver::TmmbrReceived() {
}
bool RTCPReceiver::RtcpRrTimeoutLocked(Timestamp now) {
- return ResetTimestampIfExpired(now, last_received_rb_, report_interval_);
+ bool result = ResetTimestampIfExpired(now, last_received_rb_, report_interval_);
+ if (result && rtcp_event_observer_) {
+ rtcp_event_observer_->OnRtcpTimeout();
+ }
+ return result;
}
bool RTCPReceiver::RtcpRrSequenceNumberTimeoutLocked(Timestamp now) {
- return ResetTimestampIfExpired(now, last_increased_sequence_number_,
+ bool result = ResetTimestampIfExpired(now, last_increased_sequence_number_,
report_interval_);
+ if (result && rtcp_event_observer_) {
+ rtcp_event_observer_->OnRtcpTimeout();
+ }
+ return result;
}
} // namespace webrtc
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.h b/modules/rtp_rtcp/source/rtcp_receiver.h
index 029fc3a5e2..33aa986e8b 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.h
+++ b/modules/rtp_rtcp/source/rtcp_receiver.h
@@ -371,6 +371,7 @@ class RTCPReceiver final {
RegisteredSsrcs registered_ssrcs_;
NetworkLinkRtcpObserver* const network_link_rtcp_observer_;
+ RtcpEventObserver* const rtcp_event_observer_;
RtcpIntraFrameObserver* const rtcp_intra_frame_observer_;
RtcpLossNotificationObserver* const rtcp_loss_notification_observer_;
NetworkStateEstimateObserver* const network_state_estimate_observer_;
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_interface.h b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
index 8ee991330f..3cfd0d4d01 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_interface.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
@@ -70,6 +70,9 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface {
// bandwidth estimation related message.
NetworkLinkRtcpObserver* network_link_rtcp_observer = nullptr;
+ // Called when we receive a RTCP bye or timeout
+ RtcpEventObserver* rtcp_event_observer = nullptr;
+
NetworkStateEstimateObserver* network_state_estimate_observer = nullptr;
// DEPRECATED, transport_feedback_callback is no longer invoked by the RTP
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index 23c3d3f6eb..931c29d8c8 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -82,7 +82,8 @@ std::unique_ptr<ModuleRtpRtcpImpl2> CreateRtpRtcpModule(
RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer,
RtcpCnameCallback* rtcp_cname_callback,
bool non_sender_rtt_measurement,
- uint32_t local_ssrc) {
+ uint32_t local_ssrc,
+ RtcpEventObserver* rtcp_event_observer) {
RtpRtcpInterface::Configuration configuration;
configuration.audio = false;
configuration.receiver_only = true;
@@ -93,6 +94,7 @@ std::unique_ptr<ModuleRtpRtcpImpl2> CreateRtpRtcpModule(
rtcp_packet_type_counter_observer;
configuration.rtcp_cname_callback = rtcp_cname_callback;
configuration.local_media_ssrc = local_ssrc;
+ configuration.rtcp_event_observer = rtcp_event_observer;
configuration.non_sender_rtt_measurement = non_sender_rtt_measurement;
auto rtp_rtcp = std::make_unique<ModuleRtpRtcpImpl2>(env, configuration);
@@ -266,7 +268,8 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2(
rtcp_packet_type_counter_observer,
rtcp_cname_callback,
config_.rtp.rtcp_xr.receiver_reference_time_report,
- config_.rtp.local_ssrc)),
+ config_.rtp.local_ssrc,
+ config_.rtp.rtcp_event_observer)),
nack_periodic_processor_(nack_periodic_processor),
complete_frame_callback_(complete_frame_callback),
keyframe_request_method_(config_.rtp.keyframe_method),
// Timing frame info: all important timestamps for a full lifetime of a
// single 'timing frame'.

View File

@ -1,29 +1,73 @@
From: "Byron Campen [:bwc]" <docfaraday@gmail.com>
Date: Fri, 12 Mar 2021 08:53:00 -0600
Subject: Bug 1654112 - libwebrtc modification: Init some stats that were being
passed to us uninitialized. r=ng
Date: Fri, 12 Mar 2021 08:55:00 -0600
Subject: Bug 1654112 - libwebrtc modification: Surface video RTCP SR stats
again. r=ng
Differential Revision: https://phabricator.services.mozilla.com/D108673
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c385bb870413b925af48df97aa1f2b80a26e78d2
libwebrtc has stopped surfacing these, and Chromium does not support
these stats at all.
Differential Revision: https://phabricator.services.mozilla.com/D108674
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/edac9d01a9ac7594f4b22708a4690753638ca32c
---
call/video_receive_stream.h | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
video/rtp_video_stream_receiver2.cc | 10 ++++++++++
video/rtp_video_stream_receiver2.h | 6 ++++++
video/video_receive_stream2.cc | 8 ++++++++
3 files changed, 24 insertions(+)
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index 4b1bcc5227..ef23484414 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -170,9 +170,10 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
RtcpPacketTypeCounter rtcp_packet_type_counts;
std::optional<RtpReceiveStats> rtx_rtp_stats;
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index 931c29d8c8..a3e3239225 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -1040,6 +1040,16 @@ std::optional<int64_t> RtpVideoStreamReceiver2::LastReceivedKeyframePacketMs()
return std::nullopt;
}
- uint32_t rtcp_sender_packets_sent;
- uint32_t rtcp_sender_octets_sent;
- int64_t rtcp_sender_ntp_timestamp_ms;
+ // Mozilla modification: Init these three.
+ uint32_t rtcp_sender_packets_sent = 0;
+ uint32_t rtcp_sender_octets_sent = 0;
+ int64_t rtcp_sender_ntp_timestamp_ms = 0;
+// Mozilla modification: VideoReceiveStream2 and friends do not surface RTCP
+// stats at all, and even on the most recent libwebrtc code there does not
+// seem to be any support for these stats right now. So, we hack this in.
+void RtpVideoStreamReceiver2::RemoteRTCPSenderInfo(
+ uint32_t* packet_count, uint32_t* octet_count,
+ int64_t* ntp_timestamp_ms) const {
+ RTC_DCHECK_RUN_ON(&worker_task_checker_);
+ rtp_rtcp_->RemoteRTCPSenderInfo(packet_count, octet_count, ntp_timestamp_ms);
+}
+
std::optional<RtpRtcpInterface::SenderReportStats>
RtpVideoStreamReceiver2::GetSenderReportStats() const {
RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
diff --git a/video/rtp_video_stream_receiver2.h b/video/rtp_video_stream_receiver2.h
index 141f15c3df..0fb3cd1b7c 100644
--- a/video/rtp_video_stream_receiver2.h
+++ b/video/rtp_video_stream_receiver2.h
@@ -211,6 +211,12 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender,
std::optional<RtpRtcpInterface::SenderReportStats> GetSenderReportStats()
const;
+ // Mozilla modification: VideoReceiveStream2 and friends do not surface RTCP
+ // stats at all, and even on the most recent libwebrtc code there does not
+ // seem to be any support for these stats right now. So, we hack this in.
+ void RemoteRTCPSenderInfo(uint32_t* packet_count, uint32_t* octet_count,
+ int64_t* ntp_timestamp_ms) const;
+
private:
// Implements RtpVideoFrameReceiver.
void ManageFrame(std::unique_ptr<RtpFrameObject> frame) override;
diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc
index 4372fdabdd..a655a072c4 100644
--- a/video/video_receive_stream2.cc
+++ b/video/video_receive_stream2.cc
@@ -578,6 +578,14 @@ VideoReceiveStreamInterface::Stats VideoReceiveStream2::GetStats() const {
stats.sender_reports_bytes_sent = rtcp_sr_stats->bytes_sent;
stats.sender_reports_reports_count = rtcp_sr_stats->reports_count;
}
+
+ // Mozilla modification: VideoReceiveStream2 and friends do not surface RTCP
+ // stats at all, and even on the most recent libwebrtc code there does not
+ // seem to be any support for these stats right now. So, we hack this in.
+ rtp_video_stream_receiver_.RemoteRTCPSenderInfo(
+ &stats.rtcp_sender_packets_sent, &stats.rtcp_sender_octets_sent,
+ &stats.rtcp_sender_ntp_timestamp_ms);
+
return stats;
}
// Timing frame info: all important timestamps for a full lifetime of a
// single 'timing frame'.

View File

@ -1,73 +1,35 @@
From: "Byron Campen [:bwc]" <docfaraday@gmail.com>
Date: Fri, 12 Mar 2021 08:55:00 -0600
Subject: Bug 1654112 - libwebrtc modification: Surface video RTCP SR stats
again. r=ng
From: Nico Grunbaum <na-g@nostrum.com>
Date: Mon, 26 Jul 2021 22:51:00 -0700
Subject: Bug 1654112 - fix timestamp issues with RTP sources; r=mjf
libwebrtc has stopped surfacing these, and Chromium does not support
these stats at all.
Differential Revision: https://phabricator.services.mozilla.com/D108674
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/edac9d01a9ac7594f4b22708a4690753638ca32c
Differential Revision: https://phabricator.services.mozilla.com/D120930
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/de8c14e4972f717bf937b6f2fffcd08c35e21ced
---
video/rtp_video_stream_receiver2.cc | 10 ++++++++++
video/rtp_video_stream_receiver2.h | 6 ++++++
video/video_receive_stream2.cc | 8 ++++++++
3 files changed, 24 insertions(+)
modules/rtp_rtcp/source/source_tracker.cc | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index 931c29d8c8..a3e3239225 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -1040,6 +1040,16 @@ std::optional<int64_t> RtpVideoStreamReceiver2::LastReceivedKeyframePacketMs()
return std::nullopt;
}
diff --git a/modules/rtp_rtcp/source/source_tracker.cc b/modules/rtp_rtcp/source/source_tracker.cc
index 17862148eb..4d0e8b6ad4 100644
--- a/modules/rtp_rtcp/source/source_tracker.cc
+++ b/modules/rtp_rtcp/source/source_tracker.cc
@@ -36,7 +36,8 @@ void SourceTracker::OnFrameDelivered(const RtpPacketInfos& packet_infos,
SourceKey key(RtpSourceType::CSRC, csrc);
SourceEntry& entry = UpdateEntry(key);
+// Mozilla modification: VideoReceiveStream2 and friends do not surface RTCP
+// stats at all, and even on the most recent libwebrtc code there does not
+// seem to be any support for these stats right now. So, we hack this in.
+void RtpVideoStreamReceiver2::RemoteRTCPSenderInfo(
+ uint32_t* packet_count, uint32_t* octet_count,
+ int64_t* ntp_timestamp_ms) const {
+ RTC_DCHECK_RUN_ON(&worker_task_checker_);
+ rtp_rtcp_->RemoteRTCPSenderInfo(packet_count, octet_count, ntp_timestamp_ms);
+}
+
std::optional<RtpRtcpInterface::SenderReportStats>
RtpVideoStreamReceiver2::GetSenderReportStats() const {
RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
diff --git a/video/rtp_video_stream_receiver2.h b/video/rtp_video_stream_receiver2.h
index 141f15c3df..0fb3cd1b7c 100644
--- a/video/rtp_video_stream_receiver2.h
+++ b/video/rtp_video_stream_receiver2.h
@@ -211,6 +211,12 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender,
std::optional<RtpRtcpInterface::SenderReportStats> GetSenderReportStats()
const;
+ // Mozilla modification: VideoReceiveStream2 and friends do not surface RTCP
+ // stats at all, and even on the most recent libwebrtc code there does not
+ // seem to be any support for these stats right now. So, we hack this in.
+ void RemoteRTCPSenderInfo(uint32_t* packet_count, uint32_t* octet_count,
+ int64_t* ntp_timestamp_ms) const;
+
private:
// Implements RtpVideoFrameReceiver.
void ManageFrame(std::unique_ptr<RtpFrameObject> frame) override;
diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc
index 4372fdabdd..a655a072c4 100644
--- a/video/video_receive_stream2.cc
+++ b/video/video_receive_stream2.cc
@@ -578,6 +578,14 @@ VideoReceiveStreamInterface::Stats VideoReceiveStream2::GetStats() const {
stats.sender_reports_bytes_sent = rtcp_sr_stats->bytes_sent;
stats.sender_reports_reports_count = rtcp_sr_stats->reports_count;
- entry.timestamp = delivery_time;
+ const auto packet_time = packet_info.receive_time();
+ entry.timestamp = packet_time.ms() ? packet_time : delivery_time;
entry.audio_level = packet_info.audio_level();
entry.absolute_capture_time = packet_info.absolute_capture_time();
entry.local_capture_clock_offset =
@@ -73,6 +74,10 @@ std::vector<RtpSource> SourceTracker::GetSources() const {
.local_capture_clock_offset = entry.local_capture_clock_offset});
}
+ std::sort(sources.begin(), sources.end(), [](const auto &a, const auto &b){
+ return a.timestamp().ms() > b.timestamp().ms();
+ });
+
+ // Mozilla modification: VideoReceiveStream2 and friends do not surface RTCP
+ // stats at all, and even on the most recent libwebrtc code there does not
+ // seem to be any support for these stats right now. So, we hack this in.
+ rtp_video_stream_receiver_.RemoteRTCPSenderInfo(
+ &stats.rtcp_sender_packets_sent, &stats.rtcp_sender_octets_sent,
+ &stats.rtcp_sender_ntp_timestamp_ms);
+
return stats;
return sources;
}

View File

@ -1,35 +1,29 @@
From: Nico Grunbaum <na-g@nostrum.com>
Date: Mon, 26 Jul 2021 22:51:00 -0700
Subject: Bug 1654112 - fix timestamp issues with RTP sources; r=mjf
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Fri, 20 Aug 2021 13:52:00 +0200
Subject: Bug 1654112 - Don't check the calling thread in
webrtc::AudioReceiveStream::GetSources. r=ng
Differential Revision: https://phabricator.services.mozilla.com/D120930
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/de8c14e4972f717bf937b6f2fffcd08c35e21ced
source_tracker_ is thread safe with its own internal mutex, so this call is safe
as long as the caller has a guarantee for the lifetime of the
AudioReceiveStream. This is similar to webrtc::VideoReceiveStream.
Upliftable.
Differential Revision: https://phabricator.services.mozilla.com/D123226
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c186df8a088e46285a15e40149182daa34cc6805
---
modules/rtp_rtcp/source/source_tracker.cc | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
audio/audio_receive_stream.cc | 1 -
1 file changed, 1 deletion(-)
diff --git a/modules/rtp_rtcp/source/source_tracker.cc b/modules/rtp_rtcp/source/source_tracker.cc
index 17862148eb..4d0e8b6ad4 100644
--- a/modules/rtp_rtcp/source/source_tracker.cc
+++ b/modules/rtp_rtcp/source/source_tracker.cc
@@ -36,7 +36,8 @@ void SourceTracker::OnFrameDelivered(const RtpPacketInfos& packet_infos,
SourceKey key(RtpSourceType::CSRC, csrc);
SourceEntry& entry = UpdateEntry(key);
- entry.timestamp = delivery_time;
+ const auto packet_time = packet_info.receive_time();
+ entry.timestamp = packet_time.ms() ? packet_time : delivery_time;
entry.audio_level = packet_info.audio_level();
entry.absolute_capture_time = packet_info.absolute_capture_time();
entry.local_capture_clock_offset =
@@ -73,6 +74,10 @@ std::vector<RtpSource> SourceTracker::GetSources() const {
.local_capture_clock_offset = entry.local_capture_clock_offset});
}
+ std::sort(sources.begin(), sources.end(), [](const auto &a, const auto &b){
+ return a.timestamp().ms() > b.timestamp().ms();
+ });
+
return sources;
diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc
index cd6ed5fbdd..41bc0c0c22 100644
--- a/audio/audio_receive_stream.cc
+++ b/audio/audio_receive_stream.cc
@@ -373,7 +373,6 @@ int AudioReceiveStreamImpl::GetBaseMinimumPlayoutDelayMs() const {
}
std::vector<RtpSource> AudioReceiveStreamImpl::GetSources() const {
- RTC_DCHECK_RUN_ON(&worker_thread_checker_);
return channel_receive_->GetSources();
}

View File

@ -1,29 +1,828 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Fri, 20 Aug 2021 13:52:00 +0200
Subject: Bug 1654112 - Don't check the calling thread in
webrtc::AudioReceiveStream::GetSources. r=ng
From: Paul Adenot <paul@paul.cx>
Date: Fri, 18 Aug 2023 13:13:36 -0500
Subject: Bug 1714577 - Part 6 - Copy WebRTC's trace_event.h to Gecko,
verbatim, and redirect the original trace_event.h to it. r=gerald
source_tracker_ is thread safe with its own internal mutex, so this call is safe
as long as the caller has a guarantee for the lifetime of the
AudioReceiveStream. This is similar to webrtc::VideoReceiveStream.
Upliftable.
Differential Revision: https://phabricator.services.mozilla.com/D123226
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c186df8a088e46285a15e40149182daa34cc6805
Differential Revision: https://phabricator.services.mozilla.com/D116843
---
audio/audio_receive_stream.cc | 1 -
1 file changed, 1 deletion(-)
rtc_base/trace_event.h | 813 +----------------------------------------
1 file changed, 3 insertions(+), 810 deletions(-)
diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc
index cd6ed5fbdd..41bc0c0c22 100644
--- a/audio/audio_receive_stream.cc
+++ b/audio/audio_receive_stream.cc
@@ -373,7 +373,6 @@ int AudioReceiveStreamImpl::GetBaseMinimumPlayoutDelayMs() const {
}
std::vector<RtpSource> AudioReceiveStreamImpl::GetSources() const {
- RTC_DCHECK_RUN_ON(&worker_thread_checker_);
return channel_receive_->GetSources();
}
diff --git a/rtc_base/trace_event.h b/rtc_base/trace_event.h
index 3329abd66c..b34df0c93f 100644
--- a/rtc_base/trace_event.h
+++ b/rtc_base/trace_event.h
@@ -1,810 +1,3 @@
-/*
- * Copyright (c) 2024 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 RTC_BASE_TRACE_EVENT_H_
-#define RTC_BASE_TRACE_EVENT_H_
-
-#if defined(RTC_DISABLE_TRACE_EVENTS)
-#define RTC_TRACE_EVENTS_ENABLED 0
-#else
-#define RTC_TRACE_EVENTS_ENABLED 1
-#endif
-
-// IWYU pragma: begin_exports
-#if defined(RTC_USE_PERFETTO)
-#include "rtc_base/trace_categories.h"
-#endif
-#include "third_party/perfetto/include/perfetto/tracing/event_context.h"
-#include "third_party/perfetto/include/perfetto/tracing/track.h"
-#include "third_party/perfetto/include/perfetto/tracing/track_event_args.h"
-// IWYU pragma: end_exports
-
-#if !defined(RTC_USE_PERFETTO)
-#include <string>
-
-#include "rtc_base/event_tracer.h"
-
-#define RTC_NOOP() \
- do { \
- } while (0)
-
-// TODO(b/42226290): Add implementation for these events with Perfetto.
-#define TRACE_EVENT_BEGIN(category, name, ...) RTC_NOOP();
-#define TRACE_EVENT_END(category, ...) RTC_NOOP();
-#define TRACE_EVENT(category, name, ...) RTC_NOOP();
-#define TRACE_EVENT_INSTANT(category, name, ...) RTC_NOOP();
-#define TRACE_EVENT_CATEGORY_ENABLED(category) RTC_NOOP();
-#define TRACE_COUNTER(category, track, ...) RTC_NOOP();
-
-// Type values for identifying types in the TraceValue union.
-#define TRACE_VALUE_TYPE_BOOL (static_cast<unsigned char>(1))
-#define TRACE_VALUE_TYPE_UINT (static_cast<unsigned char>(2))
-#define TRACE_VALUE_TYPE_INT (static_cast<unsigned char>(3))
-#define TRACE_VALUE_TYPE_DOUBLE (static_cast<unsigned char>(4))
-#define TRACE_VALUE_TYPE_POINTER (static_cast<unsigned char>(5))
-#define TRACE_VALUE_TYPE_STRING (static_cast<unsigned char>(6))
-#define TRACE_VALUE_TYPE_COPY_STRING (static_cast<unsigned char>(7))
-
-#if defined(TRACE_EVENT0)
-#error "Another copy of trace_event.h has already been included."
-#endif
-
-#if RTC_TRACE_EVENTS_ENABLED
-
-// Extracted from Chromium's src/base/debug/trace_event.h.
-
-// This header is designed to give you trace_event macros without specifying
-// how the events actually get collected and stored. If you need to expose trace
-// event to some other universe, you can copy-and-paste this file,
-// implement the TRACE_EVENT_API macros, and do any other necessary fixup for
-// the target platform. The end result is that multiple libraries can funnel
-// events through to a shared trace event collector.
-
-// Trace events are for tracking application performance and resource usage.
-// Macros are provided to track:
-// Begin and end of function calls
-// Counters
-//
-// Events are issued against categories. Whereas RTC_LOG's
-// categories are statically defined, TRACE categories are created
-// implicitly with a string. For example:
-// TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent")
-//
-// Events can be INSTANT, or can be pairs of BEGIN and END in the same scope:
-// TRACE_EVENT_BEGIN0("MY_SUBSYSTEM", "SomethingCostly")
-// doSomethingCostly()
-// TRACE_EVENT_END0("MY_SUBSYSTEM", "SomethingCostly")
-// Note: our tools can't always determine the correct BEGIN/END pairs unless
-// these are used in the same scope. Use ASYNC_BEGIN/ASYNC_END macros if you
-// need them to be in separate scopes.
-//
-// A common use case is to trace entire function scopes. This
-// issues a trace BEGIN and END automatically:
-// void doSomethingCostly() {
-// TRACE_EVENT0("MY_SUBSYSTEM", "doSomethingCostly");
-// ...
-// }
-//
-// Additional parameters can be associated with an event:
-// void doSomethingCostly2(int howMuch) {
-// TRACE_EVENT1("MY_SUBSYSTEM", "doSomethingCostly",
-// "howMuch", howMuch);
-// ...
-// }
-//
-// The trace system will automatically add to this information the
-// current process id, thread id, and a timestamp in microseconds.
-//
-// To trace an asynchronous procedure such as an IPC send/receive, use
-// ASYNC_BEGIN and ASYNC_END:
-// [single threaded sender code]
-// static int send_count = 0;
-// ++send_count;
-// TRACE_EVENT_ASYNC_BEGIN0("ipc", "message", send_count);
-// Send(new MyMessage(send_count));
-// [receive code]
-// void OnMyMessage(send_count) {
-// TRACE_EVENT_ASYNC_END0("ipc", "message", send_count);
-// }
-// The third parameter is a unique ID to match ASYNC_BEGIN/ASYNC_END pairs.
-// ASYNC_BEGIN and ASYNC_END can occur on any thread of any traced process.
-// Pointers can be used for the ID parameter, and they will be mangled
-// internally so that the same pointer on two different processes will not
-// match. For example:
-// class MyTracedClass {
-// public:
-// MyTracedClass() {
-// TRACE_EVENT_ASYNC_BEGIN0("category", "MyTracedClass", this);
-// }
-// ~MyTracedClass() {
-// TRACE_EVENT_ASYNC_END0("category", "MyTracedClass", this);
-// }
-// }
-//
-// Trace event also supports counters, which is a way to track a quantity
-// as it varies over time. Counters are created with the following macro:
-// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter", g_myCounterValue);
-//
-// Counters are process-specific. The macro itself can be issued from any
-// thread, however.
-//
-// Sometimes, you want to track two counters at once. You can do this with two
-// counter macros:
-// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter0", g_myCounterValue[0]);
-// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter1", g_myCounterValue[1]);
-// Or you can do it with a combined macro:
-// TRACE_COUNTER2("MY_SUBSYSTEM", "myCounter",
-// "bytesPinned", g_myCounterValue[0],
-// "bytesAllocated", g_myCounterValue[1]);
-// This indicates to the tracing UI that these counters should be displayed
-// in a single graph, as a summed area chart.
-//
-// Since counters are in a global namespace, you may want to disembiguate with a
-// unique ID, by using the TRACE_COUNTER_ID* variations.
-//
-// By default, trace collection is compiled in, but turned off at runtime.
-// Collecting trace data is the responsibility of the embedding
-// application. In Chrome's case, navigating to about:tracing will turn on
-// tracing and display data collected across all active processes.
-//
-// When are string argument values copied:
-// const char* arg_values are only referenced by default:
-// TRACE_EVENT1("category", "name",
-// "arg1", "literal string is only referenced");
-// Use TRACE_STR_COPY to force copying of a const char*:
-// TRACE_EVENT1("category", "name",
-// "arg1", TRACE_STR_COPY("string will be copied"));
-// std::string arg_values are always copied:
-// TRACE_EVENT1("category", "name",
-// "arg1", std::string("string will be copied"));
-//
-//
-// Thread Safety:
-// Thread safety is provided by methods defined in event_tracer.h. See the file
-// for details.
-
-// By default, const char* argument values are assumed to have long-lived scope
-// and will not be copied. Use this macro to force a const char* to be copied.
-#define TRACE_STR_COPY(str) \
- webrtc::trace_event_internal::TraceStringWithCopy(str)
-
-// This will mark the trace event as disabled by default. The user will need
-// to explicitly enable the event.
-#define TRACE_DISABLED_BY_DEFAULT(name) "disabled-by-default-" name
-
-// By default, uint64 ID argument values are not mangled with the Process ID in
-// TRACE_EVENT_ASYNC macros. Use this macro to force Process ID mangling.
-#define TRACE_ID_MANGLE(id) \
- webrtc::trace_event_internal::TraceID::ForceMangle(id)
-
-// Records a pair of begin and end events called "name" for the current
-// scope, with 0, 1 or 2 associated arguments. If the category is not
-// enabled, then this does nothing.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_EVENT0(category, name) \
- INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name)
-#define TRACE_EVENT1(category, name, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, arg1_name, arg1_val)
-#define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \
- INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, arg1_name, arg1_val, \
- arg2_name, arg2_val)
-
-// Enum reflecting the scope of an INSTANT event. Must fit within
-// TRACE_EVENT_FLAG_SCOPE_MASK.
-static constexpr uint8_t TRACE_EVENT_SCOPE_GLOBAL = 0u << 2;
-static constexpr uint8_t TRACE_EVENT_SCOPE_PROCESS = 1u << 2;
-static constexpr uint8_t TRACE_EVENT_SCOPE_THREAD = 2u << 2;
-
-// Records a single event called "name" immediately, with 0, 1 or 2
-// associated arguments. If the category is not enabled, then this
-// does nothing.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_EVENT_INSTANT0(category, name, scope) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category, name, \
- TRACE_EVENT_FLAG_NONE)
-#define TRACE_EVENT_INSTANT1(category, name, scope, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
-#define TRACE_EVENT_INSTANT2(category, name, scope, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
- arg2_name, arg2_val)
-
-// Records a single BEGIN event called "name" immediately, with 0, 1 or 2
-// associated arguments. If the category is not enabled, then this
-// does nothing.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_EVENT_BEGIN0(category, name) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category, name, \
- TRACE_EVENT_FLAG_NONE)
-#define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
-#define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, arg2_name, \
- arg2_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
- arg2_name, arg2_val)
-
-// Records a single END event for "name" immediately. If the category
-// is not enabled, then this does nothing.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_EVENT_END0(category, name) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category, name, \
- TRACE_EVENT_FLAG_NONE)
-#define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
-#define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, arg2_name, \
- arg2_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
- arg2_name, arg2_val)
-
-// Records the value of a counter called "name" immediately. Value
-// must be representable as a 32 bit integer.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_COUNTER1(category, name, value) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, category, name, \
- TRACE_EVENT_FLAG_NONE, "value", \
- static_cast<int>(value))
-
-// Records the values of a multi-parted counter called "name" immediately.
-// The UI will treat value1 and value2 as parts of a whole, displaying their
-// values as a stacked-bar chart.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_COUNTER2(category, name, value1_name, value1_val, value2_name, \
- value2_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, category, name, \
- TRACE_EVENT_FLAG_NONE, value1_name, \
- static_cast<int>(value1_val), value2_name, \
- static_cast<int>(value2_val))
-
-// Records the value of a counter called "name" immediately. Value
-// must be representable as a 32 bit integer.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-// - `id` is used to disambiguate counters with the same name. It must either
-// be a pointer or an integer value up to 64 bits. If it's a pointer, the bits
-// will be xored with a hash of the process ID so that the same pointer on
-// two different processes will not collide.
-#define TRACE_COUNTER_ID1(category, name, id, value) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, category, name, \
- id, TRACE_EVENT_FLAG_NONE, "value", \
- static_cast<int>(value))
-
-// Records the values of a multi-parted counter called "name" immediately.
-// The UI will treat value1 and value2 as parts of a whole, displaying their
-// values as a stacked-bar chart.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-// - `id` is used to disambiguate counters with the same name. It must either
-// be a pointer or an integer value up to 64 bits. If it's a pointer, the bits
-// will be xored with a hash of the process ID so that the same pointer on
-// two different processes will not collide.
-#define TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, \
- value2_name, value2_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, category, name, \
- id, TRACE_EVENT_FLAG_NONE, value1_name, \
- static_cast<int>(value1_val), value2_name, \
- static_cast<int>(value2_val))
-
-// Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2
-// associated arguments. If the category is not enabled, then this
-// does nothing.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-// - `id` is used to match the ASYNC_BEGIN event with the ASYNC_END event. ASYNC
-// events are considered to match if their category, name and id values all
-// match. `id` must either be a pointer or an integer value up to 64 bits. If
-// it's a pointer, the bits will be xored with a hash of the process ID so
-// that the same pointer on two different processes will not collide.
-// An asynchronous operation can consist of multiple phases. The first phase is
-// defined by the ASYNC_BEGIN calls. Additional phases can be defined using the
-// ASYNC_STEP macros. When the operation completes, call ASYNC_END.
-// An ASYNC trace typically occur on a single thread (if not, they will only be
-// drawn on the thread defined in the ASYNC_BEGIN event), but all events in that
-// operation must use the same `name` and `id`. Each event can have its own
-// args.
-#define TRACE_EVENT_ASYNC_BEGIN0(category, name, id) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, category, \
- name, id, TRACE_EVENT_FLAG_NONE)
-#define TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, category, \
- name, id, TRACE_EVENT_FLAG_NONE, arg1_name, \
- arg1_val)
-#define TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, category, \
- name, id, TRACE_EVENT_FLAG_NONE, arg1_name, \
- arg1_val, arg2_name, arg2_val)
-
-// Records a single ASYNC_STEP event for `step` immediately. If the category
-// is not enabled, then this does nothing. The `name` and `id` must match the
-// ASYNC_BEGIN event above. The `step` param identifies this step within the
-// async event. This should be called at the beginning of the next phase of an
-// asynchronous operation.
-#define TRACE_EVENT_ASYNC_STEP_INTO0(category, name, id, step) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, category, \
- name, id, TRACE_EVENT_FLAG_NONE, "step", \
- step)
-#define TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \
- arg1_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, category, \
- name, id, TRACE_EVENT_FLAG_NONE, "step", \
- step, arg1_name, arg1_val)
-
-// Records a single ASYNC_END event for "name" immediately. If the category
-// is not enabled, then this does nothing.
-#define TRACE_EVENT_ASYNC_END0(category, name, id) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, category, \
- name, id, TRACE_EVENT_FLAG_NONE)
-#define TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, category, \
- name, id, TRACE_EVENT_FLAG_NONE, arg1_name, \
- arg1_val)
-#define TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, category, \
- name, id, TRACE_EVENT_FLAG_NONE, arg1_name, \
- arg1_val, arg2_name, arg2_val)
-
-////////////////////////////////////////////////////////////////////////////////
-// Implementation specific tracing API definitions.
-
-// Get a pointer to the enabled state of the given trace category. Only
-// long-lived literal strings should be given as the category name. The returned
-// pointer can be held permanently in a local static for example. If the
-// unsigned char is non-zero, tracing is enabled. If tracing is enabled,
-// TRACE_EVENT_API_ADD_TRACE_EVENT can be called. It's OK if tracing is disabled
-// between the load of the tracing state and the call to
-// TRACE_EVENT_API_ADD_TRACE_EVENT, because this flag only provides an early out
-// for best performance when tracing is disabled.
-// const unsigned char*
-// TRACE_EVENT_API_GET_CATEGORY_ENABLED(const char* category_name)
-#define TRACE_EVENT_API_GET_CATEGORY_ENABLED \
- webrtc::EventTracer::GetCategoryEnabled
-
-// Add a trace event to the platform tracing system.
-// void TRACE_EVENT_API_ADD_TRACE_EVENT(
-// char phase,
-// const unsigned char* category_enabled,
-// const char* name,
-// unsigned long long id,
-// int num_args,
-// const char** arg_names,
-// const unsigned char* arg_types,
-// const unsigned long long* arg_values,
-// unsigned char flags)
-#define TRACE_EVENT_API_ADD_TRACE_EVENT webrtc::EventTracer::AddTraceEvent
-
-////////////////////////////////////////////////////////////////////////////////
-
-// Implementation detail: trace event macros create temporary variables
-// to keep instrumentation overhead low. These macros give each temporary
-// variable a unique name based on the line number to prevent name collissions.
-#define INTERNAL_TRACE_EVENT_UID3(a, b) trace_event_unique_##a##b
-#define INTERNAL_TRACE_EVENT_UID2(a, b) INTERNAL_TRACE_EVENT_UID3(a, b)
-#define INTERNAL_TRACE_EVENT_UID(name_prefix) \
- INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__)
-
-#if WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS
-#define INTERNAL_TRACE_EVENT_INFO_TYPE const unsigned char*
-#else
-#define INTERNAL_TRACE_EVENT_INFO_TYPE static const unsigned char*
-#endif // WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS
-
-// Implementation detail: internal macro to create static category.
-#define INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category) \
- INTERNAL_TRACE_EVENT_INFO_TYPE INTERNAL_TRACE_EVENT_UID(catstatic) = \
- TRACE_EVENT_API_GET_CATEGORY_ENABLED(category);
-
-// Implementation detail: internal macro to create static category and add
-// event if the category is enabled.
-#define INTERNAL_TRACE_EVENT_ADD(phase, category, name, flags, ...) \
- do { \
- INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \
- if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \
- webrtc::trace_event_internal::AddTraceEvent( \
- phase, INTERNAL_TRACE_EVENT_UID(catstatic), name, \
- webrtc::trace_event_internal::kNoEventId, flags, ##__VA_ARGS__); \
- } \
- } while (0)
-
-// Implementation detail: internal macro to create static category and add begin
-// event if the category is enabled. Also adds the end event when the scope
-// ends.
-#define INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, ...) \
- INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \
- webrtc::trace_event_internal::TraceEndOnScopeClose INTERNAL_TRACE_EVENT_UID( \
- profileScope); \
- if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \
- webrtc::trace_event_internal::AddTraceEvent( \
- TRACE_EVENT_PHASE_BEGIN, INTERNAL_TRACE_EVENT_UID(catstatic), name, \
- webrtc::trace_event_internal::kNoEventId, TRACE_EVENT_FLAG_NONE, \
- ##__VA_ARGS__); \
- INTERNAL_TRACE_EVENT_UID(profileScope) \
- .Initialize(INTERNAL_TRACE_EVENT_UID(catstatic), name); \
- }
-
-// Implementation detail: internal macro to create static category and add
-// event if the category is enabled.
-#define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category, name, id, flags, \
- ...) \
- do { \
- INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \
- if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \
- unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \
- webrtc::trace_event_internal::TraceID trace_event_trace_id( \
- id, &trace_event_flags); \
- webrtc::trace_event_internal::AddTraceEvent( \
- phase, INTERNAL_TRACE_EVENT_UID(catstatic), name, \
- trace_event_trace_id.data(), trace_event_flags, ##__VA_ARGS__); \
- } \
- } while (0)
-
-// Notes regarding the following definitions:
-// New values can be added and propagated to third party libraries, but existing
-// definitions must never be changed, because third party libraries may use old
-// definitions.
-
-// Phase indicates the nature of an event entry. E.g. part of a begin/end pair.
-#define TRACE_EVENT_PHASE_BEGIN ('B')
-#define TRACE_EVENT_PHASE_END ('E')
-#define TRACE_EVENT_PHASE_INSTANT ('I')
-#define TRACE_EVENT_PHASE_ASYNC_BEGIN ('S')
-#define TRACE_EVENT_PHASE_ASYNC_STEP ('T')
-#define TRACE_EVENT_PHASE_ASYNC_END ('F')
-#define TRACE_EVENT_PHASE_METADATA ('M')
-#define TRACE_EVENT_PHASE_COUNTER ('C')
-
-// Flags for changing the behavior of TRACE_EVENT_API_ADD_TRACE_EVENT.
-#define TRACE_EVENT_FLAG_NONE (static_cast<unsigned char>(0))
-#define TRACE_EVENT_FLAG_HAS_ID (static_cast<unsigned char>(1 << 1))
-#define TRACE_EVENT_FLAG_MANGLE_ID (static_cast<unsigned char>(1 << 2))
-
-namespace webrtc {
-namespace trace_event_internal {
-
-// Specify these values when the corresponding argument of AddTraceEvent is not
-// used.
-const int kZeroNumArgs = 0;
-const unsigned long long kNoEventId = 0;
-
-// TraceID encapsulates an ID that can either be an integer or pointer. Pointers
-// are mangled with the Process ID so that they are unlikely to collide when the
-// same pointer is used on different processes.
-class TraceID {
- public:
- class ForceMangle {
- public:
- explicit ForceMangle(unsigned long long id) : data_(id) {}
- explicit ForceMangle(unsigned long id) : data_(id) {}
- explicit ForceMangle(unsigned int id) : data_(id) {}
- explicit ForceMangle(unsigned short id) : data_(id) {}
- explicit ForceMangle(unsigned char id) : data_(id) {}
- explicit ForceMangle(long long id)
- : data_(static_cast<unsigned long long>(id)) {}
- explicit ForceMangle(long id)
- : data_(static_cast<unsigned long long>(id)) {}
- explicit ForceMangle(int id) : data_(static_cast<unsigned long long>(id)) {}
- explicit ForceMangle(short id)
- : data_(static_cast<unsigned long long>(id)) {}
- explicit ForceMangle(signed char id)
- : data_(static_cast<unsigned long long>(id)) {}
-
- unsigned long long data() const { return data_; }
-
- private:
- unsigned long long data_;
- };
-
- explicit TraceID(const void* id, unsigned char* flags)
- : data_(
- static_cast<unsigned long long>(reinterpret_cast<uintptr_t>(id))) {
- *flags |= TRACE_EVENT_FLAG_MANGLE_ID;
- }
- explicit TraceID(ForceMangle id, unsigned char* flags) : data_(id.data()) {
- *flags |= TRACE_EVENT_FLAG_MANGLE_ID;
- }
- explicit TraceID(unsigned long long id, unsigned char* flags) : data_(id) {
- (void)flags;
- }
- explicit TraceID(unsigned long id, unsigned char* flags) : data_(id) {
- (void)flags;
- }
- explicit TraceID(unsigned int id, unsigned char* flags) : data_(id) {
- (void)flags;
- }
- explicit TraceID(unsigned short id, unsigned char* flags) : data_(id) {
- (void)flags;
- }
- explicit TraceID(unsigned char id, unsigned char* flags) : data_(id) {
- (void)flags;
- }
- explicit TraceID(long long id, unsigned char* flags)
- : data_(static_cast<unsigned long long>(id)) {
- (void)flags;
- }
- explicit TraceID(long id, unsigned char* flags)
- : data_(static_cast<unsigned long long>(id)) {
- (void)flags;
- }
- explicit TraceID(int id, unsigned char* flags)
- : data_(static_cast<unsigned long long>(id)) {
- (void)flags;
- }
- explicit TraceID(short id, unsigned char* flags)
- : data_(static_cast<unsigned long long>(id)) {
- (void)flags;
- }
- explicit TraceID(signed char id, unsigned char* flags)
- : data_(static_cast<unsigned long long>(id)) {
- (void)flags;
- }
-
- unsigned long long data() const { return data_; }
-
- private:
- unsigned long long data_;
-};
-
-// Simple union to store various types as unsigned long long.
-union TraceValueUnion {
- bool as_bool;
- unsigned long long as_uint;
- long long as_int;
- double as_double;
- const void* as_pointer;
- const char* as_string;
-};
-
-// Simple container for const char* that should be copied instead of retained.
-class TraceStringWithCopy {
- public:
- explicit TraceStringWithCopy(const char* str) : str_(str) {}
- operator const char*() const { return str_; }
-
- private:
- const char* str_;
-};
-
-// Define SetTraceValue for each allowed type. It stores the type and
-// value in the return arguments. This allows this API to avoid declaring any
-// structures so that it is portable to third_party libraries.
-#define INTERNAL_DECLARE_SET_TRACE_VALUE(actual_type, union_member, \
- value_type_id) \
- static inline void SetTraceValue(actual_type arg, unsigned char* type, \
- unsigned long long* value) { \
- TraceValueUnion type_value; \
- type_value.union_member = arg; \
- *type = value_type_id; \
- *value = type_value.as_uint; \
- }
-// Simpler form for int types that can be safely casted.
-#define INTERNAL_DECLARE_SET_TRACE_VALUE_INT(actual_type, value_type_id) \
- static inline void SetTraceValue(actual_type arg, unsigned char* type, \
- unsigned long long* value) { \
- *type = value_type_id; \
- *value = static_cast<unsigned long long>(arg); \
- }
-
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned long long, TRACE_VALUE_TYPE_UINT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned long, TRACE_VALUE_TYPE_UINT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned int, TRACE_VALUE_TYPE_UINT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned short, TRACE_VALUE_TYPE_UINT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned char, TRACE_VALUE_TYPE_UINT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(long long, TRACE_VALUE_TYPE_INT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(long, TRACE_VALUE_TYPE_INT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(int, TRACE_VALUE_TYPE_INT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(short, TRACE_VALUE_TYPE_INT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(signed char, TRACE_VALUE_TYPE_INT)
-INTERNAL_DECLARE_SET_TRACE_VALUE(bool, as_bool, TRACE_VALUE_TYPE_BOOL)
-INTERNAL_DECLARE_SET_TRACE_VALUE(double, as_double, TRACE_VALUE_TYPE_DOUBLE)
-INTERNAL_DECLARE_SET_TRACE_VALUE(const void*,
- as_pointer,
- TRACE_VALUE_TYPE_POINTER)
-INTERNAL_DECLARE_SET_TRACE_VALUE(const char*,
- as_string,
- TRACE_VALUE_TYPE_STRING)
-INTERNAL_DECLARE_SET_TRACE_VALUE(const TraceStringWithCopy&,
- as_string,
- TRACE_VALUE_TYPE_COPY_STRING)
-
-#undef INTERNAL_DECLARE_SET_TRACE_VALUE
-#undef INTERNAL_DECLARE_SET_TRACE_VALUE_INT
-
-// std::string version of SetTraceValue so that trace arguments can be strings.
-static inline void SetTraceValue(const std::string& arg,
- unsigned char* type,
- unsigned long long* value) {
- TraceValueUnion type_value;
- type_value.as_string = arg.c_str();
- *type = TRACE_VALUE_TYPE_COPY_STRING;
- *value = type_value.as_uint;
-}
-
-// These AddTraceEvent template functions are defined here instead of in the
-// macro, because the arg_values could be temporary objects, such as
-// std::string. In order to store pointers to the internal c_str and pass
-// through to the tracing API, the arg_values must live throughout
-// these procedures.
-
-static inline void AddTraceEvent(char phase,
- const unsigned char* category_enabled,
- const char* name,
- unsigned long long id,
- unsigned char flags) {
- TRACE_EVENT_API_ADD_TRACE_EVENT(phase, category_enabled, name, id,
- kZeroNumArgs, nullptr, nullptr, nullptr,
- flags);
-}
-
-template <class ARG1_TYPE>
-static inline void AddTraceEvent(char phase,
- const unsigned char* category_enabled,
- const char* name,
- unsigned long long id,
- unsigned char flags,
- const char* arg1_name,
- const ARG1_TYPE& arg1_val) {
- const int num_args = 1;
- unsigned char arg_types[1];
- unsigned long long arg_values[1];
- SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]);
- TRACE_EVENT_API_ADD_TRACE_EVENT(phase, category_enabled, name, id, num_args,
- &arg1_name, arg_types, arg_values, flags);
-}
-
-template <class ARG1_TYPE, class ARG2_TYPE>
-static inline void AddTraceEvent(char phase,
- const unsigned char* category_enabled,
- const char* name,
- unsigned long long id,
- unsigned char flags,
- const char* arg1_name,
- const ARG1_TYPE& arg1_val,
- const char* arg2_name,
- const ARG2_TYPE& arg2_val) {
- const int num_args = 2;
- const char* arg_names[2] = {arg1_name, arg2_name};
- unsigned char arg_types[2];
- unsigned long long arg_values[2];
- SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]);
- SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]);
- TRACE_EVENT_API_ADD_TRACE_EVENT(phase, category_enabled, name, id, num_args,
- arg_names, arg_types, arg_values, flags);
-}
-
-// Used by TRACE_EVENTx macro. Do not use directly.
-class TraceEndOnScopeClose {
- public:
- // Note: members of data_ intentionally left uninitialized. See Initialize.
- TraceEndOnScopeClose() : p_data_(nullptr) {}
- ~TraceEndOnScopeClose() {
- if (p_data_)
- AddEventIfEnabled();
- }
-
- void Initialize(const unsigned char* category_enabled, const char* name) {
- data_.category_enabled = category_enabled;
- data_.name = name;
- p_data_ = &data_;
- }
-
- private:
- // Add the end event if the category is still enabled.
- void AddEventIfEnabled() {
- // Only called when p_data_ is non-null.
- if (*p_data_->category_enabled) {
- TRACE_EVENT_API_ADD_TRACE_EVENT(TRACE_EVENT_PHASE_END,
- p_data_->category_enabled, p_data_->name,
- kNoEventId, kZeroNumArgs, nullptr,
- nullptr, nullptr, TRACE_EVENT_FLAG_NONE);
- }
- }
-
- // This Data struct workaround is to avoid initializing all the members
- // in Data during construction of this object, since this object is always
- // constructed, even when tracing is disabled. If the members of Data were
- // members of this class instead, compiler warnings occur about potential
- // uninitialized accesses.
- struct Data {
- const unsigned char* category_enabled;
- const char* name;
- };
- Data* p_data_;
- Data data_;
-};
-
-} // namespace trace_event_internal
-} // namespace webrtc
-
-#else
-
-////////////////////////////////////////////////////////////////////////////////
-// This section defines no-op alternatives to the tracing macros when
-// RTC_DISABLE_TRACE_EVENTS is defined.
-
-#define TRACE_DISABLED_BY_DEFAULT(name) "disabled-by-default-" name
-
-#define TRACE_ID_MANGLE(id) 0
-
-#define TRACE_EVENT0(category, name) RTC_NOOP()
-#define TRACE_EVENT1(category, name, arg1_name, arg1_val) RTC_NOOP()
-#define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_INSTANT0(category, name, scope) RTC_NOOP()
-#define TRACE_EVENT_INSTANT1(category, name, scope, arg1_name, arg1_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_INSTANT2(category, name, scope, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_BEGIN0(category, name) RTC_NOOP()
-#define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) RTC_NOOP()
-#define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, arg2_name, \
- arg2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_END0(category, name) RTC_NOOP()
-#define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) RTC_NOOP()
-#define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, arg2_name, \
- arg2_val) \
- RTC_NOOP()
-
-#define TRACE_COUNTER1(category, name, value) RTC_NOOP()
-
-#define TRACE_COUNTER2(category, name, value1_name, value1_val, value2_name, \
- value2_val) \
- RTC_NOOP()
-
-#define TRACE_COUNTER_ID1(category, name, id, value) RTC_NOOP()
-
-#define TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, \
- value2_name, value2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_ASYNC_BEGIN0(category, name, id) RTC_NOOP()
-#define TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \
- RTC_NOOP()
-#define TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_ASYNC_STEP_INTO0(category, name, id, step) RTC_NOOP()
-#define TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \
- arg1_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_ASYNC_END0(category, name, id) RTC_NOOP()
-#define TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) \
- RTC_NOOP()
-#define TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_API_GET_CATEGORY_ENABLED ""
-
-#define TRACE_EVENT_API_ADD_TRACE_EVENT RTC_NOOP()
-
-#endif // RTC_TRACE_EVENTS_ENABLED
-#endif // RTC_USE_PERFETTO
-
-#endif // RTC_BASE_TRACE_EVENT_H_
+// This header is diverted to a similar header in Gecko, that is defining the
+// same macros, modified to talk to the Gecko Profiler.
+#include "GeckoTraceEvent.h"

View File

@ -1,828 +1,27 @@
From: Paul Adenot <paul@paul.cx>
Date: Fri, 18 Aug 2023 13:13:36 -0500
Subject: Bug 1714577 - Part 6 - Copy WebRTC's trace_event.h to Gecko,
verbatim, and redirect the original trace_event.h to it. r=gerald
From: Nico Grunbaum <na-g@nostrum.com>
Date: Thu, 28 Oct 2021 18:13:00 +0000
Subject: Bug 1729367 - P6 - Restore PID recording post cherry-pick;r=mjf
Differential Revision: https://phabricator.services.mozilla.com/D116843
This restores the code from P0, which was removed to make cherry-picking 439ffe462a66ad9fa9a251b265e4ab28c2647d25 and 449a78b1e20ea85b11f967cf3a184ee610ce21c3 easier.
Differential Revision: https://phabricator.services.mozilla.com/D129714
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/72a83cb2e571023cd4150bbdef5be5455ce851f4
---
rtc_base/trace_event.h | 813 +----------------------------------------
1 file changed, 3 insertions(+), 810 deletions(-)
modules/desktop_capture/win/window_capture_utils.cc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/rtc_base/trace_event.h b/rtc_base/trace_event.h
index 3329abd66c..b34df0c93f 100644
--- a/rtc_base/trace_event.h
+++ b/rtc_base/trace_event.h
@@ -1,810 +1,3 @@
-/*
- * Copyright (c) 2024 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 RTC_BASE_TRACE_EVENT_H_
-#define RTC_BASE_TRACE_EVENT_H_
-
-#if defined(RTC_DISABLE_TRACE_EVENTS)
-#define RTC_TRACE_EVENTS_ENABLED 0
-#else
-#define RTC_TRACE_EVENTS_ENABLED 1
-#endif
-
-// IWYU pragma: begin_exports
-#if defined(RTC_USE_PERFETTO)
-#include "rtc_base/trace_categories.h"
-#endif
-#include "third_party/perfetto/include/perfetto/tracing/event_context.h"
-#include "third_party/perfetto/include/perfetto/tracing/track.h"
-#include "third_party/perfetto/include/perfetto/tracing/track_event_args.h"
-// IWYU pragma: end_exports
-
-#if !defined(RTC_USE_PERFETTO)
-#include <string>
-
-#include "rtc_base/event_tracer.h"
-
-#define RTC_NOOP() \
- do { \
- } while (0)
-
-// TODO(b/42226290): Add implementation for these events with Perfetto.
-#define TRACE_EVENT_BEGIN(category, name, ...) RTC_NOOP();
-#define TRACE_EVENT_END(category, ...) RTC_NOOP();
-#define TRACE_EVENT(category, name, ...) RTC_NOOP();
-#define TRACE_EVENT_INSTANT(category, name, ...) RTC_NOOP();
-#define TRACE_EVENT_CATEGORY_ENABLED(category) RTC_NOOP();
-#define TRACE_COUNTER(category, track, ...) RTC_NOOP();
-
-// Type values for identifying types in the TraceValue union.
-#define TRACE_VALUE_TYPE_BOOL (static_cast<unsigned char>(1))
-#define TRACE_VALUE_TYPE_UINT (static_cast<unsigned char>(2))
-#define TRACE_VALUE_TYPE_INT (static_cast<unsigned char>(3))
-#define TRACE_VALUE_TYPE_DOUBLE (static_cast<unsigned char>(4))
-#define TRACE_VALUE_TYPE_POINTER (static_cast<unsigned char>(5))
-#define TRACE_VALUE_TYPE_STRING (static_cast<unsigned char>(6))
-#define TRACE_VALUE_TYPE_COPY_STRING (static_cast<unsigned char>(7))
-
-#if defined(TRACE_EVENT0)
-#error "Another copy of trace_event.h has already been included."
-#endif
-
-#if RTC_TRACE_EVENTS_ENABLED
-
-// Extracted from Chromium's src/base/debug/trace_event.h.
-
-// This header is designed to give you trace_event macros without specifying
-// how the events actually get collected and stored. If you need to expose trace
-// event to some other universe, you can copy-and-paste this file,
-// implement the TRACE_EVENT_API macros, and do any other necessary fixup for
-// the target platform. The end result is that multiple libraries can funnel
-// events through to a shared trace event collector.
-
-// Trace events are for tracking application performance and resource usage.
-// Macros are provided to track:
-// Begin and end of function calls
-// Counters
-//
-// Events are issued against categories. Whereas RTC_LOG's
-// categories are statically defined, TRACE categories are created
-// implicitly with a string. For example:
-// TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent")
-//
-// Events can be INSTANT, or can be pairs of BEGIN and END in the same scope:
-// TRACE_EVENT_BEGIN0("MY_SUBSYSTEM", "SomethingCostly")
-// doSomethingCostly()
-// TRACE_EVENT_END0("MY_SUBSYSTEM", "SomethingCostly")
-// Note: our tools can't always determine the correct BEGIN/END pairs unless
-// these are used in the same scope. Use ASYNC_BEGIN/ASYNC_END macros if you
-// need them to be in separate scopes.
-//
-// A common use case is to trace entire function scopes. This
-// issues a trace BEGIN and END automatically:
-// void doSomethingCostly() {
-// TRACE_EVENT0("MY_SUBSYSTEM", "doSomethingCostly");
-// ...
-// }
-//
-// Additional parameters can be associated with an event:
-// void doSomethingCostly2(int howMuch) {
-// TRACE_EVENT1("MY_SUBSYSTEM", "doSomethingCostly",
-// "howMuch", howMuch);
-// ...
-// }
-//
-// The trace system will automatically add to this information the
-// current process id, thread id, and a timestamp in microseconds.
-//
-// To trace an asynchronous procedure such as an IPC send/receive, use
-// ASYNC_BEGIN and ASYNC_END:
-// [single threaded sender code]
-// static int send_count = 0;
-// ++send_count;
-// TRACE_EVENT_ASYNC_BEGIN0("ipc", "message", send_count);
-// Send(new MyMessage(send_count));
-// [receive code]
-// void OnMyMessage(send_count) {
-// TRACE_EVENT_ASYNC_END0("ipc", "message", send_count);
-// }
-// The third parameter is a unique ID to match ASYNC_BEGIN/ASYNC_END pairs.
-// ASYNC_BEGIN and ASYNC_END can occur on any thread of any traced process.
-// Pointers can be used for the ID parameter, and they will be mangled
-// internally so that the same pointer on two different processes will not
-// match. For example:
-// class MyTracedClass {
-// public:
-// MyTracedClass() {
-// TRACE_EVENT_ASYNC_BEGIN0("category", "MyTracedClass", this);
-// }
-// ~MyTracedClass() {
-// TRACE_EVENT_ASYNC_END0("category", "MyTracedClass", this);
-// }
-// }
-//
-// Trace event also supports counters, which is a way to track a quantity
-// as it varies over time. Counters are created with the following macro:
-// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter", g_myCounterValue);
-//
-// Counters are process-specific. The macro itself can be issued from any
-// thread, however.
-//
-// Sometimes, you want to track two counters at once. You can do this with two
-// counter macros:
-// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter0", g_myCounterValue[0]);
-// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter1", g_myCounterValue[1]);
-// Or you can do it with a combined macro:
-// TRACE_COUNTER2("MY_SUBSYSTEM", "myCounter",
-// "bytesPinned", g_myCounterValue[0],
-// "bytesAllocated", g_myCounterValue[1]);
-// This indicates to the tracing UI that these counters should be displayed
-// in a single graph, as a summed area chart.
-//
-// Since counters are in a global namespace, you may want to disembiguate with a
-// unique ID, by using the TRACE_COUNTER_ID* variations.
-//
-// By default, trace collection is compiled in, but turned off at runtime.
-// Collecting trace data is the responsibility of the embedding
-// application. In Chrome's case, navigating to about:tracing will turn on
-// tracing and display data collected across all active processes.
-//
-// When are string argument values copied:
-// const char* arg_values are only referenced by default:
-// TRACE_EVENT1("category", "name",
-// "arg1", "literal string is only referenced");
-// Use TRACE_STR_COPY to force copying of a const char*:
-// TRACE_EVENT1("category", "name",
-// "arg1", TRACE_STR_COPY("string will be copied"));
-// std::string arg_values are always copied:
-// TRACE_EVENT1("category", "name",
-// "arg1", std::string("string will be copied"));
-//
-//
-// Thread Safety:
-// Thread safety is provided by methods defined in event_tracer.h. See the file
-// for details.
-
-// By default, const char* argument values are assumed to have long-lived scope
-// and will not be copied. Use this macro to force a const char* to be copied.
-#define TRACE_STR_COPY(str) \
- webrtc::trace_event_internal::TraceStringWithCopy(str)
-
-// This will mark the trace event as disabled by default. The user will need
-// to explicitly enable the event.
-#define TRACE_DISABLED_BY_DEFAULT(name) "disabled-by-default-" name
-
-// By default, uint64 ID argument values are not mangled with the Process ID in
-// TRACE_EVENT_ASYNC macros. Use this macro to force Process ID mangling.
-#define TRACE_ID_MANGLE(id) \
- webrtc::trace_event_internal::TraceID::ForceMangle(id)
-
-// Records a pair of begin and end events called "name" for the current
-// scope, with 0, 1 or 2 associated arguments. If the category is not
-// enabled, then this does nothing.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_EVENT0(category, name) \
- INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name)
-#define TRACE_EVENT1(category, name, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, arg1_name, arg1_val)
-#define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \
- INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, arg1_name, arg1_val, \
- arg2_name, arg2_val)
-
-// Enum reflecting the scope of an INSTANT event. Must fit within
-// TRACE_EVENT_FLAG_SCOPE_MASK.
-static constexpr uint8_t TRACE_EVENT_SCOPE_GLOBAL = 0u << 2;
-static constexpr uint8_t TRACE_EVENT_SCOPE_PROCESS = 1u << 2;
-static constexpr uint8_t TRACE_EVENT_SCOPE_THREAD = 2u << 2;
-
-// Records a single event called "name" immediately, with 0, 1 or 2
-// associated arguments. If the category is not enabled, then this
-// does nothing.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_EVENT_INSTANT0(category, name, scope) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category, name, \
- TRACE_EVENT_FLAG_NONE)
-#define TRACE_EVENT_INSTANT1(category, name, scope, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
-#define TRACE_EVENT_INSTANT2(category, name, scope, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
- arg2_name, arg2_val)
-
-// Records a single BEGIN event called "name" immediately, with 0, 1 or 2
-// associated arguments. If the category is not enabled, then this
-// does nothing.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_EVENT_BEGIN0(category, name) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category, name, \
- TRACE_EVENT_FLAG_NONE)
-#define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
-#define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, arg2_name, \
- arg2_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
- arg2_name, arg2_val)
-
-// Records a single END event for "name" immediately. If the category
-// is not enabled, then this does nothing.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_EVENT_END0(category, name) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category, name, \
- TRACE_EVENT_FLAG_NONE)
-#define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
-#define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, arg2_name, \
- arg2_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
- arg2_name, arg2_val)
-
-// Records the value of a counter called "name" immediately. Value
-// must be representable as a 32 bit integer.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_COUNTER1(category, name, value) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, category, name, \
- TRACE_EVENT_FLAG_NONE, "value", \
- static_cast<int>(value))
-
-// Records the values of a multi-parted counter called "name" immediately.
-// The UI will treat value1 and value2 as parts of a whole, displaying their
-// values as a stacked-bar chart.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_COUNTER2(category, name, value1_name, value1_val, value2_name, \
- value2_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, category, name, \
- TRACE_EVENT_FLAG_NONE, value1_name, \
- static_cast<int>(value1_val), value2_name, \
- static_cast<int>(value2_val))
-
-// Records the value of a counter called "name" immediately. Value
-// must be representable as a 32 bit integer.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-// - `id` is used to disambiguate counters with the same name. It must either
-// be a pointer or an integer value up to 64 bits. If it's a pointer, the bits
-// will be xored with a hash of the process ID so that the same pointer on
-// two different processes will not collide.
-#define TRACE_COUNTER_ID1(category, name, id, value) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, category, name, \
- id, TRACE_EVENT_FLAG_NONE, "value", \
- static_cast<int>(value))
-
-// Records the values of a multi-parted counter called "name" immediately.
-// The UI will treat value1 and value2 as parts of a whole, displaying their
-// values as a stacked-bar chart.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-// - `id` is used to disambiguate counters with the same name. It must either
-// be a pointer or an integer value up to 64 bits. If it's a pointer, the bits
-// will be xored with a hash of the process ID so that the same pointer on
-// two different processes will not collide.
-#define TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, \
- value2_name, value2_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, category, name, \
- id, TRACE_EVENT_FLAG_NONE, value1_name, \
- static_cast<int>(value1_val), value2_name, \
- static_cast<int>(value2_val))
-
-// Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2
-// associated arguments. If the category is not enabled, then this
-// does nothing.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-// - `id` is used to match the ASYNC_BEGIN event with the ASYNC_END event. ASYNC
-// events are considered to match if their category, name and id values all
-// match. `id` must either be a pointer or an integer value up to 64 bits. If
-// it's a pointer, the bits will be xored with a hash of the process ID so
-// that the same pointer on two different processes will not collide.
-// An asynchronous operation can consist of multiple phases. The first phase is
-// defined by the ASYNC_BEGIN calls. Additional phases can be defined using the
-// ASYNC_STEP macros. When the operation completes, call ASYNC_END.
-// An ASYNC trace typically occur on a single thread (if not, they will only be
-// drawn on the thread defined in the ASYNC_BEGIN event), but all events in that
-// operation must use the same `name` and `id`. Each event can have its own
-// args.
-#define TRACE_EVENT_ASYNC_BEGIN0(category, name, id) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, category, \
- name, id, TRACE_EVENT_FLAG_NONE)
-#define TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, category, \
- name, id, TRACE_EVENT_FLAG_NONE, arg1_name, \
- arg1_val)
-#define TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, category, \
- name, id, TRACE_EVENT_FLAG_NONE, arg1_name, \
- arg1_val, arg2_name, arg2_val)
-
-// Records a single ASYNC_STEP event for `step` immediately. If the category
-// is not enabled, then this does nothing. The `name` and `id` must match the
-// ASYNC_BEGIN event above. The `step` param identifies this step within the
-// async event. This should be called at the beginning of the next phase of an
-// asynchronous operation.
-#define TRACE_EVENT_ASYNC_STEP_INTO0(category, name, id, step) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, category, \
- name, id, TRACE_EVENT_FLAG_NONE, "step", \
- step)
-#define TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \
- arg1_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, category, \
- name, id, TRACE_EVENT_FLAG_NONE, "step", \
- step, arg1_name, arg1_val)
-
-// Records a single ASYNC_END event for "name" immediately. If the category
-// is not enabled, then this does nothing.
-#define TRACE_EVENT_ASYNC_END0(category, name, id) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, category, \
- name, id, TRACE_EVENT_FLAG_NONE)
-#define TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, category, \
- name, id, TRACE_EVENT_FLAG_NONE, arg1_name, \
- arg1_val)
-#define TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, category, \
- name, id, TRACE_EVENT_FLAG_NONE, arg1_name, \
- arg1_val, arg2_name, arg2_val)
-
-////////////////////////////////////////////////////////////////////////////////
-// Implementation specific tracing API definitions.
-
-// Get a pointer to the enabled state of the given trace category. Only
-// long-lived literal strings should be given as the category name. The returned
-// pointer can be held permanently in a local static for example. If the
-// unsigned char is non-zero, tracing is enabled. If tracing is enabled,
-// TRACE_EVENT_API_ADD_TRACE_EVENT can be called. It's OK if tracing is disabled
-// between the load of the tracing state and the call to
-// TRACE_EVENT_API_ADD_TRACE_EVENT, because this flag only provides an early out
-// for best performance when tracing is disabled.
-// const unsigned char*
-// TRACE_EVENT_API_GET_CATEGORY_ENABLED(const char* category_name)
-#define TRACE_EVENT_API_GET_CATEGORY_ENABLED \
- webrtc::EventTracer::GetCategoryEnabled
-
-// Add a trace event to the platform tracing system.
-// void TRACE_EVENT_API_ADD_TRACE_EVENT(
-// char phase,
-// const unsigned char* category_enabled,
-// const char* name,
-// unsigned long long id,
-// int num_args,
-// const char** arg_names,
-// const unsigned char* arg_types,
-// const unsigned long long* arg_values,
-// unsigned char flags)
-#define TRACE_EVENT_API_ADD_TRACE_EVENT webrtc::EventTracer::AddTraceEvent
-
-////////////////////////////////////////////////////////////////////////////////
-
-// Implementation detail: trace event macros create temporary variables
-// to keep instrumentation overhead low. These macros give each temporary
-// variable a unique name based on the line number to prevent name collissions.
-#define INTERNAL_TRACE_EVENT_UID3(a, b) trace_event_unique_##a##b
-#define INTERNAL_TRACE_EVENT_UID2(a, b) INTERNAL_TRACE_EVENT_UID3(a, b)
-#define INTERNAL_TRACE_EVENT_UID(name_prefix) \
- INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__)
-
-#if WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS
-#define INTERNAL_TRACE_EVENT_INFO_TYPE const unsigned char*
-#else
-#define INTERNAL_TRACE_EVENT_INFO_TYPE static const unsigned char*
-#endif // WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS
-
-// Implementation detail: internal macro to create static category.
-#define INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category) \
- INTERNAL_TRACE_EVENT_INFO_TYPE INTERNAL_TRACE_EVENT_UID(catstatic) = \
- TRACE_EVENT_API_GET_CATEGORY_ENABLED(category);
-
-// Implementation detail: internal macro to create static category and add
-// event if the category is enabled.
-#define INTERNAL_TRACE_EVENT_ADD(phase, category, name, flags, ...) \
- do { \
- INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \
- if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \
- webrtc::trace_event_internal::AddTraceEvent( \
- phase, INTERNAL_TRACE_EVENT_UID(catstatic), name, \
- webrtc::trace_event_internal::kNoEventId, flags, ##__VA_ARGS__); \
- } \
- } while (0)
-
-// Implementation detail: internal macro to create static category and add begin
-// event if the category is enabled. Also adds the end event when the scope
-// ends.
-#define INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, ...) \
- INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \
- webrtc::trace_event_internal::TraceEndOnScopeClose INTERNAL_TRACE_EVENT_UID( \
- profileScope); \
- if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \
- webrtc::trace_event_internal::AddTraceEvent( \
- TRACE_EVENT_PHASE_BEGIN, INTERNAL_TRACE_EVENT_UID(catstatic), name, \
- webrtc::trace_event_internal::kNoEventId, TRACE_EVENT_FLAG_NONE, \
- ##__VA_ARGS__); \
- INTERNAL_TRACE_EVENT_UID(profileScope) \
- .Initialize(INTERNAL_TRACE_EVENT_UID(catstatic), name); \
- }
-
-// Implementation detail: internal macro to create static category and add
-// event if the category is enabled.
-#define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category, name, id, flags, \
- ...) \
- do { \
- INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \
- if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \
- unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \
- webrtc::trace_event_internal::TraceID trace_event_trace_id( \
- id, &trace_event_flags); \
- webrtc::trace_event_internal::AddTraceEvent( \
- phase, INTERNAL_TRACE_EVENT_UID(catstatic), name, \
- trace_event_trace_id.data(), trace_event_flags, ##__VA_ARGS__); \
- } \
- } while (0)
-
-// Notes regarding the following definitions:
-// New values can be added and propagated to third party libraries, but existing
-// definitions must never be changed, because third party libraries may use old
-// definitions.
-
-// Phase indicates the nature of an event entry. E.g. part of a begin/end pair.
-#define TRACE_EVENT_PHASE_BEGIN ('B')
-#define TRACE_EVENT_PHASE_END ('E')
-#define TRACE_EVENT_PHASE_INSTANT ('I')
-#define TRACE_EVENT_PHASE_ASYNC_BEGIN ('S')
-#define TRACE_EVENT_PHASE_ASYNC_STEP ('T')
-#define TRACE_EVENT_PHASE_ASYNC_END ('F')
-#define TRACE_EVENT_PHASE_METADATA ('M')
-#define TRACE_EVENT_PHASE_COUNTER ('C')
-
-// Flags for changing the behavior of TRACE_EVENT_API_ADD_TRACE_EVENT.
-#define TRACE_EVENT_FLAG_NONE (static_cast<unsigned char>(0))
-#define TRACE_EVENT_FLAG_HAS_ID (static_cast<unsigned char>(1 << 1))
-#define TRACE_EVENT_FLAG_MANGLE_ID (static_cast<unsigned char>(1 << 2))
-
-namespace webrtc {
-namespace trace_event_internal {
-
-// Specify these values when the corresponding argument of AddTraceEvent is not
-// used.
-const int kZeroNumArgs = 0;
-const unsigned long long kNoEventId = 0;
-
-// TraceID encapsulates an ID that can either be an integer or pointer. Pointers
-// are mangled with the Process ID so that they are unlikely to collide when the
-// same pointer is used on different processes.
-class TraceID {
- public:
- class ForceMangle {
- public:
- explicit ForceMangle(unsigned long long id) : data_(id) {}
- explicit ForceMangle(unsigned long id) : data_(id) {}
- explicit ForceMangle(unsigned int id) : data_(id) {}
- explicit ForceMangle(unsigned short id) : data_(id) {}
- explicit ForceMangle(unsigned char id) : data_(id) {}
- explicit ForceMangle(long long id)
- : data_(static_cast<unsigned long long>(id)) {}
- explicit ForceMangle(long id)
- : data_(static_cast<unsigned long long>(id)) {}
- explicit ForceMangle(int id) : data_(static_cast<unsigned long long>(id)) {}
- explicit ForceMangle(short id)
- : data_(static_cast<unsigned long long>(id)) {}
- explicit ForceMangle(signed char id)
- : data_(static_cast<unsigned long long>(id)) {}
-
- unsigned long long data() const { return data_; }
-
- private:
- unsigned long long data_;
- };
-
- explicit TraceID(const void* id, unsigned char* flags)
- : data_(
- static_cast<unsigned long long>(reinterpret_cast<uintptr_t>(id))) {
- *flags |= TRACE_EVENT_FLAG_MANGLE_ID;
- }
- explicit TraceID(ForceMangle id, unsigned char* flags) : data_(id.data()) {
- *flags |= TRACE_EVENT_FLAG_MANGLE_ID;
- }
- explicit TraceID(unsigned long long id, unsigned char* flags) : data_(id) {
- (void)flags;
- }
- explicit TraceID(unsigned long id, unsigned char* flags) : data_(id) {
- (void)flags;
- }
- explicit TraceID(unsigned int id, unsigned char* flags) : data_(id) {
- (void)flags;
- }
- explicit TraceID(unsigned short id, unsigned char* flags) : data_(id) {
- (void)flags;
- }
- explicit TraceID(unsigned char id, unsigned char* flags) : data_(id) {
- (void)flags;
- }
- explicit TraceID(long long id, unsigned char* flags)
- : data_(static_cast<unsigned long long>(id)) {
- (void)flags;
- }
- explicit TraceID(long id, unsigned char* flags)
- : data_(static_cast<unsigned long long>(id)) {
- (void)flags;
- }
- explicit TraceID(int id, unsigned char* flags)
- : data_(static_cast<unsigned long long>(id)) {
- (void)flags;
- }
- explicit TraceID(short id, unsigned char* flags)
- : data_(static_cast<unsigned long long>(id)) {
- (void)flags;
- }
- explicit TraceID(signed char id, unsigned char* flags)
- : data_(static_cast<unsigned long long>(id)) {
- (void)flags;
- }
-
- unsigned long long data() const { return data_; }
-
- private:
- unsigned long long data_;
-};
-
-// Simple union to store various types as unsigned long long.
-union TraceValueUnion {
- bool as_bool;
- unsigned long long as_uint;
- long long as_int;
- double as_double;
- const void* as_pointer;
- const char* as_string;
-};
-
-// Simple container for const char* that should be copied instead of retained.
-class TraceStringWithCopy {
- public:
- explicit TraceStringWithCopy(const char* str) : str_(str) {}
- operator const char*() const { return str_; }
-
- private:
- const char* str_;
-};
-
-// Define SetTraceValue for each allowed type. It stores the type and
-// value in the return arguments. This allows this API to avoid declaring any
-// structures so that it is portable to third_party libraries.
-#define INTERNAL_DECLARE_SET_TRACE_VALUE(actual_type, union_member, \
- value_type_id) \
- static inline void SetTraceValue(actual_type arg, unsigned char* type, \
- unsigned long long* value) { \
- TraceValueUnion type_value; \
- type_value.union_member = arg; \
- *type = value_type_id; \
- *value = type_value.as_uint; \
- }
-// Simpler form for int types that can be safely casted.
-#define INTERNAL_DECLARE_SET_TRACE_VALUE_INT(actual_type, value_type_id) \
- static inline void SetTraceValue(actual_type arg, unsigned char* type, \
- unsigned long long* value) { \
- *type = value_type_id; \
- *value = static_cast<unsigned long long>(arg); \
- }
-
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned long long, TRACE_VALUE_TYPE_UINT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned long, TRACE_VALUE_TYPE_UINT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned int, TRACE_VALUE_TYPE_UINT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned short, TRACE_VALUE_TYPE_UINT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned char, TRACE_VALUE_TYPE_UINT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(long long, TRACE_VALUE_TYPE_INT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(long, TRACE_VALUE_TYPE_INT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(int, TRACE_VALUE_TYPE_INT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(short, TRACE_VALUE_TYPE_INT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(signed char, TRACE_VALUE_TYPE_INT)
-INTERNAL_DECLARE_SET_TRACE_VALUE(bool, as_bool, TRACE_VALUE_TYPE_BOOL)
-INTERNAL_DECLARE_SET_TRACE_VALUE(double, as_double, TRACE_VALUE_TYPE_DOUBLE)
-INTERNAL_DECLARE_SET_TRACE_VALUE(const void*,
- as_pointer,
- TRACE_VALUE_TYPE_POINTER)
-INTERNAL_DECLARE_SET_TRACE_VALUE(const char*,
- as_string,
- TRACE_VALUE_TYPE_STRING)
-INTERNAL_DECLARE_SET_TRACE_VALUE(const TraceStringWithCopy&,
- as_string,
- TRACE_VALUE_TYPE_COPY_STRING)
-
-#undef INTERNAL_DECLARE_SET_TRACE_VALUE
-#undef INTERNAL_DECLARE_SET_TRACE_VALUE_INT
-
-// std::string version of SetTraceValue so that trace arguments can be strings.
-static inline void SetTraceValue(const std::string& arg,
- unsigned char* type,
- unsigned long long* value) {
- TraceValueUnion type_value;
- type_value.as_string = arg.c_str();
- *type = TRACE_VALUE_TYPE_COPY_STRING;
- *value = type_value.as_uint;
-}
-
-// These AddTraceEvent template functions are defined here instead of in the
-// macro, because the arg_values could be temporary objects, such as
-// std::string. In order to store pointers to the internal c_str and pass
-// through to the tracing API, the arg_values must live throughout
-// these procedures.
-
-static inline void AddTraceEvent(char phase,
- const unsigned char* category_enabled,
- const char* name,
- unsigned long long id,
- unsigned char flags) {
- TRACE_EVENT_API_ADD_TRACE_EVENT(phase, category_enabled, name, id,
- kZeroNumArgs, nullptr, nullptr, nullptr,
- flags);
-}
-
-template <class ARG1_TYPE>
-static inline void AddTraceEvent(char phase,
- const unsigned char* category_enabled,
- const char* name,
- unsigned long long id,
- unsigned char flags,
- const char* arg1_name,
- const ARG1_TYPE& arg1_val) {
- const int num_args = 1;
- unsigned char arg_types[1];
- unsigned long long arg_values[1];
- SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]);
- TRACE_EVENT_API_ADD_TRACE_EVENT(phase, category_enabled, name, id, num_args,
- &arg1_name, arg_types, arg_values, flags);
-}
-
-template <class ARG1_TYPE, class ARG2_TYPE>
-static inline void AddTraceEvent(char phase,
- const unsigned char* category_enabled,
- const char* name,
- unsigned long long id,
- unsigned char flags,
- const char* arg1_name,
- const ARG1_TYPE& arg1_val,
- const char* arg2_name,
- const ARG2_TYPE& arg2_val) {
- const int num_args = 2;
- const char* arg_names[2] = {arg1_name, arg2_name};
- unsigned char arg_types[2];
- unsigned long long arg_values[2];
- SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]);
- SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]);
- TRACE_EVENT_API_ADD_TRACE_EVENT(phase, category_enabled, name, id, num_args,
- arg_names, arg_types, arg_values, flags);
-}
-
-// Used by TRACE_EVENTx macro. Do not use directly.
-class TraceEndOnScopeClose {
- public:
- // Note: members of data_ intentionally left uninitialized. See Initialize.
- TraceEndOnScopeClose() : p_data_(nullptr) {}
- ~TraceEndOnScopeClose() {
- if (p_data_)
- AddEventIfEnabled();
- }
-
- void Initialize(const unsigned char* category_enabled, const char* name) {
- data_.category_enabled = category_enabled;
- data_.name = name;
- p_data_ = &data_;
- }
-
- private:
- // Add the end event if the category is still enabled.
- void AddEventIfEnabled() {
- // Only called when p_data_ is non-null.
- if (*p_data_->category_enabled) {
- TRACE_EVENT_API_ADD_TRACE_EVENT(TRACE_EVENT_PHASE_END,
- p_data_->category_enabled, p_data_->name,
- kNoEventId, kZeroNumArgs, nullptr,
- nullptr, nullptr, TRACE_EVENT_FLAG_NONE);
- }
- }
-
- // This Data struct workaround is to avoid initializing all the members
- // in Data during construction of this object, since this object is always
- // constructed, even when tracing is disabled. If the members of Data were
- // members of this class instead, compiler warnings occur about potential
- // uninitialized accesses.
- struct Data {
- const unsigned char* category_enabled;
- const char* name;
- };
- Data* p_data_;
- Data data_;
-};
-
-} // namespace trace_event_internal
-} // namespace webrtc
-
-#else
-
-////////////////////////////////////////////////////////////////////////////////
-// This section defines no-op alternatives to the tracing macros when
-// RTC_DISABLE_TRACE_EVENTS is defined.
-
-#define TRACE_DISABLED_BY_DEFAULT(name) "disabled-by-default-" name
-
-#define TRACE_ID_MANGLE(id) 0
-
-#define TRACE_EVENT0(category, name) RTC_NOOP()
-#define TRACE_EVENT1(category, name, arg1_name, arg1_val) RTC_NOOP()
-#define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_INSTANT0(category, name, scope) RTC_NOOP()
-#define TRACE_EVENT_INSTANT1(category, name, scope, arg1_name, arg1_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_INSTANT2(category, name, scope, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_BEGIN0(category, name) RTC_NOOP()
-#define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) RTC_NOOP()
-#define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, arg2_name, \
- arg2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_END0(category, name) RTC_NOOP()
-#define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) RTC_NOOP()
-#define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, arg2_name, \
- arg2_val) \
- RTC_NOOP()
-
-#define TRACE_COUNTER1(category, name, value) RTC_NOOP()
-
-#define TRACE_COUNTER2(category, name, value1_name, value1_val, value2_name, \
- value2_val) \
- RTC_NOOP()
-
-#define TRACE_COUNTER_ID1(category, name, id, value) RTC_NOOP()
-
-#define TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, \
- value2_name, value2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_ASYNC_BEGIN0(category, name, id) RTC_NOOP()
-#define TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \
- RTC_NOOP()
-#define TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_ASYNC_STEP_INTO0(category, name, id, step) RTC_NOOP()
-#define TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \
- arg1_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_ASYNC_END0(category, name, id) RTC_NOOP()
-#define TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) \
- RTC_NOOP()
-#define TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_API_GET_CATEGORY_ENABLED ""
-
-#define TRACE_EVENT_API_ADD_TRACE_EVENT RTC_NOOP()
-
-#endif // RTC_TRACE_EVENTS_ENABLED
-#endif // RTC_USE_PERFETTO
-
-#endif // RTC_BASE_TRACE_EVENT_H_
+// This header is diverted to a similar header in Gecko, that is defining the
+// same macros, modified to talk to the Gecko Profiler.
+#include "GeckoTraceEvent.h"
diff --git a/modules/desktop_capture/win/window_capture_utils.cc b/modules/desktop_capture/win/window_capture_utils.cc
index 261c4002ae..040ee7da1c 100644
--- a/modules/desktop_capture/win/window_capture_utils.cc
+++ b/modules/desktop_capture/win/window_capture_utils.cc
@@ -79,6 +79,10 @@ BOOL CALLBACK GetWindowListHandler(HWND hwnd, LPARAM param) {
DesktopCapturer::Source window;
window.id = reinterpret_cast<WindowId>(hwnd);
+ DWORD pid;
+ GetWindowThreadProcessId(hwnd, &pid);
+ window.pid = static_cast<pid_t>(pid);
+
// GetWindowText* are potentially blocking operations if `hwnd` is
// owned by the current process. The APIs will send messages to the window's
// message loop, and if the message loop is waiting on this operation we will

View File

@ -1,27 +1,26 @@
From: Nico Grunbaum <na-g@nostrum.com>
Date: Thu, 28 Oct 2021 18:13:00 +0000
Subject: Bug 1729367 - P6 - Restore PID recording post cherry-pick;r=mjf
Subject: Bug 1729367 - P7 - restore mac PID tracking using new API;r=mjf
a=webrtc-update
This restores the code from P0, which was removed to make cherry-picking 439ffe462a66ad9fa9a251b265e4ab28c2647d25 and 449a78b1e20ea85b11f967cf3a184ee610ce21c3 easier.
Differential Revision: https://phabricator.services.mozilla.com/D129714
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/72a83cb2e571023cd4150bbdef5be5455ce851f4
Differential Revision: https://phabricator.services.mozilla.com/D129721
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/1495ca5ef535f8ad692a3a579ca42eddc14f39a8
---
modules/desktop_capture/win/window_capture_utils.cc | 4 ++++
1 file changed, 4 insertions(+)
modules/desktop_capture/window_capturer_mac.mm | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/modules/desktop_capture/win/window_capture_utils.cc b/modules/desktop_capture/win/window_capture_utils.cc
index 261c4002ae..040ee7da1c 100644
--- a/modules/desktop_capture/win/window_capture_utils.cc
+++ b/modules/desktop_capture/win/window_capture_utils.cc
@@ -79,6 +79,10 @@ BOOL CALLBACK GetWindowListHandler(HWND hwnd, LPARAM param) {
DesktopCapturer::Source window;
window.id = reinterpret_cast<WindowId>(hwnd);
+ DWORD pid;
+ GetWindowThreadProcessId(hwnd, &pid);
+ window.pid = static_cast<pid_t>(pid);
+
// GetWindowText* are potentially blocking operations if `hwnd` is
// owned by the current process. The APIs will send messages to the window's
// message loop, and if the message loop is waiting on this operation we will
diff --git a/modules/desktop_capture/window_capturer_mac.mm b/modules/desktop_capture/window_capturer_mac.mm
index 56c94baada..8f5dc25516 100644
--- a/modules/desktop_capture/window_capturer_mac.mm
+++ b/modules/desktop_capture/window_capturer_mac.mm
@@ -169,8 +169,9 @@ void WindowCapturerMac::CaptureFrame() {
return webrtc::GetWindowList(
[sources](CFDictionaryRef window) {
WindowId window_id = GetWindowId(window);
+ int pid = GetWindowOwnerPid(window);
if (window_id != kNullWindowId) {
- sources->push_back(DesktopCapturer::Source{window_id, GetWindowTitle(window)});
+ sources->push_back(DesktopCapturer::Source{window_id, pid, GetWindowTitle(window)});
}
return true;
},

View File

@ -1,26 +1,205 @@
From: Nico Grunbaum <na-g@nostrum.com>
Date: Thu, 28 Oct 2021 18:13:00 +0000
Subject: Bug 1729367 - P7 - restore mac PID tracking using new API;r=mjf
a=webrtc-update
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Tue, 2 Nov 2021 14:35:00 +0000
Subject: Bug 1729455 - Add to stats the local receive time for receiving video
Sender Reports. r=ng
Differential Revision: https://phabricator.services.mozilla.com/D129721
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/1495ca5ef535f8ad692a3a579ca42eddc14f39a8
Differential Revision: https://phabricator.services.mozilla.com/D125712
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/99267b6d193fbcb3e4c845c5e80770424d6d06e2
---
modules/desktop_capture/window_capturer_mac.mm | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
call/video_receive_stream.h | 3 ++-
modules/rtp_rtcp/source/rtcp_receiver.cc | 6 ++++--
modules/rtp_rtcp/source/rtcp_receiver.h | 3 ++-
modules/rtp_rtcp/source/rtp_rtcp_impl.cc | 10 +++++-----
modules/rtp_rtcp/source/rtp_rtcp_impl.h | 3 ++-
modules/rtp_rtcp/source/rtp_rtcp_impl2.cc | 10 +++++-----
modules/rtp_rtcp/source/rtp_rtcp_impl2.h | 3 ++-
modules/rtp_rtcp/source/rtp_rtcp_interface.h | 5 +++--
video/rtp_video_stream_receiver2.cc | 5 +++--
video/rtp_video_stream_receiver2.h | 3 ++-
video/video_receive_stream2.cc | 3 ++-
11 files changed, 32 insertions(+), 22 deletions(-)
diff --git a/modules/desktop_capture/window_capturer_mac.mm b/modules/desktop_capture/window_capturer_mac.mm
index 56c94baada..8f5dc25516 100644
--- a/modules/desktop_capture/window_capturer_mac.mm
+++ b/modules/desktop_capture/window_capturer_mac.mm
@@ -169,8 +169,9 @@ void WindowCapturerMac::CaptureFrame() {
return webrtc::GetWindowList(
[sources](CFDictionaryRef window) {
WindowId window_id = GetWindowId(window);
+ int pid = GetWindowOwnerPid(window);
if (window_id != kNullWindowId) {
- sources->push_back(DesktopCapturer::Source{window_id, GetWindowTitle(window)});
+ sources->push_back(DesktopCapturer::Source{window_id, pid, GetWindowTitle(window)});
}
return true;
},
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index ef23484414..472199ef57 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -170,10 +170,11 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
RtcpPacketTypeCounter rtcp_packet_type_counts;
std::optional<RtpReceiveStats> rtx_rtp_stats;
- // Mozilla modification: Init these three.
+ // Mozilla modification: Init these.
uint32_t rtcp_sender_packets_sent = 0;
uint32_t rtcp_sender_octets_sent = 0;
int64_t rtcp_sender_ntp_timestamp_ms = 0;
+ int64_t rtcp_sender_remote_ntp_timestamp_ms = 0;
// Timing frame info: all important timestamps for a full lifetime of a
// single 'timing frame'.
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc
index 349a9a673e..3298961fd3 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.cc
+++ b/modules/rtp_rtcp/source/rtcp_receiver.cc
@@ -391,11 +391,13 @@ RTCPReceiver::ConsumeReceivedXrReferenceTimeInfo() {
void RTCPReceiver::RemoteRTCPSenderInfo(uint32_t* packet_count,
uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const {
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const {
MutexLock lock(&rtcp_receiver_lock_);
*packet_count = remote_sender_packet_count_;
*octet_count = remote_sender_octet_count_;
- *ntp_timestamp_ms = remote_sender_ntp_time_.ToMs();
+ *ntp_timestamp_ms = last_received_sr_ntp_.ToMs();
+ *remote_ntp_timestamp_ms = remote_sender_ntp_time_.ToMs();
}
std::vector<ReportBlockData> RTCPReceiver::GetLatestReportBlockData() const {
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.h b/modules/rtp_rtcp/source/rtcp_receiver.h
index 33aa986e8b..f6d1e027f4 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.h
+++ b/modules/rtp_rtcp/source/rtcp_receiver.h
@@ -126,7 +126,8 @@ class RTCPReceiver final {
// Get received sender packet and octet counts
void RemoteRTCPSenderInfo(uint32_t* packet_count,
uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const;
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const;
std::optional<TimeDelta> AverageRtt() const;
std::optional<TimeDelta> LastRtt() const;
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
index 69b6636d3a..284fb65109 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
@@ -515,11 +515,11 @@ void ModuleRtpRtcpImpl::GetSendStreamDataCounters(
}
// Received RTCP report.
-void ModuleRtpRtcpImpl::RemoteRTCPSenderInfo(uint32_t* packet_count,
- uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const {
- return rtcp_receiver_.RemoteRTCPSenderInfo(packet_count, octet_count,
- ntp_timestamp_ms);
+void ModuleRtpRtcpImpl::RemoteRTCPSenderInfo(
+ uint32_t* packet_count, uint32_t* octet_count, int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const {
+ return rtcp_receiver_.RemoteRTCPSenderInfo(
+ packet_count, octet_count, ntp_timestamp_ms, remote_ntp_timestamp_ms);
}
std::vector<ReportBlockData> ModuleRtpRtcpImpl::GetLatestReportBlockData()
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.h b/modules/rtp_rtcp/source/rtp_rtcp_impl.h
index 2ad73523db..f990a0e452 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.h
@@ -205,7 +205,8 @@ class ABSL_DEPRECATED("") ModuleRtpRtcpImpl
void RemoteRTCPSenderInfo(uint32_t* packet_count,
uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const override;
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const override;
// A snapshot of the most recent Report Block with additional data of
// interest to statistics. Used to implement RTCRemoteInboundRtpStreamStats.
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
index 32258b9c2b..a571ab834a 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
@@ -526,11 +526,11 @@ void ModuleRtpRtcpImpl2::GetSendStreamDataCounters(
}
// Received RTCP report.
-void ModuleRtpRtcpImpl2::RemoteRTCPSenderInfo(uint32_t* packet_count,
- uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const {
- return rtcp_receiver_.RemoteRTCPSenderInfo(packet_count, octet_count,
- ntp_timestamp_ms);
+void ModuleRtpRtcpImpl2::RemoteRTCPSenderInfo(
+ uint32_t* packet_count, uint32_t* octet_count, int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const {
+ return rtcp_receiver_.RemoteRTCPSenderInfo(
+ packet_count, octet_count, ntp_timestamp_ms, remote_ntp_timestamp_ms);
}
std::vector<ReportBlockData> ModuleRtpRtcpImpl2::GetLatestReportBlockData()
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
index 625ec14c8d..af123a3015 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
@@ -200,7 +200,8 @@ class ModuleRtpRtcpImpl2 final : public RtpRtcpInterface,
void RemoteRTCPSenderInfo(uint32_t* packet_count,
uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const override;
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const override;
// A snapshot of the most recent Report Block with additional data of
// interest to statistics. Used to implement RTCRemoteInboundRtpStreamStats.
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_interface.h b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
index 3cfd0d4d01..44fad3889a 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_interface.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
@@ -403,10 +403,11 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface {
StreamDataCounters* rtx_counters) const = 0;
- // Returns packet count, octet count, and timestamp from RTCP sender report.
+ // Returns packet count, octet count, and timestamps from RTCP sender report.
virtual void RemoteRTCPSenderInfo(uint32_t* packet_count,
uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const = 0;
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const = 0;
// A snapshot of Report Blocks with additional data of interest to statistics.
// Within this list, the sender-source SSRC pair is unique and per-pair the
// ReportBlockData represents the latest Report Block that was received for
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index a3e3239225..6fe5b247bd 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -1045,9 +1045,10 @@ std::optional<int64_t> RtpVideoStreamReceiver2::LastReceivedKeyframePacketMs()
// seem to be any support for these stats right now. So, we hack this in.
void RtpVideoStreamReceiver2::RemoteRTCPSenderInfo(
uint32_t* packet_count, uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const {
+ int64_t* ntp_timestamp_ms, int64_t* remote_ntp_timestamp_ms) const {
RTC_DCHECK_RUN_ON(&worker_task_checker_);
- rtp_rtcp_->RemoteRTCPSenderInfo(packet_count, octet_count, ntp_timestamp_ms);
+ rtp_rtcp_->RemoteRTCPSenderInfo(packet_count, octet_count, ntp_timestamp_ms,
+ remote_ntp_timestamp_ms);
}
std::optional<RtpRtcpInterface::SenderReportStats>
diff --git a/video/rtp_video_stream_receiver2.h b/video/rtp_video_stream_receiver2.h
index 0fb3cd1b7c..11b9548b76 100644
--- a/video/rtp_video_stream_receiver2.h
+++ b/video/rtp_video_stream_receiver2.h
@@ -215,7 +215,8 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender,
// stats at all, and even on the most recent libwebrtc code there does not
// seem to be any support for these stats right now. So, we hack this in.
void RemoteRTCPSenderInfo(uint32_t* packet_count, uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const;
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const;
private:
// Implements RtpVideoFrameReceiver.
diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc
index a655a072c4..ed9edcdd08 100644
--- a/video/video_receive_stream2.cc
+++ b/video/video_receive_stream2.cc
@@ -584,7 +584,8 @@ VideoReceiveStreamInterface::Stats VideoReceiveStream2::GetStats() const {
// seem to be any support for these stats right now. So, we hack this in.
rtp_video_stream_receiver_.RemoteRTCPSenderInfo(
&stats.rtcp_sender_packets_sent, &stats.rtcp_sender_octets_sent,
- &stats.rtcp_sender_ntp_timestamp_ms);
+ &stats.rtcp_sender_ntp_timestamp_ms,
+ &stats.rtcp_sender_remote_ntp_timestamp_ms);
return stats;
}

View File

@ -1,205 +1,23 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Tue, 2 Nov 2021 14:35:00 +0000
Subject: Bug 1729455 - Add to stats the local receive time for receiving video
Sender Reports. r=ng
Subject: Bug 1729455 - Ensure the libwebrtc system clock is not used. r=bwc
Differential Revision: https://phabricator.services.mozilla.com/D125712
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/99267b6d193fbcb3e4c845c5e80770424d6d06e2
Differential Revision: https://phabricator.services.mozilla.com/D128244
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/3e8ac168ee3db089dd892bf140df53e15d6f0918
---
call/video_receive_stream.h | 3 ++-
modules/rtp_rtcp/source/rtcp_receiver.cc | 6 ++++--
modules/rtp_rtcp/source/rtcp_receiver.h | 3 ++-
modules/rtp_rtcp/source/rtp_rtcp_impl.cc | 10 +++++-----
modules/rtp_rtcp/source/rtp_rtcp_impl.h | 3 ++-
modules/rtp_rtcp/source/rtp_rtcp_impl2.cc | 10 +++++-----
modules/rtp_rtcp/source/rtp_rtcp_impl2.h | 3 ++-
modules/rtp_rtcp/source/rtp_rtcp_interface.h | 5 +++--
video/rtp_video_stream_receiver2.cc | 5 +++--
video/rtp_video_stream_receiver2.h | 3 ++-
video/video_receive_stream2.cc | 3 ++-
11 files changed, 32 insertions(+), 22 deletions(-)
rtc_base/system_time.cc | 2 ++
1 file changed, 2 insertions(+)
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index ef23484414..472199ef57 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -170,10 +170,11 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
RtcpPacketTypeCounter rtcp_packet_type_counts;
std::optional<RtpReceiveStats> rtx_rtp_stats;
diff --git a/rtc_base/system_time.cc b/rtc_base/system_time.cc
index 058e6c2990..1a5e447916 100644
--- a/rtc_base/system_time.cc
+++ b/rtc_base/system_time.cc
@@ -12,6 +12,8 @@
// rtc::SystemTimeNanos() must be provided externally.
#ifndef WEBRTC_EXCLUDE_SYSTEM_TIME
- // Mozilla modification: Init these three.
+ // Mozilla modification: Init these.
uint32_t rtcp_sender_packets_sent = 0;
uint32_t rtcp_sender_octets_sent = 0;
int64_t rtcp_sender_ntp_timestamp_ms = 0;
+ int64_t rtcp_sender_remote_ntp_timestamp_ms = 0;
+#error Mozilla: Must not use the built-in libwebrtc clock
+
#include <stdint.h>
// Timing frame info: all important timestamps for a full lifetime of a
// single 'timing frame'.
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc
index 349a9a673e..3298961fd3 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.cc
+++ b/modules/rtp_rtcp/source/rtcp_receiver.cc
@@ -391,11 +391,13 @@ RTCPReceiver::ConsumeReceivedXrReferenceTimeInfo() {
void RTCPReceiver::RemoteRTCPSenderInfo(uint32_t* packet_count,
uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const {
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const {
MutexLock lock(&rtcp_receiver_lock_);
*packet_count = remote_sender_packet_count_;
*octet_count = remote_sender_octet_count_;
- *ntp_timestamp_ms = remote_sender_ntp_time_.ToMs();
+ *ntp_timestamp_ms = last_received_sr_ntp_.ToMs();
+ *remote_ntp_timestamp_ms = remote_sender_ntp_time_.ToMs();
}
std::vector<ReportBlockData> RTCPReceiver::GetLatestReportBlockData() const {
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.h b/modules/rtp_rtcp/source/rtcp_receiver.h
index 33aa986e8b..f6d1e027f4 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.h
+++ b/modules/rtp_rtcp/source/rtcp_receiver.h
@@ -126,7 +126,8 @@ class RTCPReceiver final {
// Get received sender packet and octet counts
void RemoteRTCPSenderInfo(uint32_t* packet_count,
uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const;
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const;
std::optional<TimeDelta> AverageRtt() const;
std::optional<TimeDelta> LastRtt() const;
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
index 69b6636d3a..284fb65109 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
@@ -515,11 +515,11 @@ void ModuleRtpRtcpImpl::GetSendStreamDataCounters(
}
// Received RTCP report.
-void ModuleRtpRtcpImpl::RemoteRTCPSenderInfo(uint32_t* packet_count,
- uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const {
- return rtcp_receiver_.RemoteRTCPSenderInfo(packet_count, octet_count,
- ntp_timestamp_ms);
+void ModuleRtpRtcpImpl::RemoteRTCPSenderInfo(
+ uint32_t* packet_count, uint32_t* octet_count, int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const {
+ return rtcp_receiver_.RemoteRTCPSenderInfo(
+ packet_count, octet_count, ntp_timestamp_ms, remote_ntp_timestamp_ms);
}
std::vector<ReportBlockData> ModuleRtpRtcpImpl::GetLatestReportBlockData()
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.h b/modules/rtp_rtcp/source/rtp_rtcp_impl.h
index 2ad73523db..f990a0e452 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.h
@@ -205,7 +205,8 @@ class ABSL_DEPRECATED("") ModuleRtpRtcpImpl
void RemoteRTCPSenderInfo(uint32_t* packet_count,
uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const override;
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const override;
// A snapshot of the most recent Report Block with additional data of
// interest to statistics. Used to implement RTCRemoteInboundRtpStreamStats.
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
index 32258b9c2b..a571ab834a 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
@@ -526,11 +526,11 @@ void ModuleRtpRtcpImpl2::GetSendStreamDataCounters(
}
// Received RTCP report.
-void ModuleRtpRtcpImpl2::RemoteRTCPSenderInfo(uint32_t* packet_count,
- uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const {
- return rtcp_receiver_.RemoteRTCPSenderInfo(packet_count, octet_count,
- ntp_timestamp_ms);
+void ModuleRtpRtcpImpl2::RemoteRTCPSenderInfo(
+ uint32_t* packet_count, uint32_t* octet_count, int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const {
+ return rtcp_receiver_.RemoteRTCPSenderInfo(
+ packet_count, octet_count, ntp_timestamp_ms, remote_ntp_timestamp_ms);
}
std::vector<ReportBlockData> ModuleRtpRtcpImpl2::GetLatestReportBlockData()
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
index 625ec14c8d..af123a3015 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
@@ -200,7 +200,8 @@ class ModuleRtpRtcpImpl2 final : public RtpRtcpInterface,
void RemoteRTCPSenderInfo(uint32_t* packet_count,
uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const override;
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const override;
// A snapshot of the most recent Report Block with additional data of
// interest to statistics. Used to implement RTCRemoteInboundRtpStreamStats.
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_interface.h b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
index 3cfd0d4d01..44fad3889a 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_interface.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
@@ -403,10 +403,11 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface {
StreamDataCounters* rtx_counters) const = 0;
- // Returns packet count, octet count, and timestamp from RTCP sender report.
+ // Returns packet count, octet count, and timestamps from RTCP sender report.
virtual void RemoteRTCPSenderInfo(uint32_t* packet_count,
uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const = 0;
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const = 0;
// A snapshot of Report Blocks with additional data of interest to statistics.
// Within this list, the sender-source SSRC pair is unique and per-pair the
// ReportBlockData represents the latest Report Block that was received for
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index a3e3239225..6fe5b247bd 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -1045,9 +1045,10 @@ std::optional<int64_t> RtpVideoStreamReceiver2::LastReceivedKeyframePacketMs()
// seem to be any support for these stats right now. So, we hack this in.
void RtpVideoStreamReceiver2::RemoteRTCPSenderInfo(
uint32_t* packet_count, uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const {
+ int64_t* ntp_timestamp_ms, int64_t* remote_ntp_timestamp_ms) const {
RTC_DCHECK_RUN_ON(&worker_task_checker_);
- rtp_rtcp_->RemoteRTCPSenderInfo(packet_count, octet_count, ntp_timestamp_ms);
+ rtp_rtcp_->RemoteRTCPSenderInfo(packet_count, octet_count, ntp_timestamp_ms,
+ remote_ntp_timestamp_ms);
}
std::optional<RtpRtcpInterface::SenderReportStats>
diff --git a/video/rtp_video_stream_receiver2.h b/video/rtp_video_stream_receiver2.h
index 0fb3cd1b7c..11b9548b76 100644
--- a/video/rtp_video_stream_receiver2.h
+++ b/video/rtp_video_stream_receiver2.h
@@ -215,7 +215,8 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender,
// stats at all, and even on the most recent libwebrtc code there does not
// seem to be any support for these stats right now. So, we hack this in.
void RemoteRTCPSenderInfo(uint32_t* packet_count, uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const;
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const;
private:
// Implements RtpVideoFrameReceiver.
diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc
index a655a072c4..ed9edcdd08 100644
--- a/video/video_receive_stream2.cc
+++ b/video/video_receive_stream2.cc
@@ -584,7 +584,8 @@ VideoReceiveStreamInterface::Stats VideoReceiveStream2::GetStats() const {
// seem to be any support for these stats right now. So, we hack this in.
rtp_video_stream_receiver_.RemoteRTCPSenderInfo(
&stats.rtcp_sender_packets_sent, &stats.rtcp_sender_octets_sent,
- &stats.rtcp_sender_ntp_timestamp_ms);
+ &stats.rtcp_sender_ntp_timestamp_ms,
+ &stats.rtcp_sender_remote_ntp_timestamp_ms);
return stats;
}
#include <limits>

View File

@ -1,23 +1,104 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Tue, 2 Nov 2021 14:35:00 +0000
Subject: Bug 1729455 - Ensure the libwebrtc system clock is not used. r=bwc
Subject: Bug 1729455 - Inject RTCStatsTimestampMakerRealtimeClock into Call
instances. r=bwc
Differential Revision: https://phabricator.services.mozilla.com/D128244
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/3e8ac168ee3db089dd892bf140df53e15d6f0918
This patch makes libwebrtc use our clock for timestamps.
It also makes sure there's no use of the libwebrtc realtime clock, other than
for relative time tracking (like timeouts), and that future libwebrtc updates
don't introduce unaudited use of it.
Differential Revision: https://phabricator.services.mozilla.com/D127714
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0744d68b8c944e69945de4ac5c4ca71332e78ad8
---
rtc_base/system_time.cc | 2 ++
1 file changed, 2 insertions(+)
modules/rtp_rtcp/include/flexfec_receiver.h | 2 ++
modules/rtp_rtcp/source/flexfec_receiver.cc | 2 ++
rtc_base/task_utils/repeating_task.h | 4 ++--
system_wrappers/include/clock.h | 2 +-
system_wrappers/source/clock.cc | 2 +-
5 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/rtc_base/system_time.cc b/rtc_base/system_time.cc
index 058e6c2990..1a5e447916 100644
--- a/rtc_base/system_time.cc
+++ b/rtc_base/system_time.cc
@@ -12,6 +12,8 @@
// rtc::SystemTimeNanos() must be provided externally.
#ifndef WEBRTC_EXCLUDE_SYSTEM_TIME
diff --git a/modules/rtp_rtcp/include/flexfec_receiver.h b/modules/rtp_rtcp/include/flexfec_receiver.h
index a869c8ad41..b6a33882d1 100644
--- a/modules/rtp_rtcp/include/flexfec_receiver.h
+++ b/modules/rtp_rtcp/include/flexfec_receiver.h
@@ -30,9 +30,11 @@ class Clock;
+#error Mozilla: Must not use the built-in libwebrtc clock
+
#include <stdint.h>
class FlexfecReceiver {
public:
+ /* Mozilla: Avoid this since it could use GetRealTimeClock().
FlexfecReceiver(uint32_t ssrc,
uint32_t protected_media_ssrc,
RecoveredPacketReceiver* recovered_packet_receiver);
+ */
FlexfecReceiver(Clock* clock,
uint32_t ssrc,
uint32_t protected_media_ssrc,
diff --git a/modules/rtp_rtcp/source/flexfec_receiver.cc b/modules/rtp_rtcp/source/flexfec_receiver.cc
index 7f2cc0cb3c..2ba85a2157 100644
--- a/modules/rtp_rtcp/source/flexfec_receiver.cc
+++ b/modules/rtp_rtcp/source/flexfec_receiver.cc
@@ -31,6 +31,7 @@ constexpr TimeDelta kPacketLogInterval = TimeDelta::Seconds(10);
#include <limits>
} // namespace
+/* Mozilla: Avoid this since it could use GetRealTimeClock().
FlexfecReceiver::FlexfecReceiver(
uint32_t ssrc,
uint32_t protected_media_ssrc,
@@ -39,6 +40,7 @@ FlexfecReceiver::FlexfecReceiver(
ssrc,
protected_media_ssrc,
recovered_packet_receiver) {}
+ */
FlexfecReceiver::FlexfecReceiver(
Clock* clock,
diff --git a/rtc_base/task_utils/repeating_task.h b/rtc_base/task_utils/repeating_task.h
index c45de95ecc..28c691c3de 100644
--- a/rtc_base/task_utils/repeating_task.h
+++ b/rtc_base/task_utils/repeating_task.h
@@ -57,7 +57,7 @@ class RepeatingTaskHandle {
absl::AnyInvocable<TimeDelta()> closure,
TaskQueueBase::DelayPrecision precision =
TaskQueueBase::DelayPrecision::kLow,
- Clock* clock = Clock::GetRealTimeClock(),
+ Clock* clock = Clock::GetRealTimeClockRaw(),
const Location& location = Location::Current());
// DelayedStart is equivalent to Start except that the first invocation of the
@@ -68,7 +68,7 @@ class RepeatingTaskHandle {
absl::AnyInvocable<TimeDelta()> closure,
TaskQueueBase::DelayPrecision precision =
TaskQueueBase::DelayPrecision::kLow,
- Clock* clock = Clock::GetRealTimeClock(),
+ Clock* clock = Clock::GetRealTimeClockRaw(),
const Location& location = Location::Current());
// Stops future invocations of the repeating task closure. Can only be called
diff --git a/system_wrappers/include/clock.h b/system_wrappers/include/clock.h
index 60296070cc..214b34c970 100644
--- a/system_wrappers/include/clock.h
+++ b/system_wrappers/include/clock.h
@@ -49,7 +49,7 @@ class RTC_EXPORT Clock {
}
// Returns an instance of the real-time system clock implementation.
- static Clock* GetRealTimeClock();
+ static Clock* GetRealTimeClockRaw();
};
class SimulatedClock : public Clock {
diff --git a/system_wrappers/source/clock.cc b/system_wrappers/source/clock.cc
index 88c99d6a68..f7460b831c 100644
--- a/system_wrappers/source/clock.cc
+++ b/system_wrappers/source/clock.cc
@@ -57,7 +57,7 @@ class RealTimeClock : public Clock {
}
};
-Clock* Clock::GetRealTimeClock() {
+Clock* Clock::GetRealTimeClockRaw() {
static Clock* const clock = new RealTimeClock();
return clock;
}

View File

@ -1,104 +1,88 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Tue, 2 Nov 2021 14:35:00 +0000
Subject: Bug 1729455 - Inject RTCStatsTimestampMakerRealtimeClock into Call
instances. r=bwc
From: Landry Breuil <landry@openbsd.org>
Date: Wed, 22 Dec 2021 00:09:00 +0000
Subject: Bug 1654448 - P2 - readd partial support for BSD to webrtc
build;r=mjf
This patch makes libwebrtc use our clock for timestamps.
It also makes sure there's no use of the libwebrtc realtime clock, other than
for relative time tracking (like timeouts), and that future libwebrtc updates
don't introduce unaudited use of it.
only OpenBSD/amd64 is supported for now
Differential Revision: https://phabricator.services.mozilla.com/D127714
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0744d68b8c944e69945de4ac5c4ca71332e78ad8
Depends on D134432
Differential Revision: https://phabricator.services.mozilla.com/D134433
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0300b32b7de70fb8976dc82d7d3bb3adb9685857
---
modules/rtp_rtcp/include/flexfec_receiver.h | 2 ++
modules/rtp_rtcp/source/flexfec_receiver.cc | 2 ++
rtc_base/task_utils/repeating_task.h | 4 ++--
system_wrappers/include/clock.h | 2 +-
system_wrappers/source/clock.cc | 2 +-
5 files changed, 8 insertions(+), 4 deletions(-)
BUILD.gn | 3 +++
modules/video_capture/BUILD.gn | 2 +-
modules/video_capture/linux/device_info_v4l2.h | 2 ++
rtc_base/platform_thread_types.cc | 4 +++-
webrtc.gni | 2 +-
5 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/modules/rtp_rtcp/include/flexfec_receiver.h b/modules/rtp_rtcp/include/flexfec_receiver.h
index a869c8ad41..b6a33882d1 100644
--- a/modules/rtp_rtcp/include/flexfec_receiver.h
+++ b/modules/rtp_rtcp/include/flexfec_receiver.h
@@ -30,9 +30,11 @@ class Clock;
class FlexfecReceiver {
public:
+ /* Mozilla: Avoid this since it could use GetRealTimeClock().
FlexfecReceiver(uint32_t ssrc,
uint32_t protected_media_ssrc,
RecoveredPacketReceiver* recovered_packet_receiver);
+ */
FlexfecReceiver(Clock* clock,
uint32_t ssrc,
uint32_t protected_media_ssrc,
diff --git a/modules/rtp_rtcp/source/flexfec_receiver.cc b/modules/rtp_rtcp/source/flexfec_receiver.cc
index 7f2cc0cb3c..2ba85a2157 100644
--- a/modules/rtp_rtcp/source/flexfec_receiver.cc
+++ b/modules/rtp_rtcp/source/flexfec_receiver.cc
@@ -31,6 +31,7 @@ constexpr TimeDelta kPacketLogInterval = TimeDelta::Seconds(10);
} // namespace
+/* Mozilla: Avoid this since it could use GetRealTimeClock().
FlexfecReceiver::FlexfecReceiver(
uint32_t ssrc,
uint32_t protected_media_ssrc,
@@ -39,6 +40,7 @@ FlexfecReceiver::FlexfecReceiver(
ssrc,
protected_media_ssrc,
recovered_packet_receiver) {}
+ */
FlexfecReceiver::FlexfecReceiver(
Clock* clock,
diff --git a/rtc_base/task_utils/repeating_task.h b/rtc_base/task_utils/repeating_task.h
index c45de95ecc..28c691c3de 100644
--- a/rtc_base/task_utils/repeating_task.h
+++ b/rtc_base/task_utils/repeating_task.h
@@ -57,7 +57,7 @@ class RepeatingTaskHandle {
absl::AnyInvocable<TimeDelta()> closure,
TaskQueueBase::DelayPrecision precision =
TaskQueueBase::DelayPrecision::kLow,
- Clock* clock = Clock::GetRealTimeClock(),
+ Clock* clock = Clock::GetRealTimeClockRaw(),
const Location& location = Location::Current());
// DelayedStart is equivalent to Start except that the first invocation of the
@@ -68,7 +68,7 @@ class RepeatingTaskHandle {
absl::AnyInvocable<TimeDelta()> closure,
TaskQueueBase::DelayPrecision precision =
TaskQueueBase::DelayPrecision::kLow,
- Clock* clock = Clock::GetRealTimeClock(),
+ Clock* clock = Clock::GetRealTimeClockRaw(),
const Location& location = Location::Current());
// Stops future invocations of the repeating task closure. Can only be called
diff --git a/system_wrappers/include/clock.h b/system_wrappers/include/clock.h
index 60296070cc..214b34c970 100644
--- a/system_wrappers/include/clock.h
+++ b/system_wrappers/include/clock.h
@@ -49,7 +49,7 @@ class RTC_EXPORT Clock {
diff --git a/BUILD.gn b/BUILD.gn
index 87881380da..7d3005cbe3 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -222,6 +222,9 @@ config("common_inherited_config") {
if (is_linux || is_chromeos) {
defines += [ "WEBRTC_LINUX" ]
}
// Returns an instance of the real-time system clock implementation.
- static Clock* GetRealTimeClock();
+ static Clock* GetRealTimeClockRaw();
};
class SimulatedClock : public Clock {
diff --git a/system_wrappers/source/clock.cc b/system_wrappers/source/clock.cc
index 88c99d6a68..f7460b831c 100644
--- a/system_wrappers/source/clock.cc
+++ b/system_wrappers/source/clock.cc
@@ -57,7 +57,7 @@ class RealTimeClock : public Clock {
+ if (is_bsd) {
+ defines += [ "WEBRTC_BSD" ]
+ }
if (is_mac) {
defines += [ "WEBRTC_MAC" ]
}
};
diff --git a/modules/video_capture/BUILD.gn b/modules/video_capture/BUILD.gn
index a8994aaa68..a2bf27f645 100644
--- a/modules/video_capture/BUILD.gn
+++ b/modules/video_capture/BUILD.gn
@@ -72,7 +72,7 @@ if (!build_with_chromium || is_linux || is_chromeos) {
"video_capture_options.h",
]
-Clock* Clock::GetRealTimeClock() {
+Clock* Clock::GetRealTimeClockRaw() {
static Clock* const clock = new RealTimeClock();
return clock;
- if (is_linux || is_chromeos) {
+ if (is_linux || is_bsd || is_chromeos) {
sources += [
"linux/device_info_linux.cc",
"linux/device_info_v4l2.cc",
diff --git a/modules/video_capture/linux/device_info_v4l2.h b/modules/video_capture/linux/device_info_v4l2.h
index e3c2395f49..119cb07ab8 100644
--- a/modules/video_capture/linux/device_info_v4l2.h
+++ b/modules/video_capture/linux/device_info_v4l2.h
@@ -16,7 +16,9 @@
#include "modules/video_capture/device_info_impl.h"
#include "rtc_base/platform_thread.h"
+#ifdef WEBRTC_LINUX
#include <sys/inotify.h>
+#endif
struct v4l2_capability;
diff --git a/rtc_base/platform_thread_types.cc b/rtc_base/platform_thread_types.cc
index d64ea689bb..c3c6955a7b 100644
--- a/rtc_base/platform_thread_types.cc
+++ b/rtc_base/platform_thread_types.cc
@@ -50,7 +50,9 @@ PlatformThreadId CurrentThreadId() {
return static_cast<PlatformThreadId>(pthread_self());
#else
// Default implementation for nacl and solaris.
- return reinterpret_cast<PlatformThreadId>(pthread_self());
+ // WEBRTC_BSD: pthread_t is a pointer, so cannot be casted to pid_t
+ // (aka int32_t) on 64-bit archs. Required on OpenBSD.
+ return reinterpret_cast<long>(pthread_self());
#endif
#endif // defined(WEBRTC_POSIX)
}
diff --git a/webrtc.gni b/webrtc.gni
index 156c3d3985..f55b88a061 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -363,7 +363,7 @@ rtc_opus_dir = "//third_party/opus"
# Desktop capturer is supported only on Windows, OSX and Linux.
rtc_desktop_capture_supported =
- (is_win && current_os != "winuwp") || is_mac ||
+ (is_win && current_os != "winuwp") || is_mac || is_bsd ||
((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire))
###############################################################################

View File

@ -1,88 +1,138 @@
From: Landry Breuil <landry@openbsd.org>
Date: Wed, 22 Dec 2021 00:09:00 +0000
Subject: Bug 1654448 - P2 - readd partial support for BSD to webrtc
build;r=mjf
From: Michael Froman <mjfroman@mac.com>
Date: Mon, 4 Apr 2022 12:25:26 -0500
Subject: Bug 1766646 - (fix) breakout Call::Stats and SharedModuleThread into
seperate files
only OpenBSD/amd64 is supported for now
Depends on D134432
Differential Revision: https://phabricator.services.mozilla.com/D134433
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0300b32b7de70fb8976dc82d7d3bb3adb9685857
---
BUILD.gn | 3 +++
modules/video_capture/BUILD.gn | 2 +-
modules/video_capture/linux/device_info_v4l2.h | 2 ++
rtc_base/platform_thread_types.cc | 4 +++-
webrtc.gni | 2 +-
5 files changed, 10 insertions(+), 3 deletions(-)
call/BUILD.gn | 6 ++++++
call/call.cc | 13 -------------
call/call.h | 11 ++---------
call/call_basic_stats.cc | 20 ++++++++++++++++++++
call/call_basic_stats.h | 21 +++++++++++++++++++++
5 files changed, 49 insertions(+), 22 deletions(-)
create mode 100644 call/call_basic_stats.cc
create mode 100644 call/call_basic_stats.h
diff --git a/BUILD.gn b/BUILD.gn
index 87881380da..7d3005cbe3 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -222,6 +222,9 @@ config("common_inherited_config") {
if (is_linux || is_chromeos) {
defines += [ "WEBRTC_LINUX" ]
}
+ if (is_bsd) {
+ defines += [ "WEBRTC_BSD" ]
diff --git a/call/BUILD.gn b/call/BUILD.gn
index 8fb9bacedc..71b827ea82 100644
--- a/call/BUILD.gn
+++ b/call/BUILD.gn
@@ -33,6 +33,12 @@ rtc_library("call_interfaces") {
"syncable.cc",
"syncable.h",
]
+ if (build_with_mozilla) {
+ sources += [
+ "call_basic_stats.cc",
+ "call_basic_stats.h",
+ ]
+ }
if (is_mac) {
defines += [ "WEBRTC_MAC" ]
}
diff --git a/modules/video_capture/BUILD.gn b/modules/video_capture/BUILD.gn
index a8994aaa68..a2bf27f645 100644
--- a/modules/video_capture/BUILD.gn
+++ b/modules/video_capture/BUILD.gn
@@ -72,7 +72,7 @@ if (!build_with_chromium || is_linux || is_chromeos) {
"video_capture_options.h",
]
- if (is_linux || is_chromeos) {
+ if (is_linux || is_bsd || is_chromeos) {
sources += [
"linux/device_info_linux.cc",
"linux/device_info_v4l2.cc",
diff --git a/modules/video_capture/linux/device_info_v4l2.h b/modules/video_capture/linux/device_info_v4l2.h
index e3c2395f49..119cb07ab8 100644
--- a/modules/video_capture/linux/device_info_v4l2.h
+++ b/modules/video_capture/linux/device_info_v4l2.h
@@ -16,7 +16,9 @@
#include "modules/video_capture/device_info_impl.h"
deps = [
":audio_sender_interface",
diff --git a/call/call.cc b/call/call.cc
index 2b7751742f..11dbef3212 100644
--- a/call/call.cc
+++ b/call/call.cc
@@ -510,19 +510,6 @@ class Call final : public webrtc::Call,
};
} // namespace internal
#include "rtc_base/platform_thread.h"
+#ifdef WEBRTC_LINUX
#include <sys/inotify.h>
+#endif
-std::string Call::Stats::ToString(int64_t time_ms) const {
- char buf[1024];
- rtc::SimpleStringBuilder ss(buf);
- ss << "Call stats: " << time_ms << ", {";
- ss << "send_bw_bps: " << send_bandwidth_bps << ", ";
- ss << "recv_bw_bps: " << recv_bandwidth_bps << ", ";
- ss << "max_pad_bps: " << max_padding_bitrate_bps << ", ";
- ss << "pacer_delay_ms: " << pacer_delay_ms << ", ";
- ss << "rtt_ms: " << rtt_ms;
- ss << '}';
- return ss.str();
-}
-
std::unique_ptr<Call> Call::Create(CallConfig config) {
std::unique_ptr<RtpTransportControllerSendInterface> transport_send;
if (config.rtp_transport_controller_send_factory != nullptr) {
diff --git a/call/call.h b/call/call.h
index 313e8a85d1..ef782c2bb8 100644
--- a/call/call.h
+++ b/call/call.h
@@ -25,6 +25,7 @@
#include "api/transport/bitrate_settings.h"
#include "call/audio_receive_stream.h"
#include "call/audio_send_stream.h"
+#include "call/call_basic_stats.h"
#include "call/call_config.h"
#include "call/flexfec_receive_stream.h"
#include "call/packet_receiver.h"
@@ -50,15 +51,7 @@ namespace webrtc {
struct v4l2_capability;
class Call {
public:
- struct Stats {
- std::string ToString(int64_t time_ms) const;
-
- int send_bandwidth_bps = 0; // Estimated available send bandwidth.
- int max_padding_bitrate_bps = 0; // Cumulative configured max padding.
- int recv_bandwidth_bps = 0; // Estimated available receive bandwidth.
- int64_t pacer_delay_ms = 0;
- int64_t rtt_ms = -1;
- };
+ using Stats = CallBasicStats;
diff --git a/rtc_base/platform_thread_types.cc b/rtc_base/platform_thread_types.cc
index d64ea689bb..c3c6955a7b 100644
--- a/rtc_base/platform_thread_types.cc
+++ b/rtc_base/platform_thread_types.cc
@@ -50,7 +50,9 @@ PlatformThreadId CurrentThreadId() {
return static_cast<PlatformThreadId>(pthread_self());
#else
// Default implementation for nacl and solaris.
- return reinterpret_cast<PlatformThreadId>(pthread_self());
+ // WEBRTC_BSD: pthread_t is a pointer, so cannot be casted to pid_t
+ // (aka int32_t) on 64-bit archs. Required on OpenBSD.
+ return reinterpret_cast<long>(pthread_self());
#endif
#endif // defined(WEBRTC_POSIX)
}
diff --git a/webrtc.gni b/webrtc.gni
index 156c3d3985..f55b88a061 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -363,7 +363,7 @@ rtc_opus_dir = "//third_party/opus"
static std::unique_ptr<Call> Create(CallConfig config);
# Desktop capturer is supported only on Windows, OSX and Linux.
rtc_desktop_capture_supported =
- (is_win && current_os != "winuwp") || is_mac ||
+ (is_win && current_os != "winuwp") || is_mac || is_bsd ||
((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire))
###############################################################################
diff --git a/call/call_basic_stats.cc b/call/call_basic_stats.cc
new file mode 100644
index 0000000000..74333a663b
--- /dev/null
+++ b/call/call_basic_stats.cc
@@ -0,0 +1,20 @@
+#include "call/call_basic_stats.h"
+
+#include "rtc_base/strings/string_builder.h"
+
+namespace webrtc {
+
+std::string CallBasicStats::ToString(int64_t time_ms) const {
+ char buf[1024];
+ rtc::SimpleStringBuilder ss(buf);
+ ss << "Call stats: " << time_ms << ", {";
+ ss << "send_bw_bps: " << send_bandwidth_bps << ", ";
+ ss << "recv_bw_bps: " << recv_bandwidth_bps << ", ";
+ ss << "max_pad_bps: " << max_padding_bitrate_bps << ", ";
+ ss << "pacer_delay_ms: " << pacer_delay_ms << ", ";
+ ss << "rtt_ms: " << rtt_ms;
+ ss << '}';
+ return ss.str();
+}
+
+} // namespace webrtc
diff --git a/call/call_basic_stats.h b/call/call_basic_stats.h
new file mode 100644
index 0000000000..98febe9405
--- /dev/null
+++ b/call/call_basic_stats.h
@@ -0,0 +1,21 @@
+#ifndef CALL_CALL_BASIC_STATS_H_
+#define CALL_CALL_BASIC_STATS_H_
+
+#include <string>
+
+namespace webrtc {
+
+// named to avoid conflicts with video/call_stats.h
+struct CallBasicStats {
+ std::string ToString(int64_t time_ms) const;
+
+ int send_bandwidth_bps = 0; // Estimated available send bandwidth.
+ int max_padding_bitrate_bps = 0; // Cumulative configured max padding.
+ int recv_bandwidth_bps = 0; // Estimated available receive bandwidth.
+ int64_t pacer_delay_ms = 0;
+ int64_t rtt_ms = -1;
+};
+
+} // namespace webrtc
+
+#endif // CALL_CALL_BASIC_STATS_H_

View File

@ -1,138 +1,29 @@
From: Michael Froman <mjfroman@mac.com>
Date: Mon, 4 Apr 2022 12:25:26 -0500
Subject: Bug 1766646 - (fix) breakout Call::Stats and SharedModuleThread into
seperate files
Date: Fri, 8 Apr 2022 11:36:36 -0500
Subject: Bug 1766646 - (fix-b556b08668) avoid InlinedVector method that can
throw exception
---
call/BUILD.gn | 6 ++++++
call/call.cc | 13 -------------
call/call.h | 11 ++---------
call/call_basic_stats.cc | 20 ++++++++++++++++++++
call/call_basic_stats.h | 21 +++++++++++++++++++++
5 files changed, 49 insertions(+), 22 deletions(-)
create mode 100644 call/call_basic_stats.cc
create mode 100644 call/call_basic_stats.h
api/video_codecs/video_encoder.cc | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/call/BUILD.gn b/call/BUILD.gn
index 8fb9bacedc..71b827ea82 100644
--- a/call/BUILD.gn
+++ b/call/BUILD.gn
@@ -33,6 +33,12 @@ rtc_library("call_interfaces") {
"syncable.cc",
"syncable.h",
]
+ if (build_with_mozilla) {
+ sources += [
+ "call_basic_stats.cc",
+ "call_basic_stats.h",
+ ]
+ }
deps = [
":audio_sender_interface",
diff --git a/call/call.cc b/call/call.cc
index 2b7751742f..11dbef3212 100644
--- a/call/call.cc
+++ b/call/call.cc
@@ -510,19 +510,6 @@ class Call final : public webrtc::Call,
};
} // namespace internal
-std::string Call::Stats::ToString(int64_t time_ms) const {
- char buf[1024];
- rtc::SimpleStringBuilder ss(buf);
- ss << "Call stats: " << time_ms << ", {";
- ss << "send_bw_bps: " << send_bandwidth_bps << ", ";
- ss << "recv_bw_bps: " << recv_bandwidth_bps << ", ";
- ss << "max_pad_bps: " << max_padding_bitrate_bps << ", ";
- ss << "pacer_delay_ms: " << pacer_delay_ms << ", ";
- ss << "rtt_ms: " << rtt_ms;
- ss << '}';
- return ss.str();
-}
-
std::unique_ptr<Call> Call::Create(CallConfig config) {
std::unique_ptr<RtpTransportControllerSendInterface> transport_send;
if (config.rtp_transport_controller_send_factory != nullptr) {
diff --git a/call/call.h b/call/call.h
index 313e8a85d1..ef782c2bb8 100644
--- a/call/call.h
+++ b/call/call.h
@@ -25,6 +25,7 @@
#include "api/transport/bitrate_settings.h"
#include "call/audio_receive_stream.h"
#include "call/audio_send_stream.h"
+#include "call/call_basic_stats.h"
#include "call/call_config.h"
#include "call/flexfec_receive_stream.h"
#include "call/packet_receiver.h"
@@ -50,15 +51,7 @@ namespace webrtc {
class Call {
public:
- struct Stats {
- std::string ToString(int64_t time_ms) const;
-
- int send_bandwidth_bps = 0; // Estimated available send bandwidth.
- int max_padding_bitrate_bps = 0; // Cumulative configured max padding.
- int recv_bandwidth_bps = 0; // Estimated available receive bandwidth.
- int64_t pacer_delay_ms = 0;
- int64_t rtt_ms = -1;
- };
+ using Stats = CallBasicStats;
static std::unique_ptr<Call> Create(CallConfig config);
diff --git a/call/call_basic_stats.cc b/call/call_basic_stats.cc
new file mode 100644
index 0000000000..74333a663b
--- /dev/null
+++ b/call/call_basic_stats.cc
@@ -0,0 +1,20 @@
+#include "call/call_basic_stats.h"
+
+#include "rtc_base/strings/string_builder.h"
+
+namespace webrtc {
+
+std::string CallBasicStats::ToString(int64_t time_ms) const {
+ char buf[1024];
+ rtc::SimpleStringBuilder ss(buf);
+ ss << "Call stats: " << time_ms << ", {";
+ ss << "send_bw_bps: " << send_bandwidth_bps << ", ";
+ ss << "recv_bw_bps: " << recv_bandwidth_bps << ", ";
+ ss << "max_pad_bps: " << max_padding_bitrate_bps << ", ";
+ ss << "pacer_delay_ms: " << pacer_delay_ms << ", ";
+ ss << "rtt_ms: " << rtt_ms;
+ ss << '}';
+ return ss.str();
+}
+
+} // namespace webrtc
diff --git a/call/call_basic_stats.h b/call/call_basic_stats.h
new file mode 100644
index 0000000000..98febe9405
--- /dev/null
+++ b/call/call_basic_stats.h
@@ -0,0 +1,21 @@
+#ifndef CALL_CALL_BASIC_STATS_H_
+#define CALL_CALL_BASIC_STATS_H_
+
+#include <string>
+
+namespace webrtc {
+
+// named to avoid conflicts with video/call_stats.h
+struct CallBasicStats {
+ std::string ToString(int64_t time_ms) const;
+
+ int send_bandwidth_bps = 0; // Estimated available send bandwidth.
+ int max_padding_bitrate_bps = 0; // Cumulative configured max padding.
+ int recv_bandwidth_bps = 0; // Estimated available receive bandwidth.
+ int64_t pacer_delay_ms = 0;
+ int64_t rtt_ms = -1;
+};
+
+} // namespace webrtc
+
+#endif // CALL_CALL_BASIC_STATS_H_
diff --git a/api/video_codecs/video_encoder.cc b/api/video_codecs/video_encoder.cc
index c3b5f3a4e9..22a532d328 100644
--- a/api/video_codecs/video_encoder.cc
+++ b/api/video_codecs/video_encoder.cc
@@ -192,7 +192,15 @@ std::string VideoEncoder::EncoderInfo::ToString() const {
for (size_t i = 0; i < preferred_pixel_formats.size(); ++i) {
if (i > 0)
oss << ", ";
+#if defined(WEBRTC_MOZILLA_BUILD)
+ // This could assert, as opposed to throw using the form in the
+ // else, but since we're in a for loop that uses .size() we can
+ // be fairly sure that this is safe without doing a further
+ // check to make sure 'i' is in-range.
+ oss << VideoFrameBufferTypeToString(preferred_pixel_formats[i]);
+#else
oss << VideoFrameBufferTypeToString(preferred_pixel_formats.at(i));
+#endif
}
oss << "]";
if (is_qp_trusted.has_value()) {

View File

@ -1,29 +1,67 @@
From: Michael Froman <mjfroman@mac.com>
Date: Fri, 8 Apr 2022 11:36:36 -0500
Subject: Bug 1766646 - (fix-b556b08668) avoid InlinedVector method that can
throw exception
Date: Thu, 28 Apr 2022 10:53:43 -0500
Subject: Bug 1766646 - (fix-a0bb2ef2dc) add back VideoType enum values
---
api/video_codecs/video_encoder.cc | 8 ++++++++
1 file changed, 8 insertions(+)
common_video/libyuv/include/webrtc_libyuv.h | 3 +++
common_video/libyuv/webrtc_libyuv.cc | 9 +++++++++
2 files changed, 12 insertions(+)
diff --git a/api/video_codecs/video_encoder.cc b/api/video_codecs/video_encoder.cc
index c3b5f3a4e9..22a532d328 100644
--- a/api/video_codecs/video_encoder.cc
+++ b/api/video_codecs/video_encoder.cc
@@ -192,7 +192,15 @@ std::string VideoEncoder::EncoderInfo::ToString() const {
for (size_t i = 0; i < preferred_pixel_formats.size(); ++i) {
if (i > 0)
oss << ", ";
+#if defined(WEBRTC_MOZILLA_BUILD)
+ // This could assert, as opposed to throw using the form in the
+ // else, but since we're in a for loop that uses .size() we can
+ // be fairly sure that this is safe without doing a further
+ // check to make sure 'i' is in-range.
+ oss << VideoFrameBufferTypeToString(preferred_pixel_formats[i]);
+#else
oss << VideoFrameBufferTypeToString(preferred_pixel_formats.at(i));
+#endif
diff --git a/common_video/libyuv/include/webrtc_libyuv.h b/common_video/libyuv/include/webrtc_libyuv.h
index 68831c70ab..253a33294d 100644
--- a/common_video/libyuv/include/webrtc_libyuv.h
+++ b/common_video/libyuv/include/webrtc_libyuv.h
@@ -35,11 +35,14 @@ enum class VideoType {
kBGR24,
kARGB,
kABGR,
+ kARGB4444,
kRGB565,
+ kARGB1555,
kYUY2,
kYV12,
kUYVY,
kMJPEG,
+ kNV21,
kBGRA,
kNV12,
};
diff --git a/common_video/libyuv/webrtc_libyuv.cc b/common_video/libyuv/webrtc_libyuv.cc
index 31ba1feca3..05a4b184c2 100644
--- a/common_video/libyuv/webrtc_libyuv.cc
+++ b/common_video/libyuv/webrtc_libyuv.cc
@@ -24,6 +24,7 @@ size_t CalcBufferSize(VideoType type, int width, int height) {
RTC_DCHECK_GE(height, 0);
switch (type) {
case VideoType::kI420:
+ case VideoType::kNV21:
case VideoType::kIYUV:
case VideoType::kYV12:
case VideoType::kNV12: {
@@ -31,7 +32,9 @@ size_t CalcBufferSize(VideoType type, int width, int height) {
int half_height = (height + 1) >> 1;
return width * height + half_width * half_height * 2;
}
+ case VideoType::kARGB4444:
case VideoType::kRGB565:
+ case VideoType::kARGB1555:
case VideoType::kYUY2:
case VideoType::kUYVY:
return width * height * 2;
@@ -104,10 +107,16 @@ int ConvertVideoType(VideoType video_type) {
return libyuv::FOURCC_UYVY;
case VideoType::kMJPEG:
return libyuv::FOURCC_MJPG;
+ case VideoType::kNV21:
+ return libyuv::FOURCC_NV21;
case VideoType::kARGB:
return libyuv::FOURCC_ARGB;
case VideoType::kBGRA:
return libyuv::FOURCC_BGRA;
+ case VideoType::kARGB4444:
+ return libyuv::FOURCC_R444;
+ case VideoType::kARGB1555:
+ return libyuv::FOURCC_RGBO;
case VideoType::kNV12:
return libyuv::FOURCC_NV12;
}
oss << "]";
if (is_qp_trusted.has_value()) {

View File

@ -1,67 +1,73 @@
From: Michael Froman <mjfroman@mac.com>
Date: Thu, 28 Apr 2022 10:53:43 -0500
Subject: Bug 1766646 - (fix-a0bb2ef2dc) add back VideoType enum values
Date: Thu, 19 May 2022 15:32:32 -0500
Subject: Bug 1772380 - Build 1766646 - (fix-c89fdd716c) fixes for the
refactored PlatformThread API;r?mjf
---
common_video/libyuv/include/webrtc_libyuv.h | 3 +++
common_video/libyuv/webrtc_libyuv.cc | 9 +++++++++
2 files changed, 12 insertions(+)
.../video_capture/linux/device_info_v4l2.cc | 20 ++++++-------------
.../video_capture/linux/device_info_v4l2.h | 3 +--
2 files changed, 7 insertions(+), 16 deletions(-)
diff --git a/common_video/libyuv/include/webrtc_libyuv.h b/common_video/libyuv/include/webrtc_libyuv.h
index 68831c70ab..253a33294d 100644
--- a/common_video/libyuv/include/webrtc_libyuv.h
+++ b/common_video/libyuv/include/webrtc_libyuv.h
@@ -35,11 +35,14 @@ enum class VideoType {
kBGR24,
kARGB,
kABGR,
+ kARGB4444,
kRGB565,
+ kARGB1555,
kYUY2,
kYV12,
kUYVY,
kMJPEG,
+ kNV21,
kBGRA,
kNV12,
};
diff --git a/common_video/libyuv/webrtc_libyuv.cc b/common_video/libyuv/webrtc_libyuv.cc
index 31ba1feca3..05a4b184c2 100644
--- a/common_video/libyuv/webrtc_libyuv.cc
+++ b/common_video/libyuv/webrtc_libyuv.cc
@@ -24,6 +24,7 @@ size_t CalcBufferSize(VideoType type, int width, int height) {
RTC_DCHECK_GE(height, 0);
switch (type) {
case VideoType::kI420:
+ case VideoType::kNV21:
case VideoType::kIYUV:
case VideoType::kYV12:
case VideoType::kNV12: {
@@ -31,7 +32,9 @@ size_t CalcBufferSize(VideoType type, int width, int height) {
int half_height = (height + 1) >> 1;
return width * height + half_width * half_height * 2;
diff --git a/modules/video_capture/linux/device_info_v4l2.cc b/modules/video_capture/linux/device_info_v4l2.cc
index c5d33ff9a4..04caaea592 100644
--- a/modules/video_capture/linux/device_info_v4l2.cc
+++ b/modules/video_capture/linux/device_info_v4l2.cc
@@ -151,11 +151,6 @@ int DeviceInfoV4l2::ProcessInotifyEvents()
return 0;
}
-void DeviceInfoV4l2::InotifyEventThread(void* obj)
-{
- static_cast<DeviceInfoLinux*> (obj)->InotifyProcess();
-}
-
void DeviceInfoV4l2::InotifyProcess()
{
_fd_v4l = inotify_init();
@@ -181,16 +176,14 @@ void DeviceInfoV4l2::InotifyProcess()
DeviceInfoV4l2::DeviceInfoV4l2() : DeviceInfoImpl()
#ifdef WEBRTC_LINUX
- , _inotifyEventThread(new rtc::PlatformThread(
- InotifyEventThread, this, "InotifyEventThread"))
, _isShutdown(false)
#endif
{
#ifdef WEBRTC_LINUX
- if (_inotifyEventThread)
- {
- _inotifyEventThread->Start();
- }
+ _inotifyEventThread = rtc::PlatformThread::SpawnJoinable(
+ [this] {
+ InotifyProcess();
+ }, "InotifyEventThread");
#endif
}
@@ -202,9 +195,8 @@ DeviceInfoV4l2::~DeviceInfoV4l2() {
#ifdef WEBRTC_LINUX
_isShutdown = true;
- if (_inotifyEventThread) {
- _inotifyEventThread->Stop();
- _inotifyEventThread = nullptr;
+ if (!_inotifyEventThread.empty()) {
+ _inotifyEventThread.Finalize();
}
+ case VideoType::kARGB4444:
case VideoType::kRGB565:
+ case VideoType::kARGB1555:
case VideoType::kYUY2:
case VideoType::kUYVY:
return width * height * 2;
@@ -104,10 +107,16 @@ int ConvertVideoType(VideoType video_type) {
return libyuv::FOURCC_UYVY;
case VideoType::kMJPEG:
return libyuv::FOURCC_MJPG;
+ case VideoType::kNV21:
+ return libyuv::FOURCC_NV21;
case VideoType::kARGB:
return libyuv::FOURCC_ARGB;
case VideoType::kBGRA:
return libyuv::FOURCC_BGRA;
+ case VideoType::kARGB4444:
+ return libyuv::FOURCC_R444;
+ case VideoType::kARGB1555:
+ return libyuv::FOURCC_RGBO;
case VideoType::kNV12:
return libyuv::FOURCC_NV12;
}
#endif
}
diff --git a/modules/video_capture/linux/device_info_v4l2.h b/modules/video_capture/linux/device_info_v4l2.h
index 119cb07ab8..0bec3eb765 100644
--- a/modules/video_capture/linux/device_info_v4l2.h
+++ b/modules/video_capture/linux/device_info_v4l2.h
@@ -60,8 +60,7 @@ class DeviceInfoV4l2 : public DeviceInfoImpl {
int EventCheck(int fd);
int HandleEvents(int fd);
int ProcessInotifyEvents();
- std::unique_ptr<rtc::PlatformThread> _inotifyEventThread;
- static void InotifyEventThread(void*);
+ rtc::PlatformThread _inotifyEventThread;
void InotifyProcess();
int _fd_v4l, _fd_dev, _wd_v4l, _wd_dev; /* accessed on InotifyEventThread thread */
std::atomic<bool> _isShutdown;

View File

@ -1,73 +1,171 @@
From: Michael Froman <mjfroman@mac.com>
Date: Thu, 19 May 2022 15:32:32 -0500
Subject: Bug 1772380 - Build 1766646 - (fix-c89fdd716c) fixes for the
refactored PlatformThread API;r?mjf
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 18 Jan 2021 11:07:00 +0100
Subject: Bug 1766646 - (fix-ae0d117d51) ifdef our Csrc impl vs upstream's
impl, see Bug 1771332.
---
.../video_capture/linux/device_info_v4l2.cc | 20 ++++++-------------
.../video_capture/linux/device_info_v4l2.h | 3 +--
2 files changed, 7 insertions(+), 16 deletions(-)
modules/rtp_rtcp/source/rtp_header_extensions.cc | 4 ++++
modules/rtp_rtcp/source/rtp_header_extensions.h | 4 ++++
modules/rtp_rtcp/source/rtp_packet.cc | 4 ++++
modules/rtp_rtcp/source/rtp_sender.cc | 4 ++++
test/fuzzers/rtp_packet_fuzzer.cc | 4 ++++
5 files changed, 20 insertions(+)
diff --git a/modules/video_capture/linux/device_info_v4l2.cc b/modules/video_capture/linux/device_info_v4l2.cc
index c5d33ff9a4..04caaea592 100644
--- a/modules/video_capture/linux/device_info_v4l2.cc
+++ b/modules/video_capture/linux/device_info_v4l2.cc
@@ -151,11 +151,6 @@ int DeviceInfoV4l2::ProcessInotifyEvents()
return 0;
diff --git a/modules/rtp_rtcp/source/rtp_header_extensions.cc b/modules/rtp_rtcp/source/rtp_header_extensions.cc
index bb035729f8..53211fa2b4 100644
--- a/modules/rtp_rtcp/source/rtp_header_extensions.cc
+++ b/modules/rtp_rtcp/source/rtp_header_extensions.cc
@@ -181,6 +181,7 @@ bool AudioLevelExtension::Write(rtc::ArrayView<uint8_t> data,
return true;
}
-void DeviceInfoV4l2::InotifyEventThread(void* obj)
-{
- static_cast<DeviceInfoLinux*> (obj)->InotifyProcess();
-}
-
void DeviceInfoV4l2::InotifyProcess()
{
_fd_v4l = inotify_init();
@@ -181,16 +176,14 @@ void DeviceInfoV4l2::InotifyProcess()
+#if !defined(WEBRTC_MOZILLA_BUILD)
// An RTP Header Extension for Mixer-to-Client Audio Level Indication
//
// https://tools.ietf.org/html/rfc6465
@@ -230,6 +231,7 @@ bool CsrcAudioLevel::Write(rtc::ArrayView<uint8_t> data,
}
return true;
}
+#endif
DeviceInfoV4l2::DeviceInfoV4l2() : DeviceInfoImpl()
#ifdef WEBRTC_LINUX
- , _inotifyEventThread(new rtc::PlatformThread(
- InotifyEventThread, this, "InotifyEventThread"))
, _isShutdown(false)
#endif
{
#ifdef WEBRTC_LINUX
- if (_inotifyEventThread)
- {
- _inotifyEventThread->Start();
- }
+ _inotifyEventThread = rtc::PlatformThread::SpawnJoinable(
+ [this] {
+ InotifyProcess();
+ }, "InotifyEventThread");
#endif
// From RFC 5450: Transmission Time Offsets in RTP Streams.
//
@@ -423,6 +425,7 @@ bool PlayoutDelayLimits::Write(rtc::ArrayView<uint8_t> data,
return true;
}
@@ -202,9 +195,8 @@ DeviceInfoV4l2::~DeviceInfoV4l2() {
#ifdef WEBRTC_LINUX
_isShutdown = true;
+#if defined(WEBRTC_MOZILLA_BUILD)
// CSRCAudioLevel
// Sample Audio Level Encoding Using the One-Byte Header Format
// Note that the range of len is 1 to 15 which is encoded as 0 to 14
@@ -461,6 +464,7 @@ bool CsrcAudioLevel::Write(rtc::ArrayView<uint8_t> data,
// This extension if used must have at least one audio level
return csrcAudioLevels.numAudioLevels;
}
+#endif
- if (_inotifyEventThread) {
- _inotifyEventThread->Stop();
- _inotifyEventThread = nullptr;
+ if (!_inotifyEventThread.empty()) {
+ _inotifyEventThread.Finalize();
// Video Content Type.
//
diff --git a/modules/rtp_rtcp/source/rtp_header_extensions.h b/modules/rtp_rtcp/source/rtp_header_extensions.h
index ed816caa10..2ad2d18036 100644
--- a/modules/rtp_rtcp/source/rtp_header_extensions.h
+++ b/modules/rtp_rtcp/source/rtp_header_extensions.h
@@ -104,6 +104,7 @@ class AudioLevelExtension {
static bool Write(rtc::ArrayView<uint8_t> data, const AudioLevel& extension);
};
+#if !defined(WEBRTC_MOZILLA_BUILD)
class CsrcAudioLevel {
public:
static constexpr RTPExtensionType kId = kRtpExtensionCsrcAudioLevel;
@@ -118,6 +119,7 @@ class CsrcAudioLevel {
static bool Write(rtc::ArrayView<uint8_t> data,
rtc::ArrayView<const uint8_t> csrc_audio_levels);
};
+#endif
class TransmissionOffset {
public:
@@ -308,6 +310,7 @@ class ColorSpaceExtension {
static size_t WriteLuminance(uint8_t* data, float f, int denominator);
};
+#if defined(WEBRTC_MOZILLA_BUILD)
class CsrcAudioLevel {
public:
static constexpr RTPExtensionType kId = kRtpExtensionCsrcAudioLevel;
@@ -322,6 +325,7 @@ class CsrcAudioLevel {
static size_t ValueSize(const CsrcAudioLevelList& csrcAudioLevels);
static bool Write(rtc::ArrayView<uint8_t> data, const CsrcAudioLevelList& csrcAudioLevels);
};
+#endif
// Base extension class for RTP header extensions which are strings.
// Subclasses must defined kId and kUri static constexpr members.
diff --git a/modules/rtp_rtcp/source/rtp_packet.cc b/modules/rtp_rtcp/source/rtp_packet.cc
index 3192c27a49..306c17e2c2 100644
--- a/modules/rtp_rtcp/source/rtp_packet.cc
+++ b/modules/rtp_rtcp/source/rtp_packet.cc
@@ -193,7 +193,9 @@ void RtpPacket::ZeroMutableExtensions() {
break;
}
case RTPExtensionType::kRtpExtensionAudioLevel:
+#if !defined(WEBRTC_MOZILLA_BUILD)
case RTPExtensionType::kRtpExtensionCsrcAudioLevel:
+#endif
case RTPExtensionType::kRtpExtensionAbsoluteCaptureTime:
case RTPExtensionType::kRtpExtensionColorSpace:
case RTPExtensionType::kRtpExtensionCorruptionDetection:
@@ -212,10 +214,12 @@ void RtpPacket::ZeroMutableExtensions() {
// Non-mutable extension. Don't change it.
break;
}
+#if defined(WEBRTC_MOZILLA_BUILD)
case RTPExtensionType::kRtpExtensionCsrcAudioLevel: {
// TODO: This is a Mozilla addition, we need to add a handler for this.
RTC_CHECK(false);
}
+#endif
}
#endif
}
}
diff --git a/modules/video_capture/linux/device_info_v4l2.h b/modules/video_capture/linux/device_info_v4l2.h
index 119cb07ab8..0bec3eb765 100644
--- a/modules/video_capture/linux/device_info_v4l2.h
+++ b/modules/video_capture/linux/device_info_v4l2.h
@@ -60,8 +60,7 @@ class DeviceInfoV4l2 : public DeviceInfoImpl {
int EventCheck(int fd);
int HandleEvents(int fd);
int ProcessInotifyEvents();
- std::unique_ptr<rtc::PlatformThread> _inotifyEventThread;
- static void InotifyEventThread(void*);
+ rtc::PlatformThread _inotifyEventThread;
void InotifyProcess();
int _fd_v4l, _fd_dev, _wd_v4l, _wd_dev; /* accessed on InotifyEventThread thread */
std::atomic<bool> _isShutdown;
diff --git a/modules/rtp_rtcp/source/rtp_sender.cc b/modules/rtp_rtcp/source/rtp_sender.cc
index 9ff0c56253..1633319987 100644
--- a/modules/rtp_rtcp/source/rtp_sender.cc
+++ b/modules/rtp_rtcp/source/rtp_sender.cc
@@ -115,7 +115,9 @@ bool IsNonVolatile(RTPExtensionType type) {
switch (type) {
case kRtpExtensionTransmissionTimeOffset:
case kRtpExtensionAudioLevel:
+#if !defined(WEBRTC_MOZILLA_BUILD)
case kRtpExtensionCsrcAudioLevel:
+#endif
case kRtpExtensionAbsoluteSendTime:
case kRtpExtensionTransportSequenceNumber:
case kRtpExtensionTransportSequenceNumber02:
@@ -140,10 +142,12 @@ bool IsNonVolatile(RTPExtensionType type) {
case kRtpExtensionNumberOfExtensions:
RTC_DCHECK_NOTREACHED();
return false;
+#if defined(WEBRTC_MOZILLA_BUILD)
case kRtpExtensionCsrcAudioLevel:
// TODO: Mozilla implement for CsrcAudioLevel
RTC_CHECK(false);
return false;
+#endif
}
RTC_CHECK_NOTREACHED();
}
diff --git a/test/fuzzers/rtp_packet_fuzzer.cc b/test/fuzzers/rtp_packet_fuzzer.cc
index 6a7b233e29..705ceee309 100644
--- a/test/fuzzers/rtp_packet_fuzzer.cc
+++ b/test/fuzzers/rtp_packet_fuzzer.cc
@@ -79,11 +79,13 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
packet.GetExtension<AudioLevelExtension>(&audio_level);
break;
}
+#if !defined(WEBRTC_MOZILLA_BUILD)
case kRtpExtensionCsrcAudioLevel: {
std::vector<uint8_t> audio_levels;
packet.GetExtension<CsrcAudioLevel>(&audio_levels);
break;
}
+#endif
case kRtpExtensionAbsoluteSendTime:
uint32_t sendtime;
packet.GetExtension<AbsoluteSendTime>(&sendtime);
@@ -170,11 +172,13 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
CorruptionDetectionMessage message;
packet.GetExtension<CorruptionDetectionExtension>(&message);
break;
+#if defined(WEBRTC_MOZILLA_BUILD)
case kRtpExtensionCsrcAudioLevel: {
CsrcAudioLevelList levels;
packet.GetExtension<CsrcAudioLevel>(&levels);
break;
}
+#endif
}
}

View File

@ -1,171 +1,24 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 18 Jan 2021 11:07:00 +0100
Subject: Bug 1766646 - (fix-ae0d117d51) ifdef our Csrc impl vs upstream's
impl, see Bug 1771332.
From: Michael Froman <mjfroman@mac.com>
Date: Tue, 21 Jun 2022 11:11:09 -0500
Subject: Bug 1773223 - Generate webrtc moz.builds for all platforms at once.
r=mjf,firefox-build-system-reviewers,ahochheiden
---
modules/rtp_rtcp/source/rtp_header_extensions.cc | 4 ++++
modules/rtp_rtcp/source/rtp_header_extensions.h | 4 ++++
modules/rtp_rtcp/source/rtp_packet.cc | 4 ++++
modules/rtp_rtcp/source/rtp_sender.cc | 4 ++++
test/fuzzers/rtp_packet_fuzzer.cc | 4 ++++
5 files changed, 20 insertions(+)
build_overrides/build.gni | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/modules/rtp_rtcp/source/rtp_header_extensions.cc b/modules/rtp_rtcp/source/rtp_header_extensions.cc
index bb035729f8..53211fa2b4 100644
--- a/modules/rtp_rtcp/source/rtp_header_extensions.cc
+++ b/modules/rtp_rtcp/source/rtp_header_extensions.cc
@@ -181,6 +181,7 @@ bool AudioLevelExtension::Write(rtc::ArrayView<uint8_t> data,
return true;
diff --git a/build_overrides/build.gni b/build_overrides/build.gni
index 88b7ac3d38..57e8900e3e 100644
--- a/build_overrides/build.gni
+++ b/build_overrides/build.gni
@@ -50,6 +50,10 @@ if (host_os == "mac" || host_os == "linux") {
use_system_xcode = _result == 0
}
+#if !defined(WEBRTC_MOZILLA_BUILD)
// An RTP Header Extension for Mixer-to-Client Audio Level Indication
//
// https://tools.ietf.org/html/rfc6465
@@ -230,6 +231,7 @@ bool CsrcAudioLevel::Write(rtc::ArrayView<uint8_t> data,
}
return true;
}
+#endif
// From RFC 5450: Transmission Time Offsets in RTP Streams.
//
@@ -423,6 +425,7 @@ bool PlayoutDelayLimits::Write(rtc::ArrayView<uint8_t> data,
return true;
}
+#if defined(WEBRTC_MOZILLA_BUILD)
// CSRCAudioLevel
// Sample Audio Level Encoding Using the One-Byte Header Format
// Note that the range of len is 1 to 15 which is encoded as 0 to 14
@@ -461,6 +464,7 @@ bool CsrcAudioLevel::Write(rtc::ArrayView<uint8_t> data,
// This extension if used must have at least one audio level
return csrcAudioLevels.numAudioLevels;
}
+#endif
// Video Content Type.
//
diff --git a/modules/rtp_rtcp/source/rtp_header_extensions.h b/modules/rtp_rtcp/source/rtp_header_extensions.h
index ed816caa10..2ad2d18036 100644
--- a/modules/rtp_rtcp/source/rtp_header_extensions.h
+++ b/modules/rtp_rtcp/source/rtp_header_extensions.h
@@ -104,6 +104,7 @@ class AudioLevelExtension {
static bool Write(rtc::ArrayView<uint8_t> data, const AudioLevel& extension);
};
+#if !defined(WEBRTC_MOZILLA_BUILD)
class CsrcAudioLevel {
public:
static constexpr RTPExtensionType kId = kRtpExtensionCsrcAudioLevel;
@@ -118,6 +119,7 @@ class CsrcAudioLevel {
static bool Write(rtc::ArrayView<uint8_t> data,
rtc::ArrayView<const uint8_t> csrc_audio_levels);
};
+#endif
class TransmissionOffset {
public:
@@ -308,6 +310,7 @@ class ColorSpaceExtension {
static size_t WriteLuminance(uint8_t* data, float f, int denominator);
};
+#if defined(WEBRTC_MOZILLA_BUILD)
class CsrcAudioLevel {
public:
static constexpr RTPExtensionType kId = kRtpExtensionCsrcAudioLevel;
@@ -322,6 +325,7 @@ class CsrcAudioLevel {
static size_t ValueSize(const CsrcAudioLevelList& csrcAudioLevels);
static bool Write(rtc::ArrayView<uint8_t> data, const CsrcAudioLevelList& csrcAudioLevels);
};
+#endif
// Base extension class for RTP header extensions which are strings.
// Subclasses must defined kId and kUri static constexpr members.
diff --git a/modules/rtp_rtcp/source/rtp_packet.cc b/modules/rtp_rtcp/source/rtp_packet.cc
index 3192c27a49..306c17e2c2 100644
--- a/modules/rtp_rtcp/source/rtp_packet.cc
+++ b/modules/rtp_rtcp/source/rtp_packet.cc
@@ -193,7 +193,9 @@ void RtpPacket::ZeroMutableExtensions() {
break;
}
case RTPExtensionType::kRtpExtensionAudioLevel:
+#if !defined(WEBRTC_MOZILLA_BUILD)
case RTPExtensionType::kRtpExtensionCsrcAudioLevel:
+#endif
case RTPExtensionType::kRtpExtensionAbsoluteCaptureTime:
case RTPExtensionType::kRtpExtensionColorSpace:
case RTPExtensionType::kRtpExtensionCorruptionDetection:
@@ -212,10 +214,12 @@ void RtpPacket::ZeroMutableExtensions() {
// Non-mutable extension. Don't change it.
break;
}
+#if defined(WEBRTC_MOZILLA_BUILD)
case RTPExtensionType::kRtpExtensionCsrcAudioLevel: {
// TODO: This is a Mozilla addition, we need to add a handler for this.
RTC_CHECK(false);
}
+#endif
}
}
}
diff --git a/modules/rtp_rtcp/source/rtp_sender.cc b/modules/rtp_rtcp/source/rtp_sender.cc
index 9ff0c56253..1633319987 100644
--- a/modules/rtp_rtcp/source/rtp_sender.cc
+++ b/modules/rtp_rtcp/source/rtp_sender.cc
@@ -115,7 +115,9 @@ bool IsNonVolatile(RTPExtensionType type) {
switch (type) {
case kRtpExtensionTransmissionTimeOffset:
case kRtpExtensionAudioLevel:
+#if !defined(WEBRTC_MOZILLA_BUILD)
case kRtpExtensionCsrcAudioLevel:
+#endif
case kRtpExtensionAbsoluteSendTime:
case kRtpExtensionTransportSequenceNumber:
case kRtpExtensionTransportSequenceNumber02:
@@ -140,10 +142,12 @@ bool IsNonVolatile(RTPExtensionType type) {
case kRtpExtensionNumberOfExtensions:
RTC_DCHECK_NOTREACHED();
return false;
+#if defined(WEBRTC_MOZILLA_BUILD)
case kRtpExtensionCsrcAudioLevel:
// TODO: Mozilla implement for CsrcAudioLevel
RTC_CHECK(false);
return false;
+#endif
}
RTC_CHECK_NOTREACHED();
}
diff --git a/test/fuzzers/rtp_packet_fuzzer.cc b/test/fuzzers/rtp_packet_fuzzer.cc
index 6a7b233e29..705ceee309 100644
--- a/test/fuzzers/rtp_packet_fuzzer.cc
+++ b/test/fuzzers/rtp_packet_fuzzer.cc
@@ -79,11 +79,13 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
packet.GetExtension<AudioLevelExtension>(&audio_level);
break;
}
+#if !defined(WEBRTC_MOZILLA_BUILD)
case kRtpExtensionCsrcAudioLevel: {
std::vector<uint8_t> audio_levels;
packet.GetExtension<CsrcAudioLevel>(&audio_levels);
break;
}
+#endif
case kRtpExtensionAbsoluteSendTime:
uint32_t sendtime;
packet.GetExtension<AbsoluteSendTime>(&sendtime);
@@ -170,11 +172,13 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
CorruptionDetectionMessage message;
packet.GetExtension<CorruptionDetectionExtension>(&message);
break;
+#if defined(WEBRTC_MOZILLA_BUILD)
case kRtpExtensionCsrcAudioLevel: {
CsrcAudioLevelList levels;
packet.GetExtension<CsrcAudioLevel>(&levels);
break;
}
+#endif
}
}
+use_system_xcode = false
+xcode_version = "10.15"
+mac_xcode_version = "default"
+
declare_args() {
# WebRTC doesn't depend on //base from production code but only for testing
# purposes. In any case, it doesn't depend on //third_party/perfetto which

View File

@ -1,24 +1,26 @@
From: Michael Froman <mjfroman@mac.com>
Date: Tue, 21 Jun 2022 11:11:09 -0500
Subject: Bug 1773223 - Generate webrtc moz.builds for all platforms at once.
r=mjf,firefox-build-system-reviewers,ahochheiden
Date: Tue, 21 Jun 2022 11:17:46 -0500
Subject: Bug 1772380 - to upstream - ref count this in lambda capture
Bug 1876843 - (fix-23cecc1d43) drop rtc:: prefix on scoped_ptr
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2e4867d8cc9813869bd80f5201d3f7d84afcd412
---
build_overrides/build.gni | 4 ++++
1 file changed, 4 insertions(+)
modules/video_capture/linux/video_capture_v4l2.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/build_overrides/build.gni b/build_overrides/build.gni
index 88b7ac3d38..57e8900e3e 100644
--- a/build_overrides/build.gni
+++ b/build_overrides/build.gni
@@ -50,6 +50,10 @@ if (host_os == "mac" || host_os == "linux") {
use_system_xcode = _result == 0
}
+use_system_xcode = false
+xcode_version = "10.15"
+mac_xcode_version = "default"
+
declare_args() {
# WebRTC doesn't depend on //base from production code but only for testing
# purposes. In any case, it doesn't depend on //third_party/perfetto which
diff --git a/modules/video_capture/linux/video_capture_v4l2.cc b/modules/video_capture/linux/video_capture_v4l2.cc
index a2e362bb94..6d8a5e463f 100644
--- a/modules/video_capture/linux/video_capture_v4l2.cc
+++ b/modules/video_capture/linux/video_capture_v4l2.cc
@@ -303,8 +303,8 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
if (_captureThread.empty()) {
quit_ = false;
_captureThread = rtc::PlatformThread::SpawnJoinable(
- [this] {
- while (CaptureProcess()) {
+ [self = scoped_refptr(this)] {
+ while (self->CaptureProcess()) {
}
},
"CaptureThread",

View File

@ -1,26 +1,48 @@
From: Michael Froman <mjfroman@mac.com>
Date: Tue, 21 Jun 2022 11:17:46 -0500
Subject: Bug 1772380 - to upstream - ref count this in lambda capture
Date: Wed, 3 Aug 2022 20:21:25 -0500
Subject: Bug 1780582 - work around generating VideoFrameBufferType;r=mjf
Bug 1876843 - (fix-23cecc1d43) drop rtc:: prefix on scoped_ptr
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2e4867d8cc9813869bd80f5201d3f7d84afcd412
---
modules/video_capture/linux/video_capture_v4l2.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
.../api/org/webrtc/VideoFrameBufferType.java | 33 +++++++++++++++++++
1 file changed, 33 insertions(+)
create mode 100644 sdk/android/api/org/webrtc/VideoFrameBufferType.java
diff --git a/modules/video_capture/linux/video_capture_v4l2.cc b/modules/video_capture/linux/video_capture_v4l2.cc
index a2e362bb94..6d8a5e463f 100644
--- a/modules/video_capture/linux/video_capture_v4l2.cc
+++ b/modules/video_capture/linux/video_capture_v4l2.cc
@@ -303,8 +303,8 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
if (_captureThread.empty()) {
quit_ = false;
_captureThread = rtc::PlatformThread::SpawnJoinable(
- [this] {
- while (CaptureProcess()) {
+ [self = scoped_refptr(this)] {
+ while (self->CaptureProcess()) {
}
},
"CaptureThread",
diff --git a/sdk/android/api/org/webrtc/VideoFrameBufferType.java b/sdk/android/api/org/webrtc/VideoFrameBufferType.java
new file mode 100644
index 0000000000..7b05b88cba
--- /dev/null
+++ b/sdk/android/api/org/webrtc/VideoFrameBufferType.java
@@ -0,0 +1,33 @@
+
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file is autogenerated by
+// java_cpp_enum.py
+// From
+// ../../api/video/video_frame_buffer.h
+
+package org.webrtc;
+
+import androidx.annotation.IntDef;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@IntDef({
+ VideoFrameBufferType.NATIVE, VideoFrameBufferType.I420, VideoFrameBufferType.I420A,
+ VideoFrameBufferType.I422, VideoFrameBufferType.I444, VideoFrameBufferType.I010,
+ VideoFrameBufferType.I210, VideoFrameBufferType.NV12
+})
+@Retention(RetentionPolicy.SOURCE)
+public @interface VideoFrameBufferType {
+ int NATIVE = 0;
+ int I420 = 1;
+ int I420A = 2;
+ int I422 = 3;
+ int I444 = 4;
+ int I010 = 5;
+ int I210 = 6;
+ int NV12 = 7;
+}

View File

@ -1,48 +1,53 @@
From: Michael Froman <mjfroman@mac.com>
Date: Wed, 3 Aug 2022 20:21:25 -0500
Subject: Bug 1780582 - work around generating VideoFrameBufferType;r=mjf
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 5 Sep 2022 13:56:00 +0000
Subject: Bug 1786502 - Lock access to DeviceInfo devicechange callbacks.
r=webrtc-reviewers,jib
Differential Revision: https://phabricator.services.mozilla.com/D155365
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/e826dfadfe1264c59d9b13e3c17d6f75a40f5c33
---
.../api/org/webrtc/VideoFrameBufferType.java | 33 +++++++++++++++++++
1 file changed, 33 insertions(+)
create mode 100644 sdk/android/api/org/webrtc/VideoFrameBufferType.java
modules/video_capture/video_capture.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/sdk/android/api/org/webrtc/VideoFrameBufferType.java b/sdk/android/api/org/webrtc/VideoFrameBufferType.java
new file mode 100644
index 0000000000..7b05b88cba
--- /dev/null
+++ b/sdk/android/api/org/webrtc/VideoFrameBufferType.java
@@ -0,0 +1,33 @@
+
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file is autogenerated by
+// java_cpp_enum.py
+// From
+// ../../api/video/video_frame_buffer.h
+
+package org.webrtc;
+
+import androidx.annotation.IntDef;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@IntDef({
+ VideoFrameBufferType.NATIVE, VideoFrameBufferType.I420, VideoFrameBufferType.I420A,
+ VideoFrameBufferType.I422, VideoFrameBufferType.I444, VideoFrameBufferType.I010,
+ VideoFrameBufferType.I210, VideoFrameBufferType.NV12
+})
+@Retention(RetentionPolicy.SOURCE)
+public @interface VideoFrameBufferType {
+ int NATIVE = 0;
+ int I420 = 1;
+ int I420A = 2;
+ int I422 = 3;
+ int I444 = 4;
+ int I010 = 5;
+ int I210 = 6;
+ int NV12 = 7;
+}
diff --git a/modules/video_capture/video_capture.h b/modules/video_capture/video_capture.h
index 7279bed476..db07580921 100644
--- a/modules/video_capture/video_capture.h
+++ b/modules/video_capture/video_capture.h
@@ -16,6 +16,8 @@
#include "modules/desktop_capture/desktop_capture_types.h"
#include "modules/video_capture/raw_video_sink_interface.h"
#include "modules/video_capture/video_capture_defines.h"
+#include "rtc_base/synchronization/mutex.h"
+#include "rtc_base/thread_annotations.h"
#include <set>
#if defined(ANDROID)
@@ -40,15 +42,18 @@ class VideoCaptureModule : public RefCountInterface {
virtual uint32_t NumberOfDevices() = 0;
virtual int32_t Refresh() = 0;
virtual void DeviceChange() {
+ MutexLock lock(&_inputCallbacksMutex);
for (auto inputCallBack : _inputCallBacks) {
inputCallBack->OnDeviceChange();
}
}
virtual void RegisterVideoInputFeedBack(VideoInputFeedBack* callBack) {
+ MutexLock lock(&_inputCallbacksMutex);
_inputCallBacks.insert(callBack);
}
virtual void DeRegisterVideoInputFeedBack(VideoInputFeedBack* callBack) {
+ MutexLock lock(&_inputCallbacksMutex);
auto it = _inputCallBacks.find(callBack);
if (it != _inputCallBacks.end()) {
_inputCallBacks.erase(it);
@@ -102,7 +107,8 @@ class VideoCaptureModule : public RefCountInterface {
virtual ~DeviceInfo() {}
private:
- std::set<VideoInputFeedBack*> _inputCallBacks;
+ Mutex _inputCallbacksMutex;
+ std::set<VideoInputFeedBack*> _inputCallBacks RTC_GUARDED_BY(_inputCallbacksMutex);
};
// Register capture data callback

View File

@ -1,53 +1,49 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 5 Sep 2022 13:56:00 +0000
Subject: Bug 1786502 - Lock access to DeviceInfo devicechange callbacks.
r=webrtc-reviewers,jib
From: Michael Froman <mfroman@mozilla.com>
Date: Mon, 24 Oct 2022 13:00:00 -0500
Subject: Bug 1797161 - pt1 - tweak BUILD.gn around task_queue_win usage. r?ng!
Differential Revision: https://phabricator.services.mozilla.com/D155365
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/e826dfadfe1264c59d9b13e3c17d6f75a40f5c33
Add assurance that we will not build task_queue_win.cc to avoid
possible win32k API usage.
Differential Revision: https://phabricator.services.mozilla.com/D160115
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/f097eb8cbd8b7686ce306a46a4db691194fd39c1
---
modules/video_capture/video_capture.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
api/task_queue/BUILD.gn | 5 +++++
rtc_base/BUILD.gn | 4 ++++
2 files changed, 9 insertions(+)
diff --git a/modules/video_capture/video_capture.h b/modules/video_capture/video_capture.h
index 7279bed476..db07580921 100644
--- a/modules/video_capture/video_capture.h
+++ b/modules/video_capture/video_capture.h
@@ -16,6 +16,8 @@
#include "modules/desktop_capture/desktop_capture_types.h"
#include "modules/video_capture/raw_video_sink_interface.h"
#include "modules/video_capture/video_capture_defines.h"
+#include "rtc_base/synchronization/mutex.h"
+#include "rtc_base/thread_annotations.h"
#include <set>
diff --git a/api/task_queue/BUILD.gn b/api/task_queue/BUILD.gn
index 7e6be706f8..bacc3ca87a 100644
--- a/api/task_queue/BUILD.gn
+++ b/api/task_queue/BUILD.gn
@@ -29,6 +29,11 @@ rtc_library("task_queue") {
]
}
#if defined(ANDROID)
@@ -40,15 +42,18 @@ class VideoCaptureModule : public RefCountInterface {
virtual uint32_t NumberOfDevices() = 0;
virtual int32_t Refresh() = 0;
virtual void DeviceChange() {
+ MutexLock lock(&_inputCallbacksMutex);
for (auto inputCallBack : _inputCallBacks) {
inputCallBack->OnDeviceChange();
}
}
virtual void RegisterVideoInputFeedBack(VideoInputFeedBack* callBack) {
+ MutexLock lock(&_inputCallbacksMutex);
_inputCallBacks.insert(callBack);
}
virtual void DeRegisterVideoInputFeedBack(VideoInputFeedBack* callBack) {
+ MutexLock lock(&_inputCallbacksMutex);
auto it = _inputCallBacks.find(callBack);
if (it != _inputCallBacks.end()) {
_inputCallBacks.erase(it);
@@ -102,7 +107,8 @@ class VideoCaptureModule : public RefCountInterface {
virtual ~DeviceInfo() {}
private:
- std::set<VideoInputFeedBack*> _inputCallBacks;
+ Mutex _inputCallbacksMutex;
+ std::set<VideoInputFeedBack*> _inputCallBacks RTC_GUARDED_BY(_inputCallbacksMutex);
};
// Register capture data callback
+# Mozilla - we want to ensure that rtc_include_tests is set to false
+# to guarantee that default_task_queue_factory is not used so we
+# know that remaining win32k code in task_queue_win.cc is not built.
+# See Bug 1797161 for more info.
+assert(!rtc_include_tests, "Mozilla - verify rtc_include_tests is off")
if (rtc_include_tests) {
rtc_library("task_queue_test") {
visibility = [ "*" ]
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index d96d941db6..84ad4685db 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -699,10 +699,14 @@ if (is_mac || is_ios) {
if (is_win) {
rtc_library("rtc_task_queue_win") {
visibility = [ "../api/task_queue:default_task_queue_factory" ]
+# See Bug 1797161 for more info. Remove from build until win32k
+# usage is removed.
+if (!build_with_mozilla) {
sources = [
"task_queue_win.cc",
"task_queue_win.h",
]
+}
deps = [
":checks",
":logging",

View File

@ -1,49 +1,31 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Mon, 24 Oct 2022 13:00:00 -0500
Subject: Bug 1797161 - pt1 - tweak BUILD.gn around task_queue_win usage. r?ng!
Date: Mon, 24 Oct 2022 14:03:00 -0500
Subject: Bug 1797161 - pt3 - add static_assert to ensure we don't include
task_queue_win.cc in Mozilla builds. r?ng!
Add assurance that we will not build task_queue_win.cc to avoid
possible win32k API usage.
Differential Revision: https://phabricator.services.mozilla.com/D160115
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/f097eb8cbd8b7686ce306a46a4db691194fd39c1
Differential Revision: https://phabricator.services.mozilla.com/D160117
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/50b15e036924203147e34ec20e2689fe4a847645
---
api/task_queue/BUILD.gn | 5 +++++
rtc_base/BUILD.gn | 4 ++++
2 files changed, 9 insertions(+)
rtc_base/task_queue_win.cc | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/api/task_queue/BUILD.gn b/api/task_queue/BUILD.gn
index 7e6be706f8..bacc3ca87a 100644
--- a/api/task_queue/BUILD.gn
+++ b/api/task_queue/BUILD.gn
@@ -29,6 +29,11 @@ rtc_library("task_queue") {
]
}
diff --git a/rtc_base/task_queue_win.cc b/rtc_base/task_queue_win.cc
index 513ccd72cc..c9605c6bb2 100644
--- a/rtc_base/task_queue_win.cc
+++ b/rtc_base/task_queue_win.cc
@@ -8,6 +8,15 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+# Mozilla - we want to ensure that rtc_include_tests is set to false
+# to guarantee that default_task_queue_factory is not used so we
+# know that remaining win32k code in task_queue_win.cc is not built.
+# See Bug 1797161 for more info.
+assert(!rtc_include_tests, "Mozilla - verify rtc_include_tests is off")
if (rtc_include_tests) {
rtc_library("task_queue_test") {
visibility = [ "*" ]
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index d96d941db6..84ad4685db 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -699,10 +699,14 @@ if (is_mac || is_ios) {
if (is_win) {
rtc_library("rtc_task_queue_win") {
visibility = [ "../api/task_queue:default_task_queue_factory" ]
+# See Bug 1797161 for more info. Remove from build until win32k
+# usage is removed.
+if (!build_with_mozilla) {
sources = [
"task_queue_win.cc",
"task_queue_win.h",
]
+}
deps = [
":checks",
":logging",
+// Mozilla - this file should not be included in Mozilla builds until
+// win32k API usage is removed. This was once done in Bug 1395259, but
+// the upstreaming attempt stalled. Until win32k usage is officially
+// removed upstream, we have reverted to upstream's version of the file
+// (to reduce or elminate merge conflicts), and a static assert is
+// placed here to ensure this file isn't accidentally included in the
+// Mozilla build.
+static_assert(false, "This file should not be built, see Bug 1797161.");
+
#include "rtc_base/task_queue_win.h"
// clang-format off

View File

@ -1,31 +1,78 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Mon, 24 Oct 2022 14:03:00 -0500
Subject: Bug 1797161 - pt3 - add static_assert to ensure we don't include
task_queue_win.cc in Mozilla builds. r?ng!
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 12 Dec 2022 15:47:00 +0000
Subject: Bug 1451394 - Expose mac camera capture backend in .gn and switch it
to gecko libyuv. r=webrtc-reviewers,mjf
Differential Revision: https://phabricator.services.mozilla.com/D160117
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/50b15e036924203147e34ec20e2689fe4a847645
Differential Revision: https://phabricator.services.mozilla.com/D163682
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b0658888969395dca938597783c8a377b9bea209
---
rtc_base/task_queue_win.cc | 9 +++++++++
1 file changed, 9 insertions(+)
BUILD.gn | 4 ++++
sdk/BUILD.gn | 6 ++++++
2 files changed, 10 insertions(+)
diff --git a/rtc_base/task_queue_win.cc b/rtc_base/task_queue_win.cc
index 513ccd72cc..c9605c6bb2 100644
--- a/rtc_base/task_queue_win.cc
+++ b/rtc_base/task_queue_win.cc
@@ -8,6 +8,15 @@
* be found in the AUTHORS file in the root of the source tree.
*/
diff --git a/BUILD.gn b/BUILD.gn
index 7d3005cbe3..946de50dc2 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -636,6 +636,10 @@ if (!build_with_chromium) {
]
}
+// Mozilla - this file should not be included in Mozilla builds until
+// win32k API usage is removed. This was once done in Bug 1395259, but
+// the upstreaming attempt stalled. Until win32k usage is officially
+// removed upstream, we have reverted to upstream's version of the file
+// (to reduce or elminate merge conflicts), and a static assert is
+// placed here to ensure this file isn't accidentally included in the
+// Mozilla build.
+static_assert(false, "This file should not be built, see Bug 1797161.");
+ if (build_with_mozilla && is_mac) {
+ deps += [ "sdk:videocapture_objc" ]
+ }
+
#include "rtc_base/task_queue_win.h"
if (rtc_enable_protobuf) {
deps += [ "logging:rtc_event_log_proto" ]
}
diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn
index 27fb4adada..fce3ca62ff 100644
--- a/sdk/BUILD.gn
+++ b/sdk/BUILD.gn
@@ -527,6 +527,7 @@ if (is_ios || is_mac) {
}
}
// clang-format off
+ if (!build_with_mozilla) {
rtc_library("videosource_objc") {
sources = [
"objc/api/peerconnection/RTCVideoSource+Private.h",
@@ -556,6 +557,7 @@ if (is_ios || is_mac) {
":used_from_extension",
]
}
+ }
rtc_library("videoframebuffer_objc") {
visibility = [ "*" ]
@@ -588,6 +590,7 @@ if (is_ios || is_mac) {
]
}
+ if (!build_with_mozilla) {
rtc_library("metal_objc") {
visibility = [ "*" ]
allow_poison = [
@@ -649,6 +652,7 @@ if (is_ios || is_mac) {
":videoframebuffer_objc",
]
}
+ }
rtc_library("videocapture_objc") {
visibility = [ "*" ]
@@ -677,6 +681,7 @@ if (is_ios || is_mac) {
]
}
+ if (!build_with_mozilla) {
rtc_library("videocodec_objc") {
visibility = [ "*" ]
configs += [ "..:no_global_constructors" ]
@@ -1765,5 +1770,6 @@ if (is_ios || is_mac) {
"VideoToolbox.framework",
]
}
+ }
}
}

View File

@ -1,78 +1,28 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 12 Dec 2022 15:47:00 +0000
Subject: Bug 1451394 - Expose mac camera capture backend in .gn and switch it
to gecko libyuv. r=webrtc-reviewers,mjf
Subject: Bug 1451394 - Record video frame captures with PerformanceRecorder in
the new mac camera backend. r=padenot
Differential Revision: https://phabricator.services.mozilla.com/D163682
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b0658888969395dca938597783c8a377b9bea209
Also includes:
Bug 1806605 - Pass TrackingId instead of nsCString to CaptureStage.
Differential Revision: https://phabricator.services.mozilla.com/D163687
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a7362238c9e6fbe0d28200f6b41fc40a0c9a2158
---
BUILD.gn | 4 ++++
sdk/BUILD.gn | 6 ++++++
2 files changed, 10 insertions(+)
modules/video_capture/video_capture.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/BUILD.gn b/BUILD.gn
index 7d3005cbe3..946de50dc2 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -636,6 +636,10 @@ if (!build_with_chromium) {
]
}
diff --git a/modules/video_capture/video_capture.h b/modules/video_capture/video_capture.h
index db07580921..43a6a7f832 100644
--- a/modules/video_capture/video_capture.h
+++ b/modules/video_capture/video_capture.h
@@ -154,6 +154,9 @@ class VideoCaptureModule : public RefCountInterface {
// Return whether the rotation is applied or left pending.
virtual bool GetApplyRotation() = 0;
+ if (build_with_mozilla && is_mac) {
+ deps += [ "sdk:videocapture_objc" ]
+ }
+ // Mozilla: TrackingId setter for use in profiler markers.
+ virtual void SetTrackingId(uint32_t aTrackingIdProcId) {}
+
if (rtc_enable_protobuf) {
deps += [ "logging:rtc_event_log_proto" ]
}
diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn
index 27fb4adada..fce3ca62ff 100644
--- a/sdk/BUILD.gn
+++ b/sdk/BUILD.gn
@@ -527,6 +527,7 @@ if (is_ios || is_mac) {
}
}
+ if (!build_with_mozilla) {
rtc_library("videosource_objc") {
sources = [
"objc/api/peerconnection/RTCVideoSource+Private.h",
@@ -556,6 +557,7 @@ if (is_ios || is_mac) {
":used_from_extension",
]
}
+ }
rtc_library("videoframebuffer_objc") {
visibility = [ "*" ]
@@ -588,6 +590,7 @@ if (is_ios || is_mac) {
]
}
+ if (!build_with_mozilla) {
rtc_library("metal_objc") {
visibility = [ "*" ]
allow_poison = [
@@ -649,6 +652,7 @@ if (is_ios || is_mac) {
":videoframebuffer_objc",
]
}
+ }
rtc_library("videocapture_objc") {
visibility = [ "*" ]
@@ -677,6 +681,7 @@ if (is_ios || is_mac) {
]
}
+ if (!build_with_mozilla) {
rtc_library("videocodec_objc") {
visibility = [ "*" ]
configs += [ "..:no_global_constructors" ]
@@ -1765,5 +1770,6 @@ if (is_ios || is_mac) {
"VideoToolbox.framework",
]
}
+ }
}
}
protected:
~VideoCaptureModule() override {}
};

View File

@ -1,28 +1,346 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 12 Dec 2022 15:47:00 +0000
Subject: Bug 1451394 - Record video frame captures with PerformanceRecorder in
the new mac camera backend. r=padenot
Date: Tue, 23 Nov 2021 14:11:00 +0000
Subject: Bug 1742181 - libwebrtc: Implement packetsDiscarded bookkeeping for
received video. r=ng
Depends on D131707
Differential Revision: https://phabricator.services.mozilla.com/D131708
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/d0196a45a1f449874fc2a759e85e403c45c25575
Also includes:
Bug 1806605 - Pass TrackingId instead of nsCString to CaptureStage.
Differential Revision: https://phabricator.services.mozilla.com/D163687
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a7362238c9e6fbe0d28200f6b41fc40a0c9a2158
Bug 1804288 - (fix-de7ae5755b) reimplement Bug 1742181 - libwebrtc: Implement packetsDiscarded bookkeeping for received video. r=pehrsons
Differential Revision: https://phabricator.services.mozilla.com/D163959
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/ee566d1bfb654d36e5d58dce637fb0580b989ac1
---
modules/video_capture/video_capture.h | 3 +++
1 file changed, 3 insertions(+)
api/video/frame_buffer.cc | 25 ++++++++++++++++++++++---
api/video/frame_buffer.h | 4 ++++
call/video_receive_stream.h | 2 ++
modules/video_coding/packet_buffer.cc | 10 +++++++---
modules/video_coding/packet_buffer.h | 5 ++++-
video/receive_statistics_proxy.cc | 5 +++++
video/receive_statistics_proxy.h | 1 +
video/rtp_video_stream_receiver2.cc | 5 ++++-
video/rtp_video_stream_receiver2.h | 3 +++
video/video_receive_stream2.cc | 1 +
video/video_stream_buffer_controller.cc | 12 ++++++++++++
video/video_stream_buffer_controller.h | 5 +++++
12 files changed, 70 insertions(+), 8 deletions(-)
diff --git a/modules/video_capture/video_capture.h b/modules/video_capture/video_capture.h
index db07580921..43a6a7f832 100644
--- a/modules/video_capture/video_capture.h
+++ b/modules/video_capture/video_capture.h
@@ -154,6 +154,9 @@ class VideoCaptureModule : public RefCountInterface {
// Return whether the rotation is applied or left pending.
virtual bool GetApplyRotation() = 0;
diff --git a/api/video/frame_buffer.cc b/api/video/frame_buffer.cc
index fe9d4c3d23..4981acf0ca 100644
--- a/api/video/frame_buffer.cc
+++ b/api/video/frame_buffer.cc
@@ -149,14 +149,29 @@ void FrameBuffer::DropNextDecodableTemporalUnit() {
}
+ // Mozilla: TrackingId setter for use in profiler markers.
+ virtual void SetTrackingId(uint32_t aTrackingIdProcId) {}
auto end_it = std::next(next_decodable_temporal_unit_->last_frame);
- num_dropped_frames_ += std::count_if(
- frames_.begin(), end_it,
- [](const auto& f) { return f.second.encoded_frame != nullptr; });
+
protected:
~VideoCaptureModule() override {}
+ UpdateDroppedFramesAndDiscardedPackets(frames_.begin(), end_it);
frames_.erase(frames_.begin(), end_it);
FindNextAndLastDecodableTemporalUnit();
}
+void FrameBuffer::UpdateDroppedFramesAndDiscardedPackets(FrameIterator begin_it,
+ FrameIterator end_it) {
+ unsigned int num_discarded_packets = 0;
+ unsigned int num_dropped_frames =
+ std::count_if(begin_it, end_it, [&](const auto& f) {
+ if (f.second.encoded_frame) {
+ const auto& packetInfos = f.second.encoded_frame->PacketInfos();
+ num_discarded_packets += packetInfos.size();
+ }
+ return f.second.encoded_frame != nullptr;
+ });
+
+ num_dropped_frames_ += num_dropped_frames;
+ num_discarded_packets_ += num_discarded_packets;
+}
+
std::optional<int64_t> FrameBuffer::LastContinuousFrameId() const {
return last_continuous_frame_id_;
}
@@ -176,6 +191,9 @@ int FrameBuffer::GetTotalNumberOfContinuousTemporalUnits() const {
int FrameBuffer::GetTotalNumberOfDroppedFrames() const {
return num_dropped_frames_;
}
+int FrameBuffer::GetTotalNumberOfDiscardedPackets() const {
+ return num_discarded_packets_;
+}
size_t FrameBuffer::CurrentSize() const {
return frames_.size();
@@ -278,6 +296,7 @@ void FrameBuffer::FindNextAndLastDecodableTemporalUnit() {
}
void FrameBuffer::Clear() {
+ UpdateDroppedFramesAndDiscardedPackets(frames_.begin(), frames_.end());
frames_.clear();
next_decodable_temporal_unit_.reset();
decodable_temporal_units_info_.reset();
diff --git a/api/video/frame_buffer.h b/api/video/frame_buffer.h
index e607a182c2..5f2c5d0f2a 100644
--- a/api/video/frame_buffer.h
+++ b/api/video/frame_buffer.h
@@ -67,6 +67,7 @@ class FrameBuffer {
int GetTotalNumberOfContinuousTemporalUnits() const;
int GetTotalNumberOfDroppedFrames() const;
+ int GetTotalNumberOfDiscardedPackets() const;
size_t CurrentSize() const;
private:
@@ -88,6 +89,8 @@ class FrameBuffer {
void PropagateContinuity(const FrameIterator& frame_it);
void FindNextAndLastDecodableTemporalUnit();
void Clear();
+ void UpdateDroppedFramesAndDiscardedPackets(FrameIterator begin_it,
+ FrameIterator end_it);
const bool legacy_frame_id_jump_behavior_;
const size_t max_size_;
@@ -100,6 +103,7 @@ class FrameBuffer {
int num_continuous_temporal_units_ = 0;
int num_dropped_frames_ = 0;
+ int num_discarded_packets_ = 0;
};
} // namespace webrtc
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index 472199ef57..cda4dac800 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -116,6 +116,8 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
// https://www.w3.org/TR/webrtc-stats/#dom-rtcvideoreceiverstats-framesdropped
uint32_t frames_dropped = 0;
uint32_t frames_decoded = 0;
+ // https://w3c.github.io/webrtc-stats/#dom-rtcreceivedrtpstreamstats-packetsdiscarded
+ uint64_t packets_discarded = 0;
// https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-totaldecodetime
TimeDelta total_decode_time = TimeDelta::Zero();
// https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-totalprocessingdelay
diff --git a/modules/video_coding/packet_buffer.cc b/modules/video_coding/packet_buffer.cc
index 9d7b6e550c..c1f367cb3e 100644
--- a/modules/video_coding/packet_buffer.cc
+++ b/modules/video_coding/packet_buffer.cc
@@ -127,25 +127,27 @@ PacketBuffer::InsertResult PacketBuffer::InsertPacket(
return result;
}
-void PacketBuffer::ClearTo(uint16_t seq_num) {
+uint32_t PacketBuffer::ClearTo(uint16_t seq_num) {
// We have already cleared past this sequence number, no need to do anything.
if (is_cleared_to_first_seq_num_ &&
AheadOf<uint16_t>(first_seq_num_, seq_num)) {
- return;
+ return 0;
}
// If the packet buffer was cleared between a frame was created and returned.
if (!first_packet_received_)
- return;
+ return 0;
// Avoid iterating over the buffer more than once by capping the number of
// iterations to the `size_` of the buffer.
++seq_num;
+ uint32_t num_cleared_packets = 0;
size_t diff = ForwardDiff<uint16_t>(first_seq_num_, seq_num);
size_t iterations = std::min(diff, buffer_.size());
for (size_t i = 0; i < iterations; ++i) {
auto& stored = buffer_[first_seq_num_ % buffer_.size()];
if (stored != nullptr && AheadOf<uint16_t>(seq_num, stored->seq_num())) {
+ ++num_cleared_packets;
stored = nullptr;
}
++first_seq_num_;
@@ -161,6 +163,8 @@ void PacketBuffer::ClearTo(uint16_t seq_num) {
received_padding_.erase(received_padding_.begin(),
received_padding_.lower_bound(seq_num));
+
+ return num_cleared_packets;
}
void PacketBuffer::Clear() {
diff --git a/modules/video_coding/packet_buffer.h b/modules/video_coding/packet_buffer.h
index 495f64bdb3..10a9caacdd 100644
--- a/modules/video_coding/packet_buffer.h
+++ b/modules/video_coding/packet_buffer.h
@@ -80,7 +80,10 @@ class PacketBuffer {
ABSL_MUST_USE_RESULT InsertResult
InsertPacket(std::unique_ptr<Packet> packet);
ABSL_MUST_USE_RESULT InsertResult InsertPadding(uint16_t seq_num);
- void ClearTo(uint16_t seq_num);
+
+ // Clear all packets older than |seq_num|. Returns the number of packets
+ // cleared.
+ uint32_t ClearTo(uint16_t seq_num);
void Clear();
void ForceSpsPpsIdrIsH264Keyframe();
diff --git a/video/receive_statistics_proxy.cc b/video/receive_statistics_proxy.cc
index e74968bdfd..729f7b7efb 100644
--- a/video/receive_statistics_proxy.cc
+++ b/video/receive_statistics_proxy.cc
@@ -799,6 +799,11 @@ void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) {
}));
}
+void ReceiveStatisticsProxy::OnDiscardedPackets(uint32_t packets_discarded) {
+ RTC_DCHECK_RUN_ON(&main_thread_);
+ stats_.packets_discarded += packets_discarded;
+}
+
void ReceiveStatisticsProxy::OnPreDecode(VideoCodecType codec_type, int qp) {
RTC_DCHECK_RUN_ON(&main_thread_);
last_codec_type_ = codec_type;
diff --git a/video/receive_statistics_proxy.h b/video/receive_statistics_proxy.h
index 7af28fd982..8d5e208d63 100644
--- a/video/receive_statistics_proxy.h
+++ b/video/receive_statistics_proxy.h
@@ -95,6 +95,7 @@ class ReceiveStatisticsProxy : public VideoStreamBufferControllerStatsObserver,
void OnDecodableFrame(TimeDelta jitter_buffer_delay,
TimeDelta target_delay,
TimeDelta minimum_delay) override;
+ void OnDiscardedPackets(uint32_t packets_discarded) override;
void OnFrameBufferTimingsUpdated(int estimated_max_decode_time_ms,
int current_delay_ms,
int target_delay_ms,
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index 6fe5b247bd..a1d863b3ec 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -239,6 +239,7 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2(
RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer,
RtcpCnameCallback* rtcp_cname_callback,
NackPeriodicProcessor* nack_periodic_processor,
+ VideoStreamBufferControllerStatsObserver* vcm_receive_statistics,
OnCompleteFrameCallback* complete_frame_callback,
scoped_refptr<FrameDecryptorInterface> frame_decryptor,
scoped_refptr<FrameTransformerInterface> frame_transformer)
@@ -282,6 +283,7 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2(
config_.rtp.nack,
&rtcp_feedback_buffer_,
&rtcp_feedback_buffer_)),
+ vcm_receive_statistics_(vcm_receive_statistics),
packet_buffer_(kPacketBufferStartSize,
PacketBufferMaxSize(env_.field_trials())),
reference_finder_(std::make_unique<RtpFrameReferenceFinder>()),
@@ -1234,7 +1236,8 @@ void RtpVideoStreamReceiver2::FrameDecoded(int64_t picture_id) {
int64_t unwrapped_rtp_seq_num = rtp_seq_num_unwrapper_.Unwrap(seq_num);
packet_infos_.erase(packet_infos_.begin(),
packet_infos_.upper_bound(unwrapped_rtp_seq_num));
- packet_buffer_.ClearTo(seq_num);
+ uint32_t num_packets_cleared = packet_buffer_.ClearTo(seq_num);
+ vcm_receive_statistics_->OnDiscardedPackets(num_packets_cleared);
reference_finder_->ClearTo(seq_num);
}
}
diff --git a/video/rtp_video_stream_receiver2.h b/video/rtp_video_stream_receiver2.h
index 11b9548b76..d993fa104f 100644
--- a/video/rtp_video_stream_receiver2.h
+++ b/video/rtp_video_stream_receiver2.h
@@ -51,6 +51,7 @@
#include "rtc_base/thread_annotations.h"
#include "video/buffered_frame_decryptor.h"
#include "video/unique_timestamp_counter.h"
+#include "video/video_stream_buffer_controller.h"
namespace webrtc {
@@ -93,6 +94,7 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender,
RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer,
RtcpCnameCallback* rtcp_cname_callback,
NackPeriodicProcessor* nack_periodic_processor,
+ VideoStreamBufferControllerStatsObserver* vcm_receive_statistics,
// The KeyFrameRequestSender is optional; if not provided, key frame
// requests are sent via the internal RtpRtcp module.
OnCompleteFrameCallback* complete_frame_callback,
@@ -367,6 +369,7 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender,
std::unique_ptr<LossNotificationController> loss_notification_controller_
RTC_GUARDED_BY(packet_sequence_checker_);
+ VideoStreamBufferControllerStatsObserver* const vcm_receive_statistics_;
video_coding::PacketBuffer packet_buffer_
RTC_GUARDED_BY(packet_sequence_checker_);
// h26x_packet_buffer_ is nullptr if codec list doens't contain H.264 or
diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc
index ed9edcdd08..7ff917e05c 100644
--- a/video/video_receive_stream2.cc
+++ b/video/video_receive_stream2.cc
@@ -209,6 +209,7 @@ VideoReceiveStream2::VideoReceiveStream2(
&stats_proxy_,
&stats_proxy_,
nack_periodic_processor,
+ &stats_proxy_,
this, // OnCompleteFrameCallback
std::move(config_.frame_decryptor),
std::move(config_.frame_transformer)),
diff --git a/video/video_stream_buffer_controller.cc b/video/video_stream_buffer_controller.cc
index 83de75ac3f..01063b12f7 100644
--- a/video/video_stream_buffer_controller.cc
+++ b/video/video_stream_buffer_controller.cc
@@ -259,6 +259,7 @@ void VideoStreamBufferController::OnFrameReady(
// Update stats.
UpdateDroppedFrames();
+ UpdateDiscardedPackets();
UpdateFrameBufferTimings(min_receive_time, now);
UpdateTimingFrameInfo();
@@ -324,6 +325,17 @@ void VideoStreamBufferController::UpdateDroppedFrames()
buffer_->GetTotalNumberOfDroppedFrames();
}
+void VideoStreamBufferController::UpdateDiscardedPackets()
+ RTC_RUN_ON(&worker_sequence_checker_) {
+ const int discarded_packets = buffer_->GetTotalNumberOfDiscardedPackets() -
+ packets_discarded_before_last_new_frame_;
+ if (discarded_packets > 0) {
+ stats_proxy_->OnDiscardedPackets(discarded_packets);
+ }
+ packets_discarded_before_last_new_frame_ =
+ buffer_->GetTotalNumberOfDiscardedPackets();
+}
+
void VideoStreamBufferController::UpdateFrameBufferTimings(
Timestamp min_receive_time,
Timestamp now) {
diff --git a/video/video_stream_buffer_controller.h b/video/video_stream_buffer_controller.h
index 43d4544f71..3f3d6e465c 100644
--- a/video/video_stream_buffer_controller.h
+++ b/video/video_stream_buffer_controller.h
@@ -52,6 +52,8 @@ class VideoStreamBufferControllerStatsObserver {
TimeDelta target_delay,
TimeDelta minimum_delay) = 0;
+ virtual void OnDiscardedPackets(uint32_t packets_discarded) = 0;
+
// Various jitter buffer delays determined by VCMTiming.
virtual void OnFrameBufferTimingsUpdated(int estimated_max_decode_time_ms,
int current_delay_ms,
@@ -94,6 +96,7 @@ class VideoStreamBufferController {
void OnTimeout(TimeDelta delay);
void FrameReadyForDecode(uint32_t rtp_timestamp, Timestamp render_time);
void UpdateDroppedFrames() RTC_RUN_ON(&worker_sequence_checker_);
+ void UpdateDiscardedPackets() RTC_RUN_ON(&worker_sequence_checker_);
void UpdateFrameBufferTimings(Timestamp min_receive_time, Timestamp now);
void UpdateTimingFrameInfo();
bool IsTooManyFramesQueued() const RTC_RUN_ON(&worker_sequence_checker_);
@@ -120,6 +123,8 @@ class VideoStreamBufferController {
RTC_GUARDED_BY(&worker_sequence_checker_);
int frames_dropped_before_last_new_frame_
RTC_GUARDED_BY(&worker_sequence_checker_) = 0;
+ int packets_discarded_before_last_new_frame_
+ RTC_GUARDED_BY(&worker_sequence_checker_) = 0;
VCMVideoProtection protection_mode_
RTC_GUARDED_BY(&worker_sequence_checker_) = kProtectionNack;

View File

@ -1,346 +1,46 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Tue, 23 Nov 2021 14:11:00 +0000
Subject: Bug 1742181 - libwebrtc: Implement packetsDiscarded bookkeeping for
received video. r=ng
Date: Thu, 6 Jan 2022 00:16:00 +0000
Subject: Bug 1748478 - Propagate calculated discarded packets to stats. r=bwc
Depends on D131707
Differential Revision: https://phabricator.services.mozilla.com/D131708
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/d0196a45a1f449874fc2a759e85e403c45c25575
Also includes:
Bug 1804288 - (fix-de7ae5755b) reimplement Bug 1742181 - libwebrtc: Implement packetsDiscarded bookkeeping for received video. r=pehrsons
Differential Revision: https://phabricator.services.mozilla.com/D163959
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/ee566d1bfb654d36e5d58dce637fb0580b989ac1
Differential Revision: https://phabricator.services.mozilla.com/D135061
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/56fbf0469e25fa0d589c51ca112ce534a7c0ab91
---
api/video/frame_buffer.cc | 25 ++++++++++++++++++++++---
api/video/frame_buffer.h | 4 ++++
call/video_receive_stream.h | 2 ++
modules/video_coding/packet_buffer.cc | 10 +++++++---
modules/video_coding/packet_buffer.h | 5 ++++-
video/receive_statistics_proxy.cc | 5 +++++
video/receive_statistics_proxy.h | 1 +
video/rtp_video_stream_receiver2.cc | 5 ++++-
video/rtp_video_stream_receiver2.h | 3 +++
video/video_receive_stream2.cc | 1 +
video/video_stream_buffer_controller.cc | 12 ++++++++++++
video/video_stream_buffer_controller.h | 5 +++++
12 files changed, 70 insertions(+), 8 deletions(-)
video/receive_statistics_proxy.cc | 9 +++++++--
video/rtp_video_stream_receiver2.cc | 4 +++-
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/api/video/frame_buffer.cc b/api/video/frame_buffer.cc
index fe9d4c3d23..4981acf0ca 100644
--- a/api/video/frame_buffer.cc
+++ b/api/video/frame_buffer.cc
@@ -149,14 +149,29 @@ void FrameBuffer::DropNextDecodableTemporalUnit() {
}
auto end_it = std::next(next_decodable_temporal_unit_->last_frame);
- num_dropped_frames_ += std::count_if(
- frames_.begin(), end_it,
- [](const auto& f) { return f.second.encoded_frame != nullptr; });
+
+ UpdateDroppedFramesAndDiscardedPackets(frames_.begin(), end_it);
frames_.erase(frames_.begin(), end_it);
FindNextAndLastDecodableTemporalUnit();
}
+void FrameBuffer::UpdateDroppedFramesAndDiscardedPackets(FrameIterator begin_it,
+ FrameIterator end_it) {
+ unsigned int num_discarded_packets = 0;
+ unsigned int num_dropped_frames =
+ std::count_if(begin_it, end_it, [&](const auto& f) {
+ if (f.second.encoded_frame) {
+ const auto& packetInfos = f.second.encoded_frame->PacketInfos();
+ num_discarded_packets += packetInfos.size();
+ }
+ return f.second.encoded_frame != nullptr;
+ });
+
+ num_dropped_frames_ += num_dropped_frames;
+ num_discarded_packets_ += num_discarded_packets;
+}
+
std::optional<int64_t> FrameBuffer::LastContinuousFrameId() const {
return last_continuous_frame_id_;
}
@@ -176,6 +191,9 @@ int FrameBuffer::GetTotalNumberOfContinuousTemporalUnits() const {
int FrameBuffer::GetTotalNumberOfDroppedFrames() const {
return num_dropped_frames_;
}
+int FrameBuffer::GetTotalNumberOfDiscardedPackets() const {
+ return num_discarded_packets_;
+}
size_t FrameBuffer::CurrentSize() const {
return frames_.size();
@@ -278,6 +296,7 @@ void FrameBuffer::FindNextAndLastDecodableTemporalUnit() {
}
void FrameBuffer::Clear() {
+ UpdateDroppedFramesAndDiscardedPackets(frames_.begin(), frames_.end());
frames_.clear();
next_decodable_temporal_unit_.reset();
decodable_temporal_units_info_.reset();
diff --git a/api/video/frame_buffer.h b/api/video/frame_buffer.h
index e607a182c2..5f2c5d0f2a 100644
--- a/api/video/frame_buffer.h
+++ b/api/video/frame_buffer.h
@@ -67,6 +67,7 @@ class FrameBuffer {
int GetTotalNumberOfContinuousTemporalUnits() const;
int GetTotalNumberOfDroppedFrames() const;
+ int GetTotalNumberOfDiscardedPackets() const;
size_t CurrentSize() const;
private:
@@ -88,6 +89,8 @@ class FrameBuffer {
void PropagateContinuity(const FrameIterator& frame_it);
void FindNextAndLastDecodableTemporalUnit();
void Clear();
+ void UpdateDroppedFramesAndDiscardedPackets(FrameIterator begin_it,
+ FrameIterator end_it);
const bool legacy_frame_id_jump_behavior_;
const size_t max_size_;
@@ -100,6 +103,7 @@ class FrameBuffer {
int num_continuous_temporal_units_ = 0;
int num_dropped_frames_ = 0;
+ int num_discarded_packets_ = 0;
};
} // namespace webrtc
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index 472199ef57..cda4dac800 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -116,6 +116,8 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
// https://www.w3.org/TR/webrtc-stats/#dom-rtcvideoreceiverstats-framesdropped
uint32_t frames_dropped = 0;
uint32_t frames_decoded = 0;
+ // https://w3c.github.io/webrtc-stats/#dom-rtcreceivedrtpstreamstats-packetsdiscarded
+ uint64_t packets_discarded = 0;
// https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-totaldecodetime
TimeDelta total_decode_time = TimeDelta::Zero();
// https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-totalprocessingdelay
diff --git a/modules/video_coding/packet_buffer.cc b/modules/video_coding/packet_buffer.cc
index 9d7b6e550c..c1f367cb3e 100644
--- a/modules/video_coding/packet_buffer.cc
+++ b/modules/video_coding/packet_buffer.cc
@@ -127,25 +127,27 @@ PacketBuffer::InsertResult PacketBuffer::InsertPacket(
return result;
}
-void PacketBuffer::ClearTo(uint16_t seq_num) {
+uint32_t PacketBuffer::ClearTo(uint16_t seq_num) {
// We have already cleared past this sequence number, no need to do anything.
if (is_cleared_to_first_seq_num_ &&
AheadOf<uint16_t>(first_seq_num_, seq_num)) {
- return;
+ return 0;
}
// If the packet buffer was cleared between a frame was created and returned.
if (!first_packet_received_)
- return;
+ return 0;
// Avoid iterating over the buffer more than once by capping the number of
// iterations to the `size_` of the buffer.
++seq_num;
+ uint32_t num_cleared_packets = 0;
size_t diff = ForwardDiff<uint16_t>(first_seq_num_, seq_num);
size_t iterations = std::min(diff, buffer_.size());
for (size_t i = 0; i < iterations; ++i) {
auto& stored = buffer_[first_seq_num_ % buffer_.size()];
if (stored != nullptr && AheadOf<uint16_t>(seq_num, stored->seq_num())) {
+ ++num_cleared_packets;
stored = nullptr;
}
++first_seq_num_;
@@ -161,6 +163,8 @@ void PacketBuffer::ClearTo(uint16_t seq_num) {
received_padding_.erase(received_padding_.begin(),
received_padding_.lower_bound(seq_num));
+
+ return num_cleared_packets;
}
void PacketBuffer::Clear() {
diff --git a/modules/video_coding/packet_buffer.h b/modules/video_coding/packet_buffer.h
index 495f64bdb3..10a9caacdd 100644
--- a/modules/video_coding/packet_buffer.h
+++ b/modules/video_coding/packet_buffer.h
@@ -80,7 +80,10 @@ class PacketBuffer {
ABSL_MUST_USE_RESULT InsertResult
InsertPacket(std::unique_ptr<Packet> packet);
ABSL_MUST_USE_RESULT InsertResult InsertPadding(uint16_t seq_num);
- void ClearTo(uint16_t seq_num);
+
+ // Clear all packets older than |seq_num|. Returns the number of packets
+ // cleared.
+ uint32_t ClearTo(uint16_t seq_num);
void Clear();
void ForceSpsPpsIdrIsH264Keyframe();
diff --git a/video/receive_statistics_proxy.cc b/video/receive_statistics_proxy.cc
index e74968bdfd..729f7b7efb 100644
index 729f7b7efb..6e75eb837f 100644
--- a/video/receive_statistics_proxy.cc
+++ b/video/receive_statistics_proxy.cc
@@ -799,6 +799,11 @@ void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) {
}));
@@ -800,8 +800,13 @@ void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) {
}
void ReceiveStatisticsProxy::OnDiscardedPackets(uint32_t packets_discarded) {
- RTC_DCHECK_RUN_ON(&main_thread_);
- stats_.packets_discarded += packets_discarded;
+ // Can be called on either the decode queue or the worker thread
+ // See FrameBuffer2 for more details.
+ worker_thread_->PostTask(
+ SafeTask(task_safety_.flag(), [packets_discarded, this]() {
+ RTC_DCHECK_RUN_ON(&main_thread_);
+ stats_.packets_discarded += packets_discarded;
+ }));
}
+void ReceiveStatisticsProxy::OnDiscardedPackets(uint32_t packets_discarded) {
+ RTC_DCHECK_RUN_ON(&main_thread_);
+ stats_.packets_discarded += packets_discarded;
+}
+
void ReceiveStatisticsProxy::OnPreDecode(VideoCodecType codec_type, int qp) {
RTC_DCHECK_RUN_ON(&main_thread_);
last_codec_type_ = codec_type;
diff --git a/video/receive_statistics_proxy.h b/video/receive_statistics_proxy.h
index 7af28fd982..8d5e208d63 100644
--- a/video/receive_statistics_proxy.h
+++ b/video/receive_statistics_proxy.h
@@ -95,6 +95,7 @@ class ReceiveStatisticsProxy : public VideoStreamBufferControllerStatsObserver,
void OnDecodableFrame(TimeDelta jitter_buffer_delay,
TimeDelta target_delay,
TimeDelta minimum_delay) override;
+ void OnDiscardedPackets(uint32_t packets_discarded) override;
void OnFrameBufferTimingsUpdated(int estimated_max_decode_time_ms,
int current_delay_ms,
int target_delay_ms,
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index 6fe5b247bd..a1d863b3ec 100644
index a1d863b3ec..d8930a8b8e 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -239,6 +239,7 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2(
RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer,
RtcpCnameCallback* rtcp_cname_callback,
NackPeriodicProcessor* nack_periodic_processor,
+ VideoStreamBufferControllerStatsObserver* vcm_receive_statistics,
OnCompleteFrameCallback* complete_frame_callback,
scoped_refptr<FrameDecryptorInterface> frame_decryptor,
scoped_refptr<FrameTransformerInterface> frame_transformer)
@@ -282,6 +283,7 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2(
config_.rtp.nack,
&rtcp_feedback_buffer_,
&rtcp_feedback_buffer_)),
+ vcm_receive_statistics_(vcm_receive_statistics),
packet_buffer_(kPacketBufferStartSize,
PacketBufferMaxSize(env_.field_trials())),
reference_finder_(std::make_unique<RtpFrameReferenceFinder>()),
@@ -1234,7 +1236,8 @@ void RtpVideoStreamReceiver2::FrameDecoded(int64_t picture_id) {
int64_t unwrapped_rtp_seq_num = rtp_seq_num_unwrapper_.Unwrap(seq_num);
@@ -1237,7 +1237,9 @@ void RtpVideoStreamReceiver2::FrameDecoded(int64_t picture_id) {
packet_infos_.erase(packet_infos_.begin(),
packet_infos_.upper_bound(unwrapped_rtp_seq_num));
- packet_buffer_.ClearTo(seq_num);
+ uint32_t num_packets_cleared = packet_buffer_.ClearTo(seq_num);
+ vcm_receive_statistics_->OnDiscardedPackets(num_packets_cleared);
uint32_t num_packets_cleared = packet_buffer_.ClearTo(seq_num);
- vcm_receive_statistics_->OnDiscardedPackets(num_packets_cleared);
+ if (num_packets_cleared > 0) {
+ vcm_receive_statistics_->OnDiscardedPackets(num_packets_cleared);
+ }
reference_finder_->ClearTo(seq_num);
}
}
diff --git a/video/rtp_video_stream_receiver2.h b/video/rtp_video_stream_receiver2.h
index 11b9548b76..d993fa104f 100644
--- a/video/rtp_video_stream_receiver2.h
+++ b/video/rtp_video_stream_receiver2.h
@@ -51,6 +51,7 @@
#include "rtc_base/thread_annotations.h"
#include "video/buffered_frame_decryptor.h"
#include "video/unique_timestamp_counter.h"
+#include "video/video_stream_buffer_controller.h"
namespace webrtc {
@@ -93,6 +94,7 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender,
RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer,
RtcpCnameCallback* rtcp_cname_callback,
NackPeriodicProcessor* nack_periodic_processor,
+ VideoStreamBufferControllerStatsObserver* vcm_receive_statistics,
// The KeyFrameRequestSender is optional; if not provided, key frame
// requests are sent via the internal RtpRtcp module.
OnCompleteFrameCallback* complete_frame_callback,
@@ -367,6 +369,7 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender,
std::unique_ptr<LossNotificationController> loss_notification_controller_
RTC_GUARDED_BY(packet_sequence_checker_);
+ VideoStreamBufferControllerStatsObserver* const vcm_receive_statistics_;
video_coding::PacketBuffer packet_buffer_
RTC_GUARDED_BY(packet_sequence_checker_);
// h26x_packet_buffer_ is nullptr if codec list doens't contain H.264 or
diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc
index ed9edcdd08..7ff917e05c 100644
--- a/video/video_receive_stream2.cc
+++ b/video/video_receive_stream2.cc
@@ -209,6 +209,7 @@ VideoReceiveStream2::VideoReceiveStream2(
&stats_proxy_,
&stats_proxy_,
nack_periodic_processor,
+ &stats_proxy_,
this, // OnCompleteFrameCallback
std::move(config_.frame_decryptor),
std::move(config_.frame_transformer)),
diff --git a/video/video_stream_buffer_controller.cc b/video/video_stream_buffer_controller.cc
index 83de75ac3f..01063b12f7 100644
--- a/video/video_stream_buffer_controller.cc
+++ b/video/video_stream_buffer_controller.cc
@@ -259,6 +259,7 @@ void VideoStreamBufferController::OnFrameReady(
// Update stats.
UpdateDroppedFrames();
+ UpdateDiscardedPackets();
UpdateFrameBufferTimings(min_receive_time, now);
UpdateTimingFrameInfo();
@@ -324,6 +325,17 @@ void VideoStreamBufferController::UpdateDroppedFrames()
buffer_->GetTotalNumberOfDroppedFrames();
}
+void VideoStreamBufferController::UpdateDiscardedPackets()
+ RTC_RUN_ON(&worker_sequence_checker_) {
+ const int discarded_packets = buffer_->GetTotalNumberOfDiscardedPackets() -
+ packets_discarded_before_last_new_frame_;
+ if (discarded_packets > 0) {
+ stats_proxy_->OnDiscardedPackets(discarded_packets);
+ }
+ packets_discarded_before_last_new_frame_ =
+ buffer_->GetTotalNumberOfDiscardedPackets();
+}
+
void VideoStreamBufferController::UpdateFrameBufferTimings(
Timestamp min_receive_time,
Timestamp now) {
diff --git a/video/video_stream_buffer_controller.h b/video/video_stream_buffer_controller.h
index 43d4544f71..3f3d6e465c 100644
--- a/video/video_stream_buffer_controller.h
+++ b/video/video_stream_buffer_controller.h
@@ -52,6 +52,8 @@ class VideoStreamBufferControllerStatsObserver {
TimeDelta target_delay,
TimeDelta minimum_delay) = 0;
+ virtual void OnDiscardedPackets(uint32_t packets_discarded) = 0;
+
// Various jitter buffer delays determined by VCMTiming.
virtual void OnFrameBufferTimingsUpdated(int estimated_max_decode_time_ms,
int current_delay_ms,
@@ -94,6 +96,7 @@ class VideoStreamBufferController {
void OnTimeout(TimeDelta delay);
void FrameReadyForDecode(uint32_t rtp_timestamp, Timestamp render_time);
void UpdateDroppedFrames() RTC_RUN_ON(&worker_sequence_checker_);
+ void UpdateDiscardedPackets() RTC_RUN_ON(&worker_sequence_checker_);
void UpdateFrameBufferTimings(Timestamp min_receive_time, Timestamp now);
void UpdateTimingFrameInfo();
bool IsTooManyFramesQueued() const RTC_RUN_ON(&worker_sequence_checker_);
@@ -120,6 +123,8 @@ class VideoStreamBufferController {
RTC_GUARDED_BY(&worker_sequence_checker_);
int frames_dropped_before_last_new_frame_
RTC_GUARDED_BY(&worker_sequence_checker_) = 0;
+ int packets_discarded_before_last_new_frame_
+ RTC_GUARDED_BY(&worker_sequence_checker_) = 0;
VCMVideoProtection protection_mode_
RTC_GUARDED_BY(&worker_sequence_checker_) = kProtectionNack;

View File

@ -1,46 +1,221 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Thu, 6 Jan 2022 00:16:00 +0000
Subject: Bug 1748478 - Propagate calculated discarded packets to stats. r=bwc
Subject: Bug 1748458 - Add TRACE_EVENTs for dropped frames and packets for
received video. r=bwc
Differential Revision: https://phabricator.services.mozilla.com/D135061
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/56fbf0469e25fa0d589c51ca112ce534a7c0ab91
This lets us see in the profiler how many received frames and packets we decide
to drop and the reasons why.
Differential Revision: https://phabricator.services.mozilla.com/D135062
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/08e252da94c4752eccfd845eef13d8517953cc6a
Also includes:
Bug 1804288 - (fix-de7ae5755b) reimplement Bug 1748458 - Add TRACE_EVENTs for dropped frames and packets for received video. r=pehrsons
Differential Revision: https://phabricator.services.mozilla.com/D163960
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8e9a326a99cd5eaa6e447ff57c01ad9d79a09744
---
video/receive_statistics_proxy.cc | 9 +++++++--
video/rtp_video_stream_receiver2.cc | 4 +++-
2 files changed, 10 insertions(+), 3 deletions(-)
api/video/frame_buffer.cc | 33 +++++++++++++++++++++++++
video/receive_statistics_proxy.cc | 11 +++++++++
video/rtp_video_stream_receiver2.cc | 4 +++
video/video_stream_buffer_controller.cc | 7 ++++++
4 files changed, 55 insertions(+)
diff --git a/api/video/frame_buffer.cc b/api/video/frame_buffer.cc
index 4981acf0ca..f0c48f3702 100644
--- a/api/video/frame_buffer.cc
+++ b/api/video/frame_buffer.cc
@@ -25,6 +25,7 @@
#include "api/video/encoded_frame.h"
#include "rtc_base/logging.h"
#include "rtc_base/numerics/sequence_number_util.h"
+#include "rtc_base/trace_event.h"
namespace webrtc {
namespace {
@@ -77,7 +78,12 @@ FrameBuffer::FrameBuffer(int max_size,
decoded_frame_history_(max_decode_history) {}
bool FrameBuffer::InsertFrame(std::unique_ptr<EncodedFrame> frame) {
+ const uint32_t ssrc =
+ frame->PacketInfos().empty() ? 0 : frame->PacketInfos()[0].ssrc();
if (!ValidReferences(*frame)) {
+ TRACE_EVENT2("webrtc",
+ "FrameBuffer::InsertFrame Frame dropped (Invalid references)",
+ "remote_ssrc", ssrc, "frame_id", frame->Id());
RTC_DLOG(LS_WARNING) << "Frame " << frame->Id()
<< " has invalid references, dropping frame.";
return false;
@@ -87,23 +93,35 @@ bool FrameBuffer::InsertFrame(std::unique_ptr<EncodedFrame> frame) {
if (legacy_frame_id_jump_behavior_ && frame->is_keyframe() &&
AheadOf(frame->RtpTimestamp(),
*decoded_frame_history_.GetLastDecodedFrameTimestamp())) {
+ TRACE_EVENT2("webrtc",
+ "FrameBuffer::InsertFrame Frames dropped (OOO + PicId jump)",
+ "remote_ssrc", ssrc, "frame_id", frame->Id());
RTC_DLOG(LS_WARNING)
<< "Keyframe " << frame->Id()
<< " has newer timestamp but older picture id, clearing buffer.";
Clear();
} else {
// Already decoded past this frame.
+ TRACE_EVENT2("webrtc",
+ "FrameBuffer::InsertFrame Frame dropped (Out of order)",
+ "remote_ssrc", ssrc, "frame_id", frame->Id());
return false;
}
}
if (frames_.size() == max_size_) {
if (frame->is_keyframe()) {
+ TRACE_EVENT2("webrtc",
+ "FrameBuffer::InsertFrame Frames dropped (KF + Full buffer)",
+ "remote_ssrc", ssrc, "frame_id", frame->Id());
RTC_DLOG(LS_WARNING) << "Keyframe " << frame->Id()
<< " inserted into full buffer, clearing buffer.";
Clear();
} else {
// No space for this frame.
+ TRACE_EVENT2("webrtc",
+ "FrameBuffer::InsertFrame Frame dropped (Full buffer)",
+ "remote_ssrc", ssrc, "frame_id", frame->Id());
return false;
}
}
@@ -158,16 +176,31 @@ void FrameBuffer::DropNextDecodableTemporalUnit() {
void FrameBuffer::UpdateDroppedFramesAndDiscardedPackets(FrameIterator begin_it,
FrameIterator end_it) {
+ uint32_t dropped_ssrc = 0;
+ int64_t dropped_frame_id = 0;
unsigned int num_discarded_packets = 0;
unsigned int num_dropped_frames =
std::count_if(begin_it, end_it, [&](const auto& f) {
if (f.second.encoded_frame) {
const auto& packetInfos = f.second.encoded_frame->PacketInfos();
+ dropped_frame_id = f.first;
+ if (!packetInfos.empty()) {
+ dropped_ssrc = packetInfos[0].ssrc();
+ }
num_discarded_packets += packetInfos.size();
}
return f.second.encoded_frame != nullptr;
});
+ if (num_dropped_frames > 0) {
+ TRACE_EVENT2("webrtc", "FrameBuffer Dropping Old Frames", "remote_ssrc",
+ dropped_ssrc, "frame_id", dropped_frame_id);
+ }
+ if (num_discarded_packets > 0) {
+ TRACE_EVENT2("webrtc", "FrameBuffer Discarding Old Packets", "remote_ssrc",
+ dropped_ssrc, "frame_id", dropped_frame_id);
+ }
+
num_dropped_frames_ += num_dropped_frames;
num_discarded_packets_ += num_discarded_packets;
}
diff --git a/video/receive_statistics_proxy.cc b/video/receive_statistics_proxy.cc
index 729f7b7efb..6e75eb837f 100644
index 6e75eb837f..e8725574a0 100644
--- a/video/receive_statistics_proxy.cc
+++ b/video/receive_statistics_proxy.cc
@@ -800,8 +800,13 @@ void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) {
}
@@ -20,6 +20,7 @@
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/thread.h"
#include "rtc_base/time_utils.h"
+#include "rtc_base/trace_event.h"
#include "system_wrappers/include/clock.h"
#include "system_wrappers/include/metrics.h"
#include "video/video_receive_stream2.h"
@@ -767,6 +768,9 @@ void ReceiveStatisticsProxy::OnCompleteFrame(bool is_keyframe,
VideoContentType content_type) {
RTC_DCHECK_RUN_ON(&main_thread_);
+ TRACE_EVENT2("webrtc", "ReceiveStatisticsProxy::OnCompleteFrame",
+ "remote_ssrc", remote_ssrc_, "is_keyframe", is_keyframe);
+
// Content type extension is set only for keyframes and should be propagated
// for all the following delta frames. Here we may receive frames out of order
// and miscategorise some delta frames near the layer switch.
@@ -792,6 +796,8 @@ void ReceiveStatisticsProxy::OnCompleteFrame(bool is_keyframe,
void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) {
// Can be called on either the decode queue or the worker thread
// See FrameBuffer2 for more details.
+ TRACE_EVENT2("webrtc", "ReceiveStatisticsProxy::OnDroppedFrames",
+ "remote_ssrc", remote_ssrc_, "frames_dropped", frames_dropped);
worker_thread_->PostTask(
SafeTask(task_safety_.flag(), [frames_dropped, this]() {
RTC_DCHECK_RUN_ON(&main_thread_);
@@ -802,6 +808,9 @@ void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) {
void ReceiveStatisticsProxy::OnDiscardedPackets(uint32_t packets_discarded) {
- RTC_DCHECK_RUN_ON(&main_thread_);
- stats_.packets_discarded += packets_discarded;
+ // Can be called on either the decode queue or the worker thread
+ // See FrameBuffer2 for more details.
+ worker_thread_->PostTask(
+ SafeTask(task_safety_.flag(), [packets_discarded, this]() {
+ RTC_DCHECK_RUN_ON(&main_thread_);
+ stats_.packets_discarded += packets_discarded;
+ }));
// Can be called on either the decode queue or the worker thread
// See FrameBuffer2 for more details.
+ TRACE_EVENT2("webrtc", "ReceiveStatisticsProxy::OnDiscardedPackets",
+ "remote_ssrc", remote_ssrc_, "packets_discarded",
+ packets_discarded);
worker_thread_->PostTask(
SafeTask(task_safety_.flag(), [packets_discarded, this]() {
RTC_DCHECK_RUN_ON(&main_thread_);
@@ -830,6 +839,8 @@ void ReceiveStatisticsProxy::OnStreamInactive() {
void ReceiveStatisticsProxy::OnRttUpdate(int64_t avg_rtt_ms) {
RTC_DCHECK_RUN_ON(&main_thread_);
+ TRACE_EVENT2("webrtc", "ReceiveStatisticsProxy::OnRttUpdate",
+ "remote_ssrc", remote_ssrc_, "avg_rtt_ms", avg_rtt_ms);
avg_rtt_ms_ = avg_rtt_ms;
}
void ReceiveStatisticsProxy::OnPreDecode(VideoCodecType codec_type, int qp) {
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index a1d863b3ec..d8930a8b8e 100644
index d8930a8b8e..531098e317 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -1237,7 +1237,9 @@ void RtpVideoStreamReceiver2::FrameDecoded(int64_t picture_id) {
packet_infos_.erase(packet_infos_.begin(),
@@ -44,6 +44,7 @@
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/strings/string_builder.h"
+#include "rtc_base/trace_event.h"
#include "system_wrappers/include/metrics.h"
#include "system_wrappers/include/ntp_time.h"
@@ -1238,6 +1239,9 @@ void RtpVideoStreamReceiver2::FrameDecoded(int64_t picture_id) {
packet_infos_.upper_bound(unwrapped_rtp_seq_num));
uint32_t num_packets_cleared = packet_buffer_.ClearTo(seq_num);
- vcm_receive_statistics_->OnDiscardedPackets(num_packets_cleared);
+ if (num_packets_cleared > 0) {
+ vcm_receive_statistics_->OnDiscardedPackets(num_packets_cleared);
+ }
if (num_packets_cleared > 0) {
+ TRACE_EVENT2("webrtc",
+ "RtpVideoStreamReceiver2::FrameDecoded Cleared Old Packets",
+ "remote_ssrc", config_.rtp.remote_ssrc, "seq_num", seq_num);
vcm_receive_statistics_->OnDiscardedPackets(num_packets_cleared);
}
reference_finder_->ClearTo(seq_num);
}
}
diff --git a/video/video_stream_buffer_controller.cc b/video/video_stream_buffer_controller.cc
index 01063b12f7..e12ce75ba0 100644
--- a/video/video_stream_buffer_controller.cc
+++ b/video/video_stream_buffer_controller.cc
@@ -31,6 +31,7 @@
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/thread_annotations.h"
+#include "rtc_base/trace_event.h"
#include "video/frame_decode_scheduler.h"
#include "video/frame_decode_timing.h"
#include "video/task_queue_frame_decode_scheduler.h"
@@ -152,6 +153,9 @@ std::optional<int64_t> VideoStreamBufferController::InsertFrame(
std::unique_ptr<EncodedFrame> frame) {
RTC_DCHECK_RUN_ON(&worker_sequence_checker_);
FrameMetadata metadata(*frame);
+ const uint32_t ssrc =
+ frame->PacketInfos().empty() ? 0 : frame->PacketInfos()[0].ssrc();
+ const int64_t frameId = frame->Id();
int complete_units = buffer_->GetTotalNumberOfContinuousTemporalUnits();
if (buffer_->InsertFrame(std::move(frame))) {
RTC_DCHECK(metadata.receive_time) << "Frame receive time must be set!";
@@ -162,6 +166,9 @@ std::optional<int64_t> VideoStreamBufferController::InsertFrame(
*metadata.receive_time);
}
if (complete_units < buffer_->GetTotalNumberOfContinuousTemporalUnits()) {
+ TRACE_EVENT2("webrtc",
+ "VideoStreamBufferController::InsertFrame Frame Complete",
+ "remote_ssrc", ssrc, "frame_id", frameId);
stats_proxy_->OnCompleteFrame(metadata.is_keyframe, metadata.size,
metadata.contentType);
MaybeScheduleFrameForRelease();

View File

@ -1,221 +1,27 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Thu, 6 Jan 2022 00:16:00 +0000
Subject: Bug 1748458 - Add TRACE_EVENTs for dropped frames and packets for
received video. r=bwc
Subject: Bug 1748458 - Add TRACE_EVENT for keyframe requests. r=bwc
This lets us see in the profiler how many received frames and packets we decide
to drop and the reasons why.
Differential Revision: https://phabricator.services.mozilla.com/D135062
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/08e252da94c4752eccfd845eef13d8517953cc6a
Also includes:
Bug 1804288 - (fix-de7ae5755b) reimplement Bug 1748458 - Add TRACE_EVENTs for dropped frames and packets for received video. r=pehrsons
Differential Revision: https://phabricator.services.mozilla.com/D163960
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8e9a326a99cd5eaa6e447ff57c01ad9d79a09744
Differential Revision: https://phabricator.services.mozilla.com/D135113
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/5b2a7894ef1cf096d0e8977754507c0820e757fc
---
api/video/frame_buffer.cc | 33 +++++++++++++++++++++++++
video/receive_statistics_proxy.cc | 11 +++++++++
video/rtp_video_stream_receiver2.cc | 4 +++
video/video_stream_buffer_controller.cc | 7 ++++++
4 files changed, 55 insertions(+)
video/rtp_video_stream_receiver2.cc | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/api/video/frame_buffer.cc b/api/video/frame_buffer.cc
index 4981acf0ca..f0c48f3702 100644
--- a/api/video/frame_buffer.cc
+++ b/api/video/frame_buffer.cc
@@ -25,6 +25,7 @@
#include "api/video/encoded_frame.h"
#include "rtc_base/logging.h"
#include "rtc_base/numerics/sequence_number_util.h"
+#include "rtc_base/trace_event.h"
namespace webrtc {
namespace {
@@ -77,7 +78,12 @@ FrameBuffer::FrameBuffer(int max_size,
decoded_frame_history_(max_decode_history) {}
bool FrameBuffer::InsertFrame(std::unique_ptr<EncodedFrame> frame) {
+ const uint32_t ssrc =
+ frame->PacketInfos().empty() ? 0 : frame->PacketInfos()[0].ssrc();
if (!ValidReferences(*frame)) {
+ TRACE_EVENT2("webrtc",
+ "FrameBuffer::InsertFrame Frame dropped (Invalid references)",
+ "remote_ssrc", ssrc, "frame_id", frame->Id());
RTC_DLOG(LS_WARNING) << "Frame " << frame->Id()
<< " has invalid references, dropping frame.";
return false;
@@ -87,23 +93,35 @@ bool FrameBuffer::InsertFrame(std::unique_ptr<EncodedFrame> frame) {
if (legacy_frame_id_jump_behavior_ && frame->is_keyframe() &&
AheadOf(frame->RtpTimestamp(),
*decoded_frame_history_.GetLastDecodedFrameTimestamp())) {
+ TRACE_EVENT2("webrtc",
+ "FrameBuffer::InsertFrame Frames dropped (OOO + PicId jump)",
+ "remote_ssrc", ssrc, "frame_id", frame->Id());
RTC_DLOG(LS_WARNING)
<< "Keyframe " << frame->Id()
<< " has newer timestamp but older picture id, clearing buffer.";
Clear();
} else {
// Already decoded past this frame.
+ TRACE_EVENT2("webrtc",
+ "FrameBuffer::InsertFrame Frame dropped (Out of order)",
+ "remote_ssrc", ssrc, "frame_id", frame->Id());
return false;
}
}
if (frames_.size() == max_size_) {
if (frame->is_keyframe()) {
+ TRACE_EVENT2("webrtc",
+ "FrameBuffer::InsertFrame Frames dropped (KF + Full buffer)",
+ "remote_ssrc", ssrc, "frame_id", frame->Id());
RTC_DLOG(LS_WARNING) << "Keyframe " << frame->Id()
<< " inserted into full buffer, clearing buffer.";
Clear();
} else {
// No space for this frame.
+ TRACE_EVENT2("webrtc",
+ "FrameBuffer::InsertFrame Frame dropped (Full buffer)",
+ "remote_ssrc", ssrc, "frame_id", frame->Id());
return false;
}
}
@@ -158,16 +176,31 @@ void FrameBuffer::DropNextDecodableTemporalUnit() {
void FrameBuffer::UpdateDroppedFramesAndDiscardedPackets(FrameIterator begin_it,
FrameIterator end_it) {
+ uint32_t dropped_ssrc = 0;
+ int64_t dropped_frame_id = 0;
unsigned int num_discarded_packets = 0;
unsigned int num_dropped_frames =
std::count_if(begin_it, end_it, [&](const auto& f) {
if (f.second.encoded_frame) {
const auto& packetInfos = f.second.encoded_frame->PacketInfos();
+ dropped_frame_id = f.first;
+ if (!packetInfos.empty()) {
+ dropped_ssrc = packetInfos[0].ssrc();
+ }
num_discarded_packets += packetInfos.size();
}
return f.second.encoded_frame != nullptr;
});
+ if (num_dropped_frames > 0) {
+ TRACE_EVENT2("webrtc", "FrameBuffer Dropping Old Frames", "remote_ssrc",
+ dropped_ssrc, "frame_id", dropped_frame_id);
+ }
+ if (num_discarded_packets > 0) {
+ TRACE_EVENT2("webrtc", "FrameBuffer Discarding Old Packets", "remote_ssrc",
+ dropped_ssrc, "frame_id", dropped_frame_id);
+ }
+
num_dropped_frames_ += num_dropped_frames;
num_discarded_packets_ += num_discarded_packets;
}
diff --git a/video/receive_statistics_proxy.cc b/video/receive_statistics_proxy.cc
index 6e75eb837f..e8725574a0 100644
--- a/video/receive_statistics_proxy.cc
+++ b/video/receive_statistics_proxy.cc
@@ -20,6 +20,7 @@
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/thread.h"
#include "rtc_base/time_utils.h"
+#include "rtc_base/trace_event.h"
#include "system_wrappers/include/clock.h"
#include "system_wrappers/include/metrics.h"
#include "video/video_receive_stream2.h"
@@ -767,6 +768,9 @@ void ReceiveStatisticsProxy::OnCompleteFrame(bool is_keyframe,
VideoContentType content_type) {
RTC_DCHECK_RUN_ON(&main_thread_);
+ TRACE_EVENT2("webrtc", "ReceiveStatisticsProxy::OnCompleteFrame",
+ "remote_ssrc", remote_ssrc_, "is_keyframe", is_keyframe);
+
// Content type extension is set only for keyframes and should be propagated
// for all the following delta frames. Here we may receive frames out of order
// and miscategorise some delta frames near the layer switch.
@@ -792,6 +796,8 @@ void ReceiveStatisticsProxy::OnCompleteFrame(bool is_keyframe,
void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) {
// Can be called on either the decode queue or the worker thread
// See FrameBuffer2 for more details.
+ TRACE_EVENT2("webrtc", "ReceiveStatisticsProxy::OnDroppedFrames",
+ "remote_ssrc", remote_ssrc_, "frames_dropped", frames_dropped);
worker_thread_->PostTask(
SafeTask(task_safety_.flag(), [frames_dropped, this]() {
RTC_DCHECK_RUN_ON(&main_thread_);
@@ -802,6 +808,9 @@ void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) {
void ReceiveStatisticsProxy::OnDiscardedPackets(uint32_t packets_discarded) {
// Can be called on either the decode queue or the worker thread
// See FrameBuffer2 for more details.
+ TRACE_EVENT2("webrtc", "ReceiveStatisticsProxy::OnDiscardedPackets",
+ "remote_ssrc", remote_ssrc_, "packets_discarded",
+ packets_discarded);
worker_thread_->PostTask(
SafeTask(task_safety_.flag(), [packets_discarded, this]() {
RTC_DCHECK_RUN_ON(&main_thread_);
@@ -830,6 +839,8 @@ void ReceiveStatisticsProxy::OnStreamInactive() {
void ReceiveStatisticsProxy::OnRttUpdate(int64_t avg_rtt_ms) {
RTC_DCHECK_RUN_ON(&main_thread_);
+ TRACE_EVENT2("webrtc", "ReceiveStatisticsProxy::OnRttUpdate",
+ "remote_ssrc", remote_ssrc_, "avg_rtt_ms", avg_rtt_ms);
avg_rtt_ms_ = avg_rtt_ms;
}
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index d8930a8b8e..531098e317 100644
index 531098e317..7df19cf29b 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -44,6 +44,7 @@
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/strings/string_builder.h"
+#include "rtc_base/trace_event.h"
#include "system_wrappers/include/metrics.h"
#include "system_wrappers/include/ntp_time.h"
@@ -718,6 +718,12 @@ void RtpVideoStreamReceiver2::OnRtpPacket(const RtpPacketReceived& packet) {
@@ -1238,6 +1239,9 @@ void RtpVideoStreamReceiver2::FrameDecoded(int64_t picture_id) {
packet_infos_.upper_bound(unwrapped_rtp_seq_num));
uint32_t num_packets_cleared = packet_buffer_.ClearTo(seq_num);
if (num_packets_cleared > 0) {
+ TRACE_EVENT2("webrtc",
+ "RtpVideoStreamReceiver2::FrameDecoded Cleared Old Packets",
+ "remote_ssrc", config_.rtp.remote_ssrc, "seq_num", seq_num);
vcm_receive_statistics_->OnDiscardedPackets(num_packets_cleared);
}
reference_finder_->ClearTo(seq_num);
diff --git a/video/video_stream_buffer_controller.cc b/video/video_stream_buffer_controller.cc
index 01063b12f7..e12ce75ba0 100644
--- a/video/video_stream_buffer_controller.cc
+++ b/video/video_stream_buffer_controller.cc
@@ -31,6 +31,7 @@
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/thread_annotations.h"
+#include "rtc_base/trace_event.h"
#include "video/frame_decode_scheduler.h"
#include "video/frame_decode_timing.h"
#include "video/task_queue_frame_decode_scheduler.h"
@@ -152,6 +153,9 @@ std::optional<int64_t> VideoStreamBufferController::InsertFrame(
std::unique_ptr<EncodedFrame> frame) {
RTC_DCHECK_RUN_ON(&worker_sequence_checker_);
FrameMetadata metadata(*frame);
+ const uint32_t ssrc =
+ frame->PacketInfos().empty() ? 0 : frame->PacketInfos()[0].ssrc();
+ const int64_t frameId = frame->Id();
int complete_units = buffer_->GetTotalNumberOfContinuousTemporalUnits();
if (buffer_->InsertFrame(std::move(frame))) {
RTC_DCHECK(metadata.receive_time) << "Frame receive time must be set!";
@@ -162,6 +166,9 @@ std::optional<int64_t> VideoStreamBufferController::InsertFrame(
*metadata.receive_time);
}
if (complete_units < buffer_->GetTotalNumberOfContinuousTemporalUnits()) {
+ TRACE_EVENT2("webrtc",
+ "VideoStreamBufferController::InsertFrame Frame Complete",
+ "remote_ssrc", ssrc, "frame_id", frameId);
stats_proxy_->OnCompleteFrame(metadata.is_keyframe, metadata.size,
metadata.contentType);
MaybeScheduleFrameForRelease();
void RtpVideoStreamReceiver2::RequestKeyFrame() {
RTC_DCHECK_RUN_ON(&worker_task_checker_);
+ TRACE_EVENT2("webrtc", "RtpVideoStreamReceiver2::RequestKeyFrame",
+ "remote_ssrc", config_.rtp.remote_ssrc, "method",
+ keyframe_request_method_ == KeyFrameReqMethod::kPliRtcp ? "PLI"
+ : keyframe_request_method_ == KeyFrameReqMethod::kFirRtcp ? "FIR"
+ : keyframe_request_method_ == KeyFrameReqMethod::kNone ? "None"
+ : "Other");
// TODO(bugs.webrtc.org/10336): Allow the sender to ignore key frame requests
// issued by anything other than the LossNotificationController if it (the
// sender) is relying on LNTF alone.

View File

@ -1,27 +1,23 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Thu, 6 Jan 2022 00:16:00 +0000
Subject: Bug 1748458 - Add TRACE_EVENT for keyframe requests. r=bwc
Date: Wed, 11 Jan 2023 22:42:00 +0000
Subject: Bug 1800942 - Add DCHECKs to
TimestampExtrapolator::ExtrapolateLocalTime. r=mjf
Differential Revision: https://phabricator.services.mozilla.com/D135113
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/5b2a7894ef1cf096d0e8977754507c0820e757fc
Differential Revision: https://phabricator.services.mozilla.com/D166536
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c5df7f40392464ffc63f44a53ddcaab2091741e0
---
video/rtp_video_stream_receiver2.cc | 6 ++++++
1 file changed, 6 insertions(+)
modules/video_coding/timing/timestamp_extrapolator.cc | 1 +
1 file changed, 1 insertion(+)
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index 531098e317..7df19cf29b 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -718,6 +718,12 @@ void RtpVideoStreamReceiver2::OnRtpPacket(const RtpPacketReceived& packet) {
diff --git a/modules/video_coding/timing/timestamp_extrapolator.cc b/modules/video_coding/timing/timestamp_extrapolator.cc
index 15605033c8..e9a3ce211e 100644
--- a/modules/video_coding/timing/timestamp_extrapolator.cc
+++ b/modules/video_coding/timing/timestamp_extrapolator.cc
@@ -126,6 +126,7 @@ void TimestampExtrapolator::Update(Timestamp now, uint32_t ts90khz) {
std::optional<Timestamp> TimestampExtrapolator::ExtrapolateLocalTime(
uint32_t timestamp90khz) const {
int64_t unwrapped_ts90khz = unwrapper_.PeekUnwrap(timestamp90khz);
+ RTC_DCHECK_GE(unwrapped_ts90khz, 0);
void RtpVideoStreamReceiver2::RequestKeyFrame() {
RTC_DCHECK_RUN_ON(&worker_task_checker_);
+ TRACE_EVENT2("webrtc", "RtpVideoStreamReceiver2::RequestKeyFrame",
+ "remote_ssrc", config_.rtp.remote_ssrc, "method",
+ keyframe_request_method_ == KeyFrameReqMethod::kPliRtcp ? "PLI"
+ : keyframe_request_method_ == KeyFrameReqMethod::kFirRtcp ? "FIR"
+ : keyframe_request_method_ == KeyFrameReqMethod::kNone ? "None"
+ : "Other");
// TODO(bugs.webrtc.org/10336): Allow the sender to ignore key frame requests
// issued by anything other than the LossNotificationController if it (the
// sender) is relying on LNTF alone.
if (!first_unwrapped_timestamp_) {
return std::nullopt;

View File

@ -1,23 +1,25 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Wed, 11 Jan 2023 22:42:00 +0000
Subject: Bug 1800942 - Add DCHECKs to
TimestampExtrapolator::ExtrapolateLocalTime. r=mjf
Date: Wed, 8 Feb 2023 08:01:00 +0000
Subject: Bug 1814692 - Don't attempt realtime scheduling rtc::PlatformThreads.
r=webrtc-reviewers,bwc
Differential Revision: https://phabricator.services.mozilla.com/D166536
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c5df7f40392464ffc63f44a53ddcaab2091741e0
Differential Revision: https://phabricator.services.mozilla.com/D169036
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/9e64a965e26c8379261466e5273c3b383164b2c7
---
modules/video_coding/timing/timestamp_extrapolator.cc | 1 +
1 file changed, 1 insertion(+)
rtc_base/platform_thread.cc | 3 +++
1 file changed, 3 insertions(+)
diff --git a/modules/video_coding/timing/timestamp_extrapolator.cc b/modules/video_coding/timing/timestamp_extrapolator.cc
index 15605033c8..e9a3ce211e 100644
--- a/modules/video_coding/timing/timestamp_extrapolator.cc
+++ b/modules/video_coding/timing/timestamp_extrapolator.cc
@@ -126,6 +126,7 @@ void TimestampExtrapolator::Update(Timestamp now, uint32_t ts90khz) {
std::optional<Timestamp> TimestampExtrapolator::ExtrapolateLocalTime(
uint32_t timestamp90khz) const {
int64_t unwrapped_ts90khz = unwrapper_.PeekUnwrap(timestamp90khz);
+ RTC_DCHECK_GE(unwrapped_ts90khz, 0);
if (!first_unwrapped_timestamp_) {
return std::nullopt;
diff --git a/rtc_base/platform_thread.cc b/rtc_base/platform_thread.cc
index 81e115b568..dafc028c25 100644
--- a/rtc_base/platform_thread.cc
+++ b/rtc_base/platform_thread.cc
@@ -52,6 +52,9 @@ bool SetPriority(ThreadPriority priority) {
// TODO(tommi): Switch to the same mechanism as Chromium uses for changing
// thread priorities.
return true;
+#elif defined(WEBRTC_MOZILLA_BUILD) && defined(WEBRTC_LINUX)
+ // Only realtime audio uses realtime scheduling in Firefox.
+ return true;
#else
const int policy = SCHED_FIFO;
const int min_prio = sched_get_priority_min(policy);

View File

@ -1,25 +1,74 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Wed, 8 Feb 2023 08:01:00 +0000
Subject: Bug 1814692 - Don't attempt realtime scheduling rtc::PlatformThreads.
r=webrtc-reviewers,bwc
From: Jan Grulich <jgrulich@redhat.com>
Date: Fri, 10 Mar 2023 09:21:00 +0000
Subject: Bug 1819035 - get EGL display based on the used platform in the
browser r=webrtc-reviewers,ng
Differential Revision: https://phabricator.services.mozilla.com/D169036
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/9e64a965e26c8379261466e5273c3b383164b2c7
Because of a possible misconfiguration or a possible driver issue it
might happen that the browser will use a different driver on X11 and
end up using yet another one for wayland/gbm, which might lead to not
working screen sharing in the better case, but also to a crash in the
other driver (Nvidia). This adds a check for platform the browser runs
on, if it's XWayland or Wayland and based on that query EGL display for
that specific platform, rather than going for the Wayland one only.
Differential Revision: https://phabricator.services.mozilla.com/D171858
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c8606497de1f461a6352456e0e511c2ae498d526
---
rtc_base/platform_thread.cc | 3 +++
1 file changed, 3 insertions(+)
.../linux/wayland/egl_dmabuf.cc | 30 +++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/rtc_base/platform_thread.cc b/rtc_base/platform_thread.cc
index 81e115b568..dafc028c25 100644
--- a/rtc_base/platform_thread.cc
+++ b/rtc_base/platform_thread.cc
@@ -52,6 +52,9 @@ bool SetPriority(ThreadPriority priority) {
// TODO(tommi): Switch to the same mechanism as Chromium uses for changing
// thread priorities.
return true;
+#elif defined(WEBRTC_MOZILLA_BUILD) && defined(WEBRTC_LINUX)
+ // Only realtime audio uses realtime scheduling in Firefox.
+ return true;
#else
const int policy = SCHED_FIFO;
const int min_prio = sched_get_priority_min(policy);
diff --git a/modules/desktop_capture/linux/wayland/egl_dmabuf.cc b/modules/desktop_capture/linux/wayland/egl_dmabuf.cc
index fff976468c..15a447d1b0 100644
--- a/modules/desktop_capture/linux/wayland/egl_dmabuf.cc
+++ b/modules/desktop_capture/linux/wayland/egl_dmabuf.cc
@@ -13,6 +13,7 @@
#include <asm/ioctl.h>
#include <dlfcn.h>
#include <fcntl.h>
+#include <gdk/gdk.h>
#include <libdrm/drm_fourcc.h>
#include <linux/types.h>
#include <spa/param/video/format-utils.h>
@@ -218,6 +219,26 @@ static void CloseLibrary(void* library) {
}
}
+static bool IsWaylandDisplay() {
+ static auto sGdkWaylandDisplayGetType =
+ (GType (*)(void))dlsym(RTLD_DEFAULT, "gdk_wayland_display_get_type");
+ if (!sGdkWaylandDisplayGetType) {
+ return false;
+ }
+ return (G_TYPE_CHECK_INSTANCE_TYPE ((gdk_display_get_default()),
+ sGdkWaylandDisplayGetType()));
+}
+
+static bool IsX11Display() {
+ static auto sGdkX11DisplayGetType =
+ (GType (*)(void))dlsym(RTLD_DEFAULT, "gdk_x11_display_get_type");
+ if (!sGdkX11DisplayGetType) {
+ return false;
+ }
+ return (G_TYPE_CHECK_INSTANCE_TYPE ((gdk_display_get_default()),
+ sGdkX11DisplayGetType()));
+}
+
static void* g_lib_egl = nullptr;
RTC_NO_SANITIZE("cfi-icall")
@@ -363,8 +384,13 @@ EglDmaBuf::EglDmaBuf() {
return;
}
- egl_.display = EglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_KHR,
- (void*)EGL_DEFAULT_DISPLAY, nullptr);
+ if (IsWaylandDisplay()) {
+ egl_.display = EglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_KHR,
+ (void*)EGL_DEFAULT_DISPLAY, nullptr);
+ } else if (IsX11Display()) {
+ egl_.display = EglGetPlatformDisplay(EGL_PLATFORM_X11_KHR,
+ (void*)EGL_DEFAULT_DISPLAY, nullptr);
+ }
if (egl_.display == EGL_NO_DISPLAY) {
RTC_LOG(LS_ERROR) << "Failed to obtain default EGL display: "

View File

@ -1,74 +1,31 @@
From: Jan Grulich <jgrulich@redhat.com>
Date: Fri, 10 Mar 2023 09:21:00 +0000
Subject: Bug 1819035 - get EGL display based on the used platform in the
browser r=webrtc-reviewers,ng
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 27 Feb 2023 16:22:00 +0000
Subject: Bug 1817024 - (fix-fdcfefa708) In PhysicalSocket avoid a non-trivial
designated initializer. r=mjf,webrtc-reviewers
Because of a possible misconfiguration or a possible driver issue it
might happen that the browser will use a different driver on X11 and
end up using yet another one for wayland/gbm, which might lead to not
working screen sharing in the better case, but also to a crash in the
other driver (Nvidia). This adds a check for platform the browser runs
on, if it's XWayland or Wayland and based on that query EGL display for
that specific platform, rather than going for the Wayland one only.
This fixes a build failure in the base-toolchain job with GCC 7.5.0:
In file included from Unified_cpp_threading_gn0.cpp:38:0:
.../third_party/libwebrtc/rtc_base/physical_socket_server.cc: In member function 'int rtc::PhysicalSocket::DoReadFromSocket(void*, size_t, rtc::SocketAddress*, int64_t*)':
.../third_party/libwebrtc/rtc_base/physical_socket_server.cc:463:51: sorry, unimplemented: non-trivial designated initializers not supported
msghdr msg = {.msg_iov = &iov, .msg_iovlen = 1};
^
Differential Revision: https://phabricator.services.mozilla.com/D171858
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c8606497de1f461a6352456e0e511c2ae498d526
Differential Revision: https://phabricator.services.mozilla.com/D171057
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a3447f709befd84a282ca40f29b7a5ea76d5b68d
---
.../linux/wayland/egl_dmabuf.cc | 30 +++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
rtc_base/physical_socket_server.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/desktop_capture/linux/wayland/egl_dmabuf.cc b/modules/desktop_capture/linux/wayland/egl_dmabuf.cc
index fff976468c..15a447d1b0 100644
--- a/modules/desktop_capture/linux/wayland/egl_dmabuf.cc
+++ b/modules/desktop_capture/linux/wayland/egl_dmabuf.cc
@@ -13,6 +13,7 @@
#include <asm/ioctl.h>
#include <dlfcn.h>
#include <fcntl.h>
+#include <gdk/gdk.h>
#include <libdrm/drm_fourcc.h>
#include <linux/types.h>
#include <spa/param/video/format-utils.h>
@@ -218,6 +219,26 @@ static void CloseLibrary(void* library) {
}
}
+static bool IsWaylandDisplay() {
+ static auto sGdkWaylandDisplayGetType =
+ (GType (*)(void))dlsym(RTLD_DEFAULT, "gdk_wayland_display_get_type");
+ if (!sGdkWaylandDisplayGetType) {
+ return false;
+ }
+ return (G_TYPE_CHECK_INSTANCE_TYPE ((gdk_display_get_default()),
+ sGdkWaylandDisplayGetType()));
+}
+
+static bool IsX11Display() {
+ static auto sGdkX11DisplayGetType =
+ (GType (*)(void))dlsym(RTLD_DEFAULT, "gdk_x11_display_get_type");
+ if (!sGdkX11DisplayGetType) {
+ return false;
+ }
+ return (G_TYPE_CHECK_INSTANCE_TYPE ((gdk_display_get_default()),
+ sGdkX11DisplayGetType()));
+}
+
static void* g_lib_egl = nullptr;
RTC_NO_SANITIZE("cfi-icall")
@@ -363,8 +384,13 @@ EglDmaBuf::EglDmaBuf() {
return;
}
- egl_.display = EglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_KHR,
- (void*)EGL_DEFAULT_DISPLAY, nullptr);
+ if (IsWaylandDisplay()) {
+ egl_.display = EglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_KHR,
+ (void*)EGL_DEFAULT_DISPLAY, nullptr);
+ } else if (IsX11Display()) {
+ egl_.display = EglGetPlatformDisplay(EGL_PLATFORM_X11_KHR,
+ (void*)EGL_DEFAULT_DISPLAY, nullptr);
+ }
if (egl_.display == EGL_NO_DISPLAY) {
RTC_LOG(LS_ERROR) << "Failed to obtain default EGL display: "
diff --git a/rtc_base/physical_socket_server.cc b/rtc_base/physical_socket_server.cc
index 5a75fbb707..809efb8814 100644
--- a/rtc_base/physical_socket_server.cc
+++ b/rtc_base/physical_socket_server.cc
@@ -520,7 +520,7 @@ int PhysicalSocket::DoReadFromSocket(void* buffer,
#if defined(WEBRTC_POSIX)
int received = 0;
iovec iov = {.iov_base = buffer, .iov_len = length};
- msghdr msg = {.msg_iov = &iov, .msg_iovlen = 1};
+ msghdr msg = {.msg_name = nullptr, .msg_namelen = 0, .msg_iov = &iov, .msg_iovlen = 1};
if (out_addr) {
out_addr->Clear();
msg.msg_name = addr;

View File

@ -1,31 +1,24 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 27 Feb 2023 16:22:00 +0000
Subject: Bug 1817024 - (fix-fdcfefa708) In PhysicalSocket avoid a non-trivial
designated initializer. r=mjf,webrtc-reviewers
From: Byron Campen <docfaraday@gmail.com>
Date: Fri, 7 Apr 2023 20:28:00 +0000
Subject: Bug 1819048: Remove this bad assertion. r=webrtc-reviewers,jib
This fixes a build failure in the base-toolchain job with GCC 7.5.0:
In file included from Unified_cpp_threading_gn0.cpp:38:0:
.../third_party/libwebrtc/rtc_base/physical_socket_server.cc: In member function 'int rtc::PhysicalSocket::DoReadFromSocket(void*, size_t, rtc::SocketAddress*, int64_t*)':
.../third_party/libwebrtc/rtc_base/physical_socket_server.cc:463:51: sorry, unimplemented: non-trivial designated initializers not supported
msghdr msg = {.msg_iov = &iov, .msg_iovlen = 1};
^
Differential Revision: https://phabricator.services.mozilla.com/D171057
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a3447f709befd84a282ca40f29b7a5ea76d5b68d
Differential Revision: https://phabricator.services.mozilla.com/D174978
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/5a52e1b0c808edfda82f0abea668699eb68098dc
---
rtc_base/physical_socket_server.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
video/task_queue_frame_decode_scheduler.cc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/rtc_base/physical_socket_server.cc b/rtc_base/physical_socket_server.cc
index 5a75fbb707..809efb8814 100644
--- a/rtc_base/physical_socket_server.cc
+++ b/rtc_base/physical_socket_server.cc
@@ -520,7 +520,7 @@ int PhysicalSocket::DoReadFromSocket(void* buffer,
#if defined(WEBRTC_POSIX)
int received = 0;
iovec iov = {.iov_base = buffer, .iov_len = length};
- msghdr msg = {.msg_iov = &iov, .msg_iovlen = 1};
+ msghdr msg = {.msg_name = nullptr, .msg_namelen = 0, .msg_iov = &iov, .msg_iovlen = 1};
if (out_addr) {
out_addr->Clear();
msg.msg_name = addr;
diff --git a/video/task_queue_frame_decode_scheduler.cc b/video/task_queue_frame_decode_scheduler.cc
index 624f8abf4a..dcc83d4a8b 100644
--- a/video/task_queue_frame_decode_scheduler.cc
+++ b/video/task_queue_frame_decode_scheduler.cc
@@ -37,7 +37,8 @@ void TaskQueueFrameDecodeScheduler::ScheduleFrame(
uint32_t rtp,
FrameDecodeTiming::FrameSchedule schedule,
FrameReleaseCallback cb) {
- RTC_DCHECK(!stopped_) << "Can not schedule frames after stopped.";
+ // Mozilla modification, until https://bugs.webrtc.org/14944 is fixed
+ //RTC_DCHECK(!stopped_) << "Can not schedule frames after stopped.";
RTC_DCHECK(!scheduled_rtp_.has_value())
<< "Can not schedule two frames for release at the same time.";
RTC_DCHECK(cb);

View File

@ -1,24 +1,57 @@
From: Byron Campen <docfaraday@gmail.com>
Date: Fri, 7 Apr 2023 20:28:00 +0000
Subject: Bug 1819048: Remove this bad assertion. r=webrtc-reviewers,jib
From: Nico Grunbaum <na-g@nostrum.com>
Date: Tue, 6 Jun 2023 16:37:00 -0700
Subject: Bug 1833237 - (fix-f0be3bee1f) remove reference to
portal:pipewire_base;r?pehrsons
Differential Revision: https://phabricator.services.mozilla.com/D174978
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/5a52e1b0c808edfda82f0abea668699eb68098dc
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8ff886a4d366b4be35b329d1ef733a6df542067c
---
video/task_queue_frame_decode_scheduler.cc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
modules/video_capture/BUILD.gn | 4 ++++
modules/video_capture/linux/device_info_pipewire.cc | 4 ++--
modules/video_capture/linux/device_info_pipewire.h | 3 ++-
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/video/task_queue_frame_decode_scheduler.cc b/video/task_queue_frame_decode_scheduler.cc
index 624f8abf4a..dcc83d4a8b 100644
--- a/video/task_queue_frame_decode_scheduler.cc
+++ b/video/task_queue_frame_decode_scheduler.cc
@@ -37,7 +37,8 @@ void TaskQueueFrameDecodeScheduler::ScheduleFrame(
uint32_t rtp,
FrameDecodeTiming::FrameSchedule schedule,
FrameReleaseCallback cb) {
- RTC_DCHECK(!stopped_) << "Can not schedule frames after stopped.";
+ // Mozilla modification, until https://bugs.webrtc.org/14944 is fixed
+ //RTC_DCHECK(!stopped_) << "Can not schedule frames after stopped.";
RTC_DCHECK(!scheduled_rtp_.has_value())
<< "Can not schedule two frames for release at the same time.";
RTC_DCHECK(cb);
diff --git a/modules/video_capture/BUILD.gn b/modules/video_capture/BUILD.gn
index a2bf27f645..d9b3471572 100644
--- a/modules/video_capture/BUILD.gn
+++ b/modules/video_capture/BUILD.gn
@@ -108,6 +108,10 @@ if (!build_with_chromium || is_linux || is_chromeos) {
"../../media:rtc_media_base",
"../portal",
]
+ if (build_with_mozilla) {
+ configs -= [ "../portal:pipewire_base" ]
+ public_deps = [ "//third_party/pipewire" ]
+ }
}
}
if (is_win) {
diff --git a/modules/video_capture/linux/device_info_pipewire.cc b/modules/video_capture/linux/device_info_pipewire.cc
index 0ec0da3933..b802fe580c 100644
--- a/modules/video_capture/linux/device_info_pipewire.cc
+++ b/modules/video_capture/linux/device_info_pipewire.cc
@@ -49,9 +49,9 @@ int32_t DeviceInfoPipeWire::GetDeviceName(uint32_t deviceNumber,
char* deviceUniqueIdUTF8,
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8,
- uint32_t productUniqueIdUTF8Length) {
+ uint32_t productUniqueIdUTF8Length,
+ pid_t* pid) {
RTC_CHECK(pipewire_session_);
-
if (deviceNumber >= NumberOfDevices())
return -1;
diff --git a/modules/video_capture/linux/device_info_pipewire.h b/modules/video_capture/linux/device_info_pipewire.h
index 4da0c7a90b..8a33d75892 100644
--- a/modules/video_capture/linux/device_info_pipewire.h
+++ b/modules/video_capture/linux/device_info_pipewire.h
@@ -29,7 +29,8 @@ class DeviceInfoPipeWire : public DeviceInfoImpl {
char* deviceUniqueIdUTF8,
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8 = nullptr,
- uint32_t productUniqueIdUTF8Length = 0) override;
+ uint32_t productUniqueIdUTF8Length = 0,
+ pid_t* pid = 0) override;
/*
* Fills the membervariable _captureCapabilities with capabilites for the
* given device name.

View File

@ -1,57 +1,29 @@
From: Nico Grunbaum <na-g@nostrum.com>
Date: Tue, 6 Jun 2023 16:37:00 -0700
Subject: Bug 1833237 - (fix-f0be3bee1f) remove reference to
portal:pipewire_base;r?pehrsons
From: Jan-Ivar Bruaroey <jib@mozilla.com>
Date: Wed, 28 Jun 2023 20:45:00 -0400
Subject: Bug 1839451 - (fix-0f43da2248) Keep mozilla's
RTCPReceiver::RemoteRTCPSenderInfo function working.
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8ff886a4d366b4be35b329d1ef733a6df542067c
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/154c9cdb386d0f50c5e1549270e1af6ab4969602
---
modules/video_capture/BUILD.gn | 4 ++++
modules/video_capture/linux/device_info_pipewire.cc | 4 ++--
modules/video_capture/linux/device_info_pipewire.h | 3 ++-
3 files changed, 8 insertions(+), 3 deletions(-)
modules/rtp_rtcp/source/rtcp_receiver.cc | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/modules/video_capture/BUILD.gn b/modules/video_capture/BUILD.gn
index a2bf27f645..d9b3471572 100644
--- a/modules/video_capture/BUILD.gn
+++ b/modules/video_capture/BUILD.gn
@@ -108,6 +108,10 @@ if (!build_with_chromium || is_linux || is_chromeos) {
"../../media:rtc_media_base",
"../portal",
]
+ if (build_with_mozilla) {
+ configs -= [ "../portal:pipewire_base" ]
+ public_deps = [ "//third_party/pipewire" ]
+ }
}
}
if (is_win) {
diff --git a/modules/video_capture/linux/device_info_pipewire.cc b/modules/video_capture/linux/device_info_pipewire.cc
index 0ec0da3933..b802fe580c 100644
--- a/modules/video_capture/linux/device_info_pipewire.cc
+++ b/modules/video_capture/linux/device_info_pipewire.cc
@@ -49,9 +49,9 @@ int32_t DeviceInfoPipeWire::GetDeviceName(uint32_t deviceNumber,
char* deviceUniqueIdUTF8,
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8,
- uint32_t productUniqueIdUTF8Length) {
+ uint32_t productUniqueIdUTF8Length,
+ pid_t* pid) {
RTC_CHECK(pipewire_session_);
-
if (deviceNumber >= NumberOfDevices())
return -1;
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc
index 3298961fd3..44215c7473 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.cc
+++ b/modules/rtp_rtcp/source/rtcp_receiver.cc
@@ -394,10 +394,10 @@ void RTCPReceiver::RemoteRTCPSenderInfo(uint32_t* packet_count,
int64_t* ntp_timestamp_ms,
int64_t* remote_ntp_timestamp_ms) const {
MutexLock lock(&rtcp_receiver_lock_);
- *packet_count = remote_sender_packet_count_;
- *octet_count = remote_sender_octet_count_;
- *ntp_timestamp_ms = last_received_sr_ntp_.ToMs();
- *remote_ntp_timestamp_ms = remote_sender_ntp_time_.ToMs();
+ *packet_count = remote_sender_.packets_sent;
+ *octet_count = remote_sender_.bytes_sent;
+ *ntp_timestamp_ms = remote_sender_.last_arrival_timestamp.ToMs();
+ *remote_ntp_timestamp_ms = remote_sender_.last_remote_timestamp.ToMs();
}
diff --git a/modules/video_capture/linux/device_info_pipewire.h b/modules/video_capture/linux/device_info_pipewire.h
index 4da0c7a90b..8a33d75892 100644
--- a/modules/video_capture/linux/device_info_pipewire.h
+++ b/modules/video_capture/linux/device_info_pipewire.h
@@ -29,7 +29,8 @@ class DeviceInfoPipeWire : public DeviceInfoImpl {
char* deviceUniqueIdUTF8,
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8 = nullptr,
- uint32_t productUniqueIdUTF8Length = 0) override;
+ uint32_t productUniqueIdUTF8Length = 0,
+ pid_t* pid = 0) override;
/*
* Fills the membervariable _captureCapabilities with capabilites for the
* given device name.
std::vector<ReportBlockData> RTCPReceiver::GetLatestReportBlockData() const {

View File

@ -1,29 +1,33 @@
From: Jan-Ivar Bruaroey <jib@mozilla.com>
Date: Wed, 28 Jun 2023 20:45:00 -0400
Subject: Bug 1839451 - (fix-0f43da2248) Keep mozilla's
RTCPReceiver::RemoteRTCPSenderInfo function working.
From: Nico Grunbaum <na-g@nostrum.com>
Date: Thu, 22 Jun 2023 16:23:00 +0000
Subject: Bug 1837918 - libwebrtc update broke the build on
OpenBSD;r=mjf,webrtc-reviewers
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/154c9cdb386d0f50c5e1549270e1af6ab4969602
Differential Revision: https://phabricator.services.mozilla.com/D181791
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2a6a838b7021bb285f9485c2ceda6ba2543e0d6f
---
modules/rtp_rtcp/source/rtcp_receiver.cc | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
modules/video_capture/video_capture_options.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc
index 3298961fd3..44215c7473 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.cc
+++ b/modules/rtp_rtcp/source/rtcp_receiver.cc
@@ -394,10 +394,10 @@ void RTCPReceiver::RemoteRTCPSenderInfo(uint32_t* packet_count,
int64_t* ntp_timestamp_ms,
int64_t* remote_ntp_timestamp_ms) const {
MutexLock lock(&rtcp_receiver_lock_);
- *packet_count = remote_sender_packet_count_;
- *octet_count = remote_sender_octet_count_;
- *ntp_timestamp_ms = last_received_sr_ntp_.ToMs();
- *remote_ntp_timestamp_ms = remote_sender_ntp_time_.ToMs();
+ *packet_count = remote_sender_.packets_sent;
+ *octet_count = remote_sender_.bytes_sent;
+ *ntp_timestamp_ms = remote_sender_.last_arrival_timestamp.ToMs();
+ *remote_ntp_timestamp_ms = remote_sender_.last_remote_timestamp.ToMs();
}
diff --git a/modules/video_capture/video_capture_options.h b/modules/video_capture/video_capture_options.h
index 6f72f7927e..37965305d9 100644
--- a/modules/video_capture/video_capture_options.h
+++ b/modules/video_capture/video_capture_options.h
@@ -55,7 +55,7 @@ class RTC_EXPORT VideoCaptureOptions {
std::vector<ReportBlockData> RTCPReceiver::GetLatestReportBlockData() const {
void Init(Callback* callback);
-#if defined(WEBRTC_LINUX)
+#if defined(WEBRTC_LINUX) || defined(WEBRTC_BSD)
bool allow_v4l2() const { return allow_v4l2_; }
void set_allow_v4l2(bool allow) { allow_v4l2_ = allow; }
#endif
@@ -68,7 +68,7 @@ class RTC_EXPORT VideoCaptureOptions {
#endif
private:
-#if defined(WEBRTC_LINUX)
+#if defined(WEBRTC_LINUX) || defined(WEBRTC_BSD)
bool allow_v4l2_ = false;
#endif
#if defined(WEBRTC_USE_PIPEWIRE)

View File

@ -1,33 +1,24 @@
From: Nico Grunbaum <na-g@nostrum.com>
Date: Thu, 22 Jun 2023 16:23:00 +0000
Subject: Bug 1837918 - libwebrtc update broke the build on
OpenBSD;r=mjf,webrtc-reviewers
From: Michael Froman <mfroman@mozilla.com>
Date: Wed, 5 Jul 2023 19:15:00 +0000
Subject: Bug 1841864 - upstream commit 4baea5b07f should properly check size
of encoder_config_.simulcast_layers. r=jib
Differential Revision: https://phabricator.services.mozilla.com/D181791
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2a6a838b7021bb285f9485c2ceda6ba2543e0d6f
Differential Revision: https://phabricator.services.mozilla.com/D182813
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a7179d8d75313b6c9c76a496e10d102da019ff4f
---
modules/video_capture/video_capture_options.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
video/video_stream_encoder.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/video_capture/video_capture_options.h b/modules/video_capture/video_capture_options.h
index 6f72f7927e..37965305d9 100644
--- a/modules/video_capture/video_capture_options.h
+++ b/modules/video_capture/video_capture_options.h
@@ -55,7 +55,7 @@ class RTC_EXPORT VideoCaptureOptions {
diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc
index 4fc7771f0f..50fbc9eb49 100644
--- a/video/video_stream_encoder.cc
+++ b/video/video_stream_encoder.cc
@@ -1384,7 +1384,7 @@ void VideoStreamEncoder::ReconfigureEncoder() {
void Init(Callback* callback);
-#if defined(WEBRTC_LINUX)
+#if defined(WEBRTC_LINUX) || defined(WEBRTC_BSD)
bool allow_v4l2() const { return allow_v4l2_; }
void set_allow_v4l2(bool allow) { allow_v4l2_ = allow; }
#endif
@@ -68,7 +68,7 @@ class RTC_EXPORT VideoCaptureOptions {
#endif
private:
-#if defined(WEBRTC_LINUX)
+#if defined(WEBRTC_LINUX) || defined(WEBRTC_BSD)
bool allow_v4l2_ = false;
#endif
#if defined(WEBRTC_USE_PIPEWIRE)
bool is_svc = false;
bool single_stream_or_non_first_inactive = true;
- for (size_t i = 1; i < encoder_config_.number_of_streams; ++i) {
+ for (size_t i = 1; i < encoder_config_.simulcast_layers.size(); ++i) {
if (encoder_config_.simulcast_layers[i].active) {
single_stream_or_non_first_inactive = false;
break;

View File

@ -1,24 +1,24 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Wed, 5 Jul 2023 19:15:00 +0000
Subject: Bug 1841864 - upstream commit 4baea5b07f should properly check size
of encoder_config_.simulcast_layers. r=jib
From: Mike Hommey <mh+mozilla@glandium.org>
Date: Fri, 7 Jul 2023 00:58:00 +0000
Subject: Bug 1841577 - Don't set WEBRTC_ENABLE_AVX2 on platforms that don't
have AVX2. r=mjf,webrtc-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D182813
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a7179d8d75313b6c9c76a496e10d102da019ff4f
Differential Revision: https://phabricator.services.mozilla.com/D182695
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/46fb51c90709be64c35946a8cf69195121441024
---
video/video_stream_encoder.cc | 2 +-
webrtc.gni | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc
index 4fc7771f0f..50fbc9eb49 100644
--- a/video/video_stream_encoder.cc
+++ b/video/video_stream_encoder.cc
@@ -1384,7 +1384,7 @@ void VideoStreamEncoder::ReconfigureEncoder() {
diff --git a/webrtc.gni b/webrtc.gni
index f55b88a061..167b4d7de0 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -317,7 +317,7 @@ declare_args() {
bool is_svc = false;
bool single_stream_or_non_first_inactive = true;
- for (size_t i = 1; i < encoder_config_.number_of_streams; ++i) {
+ for (size_t i = 1; i < encoder_config_.simulcast_layers.size(); ++i) {
if (encoder_config_.simulcast_layers[i].active) {
single_stream_or_non_first_inactive = false;
break;
# Set this to true to enable the avx2 support in webrtc.
# TODO: Make sure that AVX2 works also for non-clang compilers.
- if (is_clang == true) {
+ if (is_clang == true && (target_cpu == "x86" || target_cpu == "x64")) {
rtc_enable_avx2 = true
} else {
rtc_enable_avx2 = false

View File

@ -1,24 +1,26 @@
From: Mike Hommey <mh+mozilla@glandium.org>
Date: Fri, 7 Jul 2023 00:58:00 +0000
Subject: Bug 1841577 - Don't set WEBRTC_ENABLE_AVX2 on platforms that don't
have AVX2. r=mjf,webrtc-reviewers
From: Byron Campen <docfaraday@gmail.com>
Date: Thu, 20 Jul 2023 14:24:00 +0000
Subject: Bug 1838080: Remove this duplicate init (that's also on the wrong
thread). r=pehrsons,webrtc-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D182695
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/46fb51c90709be64c35946a8cf69195121441024
This was causing assertions.
Differential Revision: https://phabricator.services.mozilla.com/D179731
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/6ac6592a04a839a6152d5ad5f0778f63dbbd6b1b
---
webrtc.gni | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
audio/channel_send.cc | 2 --
1 file changed, 2 deletions(-)
diff --git a/webrtc.gni b/webrtc.gni
index f55b88a061..167b4d7de0 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -317,7 +317,7 @@ declare_args() {
diff --git a/audio/channel_send.cc b/audio/channel_send.cc
index 70d3eaabbd..c3a3262a6b 100644
--- a/audio/channel_send.cc
+++ b/audio/channel_send.cc
@@ -543,8 +543,6 @@ ChannelSend::ChannelSend(
# Set this to true to enable the avx2 support in webrtc.
# TODO: Make sure that AVX2 works also for non-clang compilers.
- if (is_clang == true) {
+ if (is_clang == true && (target_cpu == "x86" || target_cpu == "x64")) {
rtc_enable_avx2 = true
} else {
rtc_enable_avx2 = false
int error = audio_coding_->RegisterTransportCallback(this);
RTC_DCHECK_EQ(0, error);
- if (frame_transformer)
- InitFrameTransformerDelegate(std::move(frame_transformer));
}
ChannelSend::~ChannelSend() {

View File

@ -1,26 +1,66 @@
From: Byron Campen <docfaraday@gmail.com>
Date: Thu, 20 Jul 2023 14:24:00 +0000
Subject: Bug 1838080: Remove this duplicate init (that's also on the wrong
thread). r=pehrsons,webrtc-reviewers
Subject: Bug 1838080: Use the current TaskQueue, instead of the current
thread, to init this. r=pehrsons,webrtc-reviewers
This was causing assertions.
There are situations where the current thread is not set, but the current
TaskQueue is (but not vice versa).
Differential Revision: https://phabricator.services.mozilla.com/D179731
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/6ac6592a04a839a6152d5ad5f0778f63dbbd6b1b
Differential Revision: https://phabricator.services.mozilla.com/D180736
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/62e71a2f745c4b98d5ee7ce9e6386aa1b657be9b
---
audio/channel_send.cc | 2 --
1 file changed, 2 deletions(-)
.../rtp_video_stream_receiver_frame_transformer_delegate.cc | 3 +--
.../rtp_video_stream_receiver_frame_transformer_delegate.h | 5 ++---
video/rtp_video_stream_receiver2.cc | 2 +-
3 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/audio/channel_send.cc b/audio/channel_send.cc
index 70d3eaabbd..c3a3262a6b 100644
--- a/audio/channel_send.cc
+++ b/audio/channel_send.cc
@@ -543,8 +543,6 @@ ChannelSend::ChannelSend(
diff --git a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
index 5ef0a80492..de74684a1f 100644
--- a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
+++ b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
@@ -96,8 +96,7 @@ RtpVideoStreamReceiverFrameTransformerDelegate::
RtpVideoFrameReceiver* receiver,
Clock* clock,
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
- rtc::Thread* network_thread,
- uint32_t ssrc)
+ TaskQueueBase* network_thread, uint32_t ssrc)
: receiver_(receiver),
frame_transformer_(std::move(frame_transformer)),
network_thread_(network_thread),
diff --git a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h
index f08fc692dd..02f2e53923 100644
--- a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h
+++ b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h
@@ -41,8 +41,7 @@ class RtpVideoStreamReceiverFrameTransformerDelegate
RtpVideoFrameReceiver* receiver,
Clock* clock,
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
- rtc::Thread* network_thread,
- uint32_t ssrc);
+ TaskQueueBase* network_thread, uint32_t ssrc);
int error = audio_coding_->RegisterTransportCallback(this);
RTC_DCHECK_EQ(0, error);
- if (frame_transformer)
- InitFrameTransformerDelegate(std::move(frame_transformer));
void Init();
void Reset();
@@ -71,7 +70,7 @@ class RtpVideoStreamReceiverFrameTransformerDelegate
RtpVideoFrameReceiver* receiver_ RTC_GUARDED_BY(network_sequence_checker_);
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer_
RTC_GUARDED_BY(network_sequence_checker_);
- rtc::Thread* const network_thread_;
+ TaskQueueBase* const network_thread_;
const uint32_t ssrc_;
Clock* const clock_;
bool short_circuit_ RTC_GUARDED_BY(network_sequence_checker_) = false;
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index 7df19cf29b..dcb192cdde 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -336,7 +336,7 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2(
frame_transformer_delegate_ =
rtc::make_ref_counted<RtpVideoStreamReceiverFrameTransformerDelegate>(
this, &env_.clock(), std::move(frame_transformer),
- rtc::Thread::Current(), config_.rtp.remote_ssrc);
+ TaskQueueBase::Current(), config_.rtp.remote_ssrc);
frame_transformer_delegate_->Init();
}
}
ChannelSend::~ChannelSend() {

View File

@ -1,66 +1,165 @@
From: Byron Campen <docfaraday@gmail.com>
Date: Thu, 20 Jul 2023 14:24:00 +0000
Subject: Bug 1838080: Use the current TaskQueue, instead of the current
thread, to init this. r=pehrsons,webrtc-reviewers
From: Michael Froman <mjfroman@mac.com>
Date: Thu, 27 Jul 2023 12:42:44 -0500
Subject: Bug 1838080: Store the rid in TransformableVideoSenderFrame.
r=ng,webrtc-reviewers
There are situations where the current thread is not set, but the current
TaskQueue is (but not vice versa).
This is necessary to reliably detect what rid a given keyframe is for, for the
purposes of resolving promises from RTCRtpScriptTransformer.generateKeyFrame.
Differential Revision: https://phabricator.services.mozilla.com/D180736
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/62e71a2f745c4b98d5ee7ce9e6386aa1b657be9b
Differential Revision: https://phabricator.services.mozilla.com/D180737
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2f1a0ba74bf71cfa0bc4e77714b8a5276a70cc36
---
.../rtp_video_stream_receiver_frame_transformer_delegate.cc | 3 +--
.../rtp_video_stream_receiver_frame_transformer_delegate.h | 5 ++---
video/rtp_video_stream_receiver2.cc | 2 +-
3 files changed, 4 insertions(+), 6 deletions(-)
api/frame_transformer_interface.h | 1 +
modules/rtp_rtcp/source/rtp_sender.h | 4 ++++
modules/rtp_rtcp/source/rtp_sender_video.cc | 1 +
...rtp_sender_video_frame_transformer_delegate.cc | 15 +++++++++++----
.../rtp_sender_video_frame_transformer_delegate.h | 2 ++
..._stream_receiver_frame_transformer_delegate.cc | 5 +++++
6 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
index 5ef0a80492..de74684a1f 100644
--- a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
+++ b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
@@ -96,8 +96,7 @@ RtpVideoStreamReceiverFrameTransformerDelegate::
RtpVideoFrameReceiver* receiver,
Clock* clock,
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
- rtc::Thread* network_thread,
- uint32_t ssrc)
+ TaskQueueBase* network_thread, uint32_t ssrc)
: receiver_(receiver),
diff --git a/api/frame_transformer_interface.h b/api/frame_transformer_interface.h
index 6959445285..47e2fddd3b 100644
--- a/api/frame_transformer_interface.h
+++ b/api/frame_transformer_interface.h
@@ -77,6 +77,7 @@ class TransformableVideoFrameInterface : public TransformableFrameInterface {
RTC_EXPORT explicit TransformableVideoFrameInterface(Passkey passkey);
virtual ~TransformableVideoFrameInterface() = default;
virtual bool IsKeyFrame() const = 0;
+ virtual const std::string& GetRid() const = 0;
virtual VideoFrameMetadata Metadata() const = 0;
diff --git a/modules/rtp_rtcp/source/rtp_sender.h b/modules/rtp_rtcp/source/rtp_sender.h
index 0a29968b0c..c23051401e 100644
--- a/modules/rtp_rtcp/source/rtp_sender.h
+++ b/modules/rtp_rtcp/source/rtp_sender.h
@@ -141,6 +141,10 @@ class RTPSender {
uint32_t SSRC() const RTC_LOCKS_EXCLUDED(send_mutex_) { return ssrc_; }
+ const std::string& Rid() const RTC_LOCKS_EXCLUDED(send_mutex_) {
+ return rid_;
+ }
+
std::optional<uint32_t> FlexfecSsrc() const RTC_LOCKS_EXCLUDED(send_mutex_) {
return flexfec_ssrc_;
}
diff --git a/modules/rtp_rtcp/source/rtp_sender_video.cc b/modules/rtp_rtcp/source/rtp_sender_video.cc
index 500cbb962d..bfa2888005 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video.cc
+++ b/modules/rtp_rtcp/source/rtp_sender_video.cc
@@ -183,6 +183,7 @@ RTPSenderVideo::RTPSenderVideo(const Config& config)
this,
config.frame_transformer,
rtp_sender_->SSRC(),
+ rtp_sender_->Rid(),
config.task_queue_factory)
: nullptr),
enable_av1_even_split_(
diff --git a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc
index b49468b8f9..04d34eda14 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc
+++ b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc
@@ -55,7 +55,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
uint32_t rtp_timestamp,
TimeDelta expected_retransmission_time,
uint32_t ssrc,
- std::vector<uint32_t> csrcs)
+ std::vector<uint32_t> csrcs,
+ const std::string& rid)
: TransformableVideoFrameInterface(Passkey()),
encoded_data_(encoded_image.GetEncodedData()),
pre_transform_payload_size_(encoded_image.size()),
@@ -68,7 +69,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
capture_time_identifier_(encoded_image.CaptureTimeIdentifier()),
expected_retransmission_time_(expected_retransmission_time),
ssrc_(ssrc),
- csrcs_(csrcs) {
+ csrcs_(csrcs),
+ rid_(rid) {
RTC_DCHECK_GE(payload_type_, 0);
RTC_DCHECK_LE(payload_type_, 127);
}
@@ -131,6 +133,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
return mime_type + CodecTypeToPayloadString(*codec_type_);
}
+ const std::string& GetRid() const override { return rid_; }
+
private:
rtc::scoped_refptr<EncodedImageBufferInterface> encoded_data_;
const size_t pre_transform_payload_size_;
@@ -145,16 +149,19 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
uint32_t ssrc_;
std::vector<uint32_t> csrcs_;
+ const std::string rid_;
};
RTPSenderVideoFrameTransformerDelegate::RTPSenderVideoFrameTransformerDelegate(
RTPVideoFrameSenderInterface* sender,
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
uint32_t ssrc,
+ const std::string& rid,
TaskQueueFactory* task_queue_factory)
: sender_(sender),
frame_transformer_(std::move(frame_transformer)),
network_thread_(network_thread),
diff --git a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h
index f08fc692dd..02f2e53923 100644
--- a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h
+++ b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h
@@ -41,8 +41,7 @@ class RtpVideoStreamReceiverFrameTransformerDelegate
RtpVideoFrameReceiver* receiver,
Clock* clock,
ssrc_(ssrc),
+ rid_(rid),
transformation_queue_(task_queue_factory->CreateTaskQueue(
"video_frame_transformer",
TaskQueueFactory::Priority::NORMAL)) {}
@@ -185,7 +192,7 @@ bool RTPSenderVideoFrameTransformerDelegate::TransformFrame(
frame_transformer_->Transform(std::make_unique<TransformableVideoSenderFrame>(
encoded_image, video_header, payload_type, codec_type, rtp_timestamp,
expected_retransmission_time, ssrc_,
- /*csrcs=*/std::vector<uint32_t>()));
+ /*csrcs=*/std::vector<uint32_t>(), rid_));
return true;
}
@@ -287,7 +294,7 @@ std::unique_ptr<TransformableVideoFrameInterface> CloneSenderVideoFrame(
return std::make_unique<TransformableVideoSenderFrame>(
encoded_image, new_header, original->GetPayloadType(), new_header.codec,
original->GetTimestamp(), kDefaultRetransmissionsTime,
- original->GetSsrc(), metadata.GetCsrcs());
+ original->GetSsrc(), metadata.GetCsrcs(), original->GetRid());
}
} // namespace webrtc
diff --git a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h
index 3580d84402..e4a75a9734 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h
+++ b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h
@@ -60,6 +60,7 @@ class RTPSenderVideoFrameTransformerDelegate : public TransformedFrameCallback {
RTPVideoFrameSenderInterface* sender,
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
- rtc::Thread* network_thread,
- uint32_t ssrc);
+ TaskQueueBase* network_thread, uint32_t ssrc);
uint32_t ssrc,
+ const std::string& rid,
TaskQueueFactory* send_transport_queue);
void Init();
void Reset();
@@ -71,7 +70,7 @@ class RtpVideoStreamReceiverFrameTransformerDelegate
RtpVideoFrameReceiver* receiver_ RTC_GUARDED_BY(network_sequence_checker_);
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer_
RTC_GUARDED_BY(network_sequence_checker_);
- rtc::Thread* const network_thread_;
+ TaskQueueBase* const network_thread_;
@@ -108,6 +109,7 @@ class RTPSenderVideoFrameTransformerDelegate : public TransformedFrameCallback {
RTPVideoFrameSenderInterface* sender_ RTC_GUARDED_BY(sender_lock_);
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer_;
const uint32_t ssrc_;
Clock* const clock_;
bool short_circuit_ RTC_GUARDED_BY(network_sequence_checker_) = false;
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index 7df19cf29b..dcb192cdde 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -336,7 +336,7 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2(
frame_transformer_delegate_ =
rtc::make_ref_counted<RtpVideoStreamReceiverFrameTransformerDelegate>(
this, &env_.clock(), std::move(frame_transformer),
- rtc::Thread::Current(), config_.rtp.remote_ssrc);
+ TaskQueueBase::Current(), config_.rtp.remote_ssrc);
frame_transformer_delegate_->Init();
+ const std::string rid_;
// Used when the encoded frames arrives without a current task queue. This can
// happen if a hardware encoder was used.
std::unique_ptr<TaskQueueBase, TaskQueueDeleter> transformation_queue_;
diff --git a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
index de74684a1f..7e0754284a 100644
--- a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
+++ b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
@@ -59,6 +59,11 @@ class TransformableVideoReceiverFrame
return frame_->FrameType() == VideoFrameType::kVideoFrameKey;
}
}
+ const std::string& GetRid() const override {
+ static const std::string empty;
+ return empty;
+ }
+
VideoFrameMetadata Metadata() const override { return metadata_; }
void SetMetadata(const VideoFrameMetadata& metadata) override {

View File

@ -1,165 +1,38 @@
From: Michael Froman <mjfroman@mac.com>
Date: Thu, 27 Jul 2023 12:42:44 -0500
Subject: Bug 1838080: Store the rid in TransformableVideoSenderFrame.
r=ng,webrtc-reviewers
From: Byron Campen <docfaraday@gmail.com>
Date: Thu, 20 Jul 2023 14:24:00 +0000
Subject: Bug 1838080: Ensure that last ref to transformation_queue_ is not
released on itself. r=pehrsons,webrtc-reviewers
This is necessary to reliably detect what rid a given keyframe is for, for the
purposes of resolving promises from RTCRtpScriptTransformer.generateKeyFrame.
Differential Revision: https://phabricator.services.mozilla.com/D180737
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2f1a0ba74bf71cfa0bc4e77714b8a5276a70cc36
Differential Revision: https://phabricator.services.mozilla.com/D181699
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/91d9e8b6a5c430a73561ffd2330865f04fcb1a6d
---
api/frame_transformer_interface.h | 1 +
modules/rtp_rtcp/source/rtp_sender.h | 4 ++++
modules/rtp_rtcp/source/rtp_sender_video.cc | 1 +
...rtp_sender_video_frame_transformer_delegate.cc | 15 +++++++++++----
.../rtp_sender_video_frame_transformer_delegate.h | 2 ++
..._stream_receiver_frame_transformer_delegate.cc | 5 +++++
6 files changed, 24 insertions(+), 4 deletions(-)
.../rtp_sender_video_frame_transformer_delegate.cc | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/api/frame_transformer_interface.h b/api/frame_transformer_interface.h
index 6959445285..47e2fddd3b 100644
--- a/api/frame_transformer_interface.h
+++ b/api/frame_transformer_interface.h
@@ -77,6 +77,7 @@ class TransformableVideoFrameInterface : public TransformableFrameInterface {
RTC_EXPORT explicit TransformableVideoFrameInterface(Passkey passkey);
virtual ~TransformableVideoFrameInterface() = default;
virtual bool IsKeyFrame() const = 0;
+ virtual const std::string& GetRid() const = 0;
virtual VideoFrameMetadata Metadata() const = 0;
diff --git a/modules/rtp_rtcp/source/rtp_sender.h b/modules/rtp_rtcp/source/rtp_sender.h
index 0a29968b0c..c23051401e 100644
--- a/modules/rtp_rtcp/source/rtp_sender.h
+++ b/modules/rtp_rtcp/source/rtp_sender.h
@@ -141,6 +141,10 @@ class RTPSender {
uint32_t SSRC() const RTC_LOCKS_EXCLUDED(send_mutex_) { return ssrc_; }
+ const std::string& Rid() const RTC_LOCKS_EXCLUDED(send_mutex_) {
+ return rid_;
+ }
+
std::optional<uint32_t> FlexfecSsrc() const RTC_LOCKS_EXCLUDED(send_mutex_) {
return flexfec_ssrc_;
}
diff --git a/modules/rtp_rtcp/source/rtp_sender_video.cc b/modules/rtp_rtcp/source/rtp_sender_video.cc
index 500cbb962d..bfa2888005 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video.cc
+++ b/modules/rtp_rtcp/source/rtp_sender_video.cc
@@ -183,6 +183,7 @@ RTPSenderVideo::RTPSenderVideo(const Config& config)
this,
config.frame_transformer,
rtp_sender_->SSRC(),
+ rtp_sender_->Rid(),
config.task_queue_factory)
: nullptr),
enable_av1_even_split_(
diff --git a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc
index b49468b8f9..04d34eda14 100644
index 04d34eda14..9d18d561d2 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc
+++ b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc
@@ -55,7 +55,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
uint32_t rtp_timestamp,
TimeDelta expected_retransmission_time,
uint32_t ssrc,
- std::vector<uint32_t> csrcs)
+ std::vector<uint32_t> csrcs,
+ const std::string& rid)
: TransformableVideoFrameInterface(Passkey()),
encoded_data_(encoded_image.GetEncodedData()),
pre_transform_payload_size_(encoded_image.size()),
@@ -68,7 +69,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
capture_time_identifier_(encoded_image.CaptureTimeIdentifier()),
expected_retransmission_time_(expected_retransmission_time),
ssrc_(ssrc),
- csrcs_(csrcs) {
+ csrcs_(csrcs),
+ rid_(rid) {
RTC_DCHECK_GE(payload_type_, 0);
RTC_DCHECK_LE(payload_type_, 127);
@@ -34,6 +34,7 @@
#include "api/video_codecs/video_codec.h"
#include "modules/rtp_rtcp/source/rtp_video_header.h"
#include "rtc_base/checks.h"
+#include "rtc_base/event.h"
#include "rtc_base/synchronization/mutex.h"
namespace webrtc {
@@ -274,6 +275,14 @@ void RTPSenderVideoFrameTransformerDelegate::Reset() {
MutexLock lock(&sender_lock_);
sender_ = nullptr;
}
@@ -131,6 +133,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
return mime_type + CodecTypeToPayloadString(*codec_type_);
}
+ const std::string& GetRid() const override { return rid_; }
+
private:
rtc::scoped_refptr<EncodedImageBufferInterface> encoded_data_;
const size_t pre_transform_payload_size_;
@@ -145,16 +149,19 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
uint32_t ssrc_;
std::vector<uint32_t> csrcs_;
+ const std::string rid_;
};
RTPSenderVideoFrameTransformerDelegate::RTPSenderVideoFrameTransformerDelegate(
RTPVideoFrameSenderInterface* sender,
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
uint32_t ssrc,
+ const std::string& rid,
TaskQueueFactory* task_queue_factory)
: sender_(sender),
frame_transformer_(std::move(frame_transformer)),
ssrc_(ssrc),
+ rid_(rid),
transformation_queue_(task_queue_factory->CreateTaskQueue(
"video_frame_transformer",
TaskQueueFactory::Priority::NORMAL)) {}
@@ -185,7 +192,7 @@ bool RTPSenderVideoFrameTransformerDelegate::TransformFrame(
frame_transformer_->Transform(std::make_unique<TransformableVideoSenderFrame>(
encoded_image, video_header, payload_type, codec_type, rtp_timestamp,
expected_retransmission_time, ssrc_,
- /*csrcs=*/std::vector<uint32_t>()));
+ /*csrcs=*/std::vector<uint32_t>(), rid_));
return true;
+ // Wait until all pending tasks are executed, to ensure that the last ref
+ // standing is not on the transformation queue.
+ rtc::Event flush;
+ transformation_queue_->PostTask([this, &flush]() {
+ RTC_DCHECK_RUN_ON(transformation_queue_.get());
+ flush.Set();
+ });
+ flush.Wait(rtc::Event::kForever);
}
@@ -287,7 +294,7 @@ std::unique_ptr<TransformableVideoFrameInterface> CloneSenderVideoFrame(
return std::make_unique<TransformableVideoSenderFrame>(
encoded_image, new_header, original->GetPayloadType(), new_header.codec,
original->GetTimestamp(), kDefaultRetransmissionsTime,
- original->GetSsrc(), metadata.GetCsrcs());
+ original->GetSsrc(), metadata.GetCsrcs(), original->GetRid());
}
} // namespace webrtc
diff --git a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h
index 3580d84402..e4a75a9734 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h
+++ b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h
@@ -60,6 +60,7 @@ class RTPSenderVideoFrameTransformerDelegate : public TransformedFrameCallback {
RTPVideoFrameSenderInterface* sender,
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
uint32_t ssrc,
+ const std::string& rid,
TaskQueueFactory* send_transport_queue);
void Init();
@@ -108,6 +109,7 @@ class RTPSenderVideoFrameTransformerDelegate : public TransformedFrameCallback {
RTPVideoFrameSenderInterface* sender_ RTC_GUARDED_BY(sender_lock_);
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer_;
const uint32_t ssrc_;
+ const std::string rid_;
// Used when the encoded frames arrives without a current task queue. This can
// happen if a hardware encoder was used.
std::unique_ptr<TaskQueueBase, TaskQueueDeleter> transformation_queue_;
diff --git a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
index de74684a1f..7e0754284a 100644
--- a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
+++ b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
@@ -59,6 +59,11 @@ class TransformableVideoReceiverFrame
return frame_->FrameType() == VideoFrameType::kVideoFrameKey;
}
+ const std::string& GetRid() const override {
+ static const std::string empty;
+ return empty;
+ }
+
VideoFrameMetadata Metadata() const override { return metadata_; }
void SetMetadata(const VideoFrameMetadata& metadata) override {
std::unique_ptr<TransformableVideoFrameInterface> CloneSenderVideoFrame(

View File

@ -1,38 +1,38 @@
From: Byron Campen <docfaraday@gmail.com>
Date: Thu, 20 Jul 2023 14:24:00 +0000
Subject: Bug 1838080: Ensure that last ref to transformation_queue_ is not
released on itself. r=pehrsons,webrtc-reviewers
From: stransky <stransky@redhat.com>
Date: Tue, 29 Aug 2023 12:43:00 +0000
Subject: Bug 1821629 [DMABuf] Don't use DMABuf if it's disabled by Firefox gfx
config r=ng,webrtc-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D181699
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/91d9e8b6a5c430a73561ffd2330865f04fcb1a6d
Differential Revision: https://phabricator.services.mozilla.com/D172224
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/158a888cad8869a2f0026fa7cfaaa13ecbfcf2ed
---
.../rtp_sender_video_frame_transformer_delegate.cc | 9 +++++++++
1 file changed, 9 insertions(+)
.../linux/wayland/shared_screencast_stream.cc | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc
index 04d34eda14..9d18d561d2 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc
+++ b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc
@@ -34,6 +34,7 @@
#include "api/video_codecs/video_codec.h"
#include "modules/rtp_rtcp/source/rtp_video_header.h"
#include "rtc_base/checks.h"
+#include "rtc_base/event.h"
diff --git a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
index 9aa50e19ee..09da88cad3 100644
--- a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
+++ b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
@@ -27,6 +27,13 @@
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/time_utils.h"
+// Wrapper for gfxVars::UseDMABuf() as we can't include gfxVars here.
+// We don't want to use dmabuf of known broken systems.
+// See FEATURE_DMABUF for details.
+namespace mozilla::gfx {
+bool IsDMABufEnabled();
+}
+
namespace webrtc {
@@ -274,6 +275,14 @@ void RTPSenderVideoFrameTransformerDelegate::Reset() {
MutexLock lock(&sender_lock_);
sender_ = nullptr;
}
+ // Wait until all pending tasks are executed, to ensure that the last ref
+ // standing is not on the transformation queue.
+ rtc::Event flush;
+ transformation_queue_->PostTask([this, &flush]() {
+ RTC_DCHECK_RUN_ON(transformation_queue_.get());
+ flush.Set();
+ });
+ flush.Wait(rtc::Event::kForever);
}
std::unique_ptr<TransformableVideoFrameInterface> CloneSenderVideoFrame(
const int kBytesPerPixel = 4;
@@ -268,7 +275,7 @@ void SharedScreenCastStreamPrivate::OnStreamParamChanged(
that->modifier_ =
has_modifier ? that->spa_video_format_.modifier : DRM_FORMAT_MOD_INVALID;
std::vector<const spa_pod*> params;
- const int buffer_types = has_modifier
+ const int buffer_types = has_modifier && mozilla::gfx::IsDMABufEnabled()
? (1 << SPA_DATA_DmaBuf) | (1 << SPA_DATA_MemFd)
: (1 << SPA_DATA_MemFd);

View File

@ -1,38 +1,47 @@
From: stransky <stransky@redhat.com>
Date: Tue, 29 Aug 2023 12:43:00 +0000
Subject: Bug 1821629 [DMABuf] Don't use DMABuf if it's disabled by Firefox gfx
config r=ng,webrtc-reviewers
Subject: Bug 1821629 [Pipewire/DMABuf] Don't create dmabuf backend if it's
disabled r=ng,webrtc-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D172224
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/158a888cad8869a2f0026fa7cfaaa13ecbfcf2ed
Depends on D172224
Differential Revision: https://phabricator.services.mozilla.com/D172229
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/237d19fe96dd7d25b6a817415ee4e6854678d648
---
.../linux/wayland/shared_screencast_stream.cc | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
.../linux/wayland/shared_screencast_stream.cc | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
index 9aa50e19ee..09da88cad3 100644
index 09da88cad3..f98253de2d 100644
--- a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
+++ b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
@@ -27,6 +27,13 @@
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/time_utils.h"
@@ -406,7 +406,9 @@ bool SharedScreenCastStreamPrivate::StartScreenCastStream(
RTC_LOG(LS_ERROR) << "Unable to open PipeWire library";
return false;
}
- egl_dmabuf_ = std::make_unique<EglDmaBuf>();
+ if (mozilla::gfx::IsDMABufEnabled()) {
+ egl_dmabuf_ = std::make_unique<EglDmaBuf>();
+ }
+// Wrapper for gfxVars::UseDMABuf() as we can't include gfxVars here.
+// We don't want to use dmabuf of known broken systems.
+// See FEATURE_DMABUF for details.
+namespace mozilla::gfx {
+bool IsDMABufEnabled();
+}
+
namespace webrtc {
pw_stream_node_id_ = stream_node_id;
const int kBytesPerPixel = 4;
@@ -268,7 +275,7 @@ void SharedScreenCastStreamPrivate::OnStreamParamChanged(
that->modifier_ =
has_modifier ? that->spa_video_format_.modifier : DRM_FORMAT_MOD_INVALID;
std::vector<const spa_pod*> params;
- const int buffer_types = has_modifier
+ const int buffer_types = has_modifier && mozilla::gfx::IsDMABufEnabled()
? (1 << SPA_DATA_DmaBuf) | (1 << SPA_DATA_MemFd)
: (1 << SPA_DATA_MemFd);
@@ -495,7 +497,8 @@ bool SharedScreenCastStreamPrivate::StartScreenCastStream(
for (uint32_t format : {SPA_VIDEO_FORMAT_BGRA, SPA_VIDEO_FORMAT_RGBA,
SPA_VIDEO_FORMAT_BGRx, SPA_VIDEO_FORMAT_RGBx}) {
// Modifiers can be used with PipeWire >= 0.3.33
- if (has_required_pw_client_version && has_required_pw_server_version) {
+ if (egl_dmabuf_ &&
+ has_required_pw_client_version && has_required_pw_server_version) {
modifiers_ = egl_dmabuf_->QueryDmaBufModifiers(format);
if (!modifiers_.empty()) {
@@ -938,7 +941,7 @@ bool SharedScreenCastStreamPrivate::ProcessDMABuffer(
const uint n_planes = spa_buffer->n_datas;
- if (!n_planes) {
+ if (!n_planes || !egl_dmabuf_) {
return false;
}

View File

@ -1,47 +1,56 @@
From: stransky <stransky@redhat.com>
Date: Tue, 29 Aug 2023 12:43:00 +0000
Subject: Bug 1821629 [Pipewire/DMABuf] Don't create dmabuf backend if it's
disabled r=ng,webrtc-reviewers
From: Michael Froman <mfroman@mozilla.com>
Date: Thu, 28 Sep 2023 14:12:00 +0000
Subject: Bug 1832465 - remove libXtst usage from libwebrtc.
r=ng,webrtc-reviewers
Depends on D172224
Differential Revision: https://phabricator.services.mozilla.com/D172229
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/237d19fe96dd7d25b6a817415ee4e6854678d648
Differential Revision: https://phabricator.services.mozilla.com/D189386
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0ec1b33b95dbb2d39355f28b2812fe25b4ad9f20
---
.../linux/wayland/shared_screencast_stream.cc | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
modules/desktop_capture/BUILD.gn | 3 +++
modules/desktop_capture/linux/x11/shared_x_display.cc | 4 ++++
2 files changed, 7 insertions(+)
diff --git a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
index 09da88cad3..f98253de2d 100644
--- a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
+++ b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
@@ -406,7 +406,9 @@ bool SharedScreenCastStreamPrivate::StartScreenCastStream(
RTC_LOG(LS_ERROR) << "Unable to open PipeWire library";
return false;
}
- egl_dmabuf_ = std::make_unique<EglDmaBuf>();
+ if (mozilla::gfx::IsDMABufEnabled()) {
+ egl_dmabuf_ = std::make_unique<EglDmaBuf>();
+ }
pw_stream_node_id_ = stream_node_id;
@@ -495,7 +497,8 @@ bool SharedScreenCastStreamPrivate::StartScreenCastStream(
for (uint32_t format : {SPA_VIDEO_FORMAT_BGRA, SPA_VIDEO_FORMAT_RGBA,
SPA_VIDEO_FORMAT_BGRx, SPA_VIDEO_FORMAT_RGBx}) {
// Modifiers can be used with PipeWire >= 0.3.33
- if (has_required_pw_client_version && has_required_pw_server_version) {
+ if (egl_dmabuf_ &&
+ has_required_pw_client_version && has_required_pw_server_version) {
modifiers_ = egl_dmabuf_->QueryDmaBufModifiers(format);
if (!modifiers_.empty()) {
@@ -938,7 +941,7 @@ bool SharedScreenCastStreamPrivate::ProcessDMABuffer(
const uint n_planes = spa_buffer->n_datas;
- if (!n_planes) {
+ if (!n_planes || !egl_dmabuf_) {
return false;
diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn
index 1047f30ee4..94741d8fc7 100644
--- a/modules/desktop_capture/BUILD.gn
+++ b/modules/desktop_capture/BUILD.gn
@@ -387,6 +387,9 @@ rtc_library("desktop_capture") {
"Xrandr",
"Xtst",
]
+ if (build_with_mozilla) {
+ libs -= [ "Xtst" ]
+ }
}
if (!is_win && !is_mac && !rtc_use_x11_extensions && !rtc_use_pipewire &&
diff --git a/modules/desktop_capture/linux/x11/shared_x_display.cc b/modules/desktop_capture/linux/x11/shared_x_display.cc
index d690b0e2ba..3f3617b074 100644
--- a/modules/desktop_capture/linux/x11/shared_x_display.cc
+++ b/modules/desktop_capture/linux/x11/shared_x_display.cc
@@ -11,7 +11,9 @@
#include "modules/desktop_capture/linux/x11/shared_x_display.h"
#include <X11/Xlib.h>
+#if !defined(WEBRTC_MOZILLA_BUILD)
#include <X11/extensions/XTest.h>
+#endif
#include <algorithm>
@@ -95,6 +97,7 @@ void SharedXDisplay::ProcessPendingXEvents() {
}
void SharedXDisplay::IgnoreXServerGrabs() {
+#if !defined(WEBRTC_MOZILLA_BUILD)
int test_event_base = 0;
int test_error_base = 0;
int major = 0;
@@ -103,6 +106,7 @@ void SharedXDisplay::IgnoreXServerGrabs() {
&minor)) {
XTestGrabControl(display(), true);
}
+#endif
}
} // namespace webrtc

View File

@ -1,56 +1,30 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Thu, 28 Sep 2023 14:12:00 +0000
Subject: Bug 1832465 - remove libXtst usage from libwebrtc.
Date: Thu, 5 Oct 2023 14:21:00 +0000
Subject: Bug 1857037 - pt1 - add shim gni files to limit BUILD.gn changes.
r=ng,webrtc-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D189386
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0ec1b33b95dbb2d39355f28b2812fe25b4ad9f20
Differential Revision: https://phabricator.services.mozilla.com/D190104
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a84d39db037cbe34aa19588b0d18335eb5e2d79b
---
modules/desktop_capture/BUILD.gn | 3 +++
modules/desktop_capture/linux/x11/shared_x_display.cc | 4 ++++
2 files changed, 7 insertions(+)
testing/libfuzzer/fuzzer_test.gni | 2 ++
testing/test.gni | 2 ++
2 files changed, 4 insertions(+)
create mode 100644 testing/libfuzzer/fuzzer_test.gni
create mode 100644 testing/test.gni
diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn
index 1047f30ee4..94741d8fc7 100644
--- a/modules/desktop_capture/BUILD.gn
+++ b/modules/desktop_capture/BUILD.gn
@@ -387,6 +387,9 @@ rtc_library("desktop_capture") {
"Xrandr",
"Xtst",
]
+ if (build_with_mozilla) {
+ libs -= [ "Xtst" ]
+ }
}
if (!is_win && !is_mac && !rtc_use_x11_extensions && !rtc_use_pipewire &&
diff --git a/modules/desktop_capture/linux/x11/shared_x_display.cc b/modules/desktop_capture/linux/x11/shared_x_display.cc
index d690b0e2ba..3f3617b074 100644
--- a/modules/desktop_capture/linux/x11/shared_x_display.cc
+++ b/modules/desktop_capture/linux/x11/shared_x_display.cc
@@ -11,7 +11,9 @@
#include "modules/desktop_capture/linux/x11/shared_x_display.h"
#include <X11/Xlib.h>
+#if !defined(WEBRTC_MOZILLA_BUILD)
#include <X11/extensions/XTest.h>
+#endif
#include <algorithm>
@@ -95,6 +97,7 @@ void SharedXDisplay::ProcessPendingXEvents() {
}
void SharedXDisplay::IgnoreXServerGrabs() {
+#if !defined(WEBRTC_MOZILLA_BUILD)
int test_event_base = 0;
int test_error_base = 0;
int major = 0;
@@ -103,6 +106,7 @@ void SharedXDisplay::IgnoreXServerGrabs() {
&minor)) {
XTestGrabControl(display(), true);
}
+#endif
}
} // namespace webrtc
diff --git a/testing/libfuzzer/fuzzer_test.gni b/testing/libfuzzer/fuzzer_test.gni
new file mode 100644
index 0000000000..8fdf3cdad2
--- /dev/null
+++ b/testing/libfuzzer/fuzzer_test.gni
@@ -0,0 +1,2 @@
+# "empty" file in place of importing new testing/libfuzzer
+# to allow BUILD.gn imports to succeed.
diff --git a/testing/test.gni b/testing/test.gni
new file mode 100644
index 0000000000..f46fa82778
--- /dev/null
+++ b/testing/test.gni
@@ -0,0 +1,2 @@
+# "empty" file in place of importing new testing/test.gni
+# to allow BUILD.gn imports to succeed.

View File

@ -1,30 +1,40 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Thu, 5 Oct 2023 14:21:00 +0000
Subject: Bug 1857037 - pt1 - add shim gni files to limit BUILD.gn changes.
r=ng,webrtc-reviewers
Date: Tue, 14 Feb 2023 03:27:00 +0000
Subject: Bug 1816173 - pt12 - add shim config for
third_party/libwebrtc/testing/{gmock|gtest} r=ng
Differential Revision: https://phabricator.services.mozilla.com/D190104
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a84d39db037cbe34aa19588b0d18335eb5e2d79b
We don't vendor third_party/libwebrtc/third_party/gmock
third_party/libwebrtc/third_party/gtest, so:
- add BUILD.gn to avoid scattered BUILD.gn changes
Differential Revision: https://phabricator.services.mozilla.com/D169674
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/4ea9d2db79c42a144235e45c47c71adf1dd01fdc
---
testing/libfuzzer/fuzzer_test.gni | 2 ++
testing/test.gni | 2 ++
2 files changed, 4 insertions(+)
create mode 100644 testing/libfuzzer/fuzzer_test.gni
create mode 100644 testing/test.gni
testing/gmock/BUILD.gn | 5 +++++
testing/gtest/BUILD.gn | 5 +++++
2 files changed, 10 insertions(+)
create mode 100644 testing/gmock/BUILD.gn
create mode 100644 testing/gtest/BUILD.gn
diff --git a/testing/libfuzzer/fuzzer_test.gni b/testing/libfuzzer/fuzzer_test.gni
diff --git a/testing/gmock/BUILD.gn b/testing/gmock/BUILD.gn
new file mode 100644
index 0000000000..8fdf3cdad2
index 0000000000..a2a1efdea9
--- /dev/null
+++ b/testing/libfuzzer/fuzzer_test.gni
@@ -0,0 +1,2 @@
+# "empty" file in place of importing new testing/libfuzzer
+# to allow BUILD.gn imports to succeed.
diff --git a/testing/test.gni b/testing/test.gni
+++ b/testing/gmock/BUILD.gn
@@ -0,0 +1,5 @@
+import("//third_party/libaom/options.gni")
+import("../../webrtc.gni")
+
+rtc_library("gmock") {
+}
diff --git a/testing/gtest/BUILD.gn b/testing/gtest/BUILD.gn
new file mode 100644
index 0000000000..f46fa82778
index 0000000000..c9c2703c37
--- /dev/null
+++ b/testing/test.gni
@@ -0,0 +1,2 @@
+# "empty" file in place of importing new testing/test.gni
+# to allow BUILD.gn imports to succeed.
+++ b/testing/gtest/BUILD.gn
@@ -0,0 +1,5 @@
+import("//third_party/libaom/options.gni")
+import("../../webrtc.gni")
+
+rtc_library("gtest") {
+}

View File

@ -1,40 +1,28 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Tue, 14 Feb 2023 03:27:00 +0000
Subject: Bug 1816173 - pt12 - add shim config for
third_party/libwebrtc/testing/{gmock|gtest} r=ng
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Wed, 18 Oct 2023 17:25:00 +0000
Subject: Bug 1857862 - (fix-32a8169a65) Don't call non-constexpr
RTC_CHECK_NOTREACHED from constexpr VideoFrameTypeToString under gcc-8.
r=webrtc-reviewers,mjf
We don't vendor third_party/libwebrtc/third_party/gmock
third_party/libwebrtc/third_party/gtest, so:
- add BUILD.gn to avoid scattered BUILD.gn changes
Differential Revision: https://phabricator.services.mozilla.com/D169674
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/4ea9d2db79c42a144235e45c47c71adf1dd01fdc
Differential Revision: https://phabricator.services.mozilla.com/D191308
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8a4449ba24fa3192b44863ed8ba96f6f94a6e88d
---
testing/gmock/BUILD.gn | 5 +++++
testing/gtest/BUILD.gn | 5 +++++
2 files changed, 10 insertions(+)
create mode 100644 testing/gmock/BUILD.gn
create mode 100644 testing/gtest/BUILD.gn
api/video/video_frame_type.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/testing/gmock/BUILD.gn b/testing/gmock/BUILD.gn
new file mode 100644
index 0000000000..a2a1efdea9
--- /dev/null
+++ b/testing/gmock/BUILD.gn
@@ -0,0 +1,5 @@
+import("//third_party/libaom/options.gni")
+import("../../webrtc.gni")
+
+rtc_library("gmock") {
+}
diff --git a/testing/gtest/BUILD.gn b/testing/gtest/BUILD.gn
new file mode 100644
index 0000000000..c9c2703c37
--- /dev/null
+++ b/testing/gtest/BUILD.gn
@@ -0,0 +1,5 @@
+import("//third_party/libaom/options.gni")
+import("../../webrtc.gni")
+
+rtc_library("gtest") {
+}
diff --git a/api/video/video_frame_type.h b/api/video/video_frame_type.h
index 9079829ff8..3665a80cd8 100644
--- a/api/video/video_frame_type.h
+++ b/api/video/video_frame_type.h
@@ -34,7 +34,11 @@ inline constexpr absl::string_view VideoFrameTypeToString(
case VideoFrameType::kVideoFrameDelta:
return "delta";
}
+// Mozilla:
+// gcc-8 complains about a constexpr function calling a non-constexpr ditto.
+#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 9)
RTC_CHECK_NOTREACHED();
+#endif
return "";
}

View File

@ -1,28 +1,41 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Wed, 18 Oct 2023 17:25:00 +0000
Subject: Bug 1857862 - (fix-32a8169a65) Don't call non-constexpr
RTC_CHECK_NOTREACHED from constexpr VideoFrameTypeToString under gcc-8.
r=webrtc-reviewers,mjf
Date: Wed, 18 Oct 2023 17:21:00 +0000
Subject: Bug 1859786 - Fix lock annotation warning in Mozilla-specific edit on
top of video_capture_impl.cc. r=webrtc-reviewers,mjf
Differential Revision: https://phabricator.services.mozilla.com/D191308
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8a4449ba24fa3192b44863ed8ba96f6f94a6e88d
The annotations were added in M116:
https://hg.mozilla.org/mozilla-central/rev/9cd372df013948ad822ae936752d725d77474fb5
Note that this was never unsafe, since _dataCallbacks is only written on the
same thread that we are patching here. This patch however, adds helpful static
analysis.
Differential Revision: https://phabricator.services.mozilla.com/D191301
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/56ff441b644400f09d2d0453dbd8991ea25db7b1
---
api/video/video_frame_type.h | 4 ++++
1 file changed, 4 insertions(+)
modules/video_capture/video_capture_impl.cc | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/api/video/video_frame_type.h b/api/video/video_frame_type.h
index 9079829ff8..3665a80cd8 100644
--- a/api/video/video_frame_type.h
+++ b/api/video/video_frame_type.h
@@ -34,7 +34,11 @@ inline constexpr absl::string_view VideoFrameTypeToString(
case VideoFrameType::kVideoFrameDelta:
return "delta";
}
+// Mozilla:
+// gcc-8 complains about a constexpr function calling a non-constexpr ditto.
+#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 9)
RTC_CHECK_NOTREACHED();
+#endif
return "";
diff --git a/modules/video_capture/video_capture_impl.cc b/modules/video_capture/video_capture_impl.cc
index 1a12020b64..dad8bee1f8 100644
--- a/modules/video_capture/video_capture_impl.cc
+++ b/modules/video_capture/video_capture_impl.cc
@@ -119,11 +119,14 @@ void VideoCaptureImpl::DeRegisterCaptureDataCallback(
}
int32_t VideoCaptureImpl::StopCaptureIfAllClientsClose() {
- if (_dataCallBacks.empty()) {
- return StopCapture();
- } else {
- return 0;
+ RTC_DCHECK_RUN_ON(&api_checker_);
+ {
+ MutexLock lock(&api_lock_);
+ if (!_dataCallBacks.empty()) {
+ return 0;
+ }
}
+ return StopCapture();
}
int32_t VideoCaptureImpl::DeliverCapturedFrame(VideoFrame& captureFrame) {

View File

@ -1,41 +1,27 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Wed, 18 Oct 2023 17:21:00 +0000
Subject: Bug 1859786 - Fix lock annotation warning in Mozilla-specific edit on
top of video_capture_impl.cc. r=webrtc-reviewers,mjf
Subject: Bug 1859786 - Fix clang-tidy warning in video_capture_impl.cc.
r=webrtc-reviewers,mjf
The annotations were added in M116:
https://hg.mozilla.org/mozilla-central/rev/9cd372df013948ad822ae936752d725d77474fb5
clang-tidy says:
'auto dataCallBack' can be declared as 'auto *dataCallBack'
Note that this was never unsafe, since _dataCallbacks is only written on the
same thread that we are patching here. This patch however, adds helpful static
analysis.
Differential Revision: https://phabricator.services.mozilla.com/D191301
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/56ff441b644400f09d2d0453dbd8991ea25db7b1
Differential Revision: https://phabricator.services.mozilla.com/D191302
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/26c84d214137a1b0de0902c7038756964e5786f4
---
modules/video_capture/video_capture_impl.cc | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
modules/video_capture/video_capture_impl.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/video_capture/video_capture_impl.cc b/modules/video_capture/video_capture_impl.cc
index 1a12020b64..dad8bee1f8 100644
index dad8bee1f8..46fff89a52 100644
--- a/modules/video_capture/video_capture_impl.cc
+++ b/modules/video_capture/video_capture_impl.cc
@@ -119,11 +119,14 @@ void VideoCaptureImpl::DeRegisterCaptureDataCallback(
}
@@ -134,7 +134,7 @@ int32_t VideoCaptureImpl::DeliverCapturedFrame(VideoFrame& captureFrame) {
int32_t VideoCaptureImpl::StopCaptureIfAllClientsClose() {
- if (_dataCallBacks.empty()) {
- return StopCapture();
- } else {
- return 0;
+ RTC_DCHECK_RUN_ON(&api_checker_);
+ {
+ MutexLock lock(&api_lock_);
+ if (!_dataCallBacks.empty()) {
+ return 0;
+ }
UpdateFrameCount(); // frame count used for local frame rate callback.
- for (auto dataCallBack : _dataCallBacks) {
+ for (auto* dataCallBack : _dataCallBacks) {
dataCallBack->OnFrame(captureFrame);
}
+ return StopCapture();
}
int32_t VideoCaptureImpl::DeliverCapturedFrame(VideoFrame& captureFrame) {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,20 +1,64 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Wed, 7 Dec 2022 17:09:00 +0000
Subject: Bug 1744645 - pt1 - add a couple empty gni files to help with
BUILD.gn corrections. r=ng
From: Nico Grunbaum <na-g@nostrum.com>
Date: Wed, 15 Nov 2023 22:33:00 +0000
Subject: Bug 1863041 - P0 - add device filter control to
RTCCameraVideoCapturer;r=pehrsons,webrtc-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D163991
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/81d86382ee468f3b36deed00d0c9d59eb85524be
I have filed this bug upstream: https://bugs.chromium.org/p/webrtc/issues/detail?id=15639
Differential Revision: https://phabricator.services.mozilla.com/D193172
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/91a763d768b74acc9cf4828f91a86df4a7b092ce
---
tools/generate_stubs/rules.gni | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 tools/generate_stubs/rules.gni
.../capturer/RTCCameraVideoCapturer.h | 5 ++++-
.../capturer/RTCCameraVideoCapturer.m | 17 +++++++++++++++--
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/tools/generate_stubs/rules.gni b/tools/generate_stubs/rules.gni
new file mode 100644
index 0000000000..1d9f36eb72
--- /dev/null
+++ b/tools/generate_stubs/rules.gni
@@ -0,0 +1,2 @@
+# "empty" file in place of importing new tools/generate_stubs
+# to allow BUILD.gn imports to succeed.
diff --git a/sdk/objc/components/capturer/RTCCameraVideoCapturer.h b/sdk/objc/components/capturer/RTCCameraVideoCapturer.h
index 9874121238..39619b2fc3 100644
--- a/sdk/objc/components/capturer/RTCCameraVideoCapturer.h
+++ b/sdk/objc/components/capturer/RTCCameraVideoCapturer.h
@@ -26,7 +26,10 @@ RTC_OBJC_EXPORT
@property(readonly, nonatomic) AVCaptureSession *captureSession;
// Returns list of available capture devices that support video capture.
-+ (NSArray<AVCaptureDevice *> *)captureDevices;
++ (NSArray<AVCaptureDevice *> *)captureDevicesWithDeviceTypes:
+ (NSArray<AVCaptureDeviceType> *)deviceTypes;
+// Returns list of default capture devices types
++ (NSArray<AVCaptureDeviceType> *)defaultCaptureDeviceTypes;
// Returns list of formats that are supported by this class for this device.
+ (NSArray<AVCaptureDeviceFormat *> *)supportedFormatsForDevice:(AVCaptureDevice *)device;
diff --git a/sdk/objc/components/capturer/RTCCameraVideoCapturer.m b/sdk/objc/components/capturer/RTCCameraVideoCapturer.m
index d25f5e20ae..4f92f56807 100644
--- a/sdk/objc/components/capturer/RTCCameraVideoCapturer.m
+++ b/sdk/objc/components/capturer/RTCCameraVideoCapturer.m
@@ -118,14 +118,27 @@ const int64_t kNanosecondsPerSecond = 1000000000;
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
-+ (NSArray<AVCaptureDevice *> *)captureDevices {
++ (NSArray<AVCaptureDevice *> *)captureDevicesWithDeviceTypes:
+ (NSArray<AVCaptureDeviceType> *)deviceTypes {
AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession
- discoverySessionWithDeviceTypes:@[ AVCaptureDeviceTypeBuiltInWideAngleCamera ]
+ discoverySessionWithDeviceTypes:deviceTypes
mediaType:AVMediaTypeVideo
position:AVCaptureDevicePositionUnspecified];
return session.devices;
}
++ (NSArray<AVCaptureDeviceType> *)defaultCaptureDeviceTypes {
+ NSArray *types = @[ AVCaptureDeviceTypeBuiltInWideAngleCamera ];
+#if !defined(WEBRTC_IOS)
+ if (@available(macOS 14.0, *)) {
+ types = [types arrayByAddingObject:AVCaptureDeviceTypeExternal];
+ } else {
+ types = [types arrayByAddingObject:AVCaptureDeviceTypeExternalUnknown];
+ }
+#endif
+ return types;
+}
+
+ (NSArray<AVCaptureDeviceFormat *> *)supportedFormatsForDevice:(AVCaptureDevice *)device {
// Support opening the device in any format. We make sure it's converted to a format we
// can handle, if needed, in the method `-setupVideoDataOutput`.

View File

@ -1,64 +1,36 @@
From: Nico Grunbaum <na-g@nostrum.com>
Date: Wed, 15 Nov 2023 22:33:00 +0000
Subject: Bug 1863041 - P0 - add device filter control to
RTCCameraVideoCapturer;r=pehrsons,webrtc-reviewers
From: Michael Froman <mfroman@mozilla.com>
Date: Mon, 4 Dec 2023 12:57:00 -0600
Subject: Bug 1867099 - (fix-66b7275561) disable wgc capture yellow-line
removal. r?ng!
I have filed this bug upstream: https://bugs.chromium.org/p/webrtc/issues/detail?id=15639
Differential Revision: https://phabricator.services.mozilla.com/D193172
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/91a763d768b74acc9cf4828f91a86df4a7b092ce
This code won't build until we support building with
Win 10 SDK v10.0.20348.0 or newer.
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0aac94794aad2ddb637f5076bc08706a11866737
---
.../capturer/RTCCameraVideoCapturer.h | 5 ++++-
.../capturer/RTCCameraVideoCapturer.m | 17 +++++++++++++++--
2 files changed, 19 insertions(+), 3 deletions(-)
modules/desktop_capture/win/wgc_capture_session.cc | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/sdk/objc/components/capturer/RTCCameraVideoCapturer.h b/sdk/objc/components/capturer/RTCCameraVideoCapturer.h
index 9874121238..39619b2fc3 100644
--- a/sdk/objc/components/capturer/RTCCameraVideoCapturer.h
+++ b/sdk/objc/components/capturer/RTCCameraVideoCapturer.h
@@ -26,7 +26,10 @@ RTC_OBJC_EXPORT
@property(readonly, nonatomic) AVCaptureSession *captureSession;
diff --git a/modules/desktop_capture/win/wgc_capture_session.cc b/modules/desktop_capture/win/wgc_capture_session.cc
index 1c86f8ed1b..f9429134dc 100644
--- a/modules/desktop_capture/win/wgc_capture_session.cc
+++ b/modules/desktop_capture/win/wgc_capture_session.cc
@@ -188,6 +188,11 @@ HRESULT WgcCaptureSession::StartCapture(const DesktopCaptureOptions& options) {
}
}
// Returns list of available capture devices that support video capture.
-+ (NSArray<AVCaptureDevice *> *)captureDevices;
++ (NSArray<AVCaptureDevice *> *)captureDevicesWithDeviceTypes:
+ (NSArray<AVCaptureDeviceType> *)deviceTypes;
+// Returns list of default capture devices types
++ (NSArray<AVCaptureDeviceType> *)defaultCaptureDeviceTypes;
// Returns list of formats that are supported by this class for this device.
+ (NSArray<AVCaptureDeviceFormat *> *)supportedFormatsForDevice:(AVCaptureDevice *)device;
diff --git a/sdk/objc/components/capturer/RTCCameraVideoCapturer.m b/sdk/objc/components/capturer/RTCCameraVideoCapturer.m
index d25f5e20ae..4f92f56807 100644
--- a/sdk/objc/components/capturer/RTCCameraVideoCapturer.m
+++ b/sdk/objc/components/capturer/RTCCameraVideoCapturer.m
@@ -118,14 +118,27 @@ const int64_t kNanosecondsPerSecond = 1000000000;
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
-+ (NSArray<AVCaptureDevice *> *)captureDevices {
++ (NSArray<AVCaptureDevice *> *)captureDevicesWithDeviceTypes:
+ (NSArray<AVCaptureDeviceType> *)deviceTypes {
AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession
- discoverySessionWithDeviceTypes:@[ AVCaptureDeviceTypeBuiltInWideAngleCamera ]
+ discoverySessionWithDeviceTypes:deviceTypes
mediaType:AVMediaTypeVideo
position:AVCaptureDevicePositionUnspecified];
return session.devices;
}
++ (NSArray<AVCaptureDeviceType> *)defaultCaptureDeviceTypes {
+ NSArray *types = @[ AVCaptureDeviceTypeBuiltInWideAngleCamera ];
+#if !defined(WEBRTC_IOS)
+ if (@available(macOS 14.0, *)) {
+ types = [types arrayByAddingObject:AVCaptureDeviceTypeExternal];
+ } else {
+ types = [types arrayByAddingObject:AVCaptureDeviceTypeExternalUnknown];
+ }
+// Until Mozilla builds with Win 10 SDK v10.0.20348.0 or newer, this
+// code will not build. Once we support the newer SDK, Bug 1868198
+// exists to decide if we ever want to use this code since it is
+// removing an indicator that capture is happening.
+#if !defined(WEBRTC_MOZILLA_BUILD)
// By default, the WGC capture API adds a yellow border around the captured
// window or display to indicate that a capture is in progress. The section
// below is an attempt to remove this yellow border to make the capture
@@ -199,6 +204,7 @@ HRESULT WgcCaptureSession::StartCapture(const DesktopCaptureOptions& options) {
&session3))) {
session3->put_IsBorderRequired(false);
}
+#endif
+ return types;
+}
+
+ (NSArray<AVCaptureDeviceFormat *> *)supportedFormatsForDevice:(AVCaptureDevice *)device {
// Support opening the device in any format. We make sure it's converted to a format we
// can handle, if needed, in the method `-setupVideoDataOutput`.
allow_zero_hertz_ = options.allow_wgc_zero_hertz();

View File

@ -1,36 +1,121 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Mon, 4 Dec 2023 12:57:00 -0600
Subject: Bug 1867099 - (fix-66b7275561) disable wgc capture yellow-line
removal. r?ng!
From: Jan Grulich <jgrulich@redhat.com>
Date: Thu, 30 Nov 2023 11:49:00 +0000
Subject: Bug 1844020 - Add option to DeviceInfo::GetDeviceName() identifying a
placeholder device r=pehrsons,webrtc-reviewers
This code won't build until we support building with
Win 10 SDK v10.0.20348.0 or newer.
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0aac94794aad2ddb637f5076bc08706a11866737
Adds a new parameter "deviceIsPlaceholder" that will be set to true in
case the returned device is not a real device but a placeholder that is
just used to inform about camera device existence.
Differential Revision: https://phabricator.services.mozilla.com/D189929
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/ed31b2acb5fbca3e2d0691a64bc52e65952070c0
---
modules/desktop_capture/win/wgc_capture_session.cc | 6 ++++++
1 file changed, 6 insertions(+)
modules/video_capture/linux/device_info_pipewire.cc | 4 +++-
modules/video_capture/linux/device_info_pipewire.h | 3 ++-
modules/video_capture/linux/device_info_v4l2.cc | 3 ++-
modules/video_capture/linux/device_info_v4l2.h | 3 ++-
modules/video_capture/video_capture.h | 3 ++-
modules/video_capture/windows/device_info_ds.cc | 3 ++-
modules/video_capture/windows/device_info_ds.h | 3 ++-
7 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/modules/desktop_capture/win/wgc_capture_session.cc b/modules/desktop_capture/win/wgc_capture_session.cc
index 1c86f8ed1b..f9429134dc 100644
--- a/modules/desktop_capture/win/wgc_capture_session.cc
+++ b/modules/desktop_capture/win/wgc_capture_session.cc
@@ -188,6 +188,11 @@ HRESULT WgcCaptureSession::StartCapture(const DesktopCaptureOptions& options) {
}
}
diff --git a/modules/video_capture/linux/device_info_pipewire.cc b/modules/video_capture/linux/device_info_pipewire.cc
index b802fe580c..db2a3c7099 100644
--- a/modules/video_capture/linux/device_info_pipewire.cc
+++ b/modules/video_capture/linux/device_info_pipewire.cc
@@ -50,8 +50,10 @@ int32_t DeviceInfoPipeWire::GetDeviceName(uint32_t deviceNumber,
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8,
uint32_t productUniqueIdUTF8Length,
- pid_t* pid) {
+ pid_t* pid,
+ bool* deviceIsPlaceholder) {
RTC_CHECK(pipewire_session_);
+
if (deviceNumber >= NumberOfDevices())
return -1;
+// Until Mozilla builds with Win 10 SDK v10.0.20348.0 or newer, this
+// code will not build. Once we support the newer SDK, Bug 1868198
+// exists to decide if we ever want to use this code since it is
+// removing an indicator that capture is happening.
+#if !defined(WEBRTC_MOZILLA_BUILD)
// By default, the WGC capture API adds a yellow border around the captured
// window or display to indicate that a capture is in progress. The section
// below is an attempt to remove this yellow border to make the capture
@@ -199,6 +204,7 @@ HRESULT WgcCaptureSession::StartCapture(const DesktopCaptureOptions& options) {
&session3))) {
session3->put_IsBorderRequired(false);
}
+#endif
diff --git a/modules/video_capture/linux/device_info_pipewire.h b/modules/video_capture/linux/device_info_pipewire.h
index 8a33d75892..00715c94bc 100644
--- a/modules/video_capture/linux/device_info_pipewire.h
+++ b/modules/video_capture/linux/device_info_pipewire.h
@@ -30,7 +30,8 @@ class DeviceInfoPipeWire : public DeviceInfoImpl {
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8 = nullptr,
uint32_t productUniqueIdUTF8Length = 0,
- pid_t* pid = 0) override;
+ pid_t* pid = 0,
+ bool* deviceIsPlaceholder = 0) override;
/*
* Fills the membervariable _captureCapabilities with capabilites for the
* given device name.
diff --git a/modules/video_capture/linux/device_info_v4l2.cc b/modules/video_capture/linux/device_info_v4l2.cc
index 04caaea592..401c38f9c5 100644
--- a/modules/video_capture/linux/device_info_v4l2.cc
+++ b/modules/video_capture/linux/device_info_v4l2.cc
@@ -232,7 +232,8 @@ int32_t DeviceInfoV4l2::GetDeviceName(uint32_t deviceNumber,
uint32_t deviceUniqueIdUTF8Length,
char* /*productUniqueIdUTF8*/,
uint32_t /*productUniqueIdUTF8Length*/,
- pid_t* /*pid*/) {
+ pid_t* /*pid*/,
+ bool* /*deviceIsPlaceholder*/) {
// Travel through /dev/video [0-63]
uint32_t count = 0;
char device[20];
diff --git a/modules/video_capture/linux/device_info_v4l2.h b/modules/video_capture/linux/device_info_v4l2.h
index 0bec3eb765..55415845ad 100644
--- a/modules/video_capture/linux/device_info_v4l2.h
+++ b/modules/video_capture/linux/device_info_v4l2.h
@@ -36,7 +36,8 @@ class DeviceInfoV4l2 : public DeviceInfoImpl {
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8 = 0,
uint32_t productUniqueIdUTF8Length = 0,
- pid_t* pid=0) override;
+ pid_t* pid = 0,
+ bool* deviceIsPlaceholder = 0) override;
/*
* Fills the membervariable _captureCapabilities with capabilites for the
* given device name.
diff --git a/modules/video_capture/video_capture.h b/modules/video_capture/video_capture.h
index 43a6a7f832..f59c34f8b2 100644
--- a/modules/video_capture/video_capture.h
+++ b/modules/video_capture/video_capture.h
@@ -74,7 +74,8 @@ class VideoCaptureModule : public RefCountInterface {
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8 = 0,
uint32_t productUniqueIdUTF8Length = 0,
- pid_t* pid = 0) = 0;
+ pid_t* pid = 0,
+ bool* deviceIsPlaceholder = 0) = 0;
allow_zero_hertz_ = options.allow_wgc_zero_hertz();
// Returns the number of capabilities this device.
virtual int32_t NumberOfCapabilities(const char* deviceUniqueIdUTF8) = 0;
diff --git a/modules/video_capture/windows/device_info_ds.cc b/modules/video_capture/windows/device_info_ds.cc
index f6927281f3..8ca741239c 100644
--- a/modules/video_capture/windows/device_info_ds.cc
+++ b/modules/video_capture/windows/device_info_ds.cc
@@ -173,7 +173,8 @@ int32_t DeviceInfoDS::GetDeviceName(uint32_t deviceNumber,
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8,
uint32_t productUniqueIdUTF8Length,
- pid_t* pid) {
+ pid_t* pid,
+ bool* deviceIsPlaceholder) {
MutexLock lock(&_apiLock);
const int32_t result = GetDeviceInfo(
deviceNumber, deviceNameUTF8, deviceNameLength, deviceUniqueIdUTF8,
diff --git a/modules/video_capture/windows/device_info_ds.h b/modules/video_capture/windows/device_info_ds.h
index e6dfaed366..a9a1449b99 100644
--- a/modules/video_capture/windows/device_info_ds.h
+++ b/modules/video_capture/windows/device_info_ds.h
@@ -51,7 +51,8 @@ class DeviceInfoDS : public DeviceInfoImpl {
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8,
uint32_t productUniqueIdUTF8Length,
- pid_t* pid) override;
+ pid_t* pid,
+ bool* deviceIsPlaceholder) override;
/*
* Display OS /capture device specific settings dialog

View File

@ -1,121 +1,107 @@
From: Jan Grulich <jgrulich@redhat.com>
Date: Thu, 30 Nov 2023 11:49:00 +0000
Subject: Bug 1844020 - Add option to DeviceInfo::GetDeviceName() identifying a
placeholder device r=pehrsons,webrtc-reviewers
From: Michael Froman <mfroman@mozilla.com>
Date: Mon, 18 Dec 2023 15:00:00 +0000
Subject: Bug 1867099 - revert libwebrtc 8602f604e0. r=bwc
Adds a new parameter "deviceIsPlaceholder" that will be set to true in
case the returned device is not a real device but a placeholder that is
just used to inform about camera device existence.
Upstream 8602f604e0 removed code sending BYEs which breaks some of
our wpt. They've opened a bug for a real fix here:
https://bugs.chromium.org/p/webrtc/issues/detail?id=15664
Differential Revision: https://phabricator.services.mozilla.com/D189929
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/ed31b2acb5fbca3e2d0691a64bc52e65952070c0
I've opened Bug 1870643 to track the real fix and upstream bug.
Differential Revision: https://phabricator.services.mozilla.com/D196729
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/d92a578327f524ec3e1c144c82492a4c76b8266f
---
modules/video_capture/linux/device_info_pipewire.cc | 4 +++-
modules/video_capture/linux/device_info_pipewire.h | 3 ++-
modules/video_capture/linux/device_info_v4l2.cc | 3 ++-
modules/video_capture/linux/device_info_v4l2.h | 3 ++-
modules/video_capture/video_capture.h | 3 ++-
modules/video_capture/windows/device_info_ds.cc | 3 ++-
modules/video_capture/windows/device_info_ds.h | 3 ++-
7 files changed, 15 insertions(+), 7 deletions(-)
call/rtp_video_sender.cc | 1 +
modules/rtp_rtcp/source/rtcp_sender.cc | 19 +++++++++++++++++--
.../rtp_rtcp/source/rtcp_sender_unittest.cc | 5 +++--
modules/rtp_rtcp/source/rtp_rtcp_impl.cc | 1 +
modules/rtp_rtcp/source/rtp_rtcp_interface.h | 2 +-
5 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/modules/video_capture/linux/device_info_pipewire.cc b/modules/video_capture/linux/device_info_pipewire.cc
index b802fe580c..db2a3c7099 100644
--- a/modules/video_capture/linux/device_info_pipewire.cc
+++ b/modules/video_capture/linux/device_info_pipewire.cc
@@ -50,8 +50,10 @@ int32_t DeviceInfoPipeWire::GetDeviceName(uint32_t deviceNumber,
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8,
uint32_t productUniqueIdUTF8Length,
- pid_t* pid) {
+ pid_t* pid,
+ bool* deviceIsPlaceholder) {
RTC_CHECK(pipewire_session_);
diff --git a/call/rtp_video_sender.cc b/call/rtp_video_sender.cc
index be56eac626..6fcc4e3b0d 100644
--- a/call/rtp_video_sender.cc
+++ b/call/rtp_video_sender.cc
@@ -533,6 +533,7 @@ void RtpVideoSender::SetModuleIsActive(bool sending,
return;
}
+ // Sends a kRtcpByeCode when going from true to false.
rtp_module.SetSendingStatus(sending);
rtp_module.SetSendingMediaStatus(sending);
if (sending) {
diff --git a/modules/rtp_rtcp/source/rtcp_sender.cc b/modules/rtp_rtcp/source/rtcp_sender.cc
index 051d77c4f7..b545633f25 100644
--- a/modules/rtp_rtcp/source/rtcp_sender.cc
+++ b/modules/rtp_rtcp/source/rtcp_sender.cc
@@ -223,8 +223,23 @@ bool RTCPSender::Sending() const {
void RTCPSender::SetSendingStatus(const FeedbackState& feedback_state,
bool sending) {
- MutexLock lock(&mutex_rtcp_sender_);
- sending_ = sending;
+ bool sendRTCPBye = false;
+ {
+ MutexLock lock(&mutex_rtcp_sender_);
+
if (deviceNumber >= NumberOfDevices())
return -1;
+ if (method_ != RtcpMode::kOff) {
+ if (sending == false && sending_ == true) {
+ // Trigger RTCP bye
+ sendRTCPBye = true;
+ }
+ }
+ sending_ = sending;
+ }
+ if (sendRTCPBye) {
+ if (SendRTCP(feedback_state, kRtcpBye) != 0) {
+ RTC_LOG(LS_WARNING) << "Failed to send RTCP BYE";
+ }
+ }
}
diff --git a/modules/video_capture/linux/device_info_pipewire.h b/modules/video_capture/linux/device_info_pipewire.h
index 8a33d75892..00715c94bc 100644
--- a/modules/video_capture/linux/device_info_pipewire.h
+++ b/modules/video_capture/linux/device_info_pipewire.h
@@ -30,7 +30,8 @@ class DeviceInfoPipeWire : public DeviceInfoImpl {
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8 = nullptr,
uint32_t productUniqueIdUTF8Length = 0,
- pid_t* pid = 0) override;
+ pid_t* pid = 0,
+ bool* deviceIsPlaceholder = 0) override;
/*
* Fills the membervariable _captureCapabilities with capabilites for the
* given device name.
diff --git a/modules/video_capture/linux/device_info_v4l2.cc b/modules/video_capture/linux/device_info_v4l2.cc
index 04caaea592..401c38f9c5 100644
--- a/modules/video_capture/linux/device_info_v4l2.cc
+++ b/modules/video_capture/linux/device_info_v4l2.cc
@@ -232,7 +232,8 @@ int32_t DeviceInfoV4l2::GetDeviceName(uint32_t deviceNumber,
uint32_t deviceUniqueIdUTF8Length,
char* /*productUniqueIdUTF8*/,
uint32_t /*productUniqueIdUTF8Length*/,
- pid_t* /*pid*/) {
+ pid_t* /*pid*/,
+ bool* /*deviceIsPlaceholder*/) {
// Travel through /dev/video [0-63]
uint32_t count = 0;
char device[20];
diff --git a/modules/video_capture/linux/device_info_v4l2.h b/modules/video_capture/linux/device_info_v4l2.h
index 0bec3eb765..55415845ad 100644
--- a/modules/video_capture/linux/device_info_v4l2.h
+++ b/modules/video_capture/linux/device_info_v4l2.h
@@ -36,7 +36,8 @@ class DeviceInfoV4l2 : public DeviceInfoImpl {
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8 = 0,
uint32_t productUniqueIdUTF8Length = 0,
- pid_t* pid=0) override;
+ pid_t* pid = 0,
+ bool* deviceIsPlaceholder = 0) override;
/*
* Fills the membervariable _captureCapabilities with capabilites for the
* given device name.
diff --git a/modules/video_capture/video_capture.h b/modules/video_capture/video_capture.h
index 43a6a7f832..f59c34f8b2 100644
--- a/modules/video_capture/video_capture.h
+++ b/modules/video_capture/video_capture.h
@@ -74,7 +74,8 @@ class VideoCaptureModule : public RefCountInterface {
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8 = 0,
uint32_t productUniqueIdUTF8Length = 0,
- pid_t* pid = 0) = 0;
+ pid_t* pid = 0,
+ bool* deviceIsPlaceholder = 0) = 0;
void RTCPSender::SetNonSenderRttMeasurement(bool enabled) {
diff --git a/modules/rtp_rtcp/source/rtcp_sender_unittest.cc b/modules/rtp_rtcp/source/rtcp_sender_unittest.cc
index 3a77df5e3e..deda5f71c8 100644
--- a/modules/rtp_rtcp/source/rtcp_sender_unittest.cc
+++ b/modules/rtp_rtcp/source/rtcp_sender_unittest.cc
@@ -347,12 +347,13 @@ TEST_F(RtcpSenderTest, SendBye) {
EXPECT_EQ(kSenderSsrc, parser()->bye()->sender_ssrc());
}
// Returns the number of capabilities this device.
virtual int32_t NumberOfCapabilities(const char* deviceUniqueIdUTF8) = 0;
diff --git a/modules/video_capture/windows/device_info_ds.cc b/modules/video_capture/windows/device_info_ds.cc
index f6927281f3..8ca741239c 100644
--- a/modules/video_capture/windows/device_info_ds.cc
+++ b/modules/video_capture/windows/device_info_ds.cc
@@ -173,7 +173,8 @@ int32_t DeviceInfoDS::GetDeviceName(uint32_t deviceNumber,
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8,
uint32_t productUniqueIdUTF8Length,
- pid_t* pid) {
+ pid_t* pid,
+ bool* deviceIsPlaceholder) {
MutexLock lock(&_apiLock);
const int32_t result = GetDeviceInfo(
deviceNumber, deviceNameUTF8, deviceNameLength, deviceUniqueIdUTF8,
diff --git a/modules/video_capture/windows/device_info_ds.h b/modules/video_capture/windows/device_info_ds.h
index e6dfaed366..a9a1449b99 100644
--- a/modules/video_capture/windows/device_info_ds.h
+++ b/modules/video_capture/windows/device_info_ds.h
@@ -51,7 +51,8 @@ class DeviceInfoDS : public DeviceInfoImpl {
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8,
uint32_t productUniqueIdUTF8Length,
- pid_t* pid) override;
+ pid_t* pid,
+ bool* deviceIsPlaceholder) override;
-TEST_F(RtcpSenderTest, StopSendingDoesNotTriggersBye) {
+TEST_F(RtcpSenderTest, StopSendingTriggersBye) {
auto rtcp_sender = CreateRtcpSender(GetDefaultConfig());
rtcp_sender->SetRTCPStatus(RtcpMode::kReducedSize);
rtcp_sender->SetSendingStatus(feedback_state(), true);
rtcp_sender->SetSendingStatus(feedback_state(), false);
- EXPECT_EQ(0, parser()->bye()->num_packets());
+ EXPECT_EQ(1, parser()->bye()->num_packets());
+ EXPECT_EQ(kSenderSsrc, parser()->bye()->sender_ssrc());
}
TEST_F(RtcpSenderTest, SendFir) {
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
index 284fb65109..41c500ba6f 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
@@ -312,6 +312,7 @@ RTCPSender::FeedbackState ModuleRtpRtcpImpl::GetFeedbackState() {
int32_t ModuleRtpRtcpImpl::SetSendingStatus(const bool sending) {
if (rtcp_sender_.Sending() != sending) {
+ // Sends RTCP BYE when going from true to false
rtcp_sender_.SetSendingStatus(GetFeedbackState(), sending);
}
return 0;
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_interface.h b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
index 44fad3889a..e312dbe9a5 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_interface.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
@@ -274,7 +274,7 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface {
// Returns the FlexFEC SSRC, if there is one.
virtual std::optional<uint32_t> FlexfecSsrc() const = 0;
- // Sets sending status.
+ // Sets sending status. Sends kRtcpByeCode when going from true to false.
// Returns -1 on failure else 0.
virtual int32_t SetSendingStatus(bool sending) = 0;
/*
* Display OS /capture device specific settings dialog

View File

@ -1,107 +1,33 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Mon, 18 Dec 2023 15:00:00 +0000
Subject: Bug 1867099 - revert libwebrtc 8602f604e0. r=bwc
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Fri, 2 Feb 2024 18:43:00 +0000
Subject: Bug 1878010 - Fix webrtc::VideoCaptureFactory for BSD.
r=grulja,gaston,webrtc-reviewers,mjf
Upstream 8602f604e0 removed code sending BYEs which breaks some of
our wpt. They've opened a bug for a real fix here:
https://bugs.chromium.org/p/webrtc/issues/detail?id=15664
I've opened Bug 1870643 to track the real fix and upstream bug.
Differential Revision: https://phabricator.services.mozilla.com/D196729
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/d92a578327f524ec3e1c144c82492a4c76b8266f
Differential Revision: https://phabricator.services.mozilla.com/D200427
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/f890637efe5abc0020fab83ff2224313cd0c8460
---
call/rtp_video_sender.cc | 1 +
modules/rtp_rtcp/source/rtcp_sender.cc | 19 +++++++++++++++++--
.../rtp_rtcp/source/rtcp_sender_unittest.cc | 5 +++--
modules/rtp_rtcp/source/rtp_rtcp_impl.cc | 1 +
modules/rtp_rtcp/source/rtp_rtcp_interface.h | 2 +-
5 files changed, 23 insertions(+), 5 deletions(-)
modules/video_capture/video_capture_factory.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/call/rtp_video_sender.cc b/call/rtp_video_sender.cc
index be56eac626..6fcc4e3b0d 100644
--- a/call/rtp_video_sender.cc
+++ b/call/rtp_video_sender.cc
@@ -533,6 +533,7 @@ void RtpVideoSender::SetModuleIsActive(bool sending,
return;
}
+ // Sends a kRtcpByeCode when going from true to false.
rtp_module.SetSendingStatus(sending);
rtp_module.SetSendingMediaStatus(sending);
if (sending) {
diff --git a/modules/rtp_rtcp/source/rtcp_sender.cc b/modules/rtp_rtcp/source/rtcp_sender.cc
index 051d77c4f7..b545633f25 100644
--- a/modules/rtp_rtcp/source/rtcp_sender.cc
+++ b/modules/rtp_rtcp/source/rtcp_sender.cc
@@ -223,8 +223,23 @@ bool RTCPSender::Sending() const {
void RTCPSender::SetSendingStatus(const FeedbackState& feedback_state,
bool sending) {
- MutexLock lock(&mutex_rtcp_sender_);
- sending_ = sending;
+ bool sendRTCPBye = false;
+ {
+ MutexLock lock(&mutex_rtcp_sender_);
+
+ if (method_ != RtcpMode::kOff) {
+ if (sending == false && sending_ == true) {
+ // Trigger RTCP bye
+ sendRTCPBye = true;
+ }
+ }
+ sending_ = sending;
+ }
+ if (sendRTCPBye) {
+ if (SendRTCP(feedback_state, kRtcpBye) != 0) {
+ RTC_LOG(LS_WARNING) << "Failed to send RTCP BYE";
+ }
+ }
}
void RTCPSender::SetNonSenderRttMeasurement(bool enabled) {
diff --git a/modules/rtp_rtcp/source/rtcp_sender_unittest.cc b/modules/rtp_rtcp/source/rtcp_sender_unittest.cc
index 3a77df5e3e..deda5f71c8 100644
--- a/modules/rtp_rtcp/source/rtcp_sender_unittest.cc
+++ b/modules/rtp_rtcp/source/rtcp_sender_unittest.cc
@@ -347,12 +347,13 @@ TEST_F(RtcpSenderTest, SendBye) {
EXPECT_EQ(kSenderSsrc, parser()->bye()->sender_ssrc());
}
-TEST_F(RtcpSenderTest, StopSendingDoesNotTriggersBye) {
+TEST_F(RtcpSenderTest, StopSendingTriggersBye) {
auto rtcp_sender = CreateRtcpSender(GetDefaultConfig());
rtcp_sender->SetRTCPStatus(RtcpMode::kReducedSize);
rtcp_sender->SetSendingStatus(feedback_state(), true);
rtcp_sender->SetSendingStatus(feedback_state(), false);
- EXPECT_EQ(0, parser()->bye()->num_packets());
+ EXPECT_EQ(1, parser()->bye()->num_packets());
+ EXPECT_EQ(kSenderSsrc, parser()->bye()->sender_ssrc());
}
TEST_F(RtcpSenderTest, SendFir) {
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
index 284fb65109..41c500ba6f 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
@@ -312,6 +312,7 @@ RTCPSender::FeedbackState ModuleRtpRtcpImpl::GetFeedbackState() {
int32_t ModuleRtpRtcpImpl::SetSendingStatus(const bool sending) {
if (rtcp_sender_.Sending() != sending) {
+ // Sends RTCP BYE when going from true to false
rtcp_sender_.SetSendingStatus(GetFeedbackState(), sending);
}
return 0;
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_interface.h b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
index 44fad3889a..e312dbe9a5 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_interface.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
@@ -274,7 +274,7 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface {
// Returns the FlexFEC SSRC, if there is one.
virtual std::optional<uint32_t> FlexfecSsrc() const = 0;
- // Sets sending status.
+ // Sets sending status. Sends kRtcpByeCode when going from true to false.
// Returns -1 on failure else 0.
virtual int32_t SetSendingStatus(bool sending) = 0;
diff --git a/modules/video_capture/video_capture_factory.cc b/modules/video_capture/video_capture_factory.cc
index e085ac2df8..2790fbbe1c 100644
--- a/modules/video_capture/video_capture_factory.cc
+++ b/modules/video_capture/video_capture_factory.cc
@@ -24,7 +24,7 @@ rtc::scoped_refptr<VideoCaptureModule> VideoCaptureFactory::Create(
const char* deviceUniqueIdUTF8) {
// This is only implemented on pure Linux and WEBRTC_LINUX is defined for
// Android as well
-#if !defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID)
+#if (!defined(WEBRTC_LINUX) && !defined(WEBRTC_BSD)) || defined(WEBRTC_ANDROID)
return nullptr;
#else
return videocapturemodule::VideoCaptureImpl::Create(options,
@@ -40,7 +40,7 @@ VideoCaptureModule::DeviceInfo* VideoCaptureFactory::CreateDeviceInfo(
VideoCaptureOptions* options) {
// This is only implemented on pure Linux and WEBRTC_LINUX is defined for
// Android as well
-#if !defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID)
+#if (!defined(WEBRTC_LINUX) && !defined(WEBRTC_BSD)) || defined(WEBRTC_ANDROID)
return nullptr;
#else
return videocapturemodule::VideoCaptureImpl::CreateDeviceInfo(options);

View File

@ -1,33 +1,74 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Fri, 2 Feb 2024 18:43:00 +0000
Subject: Bug 1878010 - Fix webrtc::VideoCaptureFactory for BSD.
r=grulja,gaston,webrtc-reviewers,mjf
From: Dan Baker <dbaker@mozilla.com>
Date: Thu, 14 Mar 2024 10:51:00 -0600
Subject: Bug 1883116 - (fix-e79e722834) add enviroment_factory to libwebrtc
build and enforce providing clock and task_queue when creating Environment
Differential Revision: https://phabricator.services.mozilla.com/D200427
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/f890637efe5abc0020fab83ff2224313cd0c8460
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2185cab977988fd4ab03b38dc67f9b06162444da
---
modules/video_capture/video_capture_factory.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
BUILD.gn | 1 +
api/environment/environment_factory.cc | 10 ++++++++++
api/task_queue/BUILD.gn | 5 +++++
3 files changed, 16 insertions(+)
diff --git a/modules/video_capture/video_capture_factory.cc b/modules/video_capture/video_capture_factory.cc
index e085ac2df8..2790fbbe1c 100644
--- a/modules/video_capture/video_capture_factory.cc
+++ b/modules/video_capture/video_capture_factory.cc
@@ -24,7 +24,7 @@ rtc::scoped_refptr<VideoCaptureModule> VideoCaptureFactory::Create(
const char* deviceUniqueIdUTF8) {
// This is only implemented on pure Linux and WEBRTC_LINUX is defined for
// Android as well
-#if !defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID)
+#if (!defined(WEBRTC_LINUX) && !defined(WEBRTC_BSD)) || defined(WEBRTC_ANDROID)
return nullptr;
#else
return videocapturemodule::VideoCaptureImpl::Create(options,
@@ -40,7 +40,7 @@ VideoCaptureModule::DeviceInfo* VideoCaptureFactory::CreateDeviceInfo(
VideoCaptureOptions* options) {
// This is only implemented on pure Linux and WEBRTC_LINUX is defined for
// Android as well
-#if !defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID)
+#if (!defined(WEBRTC_LINUX) && !defined(WEBRTC_BSD)) || defined(WEBRTC_ANDROID)
return nullptr;
#else
return videocapturemodule::VideoCaptureImpl::CreateDeviceInfo(options);
diff --git a/BUILD.gn b/BUILD.gn
index 946de50dc2..4a965e69d5 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -613,6 +613,7 @@ if (!build_with_chromium) {
if (build_with_mozilla) {
deps += [
+ "api/environment:environment_factory",
"api/video:video_frame",
"api/video:video_rtp_headers",
"test:rtp_test_utils",
diff --git a/api/environment/environment_factory.cc b/api/environment/environment_factory.cc
index 293ef6cf8a..b9cb6b4f53 100644
--- a/api/environment/environment_factory.cc
+++ b/api/environment/environment_factory.cc
@@ -102,12 +102,22 @@ Environment EnvironmentFactory::CreateWithDefaults() && {
if (field_trials_ == nullptr) {
Set(std::make_unique<FieldTrialBasedConfig>());
}
+#if defined(WEBRTC_MOZILLA_BUILD)
+ // We want to use our clock, not GetRealTimeClockRaw, and we avoid
+ // building the code under third_party/libwebrtc/task_queue. To
+ // ensure we're setting up things correctly, namely providing an
+ // Environment object with a preset task_queue_factory and clock,
+ // we'll do a release assert here.
+ RTC_CHECK(clock_);
+ RTC_CHECK(task_queue_factory_);
+#else
if (clock_ == nullptr) {
Set(Clock::GetRealTimeClock());
}
if (task_queue_factory_ == nullptr) {
Set(CreateDefaultTaskQueueFactory(field_trials_));
}
+#endif
if (event_log_ == nullptr) {
Set(std::make_unique<RtcEventLogNull>());
}
diff --git a/api/task_queue/BUILD.gn b/api/task_queue/BUILD.gn
index bacc3ca87a..5c3dd242b6 100644
--- a/api/task_queue/BUILD.gn
+++ b/api/task_queue/BUILD.gn
@@ -83,6 +83,10 @@ rtc_library("task_queue_test") {
}
rtc_library("default_task_queue_factory") {
+# Mozilla - disable this entire target to avoid inclusion of code we want
+# to avoid. Better here than trying to wack-a-mole for places that list
+# it as a dependency.
+if (!build_with_mozilla) {
visibility = [ "*" ]
if (!is_ios && !is_android) {
# Internally webrtc shouldn't rely on any specific TaskQueue implementation
@@ -121,6 +125,7 @@ rtc_library("default_task_queue_factory") {
sources += [ "default_task_queue_factory_stdlib.cc" ]
deps += [ "../../rtc_base:rtc_task_queue_stdlib" ]
}
+} # of if (!build_with_mozilla) {
}
rtc_library("pending_task_safety_flag") {

Some files were not shown because too many files have changed in this diff Show More