chromium/third_party/blink/renderer/modules/peerconnection/rtp_contributing_source_cache.h

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_PEERCONNECTION_RTP_CONTRIBUTING_SOURCE_CACHE_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_PEERCONNECTION_RTP_CONTRIBUTING_SOURCE_CACHE_H_

#include <utility>

#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/single_thread_task_runner.h"
#include "third_party/blink/public/platform/web_vector.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_rtc_rtp_contributing_source.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_rtc_rtp_synchronization_source.h"
#include "third_party/blink/renderer/modules/peerconnection/rtc_rtp_receiver.h"
#include "third_party/blink/renderer/platform/heap/collection_support/heap_vector.h"
#include "third_party/blink/renderer/platform/heap/persistent.h"
#include "third_party/blink/renderer/platform/peerconnection/rtc_rtp_source.h"
#include "third_party/blink/renderer/platform/wtf/hash_map.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"

namespace blink {

class RTCPeerConnection;
class ScriptState;

// Implements RTCRtpReceiver.getSynchronizationSources/getContributingSources as
// well as a cache of the result. The cache serves two purposes:
// 1. According to spec, calling the getters multiple times inside the same task
//    execution cycle must return the same values. The cache is cleared in the
//    next microtask.
// 2. Getting the SSRC/CSRC values involves a block-invoke to the WebRTC worker
//    thread. This class uses a heuristic to maybe-update the cache for all
//    RTCRtpReceiver objects inside the same block-invoke, reducing the total
//    number of block-invokes if the getters are called on every RTCRtpReceiver.
class RtpContributingSourceCache {};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_MODULES_PEERCONNECTION_RTP_CONTRIBUTING_SOURCE_CACHE_H_