/*
 * Copyright (C) 2006 The Android Open Source Project
 * Copyright (C) 2013 YIXIA.COM
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.vov.vitamio.widget;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Rect;
import android.media.AudioManager;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.PopupWindow;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;

import java.lang.reflect.Method;

import io.vov.vitamio.utils.Log;
import io.vov.vitamio.utils.StringUtils;

/**
 * A view containing controls for a MediaPlayer. Typically contains the buttons
 * like "Play/Pause" and a progress slider. It takes care of synchronizing the
 * controls with the state of the MediaPlayer.
 *

 * The way to use this class is to a) instantiate it programatically or b)
 * create it in your xml layout.
 *

 * a) The MediaController will create a default set of controls and put them in
 * a window floating above your application. Specifically, the controls will
 * float above the view specified with setAnchorView(). By default, the window
 * will disappear if left idle for three seconds and reappear when the user
 * touches the anchor view. To customize the MediaController's style, layout and
 * controls you should extend MediaController and override the {#link
 * {@link #makeControllerView()} method.
 *

 * b) The MediaController is a FrameLayout, you can put it in your layout xml
 * and get it through {@link #findViewById(int)}.
 *

 * NOTES: In each way, if you want customize the MediaController, the SeekBar's
 * id must be mediacontroller_progress, the Play/Pause's must be
 * mediacontroller_pause, current time's must be mediacontroller_time_current,
 * total time's must be mediacontroller_time_total, file name's must be
 * mediacontroller_file_name. And your resources must have a pause_button
 * drawable and a play_button drawable.
 *

 * Functions like show() and hide() have no effect when MediaController is
 * created in an xml layout.
 */
public class MediaController extends FrameLayout {
  private static final int sDefaultTimeout = 3000;
  private static final int FADE_OUT = 1;
  private static final int SHOW_PROGRESS = 2;
  private MediaPlayerControl mPlayer;
  private Context mContext;
  private PopupWindow mWindow;
  private int mAnimStyle;
  private View mAnchor;
  private View mRoot;
  private SeekBar mProgress;
  private TextView mEndTime, mCurrentTime;
  private TextView mFileName;
  private OutlineTextView mInfoView;
  private String mTitle;
  private long mDuration;
  private boolean mShowing;
  private boolean mDragging;
  private boolean mInstantSeeking = false;
  private boolean mFromXml = false;
  private ImageButton mPauseButton;
  private AudioManager mAM;
  private OnShownListener mShownListener;
  private OnHiddenListener mHiddenListener;
  @SuppressLint("HandlerLeak")
  private Handler mHandler = new Handler() {
    @Override
    public void handleMessage(Message msg) {
      long pos;
      switch (msg.what) {
        case FADE_OUT:
          hide();
          break;
        case SHOW_PROGRESS:
          pos = setProgress();
          if (!mDragging && mShowing) {
            msg = obtainMessage(SHOW_PROGRESS);
            sendMessageDelayed(msg, 1000 - (pos % 1000));
            updatePausePlay();
          }
          break;
      }
    }
  };
  private View.OnClickListener mPauseListener = new View.OnClickListener() {
    public void onClick(View v) {
      doPauseResume();
      show(sDefaultTimeout);
    }
  };
  private OnSeekBarChangeListener mSeekListener = new OnSeekBarChangeListener() {
    public void onStartTrackingTouch(SeekBar bar) {
      mDragging = true;
      show(3600000);
      mHandler.removeMessages(SHOW_PROGRESS);
      if (mInstantSeeking)
        mAM.setStreamMute(AudioManager.STREAM_MUSIC, true);
      if (mInfoView != null) {
        mInfoView.setText("");
        mInfoView.setVisibility(View.VISIBLE);
      }
    }

    public void onProgressChanged(SeekBar bar, int progress, boolean fromuser) {
      if (!fromuser)
        return;

      long newposition = (mDuration * progress) / 1000;
      String time = StringUtils.generateTime(newposition);
      if (mInstantSeeking)
        mPlayer.seekTo(newposition);
      if (mInfoView != null)
        mInfoView.setText(time);
      if (mCurrentTime != null)
        mCurrentTime.setText(time);
    }

    public void onStopTrackingTouch(SeekBar bar) {
      if (!mInstantSeeking)
        mPlayer.seekTo((mDuration * bar.getProgress()) / 1000);
      if (mInfoView != null) {
        mInfoView.setText("");
        mInfoView.setVisibility(View.GONE);
      }
      show(sDefaultTimeout);
      mHandler.removeMessages(SHOW_PROGRESS);
      mAM.setStreamMute(AudioManager.STREAM_MUSIC, false);
      mDragging = false;
      mHandler.sendEmptyMessageDelayed(SHOW_PROGRESS, 1000);
    }
  };

  public MediaController(Context context, AttributeSet attrs) {
    super(context, attrs);
    mRoot = this;
    mFromXml = true;
    initController(context);
  }

  public MediaController(Context context) {
    super(context);
    if (!mFromXml && initController(context))
      initFloatingWindow();
  }

  private boolean initController(Context context) {
    mContext = context;
    mAM = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
    return true;
  }

  @Override
  public void onFinishInflate() {
    if (mRoot != null)
      initControllerView(mRoot);
  }

  private void initFloatingWindow() {
    mWindow = new PopupWindow(mContext);
    mWindow.setFocusable(false);
    mWindow.setBackgroundDrawable(null);
    mWindow.setOutsideTouchable(true);
    mAnimStyle = android.R.style.Animation;
  }

