libvideorender: CB1 keep last frame on flush [2/3]

PD#SWPL-158207

Problem:
add property to set keep last frame when flush.
default is keep last frame,if set to 0,westeros will
clean last frame when flush

Solution:
add property for keep last frame on flush

Verify:
AH212

Signed-off-by: le.han <le.han@amlogic.com>
Change-Id: I52f845c11dbd8b702b8e80273dc63c18b5eb4cc2
diff --git a/render_plugin.h b/render_plugin.h
index 0419fd0..ae97325 100644
--- a/render_plugin.h
+++ b/render_plugin.h
@@ -49,6 +49,7 @@
     PLUGIN_KEY_PIXEL_ASPECT_RATIO, //set/get pixel aspect ratio,value type is double
     PLUGIN_KEY_CURRENT_OUTPUT, //set/get signal output,value type is int
     PLUGIN_KEY_VIDEO_FRAME_RATE, //set/get video frame rate,value type is RenderFraction
+    PLUGIN_KEY_KEEP_LAST_FRAME_ON_FLUSH, //set/get keep last frame when seeking,value type is int, 0 not keep, 1 keep
 } PluginKey;
 
 /**
diff --git a/westeros/wstclient_plugin.cpp b/westeros/wstclient_plugin.cpp
index 1fa5077..eafdf0b 100644
--- a/westeros/wstclient_plugin.cpp
+++ b/westeros/wstclient_plugin.cpp
@@ -35,6 +35,8 @@
     mWstClientSocket = NULL;
     mKeepLastFrame.isSet = false;
     mKeepLastFrame.value = 0;
+    mKeepLastFrameOnFlush.isSet = false;
+    mKeepLastFrameOnFlush.value = 1;
     mHideVideo.isSet = false;
     mHideVideo.value = 0;
     mFirstFramePts = -1;
@@ -264,7 +266,7 @@
     int ret;
     INFO(mLogCategory,"flush");
     if (mWstClientSocket) {
-        mWstClientSocket->sendFlushVideoClientConnection();
+        mWstClientSocket->sendFlushVideoClientConnection(mKeepLastFrameOnFlush.value);
     }
     //drop frames those had committed to westeros
     std::lock_guard<std::mutex> lck(mRenderLock);
@@ -376,6 +378,10 @@
             *(int *)value = mKeepLastFrame.value;
             TRACE(mLogCategory,"get keep last frame:%d",*(int *)value);
         } break;
+        case PLUGIN_KEY_KEEP_LAST_FRAME_ON_FLUSH: {
+            *(int *)value = mKeepLastFrameOnFlush.value;
+            TRACE(mLogCategory,"get keep last frame on flush:%d",*(int *)value);
+        } break;
         case PLUGIN_KEY_HIDE_VIDEO: {
             *(int *)value = mHideVideo.value;
             TRACE(mLogCategory,"get hide video:%d",*(int *)value);
@@ -429,6 +435,12 @@
                 mWstClientSocket->sendKeepLastFrameVideoClientConnection(mKeepLastFrame.value);
             }
         } break;
+        case PLUGIN_KEY_KEEP_LAST_FRAME_ON_FLUSH: {
+            int keepOnFlush = *(int *) (value);
+            mKeepLastFrameOnFlush.value = keepOnFlush > 0? true:false;
+            mKeepLastFrameOnFlush.isSet = true;
+            DEBUG(mLogCategory, "Set keep last frame on flush :%d",mKeepLastFrameOnFlush.value);
+        } break;
         case PLUGIN_KEY_HIDE_VIDEO: {
             int hide = *(int *)(value);
             mHideVideo.value = hide > 0? true:false;
diff --git a/westeros/wstclient_plugin.h b/westeros/wstclient_plugin.h
index 3173c92..8c10172 100644
--- a/westeros/wstclient_plugin.h
+++ b/westeros/wstclient_plugin.h
@@ -82,6 +82,7 @@
     int mLogCategory;
 
     ConfigValue mKeepLastFrame;
+    ConfigValue mKeepLastFrameOnFlush;
     ConfigValue mHideVideo;
 
     std::mutex mRenderLock;
diff --git a/westeros/wstclient_socket.cpp b/westeros/wstclient_socket.cpp
index bd49421..5ceabab 100644
--- a/westeros/wstclient_socket.cpp
+++ b/westeros/wstclient_socket.cpp
@@ -209,11 +209,11 @@
     }
 }
 
-void WstClientSocket::sendFlushVideoClientConnection()
+void WstClientSocket::sendFlushVideoClientConnection(bool keepOnFlush)
 {
     struct msghdr msg;
     struct iovec iov[1];
-    unsigned char mbody[4];
+    unsigned char mbody[5];
     int len;
     int sentLen;
 
@@ -228,8 +228,9 @@
     len = 0;
     mbody[len++] = 'V';
     mbody[len++] = 'S';
-    mbody[len++] = 1;
+    mbody[len++] = 2;
     mbody[len++] = 'S';
+    mbody[len++] = keepOnFlush? 1:0;
 
     iov[0].iov_base = (char*)mbody;
     iov[0].iov_len = len;
diff --git a/westeros/wstclient_socket.h b/westeros/wstclient_socket.h
index d6915b9..4a21e39 100644
--- a/westeros/wstclient_socket.h
+++ b/westeros/wstclient_socket.h
@@ -111,7 +111,7 @@
      */
     void sendLayerVideoClientConnection(bool pip);
     void sendResourceVideoClientConnection(bool pip);
-    void sendFlushVideoClientConnection();
+    void sendFlushVideoClientConnection(bool keepOnFlush);
     void sendPauseVideoClientConnection(bool pause);
     void sendHideVideoClientConnection(bool hide);
     void sendSessionInfoVideoClientConnection(int sessionId, int syncType );