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

Unified Diff: content/renderer/media/canvas_capture_handler.cc

Issue 2590823004: Avoid float-cast-overflow in content::VideoCapturerSource::GetCurrentSupportedFormats (Closed)
Patch Set: Created 4 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/canvas_capture_handler.cc
diff --git a/content/renderer/media/canvas_capture_handler.cc b/content/renderer/media/canvas_capture_handler.cc
index e289fd46dcec3610394a2e3f6dc2b627d18eb257..038b5e4dc9d7e2712fa3c3c2181790b4c51e4bb7 100644
--- a/content/renderer/media/canvas_capture_handler.cc
+++ b/content/renderer/media/canvas_capture_handler.cc
@@ -17,6 +17,7 @@
#include "content/renderer/media/media_stream_video_track.h"
#include "content/renderer/media/webrtc_uma_histograms.h"
#include "content/renderer/render_thread_impl.h"
+#include "media/base/limits.h"
#include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/libyuv/include/libyuv.h"
@@ -38,11 +39,14 @@ namespace content {
// This class is single threaded and pinned to main render thread.
class VideoCapturerSource : public media::VideoCapturerSource {
public:
- explicit VideoCapturerSource(base::WeakPtr<CanvasCaptureHandler>
- canvas_handler,
- double frame_rate)
- : frame_rate_(frame_rate),
- canvas_handler_(canvas_handler) {}
+ VideoCapturerSource(base::WeakPtr<CanvasCaptureHandler> canvas_handler,
+ double frame_rate)
+ : frame_rate_(static_cast<float>(
+ std::min(static_cast<double>(media::limits::kMaxFramesPerSecond),
+ frame_rate))),
+ canvas_handler_(canvas_handler) {
+ DCHECK_LE(0, frame_rate_);
+ }
protected:
void GetCurrentSupportedFormats(
@@ -79,7 +83,7 @@ class VideoCapturerSource : public media::VideoCapturerSource {
}
private:
- const double frame_rate_;
+ const float frame_rate_;
// Bound to Main Render thread.
base::ThreadChecker main_render_thread_checker_;
// CanvasCaptureHandler is owned by CanvasDrawListener in blink and might be
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698