  @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
	public void setWindowLayoutType() {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
			try {
				mAnchor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
				Method setWindowLayoutType = PopupWindow.class.getMethod("setWindowLayoutType", new Class[] { int.class });
				setWindowLayoutType.invoke(mWindow, WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG);
			} catch (Exception e) {
				Log.e("setWindowLayoutType", e);
			}
		}
	}

  /**
   * Set the view that acts as the anchor for the control view. This can for
   * example be a VideoView, or your Activity's main view.
   *
   * @param view The view to which to anchor the controller when it is visible.
   */
  public void setAnchorView(View view) {
    mAnchor = view;
    if (!mFromXml) {
      removeAllViews();
      mRoot = makeControllerView();
      mWindow.setContentView(mRoot);
      mWindow.setWidth(LayoutParams.MATCH_PARENT);
      mWindow.setHeight(LayoutParams.WRAP_CONTENT);
    }
    initControllerView(mRoot);
  }

  /**
   * Create the view that holds the widgets that control playback. Derived
   * classes can override this to create their own.
   *
   * @return The controller view.
   */
  protected View makeControllerView() {
    return ((LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(getResources().getIdentifier("mediacontroller", "layout", mContext.getPackageName()), this);
  }

  private void initControllerView(View v) {
    mPauseButton = (ImageButton) v.findViewById(getResources().getIdentifier("mediacontroller_play_pause", "id", mContext.getPackageName()));
    if (mPauseButton != null) {
      mPauseButton.requestFocus();
      mPauseButton.setOnClickListener(mPauseListener);
    }

    mProgress = (SeekBar) v.findViewById(getResources().getIdentifier("mediacontroller_seekbar", "id", mContext.getPackageName()));
    if (mProgress != null) {
      if (mProgress instanceof SeekBar) {
        SeekBar seeker = (SeekBar) mProgress;
        seeker.setOnSeekBarChangeListener(mSeekListener);
      }
      mProgress.setMax(1000);
    }

    mEndTime = (TextView) v.findViewById(getResources().getIdentifier("mediacontroller_time_total", "id", mContext.getPackageName()));
    mCurrentTime = (TextView) v.findViewById(getResources().getIdentifier("mediacontroller_time_current", "id", mContext.getPackageName()));
    mFileName = (TextView) v.findViewById(getResources().getIdentifier("mediacontroller_file_name", "id", mContext.getPackageName()));
    if (mFileName != null)
      mFileName.setText(mTitle);
  }

  public void setMediaPlayer(MediaPlayerControl player) {
    mPlayer = player;
    updatePausePlay();
  }

  /**
   * Control the action when the seekbar dragged by user
   *
   * @param seekWhenDragging True the media will seek periodically
   */
  public void setInstantSeeking(boolean seekWhenDragging) {
    mInstantSeeking = seekWhenDragging;
  }

  public void show() {
    show(sDefaultTimeout);
  }

  /**
   * Set the content of the file_name TextView
   *
   * @param name
   */
  public void setFileName(String name) {
    mTitle = name;
    if (mFileName != null)
      mFileName.setText(mTitle);
  }

  /**
   * Set the View to hold some information when interact with the
   * MediaController
   *
   * @param v
   */
  public void setInfoView(OutlineTextView v) {
    mInfoView = v;
  }

  /**
   *

   * Change the animation style resource for this controller.
   *

   *

   *

   * If the controller is showing, calling this method will take effect only the
   * next time the controller is shown.
   *

   *
   * @param animationStyle animation style to use when the controller appears
   *                       and disappears. Set to -1 for the default animation, 0 for no animation, or
   *                       a resource identifier for an explicit animation.
   */
  public void setAnimationStyle(int animationStyle) {
    mAnimStyle = animationStyle;
  }

  /**
   * Show the controller on screen. It will go away automatically after
   * 'timeout' milliseconds of inactivity.
   *
   * @param timeout The timeout in milliseconds. Use 0 to show the controller
   *                until hide() is called.
   */
  public void show(int timeout) {
    if (!mShowing && mAnchor != null && mAnchor.getWindowToken() != null) {
      if (mPauseButton != null)
        mPauseButton.requestFocus();

      if (mFromXml) {
        setVisibility(View.VISIBLE);
      } else {
        int[] location = new int[2];

        mAnchor.getLocationOnScreen(location);
        Rect anchorRect = new Rect(location[0], location[1], location[0] + mAnchor.getWidth(), location[1] + mAnchor.getHeight());

        mWindow.setAnimationStyle(mAnimStyle);
        setWindowLayoutType();
        mWindow.showAtLocation(mAnchor, Gravity.NO_GRAVITY, anchorRect.left, anchorRect.bottom);
      }
      mShowing = true;
      if (mShownListener != null)
        mShownListener.onShown();
    }
    updatePausePlay();
    mHandler.sendEmptyMessage(SHOW_PROGRESS);

    if (timeout != 0) {
      mHandler.removeMessages(FADE_OUT);
      mHandler.sendMessageDelayed(mHandler.obtainMessage(FADE_OUT), timeout);
    }
  }

  public boolean isShowing() {
    return mShowing;
  }

  public void hide() {
    if (mAnchor == null)
      return;

    if (mShowing) {
      try {
        mHandler.removeMessages(SHOW_PROGRESS);
        if (mFromXml)
          setVisibility(View.GONE);
        else
          mWindow.dismiss();
      } catch (IllegalArgumentException ex) {
        Log.d("MediaController already removed");
      }
      mShowing = false;
      if (mHiddenListener != null)
        mHiddenListener.onHidden();
    }
  }

  public void setOnShownListener(OnShownListener l) {
    mShownListener = l;
  }

  public void setOnHiddenListener(OnHiddenListener l) {
    mHiddenListener = l;
  }

  private long setProgress() {
    if (mPlayer == null || mDragging)
      return 0;

    long position = mPlayer.getCurrentPosition();
    long duration = mPlayer.getDuration();
    if (mProgress != null) {
      if (duration > 0) {
        long pos = 1000L * position / duration;
        mProgress.setProgress((int) pos);
      }
      int percent = mPlayer.getBufferPercentage();
      mProgress.setSecondaryProgress(percent * 10);
    }

    mDuration = duration;

    if (mEndTime != null)
      mEndTime.setText(StringUtils.generateTime(mDuration));
    if (mCurrentTime != null)
      mCurrentTime.setText(StringUtils.generateTime(position));

    return position;
  }

  @Override
  public boolean onTouchEvent(MotionEvent event) {
    show(sDefaultTimeout);
    return true;
  }

  @Override
  public boolean onTrackballEvent(MotionEvent ev) {
    show(sDefaultTimeout);
    return false;
  }

  @Override
  public boolean dispatchKeyEvent(KeyEvent event) {
    int keyCode = event.getKeyCode();
    if (event.getRepeatCount() == 0 && (keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || keyCode == KeyEvent.KEYCODE_SPACE)) {
      doPauseResume();
      show(sDefaultTimeout);
      if (mPauseButton != null)
        mPauseButton.requestFocus();
      return true;
    } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP) {
      if (mPlayer.isPlaying()) {
        mPlayer.pause();
        updatePausePlay();
      }
      return true;
    } else if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) {
      hide();
      return true;
    } else {
      show(sDefaultTimeout);
    }
    return super.dispatchKeyEvent(event);
  }

  private void updatePausePlay() {
    if (mRoot == null || mPauseButton == null)
      return;

    if (mPlayer.isPlaying())
      mPauseButton.setImageResource(getResources().getIdentifier("mediacontroller_pause", "drawable", mContext.getPackageName()));
    else
      mPauseButton.setImageResource(getResources().getIdentifier("mediacontroller_play", "drawable", mContext.getPackageName()));
  }

  private void doPauseResume() {
    if (mPlayer.isPlaying())
      mPlayer.pause();
    else
      mPlayer.start();
    updatePausePlay();
  }

  @Override
  public void setEnabled(boolean enabled) {
    if (mPauseButton != null)
      mPauseButton.setEnabled(enabled);
    if (mProgress != null)
      mProgress.setEnabled(enabled);
    super.setEnabled(enabled);
  }

  public interface OnShownListener {
    public void onShown();
  }

  public interface OnHiddenListener {
    public void onHidden();
  }

  public interface MediaPlayerControl {
    void start();

    void pause();

    long getDuration();

    long getCurrentPosition();

    void seekTo(long pos);

    boolean isPlaying();

    int getBufferPercentage();
  }

}

{'repo_name': 'homcin/Tuikan', 'stars': '594', 'repo_language': 'Java', 'file_name': 'ExampleUnitTest.java', 'mime_type': 'text/plain', 'hash': 2711811734041705839, 'source_dataset': 'data'}


#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <stb_image.h>

#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>

#include <learnopengl/filesystem.h>
#include <learnopengl/shader_m.h>
#include <learnopengl/camera.h>

#include <iostream>

void framebuffer_size_callback(GLFWwindow* window, int width, int height);
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
void processInput(GLFWwindow *window);
unsigned int loadTexture(const char *path);

// settings
const unsigned int SCR_WIDTH = 800;
const unsigned int SCR_HEIGHT = 600;

// camera
Camera camera(glm::vec3(0.0f, 0.0f, 3.0f));
float lastX = SCR_WIDTH / 2.0f;
float lastY = SCR_HEIGHT / 2.0f;
bool firstMouse = true;

