Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java

Issue 1523843006: MediaCodecVideoEncoder, set timestamp on the encoder surface when drawing a texture. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed comments. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 20 matching lines...) Expand all
31 import java.util.concurrent.CountDownLatch; 31 import java.util.concurrent.CountDownLatch;
32 32
33 import javax.microedition.khronos.egl.EGLConfig; 33 import javax.microedition.khronos.egl.EGLConfig;
34 import javax.microedition.khronos.egl.EGL10; 34 import javax.microedition.khronos.egl.EGL10;
35 import javax.microedition.khronos.egl.EGLContext; 35 import javax.microedition.khronos.egl.EGLContext;
36 import javax.microedition.khronos.opengles.GL10; 36 import javax.microedition.khronos.opengles.GL10;
37 37
38 import android.annotation.SuppressLint; 38 import android.annotation.SuppressLint;
39 import android.graphics.Point; 39 import android.graphics.Point;
40 import android.graphics.Rect; 40 import android.graphics.Rect;
41 import android.opengl.EGL14;
41 import android.opengl.GLES20; 42 import android.opengl.GLES20;
42 import android.opengl.GLSurfaceView; 43 import android.opengl.GLSurfaceView;
43 44
44 import org.webrtc.Logging; 45 import org.webrtc.Logging;
45 import org.webrtc.VideoRenderer.I420Frame; 46 import org.webrtc.VideoRenderer.I420Frame;
46 47
47 /** 48 /**
48 * Efficiently renders YUV frames using the GPU for CSC. 49 * Efficiently renders YUV frames using the GPU for CSC.
49 * Clients will want first to call setView() to pass GLSurfaceView 50 * Clients will want first to call setView() to pass GLSurfaceView
50 * and then for each video stream either create instance of VideoRenderer using 51 * and then for each video stream either create instance of VideoRenderer using
51 * createGui() call or VideoRenderer.Callbacks interface using create() call. 52 * createGui() call or VideoRenderer.Callbacks interface using create() call.
52 * Only one instance of the class can be created. 53 * Only one instance of the class can be created.
53 */ 54 */
54 public class VideoRendererGui implements GLSurfaceView.Renderer { 55 public class VideoRendererGui implements GLSurfaceView.Renderer {
55 // |instance|, |instance.surface|, |eglContext|, and |eglContextReady| are syn chronized on 56 // |instance|, |instance.surface|, |eglContext|, and |eglContextReady| are syn chronized on
56 // |VideoRendererGui.class|. 57 // |VideoRendererGui.class|.
57 private static VideoRendererGui instance = null; 58 private static VideoRendererGui instance = null;
58 private static Runnable eglContextReady = null; 59 private static Runnable eglContextReady = null;
59 private static final String TAG = "VideoRendererGui"; 60 private static final String TAG = "VideoRendererGui";
60 private GLSurfaceView surface; 61 private GLSurfaceView surface;
61 private static EGLContext eglContext = null; 62 private static EglBase.Context eglContext = null;
62 // Indicates if SurfaceView.Renderer.onSurfaceCreated was called. 63 // Indicates if SurfaceView.Renderer.onSurfaceCreated was called.
63 // If true then for every newly created yuv image renderer createTexture() 64 // If true then for every newly created yuv image renderer createTexture()
64 // should be called. The variable is accessed on multiple threads and 65 // should be called. The variable is accessed on multiple threads and
65 // all accesses are synchronized on yuvImageRenderers' object lock. 66 // all accesses are synchronized on yuvImageRenderers' object lock.
66 private boolean onSurfaceCreatedCalled; 67 private boolean onSurfaceCreatedCalled;
67 private int screenWidth; 68 private int screenWidth;
68 private int screenHeight; 69 private int screenHeight;
69 // List of yuv renderers. 70 // List of yuv renderers.
70 private final ArrayList<YuvImageRenderer> yuvImageRenderers; 71 private final ArrayList<YuvImageRenderer> yuvImageRenderers;
71 // Render and draw threads. 72 // Render and draw threads.
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 412
412 /** Passes GLSurfaceView to video renderer. */ 413 /** Passes GLSurfaceView to video renderer. */
413 public static synchronized void setView(GLSurfaceView surface, 414 public static synchronized void setView(GLSurfaceView surface,
414 Runnable eglContextReadyCallback) { 415 Runnable eglContextReadyCallback) {
415 Logging.d(TAG, "VideoRendererGui.setView"); 416 Logging.d(TAG, "VideoRendererGui.setView");
416 instance = new VideoRendererGui(surface); 417 instance = new VideoRendererGui(surface);
417 eglContextReady = eglContextReadyCallback; 418 eglContextReady = eglContextReadyCallback;
418 } 419 }
419 420
420 public static synchronized EglBase.Context getEglBaseContext() { 421 public static synchronized EglBase.Context getEglBaseContext() {
421 return new EglBase10.Context(eglContext); 422 return eglContext;
422 } 423 }
423 424
424 /** Releases GLSurfaceView video renderer. */ 425 /** Releases GLSurfaceView video renderer. */
425 public static synchronized void dispose() { 426 public static synchronized void dispose() {
426 if (instance == null){ 427 if (instance == null){
427 return; 428 return;
428 } 429 }
429 Logging.d(TAG, "VideoRendererGui.dispose"); 430 Logging.d(TAG, "VideoRendererGui.dispose");
430 synchronized (instance.yuvImageRenderers) { 431 synchronized (instance.yuvImageRenderers) {
431 for (YuvImageRenderer yuvImageRenderer : instance.yuvImageRenderers) { 432 for (YuvImageRenderer yuvImageRenderer : instance.yuvImageRenderers) {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 printStackTrace(renderFrameThread, "Render frame thread"); 601 printStackTrace(renderFrameThread, "Render frame thread");
601 printStackTrace(drawThread, "Draw thread"); 602 printStackTrace(drawThread, "Draw thread");
602 } 603 }
603 604
604 @SuppressLint("NewApi") 605 @SuppressLint("NewApi")
605 @Override 606 @Override
606 public void onSurfaceCreated(GL10 unused, EGLConfig config) { 607 public void onSurfaceCreated(GL10 unused, EGLConfig config) {
607 Logging.d(TAG, "VideoRendererGui.onSurfaceCreated"); 608 Logging.d(TAG, "VideoRendererGui.onSurfaceCreated");
608 // Store render EGL context. 609 // Store render EGL context.
609 synchronized (VideoRendererGui.class) { 610 synchronized (VideoRendererGui.class) {
610 eglContext = ((EGL10) EGLContext.getEGL()).eglGetCurrentContext(); 611 if (EglBase14.isEGL14Supported()) {
612 eglContext = new EglBase14.Context(EGL14.eglGetCurrentContext());
613 } else {
614 eglContext = new EglBase10.Context(((EGL10) EGLContext.getEGL()).eglGetC urrentContext());
615 }
616
611 Logging.d(TAG, "VideoRendererGui EGL Context: " + eglContext); 617 Logging.d(TAG, "VideoRendererGui EGL Context: " + eglContext);
612 } 618 }
613 619
614 synchronized (yuvImageRenderers) { 620 synchronized (yuvImageRenderers) {
615 // Create textures for all images. 621 // Create textures for all images.
616 for (YuvImageRenderer yuvImageRenderer : yuvImageRenderers) { 622 for (YuvImageRenderer yuvImageRenderer : yuvImageRenderers) {
617 yuvImageRenderer.createTextures(); 623 yuvImageRenderer.createTextures();
618 } 624 }
619 onSurfaceCreatedCalled = true; 625 onSurfaceCreatedCalled = true;
620 } 626 }
(...skipping 30 matching lines...) Expand all
651 GLES20.glViewport(0, 0, screenWidth, screenHeight); 657 GLES20.glViewport(0, 0, screenWidth, screenHeight);
652 GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); 658 GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
653 synchronized (yuvImageRenderers) { 659 synchronized (yuvImageRenderers) {
654 for (YuvImageRenderer yuvImageRenderer : yuvImageRenderers) { 660 for (YuvImageRenderer yuvImageRenderer : yuvImageRenderers) {
655 yuvImageRenderer.draw(); 661 yuvImageRenderer.draw();
656 } 662 }
657 } 663 }
658 } 664 }
659 665
660 } 666 }
OLDNEW
« no previous file with comments | « talk/app/webrtc/java/android/org/webrtc/EglBase14.java ('k') | talk/app/webrtc/java/jni/androidmediaencoder_jni.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698