Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_FRAME_BUFFER2_H_ | |
| 12 #define WEBRTC_MODULES_VIDEO_CODING_FRAME_BUFFER2_H_ | |
| 13 | |
| 14 #include <array> | |
| 15 #include <map> | |
| 16 #include <memory> | |
| 17 #include <set> | |
| 18 #include <utility> | |
| 19 | |
| 20 #include "webrtc/base/criticalsection.h" | |
| 21 #include "webrtc/base/event.h" | |
| 22 #include "webrtc/base/thread_annotations.h" | |
| 23 | |
| 24 namespace webrtc { | |
| 25 | |
| 26 class Clock; | |
| 27 class VCMJitterEstimator; | |
| 28 class VCMTiming; | |
| 29 | |
| 30 namespace video_coding { | |
| 31 | |
| 32 class FrameObject; | |
| 33 | |
| 34 class FrameBuffer { | |
| 35 public: | |
| 36 FrameBuffer(Clock* clock, | |
| 37 VCMJitterEstimator* jitter_estimator, | |
| 38 const VCMTiming* timing); | |
| 39 | |
| 40 // Insert a frame into the frame buffer. | |
| 41 void InsertFrame(std::unique_ptr<FrameObject> frame); | |
| 42 | |
| 43 // Get the next frame for decoding. Will return at latest after | |
| 44 // |max_wait_time_ms|, with either a managed FrameObject or an empty | |
| 45 // unique ptr if there is no available frame for decoding. | |
| 46 std::unique_ptr<FrameObject> NextFrame(int64_t max_wait_time_ms); | |
| 47 | |
| 48 private: | |
| 49 // FrameKey is a pair of (picture id, spatial layer). | |
| 50 using FrameKey = std::pair<uint16_t, uint8_t>; | |
| 51 | |
| 52 // Comparator used to sort frames, first on their picture id, and second | |
| 53 // on their spatial layer. | |
| 54 struct FrameComp { | |
| 55 bool operator()(const FrameKey& f1, const FrameKey& f2) const; | |
| 56 }; | |
| 57 | |
| 58 // Determines whether a frame is continuous. | |
| 59 bool IsContinuous(const FrameObject& frame) const | |
| 60 EXCLUSIVE_LOCKS_REQUIRED(crit_); | |
| 61 | |
| 62 // Keep track of which decoded franes. | |
|
danilchap
2016/05/17 16:21:39
Keep track of decoded frames?
philipel
2016/05/18 09:00:56
Done.
| |
| 63 std::set<FrameKey, FrameComp> decoded_frames_ GUARDED_BY(crit_); | |
| 64 | |
| 65 // The actual buffer that holds the FrameObjects. | |
| 66 std::map<FrameKey, std::unique_ptr<FrameObject>, FrameComp> frames_ | |
| 67 GUARDED_BY(crit_); | |
| 68 | |
| 69 rtc::CriticalSection crit_; | |
| 70 Clock* const clock_; | |
| 71 rtc::Event frame_inserted_event_; | |
| 72 VCMJitterEstimator* const jitter_estimator_; | |
| 73 const VCMTiming* const timing_; | |
| 74 int newest_picture_id_ GUARDED_BY(crit_); | |
| 75 }; | |
| 76 | |
| 77 } // namespace video_coding | |
| 78 } // namespace webrtc | |
| 79 | |
| 80 #endif // WEBRTC_MODULES_VIDEO_CODING_FRAME_BUFFER2_H_ | |
| OLD | NEW |