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 24 matching lines...) Expand all Loading... |
35 } | 35 } |
36 | 36 |
37 void VideoFrameMetadata::SetInteger(Key key, int value) { | 37 void VideoFrameMetadata::SetInteger(Key key, int value) { |
38 dictionary_.SetIntegerWithoutPathExpansion(ToInternalKey(key), value); | 38 dictionary_.SetIntegerWithoutPathExpansion(ToInternalKey(key), value); |
39 } | 39 } |
40 | 40 |
41 void VideoFrameMetadata::SetDouble(Key key, double value) { | 41 void VideoFrameMetadata::SetDouble(Key key, double value) { |
42 dictionary_.SetDoubleWithoutPathExpansion(ToInternalKey(key), value); | 42 dictionary_.SetDoubleWithoutPathExpansion(ToInternalKey(key), value); |
43 } | 43 } |
44 | 44 |
| 45 void VideoFrameMetadata::SetRotation(Key key, VideoRotation value) { |
| 46 DCHECK_EQ(ROTATION, key); |
| 47 dictionary_.SetIntegerWithoutPathExpansion(ToInternalKey(key), value); |
| 48 } |
| 49 |
45 void VideoFrameMetadata::SetString(Key key, const std::string& value) { | 50 void VideoFrameMetadata::SetString(Key key, const std::string& value) { |
46 dictionary_.SetWithoutPathExpansion( | 51 dictionary_.SetWithoutPathExpansion( |
47 ToInternalKey(key), | 52 ToInternalKey(key), |
48 // Using BinaryValue since we don't want the |value| interpreted as having | 53 // Using BinaryValue since we don't want the |value| interpreted as having |
49 // any particular character encoding (e.g., UTF-8) by | 54 // any particular character encoding (e.g., UTF-8) by |
50 // base::DictionaryValue. | 55 // base::DictionaryValue. |
51 base::BinaryValue::CreateWithCopiedBuffer(value.data(), value.size())); | 56 base::BinaryValue::CreateWithCopiedBuffer(value.data(), value.size())); |
52 } | 57 } |
53 | 58 |
54 namespace { | 59 namespace { |
(...skipping 30 matching lines...) Expand all Loading... |
85 bool VideoFrameMetadata::GetInteger(Key key, int* value) const { | 90 bool VideoFrameMetadata::GetInteger(Key key, int* value) const { |
86 DCHECK(value); | 91 DCHECK(value); |
87 return dictionary_.GetIntegerWithoutPathExpansion(ToInternalKey(key), value); | 92 return dictionary_.GetIntegerWithoutPathExpansion(ToInternalKey(key), value); |
88 } | 93 } |
89 | 94 |
90 bool VideoFrameMetadata::GetDouble(Key key, double* value) const { | 95 bool VideoFrameMetadata::GetDouble(Key key, double* value) const { |
91 DCHECK(value); | 96 DCHECK(value); |
92 return dictionary_.GetDoubleWithoutPathExpansion(ToInternalKey(key), value); | 97 return dictionary_.GetDoubleWithoutPathExpansion(ToInternalKey(key), value); |
93 } | 98 } |
94 | 99 |
| 100 bool VideoFrameMetadata::GetRotation(Key key, VideoRotation* value) const { |
| 101 DCHECK_EQ(ROTATION, key); |
| 102 DCHECK(value); |
| 103 int int_value; |
| 104 const bool rv = dictionary_.GetIntegerWithoutPathExpansion(ToInternalKey(key), |
| 105 &int_value); |
| 106 if (rv) |
| 107 *value = static_cast<VideoRotation>(int_value); |
| 108 return rv; |
| 109 } |
| 110 |
95 bool VideoFrameMetadata::GetString(Key key, std::string* value) const { | 111 bool VideoFrameMetadata::GetString(Key key, std::string* value) const { |
96 DCHECK(value); | 112 DCHECK(value); |
97 const base::BinaryValue* const binary_value = GetBinaryValue(key); | 113 const base::BinaryValue* const binary_value = GetBinaryValue(key); |
98 if (binary_value) | 114 if (binary_value) |
99 value->assign(binary_value->GetBuffer(), binary_value->GetSize()); | 115 value->assign(binary_value->GetBuffer(), binary_value->GetSize()); |
100 return !!binary_value; | 116 return !!binary_value; |
101 } | 117 } |
102 | 118 |
103 namespace { | 119 namespace { |
104 template<class TimeType> | 120 template<class TimeType> |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 const base::Value* internal_value = nullptr; | 170 const base::Value* internal_value = nullptr; |
155 if (dictionary_.GetWithoutPathExpansion(ToInternalKey(key), | 171 if (dictionary_.GetWithoutPathExpansion(ToInternalKey(key), |
156 &internal_value) && | 172 &internal_value) && |
157 internal_value->GetType() == base::Value::TYPE_BINARY) { | 173 internal_value->GetType() == base::Value::TYPE_BINARY) { |
158 return static_cast<const base::BinaryValue*>(internal_value); | 174 return static_cast<const base::BinaryValue*>(internal_value); |
159 } | 175 } |
160 return nullptr; | 176 return nullptr; |
161 } | 177 } |
162 | 178 |
163 } // namespace media | 179 } // namespace media |
OLD | NEW |