Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1013)

Side by Side Diff: media/base/media_format.cc

Issue 7452016: Remove MediaFormat once and for all. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/media_format.h ('k') | media/base/mock_filters.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "media/base/media_format.h"
6
7 namespace media {
8
9 const char MediaFormat::kURL[] = "URL";
10 const char MediaFormat::kSurfaceFormat[] = "SurfaceFormat";
11 const char MediaFormat::kSurfaceType[] = "SurfaceType";
12 const char MediaFormat::kSampleRate[] = "SampleRate";
13 const char MediaFormat::kSampleBits[] = "SampleBits";
14 const char MediaFormat::kChannels[] = "Channels";
15 const char MediaFormat::kWidth[] = "Width";
16 const char MediaFormat::kHeight[] = "Height";
17
18 MediaFormat::MediaFormat() {}
19
20 MediaFormat::~MediaFormat() {
21 Clear();
22 }
23
24 bool MediaFormat::Contains(const std::string& key) const {
25 return value_map_.find(key) != value_map_.end();
26 }
27
28 void MediaFormat::Clear() {
29 for (ValueMap::iterator iter(value_map_.begin());
30 iter != value_map_.end(); ++iter)
31 delete iter->second;
32 value_map_.clear();
33 }
34
35 void MediaFormat::SetAsBoolean(const std::string& key, bool in_value) {
36 ReleaseValue(key);
37 value_map_[key] = Value::CreateBooleanValue(in_value);
38 }
39
40 void MediaFormat::SetAsInteger(const std::string& key, int in_value) {
41 ReleaseValue(key);
42 value_map_[key] = Value::CreateIntegerValue(in_value);
43 }
44
45 void MediaFormat::SetAsReal(const std::string& key, double in_value) {
46 ReleaseValue(key);
47 value_map_[key] = Value::CreateDoubleValue(in_value);
48 }
49
50 void MediaFormat::SetAsString(const std::string& key,
51 const std::string& in_value) {
52 ReleaseValue(key);
53 value_map_[key] = Value::CreateStringValue(in_value);
54 }
55
56 bool MediaFormat::GetAsBoolean(const std::string& key, bool* out_value) const {
57 Value* value = GetValue(key);
58 return value != NULL && value->GetAsBoolean(out_value);
59 }
60
61 bool MediaFormat::GetAsInteger(const std::string& key, int* out_value) const {
62 Value* value = GetValue(key);
63 return value != NULL && value->GetAsInteger(out_value);
64 }
65
66 bool MediaFormat::GetAsReal(const std::string& key, double* out_value) const {
67 Value* value = GetValue(key);
68 return value != NULL && value->GetAsDouble(out_value);
69 }
70
71 bool MediaFormat::GetAsString(const std::string& key,
72 std::string* out_value) const {
73 Value* value = GetValue(key);
74 return value != NULL && value->GetAsString(out_value);
75 }
76
77 Value* MediaFormat::GetValue(const std::string& key) const {
78 ValueMap::const_iterator value_iter = value_map_.find(key);
79 return (value_iter == value_map_.end()) ? NULL : value_iter->second;
80 }
81
82 void MediaFormat::ReleaseValue(const std::string& key) {
83 ValueMap::iterator vm = value_map_.find(key);
84 if (vm != value_map_.end()) {
85 delete vm->second;
86 }
87 }
88
89 bool MediaFormat::operator==(MediaFormat const& other) const {
90 return value_map_ == other.value_map_;
91 }
92
93 } // namespace media
OLDNEW
« no previous file with comments | « media/base/media_format.h ('k') | media/base/mock_filters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698