| Index: webrtc/api/video/video_content_type.cc
|
| diff --git a/webrtc/api/video/video_content_type.cc b/webrtc/api/video/video_content_type.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..2c9cfb3c5e3158ce8c3ca4187f8e7b88dc9c1f00
|
| --- /dev/null
|
| +++ b/webrtc/api/video/video_content_type.cc
|
| @@ -0,0 +1,68 @@
|
| +/*
|
| + * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
| + *
|
| + * Use of this source code is governed by a BSD-style license
|
| + * that can be found in the LICENSE file in the root of the source
|
| + * tree. An additional intellectual property rights grant can be found
|
| + * in the file PATENTS. All contributing project authors may
|
| + * be found in the AUTHORS file in the root of the source tree.
|
| + */
|
| +
|
| +#include "webrtc/api/video/video_content_type.h"
|
| +#include "webrtc/rtc_base/checks.h"
|
| +
|
| +namespace webrtc {
|
| +/*
|
| +VideoContentType::VideoContentType(const &uint8_t content_type) :
|
| + content_type_(content_type) {}
|
| +*/
|
| +
|
| +const VideoContentType VideoContentType::UNSPECIFIED = VideoContentType({0});
|
| +const VideoContentType VideoContentType::SCREENSHARE = VideoContentType({1});
|
| +
|
| +VideoContentType::operator uint8_t() const {
|
| + return content_type;
|
| +}
|
| +
|
| +uint8_t VideoContentType::operator=(const uint8_t& value) {
|
| + content_type = value;
|
| + return value;
|
| +}
|
| +
|
| +bool VideoContentType::operator==(const VideoContentType& other) {
|
| + return content_type == other.content_type;
|
| +}
|
| +bool VideoContentType::operator==(const uint8_t& value) {
|
| + return content_type == value;
|
| +}
|
| +
|
| +void VideoContentType::SetExperimentId(const uint8_t& experiment_id) {
|
| + // Store in bits 3-5.
|
| + RTC_DCHECK(experiment_id < (1 << 3));
|
| + content_type = (content_type & 0b11000111) | ((experiment_id & 0b111) << 3);
|
| +}
|
| +
|
| +void VideoContentType::SetSimulcastId(const uint8_t& simulcast_id) {
|
| + // Store in bits 1-2.
|
| + RTC_DCHECK(simulcast_id < (1 << 2));
|
| + content_type = (content_type & 0b11111001) | ((simulcast_id & 0b11) << 1);
|
| +}
|
| +
|
| +uint8_t VideoContentType::GetExperimentId() {
|
| + return (content_type >> 3) & 0b111;
|
| +}
|
| +
|
| +uint8_t VideoContentType::GetSimulcastId() {
|
| + return (content_type >> 1) & 0b11;
|
| +}
|
| +
|
| +bool VideoContentType::IsValidContentType(uint8_t value) {
|
| + // Any 6-bit value is allowed.
|
| + return value < (1 << 6);
|
| +}
|
| +
|
| +bool VideoContentType::IsScreenshare() {
|
| + return (content_type & 1) > 0;
|
| +}
|
| +
|
| +} // namespace webrtc
|
|
|