Java Code Examples for android.opengl.GLSurfaceView

The following examples show how to use android.opengl.GLSurfaceView. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: AndroidPlayground   Source File: CameraCaptureActivity.java    License: MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_camera_capture);

    File outputFile = new File(Environment.getExternalStorageDirectory(), "camera-test.mp4");

    // Define a handler that receives camera-control messages from other threads.  All calls
    // to Camera must be made on the same thread.  Note we create this before the renderer
    // thread, so we know the fully-constructed object will be visible.
    mCameraHandler = new CameraHandler(this);

    // Configure the GLSurfaceView.  This will start the Renderer thread, with an
    // appropriate EGL context.
    mGLView = (GLSurfaceView) findViewById(R.id.cameraPreview_surfaceView);
    mGLView.setEGLContextClientVersion(2);     // select GLES 2.0
    mRenderer = new CameraSurfaceRenderer(mCameraHandler, outputFile);
    mGLView.setRenderer(mRenderer);
    mGLView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);

    Log.d(TAG, "onCreate complete: " + this);
}
 
Example 2
Source Project: VIA-AI   Source File: CameraGLSurfaceView.java    License: MIT License 6 votes vote down vote up
public CameraGLSurfaceView(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
    int cameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
    styledAttrs.recycle();

    if(android.os.Build.VERSION.SDK_INT >= 21)
        mRenderer = new Camera2Renderer(this);
    else
        mRenderer = new CameraRenderer(this);

    setCameraIndex(cameraIndex);

    setEGLContextClientVersion(2);
    setRenderer(mRenderer);
    setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
 
Example 3
Source Project: LPR   Source File: CameraGLSurfaceView.java    License: Apache License 2.0 6 votes vote down vote up
public CameraGLSurfaceView(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
    int cameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
    styledAttrs.recycle();

    if(android.os.Build.VERSION.SDK_INT >= 21)
        mRenderer = new Camera2Renderer(this);
    else
        mRenderer = new CameraRenderer(this);

    setCameraIndex(cameraIndex);

    setEGLContextClientVersion(2);
    setRenderer(mRenderer);
    setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
 
Example 4
Source Project: TurboLauncher   Source File: TiledImageView.java    License: Apache License 2.0 6 votes vote down vote up
public TiledImageView(Context context, AttributeSet attrs) {
    super(context, attrs);
    if (!IS_SUPPORTED) {
        return;
    }

    mRenderer = new ImageRendererWrapper();
    mRenderer.image = new TiledImageRenderer(this);
    View view;
    if (USE_TEXTURE_VIEW) {
        mTextureView = new BlockingGLTextureView(context);
        mTextureView.setRenderer(new TileRenderer());
        view = mTextureView;
    } else {
        mGLSurfaceView = new GLSurfaceView(context);
        mGLSurfaceView.setEGLContextClientVersion(2);
        mGLSurfaceView.setRenderer(new TileRenderer());
        mGLSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
        view = mGLSurfaceView;
    }
    addView(view, new LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    //setTileSource(new ColoredTiles());
}
 
Example 5
SumerianConnector(WebView webView, Session session, GLSurfaceView surfaceView) {
    mWebView = webView;
    mSession = session;
    mSurfaceView = surfaceView;

    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setMediaPlaybackRequiresUserGesture(false);
    mWebView.addJavascriptInterface(new BridgeInterface(), "Android");

    this.mWebView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            view.setBackgroundColor(0x00000000);
        }
    });
}
 
Example 6
Source Project: ml-authentication   Source File: CameraGLSurfaceView.java    License: Apache License 2.0 6 votes vote down vote up
public CameraGLSurfaceView(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
    int cameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
    styledAttrs.recycle();

    if(android.os.Build.VERSION.SDK_INT >= 21)
        mRenderer = new Camera2Renderer(this);
    else
        mRenderer = new CameraRenderer(this);

    setCameraIndex(cameraIndex);

    setEGLContextClientVersion(2);
    setRenderer(mRenderer);
    setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
 
Example 7
Source Project: retroboy   Source File: PreviewActivity.java    License: MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	
	// Force switch to landscape orientation
	setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

	// Check which camera to use
	for (int i = 0, cameras = Camera.getNumberOfCameras(); i < cameras; i++) {
		Camera.CameraInfo info = new Camera.CameraInfo();
		Camera.getCameraInfo(i, info);
		
		if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
			_cameraid = i;
			break;
		}
	}
	
	_surface = new GLSurfaceView(this);
	_surface.setEGLContextClientVersion(2);

	_renderer = new PreviewRenderer(this);
	_surface.setRenderer(_renderer);

	setContentView(_surface);
}
 
