Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,26 @@ void RealtimeMediaSource::videoFrameAvailable(VideoFrame& videoFrame, VideoFrame
updateHasStartedProducingData();

Locker locker { m_videoFrameObserversLock };
if (m_videoFrameObservers.isEmpty()) {
if (m_pendingVideoFrames.size() < maxPendingVideoFramesBeforeAddTrack) {
m_pendingVideoFrames.append(PendingVideoFrame { &videoFrame, metadata });
}
else {
WTFLogAlways("RealtimeMediaSource: Dropping video frame (queue is full) %zu frames", m_pendingVideoFrames.size());
}
return;
}
if (!m_pendingVideoFrames.isEmpty()) {
WTFLogAlways("RealtimeMediaSource: Delivering %zu queued frame(s) (pipeline ready)", m_pendingVideoFrames.size());
for (auto& pending : m_pendingVideoFrames) {
if (pending.frame) {
for (auto* obs : m_videoFrameObservers)
obs->videoFrameAvailable(*pending.frame, pending.metadata);
}
}
m_pendingVideoFrames.clear();
}

for (auto& [key, value] : m_videoFrameObservers) {
if (auto* adaptor = value.get()) {
if (adaptor->frameDecimation > 1 && ++adaptor->frameDecimationCounter % adaptor->frameDecimation)
Expand Down
7 changes: 7 additions & 0 deletions Source/WebCore/platform/mediastream/RealtimeMediaSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,13 @@ class WEBCORE_EXPORT RealtimeMediaSource
mutable Lock m_videoFrameObserversLock;
HashMap<VideoFrameObserver*, std::unique_ptr<VideoFrameAdaptor>> m_videoFrameObservers WTF_GUARDED_BY_LOCK(m_videoFrameObserversLock);

struct PendingVideoFrame {
RefPtr<VideoFrame> frame;
VideoFrameTimeMetadata metadata;
};
static constexpr size_t maxPendingVideoFramesBeforeAddTrack = 30;
Vector<PendingVideoFrame> m_pendingVideoFrames WTF_GUARDED_BY_LOCK(m_videoFrameObserversLock);

CaptureDevice m_device;

// Set on the main thread from constraints.
Expand Down