Redimensionnement de la surface d'affichage pour le ratio d'aspect de changement d'affichage vidéo sous android

Je suis en train de travailler sur un projet de vidéoconférence. Mon écran vidéo est à l'aide de surface d'affichage. Maintenant, au cours d'un appel vidéo, il ya une chance de l'aspect de changement de rapport pour les trames entrantes. J'ai donc essayé le code suivant pour qu'il

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*****************************************");
}

Tout est parfait si j'appelle cette fonction au début de l'appel.
Mon problème est que lorsque j'appelle cette fonction entre un appel pour changer le ratio d'aspect qu'il prend trop de temps pour afficher l'image suivante. Parfois, la vidéo est coincé même.

J'ai essayé de le détruire et recréer la surface avec

myVideoSurface.setVisibility(VIEW.GONE);

Mais la surface n'est pas créé.

Je suis en utilisant Mediacodec pour le décodage vidéo, je vais être averti quand il y a un changement de résolution.

Est-il quelque chose de plus que je devrais faire pour le redimensionnement d'une surfaceView quand déjà la vidéo est en cours de lecture.

Merci pour l'aide.........................

Si votre problème est résolu, merci d'accepter de répondre. Si votre question n'apparaît pas dans les "sans réponse" à la liste.
voici un bon solution

OriginalL'auteur Kevin K | 2013-12-10