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

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

Issue 1961053002: Logic for finding frame references moved from PacketBuffer to new class (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Includes in order. Created 4 years, 7 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/rtp_frame_reference_finder.h
diff --git a/webrtc/modules/video_coding/packet_buffer.h b/webrtc/modules/video_coding/rtp_frame_reference_finder.h
similarity index 60%
copy from webrtc/modules/video_coding/packet_buffer.h
copy to webrtc/modules/video_coding/rtp_frame_reference_finder.h
index 8a1d7069f4e9e9d275f239553710668f35ab1e62..52eeaed7a8961be8ce2dc8c2eb7b7f0870bdba75 100644
--- a/webrtc/modules/video_coding/packet_buffer.h
+++ b/webrtc/modules/video_coding/rtp_frame_reference_finder.h
@@ -8,98 +8,41 @@
* 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_
+#ifndef WEBRTC_MODULES_VIDEO_CODING_RTP_FRAME_REFERENCE_FINDER_H_
+#define WEBRTC_MODULES_VIDEO_CODING_RTP_FRAME_REFERENCE_FINDER_H_
#include <array>
#include <map>
-#include <memory>
#include <queue>
#include <set>
#include <utility>
-#include <vector>
#include "webrtc/base/criticalsection.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/base/thread_annotations.h"
#include "webrtc/modules/include/module_common_types.h"
-#include "webrtc/modules/video_coding/packet.h"
#include "webrtc/modules/video_coding/sequence_number_util.h"
namespace webrtc {
namespace video_coding {
-class FrameObject;
class RtpFrameObject;
+class OnCompleteFrameCallback;
-class OnCompleteFrameCallback {
+class RtpFrameReferenceFinder {
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();
+ explicit RtpFrameReferenceFinder(OnCompleteFrameCallback* frame_callback);
+ void ManageFrame(std::unique_ptr<RtpFrameObject> frame);
private:
static const uint16_t kPicIdLength = 1 << 7;
static const uint8_t kMaxTemporalLayers = 5;
- static const int kMaxStashedFrames = 10;
static const int kMaxLayerInfo = 10;
+ static const int kMaxStashedFrames = 10;
static const int kMaxNotYetReceivedFrames = 20;
static const int kMaxGofSaved = 15;
- 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 determine whether a sequence of packets is continuous or not.
- struct ContinuityInfo {
- // The sequence number of the packet.
- uint16_t seq_num = 0;
-
- // If this is the first packet of the frame.
- bool frame_begin = false;
-
- // If this is the last packet of the frame.
- bool frame_end = false;
-
- // If this slot is currently used.
- bool used = false;
-
- // If all its previous packets have been inserted into the packet buffer.
- bool continuous = false;
-
- // If this packet has been used to create a frame already.
- bool frame_created = false;
- };
-
- // Expand the buffer.
- bool ExpandBufferSize() EXCLUSIVE_LOCKS_REQUIRED(crit_);
-
- // Test if all previous packets has arrived for the given sequence number.
- bool IsContinuous(uint16_t seq_num) const EXCLUSIVE_LOCKS_REQUIRED(crit_);
-
- // Test if all packets of a frame has arrived, and if so, creates a frame.
- // May create multiple frames per invocation.
- 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);
-
- // Mark all slots used by |frame| as not used.
- void ReturnFrame(RtpFrameObject* frame);
-
- // Find the references for this frame.
- void ManageFrame(std::unique_ptr<RtpFrameObject> frame)
- EXCLUSIVE_LOCKS_REQUIRED(crit_);
+ rtc::CriticalSection crit_;
// Retry finding references for all frames that previously didn't have
// all information needed.
@@ -146,39 +89,12 @@ class PacketBuffer {
uint16_t pid_ref) EXCLUSIVE_LOCKS_REQUIRED(crit_);
// All picture ids are unwrapped to 16 bits.
- uint16_t UnwrapPictureId(uint16_t picture_id)
- EXCLUSIVE_LOCKS_REQUIRED(crit_);
-
- 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_;
-
- // The fist sequence number currently in the buffer.
- uint16_t first_seq_num_ GUARDED_BY(crit_);
-
- // The last sequence number currently in the buffer.
- uint16_t last_seq_num_ GUARDED_BY(crit_);
-
- // If the packet buffer has received its first packet.
- bool first_packet_received_ GUARDED_BY(crit_);
-
- // Buffer that holds the inserted packets.
- std::vector<VCMPacket> data_buffer_ GUARDED_BY(crit_);
-
- // Buffer that holds the information about which slot that is currently in use
- // and information needed to determine the continuity between packets.
- std::vector<ContinuityInfo> sequence_buffer_ GUARDED_BY(crit_);
-
- // The callback that is called when a frame has been created and all its
- // references has been found.
- OnCompleteFrameCallback* const frame_callback_;
+ uint16_t UnwrapPictureId(uint16_t picture_id) EXCLUSIVE_LOCKS_REQUIRED(crit_);
// Holds the last sequence number of the last frame that has been created
// given the last sequence number of a given keyframe.
- std::map<uint16_t, uint16_t, DescendingSeqNumComp<uint16_t>>
- last_seq_num_gop_ GUARDED_BY(crit_);
+ std::map<uint16_t, uint16_t, DescendingSeqNumComp<uint16_t>> last_seq_num_gop_
+ GUARDED_BY(crit_);
// Save the last picture id in order to detect when there is a gap in frames
// that have not yet been fully received.
@@ -226,9 +142,11 @@ class PacketBuffer {
std::array<std::set<uint16_t, DescendingSeqNumComp<uint16_t, kPicIdLength>>,
kMaxTemporalLayers>
missing_frames_for_layer_ GUARDED_BY(crit_);
+
+ OnCompleteFrameCallback* frame_callback_;
};
} // namespace video_coding
} // namespace webrtc
-#endif // WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_
+#endif // WEBRTC_MODULES_VIDEO_CODING_RTP_FRAME_REFERENCE_FINDER_H_
« no previous file with comments | « webrtc/modules/video_coding/packet_buffer_unittest.cc ('k') | webrtc/modules/video_coding/rtp_frame_reference_finder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698