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 |
(...skipping 28 matching lines...) Expand all Loading... |
39 const VCMTiming* timing); | 39 const VCMTiming* timing); |
40 | 40 |
41 // Insert a frame into the frame buffer. | 41 // Insert a frame into the frame buffer. |
42 void InsertFrame(std::unique_ptr<FrameObject> frame); | 42 void InsertFrame(std::unique_ptr<FrameObject> frame); |
43 | 43 |
44 // Get the next frame for decoding. Will return at latest after | 44 // Get the next frame for decoding. Will return at latest after |
45 // |max_wait_time_ms|, with either a managed FrameObject or an empty | 45 // |max_wait_time_ms|, with either a managed FrameObject or an empty |
46 // unique ptr if there is no available frame for decoding. | 46 // unique ptr if there is no available frame for decoding. |
47 std::unique_ptr<FrameObject> NextFrame(int64_t max_wait_time_ms); | 47 std::unique_ptr<FrameObject> NextFrame(int64_t max_wait_time_ms); |
48 | 48 |
| 49 // Start the frame buffer, has no effect if the frame buffer is started. |
| 50 // The frame buffer is started upon construction. |
| 51 void Start(); |
| 52 |
| 53 // Stop the frame buffer, causing any sleeping thread in NextFrame to |
| 54 // return immediately. |
| 55 void Stop(); |
| 56 |
49 private: | 57 private: |
50 // FrameKey is a pair of (picture id, spatial layer). | 58 // FrameKey is a pair of (picture id, spatial layer). |
51 using FrameKey = std::pair<uint16_t, uint8_t>; | 59 using FrameKey = std::pair<uint16_t, uint8_t>; |
52 | 60 |
53 // Comparator used to sort frames, first on their picture id, and second | 61 // Comparator used to sort frames, first on their picture id, and second |
54 // on their spatial layer. | 62 // on their spatial layer. |
55 struct FrameComp { | 63 struct FrameComp { |
56 bool operator()(const FrameKey& f1, const FrameKey& f2) const; | 64 bool operator()(const FrameKey& f1, const FrameKey& f2) const; |
57 }; | 65 }; |
58 | 66 |
59 // Determines whether a frame is continuous. | 67 // Determines whether a frame is continuous. |
60 bool IsContinuous(const FrameObject& frame) const | 68 bool IsContinuous(const FrameObject& frame) const |
61 EXCLUSIVE_LOCKS_REQUIRED(crit_); | 69 EXCLUSIVE_LOCKS_REQUIRED(crit_); |
62 | 70 |
63 // Keep track of decoded frames. | 71 // Keep track of decoded frames. |
64 std::set<FrameKey, FrameComp> decoded_frames_ GUARDED_BY(crit_); | 72 std::set<FrameKey, FrameComp> decoded_frames_ GUARDED_BY(crit_); |
65 | 73 |
66 // The actual buffer that holds the FrameObjects. | 74 // The actual buffer that holds the FrameObjects. |
67 std::map<FrameKey, std::unique_ptr<FrameObject>, FrameComp> frames_ | 75 std::map<FrameKey, std::unique_ptr<FrameObject>, FrameComp> frames_ |
68 GUARDED_BY(crit_); | 76 GUARDED_BY(crit_); |
69 | 77 |
70 rtc::CriticalSection crit_; | 78 rtc::CriticalSection crit_; |
71 Clock* const clock_; | 79 Clock* const clock_; |
72 rtc::Event frame_inserted_event_; | 80 rtc::Event frame_inserted_event_; |
73 VCMJitterEstimator* const jitter_estimator_; | 81 VCMJitterEstimator* const jitter_estimator_; |
74 const VCMTiming* const timing_; | 82 const VCMTiming* const timing_; |
75 int newest_picture_id_ GUARDED_BY(crit_); | 83 int newest_picture_id_ GUARDED_BY(crit_); |
| 84 bool stopped_ GUARDED_BY(crit_); |
76 | 85 |
77 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(FrameBuffer); | 86 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(FrameBuffer); |
78 }; | 87 }; |
79 | 88 |
80 } // namespace video_coding | 89 } // namespace video_coding |
81 } // namespace webrtc | 90 } // namespace webrtc |
82 | 91 |
83 #endif // WEBRTC_MODULES_VIDEO_CODING_FRAME_BUFFER2_H_ | 92 #endif // WEBRTC_MODULES_VIDEO_CODING_FRAME_BUFFER2_H_ |
OLD | NEW |