diff options
author | miu <miu@chromium.org> | 2015-05-19 17:31:35 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-20 00:31:37 +0000 |
commit | 1cb99158245ac2a36ea0ee5e20fd2fff71c864d1 (patch) | |
tree | 3b30842836776bc11d678ec0991305243b6a888e /media/base/video_frame_metadata.cc | |
parent | 324a169646a722c4be1e222b3bb053c46a65956e (diff) | |
download | chromium_src-1cb99158245ac2a36ea0ee5e20fd2fff71c864d1.zip chromium_src-1cb99158245ac2a36ea0ee5e20fd2fff71c864d1.tar.gz chromium_src-1cb99158245ac2a36ea0ee5e20fd2fff71c864d1.tar.bz2 |
New FRAME_DURATION VideoFrameMetadata, with Cast Streaming use case.
Adds a new FRAME_DURATION option to VideoFrameMetadata, which can be
used by consumers of video frames to improve performance (e.g., encoding
quality).
This change also adds population of the new metadata by the desktop/tab
capture pipeline, and consumption by Cast Streaming's software VP8
encoder. Having accurate frame duration information improves the
encoder's ability to choose a compression quality level that better
meets the target encode bitrate.
Later changes will require this in order to compute resource utilization
feedback signals (see bug for details).
BUG=156767
Review URL: https://codereview.chromium.org/1146723002
Cr-Commit-Position: refs/heads/master@{#330661}
Diffstat (limited to 'media/base/video_frame_metadata.cc')
-rw-r--r-- | media/base/video_frame_metadata.cc | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/media/base/video_frame_metadata.cc b/media/base/video_frame_metadata.cc index d14bbe9..d663612 100644 --- a/media/base/video_frame_metadata.cc +++ b/media/base/video_frame_metadata.cc @@ -47,14 +47,27 @@ void VideoFrameMetadata::SetString(Key key, const std::string& value) { base::BinaryValue::CreateWithCopiedBuffer(value.data(), value.size())); } -void VideoFrameMetadata::SetTimeTicks(Key key, const base::TimeTicks& value) { +namespace { +template<class TimeType> +void SetTimeValue(VideoFrameMetadata::Key key, + const TimeType& value, + base::DictionaryValue* dictionary) { const int64 internal_value = value.ToInternalValue(); - dictionary_.SetWithoutPathExpansion( + dictionary->SetWithoutPathExpansion( ToInternalKey(key), base::BinaryValue::CreateWithCopiedBuffer( reinterpret_cast<const char*>(&internal_value), sizeof(internal_value))); } +} // namespace + +void VideoFrameMetadata::SetTimeDelta(Key key, const base::TimeDelta& value) { + SetTimeValue(key, value, &dictionary_); +} + +void VideoFrameMetadata::SetTimeTicks(Key key, const base::TimeTicks& value) { + SetTimeValue(key, value, &dictionary_); +} void VideoFrameMetadata::SetValue(Key key, scoped_ptr<base::Value> value) { dictionary_.SetWithoutPathExpansion(ToInternalKey(key), value.Pass()); @@ -83,16 +96,27 @@ bool VideoFrameMetadata::GetString(Key key, std::string* value) const { return !!binary_value; } -bool VideoFrameMetadata::GetTimeTicks(Key key, base::TimeTicks* value) const { +namespace { +template<class TimeType> +bool ToTimeValue(const base::BinaryValue& binary_value, TimeType* value) { DCHECK(value); + int64 internal_value; + if (binary_value.GetSize() != sizeof(internal_value)) + return false; + memcpy(&internal_value, binary_value.GetBuffer(), sizeof(internal_value)); + *value = TimeType::FromInternalValue(internal_value); + return true; +} +} // namespace + +bool VideoFrameMetadata::GetTimeDelta(Key key, base::TimeDelta* value) const { const base::BinaryValue* const binary_value = GetBinaryValue(key); - if (binary_value && binary_value->GetSize() == sizeof(int64)) { - int64 internal_value; - memcpy(&internal_value, binary_value->GetBuffer(), sizeof(internal_value)); - *value = base::TimeTicks::FromInternalValue(internal_value); - return true; - } - return false; + return binary_value && ToTimeValue(*binary_value, value); +} + +bool VideoFrameMetadata::GetTimeTicks(Key key, base::TimeTicks* value) const { + const base::BinaryValue* const binary_value = GetBinaryValue(key); + return binary_value && ToTimeValue(*binary_value, value); } const base::Value* VideoFrameMetadata::GetValue(Key key) const { |