Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 10 | #ifndef MODULES_RTP_RTCP_INCLUDE_RTP_CVO_H_ |
| 11 | #define MODULES_RTP_RTCP_INCLUDE_RTP_CVO_H_ |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 12 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 13 | #include "api/video/video_rotation.h" |
| 14 | #include "rtc_base/checks.h" |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 15 | |
| 16 | namespace 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. |
| 22 | inline 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 Chapovalov | 96150a6 | 2016-03-07 10:55:21 +0100 | [diff] [blame] | 33 | RTC_NOTREACHED(); |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 34 | return 0; |
| 35 | } |
| 36 | |
magjed | 71eb61c | 2016-09-08 03:24:58 -0700 | [diff] [blame] | 37 | inline 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 Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 41 | case 0: |
| 42 | return kVideoRotation_0; |
| 43 | case 1: |
| 44 | return kVideoRotation_90; |
| 45 | case 2: |
| 46 | return kVideoRotation_180; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 47 | case 3: |
| 48 | return kVideoRotation_270; |
| 49 | default: |
Danil Chapovalov | 96150a6 | 2016-03-07 10:55:21 +0100 | [diff] [blame] | 50 | RTC_NOTREACHED(); |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 51 | return kVideoRotation_0; |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | } // namespace webrtc |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 56 | #endif // MODULES_RTP_RTCP_INCLUDE_RTP_CVO_H_ |