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

Side by Side Diff: media/base/video_capture_types.cc

Issue 2398813002: Cleanup of video capture into GpuMemoryBuffer (Closed)
Patch Set: Rebase Created 4 years, 2 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
« no previous file with comments | « media/base/video_capture_types.h ('k') | media/capture/video/fake_video_capture_device.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "media/base/video_capture_types.h" 5 #include "media/base/video_capture_types.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "media/base/limits.h" 10 #include "media/base/limits.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } 52 }
53 53
54 bool VideoCaptureFormat::IsValid() const { 54 bool VideoCaptureFormat::IsValid() const {
55 return (frame_size.width() < media::limits::kMaxDimension) && 55 return (frame_size.width() < media::limits::kMaxDimension) &&
56 (frame_size.height() < media::limits::kMaxDimension) && 56 (frame_size.height() < media::limits::kMaxDimension) &&
57 (frame_size.GetArea() >= 0) && 57 (frame_size.GetArea() >= 0) &&
58 (frame_size.GetArea() < media::limits::kMaxCanvas) && 58 (frame_size.GetArea() < media::limits::kMaxCanvas) &&
59 (frame_rate >= 0.0f) && 59 (frame_rate >= 0.0f) &&
60 (frame_rate < media::limits::kMaxFramesPerSecond) && 60 (frame_rate < media::limits::kMaxFramesPerSecond) &&
61 (pixel_format >= PIXEL_FORMAT_UNKNOWN && 61 (pixel_format >= PIXEL_FORMAT_UNKNOWN &&
62 pixel_format <= PIXEL_FORMAT_MAX) && 62 pixel_format <= PIXEL_FORMAT_MAX);
63 (pixel_storage == PIXEL_STORAGE_CPU ||
64 pixel_storage == PIXEL_STORAGE_GPUMEMORYBUFFER);
65 } 63 }
66 64
67 size_t VideoCaptureFormat::ImageAllocationSize() const { 65 size_t VideoCaptureFormat::ImageAllocationSize() const {
68 return VideoFrame::AllocationSize(pixel_format, frame_size); 66 return VideoFrame::AllocationSize(pixel_format, frame_size);
69 } 67 }
70 68
71 //static 69 //static
72 std::string VideoCaptureFormat::ToString(const VideoCaptureFormat& format) { 70 std::string VideoCaptureFormat::ToString(const VideoCaptureFormat& format) {
73 // Beware: This string is parsed by manager.js:parseVideoCaptureFormat_, 71 // Beware: This string is parsed by manager.js:parseVideoCaptureFormat_,
74 // take care when changing the formatting. 72 // take care when changing the formatting.
75 return base::StringPrintf( 73 return base::StringPrintf(
76 "(%s)@%.3ffps, pixel format: %s, storage: %s", 74 "(%s)@%.3ffps, pixel format: %s, storage: %s",
77 format.frame_size.ToString().c_str(), format.frame_rate, 75 format.frame_size.ToString().c_str(), format.frame_rate,
78 VideoPixelFormatToString(format.pixel_format).c_str(), 76 VideoPixelFormatToString(format.pixel_format).c_str(),
79 PixelStorageToString(format.pixel_storage).c_str()); 77 PixelStorageToString(format.pixel_storage).c_str());
80 } 78 }
81 79
82 // static 80 // static
83 std::string VideoCaptureFormat::PixelStorageToString( 81 std::string VideoCaptureFormat::PixelStorageToString(
84 VideoPixelStorage storage) { 82 VideoPixelStorage storage) {
85 switch (storage) { 83 switch (storage) {
86 case PIXEL_STORAGE_CPU: 84 case PIXEL_STORAGE_CPU:
87 return "CPU"; 85 return "CPU";
88 case PIXEL_STORAGE_GPUMEMORYBUFFER:
89 return "GPUMEMORYBUFFER";
90 } 86 }
91 NOTREACHED() << "Invalid VideoPixelStorage provided: " 87 NOTREACHED() << "Invalid VideoPixelStorage provided: "
92 << static_cast<int>(storage); 88 << static_cast<int>(storage);
93 return std::string(); 89 return std::string();
94 } 90 }
95 91
96 // static 92 // static
97 bool VideoCaptureFormat::ComparePixelFormatPreference( 93 bool VideoCaptureFormat::ComparePixelFormatPreference(
98 const VideoPixelFormat& lhs, 94 const VideoPixelFormat& lhs,
99 const VideoPixelFormat& rhs) { 95 const VideoPixelFormat& rhs) {
(...skipping 14 matching lines...) Expand all
114 110
115 bool VideoCaptureParams::IsValid() const { 111 bool VideoCaptureParams::IsValid() const {
116 return requested_format.IsValid() && 112 return requested_format.IsValid() &&
117 resolution_change_policy >= RESOLUTION_POLICY_FIXED_RESOLUTION && 113 resolution_change_policy >= RESOLUTION_POLICY_FIXED_RESOLUTION &&
118 resolution_change_policy <= RESOLUTION_POLICY_LAST && 114 resolution_change_policy <= RESOLUTION_POLICY_LAST &&
119 power_line_frequency >= PowerLineFrequency::FREQUENCY_DEFAULT && 115 power_line_frequency >= PowerLineFrequency::FREQUENCY_DEFAULT &&
120 power_line_frequency <= PowerLineFrequency::FREQUENCY_MAX; 116 power_line_frequency <= PowerLineFrequency::FREQUENCY_MAX;
121 } 117 }
122 118
123 } // namespace media 119 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_capture_types.h ('k') | media/capture/video/fake_video_capture_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698