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_FRAME_BUFFER2_H_ | 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_FRAME_BUFFER2_H_ |
12 #define WEBRTC_MODULES_VIDEO_CODING_FRAME_BUFFER2_H_ | 12 #define WEBRTC_MODULES_VIDEO_CODING_FRAME_BUFFER2_H_ |
13 | 13 |
14 #include <array> | 14 #include <array> |
15 #include <map> | 15 #include <map> |
16 #include <memory> | 16 #include <memory> |
17 #include <set> | 17 #include <set> |
18 #include <utility> | 18 #include <utility> |
19 | 19 |
20 #include "webrtc/base/constructormagic.h" | 20 #include "webrtc/base/constructormagic.h" |
21 #include "webrtc/base/criticalsection.h" | 21 #include "webrtc/base/criticalsection.h" |
22 #include "webrtc/base/event.h" | 22 #include "webrtc/base/event.h" |
23 #include "webrtc/base/thread_annotations.h" | 23 #include "webrtc/base/thread_annotations.h" |
| 24 #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
| 25 #include "webrtc/modules/video_coding/inter_frame_delay.h" |
24 | 26 |
25 namespace webrtc { | 27 namespace webrtc { |
26 | 28 |
27 class Clock; | 29 class Clock; |
28 class VCMJitterEstimator; | 30 class VCMJitterEstimator; |
29 class VCMTiming; | 31 class VCMTiming; |
30 | 32 |
31 namespace video_coding { | 33 namespace video_coding { |
32 | 34 |
33 class FrameObject; | 35 class FrameObject; |
34 | 36 |
35 class FrameBuffer { | 37 class FrameBuffer { |
36 public: | 38 public: |
37 FrameBuffer(Clock* clock, | 39 FrameBuffer(Clock* clock, |
38 VCMJitterEstimator* jitter_estimator, | 40 VCMJitterEstimator* jitter_estimator, |
39 const VCMTiming* timing); | 41 VCMTiming* timing); |
40 | 42 |
41 // Insert a frame into the frame buffer. | 43 // Insert a frame into the frame buffer. |
42 void InsertFrame(std::unique_ptr<FrameObject> frame); | 44 void InsertFrame(std::unique_ptr<FrameObject> frame); |
43 | 45 |
44 // Get the next frame for decoding. Will return at latest after | 46 // Get the next frame for decoding. Will return at latest after |
45 // |max_wait_time_ms|, with either a managed FrameObject or an empty | 47 // |max_wait_time_ms|, with either a managed FrameObject or an empty |
46 // unique ptr if there is no available frame for decoding. | 48 // unique ptr if there is no available frame for decoding. |
47 std::unique_ptr<FrameObject> NextFrame(int64_t max_wait_time_ms); | 49 std::unique_ptr<FrameObject> NextFrame(int64_t max_wait_time_ms); |
48 | 50 |
| 51 // Tells the FrameBuffer which protection mode that is in use. Affects |
| 52 // the frame timing. |
| 53 // TODO(philipel): Remove this when new timing calculations has been |
| 54 // implemented. |
| 55 void SetProtectionMode(VCMVideoProtection mode); |
| 56 |
49 // Start the frame buffer, has no effect if the frame buffer is started. | 57 // Start the frame buffer, has no effect if the frame buffer is started. |
50 // The frame buffer is started upon construction. | 58 // The frame buffer is started upon construction. |
51 void Start(); | 59 void Start(); |
52 | 60 |
53 // Stop the frame buffer, causing any sleeping thread in NextFrame to | 61 // Stop the frame buffer, causing any sleeping thread in NextFrame to |
54 // return immediately. | 62 // return immediately. |
55 void Stop(); | 63 void Stop(); |
56 | 64 |
57 private: | 65 private: |
58 // FrameKey is a pair of (picture id, spatial layer). | 66 // FrameKey is a pair of (picture id, spatial layer). |
(...skipping 12 matching lines...) Expand all Loading... |
71 // Keep track of decoded frames. | 79 // Keep track of decoded frames. |
72 std::set<FrameKey, FrameComp> decoded_frames_ GUARDED_BY(crit_); | 80 std::set<FrameKey, FrameComp> decoded_frames_ GUARDED_BY(crit_); |
73 | 81 |
74 // The actual buffer that holds the FrameObjects. | 82 // The actual buffer that holds the FrameObjects. |
75 std::map<FrameKey, std::unique_ptr<FrameObject>, FrameComp> frames_ | 83 std::map<FrameKey, std::unique_ptr<FrameObject>, FrameComp> frames_ |
76 GUARDED_BY(crit_); | 84 GUARDED_BY(crit_); |
77 | 85 |
78 rtc::CriticalSection crit_; | 86 rtc::CriticalSection crit_; |
79 Clock* const clock_; | 87 Clock* const clock_; |
80 rtc::Event frame_inserted_event_; | 88 rtc::Event frame_inserted_event_; |
81 VCMJitterEstimator* const jitter_estimator_; | 89 VCMJitterEstimator* const jitter_estimator_ GUARDED_BY(crit_); |
82 const VCMTiming* const timing_; | 90 VCMTiming* const timing_ GUARDED_BY(crit_); |
| 91 VCMInterFrameDelay inter_frame_delay_ GUARDED_BY(crit_); |
83 int newest_picture_id_ GUARDED_BY(crit_); | 92 int newest_picture_id_ GUARDED_BY(crit_); |
84 bool stopped_ GUARDED_BY(crit_); | 93 bool stopped_ GUARDED_BY(crit_); |
| 94 VCMVideoProtection protection_mode_ GUARDED_BY(crit_); |
85 | 95 |
86 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(FrameBuffer); | 96 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(FrameBuffer); |
87 }; | 97 }; |
88 | 98 |
89 } // namespace video_coding | 99 } // namespace video_coding |
90 } // namespace webrtc | 100 } // namespace webrtc |
91 | 101 |
92 #endif // WEBRTC_MODULES_VIDEO_CODING_FRAME_BUFFER2_H_ | 102 #endif // WEBRTC_MODULES_VIDEO_CODING_FRAME_BUFFER2_H_ |
OLD | NEW |