summaryrefslogtreecommitdiffstats
path: root/ppapi/shared_impl/media_stream_video_track_shared.cc
blob: 0ca894af62c2191ad5eca3827ca4a984e2b35807 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// 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 = 4096;
const int32_t kMaxHeight = 4096;

}  // namespace

namespace ppapi {

// static
bool MediaStreamVideoTrackShared::VerifyAttributes(
    const Attributes& attributes) {
  if (attributes.buffers < 0)
    return false;
  if (attributes.format < PP_VIDEOFRAME_FORMAT_UNKNOWN ||
      attributes.format > PP_VIDEOFRAME_FORMAT_LAST) {
    return false;
  }
  if (attributes.width < 0 ||
      attributes.width > kMaxWidth ||
      attributes.width & 0x3) {
    return false;
  }
  if (attributes.height < 0 ||
      attributes.height > kMaxHeight ||
      attributes.height & 0x3) {
    return false;
  }
  return true;
}

}  // namespace ppapi