pbos@webrtc.org | 29d5839 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef VIDEO_VIDEO_SEND_STREAM_H_ |
| 12 | #define VIDEO_VIDEO_SEND_STREAM_H_ |
pbos@webrtc.org | 29d5839 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 13 | |
pbos@webrtc.org | 2bb1bda | 2014-07-07 13:06:48 +0000 | [diff] [blame] | 14 | #include <map> |
kwiberg | bfefb03 | 2016-05-01 14:53:46 -0700 | [diff] [blame] | 15 | #include <memory> |
pbos@webrtc.org | dde16f1 | 2014-08-05 23:35:43 +0000 | [diff] [blame] | 16 | #include <vector> |
pbos@webrtc.org | 2bb1bda | 2014-07-07 13:06:48 +0000 | [diff] [blame] | 17 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 18 | #include "call/bitrate_allocator.h" |
| 19 | #include "call/video_receive_stream.h" |
| 20 | #include "call/video_send_stream.h" |
| 21 | #include "common_video/libyuv/include/webrtc_libyuv.h" |
| 22 | #include "modules/video_coding/protection_bitrate_calculator.h" |
| 23 | #include "rtc_base/criticalsection.h" |
| 24 | #include "rtc_base/event.h" |
| 25 | #include "rtc_base/task_queue.h" |
| 26 | #include "video/encoder_rtcp_feedback.h" |
| 27 | #include "video/send_delay_stats.h" |
| 28 | #include "video/send_statistics_proxy.h" |
| 29 | #include "video/video_stream_encoder.h" |
pbos@webrtc.org | 29d5839 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 30 | |
| 31 | namespace webrtc { |
| 32 | |
mflodman | e378702 | 2015-10-21 13:24:28 +0200 | [diff] [blame] | 33 | class CallStats; |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 34 | class SendSideCongestionController; |
perkj | 600246e | 2016-05-04 11:26:51 -0700 | [diff] [blame] | 35 | class IvfFileWriter; |
Peter Boström | f16fcbe | 2015-04-30 12:16:05 +0200 | [diff] [blame] | 36 | class ProcessThread; |
Peter Boström | 723ead8 | 2016-02-22 15:14:01 +0100 | [diff] [blame] | 37 | class RtpRtcp; |
nisse | b8f9a32 | 2017-03-27 05:36:15 -0700 | [diff] [blame] | 38 | class RtpTransportControllerSendInterface; |
terelius | adafe0b | 2016-05-26 01:58:40 -0700 | [diff] [blame] | 39 | class RtcEventLog; |
pbos@webrtc.org | 29d5839 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 40 | |
| 41 | namespace internal { |
mflodman@webrtc.org | 6879c8a | 2013-07-23 11:35:00 +0000 | [diff] [blame] | 42 | |
perkj | 26091b1 | 2016-09-01 01:17:40 -0700 | [diff] [blame] | 43 | class VideoSendStreamImpl; |
| 44 | |
| 45 | // VideoSendStream implements webrtc::VideoSendStream. |
| 46 | // Internally, it delegates all public methods to VideoSendStreamImpl and / or |
mflodman | cc3d442 | 2017-08-03 08:27:51 -0700 | [diff] [blame] | 47 | // VideoStreamEncoder. VideoSendStreamInternal is created and deleted on |
| 48 | // |worker_queue|. |
perkj | 26091b1 | 2016-09-01 01:17:40 -0700 | [diff] [blame] | 49 | class VideoSendStream : public webrtc::VideoSendStream { |
pbos@webrtc.org | 29d5839 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 50 | public: |
Åsa Persson | 4bece9a | 2017-10-06 10:04:04 +0200 | [diff] [blame] | 51 | VideoSendStream( |
| 52 | int num_cpu_cores, |
| 53 | ProcessThread* module_process_thread, |
| 54 | rtc::TaskQueue* worker_queue, |
| 55 | CallStats* call_stats, |
| 56 | RtpTransportControllerSendInterface* transport, |
| 57 | BitrateAllocator* bitrate_allocator, |
| 58 | SendDelayStats* send_delay_stats, |
| 59 | RtcEventLog* event_log, |
| 60 | VideoSendStream::Config config, |
| 61 | VideoEncoderConfig encoder_config, |
| 62 | const std::map<uint32_t, RtpState>& suspended_ssrcs, |
| 63 | const std::map<uint32_t, RtpPayloadState>& suspended_payload_states); |
pbos@webrtc.org | 29d5839 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 64 | |
Jelena Marusic | cd67022 | 2015-07-16 09:30:09 +0200 | [diff] [blame] | 65 | ~VideoSendStream() override; |
pbos@webrtc.org | 29d5839 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 66 | |
pbos | 1ba8d39 | 2016-05-01 20:18:34 -0700 | [diff] [blame] | 67 | void SignalNetworkState(NetworkState state); |
| 68 | bool DeliverRtcp(const uint8_t* packet, size_t length); |
pbos@webrtc.org | 29d5839 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 69 | |
Jelena Marusic | cd67022 | 2015-07-16 09:30:09 +0200 | [diff] [blame] | 70 | // webrtc::VideoSendStream implementation. |
pbos | 1ba8d39 | 2016-05-01 20:18:34 -0700 | [diff] [blame] | 71 | void Start() override; |
| 72 | void Stop() override; |
perkj | a49cbd3 | 2016-09-16 07:53:41 -0700 | [diff] [blame] | 73 | |
perkj | 803d97f | 2016-11-01 11:45:46 -0700 | [diff] [blame] | 74 | void SetSource(rtc::VideoSourceInterface<webrtc::VideoFrame>* source, |
| 75 | const DegradationPreference& degradation_preference) override; |
perkj | a49cbd3 | 2016-09-16 07:53:41 -0700 | [diff] [blame] | 76 | |
perkj | 26091b1 | 2016-09-01 01:17:40 -0700 | [diff] [blame] | 77 | void ReconfigureVideoEncoder(VideoEncoderConfig) override; |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 78 | Stats GetStats() override; |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 79 | |
pbos@webrtc.org | 2bb1bda | 2014-07-07 13:06:48 +0000 | [diff] [blame] | 80 | typedef std::map<uint32_t, RtpState> RtpStateMap; |
Åsa Persson | 4bece9a | 2017-10-06 10:04:04 +0200 | [diff] [blame] | 81 | typedef std::map<uint32_t, RtpPayloadState> RtpPayloadStateMap; |
palmkvist | e75f204 | 2016-09-28 06:19:48 -0700 | [diff] [blame] | 82 | |
| 83 | // Takes ownership of each file, is responsible for closing them later. |
| 84 | // Calling this method will close and finalize any current logs. |
| 85 | // Giving rtc::kInvalidPlatformFileValue in any position disables logging |
| 86 | // for the corresponding stream. |
| 87 | // If a frame to be written would make the log too large the write fails and |
| 88 | // the log is closed and finalized. A |byte_limit| of 0 means no limit. |
| 89 | void EnableEncodedFrameRecording(const std::vector<rtc::PlatformFile>& files, |
| 90 | size_t byte_limit) override; |
| 91 | |
Åsa Persson | 4bece9a | 2017-10-06 10:04:04 +0200 | [diff] [blame] | 92 | void StopPermanentlyAndGetRtpStates(RtpStateMap* rtp_state_map, |
| 93 | RtpPayloadStateMap* payload_state_map); |
Per | 83d0910 | 2016-04-15 14:59:13 +0200 | [diff] [blame] | 94 | |
nisse | 284542b | 2017-01-10 08:58:32 -0800 | [diff] [blame] | 95 | void SetTransportOverhead(size_t transport_overhead_per_packet); |
michaelt | 79e0588 | 2016-11-08 02:50:09 -0800 | [diff] [blame] | 96 | |
pbos@webrtc.org | 29d5839 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 97 | private: |
perkj | 26091b1 | 2016-09-01 01:17:40 -0700 | [diff] [blame] | 98 | class ConstructionTask; |
| 99 | class DestructAndGetRtpStateTask; |
perkj | bc75d97 | 2016-05-02 06:31:25 -0700 | [diff] [blame] | 100 | |
perkj | 26091b1 | 2016-09-01 01:17:40 -0700 | [diff] [blame] | 101 | rtc::ThreadChecker thread_checker_; |
| 102 | rtc::TaskQueue* const worker_queue_; |
| 103 | rtc::Event thread_sync_event_; |
Peter Boström | 373284d | 2015-11-03 13:53:06 +0100 | [diff] [blame] | 104 | |
| 105 | SendStatisticsProxy stats_proxy_; |
pbos@webrtc.org | 6ae48c6 | 2014-06-06 10:49:19 +0000 | [diff] [blame] | 106 | const VideoSendStream::Config config_; |
sprang | f24a064 | 2017-02-28 13:23:26 -0800 | [diff] [blame] | 107 | const VideoEncoderConfig::ContentType content_type_; |
perkj | 26091b1 | 2016-09-01 01:17:40 -0700 | [diff] [blame] | 108 | std::unique_ptr<VideoSendStreamImpl> send_stream_; |
mflodman | cc3d442 | 2017-08-03 08:27:51 -0700 | [diff] [blame] | 109 | std::unique_ptr<VideoStreamEncoder> video_stream_encoder_; |
perkj | 8eb37a3 | 2016-08-16 02:40:55 -0700 | [diff] [blame] | 110 | }; |
perkj | 26091b1 | 2016-09-01 01:17:40 -0700 | [diff] [blame] | 111 | |
pbos@webrtc.org | 29d5839 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 112 | } // namespace internal |
| 113 | } // namespace webrtc |
| 114 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 115 | #endif // VIDEO_VIDEO_SEND_STREAM_H_ |