Chromium Code Reviews| Index: ppapi/shared_impl/media_stream_video_track_shared.cc |
| diff --git a/ppapi/shared_impl/media_stream_video_track_shared.cc b/ppapi/shared_impl/media_stream_video_track_shared.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7e16c680e3228aa7898c6e19e1d416dd9cec623f |
| --- /dev/null |
| +++ b/ppapi/shared_impl/media_stream_video_track_shared.cc |
| @@ -0,0 +1,58 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ppapi/shared_impl/media_stream_video_track_shared.h" |
| + |
| +#include "base/logging.h" |
| + |
| +namespace { |
| + |
| +const int32_t kMaxWidth = 4069; |
| +const int32_t kMaxHeight = 4069; |
| + |
| +} // namespace |
| + |
| +namespace ppapi { |
| + |
| +// static |
| +bool MediaStreamVideoTrackShared::VerifyAttributes( |
| + const Attributes& attributes) { |
| + if (attributes.mask & Attributes::MASK_BUFFERS) { |
| + if (attributes.buffers < 0) |
| + return false; |
| + } else if (attributes.buffers) { |
|
Ronghua Wu (Left Chromium)
2014/02/12 19:54:15
can the value 0 means not set instead of using an
Peng
2014/02/13 17:19:11
My idea is:
If the mask is 1 and value is 0. it m
|
| + return false; |
| + } |
| + |
| + if (attributes.mask & Attributes::MASK_FORMAT) { |
| + if (attributes.format < PP_VIDEOFRAME_FORMAT_UNKNOWN || |
| + attributes.format > PP_VIDEOFRAME_FORMAT_LAST) { |
| + return false; |
| + } |
| + } else if (attributes.format) { |
| + return false; |
| + } |
| + |
| + if (attributes.mask & Attributes::MASK_WIDTH) { |
| + if (attributes.width < 0 || attributes.width > kMaxWidth) |
| + return false; |
| + if (attributes.width & 0x3) |
| + return false; |
| + } else if (attributes.width) { |
| + return false; |
| + } |
| + |
| + if (attributes.mask & Attributes::MASK_HEIGHT) { |
| + if (attributes.height < 0 || attributes.height > kMaxHeight) |
| + return false; |
| + if (attributes.height & 0x3) |
| + return false; |
| + } else if (attributes.height) { |
| + return false; |
| + } |
| + |
| + return true; |
| +} |
| + |
| +} // namespace ppapi |