Redimensionamento da vista da superfície para alterar a proporção na exibição de vídeo no Android

Eu estou trabalhando em um projeto de videoconferência. Minha exibição de vídeo está usando a exibição de superfície. Agora, durante uma chamada de vídeo, há uma chance de alteração da proporção para os quadros recebidos. Então eu tentei o seguinte código para isso

public void surfaceResize() {

   // WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Point size = new Point();
    int screenWidth = 0;
    //Get the SurfaceView layout parameters

    float aspectRatio = (float) recv_frame_width / recv_frame_height;

    if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) 
    {   
        //Get the width of the screen
        getWindowManager().getDefaultDisplay().getSize(size);
        screenWidth = size.x;

        //Set the width of the SurfaceView to the width of the screen
        surflp.width = screenWidth;

        //Set the height of the SurfaceView to match the aspect ratio of the video 
        //be sure to cast these as floats otherwise the calculation will likely be 0
        surflp.height = (int) ((1 / aspectRatio) * (float)screenWidth);

        //Commit the layout parameters

    } else {

        size.x = size.y = 0;
        //Get the width of the screen
        getWindowManager().getDefaultDisplay().getSize(size);

        int screenHeight = size.y;

        //Set the width of the SurfaceView to the width of the screen
        surflp.height = screenHeight;

        //Set the width of the SurfaceView to match the aspect ratio of the video 
        //be sure to cast these as floats otherwise the calculation will likely be 0
        surflp.width = (int) ( aspectRatio * (float)screenHeight);

        //Commit the layout parameters
        // code to do for Portrait Mode        
    }
    surflp.addRule(RelativeLayout.CENTER_HORIZONTAL);
    surflp.addRule(RelativeLayout.CENTER_VERTICAL);

    if(myVideoSurfaceView != null) 
        myVideoSurfaceView.setLayoutParams(surflp);  
    System.out.println("Surface resized*****************************************");
}

Tudo está bem se eu chamar essa função no início da chamada. Meu problema é quando eu chamo essa função entre uma chamada para alterar a proporção que leva muito tempo para exibir o próximo quadro. Às vezes o vídeo fica preso mesmo.

Eu tentei destruir e recriar a superfície com

myVideoSurface.setVisibility(VIEW.GONE);

Mas a superfície não está sendo criada.

Estou usando o Mediacodec para decodificação de vídeo. Eu serei notificado quando houver uma alteração de resolução.

Existe algo mais que devo fazer para redimensionar um surfaceView quando o vídeo já estiver sendo reproduzido.

Obrigado pela ajuda .........................

questionAnswers(1)

yourAnswerToTheQuestion