Plus log first few decoder frames in and out events.
BUG=b/25287910
Review URL: https://codereview.webrtc.org/1423843005
Cr-Commit-Position: refs/heads/master@{#10439}
I replaced quitSafely() with a CountDownLatch. The reason for not using ThreadUtils.invokeUninterruptibly() is that I want to stop accepting frames asap, and invokeUninterruptibly() would still accept frames during the waiting time.
BUG=webrtc:4742
Review URL: https://codereview.webrtc.org/1418223002
Cr-Commit-Position: refs/heads/master@{#10393}
The purpose with this change is to support older API levels by replacing EGL14 (API lvl 17) with EGL10 (API lvl 1). The main purpose is to lower API lvl requirement for SurfaceViewRenderer from API lvl 17 to API lvl 15. Also, camera texture capture will work on API lvl < 17 (and texture encode/decode in MediaCodec, but we don't use MediaCodec below API lvl 18?).
GLSurfaceView/VideoRendererGui is already using EGL10.
EGL 1.1 - 1.4 added new functionality, but won't affect performance. We don't need the functionality, so there should be no reason to not use EGL 1.0.
I have profiled AppRTCDemo with Qualcomm Trepn Profiler on a Nexus 5 and Nexus 6 and couldn't see any difference.
Specifically, this CL:
* Update EglBase to use EGL10 instead of EGL14.
* Update imports from EGL14 to EGL10 in a lot of files (plus changing import order in some cases).
* Update VideoCapturerAndroid to always support texture capture.
Review URL: https://codereview.webrtc.org/1396013004
Cr-Commit-Position: refs/heads/master@{#10378}
Add events to track when camera is requested to open,
when first camera frame is available and when camera is
closed.
BUG=b/24271359
R=perkj@webrtc.org
Review URL: https://codereview.webrtc.org/1398793005 .
Cr-Commit-Position: refs/heads/master@{#10306}
This reverts commit 90754174d98d6b71fd4aaed897bd54980f7e59c4.
Revert "Fix use of scaler in MediaCodecVideoEncoder"
This reverts commit ec93628e75fdb81f23635b39b5f3da846bcefd21.
R=magjed@webrtc.orgTBR=glaznev@webrtc.org
BUG=webrtc:4993 b/24984012
Review URL: https://codereview.webrtc.org/1407263002 .
Cr-Commit-Position: refs/heads/master@{#10300}
The code that depends on the reverted CL is disabled but not removed. NativeHandleImpl is reverted to the previous implementation, and the new implementation is renamed to NativeTextureHandleImpl. Texture capture can not be used anymore, because it will crash in peerconnection_jni.cc.
Reason for revert:
Increased HW decoder latency and crashes related to that. Also suspected cause of video tearing.
Original issue's description:
> This CL should be the last one in a series to finally
> unblock camera texture capture.
>
> The SurfaceTexture.updateTexImage() calls are moved from
> the video renderers into MediaCodecVideoDecoder, and the
> destructor of the texture frames will signal
> MediaCodecVideoDecoder that the frame has returned. This
> CL also removes the SurfaceTexture from the native handle
> and only exposes the texture matrix instead, because only
> the video source should access the SurfaceTexture.
>
> BUG=webrtc:4993
> R=glaznev@webrtc.org, perkj@webrtc.org
>
> Committed: https://crrev.com/91b348c7029d843e06868ed12b728a809c53176c
> Cr-Commit-Position: refs/heads/master@{#10203}
TBR=glaznev
BUG=webrtc:4993
Review URL: https://codereview.webrtc.org/1394103005
Cr-Commit-Position: refs/heads/master@{#10288}
This CL should reduce the number of timeouts for dequeueInputBuffer() which results in the log "MediaCodecVideo: dequeueInputBuffer error" followed by software fallback for VP8/VP9 and codec restart for H264.
A timeout always happen for dequeueInputBuffer() when frames_received_ > frames_decoded_ + num_input_buffers. The following code tries to drain the decoder before enqueuing more input buffers:
// Try to drain the decoder and wait until output is not too
// much behind the input.
if (frames_received_ > frames_decoded_ + max_pending_frames_) {
ALOGV("Received: %d. Decoded: %d. Wait for output...",
frames_received_, frames_decoded_);
if (!DeliverPendingOutputs(jni, kMediaCodecTimeoutMs,
true /* dropFrames */)) {
ALOGE << "DeliverPendingOutputs error";
return ProcessHWErrorOnCodecThread();
}
if (frames_received_ > frames_decoded_ + max_pending_frames_) {
ALOGE << "Output buffer dequeue timeout";
return ProcessHWErrorOnCodecThread();
}
...
}
However, for H264, |max_pending_frames_| can currently be larger than the number of input buffers so that the code above is never executed. This CL limits |max_pending_frames_| to the number of input buffers.
TBR=glaznev
BUG=b/24867188,b/24864151
Review URL: https://codereview.webrtc.org/1394303005
Cr-Commit-Position: refs/heads/master@{#10273}
SurfaceViewHelper requires EGL14 that was added in API level 17. Since the SurfaceViewHelper is only neeed when we capture to textures, this cl change back to not use it when we are capturing to byte buffers.
Also, thread.quitsafely was added in level 18. Instead a new ThreadUtil method has been added for this.
BUG=b/24782220
TEST = run
ninja -C out/Debug libjingle_peerconnection_android_unittest && CHECKOUT_SOURCE_ROOT=`pwd` build/android/adb_install_apk.py --debug out/Debug/apks/libjingle_peerconnection_android_unittest.apk && ./third_party/android_tools/sdk/platform-tools/adb shell am instrument -w -e class org.webrtc.VideoCapturerAndroidTest org.webrtc.test/android.test.InstrumentationTestRunner on a device running Android 4.1 (I tried Nexus 7, the first version)
Review URL: https://codereview.webrtc.org/1401023003
Cr-Commit-Position: refs/heads/master@{#10265}
This make small refactorings to MediaVideoEncoder to prepare for adding support to encode from textures. The C++ layer does not have any functional changes.
- Moves ResetEncoder to always work on the codec thread
- Adds use of ThreadChecker.
- Change Java MediaEncoder.Init to return true or false and introduce method getInputBuffers.
- Add simple unit test for Java MediaCodecVideoEncoder.
BUG=webrtc:4993
Review URL: https://codereview.webrtc.org/1396073003
Cr-Commit-Position: refs/heads/master@{#10250}
This CL is a small bug fix for "Android SurfaceViewRenderer: Allow to re-init after release() has been called" https://codereview.webrtc.org/1389203003/. It is only possible to clear the last image in release() if init() has been called beforehand.
TBR=hbos
BUG=webrtc:4742
Review URL: https://codereview.webrtc.org/1396573003 .
Cr-Commit-Position: refs/heads/master@{#10223}
These are the necessary changes in C++ related to the video capturer necessary to capture to a surface texture.
It does not handle scaling / cropping yet though.
BUG=
R=magjed@webrtc.org
Review URL: https://codereview.webrtc.org/1395673003 .
Cr-Commit-Position: refs/heads/master@{#10218}
This CL makes a thorough reset of all variables in release() and clears the last rendered image so that the SurfaceViewRenderer object can be reinitialized with init() and work properly. This CL also removes an implicit assumption that init() is called before surfaceCreated() - now they can be called in any order.
BUG=webrtc:4742
R=hbos@webrtc.org
Review URL: https://codereview.webrtc.org/1389203003 .
Cr-Commit-Position: refs/heads/master@{#10217}
This adds support for capturing to a texture in the Java part of VideoCapturerAndroid.
After this cl, the C++ also needs modification.
https://codereview.webrtc.org/1375953002/ contains the idea and have a working version where textures can be rendered in local preview.
BUG=webrtc:4993
R=magjed@webrtc.org
Review URL: https://codereview.webrtc.org/1383413002 .
Cr-Commit-Position: refs/heads/master@{#10213}
This CL should be the last one in a series to finally unblock camera texture capture.
The SurfaceTexture.updateTexImage() calls are moved from the video renderers into MediaCodecVideoDecoder, and the destructor of the texture frames will signal MediaCodecVideoDecoder that the frame has returned. This CL also removes the SurfaceTexture from the native handle and only exposes the texture matrix instead, because only the video source should access the SurfaceTexture.
BUG=webrtc:4993
R=glaznev@webrtc.org, perkj@webrtc.org
Review URL: https://codereview.webrtc.org/1378033003 .
Cr-Commit-Position: refs/heads/master@{#10203}
The Java PeerConnection maintains a cached list of Java RtpSenders
and RtpReceivers so that the same objects are returned every time
getSenders() or getReceivers() is called. They are disposed of when
PeerConnection.dispose() is called, which will also dispose their
referenced MediaStreamTracks.
Review URL: https://codereview.webrtc.org/1368143002
Cr-Commit-Position: refs/heads/master@{#10189}
This allows to correctly report first frame event in applications which
use same remote video renderer for multiple calls.
R=wzh@webrtc.org
Review URL: https://codereview.webrtc.org/1384353002 .
Cr-Commit-Position: refs/heads/master@{#10176}
Fixed a problem where eglBase.makecurrent() could be called after the context had been released if SurfaceTextureHelper was first created and immedately disconnected.
Add the possibility to inject a thread to use instead of creating a new.
BUG= webrtc:4993
R=magjed@webrtc.org
Review URL: https://codereview.webrtc.org/1384923002 .
Cr-Commit-Position: refs/heads/master@{#10174}
This CL shouldn't make any functional changes. It adds a new VideoCapturerAndroid.nativeCreateVideoCapturer() instead of always using VideoCapturer.nativeCreateVideoCapturer(). The purpose is to simplify androidvideocapturer_jni and VideoCapturerAndroid.create(). This way, it is possible to use the ctor instead of VideoCapturerAndroid.init() to initialize variables, and they can be made final etc.
R=perkj@webrtc.org
Review URL: https://codereview.webrtc.org/1360173002 .
Cr-Commit-Position: refs/heads/master@{#10171}
VideoRendererGui may need to render incoming frames multiple times. We currently call VideoRenderer.renderFrameDone() while we still hold references to the OES texture. This CL makes a deep copy of the OES texture before calling renderFrameDone(). This will truly release the dependency to the incoming frame, so that video textures sources can rely on the renderFrameDone() callback.
This CL is a part of the plan in https://codereview.webrtc.org/1357923002/.
The texture copy doesn't cause any measurable performance difference on a Nexus 5 using VideoRendererGui in a AppRTCDemo loopback call.
BUG=webrtc:4993
TEST=Revert "Enable SurfaceViewRenderer for AppRTCDemo" https://codereview.webrtc.org/1356603004/ and try AppRTCDemo.
R=perkj@webrtc.org
Review URL: https://codereview.webrtc.org/1370113005 .
Cr-Commit-Position: refs/heads/master@{#10157}
This CL separates the types and code paths for textures vs byte buffers in MediaCodecVideoDecoder.dequeueOutputBuffer() and MediaCodecVideoDecoder::DeliverPendingOutputs(). The purpose is to prepare for lifetime management of textures received from the SurfaceTexture.
This CL is a part of the plan in https://codereview.webrtc.org/1357923002/.
BUG=webrtc:4993
Review URL: https://codereview.webrtc.org/1379383002
Cr-Commit-Position: refs/heads/master@{#10156}
This CL should not change the behaviour of the decoder. The purpose is to prepare for lifetime management of textures received from the SurfaceTexture. The main change is to only use exceptions for error signaling in MediaCodecVideoDecoder.dequeueOutputBuffer() and MediaCodecVideoDecoder.releaseOutputBuffer(), not both exceptions and error return values.
BUG=webrtc:4993
R=perkj@webrtc.org
Review URL: https://codereview.webrtc.org/1383983003 .
Cr-Commit-Position: refs/heads/master@{#10148}