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/stringprintf.h" | 7 #include "base/stringprintf.h" |
8 #include "media/audio/audio_parameters.h" | 8 #include "media/audio/audio_parameters.h" |
9 #include "media/base/limits.h" | 9 #include "media/base/limits.h" |
| 10 #include "media/midi/midi_port_info.h" |
10 #include "media/video/capture/video_capture_types.h" | 11 #include "media/video/capture/video_capture_types.h" |
11 | 12 |
12 using media::AudioParameters; | 13 using media::AudioParameters; |
13 using media::ChannelLayout; | 14 using media::ChannelLayout; |
| 15 using media::MIDIPortInfo; |
| 16 using media::MIDIPortInfoList; |
14 using media::VideoCaptureParams; | 17 using media::VideoCaptureParams; |
15 using media::VideoCaptureSessionId; | 18 using media::VideoCaptureSessionId; |
16 | 19 |
17 namespace IPC { | 20 namespace IPC { |
18 | 21 |
19 void ParamTraits<AudioParameters>::Write(Message* m, | 22 void ParamTraits<AudioParameters>::Write(Message* m, |
20 const AudioParameters& p) { | 23 const AudioParameters& p) { |
21 m->WriteInt(static_cast<int>(p.format())); | 24 m->WriteInt(static_cast<int>(p.format())); |
22 m->WriteInt(static_cast<int>(p.channel_layout())); | 25 m->WriteInt(static_cast<int>(p.channel_layout())); |
23 m->WriteInt(p.sample_rate()); | 26 m->WriteInt(p.sample_rate()); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 } | 88 } |
86 | 89 |
87 return true; | 90 return true; |
88 } | 91 } |
89 | 92 |
90 void ParamTraits<VideoCaptureParams>::Log(const VideoCaptureParams& p, | 93 void ParamTraits<VideoCaptureParams>::Log(const VideoCaptureParams& p, |
91 std::string* l) { | 94 std::string* l) { |
92 l->append(base::StringPrintf("<VideoCaptureParams>")); | 95 l->append(base::StringPrintf("<VideoCaptureParams>")); |
93 } | 96 } |
94 | 97 |
| 98 // MIDI |
| 99 |
| 100 void ParamTraits<MIDIPortInfoList>::Write(Message* m, |
| 101 const MIDIPortInfoList& p) { |
| 102 int64 n = p.size(); |
| 103 m->WriteInt64(n); |
| 104 |
| 105 for (size_t i = 0; i < n; ++i) { |
| 106 m->WriteString(p[i].id_); |
| 107 m->WriteString(p[i].manufacturer_); |
| 108 m->WriteString(p[i].name_); |
| 109 m->WriteString(p[i].version_); |
| 110 } |
95 } | 111 } |
| 112 |
| 113 bool ParamTraits<MIDIPortInfoList>::Read(const Message* m, |
| 114 PickleIterator* iter, |
| 115 MIDIPortInfoList* r) { |
| 116 int64 n; |
| 117 if (!m->ReadInt64(iter, &n) || n < 0) |
| 118 return false; |
| 119 |
| 120 r->reserve(n); |
| 121 for (int i = 0; i < n; ++i) { |
| 122 std::string id; |
| 123 std::string manufacturer; |
| 124 std::string name; |
| 125 std::string version; |
| 126 |
| 127 if (!m->ReadString(iter, &id) || |
| 128 !m->ReadString(iter, &manufacturer) || |
| 129 !m->ReadString(iter, &name) || |
| 130 !m->ReadString(iter, &version)) |
| 131 return false; |
| 132 |
| 133 r->push_back(MIDIPortInfo(id, manufacturer, name, version)); |
| 134 } |
| 135 |
| 136 return true; |
| 137 } |
| 138 |
| 139 void ParamTraits<MIDIPortInfoList>::Log(const MIDIPortInfoList& p, |
| 140 std::string* l) { |
| 141 l->append(base::StringPrintf("<MIDIPortInfoList>")); |
| 142 } |
| 143 |
| 144 } |
OLD | NEW |