blob: 9466c746990a12756c8d6c5672a484b32b3c55a0 [file] [log] [blame]
pbos@webrtc.org29d58392013-05-16 12:08:03 +00001/*
2 * Copyright (c) 2013 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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef VIDEO_VIDEO_SEND_STREAM_H_
12#define VIDEO_VIDEO_SEND_STREAM_H_
pbos@webrtc.org29d58392013-05-16 12:08:03 +000013
pbos@webrtc.org2bb1bda2014-07-07 13:06:48 +000014#include <map>
kwibergbfefb032016-05-01 14:53:46 -070015#include <memory>
pbos@webrtc.orgdde16f12014-08-05 23:35:43 +000016#include <vector>
pbos@webrtc.org2bb1bda2014-07-07 13:06:48 +000017
Ying Wang3b790f32018-01-19 17:58:57 +010018#include "api/fec_controller.h"
Niels Möller213618e2018-07-24 09:29:58 +020019#include "api/video/video_stream_encoder_interface.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "call/bitrate_allocator.h"
21#include "call/video_receive_stream.h"
22#include "call/video_send_stream.h"
Steve Anton10542f22019-01-11 09:11:00 -080023#include "rtc_base/critical_section.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020024#include "rtc_base/event.h"
25#include "rtc_base/task_queue.h"
Sebastian Janssondf5e4e02019-03-29 10:34:45 +010026#include "rtc_base/thread_checker.h"
Yves Gerey665174f2018-06-19 15:03:05 +020027#include "video/send_delay_stats.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020028#include "video/send_statistics_proxy.h"
pbos@webrtc.org29d58392013-05-16 12:08:03 +000029
30namespace webrtc {
Sebastian Janssona45c8da2018-01-16 10:55:29 +010031namespace test {
32class VideoSendStreamPeer;
33} // namespace test
pbos@webrtc.org29d58392013-05-16 12:08:03 +000034
mflodmane3787022015-10-21 13:24:28 +020035class CallStats;
perkj600246e2016-05-04 11:26:51 -070036class IvfFileWriter;
Peter Boströmf16fcbe2015-04-30 12:16:05 +020037class ProcessThread;
Niels Möller213618e2018-07-24 09:29:58 +020038class RateLimiter;
Peter Boström723ead82016-02-22 15:14:01 +010039class RtpRtcp;
nisseb8f9a322017-03-27 05:36:15 -070040class RtpTransportControllerSendInterface;
tereliusadafe0b2016-05-26 01:58:40 -070041class RtcEventLog;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000042
43namespace internal {
mflodman@webrtc.org6879c8a2013-07-23 11:35:00 +000044
perkj26091b12016-09-01 01:17:40 -070045class VideoSendStreamImpl;
46
47// VideoSendStream implements webrtc::VideoSendStream.
48// Internally, it delegates all public methods to VideoSendStreamImpl and / or
mflodmancc3d4422017-08-03 08:27:51 -070049// VideoStreamEncoder. VideoSendStreamInternal is created and deleted on
50// |worker_queue|.
perkj26091b12016-09-01 01:17:40 -070051class VideoSendStream : public webrtc::VideoSendStream {
pbos@webrtc.org29d58392013-05-16 12:08:03 +000052 public:
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020053 using RtpStateMap = std::map<uint32_t, RtpState>;
54 using RtpPayloadStateMap = std::map<uint32_t, RtpPayloadState>;
55
Åsa Persson4bece9a2017-10-06 10:04:04 +020056 VideoSendStream(
Sebastian Jansson572c60f2019-03-04 18:30:41 +010057 Clock* clock,
Åsa Persson4bece9a2017-10-06 10:04:04 +020058 int num_cpu_cores,
59 ProcessThread* module_process_thread,
Sebastian Jansson74682c12019-03-01 11:50:20 +010060 TaskQueueFactory* task_queue_factory,
Åsa Persson4bece9a2017-10-06 10:04:04 +020061 CallStats* call_stats,
62 RtpTransportControllerSendInterface* transport,
Niels Möller67b011d2018-10-22 13:00:40 +020063 BitrateAllocatorInterface* bitrate_allocator,
Åsa Persson4bece9a2017-10-06 10:04:04 +020064 SendDelayStats* send_delay_stats,
65 RtcEventLog* event_log,
66 VideoSendStream::Config config,
67 VideoEncoderConfig encoder_config,
68 const std::map<uint32_t, RtpState>& suspended_ssrcs,
Ying Wang3b790f32018-01-19 17:58:57 +010069 const std::map<uint32_t, RtpPayloadState>& suspended_payload_states,
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020070 std::unique_ptr<FecController> fec_controller);
pbos@webrtc.org29d58392013-05-16 12:08:03 +000071
Jelena Marusiccd670222015-07-16 09:30:09 +020072 ~VideoSendStream() override;
pbos@webrtc.org29d58392013-05-16 12:08:03 +000073
Niels Möller8fb1a6a2019-03-05 14:29:42 +010074 void DeliverRtcp(const uint8_t* packet, size_t length);
pbos@webrtc.org29d58392013-05-16 12:08:03 +000075
Jelena Marusiccd670222015-07-16 09:30:09 +020076 // webrtc::VideoSendStream implementation.
Seth Hampsoncc7125f2018-02-02 08:46:16 -080077 void UpdateActiveSimulcastLayers(
78 const std::vector<bool> active_layers) override;
pbos1ba8d392016-05-01 20:18:34 -070079 void Start() override;
80 void Stop() override;
perkja49cbd32016-09-16 07:53:41 -070081
perkj803d97f2016-11-01 11:45:46 -070082 void SetSource(rtc::VideoSourceInterface<webrtc::VideoFrame>* source,
83 const DegradationPreference& degradation_preference) override;
perkja49cbd32016-09-16 07:53:41 -070084
perkj26091b12016-09-01 01:17:40 -070085 void ReconfigureVideoEncoder(VideoEncoderConfig) override;
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000086 Stats GetStats() override;
sprang@webrtc.orgccd42842014-01-07 09:54:34 +000087
Åsa Persson4bece9a2017-10-06 10:04:04 +020088 void StopPermanentlyAndGetRtpStates(RtpStateMap* rtp_state_map,
89 RtpPayloadStateMap* payload_state_map);
Per83d09102016-04-15 14:59:13 +020090
pbos@webrtc.org29d58392013-05-16 12:08:03 +000091 private:
Sebastian Janssona45c8da2018-01-16 10:55:29 +010092 friend class test::VideoSendStreamPeer;
93
perkj26091b12016-09-01 01:17:40 -070094 class ConstructionTask;
perkjbc75d972016-05-02 06:31:25 -070095
Danil Chapovalovb9b146c2018-06-15 12:28:07 +020096 absl::optional<float> GetPacingFactorOverride() const;
Sebastian Janssona45c8da2018-01-16 10:55:29 +010097
perkj26091b12016-09-01 01:17:40 -070098 rtc::ThreadChecker thread_checker_;
99 rtc::TaskQueue* const worker_queue_;
100 rtc::Event thread_sync_event_;
Peter Boström373284d2015-11-03 13:53:06 +0100101
102 SendStatisticsProxy stats_proxy_;
pbos@webrtc.org6ae48c62014-06-06 10:49:19 +0000103 const VideoSendStream::Config config_;
sprangf24a0642017-02-28 13:23:26 -0800104 const VideoEncoderConfig::ContentType content_type_;
perkj26091b12016-09-01 01:17:40 -0700105 std::unique_ptr<VideoSendStreamImpl> send_stream_;
Niels Möller213618e2018-07-24 09:29:58 +0200106 std::unique_ptr<VideoStreamEncoderInterface> video_stream_encoder_;
perkj8eb37a32016-08-16 02:40:55 -0700107};
perkj26091b12016-09-01 01:17:40 -0700108
pbos@webrtc.org29d58392013-05-16 12:08:03 +0000109} // namespace internal
110} // namespace webrtc
111
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200112#endif // VIDEO_VIDEO_SEND_STREAM_H_