OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_VIDEO_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_VIDEO_H_ |
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_VIDEO_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_VIDEO_H_ |
13 | 13 |
14 #include <list> | 14 #include <map> |
15 #include <memory> | 15 #include <memory> |
16 #include <vector> | |
17 | 16 |
18 #include "webrtc/common_types.h" | 17 #include "webrtc/common_types.h" |
19 #include "webrtc/modules/rtp_rtcp/include/flexfec_sender.h" | 18 #include "webrtc/modules/rtp_rtcp/include/flexfec_sender.h" |
20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 19 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
21 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" | 20 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" |
22 #include "webrtc/modules/rtp_rtcp/source/rtp_sender.h" | 21 #include "webrtc/modules/rtp_rtcp/source/rtp_sender.h" |
23 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" | 22 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
24 #include "webrtc/modules/rtp_rtcp/source/ulpfec_generator.h" | 23 #include "webrtc/modules/rtp_rtcp/source/ulpfec_generator.h" |
25 #include "webrtc/modules/rtp_rtcp/source/video_codec_information.h" | 24 #include "webrtc/modules/rtp_rtcp/source/video_codec_information.h" |
26 #include "webrtc/rtc_base/criticalsection.h" | 25 #include "webrtc/rtc_base/criticalsection.h" |
27 #include "webrtc/rtc_base/onetimeevent.h" | 26 #include "webrtc/rtc_base/onetimeevent.h" |
28 #include "webrtc/rtc_base/optional.h" | 27 #include "webrtc/rtc_base/optional.h" |
29 #include "webrtc/rtc_base/rate_statistics.h" | 28 #include "webrtc/rtc_base/rate_statistics.h" |
30 #include "webrtc/rtc_base/sequenced_task_checker.h" | 29 #include "webrtc/rtc_base/sequenced_task_checker.h" |
31 #include "webrtc/rtc_base/thread_annotations.h" | 30 #include "webrtc/rtc_base/thread_annotations.h" |
32 #include "webrtc/typedefs.h" | 31 #include "webrtc/typedefs.h" |
33 | 32 |
34 namespace webrtc { | 33 namespace webrtc { |
34 class RtpPacketizer; | |
35 class RtpPacketToSend; | 35 class RtpPacketToSend; |
36 | 36 |
37 class RTPSenderVideo { | 37 class RTPSenderVideo { |
38 public: | 38 public: |
39 RTPSenderVideo(Clock* clock, | 39 RTPSenderVideo(Clock* clock, |
40 RTPSender* rtpSender, | 40 RTPSender* rtpSender, |
41 FlexfecSender* flexfec_sender); | 41 FlexfecSender* flexfec_sender); |
42 virtual ~RTPSenderVideo(); | 42 virtual ~RTPSenderVideo(); |
43 | 43 |
44 virtual RtpVideoCodecTypes VideoCodecType() const; | 44 virtual RtpVideoCodecTypes VideoCodecType() const; |
45 | 45 |
46 static RtpUtility::Payload* CreateVideoPayload( | 46 static RtpUtility::Payload* CreateVideoPayload( |
47 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | 47 const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
48 int8_t payload_type); | 48 int8_t payload_type); |
49 | 49 |
50 bool SendVideo(RtpVideoCodecTypes video_type, | 50 bool SendVideo(RtpVideoCodecTypes video_type, |
51 FrameType frame_type, | 51 FrameType frame_type, |
52 int8_t payload_type, | 52 int8_t payload_type, |
53 uint32_t capture_timestamp, | 53 uint32_t capture_timestamp, |
54 int64_t capture_time_ms, | 54 int64_t capture_time_ms, |
55 const uint8_t* payload_data, | 55 const uint8_t* payload_data, |
56 size_t payload_size, | 56 size_t payload_size, |
57 const RTPFragmentationHeader* fragmentation, | 57 const RTPFragmentationHeader* fragmentation, |
58 const RTPVideoHeader* video_header); | 58 const RTPVideoHeader* video_header, |
59 int64_t expected_retransmission_time_ms); | |
59 | 60 |
60 void SetVideoCodecType(RtpVideoCodecTypes type); | 61 void SetVideoCodecType(RtpVideoCodecTypes type); |
61 | 62 |
62 // ULPFEC. | 63 // ULPFEC. |
63 void SetUlpfecConfig(int red_payload_type, int ulpfec_payload_type); | 64 void SetUlpfecConfig(int red_payload_type, int ulpfec_payload_type); |
64 void GetUlpfecConfig(int* red_payload_type, int* ulpfec_payload_type) const; | 65 void GetUlpfecConfig(int* red_payload_type, int* ulpfec_payload_type) const; |
65 | 66 |
66 // FlexFEC/ULPFEC. | 67 // FlexFEC/ULPFEC. |
67 void SetFecParameters(const FecProtectionParams& delta_params, | 68 void SetFecParameters(const FecProtectionParams& delta_params, |
68 const FecProtectionParams& key_params); | 69 const FecProtectionParams& key_params); |
69 | 70 |
70 // FlexFEC. | 71 // FlexFEC. |
71 rtc::Optional<uint32_t> FlexfecSsrc() const; | 72 rtc::Optional<uint32_t> FlexfecSsrc() const; |
72 | 73 |
73 uint32_t VideoBitrateSent() const; | 74 uint32_t VideoBitrateSent() const; |
74 uint32_t FecOverheadRate() const; | 75 uint32_t FecOverheadRate() const; |
75 | 76 |
76 int SelectiveRetransmissions() const; | 77 int SelectiveRetransmissions() const; |
77 void SetSelectiveRetransmissions(uint8_t settings); | 78 void SetSelectiveRetransmissions(uint8_t settings); |
78 | 79 |
80 protected: | |
81 StorageType GetStorageType(const RTPVideoHeader& header, | |
82 int32_t retransmission_settings, | |
83 RtpPacketizer* packetizer, | |
84 int64_t expected_retransmission_time); | |
85 | |
79 private: | 86 private: |
87 struct TemporalLayerStats { | |
88 explicit TemporalLayerStats(int64_t window_size_ms) | |
89 : frame_rate_fp1000s_(window_size_ms, 1000 * 1000), | |
90 last_frame_time_(0) {} | |
91 RateStatistics frame_rate_fp1000s_; | |
92 int64_t last_frame_time_; | |
danilchap
2017/08/29 17:31:20
struct members shouldn't have '_' in the end.
sprang_webrtc
2017/08/31 15:54:29
Done.
| |
93 }; | |
94 | |
80 size_t CalculateFecPacketOverhead() const EXCLUSIVE_LOCKS_REQUIRED(crit_); | 95 size_t CalculateFecPacketOverhead() const EXCLUSIVE_LOCKS_REQUIRED(crit_); |
81 | 96 |
82 void SendVideoPacket(std::unique_ptr<RtpPacketToSend> packet, | 97 void SendVideoPacket(std::unique_ptr<RtpPacketToSend> packet, |
83 StorageType storage); | 98 StorageType storage); |
84 | 99 |
85 void SendVideoPacketAsRedMaybeWithUlpfec( | 100 void SendVideoPacketAsRedMaybeWithUlpfec( |
86 std::unique_ptr<RtpPacketToSend> media_packet, | 101 std::unique_ptr<RtpPacketToSend> media_packet, |
87 StorageType media_packet_storage, | 102 StorageType media_packet_storage, |
88 bool protect_media_packet); | 103 bool protect_media_packet); |
89 | 104 |
90 // TODO(brandtr): Remove the FlexFEC functions when FlexfecSender has been | 105 // TODO(brandtr): Remove the FlexFEC functions when FlexfecSender has been |
91 // moved to PacedSender. | 106 // moved to PacedSender. |
92 void SendVideoPacketWithFlexfec(std::unique_ptr<RtpPacketToSend> media_packet, | 107 void SendVideoPacketWithFlexfec(std::unique_ptr<RtpPacketToSend> media_packet, |
93 StorageType media_packet_storage, | 108 StorageType media_packet_storage, |
94 bool protect_media_packet); | 109 bool protect_media_packet); |
95 | 110 |
96 bool red_enabled() const EXCLUSIVE_LOCKS_REQUIRED(crit_) { | 111 bool red_enabled() const EXCLUSIVE_LOCKS_REQUIRED(crit_) { |
97 return red_payload_type_ >= 0; | 112 return red_payload_type_ >= 0; |
98 } | 113 } |
99 | 114 |
100 bool ulpfec_enabled() const EXCLUSIVE_LOCKS_REQUIRED(crit_) { | 115 bool ulpfec_enabled() const EXCLUSIVE_LOCKS_REQUIRED(crit_) { |
101 return ulpfec_payload_type_ >= 0; | 116 return ulpfec_payload_type_ >= 0; |
102 } | 117 } |
103 | 118 |
104 bool flexfec_enabled() const { return flexfec_sender_ != nullptr; } | 119 bool flexfec_enabled() const { return flexfec_sender_ != nullptr; } |
105 | 120 |
121 TemporalLayerStats* GetTemporalLayerStats(int temporal_id) | |
122 EXCLUSIVE_LOCKS_REQUIRED(stats_crit_); | |
123 | |
106 RTPSender* const rtp_sender_; | 124 RTPSender* const rtp_sender_; |
107 Clock* const clock_; | 125 Clock* const clock_; |
108 | 126 |
109 // Should never be held when calling out of this class. | 127 // Should never be held when calling out of this class. |
110 rtc::CriticalSection crit_; | 128 rtc::CriticalSection crit_; |
111 | 129 |
112 RtpVideoCodecTypes video_type_; | 130 RtpVideoCodecTypes video_type_; |
113 int32_t retransmission_settings_ GUARDED_BY(crit_); | 131 int32_t retransmission_settings_ GUARDED_BY(crit_); |
114 VideoRotation last_rotation_ GUARDED_BY(crit_); | 132 VideoRotation last_rotation_ GUARDED_BY(crit_); |
115 | 133 |
116 // RED/ULPFEC. | 134 // RED/ULPFEC. |
117 int red_payload_type_ GUARDED_BY(crit_); | 135 int red_payload_type_ GUARDED_BY(crit_); |
118 int ulpfec_payload_type_ GUARDED_BY(crit_); | 136 int ulpfec_payload_type_ GUARDED_BY(crit_); |
119 UlpfecGenerator ulpfec_generator_ GUARDED_BY(crit_); | 137 UlpfecGenerator ulpfec_generator_ GUARDED_BY(crit_); |
120 | 138 |
121 // FlexFEC. | 139 // FlexFEC. |
122 FlexfecSender* const flexfec_sender_; | 140 FlexfecSender* const flexfec_sender_; |
123 | 141 |
124 // FEC parameters, applicable to either ULPFEC or FlexFEC. | 142 // FEC parameters, applicable to either ULPFEC or FlexFEC. |
125 FecProtectionParams delta_fec_params_ GUARDED_BY(crit_); | 143 FecProtectionParams delta_fec_params_ GUARDED_BY(crit_); |
126 FecProtectionParams key_fec_params_ GUARDED_BY(crit_); | 144 FecProtectionParams key_fec_params_ GUARDED_BY(crit_); |
127 | 145 |
128 rtc::CriticalSection stats_crit_; | 146 rtc::CriticalSection stats_crit_; |
129 // Bitrate used for FEC payload, RED headers, RTP headers for FEC packets | 147 // Bitrate used for FEC payload, RED headers, RTP headers for FEC packets |
130 // and any padding overhead. | 148 // and any padding overhead. |
131 RateStatistics fec_bitrate_ GUARDED_BY(stats_crit_); | 149 RateStatistics fec_bitrate_ GUARDED_BY(stats_crit_); |
132 // Bitrate used for video payload and RTP headers. | 150 // Bitrate used for video payload and RTP headers. |
133 RateStatistics video_bitrate_ GUARDED_BY(stats_crit_); | 151 RateStatistics video_bitrate_ GUARDED_BY(stats_crit_); |
152 | |
153 std::map<int, TemporalLayerStats> frame_stats_by_temporal_layer_ | |
154 GUARDED_BY(stats_crit_); | |
155 | |
134 OneTimeEvent first_frame_sent_; | 156 OneTimeEvent first_frame_sent_; |
135 }; | 157 }; |
136 | 158 |
137 } // namespace webrtc | 159 } // namespace webrtc |
138 | 160 |
139 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_VIDEO_H_ | 161 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_VIDEO_H_ |
OLD | NEW |