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

Side by Side Diff: media/video/capture/video_capture_types.cc

Issue 416553002: VideoCaptureFormat: add method to print out pixel format as string (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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/video/capture/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/video/capture/video_capture_types.h" 5 #include "media/video/capture/video_capture_types.h"
6 6
7 #include "base/logging.h"
7 #include "media/base/limits.h" 8 #include "media/base/limits.h"
8 9
9 namespace media { 10 namespace media {
10 11
11 VideoCaptureFormat::VideoCaptureFormat() 12 VideoCaptureFormat::VideoCaptureFormat()
12 : frame_rate(0.0f), pixel_format(PIXEL_FORMAT_UNKNOWN) {} 13 : frame_rate(0.0f), pixel_format(PIXEL_FORMAT_UNKNOWN) {}
13 14
14 VideoCaptureFormat::VideoCaptureFormat(const gfx::Size& frame_size, 15 VideoCaptureFormat::VideoCaptureFormat(const gfx::Size& frame_size,
15 float frame_rate, 16 float frame_rate,
16 VideoPixelFormat pixel_format) 17 VideoPixelFormat pixel_format)
17 : frame_size(frame_size), 18 : frame_size(frame_size),
18 frame_rate(frame_rate), 19 frame_rate(frame_rate),
19 pixel_format(pixel_format) {} 20 pixel_format(pixel_format) {}
20 21
21 bool VideoCaptureFormat::IsValid() const { 22 bool VideoCaptureFormat::IsValid() const {
22 return (frame_size.width() < media::limits::kMaxDimension) && 23 return (frame_size.width() < media::limits::kMaxDimension) &&
23 (frame_size.height() < media::limits::kMaxDimension) && 24 (frame_size.height() < media::limits::kMaxDimension) &&
24 (frame_size.GetArea() >= 0) && 25 (frame_size.GetArea() >= 0) &&
25 (frame_size.GetArea() < media::limits::kMaxCanvas) && 26 (frame_size.GetArea() < media::limits::kMaxCanvas) &&
26 (frame_rate >= 0.0f) && 27 (frame_rate >= 0.0f) &&
27 (frame_rate < media::limits::kMaxFramesPerSecond) && 28 (frame_rate < media::limits::kMaxFramesPerSecond) &&
28 (pixel_format >= PIXEL_FORMAT_UNKNOWN) && 29 (pixel_format >= PIXEL_FORMAT_UNKNOWN) &&
29 (pixel_format < PIXEL_FORMAT_MAX); 30 (pixel_format < PIXEL_FORMAT_MAX);
30 } 31 }
31 32
33 std::string VideoCaptureFormat::PixelFormatToString(VideoPixelFormat format) {
34 switch (format) {
35 case PIXEL_FORMAT_UNKNOWN:
36 return "UNKNOWN";
37 case PIXEL_FORMAT_I420:
38 return "I420";
39 case PIXEL_FORMAT_YUY2:
40 return "YUY2";
41 case PIXEL_FORMAT_UYVY:
42 return "UYUY";
43 case PIXEL_FORMAT_RGB24:
44 return "RGB24";
45 case PIXEL_FORMAT_ARGB:
46 return "ARGB";
47 case PIXEL_FORMAT_MJPEG:
48 return "MJPEG";
49 case PIXEL_FORMAT_NV21:
50 return "YV12";
51 case PIXEL_FORMAT_YV12:
52 return "YV12";
53 case PIXEL_FORMAT_TEXTURE:
54 return "TEXTURE";
55 case PIXEL_FORMAT_MAX:
56 break;
57 }
58 NOTREACHED() << "Invalid VideoPixelFormat provided: " << format;
59 return "";
60 }
61
32 VideoCaptureParams::VideoCaptureParams() : allow_resolution_change(false) {} 62 VideoCaptureParams::VideoCaptureParams() : allow_resolution_change(false) {}
33 63
34 } // namespace media 64 } // namespace media
OLDNEW
« no previous file with comments | « media/video/capture/video_capture_types.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698