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"
15 class MEDIA_EXPORT VideoFrameMetadata
{
18 // Video capture begin/end timestamps. Consumers can use these values for
19 // dynamic optimizations, logging stats, etc. Use Get/SetTimeTicks() for
24 // Some VideoFrames have an indication of the color space used. Use
25 // GetInteger()/SetInteger() and VideoFrame::ColorSpace enumeration.
28 // Indicates if the current frame is the End of its current Stream.
31 // The estimated duration of this frame (i.e., the amount of time between
32 // the media timestamp of this frame and the next). Note that this is not
33 // the same information provided by FRAME_RATE as the FRAME_DURATION can
34 // vary unpredictably for every frame. Consumers can use this to optimize
35 // playback scheduling, make encoding quality decisions, and/or compute
36 // frame-level resource utilization stats. Use Get/SetTimeDelta() for this
40 // Represents either the fixed frame rate, or the maximum frame rate to
41 // expect from a variable-rate source. This value generally remains the
42 // same for all frames in the same session. Use Get/SetDouble() for this
50 ~VideoFrameMetadata();
52 bool HasKey(Key key
) const;
54 void Clear() { dictionary_
.Clear(); }
56 // Setters. Overwrites existing value, if present.
57 void SetBoolean(Key key
, bool value
);
58 void SetInteger(Key key
, int value
);
59 void SetDouble(Key key
, double value
);
60 void SetString(Key key
, const std::string
& value
);
61 void SetTimeDelta(Key key
, const base::TimeDelta
& value
);
62 void SetTimeTicks(Key key
, const base::TimeTicks
& value
);
63 void SetValue(Key key
, scoped_ptr
<base::Value
> value
);
65 // Getters. Returns true if |key| is present, and its value has been set.
66 bool GetBoolean(Key key
, bool* value
) const WARN_UNUSED_RESULT
;
67 bool GetInteger(Key key
, int* value
) const WARN_UNUSED_RESULT
;
68 bool GetDouble(Key key
, double* value
) const WARN_UNUSED_RESULT
;
69 bool GetString(Key key
, std::string
* value
) const WARN_UNUSED_RESULT
;
70 bool GetTimeDelta(Key key
, base::TimeDelta
* value
) const WARN_UNUSED_RESULT
;
71 bool GetTimeTicks(Key key
, base::TimeTicks
* value
) const WARN_UNUSED_RESULT
;
73 // Returns null if |key| was not present.
74 const base::Value
* GetValue(Key key
) const WARN_UNUSED_RESULT
;
77 void MergeInternalValuesInto(base::DictionaryValue
* out
) const;
78 void MergeInternalValuesFrom(const base::DictionaryValue
& in
);
81 const base::BinaryValue
* GetBinaryValue(Key key
) const;
83 base::DictionaryValue dictionary_
;
85 DISALLOW_COPY_AND_ASSIGN(VideoFrameMetadata
);
90 #endif // MEDIA_BASE_VIDEO_FRAME_METADATA_H_