Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(553)

Side by Side Diff: webrtc/api/video/video_content_type.cc

Issue 2986893002: Piggybacking simulcast id and ALR experiment id into video content type extension. (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 /*
16 VideoContentType::VideoContentType(const &uint8_t content_type) :
17 content_type_(content_type) {}
18 */
sprang_webrtc 2017/07/26 14:13:42 Remove
ilnik 2017/07/26 14:49:48 Done.
19
20 const VideoContentType VideoContentType::UNSPECIFIED = VideoContentType({0});
21 const VideoContentType VideoContentType::SCREENSHARE = VideoContentType({1});
22
23 VideoContentType::operator uint8_t() const {
24 return content_type;
25 }
26
27 uint8_t VideoContentType::operator=(const uint8_t& value) {
28 content_type = value;
29 return value;
30 }
31
32 bool VideoContentType::operator==(const VideoContentType& other) {
33 return content_type == other.content_type;
34 }
35 bool VideoContentType::operator==(const uint8_t& value) {
36 return content_type == value;
37 }
38
39 void VideoContentType::SetExperimentId(const uint8_t& experiment_id) {
40 // Store in bits 3-5.
41 RTC_DCHECK(experiment_id < (1 << 3));
42 content_type = (content_type & 0b11000111) | ((experiment_id & 0b111) << 3);
43 }
44
45 void VideoContentType::SetSimulcastId(const uint8_t& simulcast_id) {
46 // Store in bits 1-2.
47 RTC_DCHECK(simulcast_id < (1 << 2));
48 content_type = (content_type & 0b11111001) | ((simulcast_id & 0b11) << 1);
49 }
50
51 uint8_t VideoContentType::GetExperimentId() {
52 return (content_type >> 3) & 0b111;
53 }
54
55 uint8_t VideoContentType::GetSimulcastId() {
56 return (content_type >> 1) & 0b11;
57 }
58
59 bool VideoContentType::IsValidContentType(uint8_t value) {
60 // Any 6-bit value is allowed.
61 return value < (1 << 6);
62 }
63
64 bool VideoContentType::IsScreenshare() {
65 return (content_type & 1) > 0;
66 }
67
68 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698