| OLD | NEW |
| (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 #ifndef MEDIA_BASE_MEDIA_FORMAT_H_ | |
| 6 #define MEDIA_BASE_MEDIA_FORMAT_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/values.h" | |
| 12 | |
| 13 namespace media { | |
| 14 | |
| 15 // MediaFormat is used to describe the output of a Filter to determine whether | |
| 16 // a downstream filter can accept the output from an upstream filter. | |
| 17 // | |
| 18 // For example, an audio decoder could output key-values for the number of | |
| 19 // channels and the sample rate. A downstream audio renderer would use this | |
| 20 // information to properly initialize the audio hardware before playback | |
| 21 // started. | |
| 22 class MediaFormat { | |
| 23 public: | |
| 24 // Common keys. | |
| 25 static const char kURL[]; | |
| 26 static const char kSurfaceType[]; | |
| 27 static const char kSurfaceFormat[]; | |
| 28 static const char kSampleRate[]; | |
| 29 static const char kSampleBits[]; | |
| 30 static const char kChannels[]; | |
| 31 static const char kWidth[]; | |
| 32 static const char kHeight[]; | |
| 33 | |
| 34 MediaFormat(); | |
| 35 ~MediaFormat(); | |
| 36 | |
| 37 // Basic map operations. | |
| 38 bool empty() const { return value_map_.empty(); } | |
| 39 | |
| 40 bool Contains(const std::string& key) const; | |
| 41 | |
| 42 void Clear(); | |
| 43 | |
| 44 // Value accessors. | |
| 45 void SetAsBoolean(const std::string& key, bool in_value); | |
| 46 void SetAsInteger(const std::string& key, int in_value); | |
| 47 void SetAsReal(const std::string& key, double in_value); | |
| 48 void SetAsString(const std::string& key, const std::string& in_value); | |
| 49 | |
| 50 bool GetAsBoolean(const std::string& key, bool* out_value) const; | |
| 51 bool GetAsInteger(const std::string& key, int* out_value) const; | |
| 52 bool GetAsReal(const std::string& key, double* out_value) const; | |
| 53 bool GetAsString(const std::string& key, std::string* out_value) const; | |
| 54 | |
| 55 bool operator==(MediaFormat const& other) const; | |
| 56 | |
| 57 private: | |
| 58 // Helper to return a value. | |
| 59 Value* GetValue(const std::string& key) const; | |
| 60 | |
| 61 // Helper to release Value of the key | |
| 62 void ReleaseValue(const std::string& key); | |
| 63 | |
| 64 typedef std::map<std::string, Value*> ValueMap; | |
| 65 ValueMap value_map_; | |
| 66 | |
| 67 DISALLOW_COPY_AND_ASSIGN(MediaFormat); | |
| 68 }; | |
| 69 | |
| 70 } // namespace media | |
| 71 | |
| 72 #endif // MEDIA_BASE_MEDIA_FORMAT_H_ | |
| OLD | NEW |