| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/cast/logging/log_serializer.h" | 5 #include "media/cast/logging/log_serializer.h" |
| 6 | 6 |
| 7 #include "net/base/big_endian.h" | 7 #include "base/big_endian.h" |
| 8 | 8 |
| 9 namespace media { | 9 namespace media { |
| 10 namespace cast { | 10 namespace cast { |
| 11 | 11 |
| 12 LogSerializer::LogSerializer(const int max_serialized_bytes) | 12 LogSerializer::LogSerializer(const int max_serialized_bytes) |
| 13 : index_so_far_(0), max_serialized_bytes_(max_serialized_bytes) { | 13 : index_so_far_(0), max_serialized_bytes_(max_serialized_bytes) { |
| 14 DCHECK_GT(max_serialized_bytes_, 0); | 14 DCHECK_GT(max_serialized_bytes_, 0); |
| 15 } | 15 } |
| 16 | 16 |
| 17 LogSerializer::~LogSerializer() {} | 17 LogSerializer::~LogSerializer() {} |
| (...skipping 17 matching lines...) Expand all Loading... |
| 35 const PacketEventMap& packet_events, | 35 const PacketEventMap& packet_events, |
| 36 const RtpTimestamp first_rtp_timestamp) { | 36 const RtpTimestamp first_rtp_timestamp) { |
| 37 if (!serialized_log_so_far_) { | 37 if (!serialized_log_so_far_) { |
| 38 serialized_log_so_far_.reset(new std::string(max_serialized_bytes_, 0)); | 38 serialized_log_so_far_.reset(new std::string(max_serialized_bytes_, 0)); |
| 39 } | 39 } |
| 40 | 40 |
| 41 int remaining_space = serialized_log_so_far_->size() - index_so_far_; | 41 int remaining_space = serialized_log_so_far_->size() - index_so_far_; |
| 42 if (remaining_space <= 0) | 42 if (remaining_space <= 0) |
| 43 return false; | 43 return false; |
| 44 | 44 |
| 45 net::BigEndianWriter writer(&(*serialized_log_so_far_)[index_so_far_], | 45 base::BigEndianWriter writer(&(*serialized_log_so_far_)[index_so_far_], |
| 46 remaining_space); | 46 remaining_space); |
| 47 | 47 |
| 48 // Write stream ID. | 48 // Write stream ID. |
| 49 if (!writer.WriteU32(stream_id)) | 49 if (!writer.WriteU32(stream_id)) |
| 50 return false; | 50 return false; |
| 51 | 51 |
| 52 // Write first RTP timestamp. | 52 // Write first RTP timestamp. |
| 53 if (!writer.WriteU32(first_rtp_timestamp)) | 53 if (!writer.WriteU32(first_rtp_timestamp)) |
| 54 return false; | 54 return false; |
| 55 | 55 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 scoped_ptr<std::string> LogSerializer::GetSerializedLogAndReset() { | 94 scoped_ptr<std::string> LogSerializer::GetSerializedLogAndReset() { |
| 95 serialized_log_so_far_->resize(index_so_far_); | 95 serialized_log_so_far_->resize(index_so_far_); |
| 96 index_so_far_ = 0; | 96 index_so_far_ = 0; |
| 97 return serialized_log_so_far_.Pass(); | 97 return serialized_log_so_far_.Pass(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 int LogSerializer::GetSerializedLength() const { return index_so_far_; } | 100 int LogSerializer::GetSerializedLength() const { return index_so_far_; } |
| 101 | 101 |
| 102 } // namespace cast | 102 } // namespace cast |
| 103 } // namespace media | 103 } // namespace media |
| OLD | NEW |