Florent Castelli | e7862cc | 2018-12-06 13:38:24 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | * |
| 10 | */ |
| 11 | |
| 12 | #ifndef MEDIA_ENGINE_ENCODER_SIMULCAST_PROXY_H_ |
| 13 | #define MEDIA_ENGINE_ENCODER_SIMULCAST_PROXY_H_ |
| 14 | |
| 15 | #include <stddef.h> |
| 16 | #include <stdint.h> |
| 17 | #include <memory> |
| 18 | #include <vector> |
| 19 | |
| 20 | #include "api/video/video_bitrate_allocation.h" |
| 21 | #include "api/video/video_frame.h" |
| 22 | #include "api/video_codecs/sdp_video_format.h" |
| 23 | #include "api/video_codecs/video_codec.h" |
| 24 | #include "api/video_codecs/video_encoder.h" |
| 25 | #include "api/video_codecs/video_encoder_factory.h" |
Florent Castelli | e7862cc | 2018-12-06 13:38:24 +0100 | [diff] [blame] | 26 | #include "modules/video_coding/include/video_codec_interface.h" |
Mirko Bonadei | 66e7679 | 2019-04-02 11:33:59 +0200 | [diff] [blame] | 27 | #include "rtc_base/system/rtc_export.h" |
Florent Castelli | e7862cc | 2018-12-06 13:38:24 +0100 | [diff] [blame] | 28 | |
| 29 | namespace webrtc { |
| 30 | |
| 31 | // This class provides fallback to SimulcastEncoderAdapter if default VP8Encoder |
| 32 | // doesn't support simulcast for provided settings. |
Mirko Bonadei | 66e7679 | 2019-04-02 11:33:59 +0200 | [diff] [blame] | 33 | class RTC_EXPORT EncoderSimulcastProxy : public VideoEncoder { |
Florent Castelli | e7862cc | 2018-12-06 13:38:24 +0100 | [diff] [blame] | 34 | public: |
| 35 | EncoderSimulcastProxy(VideoEncoderFactory* factory, |
| 36 | const SdpVideoFormat& format); |
| 37 | // Deprecated. Remove once all clients use constructor with both factory and |
| 38 | // SdpVideoFormat; |
| 39 | explicit EncoderSimulcastProxy(VideoEncoderFactory* factory); |
| 40 | |
| 41 | ~EncoderSimulcastProxy() override; |
| 42 | |
| 43 | // Implements VideoEncoder. |
| 44 | int Release() override; |
| 45 | int InitEncode(const VideoCodec* inst, |
| 46 | int number_of_cores, |
| 47 | size_t max_payload_size) override; |
| 48 | int Encode(const VideoFrame& input_image, |
Niels Möller | 87e2d78 | 2019-03-07 10:18:23 +0100 | [diff] [blame] | 49 | const std::vector<VideoFrameType>* frame_types) override; |
Florent Castelli | e7862cc | 2018-12-06 13:38:24 +0100 | [diff] [blame] | 50 | int RegisterEncodeCompleteCallback(EncodedImageCallback* callback) override; |
| 51 | int SetRateAllocation(const VideoBitrateAllocation& bitrate, |
| 52 | uint32_t new_framerate) override; |
Elad Alon | fb20afd | 2019-04-10 16:38:16 +0200 | [diff] [blame^] | 53 | void OnPacketLossRateUpdate(float packet_loss_rate) override; |
| 54 | void OnRttUpdate(int64_t rtt_ms) override; |
| 55 | void OnLossNotification(const LossNotification& loss_notification) override; |
Florent Castelli | e7862cc | 2018-12-06 13:38:24 +0100 | [diff] [blame] | 56 | EncoderInfo GetEncoderInfo() const override; |
| 57 | |
| 58 | private: |
| 59 | VideoEncoderFactory* const factory_; |
| 60 | SdpVideoFormat video_format_; |
| 61 | std::unique_ptr<VideoEncoder> encoder_; |
| 62 | EncodedImageCallback* callback_; |
| 63 | }; |
| 64 | |
| 65 | } // namespace webrtc |
| 66 | |
| 67 | #endif // MEDIA_ENGINE_ENCODER_SIMULCAST_PROXY_H_ |