Chromium Code Reviews| Index: media/base/video_capture_types.cc |
| diff --git a/media/base/video_capture_types.cc b/media/base/video_capture_types.cc |
| index 4649e4a697565e0bcf6a604bd3704f6586dfe399..6b811c9211d3d717a7e914257e6c6ccd772e05e2 100644 |
| --- a/media/base/video_capture_types.cc |
| +++ b/media/base/video_capture_types.cc |
| @@ -11,14 +11,27 @@ |
| namespace media { |
| VideoCaptureFormat::VideoCaptureFormat() |
| - : frame_rate(0.0f), pixel_format(PIXEL_FORMAT_UNKNOWN) {} |
| + : frame_rate(0.0f), |
| + pixel_format(PIXEL_FORMAT_UNKNOWN), |
| + pixel_storage(PIXEL_STORAGE_CPU) { |
| +} |
| VideoCaptureFormat::VideoCaptureFormat(const gfx::Size& frame_size, |
| float frame_rate, |
| VideoPixelFormat pixel_format) |
| : frame_size(frame_size), |
| frame_rate(frame_rate), |
| - pixel_format(pixel_format) {} |
| + pixel_format(pixel_format), |
| + pixel_storage(PIXEL_STORAGE_CPU) {} |
| + |
| +VideoCaptureFormat::VideoCaptureFormat(const gfx::Size& frame_size, |
| + float frame_rate, |
| + VideoPixelFormat pixel_format, |
| + VideoPixelStorage pixel_storage) |
| + : frame_size(frame_size), |
| + frame_rate(frame_rate), |
| + pixel_format(pixel_format), |
| + pixel_storage(pixel_storage) {} |
| bool VideoCaptureFormat::IsValid() const { |
| return (frame_size.width() < media::limits::kMaxDimension) && |
| @@ -27,8 +40,9 @@ bool VideoCaptureFormat::IsValid() const { |
| (frame_size.GetArea() < media::limits::kMaxCanvas) && |
| (frame_rate >= 0.0f) && |
| (frame_rate < media::limits::kMaxFramesPerSecond) && |
| - (pixel_format >= 0) && |
| - (pixel_format < PIXEL_FORMAT_MAX); |
| + (pixel_format >= 0) && (pixel_format < PIXEL_FORMAT_MAX) && |
| + (pixel_storage != PIXEL_STORAGE_TEXTURE || |
| + pixel_format == PIXEL_FORMAT_ARGB); |
| } |
| size_t VideoCaptureFormat::ImageAllocationSize() const { |
| @@ -49,13 +63,9 @@ size_t VideoCaptureFormat::ImageAllocationSize() const { |
| break; |
| case PIXEL_FORMAT_RGB32: |
| case PIXEL_FORMAT_ARGB: |
| - // GpuMemoryBuffer is an endianness-agnostic 32bpp pixel format until |
| - // http://crbug.com/439520 is closed. |
| - case PIXEL_FORMAT_GPUMEMORYBUFFER: |
| result_frame_size *= 4; |
| break; |
| case PIXEL_FORMAT_MJPEG: |
| - case PIXEL_FORMAT_TEXTURE: |
| result_frame_size = 0; |
| break; |
| default: // Sizes for the rest of the formats are unknown. |
| @@ -66,10 +76,11 @@ size_t VideoCaptureFormat::ImageAllocationSize() const { |
| } |
| std::string VideoCaptureFormat::ToString() const { |
| - return base::StringPrintf("resolution: %s, fps: %.3f, pixel format: %s", |
| - frame_size.ToString().c_str(), |
| - frame_rate, |
| - PixelFormatToString(pixel_format).c_str()); |
| + return base::StringPrintf( |
| + "(%s)@%.3ffps, pixel format: %s storage: %s.", |
| + frame_size.ToString().c_str(), frame_rate, |
| + PixelFormatToString(pixel_format).c_str(), |
| + PixelStorageToString(pixel_storage).c_str()); |
| } |
| std::string VideoCaptureFormat::PixelFormatToString(VideoPixelFormat format) { |
| @@ -96,10 +107,6 @@ std::string VideoCaptureFormat::PixelFormatToString(VideoPixelFormat format) { |
| return "NV21"; |
| case PIXEL_FORMAT_YV12: |
| return "YV12"; |
| - case PIXEL_FORMAT_TEXTURE: |
| - return "TEXTURE"; |
| - case PIXEL_FORMAT_GPUMEMORYBUFFER: |
| - return "GPUMEMORYBUFFER"; |
| case PIXEL_FORMAT_MAX: |
| break; |
| } |
| @@ -107,6 +114,20 @@ std::string VideoCaptureFormat::PixelFormatToString(VideoPixelFormat format) { |
| return ""; |
| } |
| +std::string VideoCaptureFormat::PixelStorageToString( |
| + VideoPixelStorage storage) { |
| + switch (storage) { |
| + case PIXEL_STORAGE_CPU: |
| + return "CPU"; |
| + case PIXEL_STORAGE_TEXTURE: |
| + return "TEXTURE"; |
| + case PIXEL_STORAGE_GPUMEMORYBUFFER: |
| + return "GPUMEMORYBUFFER"; |
| + } |
| + NOTREACHED() << "Invalid VideoPixelStorage provided: " << storage; |
| + return ""; |
|
dcheng
2015/06/24 21:41:48
Nit: return std::string() instead of return ""
mcasas
2015/06/25 01:19:51
Done.
|
| +} |
| + |
| VideoCaptureParams::VideoCaptureParams() |
| : resolution_change_policy(RESOLUTION_POLICY_FIXED_RESOLUTION) |
| #if defined(OS_LINUX) |