// timing
float deltaTime = 0.0f;
float lastFrame = 0.0f;

int main()
{
    // glfw: initialize and configure
    // ------------------------------
    glfwInit();
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

#ifdef __APPLE__
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
#endif

    // glfw window creation
    // --------------------
    GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "LearnOpenGL", NULL, NULL);
    if (window == NULL)
    {
        std::cout << "Failed to create GLFW window" << std::endl;
        glfwTerminate();
        return -1;
    }
    glfwMakeContextCurrent(window);
    glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
    glfwSetCursorPosCallback(window, mouse_callback);
    glfwSetScrollCallback(window, scroll_callback);

    // tell GLFW to capture our mouse
    glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);

    // glad: load all OpenGL function pointers
    // ---------------------------------------
    if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
    {
        std::cout << "Failed to initialize GLAD" << std::endl;
        return -1;
    }

    // configure global opengl state
    // -----------------------------
    glEnable(GL_DEPTH_TEST);

    // build and compile shaders
    // -------------------------
    Shader lightingShader("5.1.light_casters.vs", "5.1.light_casters.fs");
    Shader lightCubeShader("5.1.light_cube.vs", "5.1.light_cube.fs");

    // set up vertex data (and buffer(s)) and configure vertex attributes
    // ------------------------------------------------------------------
    float vertices[] = {
        // positions          // normals           // texture coords
        -0.5f, -0.5f, -0.5f,  0.0f,  0.0f, -1.0f,  0.0f,  0.0f,
         0.5f, -0.5f, -0.5f,  0.0f,  0.0f, -1.0f,  1.0f,  0.0f,
         0.5f,  0.5f, -0.5f,  0.0f,  0.0f, -1.0f,  1.0f,  1.0f,
         0.5f,  0.5f, -0.5f,  0.0f,  0.0f, -1.0f,  1.0f,  1.0f,
        -0.5f,  0.5f, -0.5f,  0.0f,  0.0f, -1.0f,  0.0f,  1.0f,
        -0.5f, -0.5f, -0.5f,  0.0f,  0.0f, -1.0f,  0.0f,  0.0f,

        -0.5f, -0.5f,  0.5f,  0.0f,  0.0f,  1.0f,  0.0f,  0.0f,
         0.5f, -0.5f,  0.5f,  0.0f,  0.0f,  1.0f,  1.0f,  0.0f,
         0.5f,  0.5f,  0.5f,  0.0f,  0.0f,  1.0f,  1.0f,  1.0f,
         0.5f,  0.5f,  0.5f,  0.0f,  0.0f,  1.0f,  1.0f,  1.0f,
        -0.5f,  0.5f,  0.5f,  0.0f,  0.0f,  1.0f,  0.0f,  1.0f,
        -0.5f, -0.5f,  0.5f,  0.0f,  0.0f,  1.0f,  0.0f,  0.0f,

        -0.5f,  0.5f,  0.5f, -1.0f,  0.0f,  0.0f,  1.0f,  0.0f,
        -0.5f,  0.5f, -0.5f, -1.0f,  0.0f,  0.0f,  1.0f,  1.0f,
        -0.5f, -0.5f, -0.5f, -1.0f,  0.0f,  0.0f,  0.0f,  1.0f,
        -0.5f, -0.5f, -0.5f, -1.0f,  0.0f,  0.0f,  0.0f,  1.0f,
        -0.5f, -0.5f,  0.5f, -1.0f,  0.0f,  0.0f,  0.0f,  0.0f,
        -0.5f,  0.5f,  0.5f, -1.0f,  0.0f,  0.0f,  1.0f,  0.0f,

         0.5f,  0.5f,  0.5f,  1.0f,  0.0f,  0.0f,  1.0f,  0.0f,
         0.5f,  0.5f, -0.5f,  1.0f,  0.0f,  0.0f,  1.0f,  1.0f,
         0.5f, -0.5f, -0.5f,  1.0f,  0.0f,  0.0f,  0.0f,  1.0f,
         0.5f, -0.5f, -0.5f,  1.0f,  0.0f,  0.0f,  0.0f,  1.0f,
         0.5f, -0.5f,  0.5f,  1.0f,  0.0f,  0.0f,  0.0f,  0.0f,
         0.5f,  0.5f,  0.5f,  1.0f,  0.0f,  0.0f,  1.0f,  0.0f,

        -0.5f, -0.5f, -0.5f,  0.0f, -1.0f,  0.0f,  0.0f,  1.0f,
         0.5f, -0.5f, -0.5f,  0.0f, -1.0f,  0.0f,  1.0f,  1.0f,
         0.5f, -0.5f,  0.5f,  0.0f, -1.0f,  0.0f,  1.0f,  0.0f,
         0.5f, -0.5f,  0.5f,  0.0f, -1.0f,  0.0f,  1.0f,  0.0f,
        -0.5f, -0.5f,  0.5f,  0.0f, -1.0f,  0.0f,  0.0f,  0.0f,
        -0.5f, -0.5f, -0.5f,  0.0f, -1.0f,  0.0f,  0.0f,  1.0f,

        -0.5f,  0.5f, -0.5f,  0.0f,  1.0f,  0.0f,  0.0f,  1.0f,
         0.5f,  0.5f, -0.5f,  0.0f,  1.0f,  0.0f,  1.0f,  1.0f,
         0.5f,  0.5f,  0.5f,  0.0f,  1.0f,  0.0f,  1.0f,  0.0f,
         0.5f,  0.5f,  0.5f,  0.0f,  1.0f,  0.0f,  1.0f,  0.0f,
        -0.5f,  0.5f,  0.5f,  0.0f,  1.0f,  0.0f,  0.0f,  0.0f,
        -0.5f,  0.5f, -0.5f,  0.0f,  1.0f,  0.0f,  0.0f,  1.0f
    };
    // positions all containers
    glm::vec3 cubePositions[] = {
        glm::vec3( 0.0f,  0.0f,  0.0f),
        glm::vec3( 2.0f,  5.0f, -15.0f),
        glm::vec3(-1.5f, -2.2f, -2.5f),
        glm::vec3(-3.8f, -2.0f, -12.3f),
        glm::vec3( 2.4f, -0.4f, -3.5f),
        glm::vec3(-1.7f,  3.0f, -7.5f),
        glm::vec3( 1.3f, -2.0f, -2.5f),
        glm::vec3( 1.5f,  2.0f, -2.5f),
        glm::vec3( 1.5f,  0.2f, -1.5f),
        glm::vec3(-1.3f,  1.0f, -1.5f)
    };
    // first, configure the cube's VAO (and VBO)
    unsigned int VBO, cubeVAO;
    glGenVertexArrays(1, &cubeVAO);
    glGenBuffers(1, &VBO);

    glBindBuffer(GL_ARRAY_BUFFER, VBO);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

    glBindVertexArray(cubeVAO);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)0);
    glEnableVertexAttribArray(0);
    glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(3 * sizeof(float)));
    glEnableVertexAttribArray(1);
    glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(6 * sizeof(float)));
    glEnableVertexAttribArray(2);

    // second, configure the light's VAO (VBO stays the same; the vertices are the same for the light object which is also a 3D cube)
    unsigned int lightCubeVAO;
    glGenVertexArrays(1, &lightCubeVAO);
    glBindVertexArray(lightCubeVAO);

    glBindBuffer(GL_ARRAY_BUFFER, VBO);
    // note that we update the lamp's position attribute's stride to reflect the updated buffer data
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)0);
    glEnableVertexAttribArray(0);

    // load textures (we now use a utility function to keep the code more organized)
    // -----------------------------------------------------------------------------
    unsigned int diffuseMap = loadTexture(FileSystem::getPath("resources/textures/container2.png").c_str());
    unsigned int specularMap = loadTexture(FileSystem::getPath("resources/textures/container2_specular.png").c_str());

    // shader configuration
    // --------------------
    lightingShader.use();
    lightingShader.setInt("material.diffuse", 0);
    lightingShader.setInt("material.specular", 1);

    // render loop
    // -----------
    while (!glfwWindowShouldClose(window))
    {
        // per-frame time logic
        // --------------------
        float currentFrame = glfwGetTime();
        deltaTime = currentFrame - lastFrame;
        lastFrame = currentFrame;

        // input
        // -----
        processInput(window);

        // render
        // ------
        glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        // be sure to activate shader when setting uniforms/drawing objects
        lightingShader.use();
        lightingShader.setVec3("light.direction", -0.2f, -1.0f, -0.3f);
        lightingShader.setVec3("viewPos", camera.Position);

        // light properties
        lightingShader.setVec3("light.ambient", 0.2f, 0.2f, 0.2f);
        lightingShader.setVec3("light.diffuse", 0.5f, 0.5f, 0.5f);
        lightingShader.setVec3("light.specular", 1.0f, 1.0f, 1.0f);

        // material properties
        lightingShader.setFloat("material.shininess", 32.0f);

        // view/projection transformations
        glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
        glm::mat4 view = camera.GetViewMatrix();
        lightingShader.setMat4("projection", projection);
        lightingShader.setMat4("view", view);

        // world transformation
        glm::mat4 model = glm::mat4(1.0f);
        lightingShader.setMat4("model", model);

        // bind diffuse map
        glActiveTexture(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_2D, diffuseMap);
        // bind specular map
        glActiveTexture(GL_TEXTURE1);
        glBindTexture(GL_TEXTURE_2D, specularMap);

        // render the cube
        // glBindVertexArray(cubeVAO);
        // glDrawArrays(GL_TRIANGLES, 0, 36);*/

        // render containers
        glBindVertexArray(cubeVAO);
        for (unsigned int i = 0; i < 10; i++)
        {
            // calculate the model matrix for each object and pass it to shader before drawing
            glm::mat4 model = glm::mat4(1.0f);
            model = glm::translate(model, cubePositions[i]);
            float angle = 20.0f * i;
            model = glm::rotate(model, glm::radians(angle), glm::vec3(1.0f, 0.3f, 0.5f));
            lightingShader.setMat4("model", model);

            glDrawArrays(GL_TRIANGLES, 0, 36);
        }

        // a lamp object is weird when we only have a directional light, don't render the light object
        // lightCubeShader.use();
        // lightCubeShader.setMat4("projection", projection);
        // lightCubeShader.setMat4("view", view);
        // model = glm::mat4(1.0f);
        // model = glm::translate(model, lightPos);
        // model = glm::scale(model, glm::vec3(0.2f)); // a smaller cube
        // lightCubeShader.setMat4("model", model);

        // glBindVertexArray(lightCubeVAO);
        // glDrawArrays(GL_TRIANGLES, 0, 36);

        // glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.)
        // -------------------------------------------------------------------------------
        glfwSwapBuffers(window);
        glfwPollEvents();
    }

    // optional: de-allocate all resources once they've outlived their purpose:
    // ------------------------------------------------------------------------
    glDeleteVertexArrays(1, &cubeVAO);
    glDeleteVertexArrays(1, &lightCubeVAO);
    glDeleteBuffers(1, &VBO);

    // glfw: terminate, clearing all previously allocated GLFW resources.
    // ------------------------------------------------------------------
    glfwTerminate();
    return 0;
}

