Index: content/common/media/media_param_traits.cc |
diff --git a/content/common/media/media_param_traits.cc b/content/common/media/media_param_traits.cc |
index 280d908ccfc00386bb8f88217abbd6897acbe6eb..2e3addab9e6dd13a5110728a10d32db832a6cec0 100644 |
--- a/content/common/media/media_param_traits.cc |
+++ b/content/common/media/media_param_traits.cc |
@@ -5,17 +5,21 @@ |
#include "content/common/media/media_param_traits.h" |
#include "base/strings/stringprintf.h" |
+#include "ipc/ipc_message_utils.h" |
#include "media/audio/audio_parameters.h" |
#include "media/base/limits.h" |
#include "media/base/video_capture_types.h" |
+#include "ui/gfx/ipc/gfx_param_traits.h" |
using media::AudioParameters; |
using media::ChannelLayout; |
using media::VideoCaptureFormat; |
-using media::VideoPixelFormat; |
namespace IPC { |
+IPC_ENUM_TRAITS_MAX_VALUE(media::VideoPixelFormat, media::PIXEL_FORMAT_MAX - 1) |
+IPC_ENUM_TRAITS_MAX_VALUE(media::VideoPixelStorage, media::PIXEL_STORAGE_MAX) |
dcheng
2015/06/25 02:02:18
See https://codereview.chromium.org/1210743003/ fo
mcasas
2015/06/25 13:51:03
Done.
|
+ |
void ParamTraits<AudioParameters>::Write(Message* m, |
const AudioParameters& p) { |
m->WriteInt(static_cast<int>(p.format())); |
@@ -39,16 +43,15 @@ bool ParamTraits<AudioParameters>::Read(const Message* m, |
!iter->ReadInt(&bits_per_sample) || |
!iter->ReadInt(&frames_per_buffer) || |
!iter->ReadInt(&channels) || |
- !iter->ReadInt(&effects)) |
+ !iter->ReadInt(&effects)) { |
return false; |
+ } |
AudioParameters params(static_cast<AudioParameters::Format>(format), |
static_cast<ChannelLayout>(channel_layout), channels, |
sample_rate, bits_per_sample, frames_per_buffer, effects); |
*r = params; |
- if (!r->IsValid()) |
- return false; |
- return true; |
+ return r->IsValid(); |
} |
void ParamTraits<AudioParameters>::Log(const AudioParameters& p, |
@@ -63,23 +66,19 @@ void ParamTraits<VideoCaptureFormat>::Write(Message* m, |
m->WriteInt(p.frame_size.height()); |
m->WriteFloat(p.frame_rate); |
m->WriteInt(static_cast<int>(p.pixel_format)); |
+ m->WriteInt(static_cast<int>(p.pixel_storage)); |
dcheng
2015/06/25 02:02:18
Btw, these should probably be WriteParam() as well
mcasas
2015/06/25 13:51:03
Done.
|
} |
bool ParamTraits<VideoCaptureFormat>::Read(const Message* m, |
base::PickleIterator* iter, |
VideoCaptureFormat* r) { |
- int frame_size_width, frame_size_height, pixel_format; |
- if (!iter->ReadInt(&frame_size_width) || |
- !iter->ReadInt(&frame_size_height) || |
- !iter->ReadFloat(&r->frame_rate) || |
- !iter->ReadInt(&pixel_format)) |
- return false; |
- |
- r->frame_size.SetSize(frame_size_width, frame_size_height); |
- r->pixel_format = static_cast<VideoPixelFormat>(pixel_format); |
- if (!r->IsValid()) |
+ if (!ReadParam(m, iter, &r->frame_size) || |
+ !ReadParam(m, iter, &r->frame_rate) || |
+ !ReadParam(m, iter, &r->pixel_format) || |
+ !ReadParam(m, iter, &r->pixel_storage)) { |
return false; |
- return true; |
+ } |
+ return r->IsValid(); |
} |
void ParamTraits<VideoCaptureFormat>::Log(const VideoCaptureFormat& p, |