Commit 8e24a911 authored by Simon Morlat's avatar Simon Morlat

Merge branch 'master' of git://git.linphone.org/mediastreamer2

parents 46518426 83718ee0
......@@ -196,13 +196,15 @@ public class AndroidVideoWindowImpl {
}
public void onDrawFrame(GL10 gl) {
if (ptr == 0)
return;
if (initPending) {
OpenGLESDisplay.init(ptr, width, height);
initPending = false;
synchronized (this) {
if (ptr == 0)
return;
if (initPending) {
OpenGLESDisplay.init(ptr, width, height);
initPending = false;
}
OpenGLESDisplay.render(ptr);
}
OpenGLESDisplay.render(ptr);
}
public void onSurfaceChanged(GL10 gl, int width, int height) {
......
......@@ -34,6 +34,7 @@ typedef struct AndroidDisplay{
MSVideoSize vsize;
struct opengles_display* ogl;
jboolean ogl_free_ready;
jmethodID set_opengles_display_id;
jmethodID request_render_id;
}AndroidDisplay;
......@@ -56,16 +57,23 @@ static void android_display_init(MSFilter *f){
if (ad->request_render_id == 0)
ms_error("Could not find 'requestRender' method\n");
ad->ogl = ogl_display_new();
ad->ogl_free_ready = FALSE;
f->data=ad;
ms_message("%s %p %p", __FUNCTION__, f, ad);
}
static void android_display_uninit(MSFilter *f){
AndroidDisplay *ad=(AndroidDisplay*)f->data;
ms_message("%s %p %p", __FUNCTION__, f, ad->ogl);
if (ad->ogl) {
// uninit must be called with gl context set (in SurfaceDestroyed callback)
ogl_display_free(ad->ogl);
if (ad->ogl_free_ready) {
ms_free(ad->ogl);
ad->ogl = 0;
} else {
ad->ogl_free_ready = TRUE;
}
}
ms_free(ad);
......@@ -84,7 +92,11 @@ static void android_display_process(MSFilter *f){
if ((m=ms_queue_peek_last(f->inputs[0]))!=NULL){
if (ms_yuv_buf_init_from_mblk (&pic,m)==0){
/* schedule display of frame */
ogl_display_set_yuv_to_display(ad->ogl, m);
if (!ad->ogl || !ad->ogl_free_ready) {
ogl_display_set_yuv_to_display(ad->ogl, m);
} else {
ms_warning("%s: opengldisplay not ready (%p)", __FUNCTION__, ad->ogl);
}
ms_queue_remove(f->inputs[0], m);
JNIEnv *jenv=ms_get_jni_env();
......@@ -106,17 +118,30 @@ static int android_display_set_window(MSFilter *f, void *arg){
jobject window=(jobject)id;
ms_filter_lock(f);
ad->android_video_window=window;
if (ad->android_video_window) {
if (window) {
unsigned int ptr = (unsigned int)ad->ogl;
ms_message("Sending opengles_display pointer as long: %p -> %u\n", ad->ogl, ptr);
(*jenv)->CallVoidMethod(jenv,ad->android_video_window,ad->set_opengles_display_id, ptr);
ms_message("Sending opengles_display pointer as long: %p -> %u", ad->ogl, ptr);
(*jenv)->CallVoidMethod(jenv,window,ad->set_opengles_display_id, ptr);
ad->ogl_free_ready = FALSE;
} else {
/* when context is lost GL resources are freed by Android */
ogl_display_uninit(ad->ogl, FALSE);
if (window != ad->android_video_window) {
ms_message("Clearing opengles_display (%p : %d)", ad->ogl, ad->ogl_free_ready);
/* when context is lost GL resources are freed by Android */
ogl_display_uninit(ad->ogl, FALSE);
if (ad->ogl_free_ready) {
ms_free(ad->ogl);
ad->ogl = 0;
} else {
ad->ogl_free_ready = TRUE;
}
/* clear native ptr, to prevent rendering to occur now that ptr is invalid */
(*jenv)->CallVoidMethod(jenv,ad->android_video_window,ad->set_opengles_display_id, 0);
}
}
ad->android_video_window=window;
ms_filter_unlock(f);
return 0;
......
......@@ -557,6 +557,7 @@ static void rotate_plane(int wDest, int hDest, int full_width, uint8_t* src, uin
int signed_dst_stride;
int incr;
int y,x;
......@@ -571,7 +572,6 @@ static void rotate_plane(int wDest, int hDest, int full_width, uint8_t* src, uin
incr = -1;
signed_dst_stride = -wDest;
}
int y,x;
for (y=0; y<hSrc; y++) {
uint8_t* dst2 = dst;
for (x=0; x<step*wSrc; x+=step) {
......@@ -601,6 +601,8 @@ static int hasNeon = 0;
mblk_t *copy_ycbcrbiplanar_to_true_yuv_with_rotation(uint8_t* y, uint8_t * cbcr, int rotation, int w, int h, int y_byte_per_row,int cbcr_byte_per_row, bool_t uFirstvSecond) {
MSPicture pict;
mblk_t *yuv_block = ms_yuv_buf_alloc(&pict, w, h);
int uv_w = w/2;
int uv_h = h/2;
#ifdef ANDROID
if (hasNeon == -1) {
......@@ -614,9 +616,6 @@ mblk_t *copy_ycbcrbiplanar_to_true_yuv_with_rotation(uint8_t* y, uint8_t * cbcr,
pict.planes[2] = tmp;
}
int uv_w = w/2;
int uv_h = h/2;
if (rotation % 180 == 0) {
int i,j;
uint8_t* u_dest=pict.planes[1], *v_dest=pict.planes[2];
......@@ -640,14 +639,15 @@ mblk_t *copy_ycbcrbiplanar_to_true_yuv_with_rotation(uint8_t* y, uint8_t * cbcr,
} else
#endif
{
// 180° y rotation
uint8_t* ysrc=y;
uint8_t* uvsrc=&cbcr[uv_h*uv_w*2-2];
uint8_t* ydst=&pict.planes[0][h*w-1];
// 180° y rotation
for(i=0; i<h*w; i++) {
*ydst-- = *ysrc++;
}
// 180° rotation + de-interlace u/v
uint8_t* uvsrc=&cbcr[uv_h*uv_w*2-2];
for (i=0; i<uv_h*uv_w*2; i++) {
*u_dest++ = *uvsrc--;
*v_dest++ = *uvsrc--;
......@@ -678,13 +678,14 @@ mblk_t *copy_ycbcrbiplanar_to_true_yuv_with_rotation(uint8_t* y, uint8_t * cbcr,
} else
#endif
{
// Copying U
uint8_t* srcu = cbcr;
uint8_t* dstu = pict.planes[1];
rotate_plane(uv_w,uv_h,cbcr_byte_per_row/2,srcu,dstu, 2, clockwise);
// Copying V
uint8_t* srcv = srcu + 1;
uint8_t* dstv = pict.planes[2];
// Copying U
rotate_plane(uv_w,uv_h,cbcr_byte_per_row/2,srcu,dstu, 2, clockwise);
// Copying V
rotate_plane(uv_w,uv_h,cbcr_byte_per_row/2,srcv,dstv, 2, clockwise);
}
}
......
......@@ -621,11 +621,12 @@ void video_stream_use_preview_video_window(VideoStream *stream, bool_t yesno){
}
void video_stream_set_device_rotation(VideoStream *stream, int orientation){
MSFilter* target_filter = NULL;
if (stream == 0)
return;
stream->device_orientation = orientation;
MSFilter* target_filter=stream->source;
target_filter=stream->source;
if (target_filter){
ms_filter_call_method(target_filter,MS_VIDEO_CAPTURE_SET_DEVICE_ORIENTATION,&orientation);
}
......
......@@ -545,8 +545,8 @@ static void dec_process(MSFilter *f) {
/* scale/copy frame to destination mblk_t */
for(i=0; i<3; i++) {
void* dest = s->outbuf.planes[i];
void* src = img->planes[i];
uint8_t* dest = s->outbuf.planes[i];
uint8_t* src = img->planes[i];
int h = img->d_h >> ((i>0)?1:0);
for(j=0; j<h; j++) {
......
......@@ -364,6 +364,10 @@ bool_t parse_args(int argc, char** argv, MediastreamDatas* out) {
void setup_media_streams(MediastreamDatas* args) {
#ifdef VIDEO_ENABLED
MSWebCam *cam=NULL;
#endif
/*create the rtp session */
ortp_init();
if (args->is_verbose) {
......@@ -390,7 +394,6 @@ void setup_media_streams(MediastreamDatas* args) {
#ifdef VIDEO_ENABLED
args->video=NULL;
MSWebCam *cam=NULL;
#endif
args->profile=rtp_profile_clone_full(&av_profile);
args->q=ortp_ev_queue_new();
......
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