Commit cbc934ef authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Try to prevent bb10 display filter from stretching video

parent c1a5c019
......@@ -20,6 +20,7 @@
#include "mediastreamer2/msfilter.h"
#include "mediastreamer2/msvideo.h"
#include "layouts.h"
#include <screen/screen.h>
......@@ -44,7 +45,6 @@ static void bb10display_set_window_id_and_group(BB10Display *d) {
screen_set_window_property_cv(d->window, SCREEN_PROPERTY_ID_STRING, strlen(d->window_id), d->window_id);
screen_join_window_group(d->window, d->window_group);
ms_message("[DEBUG] bb10display_set_window_id_and_group");
}
static void bb10display_createWindow(BB10Display *d) {
......@@ -64,16 +64,13 @@ static void bb10display_createWindow(BB10Display *d) {
int usage = SCREEN_USAGE_NATIVE;
screen_set_window_property_iv(window, SCREEN_PROPERTY_USAGE, &usage);
int dims[2] = { d->vsize.width, d->vsize.height };
screen_set_window_property_iv(window, SCREEN_PROPERTY_BUFFER_SIZE, dims);
screen_set_window_property_iv(window, SCREEN_PROPERTY_SOURCE_SIZE, dims);
int wdims[2] = { d->wsize.width, d->wsize.height };
screen_set_window_property_iv(window, SCREEN_PROPERTY_BUFFER_SIZE, wdims);
screen_set_window_property_iv(window, SCREEN_PROPERTY_SOURCE_SIZE, wdims);
int zorder = -5;
screen_set_window_property_iv(window, SCREEN_PROPERTY_ZORDER, &zorder);
//int wdims[2] = { d->wsize.width, d->wsize.height };
screen_set_window_property_iv(window, SCREEN_PROPERTY_SIZE, dims);
screen_create_window_buffers(window, 1);
screen_create_pixmap(&pixmap, context);
......@@ -84,6 +81,7 @@ static void bb10display_createWindow(BB10Display *d) {
int format = SCREEN_FORMAT_YUV420;
screen_set_pixmap_property_iv(pixmap, SCREEN_PROPERTY_FORMAT, &format);
int dims[2] = { d->vsize.width, d->vsize.height };
screen_set_pixmap_property_iv(pixmap, SCREEN_PROPERTY_BUFFER_SIZE, dims);
screen_create_pixmap_buffer(pixmap);
......@@ -98,7 +96,7 @@ static void bb10display_createWindow(BB10Display *d) {
d->pixmap_buffer = buffer;
d->stride = stride;
d->window_created = TRUE;
ms_warning("[bb10_display] bb10display_createWindow window created with size %i,%i and stride %i", dims[0], dims[1], stride);
ms_warning("[bb10_display] bb10display_createWindow window created with buffer size %i,%i and stride %i", dims[0], dims[1], stride);
if (d->window_id != NULL && d->window_group != NULL) {
bb10display_set_window_id_and_group(d);
......@@ -154,10 +152,18 @@ static void bb10display_fillWindowBuffer(BB10Display *d, MSPicture *yuvbuf) {
screen_buffer_t buffer;
screen_get_window_property_pv(d->window, SCREEN_PROPERTY_RENDER_BUFFERS, (void**) &buffer);
int attributes[] = { SCREEN_BLIT_SOURCE_WIDTH, d->vsize.width, SCREEN_BLIT_SOURCE_HEIGHT, d->vsize.height, SCREEN_BLIT_END };
MSRect rect;
ms_layout_center_rectangle(d->wsize, d->vsize, &rect);
int attributes[] = {
SCREEN_BLIT_SOURCE_WIDTH, d->vsize.width, SCREEN_BLIT_SOURCE_HEIGHT, d->vsize.height,
SCREEN_BLIT_SOURCE_X, rect.x, SCREEN_BLIT_SOURCE_Y, rect.y,
SCREEN_BLIT_SOURCE_WIDTH, rect.w, SCREEN_BLIT_SOURCE_HEIGHT, rect.h,
SCREEN_BLIT_END
};
screen_blit(d->context, buffer, d->pixmap_buffer, attributes);
int rect[4] = { 0, 0, d->vsize.width, d->vsize.height };
int rect[4] = { 0, 0, d->wsize.width, d->wsize.height };
screen_post_window(d->window, buffer, 1, rect, 0);
}
}
......@@ -174,13 +180,13 @@ static void bb10display_init(MSFilter *f) {
def_size.width = MS_VIDEO_SIZE_CIF_W;
def_size.height = MS_VIDEO_SIZE_CIF_H;
d->vsize = def_size;
d->wsize = def_size;
window_size.width = MS_VIDEO_SIZE_CIF_W;
window_size.height = MS_VIDEO_SIZE_CIF_H;
d->wsize = window_size;
d->window_id = NULL;
d->window_group = NULL;
d->stride = 0;
//bb10display_createWindow(d);
f->data = d;
ms_warning("[bb10_display] init done");
}
......@@ -205,13 +211,29 @@ static void bb10display_process(MSFilter *f) {
ms_filter_lock(f);
if (f->inputs[0] != NULL && (inm = ms_queue_peek_last(f->inputs[0])) != 0) {
if (ms_yuv_buf_init_from_mblk(&src, inm) == 0) {
bool_t destroy_and_recreate_window = FALSE;
MSVideoSize newsize;
newsize.width = src.w;
newsize.height = src.h;
if (!ms_video_size_equal(newsize, d->vsize)) {
ms_warning("[bb10_display] size changed from %i,%i to %i,%i", newsize.width, newsize.height, d->vsize.width, d->vsize.height);
ms_warning("[bb10_display] video size changed from %i,%i to %i,%i", newsize.width, newsize.height, d->vsize.width, d->vsize.height);
d->vsize = newsize;
destroy_and_recreate_window = TRUE;
}
if (d->window_created) {
int wdims[2] = { 0, 0 };
screen_get_window_property_iv(d->window, SCREEN_PROPERTY_SIZE, &wdims);
if (d->wsize.width != wdims[0] || d->wsize.height != wdims[1]) {
ms_warning("[bb10_display] screen size changed from %i,%i to %i,%i", d->wsize.width, d->wsize.height, wdims[0], wdims[1]);
d->wsize.width = wdims[0];
d->wsize.height = wdims[1];
destroy_and_recreate_window = TRUE;
}
}
if (destroy_and_recreate_window) {
if (d->window_created) {
ms_warning("[bb10_display] window created, flush and destroy");
screen_flush_context(d->context, 0);
......@@ -237,23 +259,6 @@ static void bb10display_postprocess(MSFilter *f) {
BB10Display *d = (BB10Display*) f->data;
}
static int bb10display_set_wsize(MSFilter *f, void *arg) {
BB10Display *d = (BB10Display*) f->data;
ms_filter_lock(f);
d->wsize = *(MSVideoSize*)arg;
ms_warning("[bb10_display] set wsize: %ix%i", d->wsize.width, d->wsize.height);
if (d->window_created) {
screen_flush_context(d->context, 0);
bb10display_destroyWindow(d);
}
bb10display_createWindow(d);
ms_filter_unlock(f);
return 0;
}
static int bb10_display_set_window_ids(MSFilter *f, void *arg) {
BB10Display *d = (BB10Display*) f->data;
......@@ -274,7 +279,6 @@ static int bb10_display_set_window_ids(MSFilter *f, void *arg) {
}
static MSFilterMethod ms_bb10display_methods[] = {
//{ MS_FILTER_SET_VIDEO_SIZE, bb10display_set_wsize },
{ MS_VIDEO_DISPLAY_SET_NATIVE_WINDOW_ID, bb10_display_set_window_ids },
{ 0, NULL }
};
......
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