OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/media_format.h" | 5 #include "media/base/media_format.h" |
6 | 6 |
7 namespace media { | 7 namespace media { |
8 | 8 |
9 namespace mime_type { | 9 namespace mime_type { |
10 | 10 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 value_map_[key] = Value::CreateBooleanValue(in_value); | 85 value_map_[key] = Value::CreateBooleanValue(in_value); |
86 } | 86 } |
87 | 87 |
88 void MediaFormat::SetAsInteger(const std::string& key, int in_value) { | 88 void MediaFormat::SetAsInteger(const std::string& key, int in_value) { |
89 ReleaseValue(key); | 89 ReleaseValue(key); |
90 value_map_[key] = Value::CreateIntegerValue(in_value); | 90 value_map_[key] = Value::CreateIntegerValue(in_value); |
91 } | 91 } |
92 | 92 |
93 void MediaFormat::SetAsReal(const std::string& key, double in_value) { | 93 void MediaFormat::SetAsReal(const std::string& key, double in_value) { |
94 ReleaseValue(key); | 94 ReleaseValue(key); |
95 value_map_[key] = Value::CreateRealValue(in_value); | 95 value_map_[key] = Value::CreateDoubleValue(in_value); |
96 } | 96 } |
97 | 97 |
98 void MediaFormat::SetAsString(const std::string& key, | 98 void MediaFormat::SetAsString(const std::string& key, |
99 const std::string& in_value) { | 99 const std::string& in_value) { |
100 ReleaseValue(key); | 100 ReleaseValue(key); |
101 value_map_[key] = Value::CreateStringValue(in_value); | 101 value_map_[key] = Value::CreateStringValue(in_value); |
102 } | 102 } |
103 | 103 |
104 bool MediaFormat::GetAsBoolean(const std::string& key, bool* out_value) const { | 104 bool MediaFormat::GetAsBoolean(const std::string& key, bool* out_value) const { |
105 Value* value = GetValue(key); | 105 Value* value = GetValue(key); |
106 return value != NULL && value->GetAsBoolean(out_value); | 106 return value != NULL && value->GetAsBoolean(out_value); |
107 } | 107 } |
108 | 108 |
109 bool MediaFormat::GetAsInteger(const std::string& key, int* out_value) const { | 109 bool MediaFormat::GetAsInteger(const std::string& key, int* out_value) const { |
110 Value* value = GetValue(key); | 110 Value* value = GetValue(key); |
111 return value != NULL && value->GetAsInteger(out_value); | 111 return value != NULL && value->GetAsInteger(out_value); |
112 } | 112 } |
113 | 113 |
114 bool MediaFormat::GetAsReal(const std::string& key, double* out_value) const { | 114 bool MediaFormat::GetAsReal(const std::string& key, double* out_value) const { |
115 Value* value = GetValue(key); | 115 Value* value = GetValue(key); |
116 return value != NULL && value->GetAsReal(out_value); | 116 return value != NULL && value->GetAsDouble(out_value); |
117 } | 117 } |
118 | 118 |
119 bool MediaFormat::GetAsString(const std::string& key, | 119 bool MediaFormat::GetAsString(const std::string& key, |
120 std::string* out_value) const { | 120 std::string* out_value) const { |
121 Value* value = GetValue(key); | 121 Value* value = GetValue(key); |
122 return value != NULL && value->GetAsString(out_value); | 122 return value != NULL && value->GetAsString(out_value); |
123 } | 123 } |
124 | 124 |
125 Value* MediaFormat::GetValue(const std::string& key) const { | 125 Value* MediaFormat::GetValue(const std::string& key) const { |
126 ValueMap::const_iterator value_iter = value_map_.find(key); | 126 ValueMap::const_iterator value_iter = value_map_.find(key); |
127 return (value_iter == value_map_.end()) ? NULL : value_iter->second; | 127 return (value_iter == value_map_.end()) ? NULL : value_iter->second; |
128 } | 128 } |
129 | 129 |
130 void MediaFormat::ReleaseValue(const std::string& key) { | 130 void MediaFormat::ReleaseValue(const std::string& key) { |
131 ValueMap::iterator vm = value_map_.find(key); | 131 ValueMap::iterator vm = value_map_.find(key); |
132 if (vm != value_map_.end()) { | 132 if (vm != value_map_.end()) { |
133 delete vm->second; | 133 delete vm->second; |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 } // namespace media | 137 } // namespace media |
OLD | NEW |