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

Unified 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: Implemented reordering statistics in separate class. Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/video_coding/nack_module.h
diff --git a/webrtc/modules/video_coding/nack_module.h b/webrtc/modules/video_coding/nack_module.h
new file mode 100644
index 0000000000000000000000000000000000000000..c36c93c976da62166c8bcee30a8c13e4cbd13237
--- /dev/null
+++ b/webrtc/modules/video_coding/nack_module.h
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_MODULES_VIDEO_CODING_NACK_MODULE_H_
+#define WEBRTC_MODULES_VIDEO_CODING_NACK_MODULE_H_
+
+#include <map>
+#include <vector>
+#include <set>
+
+#include "webrtc/base/thread_annotations.h"
+#include "webrtc/base/thread_checker.h"
stefan-webrtc 2016/03/01 08:52:10 Currently not used
philipel 2016/03/01 10:27:07 Done.
+#include "webrtc/modules/include/module.h"
+#include "webrtc/modules/video_coding/include/video_coding_defines.h"
+#include "webrtc/modules/video_coding/packet.h"
+#include "webrtc/modules/video_coding/distribution.h"
+#include "webrtc/system_wrappers/include/clock.h"
+#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
stefan-webrtc 2016/03/01 08:52:10 Use webrtc/base/criticalsection.h instead
philipel 2016/03/01 10:27:07 Done.
+
+namespace webrtc {
+
+class NackModule : public Module {
+ public:
+ NackModule(Clock* clock,
+ VCMNackSender* nack_sender,
+ VCMKeyFrameRequestSender* keyframe_request_sender);
+
+ void OnReceivedPacket(const VCMPacket& packet);
+ void ClearUpTo(uint16_t seq_num);
+ void UpdateRtt(int64_t rtt_ms);
+ void Stop();
+
+ // Module implementation
+ int64_t TimeUntilNextProcess() override;
+ int32_t Process() override;
+
+ private:
+ // Which fields to consider when deciding
+ // which packet to nack in GetNackBatch.
stefan-webrtc 2016/03/01 08:52:11 Format comment so that it uses the full line lengt
philipel 2016/03/01 10:27:06 Done.
+ enum NackFilterOptions {kSeqNumOnly, kTimeOnly, kSeqNumAndTime};
stefan-webrtc 2016/03/01 08:52:10 kSeqNumAndTime doesn't seem to be used?
+
+ // This class holds the sequence number of the packet that is in the nack list
+ // as well as the meta data about when it should be nacked and how many times
+ // we have tried to nack this packet.
+ struct NackInfo {
+ NackInfo();
+ NackInfo(uint16_t seq_num, uint16_t send_at_seq_num);
+
+ uint16_t seq_num;
+ uint16_t send_at_seq_num;
+ int64_t sent_at_time;
+ int retries;
+ };
+
+ void AddPacketsToNack(uint16_t seq_num_start, uint16_t seq_num_end)
+ EXCLUSIVE_LOCKS_REQUIRED(crit_);
+
+ // Removes packets from the nack list until the next
+ // keyframe. Returns true if packets were removed.
stefan-webrtc 2016/03/01 08:52:11 Reformat
philipel 2016/03/01 10:27:06 Done.
+ bool RemovePacketsUntilKeyframe()
+ EXCLUSIVE_LOCKS_REQUIRED(crit_);
+ void RemovePacketFromNack(uint16_t seq_num)
+ EXCLUSIVE_LOCKS_REQUIRED(crit_);
+ std::vector<uint16_t> GetNackBatch(NackFilterOptions options)
+ EXCLUSIVE_LOCKS_REQUIRED(crit_);
+
+ // Update the reordering distribution.
+ void UpdateReorderingStatistics(uint16_t seq_num)
+ EXCLUSIVE_LOCKS_REQUIRED(crit_);
+
+ // Returns how many packets we have to wait in order to receive
+ // the packet with probability |probabilty| or higher.
stefan-webrtc 2016/03/01 08:52:11 Reformat
philipel 2016/03/01 10:27:06 Done.
+ int WaitNumberOfPackets(float probability) const
+ EXCLUSIVE_LOCKS_REQUIRED(crit_);
+
+ rtc::CriticalSection crit_;
stefan-webrtc 2016/03/01 08:52:11 Maybe move the crit down to the group of members t
philipel 2016/03/01 10:27:06 Acknowledged.
+ Clock* const clock_;
+ VCMNackSender* const nack_sender_;
+ VCMKeyFrameRequestSender* const keyframe_request_sender_;
+
+ struct SeqNumComparator {
+ SeqNumComparator() {
+ // Alowes the comparator to wrap back one time in order to compare
+ // sequence numbers before an actual wrap has occured.
+ unwrapper_.UpdateLast(0x20000);
+ }
+ bool operator()(uint16_t s1, uint16_t s2) {
+ return unwrapper_.Unwrap(s1) < unwrapper_.Unwrap(s2);
+ }
+ SequenceNumberUnwrapper unwrapper_;
stefan-webrtc 2016/03/01 08:52:10 I'd prefer to get rid of the state and instead bui
philipel 2016/03/01 10:27:06 Done.
+ };
+
+ std::map<int16_t, NackInfo, SeqNumComparator> nack_list_ GUARDED_BY(crit_);
stefan-webrtc 2016/03/01 08:52:10 Comment on what the int16_t represent here and bel
philipel 2016/03/01 10:27:06 Yes, should be uint16_t.
+ std::set<int16_t, SeqNumComparator> keyframe_list_ GUARDED_BY(crit_);
+ Distribution reordering_distribution_;
+ bool running_ GUARDED_BY(crit_);
+ bool initialized_ GUARDED_BY(crit_);
+ int64_t rtt_ms_ GUARDED_BY(crit_);
+ uint16_t last_seq_num_ GUARDED_BY(crit_);
+ int64_t next_process_time_ms_ GUARDED_BY(crit_);
+};
+
+} // namespace webrtc
+
+#endif // WEBRTC_MODULES_VIDEO_CODING_NACK_MODULE_H_

Powered by Google App Engine
This is Rietveld 408576698