OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <stddef.h> |
| 6 |
| 7 #include <sstream> |
| 8 |
| 9 #include "base/logging.h" |
| 10 #include "base/numerics/safe_math.h" |
| 11 #include "content/common/gpu/media_messages.h" |
| 12 |
| 13 namespace IPC { |
| 14 |
| 15 void ParamTraits<media::BitstreamBuffer>::Write(base::Pickle* m, |
| 16 const param_type& p) { |
| 17 WriteParam(m, p.id()); |
| 18 WriteParam(m, static_cast<uint64_t>(p.size())); |
| 19 WriteParam(m, p.presentation_timestamp()); |
| 20 WriteParam(m, p.key_id()); |
| 21 if (!p.key_id().empty()) { |
| 22 WriteParam(m, p.iv()); |
| 23 WriteParam(m, p.subsamples()); |
| 24 } |
| 25 WriteParam(m, p.handle()); |
| 26 } |
| 27 |
| 28 bool ParamTraits<media::BitstreamBuffer>::Read(const base::Pickle* m, |
| 29 base::PickleIterator* iter, |
| 30 param_type* r) { |
| 31 DCHECK(r); |
| 32 uint64_t size = 0; |
| 33 if (!(ReadParam(m, iter, &r->id_) && ReadParam(m, iter, &size) && |
| 34 ReadParam(m, iter, &r->presentation_timestamp_) && |
| 35 ReadParam(m, iter, &r->key_id_))) |
| 36 return false; |
| 37 |
| 38 base::CheckedNumeric<size_t> checked_size(size); |
| 39 if (!checked_size.IsValid()) { |
| 40 DLOG(ERROR) << "Invalid size: " << size; |
| 41 return false; |
| 42 } |
| 43 r->size_ = checked_size.ValueOrDie(); |
| 44 |
| 45 if (!r->key_id_.empty()) { |
| 46 if (!(ReadParam(m, iter, &r->iv_) && ReadParam(m, iter, &r->subsamples_))) |
| 47 return false; |
| 48 } |
| 49 |
| 50 return ReadParam(m, iter, &r->handle_); |
| 51 } |
| 52 |
| 53 void ParamTraits<media::BitstreamBuffer>::Log(const param_type& p, |
| 54 std::string* l) { |
| 55 std::ostringstream oss; |
| 56 oss << "id=" << p.id() << ", size=" << p.size() << ", presentation_timestamp=" |
| 57 << p.presentation_timestamp().ToInternalValue(); |
| 58 l->append(oss.str()); |
| 59 } |
| 60 |
| 61 } // namespace IPC |
OLD | NEW |