OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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_INCLUDE_FLEXFEC_SENDER_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_INCLUDE_FLEXFEC_SENDER_H_ |
12 #define WEBRTC_MODULES_RTP_RTCP_INCLUDE_FLEXFEC_SENDER_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_INCLUDE_FLEXFEC_SENDER_H_ |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "webrtc/base/array_view.h" | |
17 #include "webrtc/base/basictypes.h" | 18 #include "webrtc/base/basictypes.h" |
18 #include "webrtc/base/random.h" | 19 #include "webrtc/base/random.h" |
19 #include "webrtc/base/sequenced_task_checker.h" | 20 #include "webrtc/base/sequenced_task_checker.h" |
20 #include "webrtc/config.h" | 21 #include "webrtc/config.h" |
21 #include "webrtc/modules/include/module_common_types.h" | 22 #include "webrtc/modules/include/module_common_types.h" |
22 #include "webrtc/modules/rtp_rtcp/include/flexfec_sender.h" | 23 #include "webrtc/modules/rtp_rtcp/include/flexfec_sender.h" |
23 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" | 24 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" |
24 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_to_send.h" | 25 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_to_send.h" |
25 #include "webrtc/modules/rtp_rtcp/source/ulpfec_generator.h" | 26 #include "webrtc/modules/rtp_rtcp/source/ulpfec_generator.h" |
26 #include "webrtc/system_wrappers/include/clock.h" | 27 #include "webrtc/system_wrappers/include/clock.h" |
27 | 28 |
28 namespace webrtc { | 29 namespace webrtc { |
29 | 30 |
30 class RtpPacketToSend; | 31 class RtpPacketToSend; |
31 | 32 |
32 // Note that this class is not thread safe, and thus requires external | 33 // Note that this class is not thread safe, and thus requires external |
33 // synchronization. Currently, this is done using the lock in PayloadRouter. | 34 // synchronization. Currently, this is done using the lock in PayloadRouter. |
34 | 35 |
35 class FlexfecSender { | 36 class FlexfecSender { |
36 public: | 37 public: |
37 FlexfecSender(int payload_type, | 38 FlexfecSender(int payload_type, |
38 uint32_t ssrc, | 39 uint32_t ssrc, |
39 uint32_t protected_media_ssrc, | 40 uint32_t protected_media_ssrc, |
40 const std::vector<RtpExtension>& rtp_header_extensions, | 41 const std::vector<RtpExtension>& rtp_header_extensions, |
42 rtc::ArrayView<const RtpExtensionSize> extension_sizes, | |
41 Clock* clock); | 43 Clock* clock); |
42 ~FlexfecSender(); | 44 ~FlexfecSender(); |
43 | 45 |
44 uint32_t ssrc() const { return ssrc_; } | 46 uint32_t ssrc() const { return ssrc_; } |
45 | 47 |
46 // Sets the FEC rate, max frames sent before FEC packets are sent, | 48 // Sets the FEC rate, max frames sent before FEC packets are sent, |
47 // and what type of generator matrices are used. | 49 // and what type of generator matrices are used. |
48 void SetFecParameters(const FecProtectionParams& params); | 50 void SetFecParameters(const FecProtectionParams& params); |
49 | 51 |
50 // Adds a media packet to the internal buffer. When enough media packets | 52 // Adds a media packet to the internal buffer. When enough media packets |
51 // have been added, the FEC packets are generated and stored internally. | 53 // have been added, the FEC packets are generated and stored internally. |
52 // These FEC packets are then obtained by calling GetFecPackets(). | 54 // These FEC packets are then obtained by calling GetFecPackets(). |
53 // Returns true if the media packet was successfully added. | 55 // Returns true if the media packet was successfully added. |
54 bool AddRtpPacketAndGenerateFec(const RtpPacketToSend& packet); | 56 bool AddRtpPacketAndGenerateFec(const RtpPacketToSend& packet); |
55 | 57 |
56 // Returns true if there are generated FEC packets available. | 58 // Returns true if there are generated FEC packets available. |
57 bool FecAvailable() const; | 59 bool FecAvailable() const; |
58 | 60 |
59 // Returns generated FlexFEC packets. | 61 // Returns generated FlexFEC packets. |
60 std::vector<std::unique_ptr<RtpPacketToSend>> GetFecPackets(); | 62 std::vector<std::unique_ptr<RtpPacketToSend>> GetFecPackets(); |
61 | 63 |
62 // Returns the overhead, per packet, for FlexFEC. | 64 // Returns the overhead, per packet, for FlexFEC. |extension_sizes| is used |
65 // to calculate the RTP header extension overhead and it should have an entry | |
brandtr
2017/05/10 14:36:27
I think this comment is redundant now?
erikvarga1
2017/05/10 15:39:31
Oops, I forgot to remove that. Removed now.
| |
66 // for each extension that a packet might use. If only fixed-length extensions | |
67 // are used, |extension_sizes| should be the same at each call. | |
63 size_t MaxPacketOverhead() const; | 68 size_t MaxPacketOverhead() const; |
64 | 69 |
65 private: | 70 private: |
66 // Utility. | 71 // Utility. |
67 Clock* const clock_; | 72 Clock* const clock_; |
68 Random random_; | 73 Random random_; |
69 int64_t last_generated_packet_ms_; | 74 int64_t last_generated_packet_ms_; |
70 | 75 |
71 // Config. | 76 // Config. |
72 const int payload_type_; | 77 const int payload_type_; |
73 const uint32_t timestamp_offset_; | 78 const uint32_t timestamp_offset_; |
74 const uint32_t ssrc_; | 79 const uint32_t ssrc_; |
75 const uint32_t protected_media_ssrc_; | 80 const uint32_t protected_media_ssrc_; |
76 // Sequence number of next packet to generate. | 81 // Sequence number of next packet to generate. |
77 uint16_t seq_num_; | 82 uint16_t seq_num_; |
78 | 83 |
79 // Implementation. | 84 // Implementation. |
80 UlpfecGenerator ulpfec_generator_; | 85 UlpfecGenerator ulpfec_generator_; |
81 const RtpHeaderExtensionMap rtp_header_extension_map_; | 86 const RtpHeaderExtensionMap rtp_header_extension_map_; |
87 size_t header_extensions_size_; | |
brandtr
2017/05/10 14:36:27
Can you make this const?
erikvarga1
2017/05/10 15:39:31
Done.
| |
82 }; | 88 }; |
83 | 89 |
84 } // namespace webrtc | 90 } // namespace webrtc |
85 | 91 |
86 #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_FLEXFEC_SENDER_H_ | 92 #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_FLEXFEC_SENDER_H_ |
OLD | NEW |