Telegram-Android/TMessagesProj/jni/voip/webrtc/video/video_send_stream.h

124 lines
4.1 KiB
C
Raw Normal View History

2020-08-14 18:58:22 +02:00
/*
* Copyright (c) 2013 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 VIDEO_VIDEO_SEND_STREAM_H_
#define VIDEO_VIDEO_SEND_STREAM_H_
#include <map>
#include <memory>
#include <vector>
#include "api/fec_controller.h"
2023-02-18 22:24:25 +01:00
#include "api/field_trials_view.h"
2021-06-25 02:43:10 +02:00
#include "api/sequence_checker.h"
2023-02-18 22:24:25 +01:00
#include "api/task_queue/pending_task_safety_flag.h"
2020-08-14 18:58:22 +02:00
#include "call/bitrate_allocator.h"
#include "call/video_receive_stream.h"
#include "call/video_send_stream.h"
2023-02-18 22:24:25 +01:00
#include "modules/utility/maybe_worker_thread.h"
2020-08-14 18:58:22 +02:00
#include "rtc_base/event.h"
2022-03-11 17:49:54 +01:00
#include "rtc_base/system/no_unique_address.h"
#include "video/encoder_rtcp_feedback.h"
2020-08-14 18:58:22 +02:00
#include "video/send_delay_stats.h"
#include "video/send_statistics_proxy.h"
2022-03-11 17:49:54 +01:00
#include "video/video_send_stream_impl.h"
2023-02-18 22:24:25 +01:00
#include "video/video_stream_encoder_interface.h"
2020-08-14 18:58:22 +02:00
namespace webrtc {
namespace test {
class VideoSendStreamPeer;
} // namespace test
class CallStats;
class IvfFileWriter;
class RateLimiter;
class RtpRtcp;
class RtpTransportControllerSendInterface;
class RtcEventLog;
namespace internal {
class VideoSendStreamImpl;
// VideoSendStream implements webrtc::VideoSendStream.
// Internally, it delegates all public methods to VideoSendStreamImpl and / or
2022-03-11 17:49:54 +01:00
// VideoStreamEncoder.
2020-08-14 18:58:22 +02:00
class VideoSendStream : public webrtc::VideoSendStream {
public:
using RtpStateMap = std::map<uint32_t, RtpState>;
using RtpPayloadStateMap = std::map<uint32_t, RtpPayloadState>;
VideoSendStream(
Clock* clock,
int num_cpu_cores,
TaskQueueFactory* task_queue_factory,
2022-03-11 17:49:54 +01:00
TaskQueueBase* network_queue,
2020-08-14 18:58:22 +02:00
RtcpRttStats* call_stats,
RtpTransportControllerSendInterface* transport,
BitrateAllocatorInterface* bitrate_allocator,
SendDelayStats* send_delay_stats,
RtcEventLog* event_log,
VideoSendStream::Config config,
VideoEncoderConfig encoder_config,
const std::map<uint32_t, RtpState>& suspended_ssrcs,
const std::map<uint32_t, RtpPayloadState>& suspended_payload_states,
2023-02-18 22:24:25 +01:00
std::unique_ptr<FecController> fec_controller,
const FieldTrialsView& field_trials);
2020-08-14 18:58:22 +02:00
~VideoSendStream() override;
void DeliverRtcp(const uint8_t* packet, size_t length);
// webrtc::VideoSendStream implementation.
2023-02-18 22:24:25 +01:00
void UpdateActiveSimulcastLayers(std::vector<bool> active_layers) override;
2020-08-14 18:58:22 +02:00
void Start() override;
void Stop() override;
2022-03-11 17:49:54 +01:00
bool started() override;
2020-08-14 18:58:22 +02:00
void AddAdaptationResource(rtc::scoped_refptr<Resource> resource) override;
std::vector<rtc::scoped_refptr<Resource>> GetAdaptationResources() override;
void SetSource(rtc::VideoSourceInterface<webrtc::VideoFrame>* source,
const DegradationPreference& degradation_preference) override;
void ReconfigureVideoEncoder(VideoEncoderConfig) override;
Stats GetStats() override;
void StopPermanentlyAndGetRtpStates(RtpStateMap* rtp_state_map,
RtpPayloadStateMap* payload_state_map);
2023-02-18 22:24:25 +01:00
void GenerateKeyFrame() override;
2020-08-14 18:58:22 +02:00
private:
friend class test::VideoSendStreamPeer;
absl::optional<float> GetPacingFactorOverride() const;
2022-03-11 17:49:54 +01:00
RTC_NO_UNIQUE_ADDRESS SequenceChecker thread_checker_;
2023-02-18 22:24:25 +01:00
MaybeWorkerThread* const rtp_transport_queue_;
2022-03-11 17:49:54 +01:00
RtpTransportControllerSendInterface* const transport_;
2020-08-14 18:58:22 +02:00
rtc::Event thread_sync_event_;
2022-03-11 17:49:54 +01:00
rtc::scoped_refptr<PendingTaskSafetyFlag> transport_queue_safety_ =
PendingTaskSafetyFlag::CreateDetached();
2020-08-14 18:58:22 +02:00
SendStatisticsProxy stats_proxy_;
const VideoSendStream::Config config_;
const VideoEncoderConfig::ContentType content_type_;
std::unique_ptr<VideoStreamEncoderInterface> video_stream_encoder_;
2022-03-11 17:49:54 +01:00
EncoderRtcpFeedback encoder_feedback_;
RtpVideoSenderInterface* const rtp_video_sender_;
VideoSendStreamImpl send_stream_;
bool running_ RTC_GUARDED_BY(thread_checker_) = false;
2020-08-14 18:58:22 +02:00
};
} // namespace internal
} // namespace webrtc
#endif // VIDEO_VIDEO_SEND_STREAM_H_