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

Side by Side Diff: webrtc/modules/video_coding/nack_module.h

Issue 1715673002: Implement the NackModule as part of the new jitter buffer. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Feedback fixes. Created 4 years, 9 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
(Empty)
1 /*
2 * Copyright (c) 2016 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
11 #ifndef WEBRTC_MODULES_VIDEO_CODING_NACK_MODULE_H_
12 #define WEBRTC_MODULES_VIDEO_CODING_NACK_MODULE_H_
13
14 #include <map>
15 #include <vector>
16 #include <set>
17
18 #include "webrtc/base/thread_annotations.h"
19 #include "webrtc/modules/include/module.h"
20 #include "webrtc/modules/video_coding/include/video_coding_defines.h"
21 #include "webrtc/modules/video_coding/packet.h"
22 #include "webrtc/system_wrappers/include/clock.h"
23 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
24
25 namespace webrtc {
26
27 class NackModule : public Module {
28 public:
stefan-webrtc 2016/02/26 09:26:55 I think we need a method which can be used to info
philipel 2016/02/26 15:12:07 Agree, implemented.
29 NackModule(Clock* clock,
30 VCMNackSender* nack_sender,
31 VCMKeyFrameRequestSender* keyframe_request_sender);
32
33 void OnReceivedPacket(const VCMPacket& packet);
34 void UpdateRtt(int64_t rtt_ms);
35 void Stop();
36
37 // Module implementation
38 int64_t TimeUntilNextProcess() override;
39 int32_t Process() override;
40
41 private:
42 static const uint16_t kMaxNackPackets = 1000;
43 static const uint16_t kMaxReorderedPackets = 128;
44 static const uint16_t kNumReorderingBuckets = 5;
45 static const uint16_t kDefaultRttMs = 100;
46 static const uint8_t kMaxNackRetries = 10;
47 static const uint8_t kProcessFrequency = 50;
48 static const uint8_t kProcessIntervalMs = 1000 / kProcessFrequency;
49
50 // This class holds the sequence number of the packet that is in the nack list
51 // as well as the meta data about when it should be nacked and how many times
52 // we have tried to nack this packet.
53 struct NackInfo {
54 NackInfo();
55 NackInfo(uint16_t seq_num, uint16_t send_at_seq_num);
56
57 uint16_t seq_num;
58 uint16_t send_at_seq_num;
59 int64_t send_at_time;
stefan-webrtc 2016/02/26 09:26:55 Would it be more logical to have "sent_at_time" an
philipel 2016/02/26 15:12:07 For the timestamp I think this is a good idea.
60 int retries;
61 };
62
63 void AddPacketsToNack(uint16_t seq_num_start, uint16_t seq_num_end)
64 EXCLUSIVE_LOCKS_REQUIRED(crit_);
65
66 // Removes packets from the nack list until the next
67 // keyframe. Returns true if packets were removed.
68 bool RemovePacketsUntilKeyframe()
69 EXCLUSIVE_LOCKS_REQUIRED(crit_);
70 void RemovePacketFromNack(uint16_t seq_num)
71 EXCLUSIVE_LOCKS_REQUIRED(crit_);
72
73 // Which fields to consider when deciding
74 // which packet to nack in GetNackBatch.
75 enum NackFilterOptions {kSeqNumOnly,
76 kTimeOnly,
77 kSeqNumAndTime};
stefan-webrtc 2016/02/26 09:26:55 Place type definitions directly after "private:"
philipel 2016/02/26 15:12:07 Done.
78 std::vector<uint16_t> GetNackBatch(NackFilterOptions options)
79 EXCLUSIVE_LOCKS_REQUIRED(crit_);
80
81 // Update the reordering distribution.
82 void UpdateReorderingStatistics(uint16_t seq_num)
83 EXCLUSIVE_LOCKS_REQUIRED(crit_);
84
85 // Returns how many packets we have to wait in order to receive
86 // the packet with probability |probabilty| or higher.
87 int WaitNumberOfPackets(float probability) const
88 EXCLUSIVE_LOCKS_REQUIRED(crit_);
89
90 rtc::CriticalSection crit_;
91 Clock* const clock_;
92 VCMNackSender* const nack_sender_;
93 VCMKeyFrameRequestSender* const keyframe_request_sender_;
94
95 SequenceNumberUnwrapper unwrapper_;
96 std::map<int64_t, NackInfo> nack_list_ GUARDED_BY(crit_);
97 std::set<int64_t> seq_num_keyframes_ GUARDED_BY(crit_);
stefan-webrtc 2016/02/26 09:26:55 std::set<uint16_t>, right?
philipel 2016/02/26 15:12:07 I use the unrolled sequence number as the key, may
98 bool running_ GUARDED_BY(crit_);
99 bool initialized_ GUARDED_BY(crit_);
100 int64_t rtt_ms_ GUARDED_BY(crit_);
101 uint16_t last_seq_num_ GUARDED_BY(crit_);
102 int64_t last_process_time_ms_ GUARDED_BY(crit_);
103
104 uint8_t reordering_index_ GUARDED_BY(crit_);
105 uint8_t reordering_count_ GUARDED_BY(crit_);
stefan-webrtc 2016/02/26 09:26:55 int
philipel 2016/02/26 15:12:07 Done.
106 int8_t reordering_occurences_[kMaxReorderedPackets] GUARDED_BY(crit_);
stefan-webrtc 2016/02/26 09:26:55 int
philipel 2016/02/26 15:12:07 Done.
107 uint8_t reordering_buckets_[kNumReorderingBuckets] GUARDED_BY(crit_);
stefan-webrtc 2016/02/26 09:26:55 int
philipel 2016/02/26 15:12:07 Done.
108 };
109
110 } // namespace webrtc
111
112 #endif // WEBRTC_MODULES_VIDEO_CODING_NACK_MODULE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698