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

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

Issue 2199133004: PacketBuffer is now ref counted. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Moved RtpFrameReferenceFinder out of PacketBuffer. Created 4 years, 4 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/packet_buffer.h
diff --git a/webrtc/modules/video_coding/packet_buffer.h b/webrtc/modules/video_coding/packet_buffer.h
index ec187de086506c7056373b31fd2184d63dddddfb..706a35b72099f0108c31cae627c60214d051a0af 100644
--- a/webrtc/modules/video_coding/packet_buffer.h
+++ b/webrtc/modules/video_coding/packet_buffer.h
@@ -14,6 +14,7 @@
#include <vector>
#include "webrtc/base/criticalsection.h"
+#include "webrtc/base/scoped_ref_ptr.h"
#include "webrtc/base/thread_annotations.h"
#include "webrtc/modules/include/module_common_types.h"
#include "webrtc/modules/video_coding/packet.h"
@@ -29,23 +30,36 @@ namespace video_coding {
class FrameObject;
class RtpFrameObject;
-class OnCompleteFrameCallback {
+// A received frame is a frame which has received all its packets.
+class OnReceivedFrameCallback {
public:
- virtual ~OnCompleteFrameCallback() {}
- virtual void OnCompleteFrame(std::unique_ptr<FrameObject> frame) = 0;
+ virtual ~OnReceivedFrameCallback() {}
+ virtual void OnReceivedFrame(std::unique_ptr<RtpFrameObject> frame) = 0;
};
class PacketBuffer {
public:
+ static rtc::scoped_refptr<PacketBuffer> Create(
+ Clock* clock,
+ size_t start_buffer_size,
+ size_t max_buffer_size,
+ OnReceivedFrameCallback* frame_callback);
+
+ virtual bool InsertPacket(const VCMPacket& packet);
danilchap 2016/08/04 16:03:09 add a comment that you make it virtual for testing
philipel 2016/08/08 13:34:57 Done.
+ void ClearTo(uint16_t seq_num);
+ void Clear();
+
+ int AddRef() const;
+ int Release() const;
+
+ virtual ~PacketBuffer();
danilchap 2016/08/04 16:03:09 destructor should be before other functions (inclu
philipel 2016/08/08 13:34:57 Done.
danilchap 2016/08/08 14:49:31 Almost, unless you treat Create as a constructor.
philipel 2016/08/08 15:02:43 I think it's reasonable to consider the Create fun
+
+ protected:
// Both |start_buffer_size| and |max_buffer_size| must be a power of 2.
PacketBuffer(Clock* clock,
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 Clear();
+ OnReceivedFrameCallback* frame_callback);
private:
friend RtpFrameObject;
@@ -85,13 +99,13 @@ class PacketBuffer {
void FindFrames(uint16_t seq_num) EXCLUSIVE_LOCKS_REQUIRED(crit_);
// Copy the bitstream for |frame| to |destination|.
- bool GetBitstream(const RtpFrameObject& frame, uint8_t* destination);
+ virtual bool GetBitstream(const RtpFrameObject& frame, uint8_t* destination);
// Get the packet with sequence number |seq_num|.
- VCMPacket* GetPacket(uint16_t seq_num);
+ virtual VCMPacket* GetPacket(uint16_t seq_num);
// Mark all slots used by |frame| as not used.
- void ReturnFrame(RtpFrameObject* frame);
+ virtual void ReturnFrame(RtpFrameObject* frame);
rtc::CriticalSection crit_;
@@ -115,9 +129,10 @@ class PacketBuffer {
// and information needed to determine the continuity between packets.
std::vector<ContinuityInfo> sequence_buffer_ GUARDED_BY(crit_);
- // Frames that have received all their packets are handed off to the
- // |reference_finder_| which finds the dependencies between the frames.
- RtpFrameReferenceFinder reference_finder_;
+ // Called when a received frame is found.
+ OnReceivedFrameCallback* received_frame_callback_ GUARDED_BY(crit_);
danilchap 2016/08/04 16:03:09 OnReceivedFrameCallback* const received_frame_call
philipel 2016/08/08 13:34:57 Now const and removed GUARDED_BY
+
+ mutable volatile int ref_count_ = 0;
};
} // namespace video_coding

Powered by Google App Engine
This is Rietveld 408576698