Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | |
|
stefan-webrtc
2016/02/23 12:29:01
2016
| |
| 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 | |
| 17 #include "webrtc/base/thread_annotations.h" | |
| 18 #include "webrtc/modules/include/module.h" | |
| 19 #include "webrtc/modules/video_coding/include/video_coding_defines.h" | |
| 20 #include "webrtc/modules/video_coding/packet.h" | |
| 21 #include "webrtc/system_wrappers/include/clock.h" | |
| 22 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | |
| 23 | |
| 24 namespace webrtc { | |
| 25 | |
| 26 class NackModule : public Module { | |
|
stefan-webrtc
2016/02/23 12:29:01
It's difficult to see why this needs to be a Modul
philipel
2016/02/25 15:09:32
The reason this is a module is because it needs to
stefan-webrtc
2016/02/26 09:26:54
Maybe you should include the code which uses it in
philipel
2016/02/26 15:12:06
It is included in the NackModule::Process function
stefan-webrtc
2016/03/01 08:52:09
I'm talking about the code that registers the Nack
| |
| 27 public: | |
| 28 NackModule(CriticalSectionWrapper* critical_section, | |
| 29 Clock* clock, | |
| 30 VCMNackSender* nack_sender, | |
| 31 VCMKeyFrameRequestSender* keyframe_request_sender); | |
| 32 | |
| 33 ~NackModule(); | |
| 34 | |
| 35 void Notify(const VCMPacket& packet); | |
|
stefan-webrtc
2016/02/23 12:29:02
OnReceivedPacket, possibly?
philipel
2016/02/25 15:09:32
Done.
| |
| 36 void UpdateRtt(int64_t rtt_ms); | |
| 37 void Stop(); | |
| 38 | |
| 39 // Module implementation | |
| 40 int64_t TimeUntilNextProcess() override; | |
| 41 int32_t Process() override; | |
| 42 | |
| 43 private: | |
| 44 static const uint16_t kMaxNackPackets = 1000; | |
| 45 static const uint16_t kMaxReorderedPackets = 128; | |
| 46 static const uint16_t kNumReorderingBuckets = 5; | |
| 47 static const uint16_t kDefaultRttMs = 100; | |
| 48 static const uint8_t kMaxNackRetries = 10; | |
| 49 static const uint8_t kProcessFrequency = 50; | |
| 50 static const uint8_t kProcessIntervalMs = 1000 / kProcessFrequency; | |
|
stefan-webrtc
2016/02/23 12:29:02
Any reason we're mixing static constants defined i
philipel
2016/02/25 15:09:32
Earlier I had logic which used these constants as
stefan-webrtc
2016/02/26 09:26:54
I guess my question is, can we move more constants
philipel
2016/02/26 15:12:06
Sure!
| |
| 51 | |
| 52 struct NackInfo { | |
|
stefan-webrtc
2016/02/23 12:29:02
Could you add a comment which shortly describes wh
philipel
2016/02/25 15:09:32
Done.
| |
| 53 uint16_t seq_num; | |
| 54 uint16_t send_at_seq_num; | |
| 55 int64_t send_at_timestamp; | |
|
stefan-webrtc
2016/02/23 12:29:01
time_last_sent_ms?
philipel
2016/02/25 15:09:32
This is the timestamp at which this nack should be
| |
| 56 uint8_t retries; | |
|
stefan-webrtc
2016/02/23 12:29:02
int
philipel
2016/02/25 15:09:32
Done.
| |
| 57 | |
| 58 NackInfo(); | |
| 59 NackInfo(uint16_t seq_num, uint16_t send_at_seq_num); | |
|
stefan-webrtc
2016/02/23 12:29:02
Constructors at the top.
philipel
2016/02/25 15:09:32
Done.
| |
| 60 }; | |
| 61 | |
| 62 void AddPacketsToNack(uint16_t seq_num_start, uint16_t seq_num_end) | |
| 63 EXCLUSIVE_LOCKS_REQUIRED(critical_section_); | |
| 64 void RemovePacketFromNack(uint16_t seq_num) | |
| 65 EXCLUSIVE_LOCKS_REQUIRED(critical_section_); | |
| 66 std::vector<uint16_t> GetNackBatch(bool consider_seq_num, | |
| 67 bool consider_timestamp) | |
| 68 EXCLUSIVE_LOCKS_REQUIRED(critical_section_); | |
| 69 | |
| 70 // Update the reordering distribution. | |
| 71 void UpdateReorderingStatistics(uint16_t seq_num) | |
| 72 EXCLUSIVE_LOCKS_REQUIRED(critical_section_); | |
| 73 | |
| 74 // Returns how many packets we have to wait in order to receive | |
| 75 // the packet with probability |probabilty| or higher. | |
| 76 uint8_t WaitNumberOfPackets(float probability) const | |
| 77 EXCLUSIVE_LOCKS_REQUIRED(critical_section_); | |
| 78 | |
| 79 CriticalSectionWrapper* critical_section_; | |
|
stefan-webrtc
2016/02/23 12:29:01
Prefer keeping this shorter, e.g., crit_ which is
philipel
2016/02/25 15:09:32
NackModule now has its own rtc::CriticalSection cr
| |
| 80 Clock* clock_; | |
|
stefan-webrtc
2016/02/23 12:29:01
Clock* const
philipel
2016/02/25 15:09:32
Done.
| |
| 81 VCMNackSender* nack_sender_; | |
| 82 VCMKeyFrameRequestSender* keyframe_request_sender_; | |
|
stefan-webrtc
2016/02/23 12:29:02
Can these two be const too?
philipel
2016/02/25 15:09:32
Done.
| |
| 83 | |
| 84 typedef std::map<uint16_t, NackInfo> NackList; | |
|
stefan-webrtc
2016/02/23 12:29:01
I think we can live without this typedef now that
philipel
2016/02/25 15:09:32
Done.
| |
| 85 NackList nack_list_ GUARDED_BY(critical_section_); | |
| 86 | |
| 87 bool running_ GUARDED_BY(critical_section_); | |
| 88 uint16_t last_seq_num_ GUARDED_BY(critical_section_); | |
|
stefan-webrtc
2016/02/23 12:29:01
Move this down to the other last_ members.
philipel
2016/02/25 15:09:32
Done.
| |
| 89 bool initialized_ GUARDED_BY(critical_section_); | |
| 90 int64_t rtt_ms_ GUARDED_BY(critical_section_); | |
| 91 int64_t last_process_timestamp_ms_ GUARDED_BY(critical_section_); | |
| 92 uint16_t last_keyframe_seq_num_ GUARDED_BY(critical_section_); | |
| 93 | |
| 94 uint8_t reordering_index_ GUARDED_BY(critical_section_); | |
| 95 uint8_t reordering_count_ GUARDED_BY(critical_section_); | |
| 96 int8_t reordering_occurences_[kMaxReorderedPackets] GUARDED_BY( | |
| 97 critical_section_); | |
| 98 uint8_t reordering_buckets_[kNumReorderingBuckets] GUARDED_BY( | |
| 99 critical_section_); | |
|
stefan-webrtc
2016/02/23 12:29:02
Most members are protected by critical_section_. C
philipel
2016/02/25 15:09:32
My understanding of most classes is that almost ev
stefan-webrtc
2016/02/26 09:26:55
Right, but I think it would be good to go over wha
philipel
2016/02/26 15:12:06
Sure, I will add it to the next patch set.
| |
| 100 }; | |
| 101 | |
| 102 } // namespace webrtc | |
| 103 | |
| 104 #endif // WEBRTC_MODULES_VIDEO_CODING_NACK_MODULE_H_ | |
| OLD | NEW |