// process all input: query GLFW whether relevant keys are pressed/released this frame and react accordingly
// ---------------------------------------------------------------------------------------------------------
void processInput(GLFWwindow *window)
{
    if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
        glfwSetWindowShouldClose(window, true);

    if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
        camera.ProcessKeyboard(FORWARD, deltaTime);
    if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
        camera.ProcessKeyboard(BACKWARD, deltaTime);
    if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
        camera.ProcessKeyboard(LEFT, deltaTime);
    if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
        camera.ProcessKeyboard(RIGHT, deltaTime);
}

// glfw: whenever the window size changed (by OS or user resize) this callback function executes
// ---------------------------------------------------------------------------------------------
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
    // make sure the viewport matches the new window dimensions; note that width and
    // height will be significantly larger than specified on retina displays.
    glViewport(0, 0, width, height);
}

// glfw: whenever the mouse moves, this callback is called
// -------------------------------------------------------
void mouse_callback(GLFWwindow* window, double xpos, double ypos)
{
    if (firstMouse)
    {
        lastX = xpos;
        lastY = ypos;
        firstMouse = false;
    }

    float xoffset = xpos - lastX;
    float yoffset = lastY - ypos; // reversed since y-coordinates go from bottom to top

    lastX = xpos;
    lastY = ypos;

    camera.ProcessMouseMovement(xoffset, yoffset);
}

// glfw: whenever the mouse scroll wheel scrolls, this callback is called
// ----------------------------------------------------------------------
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset)
{
    camera.ProcessMouseScroll(yoffset);
}

// utility function for loading a 2D texture from file
// ---------------------------------------------------
unsigned int loadTexture(char const * path)
{
    unsigned int textureID;
    glGenTextures(1, &textureID);

    int width, height, nrComponents;
    unsigned char *data = stbi_load(path, &width, &height, &nrComponents, 0);
    if (data)
    {
        GLenum format;
        if (nrComponents == 1)
            format = GL_RED;
        else if (nrComponents == 3)
            format = GL_RGB;
        else if (nrComponents == 4)
            format = GL_RGBA;

        glBindTexture(GL_TEXTURE_2D, textureID);
        glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, data);
        glGenerateMipmap(GL_TEXTURE_2D);

        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

        stbi_image_free(data);
    }
    else
    {
        std::cout << "Texture failed to load at path: " << path << std::endl;
        stbi_image_free(data);
    }

    return textureID;
}

{'repo_name': 'JoeyDeVries/LearnOpenGL', 'stars': '4415', 'repo_language': 'C++', 'file_name': 'FindGLM.cmake', 'mime_type': 'text/plain', 'hash': -678975538048244590, 'source_dataset': 'data'}


