Add CVO support to Vie layer.

1. standard plumbing CVO through vie layer.
2. added a rtp_cvo.h which has both conversion functions from rtp header byte to/from VideoRotation.

WebRTCVideoEngine will later pass the rotation info in SendFrame() through VieVideoFrameI420.

BUG=4145
R=mflodman@webrtc.org, tommi@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/46429007

Cr-Original-Commit-Position: refs/heads/master@{#8703}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: fdd10579496123c9a7fdc0bf185e2a26a12ed340
diff --git a/video_engine/vie_receiver.cc b/video_engine/vie_receiver.cc
index 0d1f1ad..e61c82b 100644
--- a/video_engine/vie_receiver.cc
+++ b/video_engine/vie_receiver.cc
@@ -16,6 +16,7 @@
 #include "webrtc/modules/rtp_rtcp/interface/fec_receiver.h"
 #include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h"
 #include "webrtc/modules/rtp_rtcp/interface/remote_ntp_time_estimator.h"
+#include "webrtc/modules/rtp_rtcp/interface/rtp_cvo.h"
 #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h"
 #include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h"
 #include "webrtc/modules/rtp_rtcp/interface/rtp_receiver.h"
@@ -58,6 +59,7 @@
       receiving_(false),
       restored_packet_in_use_(false),
       receiving_ast_enabled_(false),
+      receiving_cvo_enabled_(false),
       last_packet_log_ms_(-1) {
   assert(remote_bitrate_estimator);
 }
@@ -187,6 +189,22 @@
   }
 }
 
+bool ViEReceiver::SetReceiveVideoRotationStatus(bool enable, int id) {
+  if (enable) {
+    if (rtp_header_parser_->RegisterRtpHeaderExtension(
+            kRtpExtensionVideoRotation, id)) {
+      receiving_cvo_enabled_ = true;
+      return true;
+    } else {
+      return false;
+    }
+  } else {
+    receiving_cvo_enabled_ = false;
+    return rtp_header_parser_->DeregisterRtpHeaderExtension(
+        kRtpExtensionVideoRotation);
+  }
+}
+
 int ViEReceiver::ReceivedRTPPacket(const void* rtp_packet,
                                    size_t rtp_packet_length,
                                    const PacketTime& packet_time) {
@@ -382,6 +400,11 @@
     return;
   }
   rtp_header.type.Video.codec = payload_specific.Video.videoCodecType;
+  rtp_header.type.Video.rotation = kVideoRotation_0;
+  if (header.extension.hasVideoRotation) {
+    rtp_header.type.Video.rotation =
+        ConvertCVOByteToVideoRotation(header.extension.videoRotation);
+  }
   OnReceivedPayloadData(NULL, 0, &rtp_header);
 }