Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/common/media/media_param_traits.h" | 5 #include "content/common/media/media_param_traits.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "content/common/media/audio_messages.h" | |
| 8 #include "content/common/media/video_capture_messages.h" | 9 #include "content/common/media/video_capture_messages.h" |
| 9 #include "ipc/ipc_message_utils.h" | 10 #include "ipc/ipc_message_utils.h" |
| 10 #include "media/audio/audio_parameters.h" | 11 #include "media/audio/audio_parameters.h" |
| 11 #include "media/base/limits.h" | 12 #include "media/base/limits.h" |
| 12 #include "ui/gfx/ipc/gfx_param_traits.h" | 13 #include "ui/gfx/ipc/gfx_param_traits.h" |
| 13 | 14 |
| 14 using media::AudioParameters; | 15 using media::AudioParameters; |
| 15 using media::ChannelLayout; | 16 using media::ChannelLayout; |
| 16 using media::VideoCaptureFormat; | 17 using media::VideoCaptureFormat; |
| 17 | 18 |
| 18 namespace IPC { | 19 namespace IPC { |
| 19 | 20 |
| 20 void ParamTraits<AudioParameters>::Write(Message* m, | 21 void ParamTraits<AudioParameters>::Write(Message* m, |
| 21 const AudioParameters& p) { | 22 const AudioParameters& p) { |
| 22 m->WriteInt(static_cast<int>(p.format())); | 23 WriteParam(m, p.format()); |
| 23 m->WriteInt(static_cast<int>(p.channel_layout())); | 24 WriteParam(m, p.channel_layout()); |
| 24 m->WriteInt(p.sample_rate()); | 25 WriteParam(m, p.sample_rate()); |
| 25 m->WriteInt(p.bits_per_sample()); | 26 WriteParam(m, p.bits_per_sample()); |
| 26 m->WriteInt(p.frames_per_buffer()); | 27 WriteParam(m, p.frames_per_buffer()); |
| 27 m->WriteInt(p.channels()); | 28 WriteParam(m, p.channels()); |
| 28 m->WriteInt(p.effects()); | 29 WriteParam(m, p.effects()); |
| 29 } | 30 } |
| 30 | 31 |
| 31 bool ParamTraits<AudioParameters>::Read(const Message* m, | 32 bool ParamTraits<AudioParameters>::Read(const Message* m, |
| 32 base::PickleIterator* iter, | 33 base::PickleIterator* iter, |
| 33 AudioParameters* r) { | 34 AudioParameters* r) { |
| 34 int format, channel_layout, sample_rate, bits_per_sample, | 35 AudioParameters::Format format; |
| 35 frames_per_buffer, channels, effects; | 36 ChannelLayout channel_layout; |
| 37 int sample_rate, bits_per_sample, frames_per_buffer, channels, effects; | |
| 36 | 38 |
| 37 if (!iter->ReadInt(&format) || | 39 if (!ReadParam(m, iter, &format) || !ReadParam(m, iter, &channel_layout) || |
|
Tom Sepez
2015/06/30 15:37:07
nit: I'd still prefer one per line.
dcheng
2015/06/30 18:11:59
This is due to clang-format: if you feel strongly
Tom Sepez
2015/06/30 19:43:22
No worries. Let's leave it as is.
| |
| 38 !iter->ReadInt(&channel_layout) || | 40 !ReadParam(m, iter, &sample_rate) || |
| 39 !iter->ReadInt(&sample_rate) || | 41 !ReadParam(m, iter, &bits_per_sample) || |
| 40 !iter->ReadInt(&bits_per_sample) || | 42 !ReadParam(m, iter, &frames_per_buffer) || |
| 41 !iter->ReadInt(&frames_per_buffer) || | 43 !ReadParam(m, iter, &channels) || !ReadParam(m, iter, &effects)) { |
| 42 !iter->ReadInt(&channels) || | |
| 43 !iter->ReadInt(&effects)) { | |
| 44 return false; | 44 return false; |
| 45 } | 45 } |
| 46 | 46 |
| 47 AudioParameters params(static_cast<AudioParameters::Format>(format), | 47 AudioParameters params(format, channel_layout, channels, sample_rate, |
| 48 static_cast<ChannelLayout>(channel_layout), channels, | 48 bits_per_sample, frames_per_buffer, effects); |
| 49 sample_rate, bits_per_sample, frames_per_buffer, effects); | |
| 50 *r = params; | 49 *r = params; |
| 51 return r->IsValid(); | 50 return r->IsValid(); |
| 52 } | 51 } |
| 53 | 52 |
| 54 void ParamTraits<AudioParameters>::Log(const AudioParameters& p, | 53 void ParamTraits<AudioParameters>::Log(const AudioParameters& p, |
| 55 std::string* l) { | 54 std::string* l) { |
| 56 l->append(base::StringPrintf("<AudioParameters>")); | 55 l->append(base::StringPrintf("<AudioParameters>")); |
| 57 } | 56 } |
| 58 | 57 |
| 59 void ParamTraits<VideoCaptureFormat>::Write(Message* m, | 58 void ParamTraits<VideoCaptureFormat>::Write(Message* m, |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 76 return r->IsValid(); | 75 return r->IsValid(); |
| 77 } | 76 } |
| 78 | 77 |
| 79 void ParamTraits<VideoCaptureFormat>::Log(const VideoCaptureFormat& p, | 78 void ParamTraits<VideoCaptureFormat>::Log(const VideoCaptureFormat& p, |
| 80 std::string* l) { | 79 std::string* l) { |
| 81 l->append( | 80 l->append( |
| 82 base::StringPrintf("<VideoCaptureFormat> %s", p.ToString().c_str())); | 81 base::StringPrintf("<VideoCaptureFormat> %s", p.ToString().c_str())); |
| 83 } | 82 } |
| 84 | 83 |
| 85 } | 84 } |
| OLD | NEW |