Chromium Code Reviews| 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..7df91f77be9fe33994394e816acda79ec6096381 |
| --- /dev/null |
| +++ b/webrtc/api/video/video_content_type.cc |
| @@ -0,0 +1,63 @@ |
| +/* |
| + * 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 { |
| +const VideoContentType VideoContentType::UNSPECIFIED = VideoContentType({0}); |
| +const VideoContentType VideoContentType::SCREENSHARE = VideoContentType({1}); |
| + |
| +VideoContentType::operator uint8_t() const { |
| + return content_type; |
| +} |
| + |
| +uint8_t VideoContentType::operator=(uint8_t value) { |
| + content_type = value; |
| + return value; |
| +} |
| + |
| +bool VideoContentType::operator==(const VideoContentType& other) { |
| + return content_type == other.content_type; |
| +} |
|
sprang_webrtc
2017/08/24 09:13:16
\n
ilnik
2017/08/25 12:35:07
Done.
|
| +bool VideoContentType::operator==(uint8_t value) { |
| + return content_type == value; |
| +} |
| + |
| +void VideoContentType::SetExperimentId(uint8_t experiment_id) { |
| + // Store in bits 3-5. |
| + RTC_DCHECK(experiment_id < (1 << 3)); |
| + content_type = (content_type & 0b11000111) | ((experiment_id & 0b111) << 3); |
|
sprang_webrtc
2017/08/24 09:13:16
Could you document the format in a comment at the
ilnik
2017/08/25 12:35:07
Done.
|
| +} |
| + |
| +void VideoContentType::SetSimulcastId(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() const { |
| + return (content_type >> 3) & 0b111; |
| +} |
| + |
| +uint8_t VideoContentType::GetSimulcastId() const { |
| + return (content_type >> 1) & 0b11; |
| +} |
| + |
| +bool VideoContentType::IsValidContentType(uint8_t value) { |
| + // Any 6-bit value is allowed. |
| + return value < (1 << 6); |
| +} |
| + |
| +bool VideoContentType::IsScreenshare() const { |
| + return (content_type & 1) > 0; |
| +} |
| + |
| +} // namespace webrtc |