OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #include "webrtc/api/video/video_content_type.h" | |
12 #include "webrtc/rtc_base/checks.h" | |
13 | |
14 namespace webrtc { | |
15 const VideoContentType VideoContentType::UNSPECIFIED = VideoContentType({0}); | |
16 const VideoContentType VideoContentType::SCREENSHARE = VideoContentType({1}); | |
17 | |
18 VideoContentType::operator uint8_t() const { | |
19 return content_type; | |
20 } | |
21 | |
22 uint8_t VideoContentType::operator=(uint8_t value) { | |
23 content_type = value; | |
24 return value; | |
25 } | |
26 | |
27 bool VideoContentType::operator==(const VideoContentType& other) { | |
28 return content_type == other.content_type; | |
29 } | |
sprang_webrtc
2017/08/24 09:13:16
\n
ilnik
2017/08/25 12:35:07
Done.
| |
30 bool VideoContentType::operator==(uint8_t value) { | |
31 return content_type == value; | |
32 } | |
33 | |
34 void VideoContentType::SetExperimentId(uint8_t experiment_id) { | |
35 // Store in bits 3-5. | |
36 RTC_DCHECK(experiment_id < (1 << 3)); | |
37 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.
| |
38 } | |
39 | |
40 void VideoContentType::SetSimulcastId(uint8_t simulcast_id) { | |
41 // Store in bits 1-2. | |
42 RTC_DCHECK(simulcast_id < (1 << 2)); | |
43 content_type = (content_type & 0b11111001) | ((simulcast_id & 0b11) << 1); | |
44 } | |
45 | |
46 uint8_t VideoContentType::GetExperimentId() const { | |
47 return (content_type >> 3) & 0b111; | |
48 } | |
49 | |
50 uint8_t VideoContentType::GetSimulcastId() const { | |
51 return (content_type >> 1) & 0b11; | |
52 } | |
53 | |
54 bool VideoContentType::IsValidContentType(uint8_t value) { | |
55 // Any 6-bit value is allowed. | |
56 return value < (1 << 6); | |
57 } | |
58 | |
59 bool VideoContentType::IsScreenshare() const { | |
60 return (content_type & 1) > 0; | |
61 } | |
62 | |
63 } // namespace webrtc | |
OLD | NEW |