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 */ 10 #ifndef MODULES_RTP_RTCP_INCLUDE_RTP_CVO_H_ 11 #define MODULES_RTP_RTCP_INCLUDE_RTP_CVO_H_ 12 13 #include "api/video/video_rotation.h" 14 #include "rtc_base/checks.h" 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. ConvertVideoRotationToCVOByte(VideoRotation rotation)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 } 33 RTC_NOTREACHED(); 34 return 0; 35 } 36 ConvertCVOByteToVideoRotation(uint8_t cvo_byte)37inline 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) { 41 case 0: 42 return kVideoRotation_0; 43 case 1: 44 return kVideoRotation_90; 45 case 2: 46 return kVideoRotation_180; 47 case 3: 48 return kVideoRotation_270; 49 default: 50 RTC_NOTREACHED(); 51 return kVideoRotation_0; 52 } 53 } 54 55 } // namespace webrtc 56 #endif // MODULES_RTP_RTCP_INCLUDE_RTP_CVO_H_ 57