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

Unified Diff: webrtc/modules/video_coding/packet_buffer.h

Issue 1772383002: Packet buffer for the new jitter buffer. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: More parenthesis for the buildbots! 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/video_coding/frame_object.cc ('k') | webrtc/modules/video_coding/packet_buffer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/video_coding/packet_buffer.h
diff --git a/webrtc/modules/video_coding/packet_buffer.h b/webrtc/modules/video_coding/packet_buffer.h
new file mode 100644
index 0000000000000000000000000000000000000000..6ca514536ef942fe1c1c454db7036e19ba4d485e
--- /dev/null
+++ b/webrtc/modules/video_coding/packet_buffer.h
@@ -0,0 +1,81 @@
+/*
+ * 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_PACKET_BUFFER_H_
+#define WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_
+
+#include <vector>
+
+#include "webrtc/base/criticalsection.h"
+#include "webrtc/base/scoped_ptr.h"
+#include "webrtc/base/thread_annotations.h"
+#include "webrtc/modules/video_coding/packet.h"
+
+namespace webrtc {
+namespace video_coding {
+
+class FrameObject;
+class RtpFrameObject;
+
+class OnCompleteFrameCallback {
+ public:
+ virtual ~OnCompleteFrameCallback() {}
+ virtual void OnCompleteFrame(std::unique_ptr<FrameObject> frame) = 0;
+};
+
+class PacketBuffer {
+ public:
+ // Both |start_buffer_size| and |max_buffer_size| must be a power of 2.
+ PacketBuffer(size_t start_buffer_size,
+ size_t max_buffer_size,
+ OnCompleteFrameCallback* frame_callback);
+
+ bool InsertPacket(const VCMPacket& packet);
+ void ClearTo(uint16_t seq_num);
+ void Flush();
+
+ private:
+ friend RtpFrameObject;
+ // Since we want the packet buffer to be as packet type agnostic
+ // as possible we extract only the information needed in order
+ // to determin whether a sequence of packets is continuous or not.
+ struct ContinuityInfo {
+ uint16_t seq_num = 0;
+ bool frame_begin = false;
+ bool frame_end = false;
+ bool used = false;
+ bool continuous = false;
+ };
+
+ bool ExpandBufferSize() EXCLUSIVE_LOCKS_REQUIRED(crit_);
+ bool IsContinuous(uint16_t seq_num) const EXCLUSIVE_LOCKS_REQUIRED(crit_);
+ void FindCompleteFrames(uint16_t seq_num) EXCLUSIVE_LOCKS_REQUIRED(crit_);
+ bool GetBitstream(const RtpFrameObject& frame, uint8_t* destination);
+ void ReturnFrame(RtpFrameObject* frame);
+
+ rtc::CriticalSection crit_;
+
+ // Buffer size_ and max_size_ must always be a power of two.
+ size_t size_ GUARDED_BY(crit_);
+ const size_t max_size_;
+
+ uint16_t last_seq_num_ GUARDED_BY(crit_);
+ uint16_t first_seq_num_ GUARDED_BY(crit_);
+ bool initialized_ GUARDED_BY(crit_);
+ std::vector<VCMPacket> data_buffer_ GUARDED_BY(crit_);
+ std::vector<ContinuityInfo> sequence_buffer_ GUARDED_BY(crit_);
+
+ OnCompleteFrameCallback* const frame_callback_;
+};
+
+} // namespace video_coding
+} // namespace webrtc
+
+#endif // WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_
« no previous file with comments | « webrtc/modules/video_coding/frame_object.cc ('k') | webrtc/modules/video_coding/packet_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698