| 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 #ifndef MEDIA_BASE_VIDEO_FRAME_METADATA_H_ | 5 #ifndef MEDIA_BASE_VIDEO_FRAME_METADATA_H_ |
| 6 #define MEDIA_BASE_VIDEO_FRAME_METADATA_H_ | 6 #define MEDIA_BASE_VIDEO_FRAME_METADATA_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "media/base/media_export.h" | 15 #include "media/base/media_export.h" |
| 16 #include "media/base/video_rotation.h" |
| 16 | 17 |
| 17 namespace media { | 18 namespace media { |
| 18 | 19 |
| 19 class MEDIA_EXPORT VideoFrameMetadata { | 20 class MEDIA_EXPORT VideoFrameMetadata { |
| 20 public: | 21 public: |
| 21 enum Key { | 22 enum Key { |
| 22 // Sources of VideoFrames use this marker to indicate that the associated | 23 // Sources of VideoFrames use this marker to indicate that the associated |
| 23 // VideoFrame can be overlayed, case in which its contents do not need to be | 24 // VideoFrame can be overlayed, case in which its contents do not need to be |
| 24 // further composited but displayed directly. Use Get/SetBoolean() for | 25 // further composited but displayed directly. Use Get/SetBoolean() for |
| 25 // this Key. | 26 // this Key. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // is available for encoding and/or sufficient bandwidth is available for | 100 // is available for encoding and/or sufficient bandwidth is available for |
| 100 // transmission over the network. The maximum of the two utilization | 101 // transmission over the network. The maximum of the two utilization |
| 101 // measurements would be used as feedback. | 102 // measurements would be used as feedback. |
| 102 RESOURCE_UTILIZATION, | 103 RESOURCE_UTILIZATION, |
| 103 | 104 |
| 104 // Sources of VideoFrames use this marker to indicate that an instance of | 105 // Sources of VideoFrames use this marker to indicate that an instance of |
| 105 // VideoFrameExternalResources produced from the associated video frame | 106 // VideoFrameExternalResources produced from the associated video frame |
| 106 // should use read lock fences. | 107 // should use read lock fences. |
| 107 READ_LOCK_FENCES_ENABLED, | 108 READ_LOCK_FENCES_ENABLED, |
| 108 | 109 |
| 110 // Indicates that the frame is rotated. |
| 111 ROTATION, |
| 112 |
| 109 NUM_KEYS | 113 NUM_KEYS |
| 110 }; | 114 }; |
| 111 | 115 |
| 112 VideoFrameMetadata(); | 116 VideoFrameMetadata(); |
| 113 ~VideoFrameMetadata(); | 117 ~VideoFrameMetadata(); |
| 114 | 118 |
| 115 bool HasKey(Key key) const; | 119 bool HasKey(Key key) const; |
| 116 | 120 |
| 117 void Clear() { dictionary_.Clear(); } | 121 void Clear() { dictionary_.Clear(); } |
| 118 | 122 |
| 119 // Setters. Overwrites existing value, if present. | 123 // Setters. Overwrites existing value, if present. |
| 120 void SetBoolean(Key key, bool value); | 124 void SetBoolean(Key key, bool value); |
| 121 void SetInteger(Key key, int value); | 125 void SetInteger(Key key, int value); |
| 122 void SetDouble(Key key, double value); | 126 void SetDouble(Key key, double value); |
| 127 void SetRotation(Key key, VideoRotation value); |
| 123 void SetString(Key key, const std::string& value); | 128 void SetString(Key key, const std::string& value); |
| 124 void SetTimeDelta(Key key, const base::TimeDelta& value); | 129 void SetTimeDelta(Key key, const base::TimeDelta& value); |
| 125 void SetTimeTicks(Key key, const base::TimeTicks& value); | 130 void SetTimeTicks(Key key, const base::TimeTicks& value); |
| 126 void SetValue(Key key, std::unique_ptr<base::Value> value); | 131 void SetValue(Key key, std::unique_ptr<base::Value> value); |
| 127 | 132 |
| 128 // Getters. Returns true if |key| is present, and its value has been set. | 133 // Getters. Returns true if |key| is present, and its value has been set. |
| 129 bool GetBoolean(Key key, bool* value) const WARN_UNUSED_RESULT; | 134 bool GetBoolean(Key key, bool* value) const WARN_UNUSED_RESULT; |
| 130 bool GetInteger(Key key, int* value) const WARN_UNUSED_RESULT; | 135 bool GetInteger(Key key, int* value) const WARN_UNUSED_RESULT; |
| 131 bool GetDouble(Key key, double* value) const WARN_UNUSED_RESULT; | 136 bool GetDouble(Key key, double* value) const WARN_UNUSED_RESULT; |
| 137 bool GetRotation(Key key, VideoRotation* value) const WARN_UNUSED_RESULT; |
| 132 bool GetString(Key key, std::string* value) const WARN_UNUSED_RESULT; | 138 bool GetString(Key key, std::string* value) const WARN_UNUSED_RESULT; |
| 133 bool GetTimeDelta(Key key, base::TimeDelta* value) const WARN_UNUSED_RESULT; | 139 bool GetTimeDelta(Key key, base::TimeDelta* value) const WARN_UNUSED_RESULT; |
| 134 bool GetTimeTicks(Key key, base::TimeTicks* value) const WARN_UNUSED_RESULT; | 140 bool GetTimeTicks(Key key, base::TimeTicks* value) const WARN_UNUSED_RESULT; |
| 135 | 141 |
| 136 // Returns null if |key| was not present. | 142 // Returns null if |key| was not present. |
| 137 const base::Value* GetValue(Key key) const WARN_UNUSED_RESULT; | 143 const base::Value* GetValue(Key key) const WARN_UNUSED_RESULT; |
| 138 | 144 |
| 139 // Convenience method that returns true if |key| exists and is set to true. | 145 // Convenience method that returns true if |key| exists and is set to true. |
| 140 bool IsTrue(Key key) const WARN_UNUSED_RESULT; | 146 bool IsTrue(Key key) const WARN_UNUSED_RESULT; |
| 141 | 147 |
| 142 // For serialization. | 148 // For serialization. |
| 143 void MergeInternalValuesInto(base::DictionaryValue* out) const; | 149 void MergeInternalValuesInto(base::DictionaryValue* out) const; |
| 144 void MergeInternalValuesFrom(const base::DictionaryValue& in); | 150 void MergeInternalValuesFrom(const base::DictionaryValue& in); |
| 145 | 151 |
| 146 // Merges internal values from |metadata_source|. | 152 // Merges internal values from |metadata_source|. |
| 147 void MergeMetadataFrom(const VideoFrameMetadata* metadata_source); | 153 void MergeMetadataFrom(const VideoFrameMetadata* metadata_source); |
| 148 | 154 |
| 149 private: | 155 private: |
| 150 const base::BinaryValue* GetBinaryValue(Key key) const; | 156 const base::BinaryValue* GetBinaryValue(Key key) const; |
| 151 | 157 |
| 152 base::DictionaryValue dictionary_; | 158 base::DictionaryValue dictionary_; |
| 153 | 159 |
| 154 DISALLOW_COPY_AND_ASSIGN(VideoFrameMetadata); | 160 DISALLOW_COPY_AND_ASSIGN(VideoFrameMetadata); |
| 155 }; | 161 }; |
| 156 | 162 |
| 157 } // namespace media | 163 } // namespace media |
| 158 | 164 |
| 159 #endif // MEDIA_BASE_VIDEO_FRAME_METADATA_H_ | 165 #endif // MEDIA_BASE_VIDEO_FRAME_METADATA_H_ |
| OLD | NEW |