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

Side by Side Diff: content/browser/media/capture/video_capture_oracle.cc

Issue 1146723002: New FRAME_DURATION VideoFrameMetadata, with Cast Streaming use case. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Expanded comments for VideoFrameMetadata::FRAME_DURATION. Created 5 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/media/capture/video_capture_oracle.h" 5 #include "content/browser/media/capture/video_capture_oracle.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 DCHECK_GE(event, 0); 53 DCHECK_GE(event, 0);
54 DCHECK_LT(event, kNumEvents); 54 DCHECK_LT(event, kNumEvents);
55 if (event_time < last_event_time_[event]) { 55 if (event_time < last_event_time_[event]) {
56 LOG(WARNING) << "Event time is not monotonically non-decreasing. " 56 LOG(WARNING) << "Event time is not monotonically non-decreasing. "
57 << "Deciding not to capture this frame."; 57 << "Deciding not to capture this frame.";
58 return false; 58 return false;
59 } 59 }
60 last_event_time_[event] = event_time; 60 last_event_time_[event] = event_time;
61 61
62 bool should_sample; 62 bool should_sample;
63 duration_of_next_frame_ = base::TimeDelta();
63 switch (event) { 64 switch (event) {
64 case kCompositorUpdate: 65 case kCompositorUpdate:
65 smoothing_sampler_.ConsiderPresentationEvent(event_time); 66 smoothing_sampler_.ConsiderPresentationEvent(event_time);
66 content_sampler_.ConsiderPresentationEvent(damage_rect, event_time); 67 content_sampler_.ConsiderPresentationEvent(damage_rect, event_time);
67 if (content_sampler_.HasProposal()) { 68 if (content_sampler_.HasProposal()) {
68 should_sample = content_sampler_.ShouldSample(); 69 should_sample = content_sampler_.ShouldSample();
69 if (should_sample) 70 if (should_sample) {
70 event_time = content_sampler_.frame_timestamp(); 71 event_time = content_sampler_.frame_timestamp();
72 duration_of_next_frame_ = content_sampler_.sampling_period();
73 }
71 } else { 74 } else {
72 should_sample = smoothing_sampler_.ShouldSample(); 75 should_sample = smoothing_sampler_.ShouldSample();
76 if (should_sample)
77 duration_of_next_frame_ = smoothing_sampler_.min_capture_period();
73 } 78 }
74 break; 79 break;
75 default: 80 default:
76 should_sample = smoothing_sampler_.IsOverdueForSamplingAt(event_time); 81 should_sample = smoothing_sampler_.IsOverdueForSamplingAt(event_time);
82 if (should_sample)
83 duration_of_next_frame_ = smoothing_sampler_.min_capture_period();
77 break; 84 break;
78 } 85 }
79 86
80 SetFrameTimestamp(frame_number_, event_time); 87 SetFrameTimestamp(frame_number_, event_time);
81 return should_sample; 88 return should_sample;
82 } 89 }
83 90
84 int VideoCaptureOracle::RecordCapture() { 91 int VideoCaptureOracle::RecordCapture() {
85 smoothing_sampler_.RecordSample(); 92 smoothing_sampler_.RecordSample();
86 content_sampler_.RecordSample(GetFrameTimestamp(frame_number_)); 93 content_sampler_.RecordSample(GetFrameTimestamp(frame_number_));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 DCHECK_LT(frame_number_ - frame_number, kMaxFrameTimestamps); 145 DCHECK_LT(frame_number_ - frame_number, kMaxFrameTimestamps);
139 return frame_timestamps_[frame_number % kMaxFrameTimestamps]; 146 return frame_timestamps_[frame_number % kMaxFrameTimestamps];
140 } 147 }
141 148
142 void VideoCaptureOracle::SetFrameTimestamp(int frame_number, 149 void VideoCaptureOracle::SetFrameTimestamp(int frame_number,
143 base::TimeTicks timestamp) { 150 base::TimeTicks timestamp) {
144 frame_timestamps_[frame_number % kMaxFrameTimestamps] = timestamp; 151 frame_timestamps_[frame_number % kMaxFrameTimestamps] = timestamp;
145 } 152 }
146 153
147 } // namespace content 154 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/media/capture/video_capture_oracle.h ('k') | content/browser/media/capture/video_capture_oracle_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698