| 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 "base/logging.h" | 5 #include "base/logging.h" | 
| 6 #include "base/strings/string_number_conversions.h" | 6 #include "base/strings/string_number_conversions.h" | 
| 7 #include "media/base/video_frame_metadata.h" | 7 #include "media/base/video_frame_metadata.h" | 
| 8 | 8 | 
| 9 namespace media { | 9 namespace media { | 
| 10 | 10 | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 45       // any particular character encoding (e.g., UTF-8) by | 45       // any particular character encoding (e.g., UTF-8) by | 
| 46       // base::DictionaryValue. | 46       // base::DictionaryValue. | 
| 47       base::BinaryValue::CreateWithCopiedBuffer(value.data(), value.size())); | 47       base::BinaryValue::CreateWithCopiedBuffer(value.data(), value.size())); | 
| 48 } | 48 } | 
| 49 | 49 | 
| 50 namespace { | 50 namespace { | 
| 51 template<class TimeType> | 51 template<class TimeType> | 
| 52 void SetTimeValue(VideoFrameMetadata::Key key, | 52 void SetTimeValue(VideoFrameMetadata::Key key, | 
| 53                   const TimeType& value, | 53                   const TimeType& value, | 
| 54                   base::DictionaryValue* dictionary) { | 54                   base::DictionaryValue* dictionary) { | 
| 55   const int64 internal_value = value.ToInternalValue(); | 55   const int64_t internal_value = value.ToInternalValue(); | 
| 56   dictionary->SetWithoutPathExpansion( | 56   dictionary->SetWithoutPathExpansion( | 
| 57       ToInternalKey(key), | 57       ToInternalKey(key), | 
| 58       base::BinaryValue::CreateWithCopiedBuffer( | 58       base::BinaryValue::CreateWithCopiedBuffer( | 
| 59           reinterpret_cast<const char*>(&internal_value), | 59           reinterpret_cast<const char*>(&internal_value), | 
| 60           sizeof(internal_value))); | 60           sizeof(internal_value))); | 
| 61 } | 61 } | 
| 62 }  // namespace | 62 }  // namespace | 
| 63 | 63 | 
| 64 void VideoFrameMetadata::SetTimeDelta(Key key, const base::TimeDelta& value) { | 64 void VideoFrameMetadata::SetTimeDelta(Key key, const base::TimeDelta& value) { | 
| 65   SetTimeValue(key, value, &dictionary_); | 65   SetTimeValue(key, value, &dictionary_); | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 93   const base::BinaryValue* const binary_value = GetBinaryValue(key); | 93   const base::BinaryValue* const binary_value = GetBinaryValue(key); | 
| 94   if (binary_value) | 94   if (binary_value) | 
| 95     value->assign(binary_value->GetBuffer(), binary_value->GetSize()); | 95     value->assign(binary_value->GetBuffer(), binary_value->GetSize()); | 
| 96   return !!binary_value; | 96   return !!binary_value; | 
| 97 } | 97 } | 
| 98 | 98 | 
| 99 namespace { | 99 namespace { | 
| 100 template<class TimeType> | 100 template<class TimeType> | 
| 101 bool ToTimeValue(const base::BinaryValue& binary_value, TimeType* value) { | 101 bool ToTimeValue(const base::BinaryValue& binary_value, TimeType* value) { | 
| 102   DCHECK(value); | 102   DCHECK(value); | 
| 103   int64 internal_value; | 103   int64_t internal_value; | 
| 104   if (binary_value.GetSize() != sizeof(internal_value)) | 104   if (binary_value.GetSize() != sizeof(internal_value)) | 
| 105     return false; | 105     return false; | 
| 106   memcpy(&internal_value, binary_value.GetBuffer(), sizeof(internal_value)); | 106   memcpy(&internal_value, binary_value.GetBuffer(), sizeof(internal_value)); | 
| 107   *value = TimeType::FromInternalValue(internal_value); | 107   *value = TimeType::FromInternalValue(internal_value); | 
| 108   return true; | 108   return true; | 
| 109 } | 109 } | 
| 110 }  // namespace | 110 }  // namespace | 
| 111 | 111 | 
| 112 bool VideoFrameMetadata::GetTimeDelta(Key key, base::TimeDelta* value) const { | 112 bool VideoFrameMetadata::GetTimeDelta(Key key, base::TimeDelta* value) const { | 
| 113   const base::BinaryValue* const binary_value = GetBinaryValue(key); | 113   const base::BinaryValue* const binary_value = GetBinaryValue(key); | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 145   const base::Value* internal_value = nullptr; | 145   const base::Value* internal_value = nullptr; | 
| 146   if (dictionary_.GetWithoutPathExpansion(ToInternalKey(key), | 146   if (dictionary_.GetWithoutPathExpansion(ToInternalKey(key), | 
| 147                                           &internal_value) && | 147                                           &internal_value) && | 
| 148       internal_value->GetType() == base::Value::TYPE_BINARY) { | 148       internal_value->GetType() == base::Value::TYPE_BINARY) { | 
| 149     return static_cast<const base::BinaryValue*>(internal_value); | 149     return static_cast<const base::BinaryValue*>(internal_value); | 
| 150   } | 150   } | 
| 151   return nullptr; | 151   return nullptr; | 
| 152 } | 152 } | 
| 153 | 153 | 
| 154 }  // namespace media | 154 }  // namespace media | 
| OLD | NEW | 
|---|