chromium/third_party/blink/renderer/platform/peerconnection/rtc_encoded_video_stream_transformer.cc

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

#include "third_party/blink/renderer/platform/peerconnection/rtc_encoded_video_stream_transformer.h"

#include <inttypes.h>

#include <utility>

#include "base/memory/ptr_util.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/lock.h"
#include "base/task/single_thread_task_runner.h"
#include "third_party/blink/public/platform/modules/webrtc/webrtc_logging.h"
#include "third_party/blink/renderer/platform/heap/persistent.h"
#include "third_party/blink/renderer/platform/peerconnection/rtc_scoped_refptr_cross_thread_copier.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_copier_base.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_copier_std.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/webrtc/api/frame_transformer_interface.h"
#include "third_party/webrtc/rtc_base/ref_counted_object.h"

namespace blink {

namespace {

Metronome;

// Safety limit of number of frames buffered while waiting to shortcircuit/set a
// transform, to protect from eg apps requiring encoded transforms (via setting
// encodedInsertableStreams) and never calling createEncodedStreams(), which
// would otherwise buffer frames forever. Worst case 2 seconds (assuming <=
// 60fps) should be a reasonable upperbound to JS contention slowing down
// shortcircuiting/setting transforms.
const size_t kMaxBufferedFrames =;

// This delegate class exists to work around the fact that
// RTCEncodedVideoStreamTransformer cannot derive from rtc::RefCountedObject
// and post tasks referencing itself as an rtc::scoped_refptr. Instead,
// RTCEncodedVideoStreamTransformer creates a delegate using
// rtc::RefCountedObject and posts tasks referencing the delegate, which
// invokes the RTCEncodedVideoStreamTransformer via callbacks.
class RTCEncodedVideoStreamTransformerDelegate
    : public webrtc::FrameTransformerInterface {};

}  // namespace

RTCEncodedVideoStreamTransformer::Broker::Broker(
    RTCEncodedVideoStreamTransformer* transformer_)
    :{}

void RTCEncodedVideoStreamTransformer::Broker::
    RegisterTransformedFrameSinkCallback(
        rtc::scoped_refptr<webrtc::TransformedFrameCallback>
            send_frame_to_sink_callback,
        uint32_t ssrc) {}

void RTCEncodedVideoStreamTransformer::Broker::
    UnregisterTransformedFrameSinkCallback(uint32_t ssrc) {}

void RTCEncodedVideoStreamTransformer::Broker::TransformFrameOnSourceTaskRunner(
    std::unique_ptr<webrtc::TransformableVideoFrameInterface> frame) {}

void RTCEncodedVideoStreamTransformer::Broker::SetTransformerCallback(
    TransformerCallback callback) {}

void RTCEncodedVideoStreamTransformer::Broker::ResetTransformerCallback() {}

void RTCEncodedVideoStreamTransformer::Broker::SetSourceTaskRunner(
    scoped_refptr<base::SingleThreadTaskRunner> task_runner) {}

void RTCEncodedVideoStreamTransformer::Broker::ClearTransformer() {}

void RTCEncodedVideoStreamTransformer::Broker::SendFrameToSink(
    std::unique_ptr<webrtc::TransformableVideoFrameInterface> frame) {}

void RTCEncodedVideoStreamTransformer::Broker::StartShortCircuiting() {}

RTCEncodedVideoStreamTransformer::RTCEncodedVideoStreamTransformer(
    scoped_refptr<base::SingleThreadTaskRunner> realm_task_runner,
    std::unique_ptr<Metronome> metronome)
    :{}

RTCEncodedVideoStreamTransformer::~RTCEncodedVideoStreamTransformer() {}

void RTCEncodedVideoStreamTransformer::RegisterTransformedFrameSinkCallback(
    rtc::scoped_refptr<webrtc::TransformedFrameCallback> callback,
    uint32_t ssrc) {}

void RTCEncodedVideoStreamTransformer::UnregisterTransformedFrameSinkCallback(
    uint32_t ssrc) {}

void RTCEncodedVideoStreamTransformer::TransformFrame(
    std::unique_ptr<webrtc::TransformableVideoFrameInterface> frame) {}

void RTCEncodedVideoStreamTransformer::SendFrameToSink(
    std::unique_ptr<webrtc::TransformableVideoFrameInterface> frame) {}

void RTCEncodedVideoStreamTransformer::StartShortCircuiting() {}

void RTCEncodedVideoStreamTransformer::SetTransformerCallback(
    TransformerCallback callback) {}

void RTCEncodedVideoStreamTransformer::ResetTransformerCallback() {}

bool RTCEncodedVideoStreamTransformer::HasTransformerCallback() {}

bool RTCEncodedVideoStreamTransformer::HasTransformedFrameSinkCallback(
    uint32_t ssrc) const {}

rtc::scoped_refptr<webrtc::FrameTransformerInterface>
RTCEncodedVideoStreamTransformer::Delegate() {}

void RTCEncodedVideoStreamTransformer::SetSourceTaskRunner(
    scoped_refptr<base::SingleThreadTaskRunner> realm_task_runner) {}

scoped_refptr<RTCEncodedVideoStreamTransformer::Broker>
RTCEncodedVideoStreamTransformer::GetBroker() {}

void RTCEncodedVideoStreamTransformer::LogMessage(const std::string& message) {}

}  // namespace blink