<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:focusableInTouchMode="true"
    android:background="@drawable/trtcliveroom_bg_main_gradient">

    <com.tencent.liteav.demo.beauty.view.BeautyPanel
        android:id="@+id/beauty_panel"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:visibility="gone"
        android:clickable="true"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintLeft_toLeftOf="parent" />

    <android.support.constraint.Guideline
        android:id="@+id/gl_vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_percent="0.5" />

    <android.support.constraint.Guideline
        android:id="@+id/gl_horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_percent="0.5" />

    <com.tencent.rtmp.ui.TXCloudVideoView
        android:id="@+id/video_view_anchor"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <android.support.constraint.Group
        android:id="@+id/before_live"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:constraint_referenced_ids="btn_close_before_live,btn_switch_cam_before_live,btn_beauty_before_live,cl_live_room_before,btn_start_room" />

    <android.support.constraint.Group
        android:id="@+id/after_live"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:visibility="gone"
        app:constraint_referenced_ids="anchor_danmaku_view,layout_live_pusher_info,rv_audience_avatar,lv_im_msg,video_view_link_mic_1,video_view_link_mic_2,video_view_link_mic_3,btn_audio_ctrl,btn_request_pk,btn_message_input,btn_close,btn_switch_camera,beauty_btn" />

    <RelativeLayout
        android:id="@+id/pk_container"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginTop="20dp"
        app:layout_constraintBottom_toBottomOf="@+id/gl_horizontal"
        app:layout_constraintLeft_toLeftOf="@id/gl_vertical"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/layout_live_pusher_info" />

    <ImageView
        android:id="@+id/iv_pk_layer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/trtcliveroom_icon_pk_layer"
        android:visibility="gone"
        app:layout_constraintBottom_toTopOf="@+id/gl_horizontal"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent" />

    <!--连麦：播放小窗口定义 开始-->
    <!--连麦：第一个播放小窗口-->
    <com.tencent.liteav.liveroom.ui.widget.video.TCVideoView
        android:id="@+id/video_view_link_mic_1"
        style="@style/TRTCLiveRoomLinkMic"
        app:layout_constraintBottom_toTopOf="@+id/tool_bar_view"
        app:layout_constraintEnd_toEndOf="parent" />

    <!--连麦：第二个播放小窗口-->
    <com.tencent.liteav.liveroom.ui.widget.video.TCVideoView
        android:id="@+id/video_view_link_mic_2"
        style="@style/TRTCLiveRoomLinkMic"
        app:layout_constraintBottom_toTopOf="@+id/video_view_link_mic_1"
        app:layout_constraintEnd_toEndOf="parent" />

    <!--连麦：第三个播放小窗口-->
    <com.tencent.liteav.liveroom.ui.widget.video.TCVideoView
        android:id="@+id/video_view_link_mic_3"
        style="@style/TRTCLiveRoomLinkMic"
        app:layout_constraintBottom_toTopOf="@+id/video_view_link_mic_2"
        app:layout_constraintEnd_toEndOf="parent" />
    <!--连麦：播放小窗口定义 结束-->

    <include
        android:id="@+id/layout_live_pusher_info"
        layout="@layout/trtcliveroom_include_live_pusher_info"
        android:layout_width="110dp"
        android:layout_height="35dp"
        android:layout_marginStart="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <android.support.v7.widget.RecyclerView
        android:id="@+id/rv_audience_avatar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp"
        android:layout_marginRight="15dp"
        app:layout_constraintStart_toEndOf="@id/layout_live_pusher_info"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/btn_close_before_live"
        android:layout_width="@dimen/trtcliveroom_btn_size"
        android:layout_height="@dimen/trtcliveroom_btn_size"
        android:layout_marginTop="15dp"
        android:layout_marginEnd="15dp"
        android:layout_marginRight="15dp"
        android:background="@drawable/trtcliveroom_btn_close"
        android:onClick="onClick"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/btn_switch_cam_before_live"
        android:layout_width="@dimen/trtcliveroom_btn_size"
        android:layout_height="@dimen/trtcliveroom_btn_size"
        android:background="@drawable/trtcliveroom_icon_switch_camera_on"
        android:onClick="onClick"
        app:layout_constraintBottom_toBottomOf="@+id/btn_start_room"
        app:layout_constraintEnd_toStartOf="@+id/btn_start_room"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/btn_start_room" />

    <Button
        android:id="@+id/btn_start_room"
        android:layout_width="150dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="25dp"
        android:background="@drawable/trtcliveroom_bg_start_live_button_border"
        android:text="@string/trtcliveroom_btn_start_live"
        android:textColor="@color/white"
        android:textSize="@dimen/trtcliveroom_text_size_large"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@+id/btn_beauty_before_live"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@+id/btn_switch_cam_before_live" />

    <Button
        android:id="@+id/btn_beauty_before_live"
        android:layout_width="@dimen/trtcliveroom_btn_size"
        android:layout_height="@dimen/trtcliveroom_btn_size"
        android:background="@drawable/trtcliveroom_icon_beauty_drawable"
        android:onClick="onClick"
        app:layout_constraintBottom_toBottomOf="@+id/btn_start_room"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@+id/btn_start_room"
        app:layout_constraintTop_toTopOf="@+id/btn_start_room" />

    <Button
        android:id="@+id/btn_message_input"
        android:layout_width="@dimen/trtcliveroom_btn_size"
        android:layout_height="@dimen/trtcliveroom_btn_size"
        android:layout_marginBottom="19dp"
        android:background="@drawable/trtcliveroom_icon_message"
        android:onClick="onClick"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@+id/btn_switch_camera"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/btn_switch_camera" />

    <Button
        android:id="@+id/btn_switch_camera"
        android:layout_width="@dimen/trtcliveroom_btn_size"
        android:layout_height="@dimen/trtcliveroom_btn_size"
        android:layout_marginBottom="19dp"
        android:background="@drawable/trtcliveroom_icon_switch_camera_on"
        android:onClick="onClick"
        app:layout_constraintEnd_toStartOf="@+id/btn_request_pk"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@+id/btn_message_input"
        app:layout_constraintTop_toTopOf="@+id/btn_request_pk" />

    <Button
        android:id="@+id/btn_request_pk"
        android:layout_width="@dimen/trtcliveroom_btn_size"
        android:layout_height="@dimen/trtcliveroom_btn_size"
        android:layout_marginBottom="19dp"
        android:background="@drawable/trtcliveroom_pk_start"
        android:onClick="onClick"
        app:layout_constraintEnd_toStartOf="@+id/beauty_btn"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@+id/btn_switch_camera"
        app:layout_constraintTop_toTopOf="@+id/beauty_btn" />

    <Button
        android:id="@+id/beauty_btn"
        android:layout_width="@dimen/trtcliveroom_btn_size"
        android:layout_height="@dimen/trtcliveroom_btn_size"
        android:layout_marginBottom="19dp"
        android:background="@drawable/trtcliveroom_icon_beauty_drawable"
        android:onClick="onClick"
        app:layout_constraintEnd_toStartOf="@+id/btn_audio_ctrl"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@+id/btn_request_pk"
        app:layout_constraintTop_toTopOf="@+id/btn_audio_ctrl" />

    <Button
        android:id="@+id/btn_audio_ctrl"
        android:layout_width="@dimen/trtcliveroom_btn_size"
        android:layout_height="@dimen/trtcliveroom_btn_size"
        android:layout_marginBottom="19dp"
        android:background="@drawable/trtcliveroom_music_big"
        android:onClick="onClick"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@+id/beauty_btn" />

    <Button
        android:id="@+id/btn_close"
        android:layout_width="80dp"
        android:layout_height="26dp"
        android:layout_marginTop="10dp"
        android:layout_marginRight="20dp"
        android:background="@drawable/trtcliveroom_btn_live_over"
        android:onClick="onClick"
        android:text="@string/trtcliveroom_btn_stop_live"
        android:textColor="@color/white"
        android:textSize="14sp"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <View
        android:id="@+id/tool_bar_view"
        android:layout_width="wrap_content"
        android:layout_height="1px"
        android:layout_marginBottom="5dp"
        app:layout_constraintBottom_toTopOf="@id/btn_start_room"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent" />

    <ListView
        android:id="@+id/lv_im_msg"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginStart="15dp"
        android:layout_marginLeft="15dp"
        android:cacheColorHint="@color/trtcliveroom_transparent"
        android:divider="#3c421b1b"
        android:scrollbarStyle="outsideOverlay"
        android:scrollbars="none"
        android:stackFromBottom="true"
        app:layout_constraintBottom_toBottomOf="@+id/tool_bar_view"
        app:layout_constraintEnd_toEndOf="@+id/gl_vertical"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/gl_horizontal"
        tools:visibility="visible" />

    <com.tencent.liteav.liveroom.ui.anchor.AnchorPKSelectView
        android:id="@+id/anchor_pk_select_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@color/trtcliveroom_color_bg_select_pk"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />

    <!--点赞动画-->
    <com.tencent.liteav.liveroom.ui.widget.like.TCHeartLayout
        android:id="@+id/heart_layout"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:focusable="true"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="@id/tool_bar_view"
        app:layout_constraintEnd_toEndOf="parent" />

    <master.flame.danmaku.ui.widget.DanmakuView
        android:id="@+id/anchor_danmaku_view"
        android:layout_width="wrap_content"
        android:layout_height="80dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <android.support.constraint.ConstraintLayout
        android:id="@+id/cl_live_room_before"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:background="@drawable/trtcliveroom_message_background"
        android:gravity="center_vertical"
        android:orientation="horizontal"
        app:layout_constraintBottom_toBottomOf="@id/gl_horizontal"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <ImageView
            android:id="@+id/img_live_room_cover"
            android:layout_width="70dp"
            android:layout_height="70dp"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="10dp"
            android:src="@drawable/trtcliveroom_bg_cover"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/tv_live_room_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:text="@string/trtcliveroom_text_room_name"
            android:textColor="@color/colorWhite"
            android:textSize="@dimen/trtcliveroom_text_size_large"
            android:textStyle="bold"
            app:layout_constraintStart_toEndOf="@+id/img_live_room_cover"
            app:layout_constraintTop_toTopOf="@+id/img_live_room_cover" />

        <EditText
            android:id="@+id/et_live_room_name"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginBottom="5dp"
            android:background="@null"
            android:hint="@string/trtcliveroom_hint_live_room_name"
            android:maxLength="10"
            android:maxLines="1"
            android:singleLine="true"
            android:textCursorDrawable="@drawable/trtcliveroom_bg_edittext"
            android:textSize="22sp"
            android:textStyle="bold"
            app:layout_constraintBottom_toBottomOf="@+id/img_live_room_cover"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toEndOf="@+id/img_live_room_cover" />

        <TextView
            android:id="@+id/tv_live_room_quality_tag"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="10dp"
            android:text="@string/trtcliveroom_text_voice_quality"
            android:textColor="@color/colorWhite"
            android:textSize="@dimen/trtcliveroom_text_size_middle"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toEndOf="@+id/img_live_room_cover"
            app:layout_constraintTop_toBottomOf="@+id/et_live_room_name" />

        <RadioGroup
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:orientation="horizontal"
            app:layout_constraintBottom_toBottomOf="@+id/tv_live_room_quality_tag"
            app:layout_constraintStart_toEndOf="@+id/tv_live_room_quality_tag"
            app:layout_constraintTop_toTopOf="@+id/tv_live_room_quality_tag">

            <RadioButton
                android:id="@+id/rb_live_room_quality_normal"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/trtcliveroom_bg_live_room_rb_quality"
                android:button="@null"
                android:gravity="center"
                android:text="@string/trtcliveroom_voice_quality_standard"
                android:textColor="@color/white"
                app:layout_constraintBottom_toBottomOf="@+id/tv_live_room_quality_tag"
                app:layout_constraintStart_toEndOf="@+id/tv_live_room_quality_tag"
                app:layout_constraintTop_toTopOf="@+id/tv_live_room_quality_tag" />

            <RadioButton
                android:id="@+id/rb_live_room_quality_music"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:background="@drawable/trtcliveroom_bg_live_room_rb_quality"
                android:button="@null"
                android:gravity="center"
                android:checked="true"
                android:text="@string/trtcliveroom_voice_quality_muisic"
                android:textColor="@color/white" />

        </RadioGroup>

    </android.support.constraint.ConstraintLayout>

    <com.tencent.liteav.audiosettingkit.AudioEffectPanel
        android:id="@+id/anchor_audio_panel"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        tools:visibility="gone"/>

