Merge "avsync: support trick play"
diff --git a/avsync-lib/src/aml_avsync.h b/avsync-lib/src/aml_avsync.h
index 3ae1602..c9da796 100644
--- a/avsync-lib/src/aml_avsync.h
+++ b/avsync-lib/src/aml_avsync.h
@@ -106,4 +106,15 @@
*/
void av_sync_update_vsync_interval(void *sync, pts90K vsync_interval);
+/* set playback speed
+ * Currently only work for VMASTER mode
+ * Params:
+ * @speed: 1.0 is normal speed. 2.0 is 2x faster. 0.1 is 10x slower
+ * Minimium speed is 0.001
+ * Max speed is 100
+ * Return:
+ * 0 for OK, or error code
+ */
+int av_sync_set_speed(void *sync, float speed);
+
#endif
diff --git a/avsync-lib/src/avsync.c b/avsync-lib/src/avsync.c
index e5833b7..09af5d6 100644
--- a/avsync-lib/src/avsync.c
+++ b/avsync-lib/src/avsync.c
@@ -450,3 +450,19 @@
detect_pattern(avsync->pattern_detector, AV_SYNC_FRAME_P22, cur_period, last_period);
detect_pattern(avsync->pattern_detector, AV_SYNC_FRAME_P41, cur_period, last_period);
}
+
+int av_sync_set_speed(void *sync, float speed)
+{
+ struct av_sync_session *avsync = (struct av_sync_session *)sync;
+
+ if (speed < 0.001f || speed > 100) {
+ log_error("wrong speed %f [0.0001, 100]", speed);
+ return -1;
+ }
+ if (avsync->mode != AV_SYNC_MODE_VMASTER) {
+ log_info("ignore set speed in mode %d", avsync->mode);
+ return 0;
+ }
+
+ return tsync_set_speed(avsync->session_id, speed);
+}
diff --git a/avsync-lib/src/tsync.c b/avsync-lib/src/tsync.c
index f07b203..c29242d 100644
--- a/avsync-lib/src/tsync.c
+++ b/avsync-lib/src/tsync.c
@@ -31,6 +31,7 @@
#define AMSTREAM_IOC_SET_VSYNC_UPINT _IOW((_A_M), 0x89, int)
#define AMSTREAM_IOC_SET_VIDEOPEEK _IOW(_A_M, 0xbf, unsigned int)
#define AMSTREAM_IOC_SET_NO_VIDEO_STOP _IOW(_A_M, 0xf5, unsigned int)
+#define AMSTREAM_IOC_SET_VSYNC_SLOW_FACTOR _IOW((_A_M), 0x8b, int)
static int config_sys_node(const char* path, const char* value)
{
@@ -186,3 +187,8 @@
log_info("no_video_stop %d", disable);
return video_device_ioctl(AMSTREAM_IOC_SET_NO_VIDEO_STOP, disable);
}
+
+int tsync_set_speed(int session, float speed)
+{
+ return video_device_ioctl(AMSTREAM_IOC_SET_VSYNC_SLOW_FACTOR, 1000000 * speed);
+}
diff --git a/avsync-lib/src/tsync.h b/avsync-lib/src/tsync.h
index c1a6eeb..8975830 100644
--- a/avsync-lib/src/tsync.h
+++ b/avsync-lib/src/tsync.h
@@ -27,5 +27,6 @@
int tsync_set_video_peek_mode(int session);
int tsync_set_video_sync_thres(int session, bool enable);
int tsync_disable_video_stop_event(int session, bool disable);
+int tsync_set_speed(int session, float speed);
#endif