| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_ | 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_ |
| 12 #define WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_ | 12 #define WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_ |
| 13 | 13 |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "webrtc/base/criticalsection.h" | 16 #include "webrtc/base/criticalsection.h" |
| 17 #include "webrtc/base/thread_annotations.h" | 17 #include "webrtc/base/thread_annotations.h" |
| 18 #include "webrtc/modules/include/module_common_types.h" | 18 #include "webrtc/modules/include/module_common_types.h" |
| 19 #include "webrtc/modules/video_coding/packet.h" | 19 #include "webrtc/modules/video_coding/packet.h" |
| 20 #include "webrtc/modules/video_coding/rtp_frame_reference_finder.h" | 20 #include "webrtc/modules/video_coding/rtp_frame_reference_finder.h" |
| 21 #include "webrtc/modules/video_coding/sequence_number_util.h" | 21 #include "webrtc/modules/video_coding/sequence_number_util.h" |
| 22 | 22 |
| 23 namespace webrtc { | 23 namespace webrtc { |
| 24 |
| 25 class Clock; |
| 26 |
| 24 namespace video_coding { | 27 namespace video_coding { |
| 25 | 28 |
| 26 class FrameObject; | 29 class FrameObject; |
| 27 class RtpFrameObject; | 30 class RtpFrameObject; |
| 28 | 31 |
| 29 class OnCompleteFrameCallback { | 32 class OnCompleteFrameCallback { |
| 30 public: | 33 public: |
| 31 virtual ~OnCompleteFrameCallback() {} | 34 virtual ~OnCompleteFrameCallback() {} |
| 32 virtual void OnCompleteFrame(std::unique_ptr<FrameObject> frame) = 0; | 35 virtual void OnCompleteFrame(std::unique_ptr<FrameObject> frame) = 0; |
| 33 }; | 36 }; |
| 34 | 37 |
| 35 class PacketBuffer { | 38 class PacketBuffer { |
| 36 public: | 39 public: |
| 37 // Both |start_buffer_size| and |max_buffer_size| must be a power of 2. | 40 // Both |start_buffer_size| and |max_buffer_size| must be a power of 2. |
| 38 PacketBuffer(size_t start_buffer_size, | 41 PacketBuffer(Clock* clock, |
| 42 size_t start_buffer_size, |
| 39 size_t max_buffer_size, | 43 size_t max_buffer_size, |
| 40 OnCompleteFrameCallback* frame_callback); | 44 OnCompleteFrameCallback* frame_callback); |
| 41 | 45 |
| 42 bool InsertPacket(const VCMPacket& packet); | 46 bool InsertPacket(const VCMPacket& packet); |
| 43 void ClearTo(uint16_t seq_num); | 47 void ClearTo(uint16_t seq_num); |
| 44 void Clear(); | 48 void Clear(); |
| 45 | 49 |
| 46 private: | 50 private: |
| 47 friend RtpFrameObject; | 51 friend RtpFrameObject; |
| 48 // Since we want the packet buffer to be as packet type agnostic | 52 // Since we want the packet buffer to be as packet type agnostic |
| (...skipping 12 matching lines...) Expand all Loading... |
| 61 // If this slot is currently used. | 65 // If this slot is currently used. |
| 62 bool used = false; | 66 bool used = false; |
| 63 | 67 |
| 64 // If all its previous packets have been inserted into the packet buffer. | 68 // If all its previous packets have been inserted into the packet buffer. |
| 65 bool continuous = false; | 69 bool continuous = false; |
| 66 | 70 |
| 67 // If this packet has been used to create a frame already. | 71 // If this packet has been used to create a frame already. |
| 68 bool frame_created = false; | 72 bool frame_created = false; |
| 69 }; | 73 }; |
| 70 | 74 |
| 75 Clock* const clock_; |
| 76 |
| 71 // Tries to expand the buffer. | 77 // Tries to expand the buffer. |
| 72 bool ExpandBufferSize() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 78 bool ExpandBufferSize() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
| 73 | 79 |
| 74 // Test if all previous packets has arrived for the given sequence number. | 80 // Test if all previous packets has arrived for the given sequence number. |
| 75 bool IsContinuous(uint16_t seq_num) const EXCLUSIVE_LOCKS_REQUIRED(crit_); | 81 bool IsContinuous(uint16_t seq_num) const EXCLUSIVE_LOCKS_REQUIRED(crit_); |
| 76 | 82 |
| 77 // Test if all packets of a frame has arrived, and if so, creates a frame. | 83 // Test if all packets of a frame has arrived, and if so, creates a frame. |
| 78 // May create multiple frames per invocation. | 84 // May create multiple frames per invocation. |
| 79 void FindFrames(uint16_t seq_num) EXCLUSIVE_LOCKS_REQUIRED(crit_); | 85 void FindFrames(uint16_t seq_num) EXCLUSIVE_LOCKS_REQUIRED(crit_); |
| 80 | 86 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 111 | 117 |
| 112 // Frames that have received all their packets are handed off to the | 118 // Frames that have received all their packets are handed off to the |
| 113 // |reference_finder_| which finds the dependencies between the frames. | 119 // |reference_finder_| which finds the dependencies between the frames. |
| 114 RtpFrameReferenceFinder reference_finder_; | 120 RtpFrameReferenceFinder reference_finder_; |
| 115 }; | 121 }; |
| 116 | 122 |
| 117 } // namespace video_coding | 123 } // namespace video_coding |
| 118 } // namespace webrtc | 124 } // namespace webrtc |
| 119 | 125 |
| 120 #endif // WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_ | 126 #endif // WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_ |
| OLD | NEW |