public void stop() {
    if (showing) {
      videoReceiver.stop();
      codec.close();
      audioTrack.stop();
      audioTrack.release();

      log.debug("VideoSurface.stop().endDrawer()");
      endDrawer();

      showing = false;
    }
  }
  public void start(ClientOptions opt, Context context) {

    if (showing) stop();
    synchronized (this) {
      codec.init();
      mu = codec.samp_rate() / 8000;
      maxjitter =
          AudioTrack.getMinBufferSize(
              codec.samp_rate(), AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT);
      if (maxjitter < 2 * 2 * BUFFER_SIZE * 3 * mu) maxjitter = 2 * 2 * BUFFER_SIZE * 3 * mu;
      audioTrack =
          new AudioTrack(
              AudioManager.STREAM_VOICE_CALL,
              codec.samp_rate(),
              AudioFormat.CHANNEL_OUT_MONO,
              AudioFormat.ENCODING_PCM_16BIT,
              maxjitter,
              AudioTrack.MODE_STREAM);
      AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
      /*if (Integer.parseInt(Build.VERSION.SDK) >= 5)
      	am.setSpeakerphoneOn(true);
      else*/
      am.setMode(AudioManager.MODE_IN_COMMUNICATION);
      audioTrack.play();

      running = true;
    }
    // BigBlueButtonClient bbb = ((BigBlueButton)
    // getContext().getApplicationContext()).getHandler();
    videoReceiver =
        new VideoReceiver(opt) {
          @Override
          protected void onVideo(Video video) {
            // VideoChild vc=new VideoChild(video);
            Log.d("video", "video received");
            byte[] data = video.getBody();
            enqueueFrame(data, data.length);
          }

          @Override
          protected void onAudio(Audio audio) {
            // VideoChild vc=new VideoChild(video);

            byte[] audioData = audio.getByteArray();

            int offset = 1;

            //      byte[] tmpBuffer = new byte[audioData.length - offset];
            //      System.arraycopy(audioData, offset, tmpBuffer, 0, tmpBuffer.length);
            //      pkt.setPayload(tmpBuffer, tmpBuffer.length);
            //      int decodedSize = codec.decode(pktBuffer, decodedBuffer,
            // pkt.getPayloadLength());

            System.arraycopy(audioData, offset, pktBuffer, 12, audioData.length - offset);
            int decodedSize = codec.decode(pktBuffer, decodedBuffer, audioData.length - offset);
            write(decodedBuffer, 0, decodedSize);
          }
        };

    // float tmp = videoReceiver.getAspectRatio();
    aspectRatio = DEFAULT_ASPECT_RATIO;

    updateLayoutParams(inDialog);

    videoReceiver.start();

    showing = true;
  }