blob: bc0b4ee95c5d871c005a308fd13e87e86dbf2827 [file] [log] [blame]
Henrik Kjellanderff761fb2015-11-04 08:31:52 +01001/*
2 * Copyright (c) 2015 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 */
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020010#ifndef MODULES_RTP_RTCP_INCLUDE_RTP_CVO_H_
11#define MODULES_RTP_RTCP_INCLUDE_RTP_CVO_H_
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010012
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020013#include "api/video/video_rotation.h"
14#include "rtc_base/checks.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010015
16namespace webrtc {
17
18// Please refer to http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/
19// 12.07.00_60/ts_126114v120700p.pdf Section 7.4.5. The rotation of a frame is
20// the clockwise angle the frames must be rotated in order to display the frames
21// correctly if the display is rotated in its natural orientation.
22inline uint8_t ConvertVideoRotationToCVOByte(VideoRotation rotation) {
23 switch (rotation) {
24 case kVideoRotation_0:
25 return 0;
26 case kVideoRotation_90:
27 return 1;
28 case kVideoRotation_180:
29 return 2;
30 case kVideoRotation_270:
31 return 3;
32 }
Danil Chapovalov96150a62016-03-07 10:55:21 +010033 RTC_NOTREACHED();
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010034 return 0;
35}
36
magjed71eb61c2016-09-08 03:24:58 -070037inline VideoRotation ConvertCVOByteToVideoRotation(uint8_t cvo_byte) {
38 // CVO byte: |0 0 0 0 C F R R|.
39 const uint8_t rotation_bits = cvo_byte & 0x3;
40 switch (rotation_bits) {
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010041 case 0:
42 return kVideoRotation_0;
43 case 1:
44 return kVideoRotation_90;
45 case 2:
46 return kVideoRotation_180;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010047 case 3:
48 return kVideoRotation_270;
49 default:
Danil Chapovalov96150a62016-03-07 10:55:21 +010050 RTC_NOTREACHED();
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010051 return kVideoRotation_0;
52 }
53}
54
55} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020056#endif // MODULES_RTP_RTCP_INCLUDE_RTP_CVO_H_