| 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" |
| 6 |
| 5 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> |
| 6 | 9 |
| 7 #include "base/logging.h" | 10 #include "base/logging.h" |
| 8 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 9 #include "media/base/video_frame_metadata.h" | |
| 10 | 12 |
| 11 namespace media { | 13 namespace media { |
| 12 | 14 |
| 13 namespace { | 15 namespace { |
| 14 | 16 |
| 15 // Map enum key to internal std::string key used by base::DictionaryValue. | 17 // Map enum key to internal std::string key used by base::DictionaryValue. |
| 16 inline std::string ToInternalKey(VideoFrameMetadata::Key key) { | 18 inline std::string ToInternalKey(VideoFrameMetadata::Key key) { |
| 17 DCHECK_LT(key, VideoFrameMetadata::NUM_KEYS); | 19 DCHECK_LT(key, VideoFrameMetadata::NUM_KEYS); |
| 18 return base::IntToString(static_cast<int>(key)); | 20 return base::IntToString(static_cast<int>(key)); |
| 19 } | 21 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 67 |
| 66 void VideoFrameMetadata::SetTimeDelta(Key key, const base::TimeDelta& value) { | 68 void VideoFrameMetadata::SetTimeDelta(Key key, const base::TimeDelta& value) { |
| 67 SetTimeValue(key, value, &dictionary_); | 69 SetTimeValue(key, value, &dictionary_); |
| 68 } | 70 } |
| 69 | 71 |
| 70 void VideoFrameMetadata::SetTimeTicks(Key key, const base::TimeTicks& value) { | 72 void VideoFrameMetadata::SetTimeTicks(Key key, const base::TimeTicks& value) { |
| 71 SetTimeValue(key, value, &dictionary_); | 73 SetTimeValue(key, value, &dictionary_); |
| 72 } | 74 } |
| 73 | 75 |
| 74 void VideoFrameMetadata::SetValue(Key key, scoped_ptr<base::Value> value) { | 76 void VideoFrameMetadata::SetValue(Key key, scoped_ptr<base::Value> value) { |
| 75 dictionary_.SetWithoutPathExpansion(ToInternalKey(key), value.Pass()); | 77 dictionary_.SetWithoutPathExpansion(ToInternalKey(key), std::move(value)); |
| 76 } | 78 } |
| 77 | 79 |
| 78 bool VideoFrameMetadata::GetBoolean(Key key, bool* value) const { | 80 bool VideoFrameMetadata::GetBoolean(Key key, bool* value) const { |
| 79 DCHECK(value); | 81 DCHECK(value); |
| 80 return dictionary_.GetBooleanWithoutPathExpansion(ToInternalKey(key), value); | 82 return dictionary_.GetBooleanWithoutPathExpansion(ToInternalKey(key), value); |
| 81 } | 83 } |
| 82 | 84 |
| 83 bool VideoFrameMetadata::GetInteger(Key key, int* value) const { | 85 bool VideoFrameMetadata::GetInteger(Key key, int* value) const { |
| 84 DCHECK(value); | 86 DCHECK(value); |
| 85 return dictionary_.GetIntegerWithoutPathExpansion(ToInternalKey(key), value); | 87 return dictionary_.GetIntegerWithoutPathExpansion(ToInternalKey(key), value); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 const base::Value* internal_value = nullptr; | 149 const base::Value* internal_value = nullptr; |
| 148 if (dictionary_.GetWithoutPathExpansion(ToInternalKey(key), | 150 if (dictionary_.GetWithoutPathExpansion(ToInternalKey(key), |
| 149 &internal_value) && | 151 &internal_value) && |
| 150 internal_value->GetType() == base::Value::TYPE_BINARY) { | 152 internal_value->GetType() == base::Value::TYPE_BINARY) { |
| 151 return static_cast<const base::BinaryValue*>(internal_value); | 153 return static_cast<const base::BinaryValue*>(internal_value); |
| 152 } | 154 } |
| 153 return nullptr; | 155 return nullptr; |
| 154 } | 156 } |
| 155 | 157 |
| 156 } // namespace media | 158 } // namespace media |
| OLD | NEW |