Example 8
Source Project: PanoramaGL   Source File: PLTexture.java    License: Apache License 2.0 6 votes vote down vote up
protected void recycleTexture(GL10 gl)
{
	if(gl != null && mTextureId != null && mTextureId[0] != 0)
	{
		if(PLUtils.getAndroidVersion() < 3f)
		{
			gl.glDeleteTextures(1, mTextureId, 0);
			mTextureId[0] = 0;
			mGLWrapper = null;
			mIsValid = false;
		}
		else if(mGLWrapper != null)
		{
			GLSurfaceView glSurfaceView = mGLWrapper.getGLSurfaceView();
			if(glSurfaceView != null)
				glSurfaceView.queueEvent(new PLRecycleTextureRunnable(this));
		}
	}
}
 
Example 9
Source Project: MOAAP   Source File: CameraGLSurfaceView.java    License: MIT License 6 votes vote down vote up
public CameraGLSurfaceView(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
    int cameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
    styledAttrs.recycle();

    if(android.os.Build.VERSION.SDK_INT >= 21)
        mRenderer = new Camera2Renderer(this);
    else
        mRenderer = new CameraRenderer(this);

    setCameraIndex(cameraIndex);

    setEGLContextClientVersion(2);
    setRenderer(mRenderer);
    setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
 
Example 10
Source Project: sudokufx   Source File: CameraGLSurfaceView.java    License: Apache License 2.0 6 votes vote down vote up
public CameraGLSurfaceView(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
    int cameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
    styledAttrs.recycle();

    if(android.os.Build.VERSION.SDK_INT >= 21)
        mRenderer = new Camera2Renderer(this);
    else
        mRenderer = new CameraRenderer(this);

    setCameraIndex(cameraIndex);

    setEGLContextClientVersion(2);
    setRenderer(mRenderer);
    setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
 
Example 11
Source Project: opentok-android-sdk-samples   Source File: MainActivity.java    License: MIT License 6 votes vote down vote up
@Override
public void onConnected(Session session) {
    Log.d(TAG, "onConnected: Connected to session " + session.getSessionId());

    mPublisher = new Publisher.Builder(MainActivity.this)
            .name("publisher")
            .capturer(new CustomVideoCapturer(MainActivity.this, Publisher.CameraCaptureResolution.MEDIUM, Publisher.CameraCaptureFrameRate.FPS_30))
            .renderer(new InvertedColorsVideoRenderer(MainActivity.this)).build();
    mPublisher.setPublisherListener(this);

    mPublisher.setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);
    mPublisherViewContainer.addView(mPublisher.getView());

    if (mPublisher.getView() instanceof GLSurfaceView) {
        ((GLSurfaceView) (mPublisher.getView())).setZOrderOnTop(true);
    }

    mSession.publish(mPublisher);
}
 
Example 12
Source Project: LB-Launcher   Source File: TiledImageView.java    License: Apache License 2.0 6 votes vote down vote up
public TiledImageView(Context context, AttributeSet attrs) {
    super(context, attrs);
    if (!IS_SUPPORTED) {
        return;
    }

    mRenderer = new ImageRendererWrapper();
    mRenderer.image = new TiledImageRenderer(this);
    View view;
    if (USE_TEXTURE_VIEW) {
        mTextureView = new BlockingGLTextureView(context);
        mTextureView.setRenderer(new TileRenderer());
        view = mTextureView;
    } else {
        mGLSurfaceView = new GLSurfaceView(context);
        mGLSurfaceView.setEGLContextClientVersion(2);
        mGLSurfaceView.setRenderer(new TileRenderer());
        mGLSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
        view = mGLSurfaceView;
    }
    addView(view, new LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    //setTileSource(new ColoredTiles());
}
 
Example 13
Source Project: GSYVideoPlayer   Source File: BlackAndWhiteEffect.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public String getShader(GLSurfaceView mGlSurfaceView) {

    String shader = "#extension GL_OES_EGL_image_external : require\n"
            + "precision mediump float;\n"
            + "varying vec2 vTextureCoord;\n"
            + "uniform samplerExternalOES sTexture;\n" + "void main() {\n"
            + "  vec4 color = texture2D(sTexture, vTextureCoord);\n"
            + "  float colorR = (color.r + color.g + color.b) / 3.0;\n"
            + "  float colorG = (color.r + color.g + color.b) / 3.0;\n"
            + "  float colorB = (color.r + color.g + color.b) / 3.0;\n"
            + "  gl_FragColor = vec4(colorR, colorG, colorB, color.a);\n"
            + "}\n";

    return shader;

}
 
Example 14
Source Project: janus-gateway-android   Source File: JanusActivity.java    License: MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    java.lang.System.setProperty("java.net.preferIPv6Addresses", "false");
    java.lang.System.setProperty("java.net.preferIPv4Stack", "true");
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_janus);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

    vsv = (GLSurfaceView) findViewById(R.id.glview);
    vsv.setPreserveEGLContextOnPause(true);
    vsv.setKeepScreenOn(true);
    VideoRendererGui.setView(vsv, new MyInit());

    localRender = VideoRendererGui.create(72, 72, 25, 25, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, false);
    remoteRender = VideoRendererGui.create(0, 0, 25, 25, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, true);
}
 
