Line data Source code
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 WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_CVO_H_
11 : #define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_CVO_H_
12 :
13 : #include "webrtc/api/video/video_rotation.h"
14 : #include "webrtc/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.
22 0 : inline uint8_t ConvertVideoRotationToCVOByte(VideoRotation rotation) {
23 0 : switch (rotation) {
24 : case kVideoRotation_0:
25 0 : return 0;
26 : case kVideoRotation_90:
27 0 : return 1;
28 : case kVideoRotation_180:
29 0 : return 2;
30 : case kVideoRotation_270:
31 0 : return 3;
32 : }
33 0 : RTC_NOTREACHED();
34 0 : return 0;
35 : }
36 :
37 0 : inline VideoRotation ConvertCVOByteToVideoRotation(uint8_t cvo_byte) {
38 : // CVO byte: |0 0 0 0 C F R R|.
39 0 : const uint8_t rotation_bits = cvo_byte & 0x3;
40 0 : switch (rotation_bits) {
41 : case 0:
42 0 : return kVideoRotation_0;
43 : case 1:
44 0 : return kVideoRotation_90;
45 : case 2:
46 0 : return kVideoRotation_180;
47 : case 3:
48 0 : return kVideoRotation_270;
49 : default:
50 0 : RTC_NOTREACHED();
51 0 : return kVideoRotation_0;
52 : }
53 : }
54 :
55 : } // namespace webrtc
56 : #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_CVO_H_
|