summaryrefslogtreecommitdiffstats
path: root/chromecast
diff options
context:
space:
mode:
authordcheng <dcheng@chromium.org>2015-06-30 10:48:09 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-30 17:49:45 +0000
commit8c0a4e2f79b220335bde00338f4656e47492928c (patch)
treebaff016a6fcd7201f50cc0b5f24c7931d988efdd /chromecast
parent70fadb041abae3242d2c00066ff806f47a98aecc (diff)
downloadchromium_src-8c0a4e2f79b220335bde00338f4656e47492928c.zip
chromium_src-8c0a4e2f79b220335bde00338f4656e47492928c.tar.gz
chromium_src-8c0a4e2f79b220335bde00338f4656e47492928c.tar.bz2
Use type-deducing IPC helpers in cma_param_traits.cc
This is simpler and easier to maintain than manually specifying the template specialization to use. BUG=504205 Review URL: https://codereview.chromium.org/1214783004 Cr-Commit-Position: refs/heads/master@{#336814}
Diffstat (limited to 'chromecast')
-rw-r--r--chromecast/common/media/cma_param_traits.cc63
1 files changed, 27 insertions, 36 deletions
diff --git a/chromecast/common/media/cma_param_traits.cc b/chromecast/common/media/cma_param_traits.cc
index 2bb9a26..8849be1 100644
--- a/chromecast/common/media/cma_param_traits.cc
+++ b/chromecast/common/media/cma_param_traits.cc
@@ -30,18 +30,18 @@ namespace IPC {
void ParamTraits<media::AudioDecoderConfig>::Write(
Message* m, const media::AudioDecoderConfig& p) {
- ParamTraits<media::AudioCodec>::Write(m, p.codec());
- ParamTraits<media::SampleFormat>::Write(m, p.sample_format());
- ParamTraits<media::ChannelLayout>::Write(m, p.channel_layout());
- ParamTraits<int>::Write(m, p.samples_per_second());
- ParamTraits<bool>::Write(m, p.is_encrypted());
+ WriteParam(m, p.codec());
+ WriteParam(m, p.sample_format());
+ WriteParam(m, p.channel_layout());
+ WriteParam(m, p.samples_per_second());
+ WriteParam(m, p.is_encrypted());
std::vector<uint8> extra_data;
if (p.extra_data_size() > 0) {
extra_data =
std::vector<uint8>(p.extra_data(),
p.extra_data() + p.extra_data_size());
}
- ParamTraits<std::vector<uint8> >::Write(m, extra_data);
+ WriteParam(m, extra_data);
}
bool ParamTraits<media::AudioDecoderConfig>::Read(
@@ -53,18 +53,14 @@ bool ParamTraits<media::AudioDecoderConfig>::Read(
media::ChannelLayout channel_layout;
int samples_per_second;
bool is_encrypted;
- if (!ParamTraits<media::AudioCodec>::Read(m, iter, &codec) ||
- !ParamTraits<media::SampleFormat>::Read(m, iter, &sample_format) ||
- !ParamTraits<media::ChannelLayout>::Read(m, iter, &channel_layout) ||
- !ParamTraits<int>::Read(m, iter, &samples_per_second) ||
- !ParamTraits<bool>::Read(m, iter, &is_encrypted)) {
- return false;
- }
std::vector<uint8> extra_data;
- if (!ParamTraits<std::vector<uint8> >::Read(m, iter, &extra_data))
+ if (!ReadParam(m, iter, &codec) || !ReadParam(m, iter, &sample_format) ||
+ !ReadParam(m, iter, &channel_layout) ||
+ !ReadParam(m, iter, &samples_per_second) ||
+ !ReadParam(m, iter, &is_encrypted) || !ReadParam(m, iter, &extra_data))
return false;
- const uint8* extra_data_ptr = NULL;
- if (extra_data.size() > 0)
+ const uint8* extra_data_ptr = nullptr;
+ if (!extra_data.empty())
extra_data_ptr = &extra_data[0];
*r = media::AudioDecoderConfig(codec, sample_format, channel_layout,
samples_per_second,
@@ -80,20 +76,20 @@ void ParamTraits<media::AudioDecoderConfig>::Log(
void ParamTraits<media::VideoDecoderConfig>::Write(
Message* m, const media::VideoDecoderConfig& p) {
- ParamTraits<media::VideoCodec>::Write(m, p.codec());
- ParamTraits<media::VideoCodecProfile>::Write(m, p.profile());
- ParamTraits<media::VideoFrame::Format>::Write(m, p.format());
- ParamTraits<gfx::Size>::Write(m, p.coded_size());
- ParamTraits<gfx::Rect>::Write(m, p.visible_rect());
- ParamTraits<gfx::Size>::Write(m, p.natural_size());
- ParamTraits<bool>::Write(m, p.is_encrypted());
+ WriteParam(m, p.codec());
+ WriteParam(m, p.profile());
+ WriteParam(m, p.format());
+ WriteParam(m, p.coded_size());
+ WriteParam(m, p.visible_rect());
+ WriteParam(m, p.natural_size());
+ WriteParam(m, p.is_encrypted());
std::vector<uint8> extra_data;
if (p.extra_data_size() > 0) {
extra_data =
std::vector<uint8>(p.extra_data(),
p.extra_data() + p.extra_data_size());
}
- ParamTraits<std::vector<uint8> >::Write(m, extra_data);
+ WriteParam(m, extra_data);
}
bool ParamTraits<media::VideoDecoderConfig>::Read(
@@ -107,20 +103,15 @@ bool ParamTraits<media::VideoDecoderConfig>::Read(
gfx::Rect visible_rect;
gfx::Size natural_size;
bool is_encrypted;
- if (!ParamTraits<media::VideoCodec>::Read(m, iter, &codec) ||
- !ParamTraits<media::VideoCodecProfile>::Read(m, iter, &profile) ||
- !ParamTraits<media::VideoFrame::Format>::Read(m, iter, &format) ||
- !ParamTraits<gfx::Size>::Read(m, iter, &coded_size) ||
- !ParamTraits<gfx::Rect>::Read(m, iter, &visible_rect) ||
- !ParamTraits<gfx::Size>::Read(m, iter, &natural_size) ||
- !ParamTraits<bool>::Read(m, iter, &is_encrypted)) {
- return false;
- }
std::vector<uint8> extra_data;
- if (!ParamTraits<std::vector<uint8> >::Read(m, iter, &extra_data))
+ if (!ReadParam(m, iter, &codec) || !ReadParam(m, iter, &profile) ||
+ !ReadParam(m, iter, &format) || !ReadParam(m, iter, &coded_size) ||
+ !ReadParam(m, iter, &visible_rect) ||
+ !ReadParam(m, iter, &natural_size) ||
+ !ReadParam(m, iter, &is_encrypted) || !ReadParam(m, iter, &extra_data))
return false;
- const uint8* extra_data_ptr = NULL;
- if (extra_data.size() > 0)
+ const uint8* extra_data_ptr = nullptr;
+ if (!extra_data.empty())
extra_data_ptr = &extra_data[0];
*r = media::VideoDecoderConfig(codec, profile, format,
coded_size, visible_rect, natural_size,