</android.support.constraint.ConstraintLayout>

{'repo_name': 'tencentyun/TRTCSDK', 'stars': '648', 'repo_language': 'C++', 'file_name': 'convert_argb.h', 'mime_type': 'text/x-c++', 'hash': 2218516076677500572, 'source_dataset': 'data'}


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<link rel="stylesheet" type="text/css" href="search.css"/>

Loading...

Searching...

No Matches

{'repo_name': 'alexa/alexa-auto-sdk', 'stars': '202', 'repo_language': 'C++', 'file_name': 'libcrypto.pc', 'mime_type': 'text/plain', 'hash': -5132749468743805236, 'source_dataset': 'data'}


/*
Copyright (c) 2012, Broadcom Europe Ltd
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the copyright holder nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef MMAL_UTIL_H
#define MMAL_UTIL_H

#include "interface/mmal/mmal.h"

/** \defgroup MmalUtilities Utility functions
 * The utility functions provide helpers for common functionality that is not part
 * of the core MMAL API.
 * @{
 */

/** Offset in bytes of FIELD in TYPE. */
#define MMAL_OFFSET(TYPE, FIELD) ((size_t)((uint8_t *)&((TYPE*)0)->FIELD - (uint8_t *)0))

#ifdef __cplusplus
extern "C" {
#endif

/** Convert a status to a statically-allocated string.
 *
 * @param status The MMAL status code.
 * @return A C string describing the status code.
 */
const char *mmal_status_to_string(MMAL_STATUS_T status);

/** Convert stride to pixel width for a given pixel encoding.
 *
 * @param encoding The pixel encoding (such as one of the \ref MmalEncodings "pre-defined encodings")
 * @param stride The stride in bytes.
 * @return The width in pixels.
 */
uint32_t mmal_encoding_stride_to_width(uint32_t encoding, uint32_t stride);

/** Convert pixel width to stride for a given pixel encoding
 *
 * @param encoding The pixel encoding (such as one of the \ref MmalEncodings "pre-defined encodings")
 * @param width The width in pixels.
 * @return The stride in bytes.
 */
uint32_t mmal_encoding_width_to_stride(uint32_t encoding, uint32_t width);

/** Return the 16 line high sliced version of a given pixel encoding
 *
 * @param encoding The pixel encoding (such as one of the \ref MmalEncodings "pre-defined encodings")
 * @return The sliced equivalent, or MMAL_ENCODING_UNKNOWN if not supported.
 */
uint32_t mmal_encoding_get_slice_variant(uint32_t encoding);

/** Convert a port type to a string.
 *
 * @param type The MMAL port type.
 * @return A NULL-terminated string describing the port type.
 */
const char* mmal_port_type_to_string(MMAL_PORT_TYPE_T type);

/** Get a parameter from a port allocating the required amount of memory
 * for the parameter (i.e. for variable length parameters like URI or arrays).
 * The size field will be set on output to the actual size of the
 * parameter allocated and retrieved.
 *
 * The pointer returned must be released by a call to \ref mmal_port_parameter_free().
 *
 * @param port port to send request to
 * @param id parameter id
 * @param size initial size hint for allocation (can be 0)
 * @param status status of the parameter get operation (can be 0)
 * @return pointer to the header of the parameter or NULL on failure.
 */
MMAL_PARAMETER_HEADER_T *mmal_port_parameter_alloc_get(MMAL_PORT_T *port,
   uint32_t id, uint32_t size, MMAL_STATUS_T *status);

/** Free a parameter structure previously allocated via
 * \ref mmal_port_parameter_alloc_get().
 *
 * @param param pointer to header of the parameter
 */
void mmal_port_parameter_free(MMAL_PARAMETER_HEADER_T *param);

/** Copy buffer header metadata from source to destination.
 *
 * @param dest The destination buffer header.
 * @param src  The source buffer header.
 */
void mmal_buffer_header_copy_header(MMAL_BUFFER_HEADER_T *dest, const MMAL_BUFFER_HEADER_T *src);

/** Create a pool of MMAL_BUFFER_HEADER_T associated with a specific port.
 * This allows a client to allocate memory for the payload buffers based on the preferences
 * of a port. This for instance will allow the port to allocate memory which can be shared
 * between the host processor and videocore.
 * After allocation, all allocated buffer headers will have been added to the queue.
 *
 * It is valid to create a pool with no buffer headers, or with zero size payload buffers.
 * The mmal_pool_resize() function can be used to increase or decrease the number of buffer
 * headers, or the size of the payload buffers, after creation of the pool.
 *
 * @param port         Port responsible for creating the pool.
 * @param headers      Number of buffers which will be allocated with the pool.
 * @param payload_size Size of the payload buffer which will be allocated in
 *                     each of the buffer headers.
 * @return Pointer to the newly created pool or NULL on failure.
 */
MMAL_POOL_T *mmal_port_pool_create(MMAL_PORT_T *port,
   unsigned int headers, uint32_t payload_size);

/** Destroy a pool of MMAL_BUFFER_HEADER_T associated with a specific port.
 * This will also deallocate all of the memory which was allocated when creating or
 * resizing the pool.
 *
 * @param port  Pointer to the port responsible for creating the pool.
 * @param pool  Pointer to the pool to be destroyed.
 */
void mmal_port_pool_destroy(MMAL_PORT_T *port, MMAL_POOL_T *pool);

/** Log the content of a \ref MMAL_PORT_T structure.
 *
 * @param port  Pointer to the port to dump.
 */
void mmal_log_dump_port(MMAL_PORT_T *port);

/** Log the content of a \ref MMAL_ES_FORMAT_T structure.
 *
 * @param format  Pointer to the format to dump.
 */
void mmal_log_dump_format(MMAL_ES_FORMAT_T *format);

/** Return the nth port.
 *
 * @param comp   component to query
 * @param index  port index
 * @param type   port type
 *
 * @return port or NULL if not found
 */
MMAL_PORT_T *mmal_util_get_port(MMAL_COMPONENT_T *comp, MMAL_PORT_TYPE_T type, unsigned index);

/** Convert a 4cc into a string.
 *
 * @param buf    Destination for result
 * @param len    Size of result buffer
 * @param fourcc 4cc to be converted
 * @return converted string (buf)
 *
 */
char *mmal_4cc_to_string(char *buf, size_t len, uint32_t fourcc);

/** On FW prior to June 2016, camera and video_splitter
 *  had BGR24 and RGB24 support reversed.
 *  This is now fixed, and this function will return whether the
 *  FW has the fix or not.
 *
 * @param port   MMAL port to check (on camera or video_splitter)
 * @return 0 if old firmware, 1 if new.
 *
 */
int mmal_util_rgb_order_fixed(MMAL_PORT_T *port);

#ifdef __cplusplus
}
#endif

