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

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

Issue 1211273005: Use safer IPC serializations in media_param_traits.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up unit tests Created 5 years, 5 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') | no next file » | 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/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "media/base/limits.h" 9 #include "media/base/limits.h"
10 10
(...skipping 24 matching lines...) Expand all
35 pixel_storage(pixel_storage) { 35 pixel_storage(pixel_storage) {
36 } 36 }
37 37
38 bool VideoCaptureFormat::IsValid() const { 38 bool VideoCaptureFormat::IsValid() const {
39 return (frame_size.width() < media::limits::kMaxDimension) && 39 return (frame_size.width() < media::limits::kMaxDimension) &&
40 (frame_size.height() < media::limits::kMaxDimension) && 40 (frame_size.height() < media::limits::kMaxDimension) &&
41 (frame_size.GetArea() >= 0) && 41 (frame_size.GetArea() >= 0) &&
42 (frame_size.GetArea() < media::limits::kMaxCanvas) && 42 (frame_size.GetArea() < media::limits::kMaxCanvas) &&
43 (frame_rate >= 0.0f) && 43 (frame_rate >= 0.0f) &&
44 (frame_rate < media::limits::kMaxFramesPerSecond) && 44 (frame_rate < media::limits::kMaxFramesPerSecond) &&
45 (pixel_format >= 0) && (pixel_format < PIXEL_FORMAT_MAX) &&
46 (pixel_storage != PIXEL_STORAGE_TEXTURE || 45 (pixel_storage != PIXEL_STORAGE_TEXTURE ||
47 pixel_format == PIXEL_FORMAT_ARGB); 46 pixel_format == PIXEL_FORMAT_ARGB);
48 } 47 }
49 48
50 size_t VideoCaptureFormat::ImageAllocationSize() const { 49 size_t VideoCaptureFormat::ImageAllocationSize() const {
51 size_t result_frame_size = frame_size.GetArea(); 50 size_t result_frame_size = frame_size.GetArea();
52 switch (pixel_format) { 51 switch (pixel_format) {
53 case PIXEL_FORMAT_I420: 52 case PIXEL_FORMAT_I420:
54 case PIXEL_FORMAT_YV12: 53 case PIXEL_FORMAT_YV12:
55 case PIXEL_FORMAT_NV12: 54 case PIXEL_FORMAT_NV12:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 case PIXEL_FORMAT_ARGB: 101 case PIXEL_FORMAT_ARGB:
103 return "ARGB"; 102 return "ARGB";
104 case PIXEL_FORMAT_MJPEG: 103 case PIXEL_FORMAT_MJPEG:
105 return "MJPEG"; 104 return "MJPEG";
106 case PIXEL_FORMAT_NV12: 105 case PIXEL_FORMAT_NV12:
107 return "NV12"; 106 return "NV12";
108 case PIXEL_FORMAT_NV21: 107 case PIXEL_FORMAT_NV21:
109 return "NV21"; 108 return "NV21";
110 case PIXEL_FORMAT_YV12: 109 case PIXEL_FORMAT_YV12:
111 return "YV12"; 110 return "YV12";
112 case PIXEL_FORMAT_MAX:
113 break;
114 } 111 }
115 NOTREACHED() << "Invalid VideoPixelFormat provided: " << format; 112 NOTREACHED() << "Invalid VideoPixelFormat provided: " << format;
116 return std::string(); 113 return std::string();
117 } 114 }
118 115
119 //static 116 //static
120 std::string VideoCaptureFormat::PixelStorageToString( 117 std::string VideoCaptureFormat::PixelStorageToString(
121 VideoPixelStorage storage) { 118 VideoPixelStorage storage) {
122 switch (storage) { 119 switch (storage) {
123 case PIXEL_STORAGE_CPU: 120 case PIXEL_STORAGE_CPU:
124 return "CPU"; 121 return "CPU";
125 case PIXEL_STORAGE_TEXTURE: 122 case PIXEL_STORAGE_TEXTURE:
126 return "TEXTURE"; 123 return "TEXTURE";
127 case PIXEL_STORAGE_GPUMEMORYBUFFER: 124 case PIXEL_STORAGE_GPUMEMORYBUFFER:
128 return "GPUMEMORYBUFFER"; 125 return "GPUMEMORYBUFFER";
129 } 126 }
130 NOTREACHED() << "Invalid VideoPixelStorage provided: " 127 NOTREACHED() << "Invalid VideoPixelStorage provided: "
131 << static_cast<int>(storage); 128 << static_cast<int>(storage);
132 return std::string(); 129 return std::string();
133 } 130 }
134 131
135 VideoCaptureParams::VideoCaptureParams() 132 VideoCaptureParams::VideoCaptureParams()
136 : resolution_change_policy(RESOLUTION_POLICY_FIXED_RESOLUTION), 133 : resolution_change_policy(RESOLUTION_POLICY_FIXED_RESOLUTION),
137 use_gpu_memory_buffers(false) { 134 use_gpu_memory_buffers(false) {
138 } 135 }
139 136
140 } // namespace media 137 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_capture_types.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698