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

Unified Diff: webrtc/modules/video_coding/frame_buffer2.cc

Issue 2105323002: FrameBuffer2 now has Start/Stop methods. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « webrtc/modules/video_coding/frame_buffer2.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/video_coding/frame_buffer2.cc
diff --git a/webrtc/modules/video_coding/frame_buffer2.cc b/webrtc/modules/video_coding/frame_buffer2.cc
index c6a1a06e7563eeab1a96acdb1eeb4858f6d74822..8a3f43686ee65138f13e0a19002fb1da9f6b9e37 100644
--- a/webrtc/modules/video_coding/frame_buffer2.cc
+++ b/webrtc/modules/video_coding/frame_buffer2.cc
@@ -47,16 +47,21 @@ FrameBuffer::FrameBuffer(Clock* clock,
frame_inserted_event_(false, false),
jitter_estimator_(jitter_estimator),
timing_(timing),
- newest_picture_id_(-1) {}
+ newest_picture_id_(-1),
+ stopped_(false) {}
std::unique_ptr<FrameObject> FrameBuffer::NextFrame(int64_t max_wait_time_ms) {
int64_t latest_return_time = clock_->TimeInMilliseconds() + max_wait_time_ms;
while (true) {
- int64_t now = clock_->TimeInMilliseconds();
- int64_t wait_ms = max_wait_time_ms;
-
crit_.Enter();
pbos-webrtc 2016/06/29 15:51:26 Can you replace these explicit enters with rtc::Cr
philipel 2016/06/30 09:36:56 Sorry, scopes wont work throughout this functions,
pbos-webrtc 2016/06/30 09:44:07 What do you mean? Have one scoped between line 56
philipel 2016/06/30 11:37:35 The problem is the |next_frame| iterator which we
pbos-webrtc 2016/06/30 12:04:53 Can frames_' size be modified while the lock is dr
philipel 2016/06/30 12:20:04 You can't call frames_.size() while not holding th
frame_inserted_event_.Reset();
+ if (stopped_) {
+ crit_.Leave();
+ return std::unique_ptr<FrameObject>();
+ }
+
+ int64_t now = clock_->TimeInMilliseconds();
+ int64_t wait_ms = max_wait_time_ms;
auto next_frame = frames_.end();
for (auto frame_it = frames_.begin(); frame_it != frames_.end();
++frame_it) {
@@ -100,6 +105,17 @@ std::unique_ptr<FrameObject> FrameBuffer::NextFrame(int64_t max_wait_time_ms) {
}
}
+void FrameBuffer::Start() {
+ rtc::CritScope lock(&crit_);
+ stopped_ = false;
+}
+
+void FrameBuffer::Stop() {
+ rtc::CritScope lock(&crit_);
+ stopped_ = true;
+ frame_inserted_event_.Set();
+}
+
void FrameBuffer::InsertFrame(std::unique_ptr<FrameObject> frame) {
rtc::CritScope lock(&crit_);
if (newest_picture_id_ == -1)
« no previous file with comments | « webrtc/modules/video_coding/frame_buffer2.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698