Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(654)

Unified Diff: third_party/WebKit/Source/modules/peerconnection/RTCRtpReceiver.cpp

Issue 2803693002: RTCRtpReceiver.getContributingSources() added. (Closed)
Patch Set: Rebase with dependent CL, timestamp in ms, not s Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/peerconnection/RTCRtpReceiver.cpp
diff --git a/third_party/WebKit/Source/modules/peerconnection/RTCRtpReceiver.cpp b/third_party/WebKit/Source/modules/peerconnection/RTCRtpReceiver.cpp
index e929cb6b097b02b5cd35cc05d06d702514c9511e..edf164f4c9c2b7553fa247282204b121e267b139 100644
--- a/third_party/WebKit/Source/modules/peerconnection/RTCRtpReceiver.cpp
+++ b/third_party/WebKit/Source/modules/peerconnection/RTCRtpReceiver.cpp
@@ -4,6 +4,8 @@
#include "modules/peerconnection/RTCRtpReceiver.h"
+#include "bindings/core/v8/Microtask.h"
+#include "public/platform/WebRTCRtpContributingSource.h"
#include "wtf/text/WTFString.h"
namespace blink {
@@ -20,8 +22,57 @@ MediaStreamTrack* RTCRtpReceiver::track() const {
return m_track;
}
+HeapVector<Member<RTCRtpContributingSource>>
+RTCRtpReceiver::getContributingSources() {
+ updateSourcesIfNeeded();
+ return m_contributingSources;
+}
+
+void RTCRtpReceiver::updateSourcesIfNeeded() {
+ if (m_contributingSourcesNeedsUpdating) {
foolip 2017/04/06 10:07:23 if (!m_contributingSourcesNeedsUpdating) return.
hbos_chromium 2017/04/06 11:10:15 Done.
+ m_contributingSources.clear();
+ for (const auto& webContributingSource : m_receiver->getSources()) {
foolip 2017/04/06 10:07:23 Can you spell out the type here, unless it's some
hbos_chromium 2017/04/06 11:10:15 Done.
+ if (webContributingSource->sourceType() ==
+ WebRTCRtpContributingSourceType::SSRC) {
+ // TODO(hbos): When |getSynchronizationSources| is added to get SSRC
+ // sources don't ignore SSRCs here.
+ continue;
+ }
+ DCHECK_EQ(webContributingSource->sourceType(),
+ WebRTCRtpContributingSourceType::CSRC);
+ auto it =
+ m_contributingSourcesBySourceId.find(webContributingSource->source());
+ if (it == m_contributingSourcesBySourceId.end()) {
+ RTCRtpContributingSource* contributingSource =
+ new RTCRtpContributingSource(this, *webContributingSource);
+ m_contributingSourcesBySourceId.insert(contributingSource->source(),
+ contributingSource);
+ m_contributingSources.push_back(contributingSource);
+ } else {
+ *it->value = *webContributingSource;
+ m_contributingSources.push_back(it->value);
+ }
+ }
+ // Clear the flag and schedule a microtask to reset it to true. This makes
+ // the cache valid until the next iteration of the event loop. As such,
foolip 2017/04/06 10:07:23 s/iteration of the event loop/microtask checkpoint
hbos_chromium 2017/04/06 11:10:15 Done. The spec says objects are to be updated whe
Taylor_Brandstetter 2017/04/06 20:34:41 The webrtc editors ended up filing this exact bug
foolip 2017/04/07 06:49:51 OK. The situation is very similar to media element
Taylor_Brandstetter 2017/04/07 17:07:46 As far as I know, this is all the related state. F
foolip 2017/04/10 07:42:33 Great, thanks!
+ // sources represent a snapshot and can be compared reliably in .js code,
+ // no risk of being updated due to an RTP packet arriving. E.g.
+ // "source.timestamp == source.timestamp" will always be true.
+ m_contributingSourcesNeedsUpdating = false;
+ Microtask::enqueueMicrotask(
+ WTF::bind(&RTCRtpReceiver::setContributingSourcesNeedsUpdating,
+ wrapWeakPersistent(this)));
+ }
+}
+
+void RTCRtpReceiver::setContributingSourcesNeedsUpdating() {
+ m_contributingSourcesNeedsUpdating = true;
+}
+
DEFINE_TRACE(RTCRtpReceiver) {
visitor->trace(m_track);
+ visitor->trace(m_contributingSourcesBySourceId);
+ visitor->trace(m_contributingSources);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698