Delete unused downloads page asset.
[chromium-blink-merge.git] / media / base / video_frame_metadata.h
blobbd330f0ed3bfa598ded89b9cc9915a58e7405ca0
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
3 // found in the LICENSE file.
5 #ifndef MEDIA_BASE_VIDEO_FRAME_METADATA_H_
6 #define MEDIA_BASE_VIDEO_FRAME_METADATA_H_
8 #include "base/compiler_specific.h"
9 #include "base/time/time.h"
10 #include "base/values.h"
11 #include "media/base/media_export.h"
13 namespace media {
15 class MEDIA_EXPORT VideoFrameMetadata {
16 public:
17 enum Key {
18 // Sources of VideoFrames use this marker to indicate that the associated
19 // VideoFrame can be overlayed, case in which its contents do not need to be
20 // further composited but displayed directly. Use Get/SetBoolean() for
21 // this Key.
22 ALLOW_OVERLAY,
24 // Video capture begin/end timestamps. Consumers can use these values for
25 // dynamic optimizations, logging stats, etc. Use Get/SetTimeTicks() for
26 // these keys.
27 CAPTURE_BEGIN_TIME,
28 CAPTURE_END_TIME,
30 // Some VideoFrames have an indication of the color space used. Use
31 // GetInteger()/SetInteger() and ColorSpace enumeration.
32 COLOR_SPACE,
34 // Indicates if the current frame is the End of its current Stream. Use
35 // Get/SetBoolean() for this Key.
36 END_OF_STREAM,
38 // The estimated duration of this frame (i.e., the amount of time between
39 // the media timestamp of this frame and the next). Note that this is not
40 // the same information provided by FRAME_RATE as the FRAME_DURATION can
41 // vary unpredictably for every frame. Consumers can use this to optimize
42 // playback scheduling, make encoding quality decisions, and/or compute
43 // frame-level resource utilization stats. Use Get/SetTimeDelta() for this
44 // key.
45 FRAME_DURATION,
47 // Represents either the fixed frame rate, or the maximum frame rate to
48 // expect from a variable-rate source. This value generally remains the
49 // same for all frames in the same session. Use Get/SetDouble() for this
50 // key.
51 FRAME_RATE,
53 // A feedback signal that indicates the fraction of the tolerable maximum
54 // amount of resources that were utilized to process this frame. A producer
55 // can check this value after-the-fact, usually via a VideoFrame destruction
56 // observer, to determine whether the consumer can handle more or less data
57 // volume, and achieve the right quality versus performance trade-off.
59 // Use Get/SetDouble() for this key. Values are interpreted as follows:
60 // Less than 0.0 is meaningless and should be ignored. 1.0 indicates a
61 // maximum sustainable utilization. Greater than 1.0 indicates the consumer
62 // is likely to stall or drop frames if the data volume is not reduced.
64 // Example: In a system that encodes and transmits video frames over the
65 // network, this value can be used to indicate whether sufficient CPU
66 // is available for encoding and/or sufficient bandwidth is available for
67 // transmission over the network. The maximum of the two utilization
68 // measurements would be used as feedback.
69 RESOURCE_UTILIZATION,
71 NUM_KEYS
74 VideoFrameMetadata();
75 ~VideoFrameMetadata();
77 bool HasKey(Key key) const;
79 void Clear() { dictionary_.Clear(); }
81 // Setters. Overwrites existing value, if present.
82 void SetBoolean(Key key, bool value);
83 void SetInteger(Key key, int value);
84 void SetDouble(Key key, double value);
85 void SetString(Key key, const std::string& value);
86 void SetTimeDelta(Key key, const base::TimeDelta& value);
87 void SetTimeTicks(Key key, const base::TimeTicks& value);
88 void SetValue(Key key, scoped_ptr<base::Value> value);
90 // Getters. Returns true if |key| is present, and its value has been set.
91 bool GetBoolean(Key key, bool* value) const WARN_UNUSED_RESULT;
92 bool GetInteger(Key key, int* value) const WARN_UNUSED_RESULT;
93 bool GetDouble(Key key, double* value) const WARN_UNUSED_RESULT;
94 bool GetString(Key key, std::string* value) const WARN_UNUSED_RESULT;
95 bool GetTimeDelta(Key key, base::TimeDelta* value) const WARN_UNUSED_RESULT;
96 bool GetTimeTicks(Key key, base::TimeTicks* value) const WARN_UNUSED_RESULT;
98 // Returns null if |key| was not present.
99 const base::Value* GetValue(Key key) const WARN_UNUSED_RESULT;
101 // Convenience method that returns true if |key| exists and is set to true.
102 bool IsTrue(Key key) const WARN_UNUSED_RESULT;
104 // For serialization.
105 void MergeInternalValuesInto(base::DictionaryValue* out) const;
106 void MergeInternalValuesFrom(const base::DictionaryValue& in);
108 private:
109 const base::BinaryValue* GetBinaryValue(Key key) const;
111 base::DictionaryValue dictionary_;
113 DISALLOW_COPY_AND_ASSIGN(VideoFrameMetadata);
116 } // namespace media
118 #endif // MEDIA_BASE_VIDEO_FRAME_METADATA_H_