OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/base/video_frame_metadata.h" | 5 #include "media/base/video_frame_metadata.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 93 matching lines...) Loading... |
104 &int_value); | 104 &int_value); |
105 if (rv) | 105 if (rv) |
106 *value = static_cast<VideoRotation>(int_value); | 106 *value = static_cast<VideoRotation>(int_value); |
107 return rv; | 107 return rv; |
108 } | 108 } |
109 | 109 |
110 bool VideoFrameMetadata::GetString(Key key, std::string* value) const { | 110 bool VideoFrameMetadata::GetString(Key key, std::string* value) const { |
111 DCHECK(value); | 111 DCHECK(value); |
112 const base::Value* const binary_value = GetBinaryValue(key); | 112 const base::Value* const binary_value = GetBinaryValue(key); |
113 if (binary_value) | 113 if (binary_value) |
114 value->assign(binary_value->GetBuffer(), binary_value->GetSize()); | 114 value->assign(binary_value->GetBlob().data(), |
| 115 binary_value->GetBlob().size()); |
115 return !!binary_value; | 116 return !!binary_value; |
116 } | 117 } |
117 | 118 |
118 namespace { | 119 namespace { |
119 template <class TimeType> | 120 template <class TimeType> |
120 bool ToTimeValue(const base::Value& binary_value, TimeType* value) { | 121 bool ToTimeValue(const base::Value& binary_value, TimeType* value) { |
121 DCHECK(value); | 122 DCHECK(value); |
122 int64_t internal_value; | 123 int64_t internal_value; |
123 if (binary_value.GetSize() != sizeof(internal_value)) | 124 if (binary_value.GetBlob().size() != sizeof(internal_value)) |
124 return false; | 125 return false; |
125 memcpy(&internal_value, binary_value.GetBuffer(), sizeof(internal_value)); | 126 memcpy(&internal_value, binary_value.GetBlob().data(), |
| 127 sizeof(internal_value)); |
126 *value = TimeType::FromInternalValue(internal_value); | 128 *value = TimeType::FromInternalValue(internal_value); |
127 return true; | 129 return true; |
128 } | 130 } |
129 } // namespace | 131 } // namespace |
130 | 132 |
131 bool VideoFrameMetadata::GetTimeDelta(Key key, base::TimeDelta* value) const { | 133 bool VideoFrameMetadata::GetTimeDelta(Key key, base::TimeDelta* value) const { |
132 const base::Value* const binary_value = GetBinaryValue(key); | 134 const base::Value* const binary_value = GetBinaryValue(key); |
133 return binary_value && ToTimeValue(*binary_value, value); | 135 return binary_value && ToTimeValue(*binary_value, value); |
134 } | 136 } |
135 | 137 |
(...skipping 33 matching lines...) Loading... |
169 const base::Value* internal_value = nullptr; | 171 const base::Value* internal_value = nullptr; |
170 if (dictionary_.GetWithoutPathExpansion(ToInternalKey(key), | 172 if (dictionary_.GetWithoutPathExpansion(ToInternalKey(key), |
171 &internal_value) && | 173 &internal_value) && |
172 internal_value->GetType() == base::Value::Type::BINARY) { | 174 internal_value->GetType() == base::Value::Type::BINARY) { |
173 return internal_value; | 175 return internal_value; |
174 } | 176 } |
175 return nullptr; | 177 return nullptr; |
176 } | 178 } |
177 | 179 |
178 } // namespace media | 180 } // namespace media |
OLD | NEW |