Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(900)

Side by Side Diff: webrtc/modules/rtp_rtcp/include/flexfec_sender.h

Issue 2912713002: Persist RTP state for FlexFEC. (Closed)
Patch Set: Fix fuzzer and win compile. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/array_view.h"
18 #include "webrtc/base/basictypes.h" 18 #include "webrtc/base/basictypes.h"
19 #include "webrtc/base/random.h" 19 #include "webrtc/base/random.h"
20 #include "webrtc/base/sequenced_task_checker.h"
21 #include "webrtc/config.h" 20 #include "webrtc/config.h"
22 #include "webrtc/modules/include/module_common_types.h" 21 #include "webrtc/modules/include/module_common_types.h"
23 #include "webrtc/modules/rtp_rtcp/include/flexfec_sender.h" 22 #include "webrtc/modules/rtp_rtcp/include/flexfec_sender.h"
23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
24 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" 24 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h"
25 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_to_send.h" 25 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_to_send.h"
26 #include "webrtc/modules/rtp_rtcp/source/ulpfec_generator.h" 26 #include "webrtc/modules/rtp_rtcp/source/ulpfec_generator.h"
27 #include "webrtc/system_wrappers/include/clock.h" 27 #include "webrtc/system_wrappers/include/clock.h"
28 28
29 namespace webrtc { 29 namespace webrtc {
30 30
31 class RtpPacketToSend; 31 class RtpPacketToSend;
32 32
33 // 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
34 // synchronization. Currently, this is done using the lock in PayloadRouter. 34 // synchronization. Currently, this is done using the lock in PayloadRouter.
35 35
36 class FlexfecSender { 36 class FlexfecSender {
37 public: 37 public:
38 FlexfecSender(int payload_type, 38 FlexfecSender(int payload_type,
39 uint32_t ssrc, 39 uint32_t ssrc,
40 uint32_t protected_media_ssrc, 40 uint32_t protected_media_ssrc,
41 const std::vector<RtpExtension>& rtp_header_extensions, 41 const std::vector<RtpExtension>& rtp_header_extensions,
42 rtc::ArrayView<const RtpExtensionSize> extension_sizes, 42 rtc::ArrayView<const RtpExtensionSize> extension_sizes,
43 const RtpState* rtp_state,
43 Clock* clock); 44 Clock* clock);
44 ~FlexfecSender(); 45 ~FlexfecSender();
45 46
46 uint32_t ssrc() const { return ssrc_; } 47 uint32_t ssrc() const { return ssrc_; }
47 48
48 // Sets the FEC rate, max frames sent before FEC packets are sent, 49 // Sets the FEC rate, max frames sent before FEC packets are sent,
49 // and what type of generator matrices are used. 50 // and what type of generator matrices are used.
50 void SetFecParameters(const FecProtectionParams& params); 51 void SetFecParameters(const FecProtectionParams& params);
51 52
52 // Adds a media packet to the internal buffer. When enough media packets 53 // Adds a media packet to the internal buffer. When enough media packets
53 // have been added, the FEC packets are generated and stored internally. 54 // have been added, the FEC packets are generated and stored internally.
54 // These FEC packets are then obtained by calling GetFecPackets(). 55 // These FEC packets are then obtained by calling GetFecPackets().
55 // Returns true if the media packet was successfully added. 56 // Returns true if the media packet was successfully added.
56 bool AddRtpPacketAndGenerateFec(const RtpPacketToSend& packet); 57 bool AddRtpPacketAndGenerateFec(const RtpPacketToSend& packet);
57 58
58 // Returns true if there are generated FEC packets available. 59 // Returns true if there are generated FEC packets available.
59 bool FecAvailable() const; 60 bool FecAvailable() const;
60 61
61 // Returns generated FlexFEC packets. 62 // Returns generated FlexFEC packets.
62 std::vector<std::unique_ptr<RtpPacketToSend>> GetFecPackets(); 63 std::vector<std::unique_ptr<RtpPacketToSend>> GetFecPackets();
63 64
64 // Returns the overhead, per packet, for FlexFEC. 65 // Returns the overhead, per packet, for FlexFEC.
65 size_t MaxPacketOverhead() const; 66 size_t MaxPacketOverhead() const;
66 67
68 // Only called on the VideoSendStream queue, after operation has shut down.
69 RtpState GetRtpState();
70
67 private: 71 private:
68 // Utility. 72 // Utility.
69 Clock* const clock_; 73 Clock* const clock_;
70 Random random_; 74 Random random_;
71 int64_t last_generated_packet_ms_; 75 int64_t last_generated_packet_ms_;
72 76
73 // Config. 77 // Config.
74 const int payload_type_; 78 const int payload_type_;
75 const uint32_t timestamp_offset_; 79 const uint32_t timestamp_offset_;
76 const uint32_t ssrc_; 80 const uint32_t ssrc_;
77 const uint32_t protected_media_ssrc_; 81 const uint32_t protected_media_ssrc_;
78 // Sequence number of next packet to generate. 82 // Sequence number of next packet to generate.
79 uint16_t seq_num_; 83 uint16_t seq_num_;
80 84
81 // Implementation. 85 // Implementation.
82 UlpfecGenerator ulpfec_generator_; 86 UlpfecGenerator ulpfec_generator_;
83 const RtpHeaderExtensionMap rtp_header_extension_map_; 87 const RtpHeaderExtensionMap rtp_header_extension_map_;
84 const size_t header_extensions_size_; 88 const size_t header_extensions_size_;
85 }; 89 };
86 90
87 } // namespace webrtc 91 } // namespace webrtc
88 92
89 #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_FLEXFEC_SENDER_H_ 93 #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_FLEXFEC_SENDER_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/rtp_rtcp/source/flexfec_sender.cc » ('j') | webrtc/video/end_to_end_tests.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698