diff --git a/api/BUILD.gn b/api/BUILD.gn index 517a0db0a0..b48247ce0f 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -162,6 +162,7 @@ rtc_library("libjingle_peerconnection_api") { ":audio_options_api", ":callfactory_api", ":fec_controller_api", + ":frame_transformer_interface", ":libjingle_logging_api", ":media_stream_interface", ":network_state_predictor_api", @@ -213,6 +214,16 @@ rtc_library("libjingle_peerconnection_api") { ] } +rtc_source_set("frame_transformer_interface") { + visibility = [ "*" ] + sources = [ "frame_transformer_interface.h" ] + deps = [ + ":scoped_refptr", + "../rtc_base:refcount", + "video:encoded_frame", + ] +} + rtc_library("rtc_error") { visibility = [ "*" ] sources = [ diff --git a/api/DEPS b/api/DEPS index ef9db30804..1e92b12281 100644 --- a/api/DEPS +++ b/api/DEPS @@ -90,6 +90,10 @@ specific_include_rules = { "+modules/include/module_fec_types.h", ], + "frame_transformer_interface\.h": [ + "+rtc_base/ref_count.h", + ], + "ice_transport_interface\.h": [ "+rtc_base/ref_count.h", ], diff --git a/api/frame_transformer_interface.h b/api/frame_transformer_interface.h new file mode 100644 index 0000000000..666a791f91 --- /dev/null +++ b/api/frame_transformer_interface.h @@ -0,0 +1,58 @@ +/* + * Copyright 2020 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 API_FRAME_TRANSFORMER_INTERFACE_H_ +#define API_FRAME_TRANSFORMER_INTERFACE_H_ + +#include +#include + +#include "api/scoped_refptr.h" +#include "api/video/encoded_frame.h" +#include "rtc_base/ref_count.h" + +namespace webrtc { + +// Objects implement this interface to be notified with the transformed frame. +class TransformedFrameCallback : public rtc::RefCountInterface { + public: + virtual void OnTransformedFrame( + std::unique_ptr transformed_frame) = 0; + + protected: + ~TransformedFrameCallback() override = default; +}; + +// Transformes encoded frames. The transformed frame is sent in a callback using +// the TransformedFrameCallback interface (see below). +class FrameTransformerInterface : public rtc::RefCountInterface { + public: + // Transforms |frame| using the implementing class' processing logic. + // |additional_data| holds data that is needed in the frame transformation + // logic, but is not included in |frame|; for example, when the transform + // function is used for encrypting/decrypting the frame, the additional data + // holds the serialized generic frame descriptor extension calculated in + // webrtc::RtpDescriptorAuthentication, needed in the encryption/decryption + // algorithms. + virtual void TransformFrame(std::unique_ptr frame, + std::vector additional_data, + uint32_t ssrc) = 0; + + virtual void RegisterTransformedFrameCallback( + rtc::scoped_refptr) = 0; + virtual void UnregisterTransformedFrameCallback() = 0; + + protected: + ~FrameTransformerInterface() override = default; +}; + +} // namespace webrtc + +#endif // API_FRAME_TRANSFORMER_INTERFACE_H_