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

Side by Side 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: Feedback fixes Created 4 years, 8 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_PACKET_BUFFER_H_
12 #define WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_
13
14 #include <vector>
15
16 #include "webrtc/base/criticalsection.h"
17 #include "webrtc/base/scoped_ptr.h"
18 #include "webrtc/base/thread_annotations.h"
19 #include "webrtc/modules/video_coding/packet.h"
20
21 namespace webrtc {
22 namespace video_coding {
23
24 class FrameObject;
25 class RtpFrameObject;
26
27 class OnCompleteFrameCallback {
28 public:
29 virtual ~OnCompleteFrameCallback() {}
30 virtual void OnCompleteFrame(std::unique_ptr<FrameObject> frame) = 0;
31 };
32
33 class PacketBuffer {
34 public:
35 PacketBuffer(size_t start_buffer_size,
stefan-webrtc 2016/03/30 11:59:32 Comment on power of 2 requirements.
philipel 2016/03/30 12:40:11 Done.
36 size_t max_buffer_size,
37 OnCompleteFrameCallback* frame_callback);
38 bool InsertPacket(const VCMPacket& packet);
39 void ClearUpTo(uint16_t seq_num);
40 void Flush();
41
42 private:
43 friend RtpFrameObject;
44 // Since we want the packet buffer to be as packet type agnostic
45 // as possible we extract only the information needed in order
46 // to determin whether a sequence of packets is continuous or not.
47 struct ContinuityInfo {
48 uint16_t seq_num = 0;
49 bool frame_begin = false;
50 bool frame_end = false;
51 bool used = false;
52 bool continuous = false;
53 };
54
55 bool ExpandBufferSize() EXCLUSIVE_LOCKS_REQUIRED(crit_);
56 bool IsContinuous(uint16_t seq_num) const EXCLUSIVE_LOCKS_REQUIRED(crit_);
57 void FindCompleteFrames(uint16_t seq_num) EXCLUSIVE_LOCKS_REQUIRED(crit_);
58 bool GetBitstream(const RtpFrameObject& frame, uint8_t* destination);
59 void ReturnFrame(RtpFrameObject* frame);
60
61 rtc::CriticalSection crit_;
62
63 // Buffer size_ and max_size_ must always be a power of two.
64 size_t size_ GUARDED_BY(crit_);
65 const size_t max_size_;
66
67 uint16_t clear_up_to_ GUARDED_BY(crit_);
68 bool initialized_ GUARDED_BY(crit_);
69 std::vector<VCMPacket> data_buffer_ GUARDED_BY(crit_);
70 std::vector<ContinuityInfo> sequence_buffer_ GUARDED_BY(crit_);
71
72
73 OnCompleteFrameCallback* const frame_callback_;
74 };
75
76 } // namespace video_coding
77 } // namespace webrtc
78
79 #endif // WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698