Example 15
/**
 * Constructs this object.
 * 
 * @param view the current glSurfaceView
 * @param renderer the renderer to wrap
 * @param latch the count down latch
 */

public GLRenderWrapper(GLSurfaceView view,
		Renderer renderer, CountDownLatch latch) {
	this.view = view;
	this.renderer = renderer;
	this.latch = latch;
	
	this.width = view.getWidth();
	this.height = view.getHeight();
	
	Integer out = new Reflect(view).field("mEGLContextClientVersion")
			.out(Integer.class);
	if ( out != null ) {
		this.glVersion = out.intValue();
	} else {
		this.glVersion = -1;
		this.takeScreenshot = false;
	}
}
 
Example 16
Source Project: Android-Example   Source File: CurlView.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Initialize method.
 */
private void init(Context ctx) {
	mRenderer = new CurlRenderer(this);
	setRenderer(mRenderer);
	setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
	setOnTouchListener(this);

	// Even though left and right pages are static we have to allocate room
	// for curl on them too as we are switching meshes. Another way would be
	// to swap texture ids only.
	mPageLeft = new CurlMesh(10);
	mPageRight = new CurlMesh(10);
	mPageCurl = new CurlMesh(10);
	mPageLeft.setFlipTexture(true);
	mPageRight.setFlipTexture(false);
}
 
Example 17
Source Project: panoramagl   Source File: GLWrapper.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * init methods
 */

public GLWrapper(GL gl, GLSurfaceView glSurfaceView) {
    mGL = (GL10) gl;
    if (gl instanceof GL10Ext) {
        mGL10Ext = (GL10Ext) gl;
    }
    if (gl instanceof GL11) {
        mGL11 = (GL11) gl;
    }
    if (gl instanceof GL11Ext) {
        mGL11Ext = (GL11Ext) gl;
    }
    if (gl instanceof GL11ExtensionPack) {
        mGL11ExtPack = (GL11ExtensionPack) gl;
    }
    mGLSurfaceView = glSurfaceView;
}
 
