libmix: set dynamic rotation degree to video driver

BZ: 148092
When the rotation degree changes, set the new degree to
video driver through API vaSetDisplayAttributes at runtime

Change-Id: I10dc3480e315a0fc5e1ec4492108d784b9ba9920
Signed-off-by: Weian Chen <weian.chen@intel.com>
diff --git a/videodecoder/VideoDecoderAVC.cpp b/videodecoder/VideoDecoderAVC.cpp
index 5b8efef..6396440 100644
--- a/videodecoder/VideoDecoderAVC.cpp
+++ b/videodecoder/VideoDecoderAVC.cpp
@@ -117,6 +117,8 @@
         }
     }
 
+    VideoDecoderBase::setRotationDegrees(buffer);
+
     status = decodeFrame(buffer, data);
     if (status == DECODE_MULTIPLE_FRAME) {
         buffer->ext = &mExtensionBuffer;
diff --git a/videodecoder/VideoDecoderBase.cpp b/videodecoder/VideoDecoderBase.cpp
index cf20c24..eaacfff 100644
--- a/videodecoder/VideoDecoderBase.cpp
+++ b/videodecoder/VideoDecoderBase.cpp
@@ -55,6 +55,7 @@
       mManageReference(true),
       mOutputMethod(OUTPUT_BY_PCT),
       mOutputWindowSize(OUTPUT_WINDOW_SIZE),
+      mRotationDegrees(0),
       mNumSurfaces(0),
       mSurfaceBuffers(NULL),
       mOutputHead(NULL),
@@ -1371,3 +1372,25 @@
         }
     }
 }
+
+void VideoDecoderBase::setRotationDegrees(VideoDecodeBuffer *buffer) {
+
+    if (mRotationDegrees != buffer->rotationDegrees) {
+        ITRACE("set new mRotationDegrees = %d", mRotationDegrees);
+        VADisplayAttribute rotate;
+        rotate.type = VADisplayAttribRotation;
+        rotate.value = VA_ROTATION_NONE;
+        if (buffer->rotationDegrees == 0)
+            rotate.value = VA_ROTATION_NONE;
+        else if (buffer->rotationDegrees == 90)
+            rotate.value = VA_ROTATION_90;
+        else if (buffer->rotationDegrees == 180)
+            rotate.value = VA_ROTATION_180;
+        else if (buffer->rotationDegrees == 270)
+            rotate.value = VA_ROTATION_270;
+
+        vaSetDisplayAttributes(mVADisplay, &rotate, 1);
+        mRotationDegrees = buffer->rotationDegrees;
+   }
+}
+
diff --git a/videodecoder/VideoDecoderBase.h b/videodecoder/VideoDecoderBase.h
index 6527be6..dcc1548 100644
--- a/videodecoder/VideoDecoderBase.h
+++ b/videodecoder/VideoDecoderBase.h
@@ -125,6 +125,7 @@
     bool mShowFrame; // indicate whether the decoded frame is for display
 
     int32_t mOutputWindowSize; // indicate limit of number of outstanding frames for output
+    int32_t mRotationDegrees;
 
     bool mErrReportEnabled;
 
@@ -170,6 +171,7 @@
     void setOutputWindowSize(int32_t size) {mOutputWindowSize = (size < OUTPUT_WINDOW_SIZE) ? size : OUTPUT_WINDOW_SIZE;}
     void querySurfaceRenderStatus(VideoSurfaceBuffer* surface);
     void enableLowDelayMode(bool enable) {mLowDelay = enable;}
+    void setRotationDegrees(VideoDecodeBuffer *buffer);
 };
 
 
diff --git a/videodecoder/VideoDecoderDefs.h b/videodecoder/VideoDecoderDefs.h
index 7a903c4..ea1c9f9 100644
--- a/videodecoder/VideoDecoderDefs.h
+++ b/videodecoder/VideoDecoderDefs.h
@@ -124,6 +124,7 @@
     int32_t size;
     int64_t timeStamp;
     uint32_t flag;
+    uint32_t rotationDegrees;
     VideoExtensionBuffer *ext;
 };
 
diff --git a/videodecoder/VideoDecoderVP8.cpp b/videodecoder/VideoDecoderVP8.cpp
index 145c7b6..34fd866 100644
--- a/videodecoder/VideoDecoderVP8.cpp
+++ b/videodecoder/VideoDecoderVP8.cpp
@@ -145,6 +145,8 @@
         CHECK_STATUS("startVA");
     }
 
+    VideoDecoderBase::setRotationDegrees(buffer);
+
     status = decodeFrame(buffer, data);
 
     return status;