- Make shared EGL context used for HW video decoding member

of decoder factory class.
- Add new Peer connection factory method to initialize shared
EGL context.

This provides an option to use single peer connection factory
in the application and create peer connections from the same
factory and reinitialize shared EGL context for video
decoding HW acceleration.

R=wzh@webrtc.org

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

Cr-Commit-Position: refs/heads/master@{#9838}
This commit is contained in:
Alex Glaznev
2015-09-01 15:04:13 -07:00
parent c36d4df250
commit 4d2f4d1c69
10 changed files with 129 additions and 90 deletions

View File

@ -394,8 +394,7 @@ public class CallActivity extends Activity
Log.d(TAG, "Creating peer connection factory, delay=" + delta + "ms");
peerConnectionClient = PeerConnectionClient.getInstance();
peerConnectionClient.createPeerConnectionFactory(CallActivity.this,
VideoRendererGui.getEGLContext(), peerConnectionParameters,
CallActivity.this);
peerConnectionParameters, CallActivity.this);
}
if (signalingParameters != null) {
Log.w(TAG, "EGL context is ready after room connection.");
@ -481,7 +480,7 @@ public class CallActivity extends Activity
return;
}
logAndToast("Creating peer connection, delay=" + delta + "ms");
peerConnectionClient.createPeerConnection(
peerConnectionClient.createPeerConnection(VideoRendererGui.getEGLContext(),
localRender, remoteRender, signalingParameters);
if (signalingParameters.initiator) {

View File

@ -216,7 +216,6 @@ public class PeerConnectionClient {
public void createPeerConnectionFactory(
final Context context,
final EGLContext renderEGLContext,
final PeerConnectionParameters peerConnectionParameters,
final PeerConnectionEvents events) {
this.peerConnectionParameters = peerConnectionParameters;
@ -241,12 +240,13 @@ public class PeerConnectionClient {
executor.execute(new Runnable() {
@Override
public void run() {
createPeerConnectionFactoryInternal(context, renderEGLContext);
createPeerConnectionFactoryInternal(context);
}
});
}
public void createPeerConnection(
final EGLContext renderEGLContext,
final VideoRenderer.Callbacks localRender,
final VideoRenderer.Callbacks remoteRender,
final SignalingParameters signalingParameters) {
@ -261,7 +261,7 @@ public class PeerConnectionClient {
@Override
public void run() {
createMediaConstraintsInternal();
createPeerConnectionInternal();
createPeerConnectionInternal(renderEGLContext);
}
});
}
@ -279,11 +279,9 @@ public class PeerConnectionClient {
return videoCallEnabled;
}
private void createPeerConnectionFactoryInternal(
Context context, EGLContext renderEGLContext) {
Log.d(TAG, "Create peer connection factory with EGLContext "
+ renderEGLContext + ". Use video: "
+ peerConnectionParameters.videoCallEnabled);
private void createPeerConnectionFactoryInternal(Context context) {
Log.d(TAG, "Create peer connection factory. Use video: " +
peerConnectionParameters.videoCallEnabled);
isError = false;
// Check if VP9 is used by default.
if (videoCallEnabled && peerConnectionParameters.videoCodec != null
@ -304,9 +302,8 @@ public class PeerConnectionClient {
&& peerConnectionParameters.audioCodec.equals(AUDIO_CODEC_ISAC)) {
preferIsac = true;
}
if (!PeerConnectionFactory.initializeAndroidGlobals(
context, true, true,
peerConnectionParameters.videoCodecHwAcceleration, renderEGLContext)) {
if (!PeerConnectionFactory.initializeAndroidGlobals(context, true, true,
peerConnectionParameters.videoCodecHwAcceleration)) {
events.onPeerConnectionError("Failed to initializeAndroidGlobals");
}
factory = new PeerConnectionFactory();
@ -402,18 +399,24 @@ public class PeerConnectionClient {
}
}
private void createPeerConnectionInternal() {
private void createPeerConnectionInternal(EGLContext renderEGLContext) {
if (factory == null || isError) {
Log.e(TAG, "Peerconnection factory is not created");
return;
}
Log.d(TAG, "Create peer connection");
Log.d(TAG, "Create peer connection.");
Log.d(TAG, "PCConstraints: " + pcConstraints.toString());
if (videoConstraints != null) {
Log.d(TAG, "VideoConstraints: " + videoConstraints.toString());
}
queuedRemoteCandidates = new LinkedList<IceCandidate>();
if (videoCallEnabled) {
Log.d(TAG, "EGLContext: " + renderEGLContext);
factory.setVideoHwAccelerationOptions(renderEGLContext);
}
PeerConnection.RTCConfiguration rtcConfig =
new PeerConnection.RTCConfiguration(signalingParameters.iceServers);
// TCP candidates are only useful when connecting to a server that supports