tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

rtp_cvo.h (1739B)


      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 <cstdint>
     14 
     15 #include "api/video/video_rotation.h"
     16 #include "rtc_base/checks.h"
     17 
     18 namespace webrtc {
     19 
     20 // Please refer to http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/
     21 // 12.07.00_60/ts_126114v120700p.pdf Section 7.4.5. The rotation of a frame is
     22 // the clockwise angle the frames must be rotated in order to display the frames
     23 // correctly if the display is rotated in its natural orientation.
     24 inline uint8_t ConvertVideoRotationToCVOByte(VideoRotation rotation) {
     25  switch (rotation) {
     26    case kVideoRotation_0:
     27      return 0;
     28    case kVideoRotation_90:
     29      return 1;
     30    case kVideoRotation_180:
     31      return 2;
     32    case kVideoRotation_270:
     33      return 3;
     34  }
     35  RTC_DCHECK_NOTREACHED();
     36  return 0;
     37 }
     38 
     39 inline VideoRotation ConvertCVOByteToVideoRotation(uint8_t cvo_byte) {
     40  // CVO byte: |0 0 0 0 C F R R|.
     41  const uint8_t rotation_bits = cvo_byte & 0x3;
     42  switch (rotation_bits) {
     43    case 0:
     44      return kVideoRotation_0;
     45    case 1:
     46      return kVideoRotation_90;
     47    case 2:
     48      return kVideoRotation_180;
     49    case 3:
     50      return kVideoRotation_270;
     51    default:
     52      RTC_DCHECK_NOTREACHED();
     53      return kVideoRotation_0;
     54  }
     55 }
     56 
     57 }  // namespace webrtc
     58 #endif  // MODULES_RTP_RTCP_INCLUDE_RTP_CVO_H_