/** @} */

#endif

{'repo_name': 'libretro/RetroArch', 'stars': '4484', 'repo_language': 'C', 'file_name': 'Makefile', 'mime_type': 'text/plain', 'hash': -8582325472580115489, 'source_dataset': 'data'}


import { HideHelp, HideLoadButton, UpdateLastUpdate } from './app.action';
import {Action, Selector, State, StateContext} from '@ngxs/store';

export interface ConversationsModel {
  lastUpdate: Date | null;
  hideHelp: boolean;
  hideLoadButton: boolean;
}

@State<ConversationsModel>({
  name: 'Conversations',
  defaults: {
    lastUpdate: null,
    hideHelp: false,
    hideLoadButton: false,
  }
})

export class ConversationsState {

  @Selector()
  static getLastUpdate(state: ConversationsModel) {
    return state.lastUpdate;
  }

  @Selector()
  static getHideHelp(state: ConversationsModel) {
    return state.hideHelp;
  }

  @Selector()
  static getHideLoadButton(state: ConversationsModel) {
    return state.hideLoadButton;
  }

  @Action(UpdateLastUpdate)
  updateLastUpdate({setState, patchState}: StateContext<ConversationsModel>, {payload}: UpdateLastUpdate) {
    patchState({
      lastUpdate: payload
    });
  }

  @Action(HideHelp)
  updateHideHelp({setState, patchState}: StateContext<ConversationsModel>, {payload}: HideHelp) {
    patchState({
      hideHelp: payload
    });
  }

  @Action(HideLoadButton)
  updateHideLoadButton({setState, patchState}: StateContext<ConversationsModel>, {payload}: HideLoadButton) {
    patchState({
      hideLoadButton: payload
    });
  }

}

{'repo_name': 'w11k/calendar-for-trello', 'stars': '119', 'repo_language': 'TypeScript', 'file_name': 'app.e2e-spec.ts', 'mime_type': 'text/x-java', 'hash': 6165952222040279370, 'source_dataset': 'data'}


@CHARSET "ISO-8859-1";

.sortable-placeholder {
    border: 3px dashed gray;
    height: 48px;
}

.draghandle {
    cursor: move
}

tr.wm_map_disabled {
    color: #ccc;
}

td.wm_maptitle {
    padding-right: 20px;
}

span.wm_maptitle {
    font-size: 150%;
}

.wm_controls {
    font-size: 70%;
    color: lightgray;
}

.wm_maplist {
    padding-left: 100px;
    padding-bottom: 50px;
}

.wm_mapgroup {
    padding-left: 30px;
}

img.thumb48 {
    border: 1px solid #eee;
}

td.maptable_thumb {
    width: 66px;
}

td.maptable_disc {
    width: 12px;
}

td.maptable_delete {
    width: 20px;
}

td.maptable_perms {
    width: 150px;
}

td.maptable_names {
    width: 400px;
}

td.maptable_status {
    width: 100px;
}

td.maptable_settings {
    width: 80px;
}

td.maptable_active {
    width: 50px;
}

div.wm_mapgroup table {
    border-top: 1px solid #eee;
}

.wm_warningcount {
    border: 2px red solid;
    padding: 2px;
}

.wm_maplist tr td {
    border-bottom: 1px solid #cccccc;
}

.wm_maplist tr th {
    color: gray;
    font-weight: normal;
}

.xwm_maplist tr.alt-row {
    background-color: #eef;
}

.wm_map_extra {
    display: none;
}

.wm_warning {
    padding: 5px;
    width: 50%;
    border: 2px red solid;
    margin: 5px auto 15px auto;
    background-color: #fee;
}

/* .all_map_holder { margin-left: auto; margin-right: auto;  } */

tr.fig, tr.fig td {
    border-top: 1px solid gray;
}

td.groupheader {
    background-color: #009;
    color: white;
    font-weight: bold;
}

