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 "content/common/gpu/gpu_messages.h" |
| 6 |
| 7 namespace IPC { |
| 8 |
| 9 void ParamTraits<media::BitstreamBuffer>::Write(base::Pickle* m, |
| 10 const param_type& p) { |
| 11 DCHECK_GE(p.id(), 0); |
| 12 DCHECK(base::SharedMemory::IsHandleValid(p.handle())); |
| 13 |
| 14 WriteParam(m, p.id()); |
| 15 WriteParam(m, p.size()); |
| 16 WriteParam(m, p.presentation_timestamp()); |
| 17 WriteParam(m, p.key_id()); |
| 18 if (!p.key_id().empty()) { |
| 19 WriteParam(m, p.iv()); |
| 20 WriteParam(m, p.subsamples()); |
| 21 } |
| 22 WriteParam(m, p.handle()); |
| 23 } |
| 24 |
| 25 bool ParamTraits<media::BitstreamBuffer>::Read(const base::Pickle* m, |
| 26 base::PickleIterator* iter, |
| 27 param_type* r) { |
| 28 DCHECK(r); |
| 29 if (!(ReadParam(m, iter, &r->id_) && ReadParam(m, iter, &r->size_) && |
| 30 ReadParam(m, iter, &r->presentation_timestamp_) && |
| 31 ReadParam(m, iter, &r->key_id_))) |
| 32 return false; |
| 33 if (r->id_ < 0) { |
| 34 LOG(ERROR) << "Invalid id: " << r->id_; |
| 35 return false; |
| 36 } |
| 37 if (!r->key_id_.empty()) { |
| 38 if (!(ReadParam(m, iter, &r->iv_) && ReadParam(m, iter, &r->subsamples_))) |
| 39 return false; |
| 40 } |
| 41 if (!(ReadParam(m, iter, &r->handle_) && |
| 42 base::SharedMemory::IsHandleValid(r->handle_))) { |
| 43 LOG(ERROR) << "fail to read valid handle."; |
| 44 return false; |
| 45 } |
| 46 return true; |
| 47 } |
| 48 |
| 49 void ParamTraits<media::BitstreamBuffer>::Log(const param_type& p, |
| 50 std::string* l) { |
| 51 std::ostringstream oss; |
| 52 oss << "id=" << p.id() << ", size=" << p.size() << ", presentation_timestamp=" |
| 53 << p.presentation_timestamp().ToInternalValue(); |
| 54 l->append(oss.str()); |
| 55 } |
| 56 |
| 57 } // namespace IPC |
OLD | NEW |