Example 18
public CameraGLSurfaceView(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
    int cameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
    styledAttrs.recycle();

    if(android.os.Build.VERSION.SDK_INT >= 21)
        mRenderer = new Camera2Renderer(this);
    else
        mRenderer = new CameraRenderer(this);

    setCameraIndex(cameraIndex);

    setEGLContextClientVersion(2);
    setRenderer(mRenderer);
    setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
 
Example 19
Source Project: Trebuchet   Source File: TiledImageView.java    License: GNU General Public License v3.0 5 votes vote down vote up
public TiledImageView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mRenderer = new ImageRendererWrapper();
    mRenderer.image = new TiledImageRenderer(this);
    mGLSurfaceView = new GLSurfaceView(context);
    mGLSurfaceView.setEGLContextClientVersion(2);
    mGLSurfaceView.setRenderer(new TileRenderer());
    mGLSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
    addView(mGLSurfaceView, new LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    //setTileSource(new ColoredTiles());
}
 
Example 20
Source Project: panoramagl   Source File: PLView.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * init methods
 */

public PLSurfaceView(Context context, Renderer renderer) {
    super(context);
    this.setRenderer(renderer);
    this.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
 
Example 21
Source Project: remixed-dungeon   Source File: Game.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    iap = new Iap(this);

    try {
        version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
        versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
    } catch (NameNotFoundException e) {
        version = "???";
        versionCode = 0;
    }

    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    view = new GLSurfaceView(this);
    view.setEGLContextClientVersion(2);

    // Hope this allow game work on broader devices list
    // view.setEGLConfigChooser( false );
    view.setRenderer(this);
    view.setOnTouchListener(this);

    layout = new LinearLayout(this);
    getLayout().setOrientation(LinearLayout.VERTICAL);
    getLayout().addView(view);

    setContentView(getLayout());
}
 
Example 22
Source Project: opengl   Source File: MyGLSurfaceView.java    License: Apache License 2.0 5 votes vote down vote up
public MyGLSurfaceView(Context context) {
    super(context);

    // Create an OpenGL ES 2.0 context.
    setEGLContextClientVersion(2);

    // Set the Renderer for drawing on the GLSurfaceView
    mRenderer = new MyGLRenderer();
    setRenderer(mRenderer);

    // Render the view only when there is a change in the drawing data
    setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
 
Example 23
Source Project: ZGDanmaku   Source File: ZGDanmakuView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void start() {
    ZGLog.i("ZGDanmakuView start");
    stop();
    setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
    requestRender();
    mDanmakuController.start();
}
 
Example 24
Source Project: ZGDanmaku   Source File: ZGDanmakuView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void stop() {
    ZGLog.i("ZGDanmakuView stop");
    mDanmakuController.stop();
    setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
    //清屏
    mRenderer.getRendererDanmakuList().clear();
    requestRender();
}
 
Example 25
Source Project: GSYVideoPlayer   Source File: SampleBlurEffect.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public String getShader(GLSurfaceView mGlSurfaceView) {
    String s =
            "#extension GL_OES_EGL_image_external : require\n" +
                    "precision mediump float;\n" +
            "uniform samplerExternalOES sTexture;\n" +
            "varying vec2 vTextureCoord;\n" +
            "const float blurSize = "+ blur + "/800.0;\n" +
            "const float weightSum = 70.0 + 2.0 * (1.0 + 8.0 + 28.0 + 56.0);\n" +
            "\n" +
            "void main(void)\n" +
            "{\n" +
            "   vec4 sum = vec4(0.0);\n" +
            "\n" +
            "   sum += texture2D(sTexture, vec2(vTextureCoord.x - 4.0*blurSize, vTextureCoord.y)) * 1.0 / weightSum;\n" +
            "   sum += texture2D(sTexture, vec2(vTextureCoord.x - 3.0*blurSize, vTextureCoord.y)) * 8.0 / weightSum;\n" +
            "   sum += texture2D(sTexture, vec2(vTextureCoord.x - 2.0*blurSize, vTextureCoord.y)) * 28.0 / weightSum;\n" +
            "   sum += texture2D(sTexture, vec2(vTextureCoord.x - blurSize, vTextureCoord.y)) * 56.0 / weightSum;\n" +
            "   sum += texture2D(sTexture, vec2(vTextureCoord.x, vTextureCoord.y)) * 70.0 / weightSum;\n" +
            "   sum += texture2D(sTexture, vec2(vTextureCoord.x + blurSize, vTextureCoord.y)) * 56.0 / weightSum;\n" +
            "   sum += texture2D(sTexture, vec2(vTextureCoord.x + 2.0*blurSize, vTextureCoord.y)) * 28.0 / weightSum;\n" +
            "   sum += texture2D(sTexture, vec2(vTextureCoord.x + 3.0*blurSize, vTextureCoord.y)) * 8.0 / weightSum;\n" +
            "   sum += texture2D(sTexture, vec2(vTextureCoord.x + 4.0*blurSize, vTextureCoord.y)) * 1.0 / weightSum;\n" +
            "\n" +
            "   gl_FragColor = sum;\n" +
            "}";
    return s;
}
 
Example 26
Source Project: alynx-live-wallpaper   Source File: GLWallpaperService.java    License: Apache License 2.0 5 votes vote down vote up
private void createGLSurfaceView() {
    if (glSurfaceView != null) {
        glSurfaceView.onDestroy();
        glSurfaceView = null;
    }
    glSurfaceView = new GLWallpaperSurfaceView(context);
    final ActivityManager activityManager = (ActivityManager)getSystemService(
        Context.ACTIVITY_SERVICE
    );
    if (activityManager == null) {
        throw new RuntimeException("Cannot get ActivityManager");
    }
    final ConfigurationInfo configInfo = activityManager.getDeviceConfigurationInfo();
    if (configInfo.reqGlEsVersion >= 0x30000) {
        Utils.debug(TAG, "Support GLESv3");
        glSurfaceView.setEGLContextClientVersion(3);
        renderer = new GLES30WallpaperRenderer(context);
    } else if (configInfo.reqGlEsVersion >= 0x20000) {
        Utils.debug(TAG, "Fallback to GLESv2");
        glSurfaceView.setEGLContextClientVersion(2);
        renderer = new GLES20WallpaperRenderer(context);
    } else {
        Toast.makeText(context, R.string.gles_version, Toast.LENGTH_LONG).show();
        throw new RuntimeException("Needs GLESv2 or higher");
    }
    glSurfaceView.setPreserveEGLContextOnPause(true);
    glSurfaceView.setRenderer(renderer);
    // On demand render will lead to black screen.
    glSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
}
 
Example 27
Source Project: UltimateAndroid   Source File: FlipViewController.java    License: Apache License 2.0 5 votes vote down vote up
private void setupSurfaceView(Context context) {
  surfaceView = new GLSurfaceView(getContext());

  cards = new FlipCards(this, flipOrientation == VERTICAL);
  renderer = new FlipRenderer(this, cards);

  surfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
  surfaceView.setZOrderOnTop(true);
  surfaceView.setRenderer(renderer);
  surfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
  surfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);

  addViewInLayout(surfaceView, -1, new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
                                                                LayoutParams.FILL_PARENT), false);
}
 
Example 28
Source Project: Socket.io-FLSocketIM-Android   Source File: VideoChatActivity.java    License: MIT License 5 votes vote down vote up
@Override
protected void initData() {
    super.initData();

    Bundle bundle = getIntent().getExtras();
    String fromUser = bundle.getString("fromUser");
    String toUser = bundle.getString("toUser");
    String room = bundle.getString("room");
    this.fromUser = fromUser;
    this.toUser = toUser;
    this.room = room;
    int type = bundle.getInt("type");
    videoType = type == 0?ChatVideoType.videoTypeCaller:ChatVideoType.videoTypeCallee;
    videoView = new GLSurfaceView(mContext);
    videoView.setPreserveEGLContextOnPause(true);
    videoView.setKeepScreenOn(true);
    VideoRendererGui.setView(videoView, new Runnable() {
        @Override
        public void run() {

            initHelper();
        }
    });
    FrameLayout layout = findViewById(R.id.video_view_back);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    layout.addView(videoView, layoutParams);

    /*
    * 两者初始化顺序会影响最终渲染层的层次结构
    * */
    remoteRender = VideoRendererGui.create(0, 0, 100, 100, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, true);
    localRender = VideoRendererGui.create(66, 0, 33, 33, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, true);

}
 
Example 29
Source Project: MegviiFacepp-Android-SDK   Source File: MediaHelper.java    License: Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param cameraWidth
 * @param cameraHeight
 * @param isLand  横屏
 */
public MediaHelper(int cameraWidth, int cameraHeight, boolean isLand, GLSurfaceView surfaceView){
    if (!isLand) {
        mCameraWidth = cameraWidth;
        mCameraHeight = cameraHeight;
    } else {
        mCameraWidth = cameraHeight;
        mCameraHeight = cameraWidth;
    }
    mSurfaceView=surfaceView;
    Matrix.setIdentityM(mMvpMatrix,0);
    Matrix.rotateM(mMvpMatrix,0,270,0,0,1);
    // TODO: 2017/10/27
}
 
Example 30
Source Project: opentok-react-native   Source File: OTPublisherLayout.java    License: MIT License 5 votes vote down vote up
public void createPublisherView(String publisherId) {

        ConcurrentHashMap<String, Publisher> mPublishers = sharedState.getPublishers();
        ConcurrentHashMap<String, String> androidOnTopMap = sharedState.getAndroidOnTopMap();
        ConcurrentHashMap<String, String> androidZOrderMap = sharedState.getAndroidZOrderMap();
        String pubOrSub = "";
        String zOrder = "";
        Publisher mPublisher = mPublishers.get(publisherId);
        if (mPublisher != null) {
            if (androidOnTopMap.get(mPublisher.getSession().getSessionId()) != null) {
                pubOrSub = androidOnTopMap.get(mPublisher.getSession().getSessionId());
            }
            if (androidZOrderMap.get(mPublisher.getSession().getSessionId()) != null) {
                zOrder = androidZOrderMap.get(mPublisher.getSession().getSessionId());
            }
            mPublisher.setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE,
                    BaseVideoRenderer.STYLE_VIDEO_FILL);
            FrameLayout mPublisherViewContainer = new FrameLayout(getContext());
            if (pubOrSub.equals("publisher") && mPublisher.getView() instanceof GLSurfaceView) {
                if (zOrder.equals("mediaOverlay")) {
                    ((GLSurfaceView) mPublisher.getView()).setZOrderMediaOverlay(true);
                } else {
                    ((GLSurfaceView) mPublisher.getView()).setZOrderOnTop(true);
                }
            }
            ConcurrentHashMap<String, FrameLayout> mPublisherViewContainers = sharedState.getPublisherViewContainers();
            mPublisherViewContainers.put(publisherId, mPublisherViewContainer);
            addView(mPublisherViewContainer, 0);
            mPublisherViewContainer.addView(mPublisher.getView());
            requestLayout();
        }

    }