Commit a8c09957 authored by François Grisez's avatar François Grisez Committed by François Grisez

Add MS_FILTER_GET_FPS to qtcapture filter

This method give the average FPS of the capture
parent e4530d24
......@@ -321,6 +321,7 @@ typedef struct v4mState {
float fps;
float start_time;
int frame_count;
MSAverageFPS afps;
} v4mState;
......@@ -391,6 +392,7 @@ static void v4m_process(MSFilter * obj){
mblk_set_marker_info(om,TRUE);
ms_queue_put(obj->outputs[0],om);
s->frame_count++;
ms_average_fps_update(&s->afps, obj->ticker->time);
}
} else {
flushq([s->webcam rq],0);
......@@ -402,12 +404,15 @@ static void v4m_process(MSFilter * obj){
}
static void v4m_preprocess(MSFilter *f) {
v4m_start(f,NULL);
v4mState *s = (v4mState *)f->data;
ms_average_fps_init(&s->afps, "QuickTime capture average fps = %f");
v4m_start(f,NULL);
}
static void v4m_postprocess(MSFilter *f) {
v4mState *s = (v4mState *)f->data;
v4m_stop(f,NULL);
ms_average_fps_init(&s->afps, "QuickTime capture average fps = %f");
}
static int v4m_set_fps(MSFilter *f, void *arg) {
......@@ -417,6 +422,12 @@ static int v4m_set_fps(MSFilter *f, void *arg) {
return 0;
}
static int v4m_get_fps(MSFilter *f, void *arg) {
v4mState *s = (v4mState *)f->data;
*((float *)arg) = ms_average_fps_get(&s->afps);
return 0;
}
static int v4m_get_pix_fmt(MSFilter *f,void *arg) {
NSAutoreleasePool* myPool = [[NSAutoreleasePool alloc] init];
v4mState *s = (v4mState*)f->data;
......@@ -443,6 +454,7 @@ static int v4m_get_vsize(MSFilter *f, void *arg) {
static MSFilterMethod methods[] = {
{ MS_FILTER_SET_FPS , v4m_set_fps },
{ MS_FILTER_GET_FPS , v4m_get_fps },
{ MS_FILTER_GET_PIX_FMT , v4m_get_pix_fmt },
{ MS_FILTER_SET_VIDEO_SIZE, v4m_set_vsize },
{ MS_V4L_START , v4m_start },
......
......@@ -823,7 +823,7 @@ bool_t ms_video_update_average_fps(MSAverageFPS* afps, uint32_t current_time){
}
float ms_average_fps_get(const MSAverageFPS* afps){
return afps->mean_inter_frame!=0 ? 1.0/afps->mean_inter_frame : 0;
return afps->mean_inter_frame!=0 ? 1.0/afps->mean_inter_frame : 0.0;
}
MSVideoConfiguration ms_video_find_best_configuration_for_bitrate(const MSVideoConfiguration *vconf_list, int bitrate) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment