353 Commits

Author SHA1 Message Date
nisse
03f80ebb83 Refactor EglBase configuration.
Delete EglBase.ConfigType, instead pass arrays of attributes, and define
constant arrays for the common cases.

Both in progress NativeToI420 and extending GlRectDrawer to other shapes (with alpha) needs this.

BUG=b/25694445

Review URL: https://codereview.webrtc.org/1498003002

Cr-Commit-Position: refs/heads/master@{#10908}
2015-12-07 09:17:22 +00:00
Honghai Zhang
381b4217cb Ping backup connection at a slower rate
and make it configurable from the app.
Changed the decision on whether a connection is pingable:
1.Check whether a connection is a backup connection. A connection is considered as a backup connection only if the channel is complete, the connection is active and it is not the best connection.
2. Ping a non-backup connection if it is active and for backup connection, ping it at a slower rate.
Note the default behavior is the same as before.

Also cached the channel state since we are accessing it more often.
BUG=webrtc:5034
R=pthatcher@webrtc.org

Review URL: https://codereview.webrtc.org/1455033004 .

Cr-Commit-Position: refs/heads/master@{#10900}
2015-12-04 20:24:10 +00:00
honghaiz
9462052f32 In some rare Android systems ConnectivityManager may be null.
Handle this case more gracefully.

BUG=

Review URL: https://codereview.webrtc.org/1490403002

Cr-Commit-Position: refs/heads/master@{#10875}
2015-12-02 22:33:26 +00:00
deadbeef
ee524f7c02 Adding Java binding for CreateSender.
Review URL: https://codereview.webrtc.org/1486243002

Cr-Commit-Position: refs/heads/master@{#10871}
2015-12-02 19:27:47 +00:00
perkj
d20d247166 Fix VideoCaptureAndroid, drop frame when switching camera using textures.
Dropping the first frame intended to fix a problem when switching cameras on N6 when we are capturing to textures but due to a silly bug fixed in this cl the frame was not dropped...

BUG=webrtc:5262
TBR=magjed@webrtc.org

Review URL: https://codereview.webrtc.org/1489363002

Cr-Commit-Position: refs/heads/master@{#10867}
2015-12-02 12:25:32 +00:00
perkj
226a602ad6 Fix problem when drawing to the Android Media encoder surface.
Problem seen on N6.
BUG=webrtc:5147

TBR=magjed@webrtc.org

Review URL: https://codereview.webrtc.org/1491623003

Cr-Commit-Position: refs/heads/master@{#10866}
2015-12-02 10:24:46 +00:00
perkj
40455d6f37 This cl change so that we use EGL14 where it is supported and EGL10 otherwise. The idea is to make this agnostic to an application and for WebRTC except in EGLBase.
The reason we want to use EGL14 is to be able to use EGLExt.eglPresentationTimeANDROID when writing textures to MediaEncoder.

BUG=webrtc:4993
TBR=glaznew@webrtc.org

Review URL: https://codereview.webrtc.org/1461083002

Cr-Commit-Position: refs/heads/master@{#10864}
2015-12-02 09:07:22 +00:00
perkj
14f4144a82 Add helper KeepRefUntilDone.
The callback keeps a reference to an object until the callback goes out of scope.

Review URL: https://codereview.webrtc.org/1487493002

Cr-Commit-Position: refs/heads/master@{#10847}
2015-12-01 06:15:53 +00:00
glaznev
ee69ed505b Add separate event for camera freeze.
Review URL: https://codereview.webrtc.org/1479523003

Cr-Commit-Position: refs/heads/master@{#10846}
2015-11-30 23:26:44 +00:00
magjed
ae54b835ea Android SurfaceViewRenderer: Add resetStatistics() method
Review URL: https://codereview.webrtc.org/1472323003

Cr-Commit-Position: refs/heads/master@{#10833}
2015-11-28 11:15:04 +00:00
Per
727dbc2968 VideoCapturerAndroid - allow lower frame rate in bad lightning
Insted of using a fixed frame rate, we allow the camera to use a lower frame rate. The camera will choose depending on lightning condition.

TESTED= In a room with low light on N5, N6 N7, Galaxy 4.
BUG=webrtc:5262
R=magjed@webrtc.org

Review URL: https://codereview.webrtc.org/1479563004 .

Cr-Commit-Position: refs/heads/master@{#10807}
2015-11-26 14:15:51 +00:00
Per
598242a583 Support texture scaling in Androids MediaEncoder.
This cl make it possible for the hw video encoder to downscale a texture image before encoding. The purpose is to allow downscaling if the quality is too bad at the current resolution.
BUG=webrtc:4993
R=magjed@webrtc.org, pbos@webrtc.org

Review URL: https://codereview.webrtc.org/1470043002 .

Cr-Commit-Position: refs/heads/master@{#10804}
2015-11-26 13:29:06 +00:00
Per
a3c20bb9a0 Add support for scaling textures in AndroidVideoCapturer.
The idea is to also reuse AndroidTextureBuffer::CropAndScale when scaling in the encoder.

BUG=webrtc:4993
R=magjed@webrtc.org

Review URL: https://codereview.webrtc.org/1471333003 .

Cr-Commit-Position: refs/heads/master@{#10802}
2015-11-26 12:41:52 +00:00
ivoc
b2514725a9 Add JNI interface for functions to start and stop recording AEC dumps and RTC event logs.
BUG=webrtc:4741

Review URL: https://codereview.webrtc.org/1409323009

Cr-Commit-Position: refs/heads/master@{#10776}
2015-11-24 17:00:39 +00:00
Magnus Jedvert
4c5eea3c73 Android SurfaceViewRenderer: Don't rely on widthSpec/heightSpec after onMeasure() returns
SurfaceViewRenderer currently stores widthSpec/heightSpec internally, and triggers requestLayout() from renderFrameOnRenderThread()->checkConsistentLayout() when it detects a change using widthSpec/heightSpec. This is not reliable, because onMeasure() might be called several times during the layout process negotiation. For example it might look like this:
-> onMeasure(at most 1920, at most 1080)
<- setMeasuredDimension(1080, 1080)
-> onMeasure(exactly 1080, exactly 1080)
<- setMeasuredDimension(1080, 1080)
Then we store (exactly 1080, exactly 1080) even though we are allowed to be bigger than this, and requestLayout() will never be triggered.

This CL moves the requestLayout() trigger to updateFrameDimensionsAndReportEvents() when the frame size changes.

Other small changes in this CL are:
* Replace with/height variables with Point.
* Add logging in updateFrameDimensionsAndReportEvents() even when rendererEvents is null.
* Use Math.round() in RendererCommon.getDisplaySize() instead of integer cast.

R=hbos@webrtc.org

Review URL: https://codereview.webrtc.org/1453413005 .

Cr-Commit-Position: refs/heads/master@{#10774}
2015-11-24 16:45:32 +00:00
perkj
7baf79fb9e Temporary remove spamming MediaDecoder log
This log will write for each decoded frame if the textures are rendered using VideoRenderGUI
and the the screen is locked.

TBR=glaznew@webrtc.org

Review URL: https://codereview.webrtc.org/1465093004

Cr-Commit-Position: refs/heads/master@{#10771}
2015-11-24 14:26:46 +00:00
Magnus Jedvert
4f2152e328 Android SurfaceViewRenderer: Make sure not to call eglCreateSurface() twice
eglCreateSurface() calls are posted to the render thread from both init() and surfaceCreated(). If the render thread does not process the eglCreateSurface() message from init() before surfaceCreated() is called, eglCreateSurface() will be called twice resulting in a crash.

This CL makes sure eglCreateSurface() is only called once.

BUG=b/25815604
R=hbos@webrtc.org

Review URL: https://codereview.webrtc.org/1466133002 .

Cr-Commit-Position: refs/heads/master@{#10769}
2015-11-24 12:54:36 +00:00
perkj
9237559b16 Add SurfaceTextureHelper.disconnect(Handler handler) method
This method should be used when the SurfaceTextureHelper is created to use a specific handler.
This now guarantee that the looper used by handler is destroyed after a frame has been returned.

Review URL: https://codereview.webrtc.org/1465163003

Cr-Commit-Position: refs/heads/master@{#10767}
2015-11-24 11:03:19 +00:00
Magnus Jedvert
1aa6efe885 Android ThreadUtils: Make the class public for access outside org.webrtc
Also make the class non-final. We shouldn't use non-final classes, because then we can't mock them.

R=henrika@webrtc.org

Review URL: https://codereview.webrtc.org/1470973002 .

Cr-Commit-Position: refs/heads/master@{#10757}
2015-11-23 19:13:36 +00:00
perkj
87d584597c Fix androidmediadecoder_jni TS logging.
And fix pragma warning about deprecated "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h include.

Review URL: https://codereview.webrtc.org/1461273002

Cr-Commit-Position: refs/heads/master@{#10744}
2015-11-23 09:46:32 +00:00
perkj
30e918278c This cl add support to encode from textures to MediaCodecVideoEncoder.
This has also partly been reviewed in https://codereview.webrtc.org/1375953002/.

BUG=webrtc:4993
TBR=glaznew@webrtc.org

Review URL: https://codereview.webrtc.org/1403713002

Cr-Commit-Position: refs/heads/master@{#10725}
2015-11-20 09:31:32 +00:00
Alex Glaznev
17c0aff9ea Enable VP9 HW decoder on Exynos chips.
R=wzh@webrtc.org

Review URL: https://codereview.webrtc.org/1466543002 .

Cr-Commit-Position: refs/heads/master@{#10720}
2015-11-19 23:56:24 +00:00
Magnus Jedvert
ef453238aa Android: Make classes non-final
The classes are not mockable if they are final.

R=phoglund@webrtc.org

Review URL: https://codereview.webrtc.org/1459873002 .

Cr-Commit-Position: refs/heads/master@{#10714}
2015-11-19 16:54:16 +00:00
henrika
b6755ab6df Revert of Adding thread timeout for audio recorer thread in Java (patchset #2 id:20001 of https://codereview.webrtc.org/1444313002/ )
Reason for revert:
Reverting since this fix might hide real issue and the reported root problem seems extremely rare.

Original issue's description:
> Adding thread timeout for audio recorer thread in Java
>
> BUG=NONE
>
> Committed: https://crrev.com/fd614c2149c7985bd83df809df71d0d60e5a8f74
> Cr-Commit-Position: refs/heads/master@{#10671}

TBR=magjed@webrtc.org,tommi@webrtc.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=NONE

Review URL: https://codereview.webrtc.org/1459123002

Cr-Commit-Position: refs/heads/master@{#10707}
2015-11-19 10:43:19 +00:00
Per
488e75f11b Patchset 1 yet again relands without modification https://codereview.webrtc.org/1422963003/
It do the following:

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.
It moves the responsibility of calculating the decode time to Java.

Patchset2 Refactor MediaCodecVideoDecoder to drop frames if a texture is not released.

R=magjed@webrtc.org

Review URL: https://codereview.webrtc.org/1440343002 .

Cr-Commit-Position: refs/heads/master@{#10706}
2015-11-19 09:43:46 +00:00
kjellander@webrtc.org
b7ce96470b modules/video_coding/utility: Remove include
This makes it clearer this code not meant to be used as an API.
I could not find any use of this in downstream code.

BUG=webrtc:5095
TESTED=git cl try -c --bot=android_compile_rel --bot=linux_compile_rel --bot=win_compile_rel --bot=mac_compile_rel --bot=ios_rel --bot=linux_gn_rel --bot=win_x64_gn_rel --bot=mac_x64_gn_rel --bot=android_gn_rel -m tryserver.webrtc
R=stefan@webrtc.org
TBR=magjed@webrtc.org

Review URL: https://codereview.webrtc.org/1440873005 .

Cr-Commit-Position: refs/heads/master@{#10699}
2015-11-18 22:04:20 +00:00
Alex Glaznev
ad948c42a1 Preliminary support of VP9 HW encoder on Android.
Not fully tested yet. Verified in test loopback application
with fake VP9 codec factory.
Assume that encoder generates bitstream in non flexible mode with
one temporal and one spatial layers.

R=magjed@webrtc.org

Review URL: https://codereview.webrtc.org/1451953002 .

Cr-Commit-Position: refs/heads/master@{#10695}
2015-11-18 21:06:51 +00:00
henrika
fd614c2149 Adding thread timeout for audio recorer thread in Java
BUG=NONE

Review URL: https://codereview.webrtc.org/1444313002

Cr-Commit-Position: refs/heads/master@{#10671}
2015-11-17 12:28:33 +00:00
kjellander
6f8ce060a2 common_video: rename interface -> include
To avoid breaking downstream, the "interface" directories were copied
into a new "common_video/include" dir. The old headers got pragma
warnings added about deprecation (a very short deprecation since I plan
to remove them as soon downstream is updated).
The header guards are also identical to avoid mixing them up in the transition.

BUG=webrtc:5095
TESTED=Passing compile-trybots with --clobber flag:
git cl try --clobber --bot=win_compile_rel --bot=linux_compile_rel --bot=android_compile_rel --bot=mac_compile_rel --bot=ios_rel --bot=linux_gn_rel --bot=win_x64_gn_rel --bot=mac_x64_gn_rel --bot=android_gn_rel -m tryserver.webrtc

Review URL: https://codereview.webrtc.org/1418913006

Cr-Commit-Position: refs/heads/master@{#10659}
2015-11-16 21:52:31 +00:00
magjed
633a3aa26f ThreadUtils: Add joinUninterruptibly() with timeout
This is similar to com.google.common.util.concurrent.Uninterruptibles.joinUninterruptibly().
http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/util/concurrent/Uninterruptibles.html#joinUninterruptibly(java.lang.Thread,%20long,%20java.util.concurrent.TimeUnit)

Review URL: https://codereview.webrtc.org/1444273002

Cr-Commit-Position: refs/heads/master@{#10651}
2015-11-16 13:12:36 +00:00
magjed
3e0f602055 Android EglBase: Add support for creating EGLSurface from Surface, not SurfaceHolder
Review URL: https://codereview.webrtc.org/1438223003

Cr-Commit-Position: refs/heads/master@{#10646}
2015-11-16 10:04:57 +00:00
magjed
4a41361f98 Android SurfaceViewRenderer: Never hold a pending frame indefinitely
The original purpose with keeping one pending frame in SurfaceViewRenderer was to reduce latency for the first rendered frame when we are waiting for the Surface to be created. However, it is very dangerous to hold a pending frame indefinitely when used with a SurfaceTexture, because the SurfaceTexture only has one frame and thus holding a frame in the renderer will freeze everything and typically cause timeout crashes.

Review URL: https://codereview.webrtc.org/1435413006

Cr-Commit-Position: refs/heads/master@{#10638}
2015-11-13 16:48:06 +00:00
Per
c01c25434b Revert of Android MediaCodecVideoDecoder: Manage lifetime of texture frames (patchset #12 id:320001 of https://codereview.webrtc.org/1422963003/ )
Reason for revert:
Causes fallback to SW decoder if a renderer is put in the background.

Original issue's description:
> Patchset 1 is a pure
> revert of "Revert of "Android MediaCodecVideoDecoder: Manage lifetime of texture frames" https://codereview.webrtc.org/1378033003/
>
> Following patchsets move the responsibility of calculating the decode time to Java.
>
> TESTED= Apprtc loopback using H264 and VP8 on N5, N6, N7, S5
>
> Committed: https://crrev.com/9cb8982e64f08d3d630bf7c3d2bcc78c10db88e2
> Cr-Commit-Position: refs/heads/master@{#10597}

TBR=magjed@webrtc.org,glaznev@webrtc.org
NOPRESUBMIT=true
NOTREECHECKS=true

Review URL: https://codereview.webrtc.org/1441363002 .

Cr-Commit-Position: refs/heads/master@{#10637}
2015-11-13 15:58:37 +00:00
Patrik Höglund
68876f990e Introduces Android API level linting, fixes all current API lint errors.
This CL attempts to annotate accesses on >16 API levels using as
small scopes as possible. The TargetApi notations mean "yes, I know
I'm accessing a higher API and I take responsibility for gating the
call on Android API level". The Encoder/Decoder classes are annotated
on the whole class, but they're only accessed through JNI; we should
annotate on method level otherwise and preferably on private methods.

This patch also fixes some compiler-level deprecation warnings (i.e.
-Xlint:deprecation), but probably not all of them.

BUG=webrtc:5063
R=henrika@webrtc.org, kjellander@webrtc.org, magjed@webrtc.org

Review URL: https://codereview.webrtc.org/1412673008 .

Cr-Commit-Position: refs/heads/master@{#10624}
2015-11-12 16:37:01 +00:00
perkj
9576e54836 Reland "Prepare MediaCodecVideoEncoder for surface textures.""
This reverts commit 12f680214e28dc5f0a13ac8afc0d1445f89e67e6.
Original cl in https://codereview.webrtc.org/1396073003/
Prepare MediaCodecVideoEncoder for surface textures.
This refactors 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.

The pure revert of the revert is in patchset 1.
Patchset 2, moves getting the input buffer to before storing pending timestamps etc to fix b/24984012.

BUG=webrtc:4993 b/24984012

Review URL: https://codereview.webrtc.org/1406203002

Cr-Commit-Position: refs/heads/master@{#10622}
2015-11-12 14:43:22 +00:00
magjed
fc6affc60d Android SurfaceViewRenderer: Call glClear() for every frame to avoid bad GL state
BUG=webrtc:5147

Review URL: https://codereview.webrtc.org/1436883002

Cr-Commit-Position: refs/heads/master@{#10617}
2015-11-12 09:08:37 +00:00
perkj
cbfabbf818 Fix potential tearing issue in VideoRendererGui.
This make sure that the texture copy is syncronized.

To reproduce the problem I:
Reverted "Revert of "Android MediaCodecVideoDecoder: Manage lifetime of texture frames" https://codereview.webrtc.org/1378033003/"
commit 543b6ca30a43eeb069c699291460ce6bacc7959d.
Reverted "Enable SurfaceViewRenderer for AppRTCDemo"
commit 7076729c57c27aa813760d2038be02c36f4d7649.
and ran ApprtDemo in loopback and changed the orientation a couple of times.

TBR=glaznev@webrtc.org

Review URL: https://codereview.webrtc.org/1437823002

Cr-Commit-Position: refs/heads/master@{#10598}
2015-11-11 11:38:39 +00:00
perkj
9cb8982e64 Patchset 1 is a pure
revert of "Revert of "Android MediaCodecVideoDecoder: Manage lifetime of texture frames" https://codereview.webrtc.org/1378033003/

Following patchsets move the responsibility of calculating the decode time to Java.

TESTED= Apprtc loopback using H264 and VP8 on N5, N6, N7, S5

Review URL: https://codereview.webrtc.org/1422963003

Cr-Commit-Position: refs/heads/master@{#10597}
2015-11-11 11:27:05 +00:00
magjed
b2d1c5026d SurfaceViewRenderer: Add resource name to log outputs and exceptions
Add resource name to log outputs to distinguish local renderer from remote renderer.

This Cl also adds some thread checks and factors out a small helper function makeBlack().

Review URL: https://codereview.webrtc.org/1420203003

Cr-Commit-Position: refs/heads/master@{#10596}
2015-11-11 11:06:49 +00:00
Alex Glaznev
69a7fd5047 Support VP9 HW video decoding on Android.
Preliminary verification is done for OMX.google.vp9.decoder codec.

R=magjed@webrtc.org

Review URL: https://codereview.webrtc.org/1416023005 .

Cr-Commit-Position: refs/heads/master@{#10586}
2015-11-10 18:25:59 +00:00
perkj
83dfad6853 VideoCapturerAndroid: Changed camera freeze check to check that all frames are pending before reporting a client error.
BUG=b/25514149

Review URL: https://codereview.webrtc.org/1423073006

Cr-Commit-Position: refs/heads/master@{#10563}
2015-11-09 15:39:55 +00:00
perkj
89ef6cc13e Attempt to open Android camera later if it is already in use.
This change VideoCapturerAndroid to attempt 3 times with a period of 300ms to open the camera if it fails.
This is so that if another application have it already opened, it would have more time to release it.
BUG=b/25190234

Review URL: https://codereview.webrtc.org/1422023007

Cr-Commit-Position: refs/heads/master@{#10559}
2015-11-09 09:35:26 +00:00
magjed
1ebf8ba368 SurfaceViewRenderer: Drop old frames instead of new frames
If SurfaceViewRenderer can't keep up with the stream of incoming frames it has to drop frames. Currently, new frames are dropped until the old pending frame is rendered. This CL drops the old pending frame instead.

Review URL: https://codereview.webrtc.org/1417063005

Cr-Commit-Position: refs/heads/master@{#10558}
2015-11-09 08:41:55 +00:00
perkj
3bfef44a4d Changed timeout to 6s for reporting android camera freeze.
Also distinguish between camera failures and failures due to that buffers has not been returned.
Adds unit tests for making sure CameraEventHandler.onError is triggered if frames are not returned.

BUG=b/25514149

Review URL: https://codereview.webrtc.org/1415013006

Cr-Commit-Position: refs/heads/master@{#10555}
2015-11-08 14:58:22 +00:00
noahric
23725e09c6 Remove ICU usage from jni_helpers.cc.
JNI already has jstring<->UTF8 string conversion, so using that should
save ~1mb off android binaries (ICU is *large*), probably around
300-400k after compression.

BUG=

Review URL: https://codereview.webrtc.org/1430023005

Cr-Commit-Position: refs/heads/master@{#10545}
2015-11-06 21:56:11 +00:00
Honghai Zhang
5a846c086b Make ConnectionType public in order to add java NetworkObserver.
BUG=
R=glaznev@webrtc.org, jiayl@google.com

Review URL: https://codereview.webrtc.org/1429053002 .

Cr-Commit-Position: refs/heads/master@{#10485}
2015-11-02 19:33:30 +00:00
Alex Glaznev
5c3da4b6e9 Call MediaCodec.stop() on separate thread.
MediaCodec.stop() call may hang in some rear cases. To avoid
application hang this call need to be done on separate thread and
possible error reported back to application.
Application may elect to continue executing and use another codec
instance for encoding/decoding or stop the call and exit.

BUG=b/24339249
R=magjed@webrtc.org

Review URL: https://codereview.webrtc.org/1425143005 .

Cr-Commit-Position: refs/heads/master@{#10467}
2015-10-30 22:31:25 +00:00
asapersson
075fb4bfea MediaCodecVideoEncoder: Add number of quality resolution downscales to Encoded callback.
BUG=

Review URL: https://codereview.webrtc.org/1426033002

Cr-Commit-Position: refs/heads/master@{#10453}
2015-10-29 15:49:21 +00:00
glaznev
e55c42c13e Remove limitation on the amount of maximum pending HW decoder inputs.
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}
2015-10-28 17:30:38 +00:00
Henrik Kjellander
98f53510b2 system_wrappers: rename interface -> include
BUG=webrtc:5095
R=tommi@webrtc.org

Review URL: https://codereview.webrtc.org/1413333002 .

Cr-Commit-Position: refs/heads/master@{#10438}
2015-10-28 17:17:50 +00:00