.wm_expanded {
    height: 200px;
    border-left: 1px solid gray;
    border-bottom: 1px solid gray;
    border-right: 1px solid gray;
}

/* Cycle-related stuff */

body#wm_fullscreen {
    font-family: sans-serif;
    margin: 0;
    border: 0;
    padding: 0;
    background-color: black;
}

#wmcyclecontrolbox.fullscreen {
    z-index: 100;
    opacity: 0.9;
    position: fixed;
    left: 10px;
    top: 10px;
}

#wmcyclecontrolbox {
    background-color: rgb(255, 255, 255);
    padding: 10px;
    border: solid 1px black;
    width: 450px;
    font-size: small;
}

#wmcyclecontrolbox.fullscreen #cycle_fullscreen {
    display: none;
}

#wm_progress {
    width: 450px;
    background-color: rgb(128, 128, 128);
    height: 8px;
    margin-bottom: 2px;
}

#wm_progress.paused {
    background-color: rgb(128, 0, 0);
}

.fullscreen .weathermapholder {
    display: none;
    position: absolute;
}

.inplace .weathermapholder {
    display: none;
}

#wm_cyclecontrols a img {
    width: 16px;
    height: 16px;
    border: 0;
}

{'repo_name': 'howardjones/network-weathermap', 'stars': '355', 'repo_language': 'PHP', 'file_name': 'front.php', 'mime_type': 'text/x-php', 'hash': 3113654365096044250, 'source_dataset': 'data'}


// Copyright (c) 2006, 2007 Julio M. Merino Vidal
// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
// Copyright (c) 2009 Boris Schaeling
// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
// Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
// Copyright (c) 2016 Klemens D. Morgenstern
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#ifndef BOOST_PROCESS_DETAIL_INITIALIZERS_THROW_ON_ERROR_HPP
#define BOOST_PROCESS_DETAIL_INITIALIZERS_THROW_ON_ERROR_HPP

#include <boost/process/detail/config.hpp>
#include <boost/process/detail/handler_base.hpp>

namespace boost { namespace process { namespace detail {

struct throw_on_error_ : ::boost::process::detail::handler
{
    template <class Executor>
    void on_error(Executor& exec, const std::error_code & ec) const
    {
        throw process_error(ec, "process creation failed");
    }

    const throw_on_error_ &operator()() const {return *this;}
};

}

constexpr boost::process::detail::throw_on_error_ throw_on_error;

}}

#endif

{'repo_name': 'VoltDB/voltdb', 'stars': '1597', 'repo_language': 'Java', 'file_name': 'NonBlockingHashMap.java', 'mime_type': 'text/plain', 'hash': 1684198042871754798, 'source_dataset': 'data'}


//Copyright (C) 2004 Klaus Wuestefeld
//This is free software. It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license distributed along with this file for more details.
//Contributions: Alexandre Nodari.

package org.prevayler.foundation.network;

import java.io.IOException;
import java.net.ServerSocket;

public class ObjectServerSocketImpl implements ObjectServerSocket {

  private final ServerSocket _serverSocket;

  public ObjectServerSocketImpl(int port) throws IOException {
    _serverSocket = new ServerSocket(port);
  }

  public ObjectSocket accept() throws IOException {
    return new ObjectSocketImpl(_serverSocket.accept());
  }

  public void close() throws IOException {
    _serverSocket.close();
  }
}

{'repo_name': 'prevayler/prevayler', 'stars': '257', 'repo_language': 'Java', 'file_name': 'XStreamSerializer.java', 'mime_type': 'text/html', 'hash': 6950808025180924066, 'source_dataset': 'data'}


/* LzmaRamDecode.h */

#ifndef __LzmaRamDecode_h
#define __LzmaRamDecode_h

#include <stdlib.h>

/*
LzmaRamGetUncompressedSize:
  In:
    inBuffer - input data
    inSize   - input data size
  Out:
    outSize  - uncompressed size
  Return code:
    0 - OK
    1 - Error in headers
*/

int LzmaRamGetUncompressedSize(
    const unsigned char *inBuffer,
    size_t inSize,
    size_t *outSize);

/*
LzmaRamDecompress:
  In:
    inBuffer  - input data
    inSize    - input data size
    outBuffer - output data
    outSize   - output size
    allocFunc - alloc function (can be malloc)
    freeFunc  - free function (can be free)
  Out:
    outSizeProcessed - processed size
  Return code:
    0 - OK
    1 - Error in headers / data stream
    2 - Memory allocating error

Memory requirements depend from properties of LZMA stream.
With default lzma settings it's about 16 KB.
*/

int LzmaRamDecompress(
    const unsigned char *inBuffer,
    size_t inSize,
    unsigned char *outBuffer,
    size_t outSize,
    size_t *outSizeProcessed,
    void * (*allocFunc)(size_t size),
    void (*freeFunc)(void *));

#endif

{'repo_name': 'rampageX/firmware-mod-kit', 'stars': '381', 'repo_language': 'C++', 'file_name': 'create-reversion-firmware.sh', 'mime_type': 'text/x-shellscript', 'hash': 6552569762670870240, 'source_dataset': 'data'}


# Copyright 2011 Mario Mulansky
# Copyright 2012 Karsten Ahnert
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

project
    : requirements
      <define>BOOST_ALL_NO_LIB=1
    :
    ;

lib quadmath : : <name>quadmath <link>shared ;

exe black_hole : black_hole.cpp quadmath : <cxxflags>-std=c++0x ;

{'repo_name': 'headmyshoulder/odeint-v2', 'stars': '268', 'repo_language': 'C++', 'file_name': 'error_stepper.qbk', 'mime_type': 'text/x-c++', 'hash': -594014707290689438, 'source_dataset': 'data'}


.drop-target.drop-open {
    outline: 2px solid;
}

.body {
    position: relative;
    margin-right: 300px;
}

.page {
    max-width: 100%;
    width: 1080px;
    padding: 0 10px;
    box-sizing: border-box;
    margin: 0 auto;
}

.navigation {
    background: blue;
    color: #fff;
    margin-right: 300px;
    margin-bottom: 30px;
}

.navigation .item a {
    padding: 30px 20px;
    display: inline-block;
}

.navigation .item a {
    color: inherit;
}

.navigation .drop-target.drop-open {
    background: #fff;
    color: blue;
    outline: none;
}

.right-sidebar {
    position: fixed;
    height: 50%;
    width: 300px;
    background: #eee;
    overflow: auto;
    right: 0;
}

.right-sidebar .drop-target.drop-open {
    background: blue;
    color: #fff;
    outline: none;
}

.right-sidebar .item a {
    display: block;
    padding: 20px;
    margin-bottom: 10px;
    background: rgba(0, 0, 0, .1);
}

.right-sidebar-top {
    top: 0;
}

.right-sidebar-bottom {
    top: 50%;
    background: #ccc;
}

.scroll-container {
    position: relative;
    overflow: auto;
    background: #eee;
    padding: 20px;
    margin-bottom: 20px;
    margin-right: 20px;
    height: 200px;
    width: 200px;
}

.absolute-container {
    position: absolute;
    top: 20px;
    right: 300px;
}

{'repo_name': 'Apress/pro-asp.net-core-mvc-2', 'stars': '336', 'repo_language': 'HTML', 'file_name': 'npm-shrinkwrap.json', 'mime_type': 'text/plain', 'hash': -1164698149695765743, 'source_dataset': 'data'}