Merge changes from internal repo to AppRTCDemo.
- Add a setting option to disable outgoing video in a call. - Add an option to select audio codec. - Add an option to specify audio bitrate for Opus codec. - Plus add an option to select H.264 as default video codec. R=wzh@webrtc.org Review URL: https://webrtc-codereview.appspot.com/42449004 Cr-Commit-Position: refs/heads/master@{#8468} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8468 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
d324546ced
commit
e3fccd4268
@ -28,6 +28,12 @@
|
||||
<string-array name="videoCodecs">
|
||||
<item>VP8</item>
|
||||
<item>VP9</item>
|
||||
<item>H264</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="audioCodecs">
|
||||
<item>OPUS</item>
|
||||
<item>ISAC</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
@ -28,6 +28,14 @@
|
||||
<string name="pref_room_key">room_preference</string>
|
||||
<string name="pref_room_list_key">room_list_preference</string>
|
||||
|
||||
<string name="pref_videosettings_key">video_settings_key</string>
|
||||
<string name="pref_videosettings_title">WebRTC video settings.</string>
|
||||
|
||||
<string name="pref_videocall_key">videocall_preference</string>
|
||||
<string name="pref_videocall_title">Video call.</string>
|
||||
<string name="pref_videocall_dlg">Enable video in a call.</string>
|
||||
<string name="pref_videocall_default">true</string>
|
||||
|
||||
<string name="pref_resolution_key">resolution_preference</string>
|
||||
<string name="pref_resolution_title">Video resolution.</string>
|
||||
<string name="pref_resolution_dlg">Enter AppRTC local video resolution.</string>
|
||||
@ -38,20 +46,15 @@
|
||||
<string name="pref_fps_dlg">Enter local camera fps.</string>
|
||||
<string name="pref_fps_default">Default</string>
|
||||
|
||||
<string name="pref_cpu_usage_detection_key">cpu_usage_detection</string>
|
||||
<string name="pref_cpu_usage_detection_title">CPU overuse detection.</string>
|
||||
<string name="pref_cpu_usage_detection_dlg">Adapt transmission to CPU status.</string>
|
||||
<string name="pref_cpu_usage_detection_default" translatable="false">true</string>
|
||||
<string name="pref_startvideobitrate_key">startvideobitrate_preference</string>
|
||||
<string name="pref_startvideobitrate_title">Start video bitrate setting.</string>
|
||||
<string name="pref_startvideobitrate_dlg">Start video bitrate setting.</string>
|
||||
<string name="pref_startvideobitrate_default">Default</string>
|
||||
|
||||
<string name="pref_startbitrate_key">startbitrate_preference</string>
|
||||
<string name="pref_startbitrate_title">Start bitrate setting.</string>
|
||||
<string name="pref_startbitrate_dlg">Start bitrate setting.</string>
|
||||
<string name="pref_startbitrate_default">Default</string>
|
||||
|
||||
<string name="pref_startbitratevalue_key">startbitratevalue_preference</string>
|
||||
<string name="pref_startbitratevalue_title">Video encoder start bitrate.</string>
|
||||
<string name="pref_startbitratevalue_dlg">Enter video encoder start bitrate in kbps.</string>
|
||||
<string name="pref_startbitratevalue_default">1000</string>
|
||||
<string name="pref_startvideobitratevalue_key">startvideobitratevalue_preference</string>
|
||||
<string name="pref_startvideobitratevalue_title">Video encoder start bitrate.</string>
|
||||
<string name="pref_startvideobitratevalue_dlg">Enter video encoder start bitrate in kbps.</string>
|
||||
<string name="pref_startvideobitratevalue_default">1000</string>
|
||||
|
||||
<string name="pref_videocodec_key">videocodec_preference</string>
|
||||
<string name="pref_videocodec_title">Default video codec.</string>
|
||||
@ -66,6 +69,32 @@
|
||||
<string name="pref_value_enabled">Enabled</string>
|
||||
<string name="pref_value_disabled">Disabled</string>
|
||||
|
||||
<string name="pref_audiosettings_key">audio_settings_key</string>
|
||||
<string name="pref_audiosettings_title">WebRTC audio settings.</string>
|
||||
|
||||
<string name="pref_startaudiobitrate_key">startaudiobitrate_preference</string>
|
||||
<string name="pref_startaudiobitrate_title">Audio bitrate setting.</string>
|
||||
<string name="pref_startaudiobitrate_dlg">Audio bitrate setting.</string>
|
||||
<string name="pref_startaudiobitrate_default">Default</string>
|
||||
|
||||
<string name="pref_startaudiobitratevalue_key">startaudiobitratevalue_preference</string>
|
||||
<string name="pref_startaudiobitratevalue_title">Audio codec bitrate.</string>
|
||||
<string name="pref_startaudiobitratevalue_dlg">Enter audio codec bitrate in kbps.</string>
|
||||
<string name="pref_startaudiobitratevalue_default">32</string>
|
||||
|
||||
<string name="pref_audiocodec_key">audiocodec_preference</string>
|
||||
<string name="pref_audiocodec_title">Default audio codec.</string>
|
||||
<string name="pref_audiocodec_dlg">Select default audio codec.</string>
|
||||
<string name="pref_audiocodec_default">OPUS</string>
|
||||
|
||||
<string name="pref_miscsettings_key">misc_settings_key</string>
|
||||
<string name="pref_miscsettings_title">Miscellaneous settings.</string>
|
||||
|
||||
<string name="pref_cpu_usage_detection_key">cpu_usage_detection</string>
|
||||
<string name="pref_cpu_usage_detection_title">CPU overuse detection.</string>
|
||||
<string name="pref_cpu_usage_detection_dlg">Adapt transmission to CPU status.</string>
|
||||
<string name="pref_cpu_usage_detection_default" translatable="false">true</string>
|
||||
|
||||
<string name="pref_room_server_url_key">room_server_url_preference</string>
|
||||
<string name="pref_room_server_url_title">Room server URL.</string>
|
||||
<string name="pref_room_server_url_dlg">Enter a room server URL.</string>
|
||||
|
@ -1,67 +1,111 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<ListPreference
|
||||
android:key="@string/pref_resolution_key"
|
||||
android:title="@string/pref_resolution_title"
|
||||
android:defaultValue="@string/pref_resolution_default"
|
||||
android:dialogTitle="@string/pref_resolution_dlg"
|
||||
android:entries="@array/videoResolutions"
|
||||
android:entryValues="@array/videoResolutionsValues" />
|
||||
<PreferenceCategory
|
||||
android:key="@string/pref_videosettings_key"
|
||||
android:title="@string/pref_videosettings_title">
|
||||
|
||||
<ListPreference
|
||||
android:key="@string/pref_fps_key"
|
||||
android:title="@string/pref_fps_title"
|
||||
android:defaultValue="@string/pref_fps_default"
|
||||
android:dialogTitle="@string/pref_fps_dlg"
|
||||
android:entries="@array/cameraFps"
|
||||
android:entryValues="@array/cameraFps" />
|
||||
<CheckBoxPreference
|
||||
android:key="@string/pref_videocall_key"
|
||||
android:title="@string/pref_videocall_title"
|
||||
android:dialogTitle="@string/pref_videocall_dlg"
|
||||
android:defaultValue="@string/pref_videocall_default" />
|
||||
|
||||
<ListPreference
|
||||
android:key="@string/pref_startbitrate_key"
|
||||
android:title="@string/pref_startbitrate_title"
|
||||
android:defaultValue="@string/pref_startbitrate_default"
|
||||
android:dialogTitle="@string/pref_startbitrate_dlg"
|
||||
android:entries="@array/startBitrate"
|
||||
android:entryValues="@array/startBitrate" />
|
||||
<ListPreference
|
||||
android:key="@string/pref_resolution_key"
|
||||
android:title="@string/pref_resolution_title"
|
||||
android:defaultValue="@string/pref_resolution_default"
|
||||
android:dialogTitle="@string/pref_resolution_dlg"
|
||||
android:entries="@array/videoResolutions"
|
||||
android:entryValues="@array/videoResolutionsValues" />
|
||||
|
||||
<EditTextPreference
|
||||
android:key="@string/pref_startbitratevalue_key"
|
||||
android:title="@string/pref_startbitratevalue_title"
|
||||
android:inputType="number"
|
||||
android:defaultValue="@string/pref_startbitratevalue_default"
|
||||
android:dialogTitle="@string/pref_startbitratevalue_dlg" />
|
||||
<ListPreference
|
||||
android:key="@string/pref_fps_key"
|
||||
android:title="@string/pref_fps_title"
|
||||
android:defaultValue="@string/pref_fps_default"
|
||||
android:dialogTitle="@string/pref_fps_dlg"
|
||||
android:entries="@array/cameraFps"
|
||||
android:entryValues="@array/cameraFps" />
|
||||
|
||||
<ListPreference
|
||||
android:key="@string/pref_videocodec_key"
|
||||
android:title="@string/pref_videocodec_title"
|
||||
android:defaultValue="@string/pref_videocodec_default"
|
||||
android:dialogTitle="@string/pref_videocodec_dlg"
|
||||
android:entries="@array/videoCodecs"
|
||||
android:entryValues="@array/videoCodecs" />
|
||||
<ListPreference
|
||||
android:key="@string/pref_startvideobitrate_key"
|
||||
android:title="@string/pref_startvideobitrate_title"
|
||||
android:defaultValue="@string/pref_startvideobitrate_default"
|
||||
android:dialogTitle="@string/pref_startvideobitrate_dlg"
|
||||
android:entries="@array/startBitrate"
|
||||
android:entryValues="@array/startBitrate" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="@string/pref_hwcodec_key"
|
||||
android:title="@string/pref_hwcodec_title"
|
||||
android:dialogTitle="@string/pref_hwcodec_dlg"
|
||||
android:defaultValue="@string/pref_hwcodec_default" />
|
||||
<EditTextPreference
|
||||
android:key="@string/pref_startvideobitratevalue_key"
|
||||
android:title="@string/pref_startvideobitratevalue_title"
|
||||
android:inputType="number"
|
||||
android:defaultValue="@string/pref_startvideobitratevalue_default"
|
||||
android:dialogTitle="@string/pref_startvideobitratevalue_dlg" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="@string/pref_cpu_usage_detection_key"
|
||||
android:title="@string/pref_cpu_usage_detection_title"
|
||||
android:dialogTitle="@string/pref_cpu_usage_detection_dlg"
|
||||
android:defaultValue="@string/pref_cpu_usage_detection_default" />
|
||||
<ListPreference
|
||||
android:key="@string/pref_videocodec_key"
|
||||
android:title="@string/pref_videocodec_title"
|
||||
android:defaultValue="@string/pref_videocodec_default"
|
||||
android:dialogTitle="@string/pref_videocodec_dlg"
|
||||
android:entries="@array/videoCodecs"
|
||||
android:entryValues="@array/videoCodecs" />
|
||||
|
||||
<EditTextPreference
|
||||
android:key="@string/pref_room_server_url_key"
|
||||
android:title="@string/pref_room_server_url_title"
|
||||
android:inputType="text"
|
||||
android:defaultValue="@string/pref_room_server_url_default"
|
||||
android:dialogTitle="@string/pref_room_server_url_dlg" />
|
||||
<CheckBoxPreference
|
||||
android:key="@string/pref_hwcodec_key"
|
||||
android:title="@string/pref_hwcodec_title"
|
||||
android:dialogTitle="@string/pref_hwcodec_dlg"
|
||||
android:defaultValue="@string/pref_hwcodec_default" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="@string/pref_displayhud_key"
|
||||
android:title="@string/pref_displayhud_title"
|
||||
android:dialogTitle="@string/pref_displayhud_dlg"
|
||||
android:defaultValue="@string/pref_displayhud_default" />
|
||||
<PreferenceCategory
|
||||
android:key="@string/pref_audiosettings_key"
|
||||
android:title="@string/pref_audiosettings_title">
|
||||
|
||||
<ListPreference
|
||||
android:key="@string/pref_startaudiobitrate_key"
|
||||
android:title="@string/pref_startaudiobitrate_title"
|
||||
android:defaultValue="@string/pref_startaudiobitrate_default"
|
||||
android:dialogTitle="@string/pref_startaudiobitrate_dlg"
|
||||
android:entries="@array/startBitrate"
|
||||
android:entryValues="@array/startBitrate" />
|
||||
|
||||
<EditTextPreference
|
||||
android:key="@string/pref_startaudiobitratevalue_key"
|
||||
android:title="@string/pref_startaudiobitratevalue_title"
|
||||
android:inputType="number"
|
||||
android:defaultValue="@string/pref_startaudiobitratevalue_default"
|
||||
android:dialogTitle="@string/pref_startaudiobitratevalue_dlg" />
|
||||
|
||||
<ListPreference
|
||||
android:key="@string/pref_audiocodec_key"
|
||||
android:title="@string/pref_audiocodec_title"
|
||||
android:defaultValue="@string/pref_audiocodec_default"
|
||||
android:dialogTitle="@string/pref_audiocodec_dlg"
|
||||
android:entries="@array/audioCodecs"
|
||||
android:entryValues="@array/audioCodecs" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="@string/pref_miscsettings_key"
|
||||
android:title="@string/pref_miscsettings_title">
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="@string/pref_cpu_usage_detection_key"
|
||||
android:title="@string/pref_cpu_usage_detection_title"
|
||||
android:dialogTitle="@string/pref_cpu_usage_detection_dlg"
|
||||
android:defaultValue="@string/pref_cpu_usage_detection_default" />
|
||||
|
||||
<EditTextPreference
|
||||
android:key="@string/pref_room_server_url_key"
|
||||
android:title="@string/pref_room_server_url_title"
|
||||
android:inputType="text"
|
||||
android:defaultValue="@string/pref_room_server_url_default"
|
||||
android:dialogTitle="@string/pref_room_server_url_dlg" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="@string/pref_displayhud_key"
|
||||
android:title="@string/pref_displayhud_title"
|
||||
android:dialogTitle="@string/pref_displayhud_dlg"
|
||||
android:defaultValue="@string/pref_displayhud_default" />
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@ -66,18 +66,24 @@ public class CallActivity extends Activity
|
||||
"org.appspot.apprtc.ROOMID";
|
||||
public static final String EXTRA_LOOPBACK =
|
||||
"org.appspot.apprtc.LOOPBACK";
|
||||
public static final String EXTRA_HWCODEC =
|
||||
"org.appspot.apprtc.HWCODEC";
|
||||
public static final String EXTRA_VIDEO_BITRATE =
|
||||
"org.appspot.apprtc.VIDEO_BITRATE";
|
||||
public static final String EXTRA_VIDEO_CALL =
|
||||
"org.appspot.apprtc.VIDEO_CALL";
|
||||
public static final String EXTRA_VIDEO_WIDTH =
|
||||
"org.appspot.apprtc.VIDEO_WIDTH";
|
||||
public static final String EXTRA_VIDEO_HEIGHT =
|
||||
"org.appspot.apprtc.VIDEO_HEIGHT";
|
||||
public static final String EXTRA_VIDEO_FPS =
|
||||
"org.appspot.apprtc.VIDEO_FPS";
|
||||
public static final String EXTRA_VIDEO_BITRATE =
|
||||
"org.appspot.apprtc.VIDEO_BITRATE";
|
||||
public static final String EXTRA_VIDEOCODEC =
|
||||
"org.appspot.apprtc.VIDEOCODEC";
|
||||
public static final String EXTRA_HWCODEC_ENABLED =
|
||||
"org.appspot.apprtc.HWCODEC";
|
||||
public static final String EXTRA_AUDIO_BITRATE =
|
||||
"org.appspot.apprtc.AUDIO_BITRATE";
|
||||
public static final String EXTRA_AUDIOCODEC =
|
||||
"org.appspot.apprtc.AUDIOCODEC";
|
||||
public static final String EXTRA_CPUOVERUSE_DETECTION =
|
||||
"org.appspot.apprtc.CPUOVERUSE_DETECTION";
|
||||
public static final String EXTRA_DISPLAY_HUD =
|
||||
@ -118,11 +124,10 @@ public class CallActivity extends Activity
|
||||
private boolean activityRunning;
|
||||
private RoomConnectionParameters roomConnectionParameters;
|
||||
private PeerConnectionParameters peerConnectionParameters;
|
||||
private boolean hwCodecAcceleration;
|
||||
private String videoCodec;
|
||||
private boolean iceConnected;
|
||||
private boolean isError;
|
||||
private boolean callControlFragmentVisible = true;
|
||||
private long callStartedTimeMs = 0;
|
||||
|
||||
// Controls
|
||||
private GLSurfaceView videoView;
|
||||
@ -194,17 +199,17 @@ public class CallActivity extends Activity
|
||||
return;
|
||||
}
|
||||
boolean loopback = intent.getBooleanExtra(EXTRA_LOOPBACK, false);
|
||||
hwCodecAcceleration = intent.getBooleanExtra(EXTRA_HWCODEC, true);
|
||||
if (intent.hasExtra(EXTRA_VIDEOCODEC)) {
|
||||
videoCodec = intent.getStringExtra(EXTRA_VIDEOCODEC);
|
||||
} else {
|
||||
videoCodec = PeerConnectionClient.VIDEO_CODEC_VP8; // use VP8 by default.
|
||||
}
|
||||
peerConnectionParameters = new PeerConnectionParameters(
|
||||
intent.getBooleanExtra(EXTRA_VIDEO_CALL, true),
|
||||
loopback,
|
||||
intent.getIntExtra(EXTRA_VIDEO_WIDTH, 0),
|
||||
intent.getIntExtra(EXTRA_VIDEO_HEIGHT, 0),
|
||||
intent.getIntExtra(EXTRA_VIDEO_FPS, 0),
|
||||
intent.getIntExtra(EXTRA_VIDEO_BITRATE, 0),
|
||||
intent.getStringExtra(EXTRA_VIDEOCODEC),
|
||||
intent.getBooleanExtra(EXTRA_HWCODEC_ENABLED, true),
|
||||
intent.getIntExtra(EXTRA_AUDIO_BITRATE, 0),
|
||||
intent.getStringExtra(EXTRA_AUDIOCODEC),
|
||||
intent.getBooleanExtra(EXTRA_CPUOVERUSE_DETECTION, true));
|
||||
commandLineRun = intent.getBooleanExtra(EXTRA_CMDLINE, false);
|
||||
runTimeMs = intent.getIntExtra(EXTRA_RUNTIME, 0);
|
||||
@ -319,6 +324,8 @@ public class CallActivity extends Activity
|
||||
Log.e(TAG, "AppRTC client is not allocated for a call.");
|
||||
return;
|
||||
}
|
||||
callStartedTimeMs = System.currentTimeMillis();
|
||||
|
||||
// Start room connection.
|
||||
logAndToast(getString(R.string.connecting_to,
|
||||
roomConnectionParameters.roomUrl));
|
||||
@ -343,6 +350,9 @@ public class CallActivity extends Activity
|
||||
|
||||
// Should be called from UI thread
|
||||
private void callConnected() {
|
||||
final long delta = System.currentTimeMillis() - callStartedTimeMs;
|
||||
Log.i(TAG, "Call connected: delay=" + delta + "ms");
|
||||
|
||||
// Update video view.
|
||||
updateVideoView();
|
||||
// Enable statistics callback.
|
||||
@ -360,10 +370,12 @@ public class CallActivity extends Activity
|
||||
@Override
|
||||
public void run() {
|
||||
if (peerConnectionClient == null) {
|
||||
final long delta = System.currentTimeMillis() - callStartedTimeMs;
|
||||
Log.d(TAG, "Creating peer connection factory, delay=" + delta + "ms");
|
||||
peerConnectionClient = new PeerConnectionClient();
|
||||
peerConnectionClient.createPeerConnectionFactory(CallActivity.this,
|
||||
videoCodec, hwCodecAcceleration,
|
||||
VideoRendererGui.getEGLContext(), CallActivity.this);
|
||||
VideoRendererGui.getEGLContext(), peerConnectionParameters,
|
||||
CallActivity.this);
|
||||
}
|
||||
if (signalingParameters != null) {
|
||||
Log.w(TAG, "EGL context is ready after room connection.");
|
||||
@ -428,15 +440,16 @@ public class CallActivity extends Activity
|
||||
// All callbacks are invoked from websocket signaling looper thread and
|
||||
// are routed to UI thread.
|
||||
private void onConnectedToRoomInternal(final SignalingParameters params) {
|
||||
final long delta = System.currentTimeMillis() - callStartedTimeMs;
|
||||
|
||||
signalingParameters = params;
|
||||
if (peerConnectionClient == null) {
|
||||
Log.w(TAG, "Room is connected, but EGL context is not ready yet.");
|
||||
return;
|
||||
}
|
||||
logAndToast("Creating peer connection...");
|
||||
logAndToast("Creating peer connection, delay=" + delta + "ms");
|
||||
peerConnectionClient.createPeerConnection(
|
||||
localRender, remoteRender,
|
||||
signalingParameters, peerConnectionParameters);
|
||||
localRender, remoteRender, signalingParameters);
|
||||
|
||||
if (signalingParameters.initiator) {
|
||||
logAndToast("Creating OFFER...");
|
||||
@ -472,6 +485,7 @@ public class CallActivity extends Activity
|
||||
|
||||
@Override
|
||||
public void onRemoteDescription(final SessionDescription sdp) {
|
||||
final long delta = System.currentTimeMillis() - callStartedTimeMs;
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -479,7 +493,7 @@ public class CallActivity extends Activity
|
||||
Log.e(TAG, "Received remote SDP for non-initilized peer connection.");
|
||||
return;
|
||||
}
|
||||
logAndToast("Received remote " + sdp.type + " ...");
|
||||
logAndToast("Received remote " + sdp.type + ", delay=" + delta + "ms");
|
||||
peerConnectionClient.setRemoteDescription(sdp);
|
||||
if (!signalingParameters.initiator) {
|
||||
logAndToast("Creating ANSWER...");
|
||||
@ -536,11 +550,12 @@ public class CallActivity extends Activity
|
||||
// are routed to UI thread.
|
||||
@Override
|
||||
public void onLocalDescription(final SessionDescription sdp) {
|
||||
final long delta = System.currentTimeMillis() - callStartedTimeMs;
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (appRtcClient != null) {
|
||||
logAndToast("Sending " + sdp.type + " ...");
|
||||
logAndToast("Sending " + sdp.type + ", delay=" + delta + "ms");
|
||||
if (signalingParameters.initiator) {
|
||||
appRtcClient.sendOfferSdp(sdp);
|
||||
} else {
|
||||
@ -565,10 +580,11 @@ public class CallActivity extends Activity
|
||||
|
||||
@Override
|
||||
public void onIceConnected() {
|
||||
final long delta = System.currentTimeMillis() - callStartedTimeMs;
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
logAndToast("ICE connected");
|
||||
logAndToast("ICE connected, delay=" + delta + "ms");
|
||||
iceConnected = true;
|
||||
callConnected();
|
||||
}
|
||||
|
@ -71,11 +71,15 @@ public class ConnectActivity extends Activity {
|
||||
private EditText roomEditText;
|
||||
private ListView roomListView;
|
||||
private SharedPreferences sharedPref;
|
||||
private String keyprefVideoCallEnabled;
|
||||
private String keyprefResolution;
|
||||
private String keyprefFps;
|
||||
private String keyprefBitrateType;
|
||||
private String keyprefBitrateValue;
|
||||
private String keyprefVideoBitrateType;
|
||||
private String keyprefVideoBitrateValue;
|
||||
private String keyprefVideoCodec;
|
||||
private String keyprefAudioBitrateType;
|
||||
private String keyprefAudioBitrateValue;
|
||||
private String keyprefAudioCodec;
|
||||
private String keyprefHwCodecAcceleration;
|
||||
private String keyprefCpuUsageDetection;
|
||||
private String keyprefDisplayHud;
|
||||
@ -92,12 +96,16 @@ public class ConnectActivity extends Activity {
|
||||
// Get setting keys.
|
||||
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
|
||||
sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
keyprefVideoCallEnabled = getString(R.string.pref_videocall_key);
|
||||
keyprefResolution = getString(R.string.pref_resolution_key);
|
||||
keyprefFps = getString(R.string.pref_fps_key);
|
||||
keyprefBitrateType = getString(R.string.pref_startbitrate_key);
|
||||
keyprefBitrateValue = getString(R.string.pref_startbitratevalue_key);
|
||||
keyprefVideoBitrateType = getString(R.string.pref_startvideobitrate_key);
|
||||
keyprefVideoBitrateValue = getString(R.string.pref_startvideobitratevalue_key);
|
||||
keyprefVideoCodec = getString(R.string.pref_videocodec_key);
|
||||
keyprefHwCodecAcceleration = getString(R.string.pref_hwcodec_key);
|
||||
keyprefAudioBitrateType = getString(R.string.pref_startaudiobitrate_key);
|
||||
keyprefAudioBitrateValue = getString(R.string.pref_startaudiobitratevalue_key);
|
||||
keyprefAudioCodec = getString(R.string.pref_audiocodec_key);
|
||||
keyprefCpuUsageDetection = getString(R.string.pref_cpu_usage_detection_key);
|
||||
keyprefDisplayHud = getString(R.string.pref_displayhud_key);
|
||||
keyprefRoomServerUrl = getString(R.string.pref_room_server_url_key);
|
||||
@ -244,9 +252,15 @@ public class ConnectActivity extends Activity {
|
||||
keyprefRoomServerUrl,
|
||||
getString(R.string.pref_room_server_url_default));
|
||||
|
||||
// Get default video codec.
|
||||
// Video call enabled flag.
|
||||
boolean videoCallEnabled = sharedPref.getBoolean(keyprefVideoCallEnabled,
|
||||
Boolean.valueOf(getString(R.string.pref_videocall_default)));
|
||||
|
||||
// Get default codecs.
|
||||
String videoCodec = sharedPref.getString(keyprefVideoCodec,
|
||||
getString(R.string.pref_videocodec_default));
|
||||
String audioCodec = sharedPref.getString(keyprefAudioCodec,
|
||||
getString(R.string.pref_audiocodec_default));
|
||||
|
||||
// Check HW codec flag.
|
||||
boolean hwCodec = sharedPref.getBoolean(keyprefHwCodecAcceleration,
|
||||
@ -282,15 +296,25 @@ public class ConnectActivity extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
// Get start bitrate.
|
||||
int startBitrate = 0;
|
||||
String bitrateTypeDefault = getString(R.string.pref_startbitrate_default);
|
||||
// Get video and audio start bitrate.
|
||||
int videoStartBitrate = 0;
|
||||
String bitrateTypeDefault = getString(
|
||||
R.string.pref_startvideobitrate_default);
|
||||
String bitrateType = sharedPref.getString(
|
||||
keyprefBitrateType, bitrateTypeDefault);
|
||||
keyprefVideoBitrateType, bitrateTypeDefault);
|
||||
if (!bitrateType.equals(bitrateTypeDefault)) {
|
||||
String bitrateValue = sharedPref.getString(keyprefBitrateValue,
|
||||
getString(R.string.pref_startbitratevalue_default));
|
||||
startBitrate = Integer.parseInt(bitrateValue);
|
||||
String bitrateValue = sharedPref.getString(keyprefVideoBitrateValue,
|
||||
getString(R.string.pref_startvideobitratevalue_default));
|
||||
videoStartBitrate = Integer.parseInt(bitrateValue);
|
||||
}
|
||||
int audioStartBitrate = 0;
|
||||
bitrateTypeDefault = getString(R.string.pref_startaudiobitrate_default);
|
||||
bitrateType = sharedPref.getString(
|
||||
keyprefAudioBitrateType, bitrateTypeDefault);
|
||||
if (!bitrateType.equals(bitrateTypeDefault)) {
|
||||
String bitrateValue = sharedPref.getString(keyprefAudioBitrateValue,
|
||||
getString(R.string.pref_startaudiobitratevalue_default));
|
||||
audioStartBitrate = Integer.parseInt(bitrateValue);
|
||||
}
|
||||
|
||||
// Test if CpuOveruseDetection should be disabled. By default is on.
|
||||
@ -311,12 +335,15 @@ public class ConnectActivity extends Activity {
|
||||
intent.setData(uri);
|
||||
intent.putExtra(CallActivity.EXTRA_ROOMID, roomId);
|
||||
intent.putExtra(CallActivity.EXTRA_LOOPBACK, loopback);
|
||||
intent.putExtra(CallActivity.EXTRA_VIDEOCODEC, videoCodec);
|
||||
intent.putExtra(CallActivity.EXTRA_HWCODEC, hwCodec);
|
||||
intent.putExtra(CallActivity.EXTRA_VIDEO_BITRATE, startBitrate);
|
||||
intent.putExtra(CallActivity.EXTRA_VIDEO_CALL, videoCallEnabled);
|
||||
intent.putExtra(CallActivity.EXTRA_VIDEO_WIDTH, videoWidth);
|
||||
intent.putExtra(CallActivity.EXTRA_VIDEO_HEIGHT, videoHeight);
|
||||
intent.putExtra(CallActivity.EXTRA_VIDEO_FPS, cameraFps);
|
||||
intent.putExtra(CallActivity.EXTRA_VIDEO_BITRATE, videoStartBitrate);
|
||||
intent.putExtra(CallActivity.EXTRA_VIDEOCODEC, videoCodec);
|
||||
intent.putExtra(CallActivity.EXTRA_HWCODEC_ENABLED, hwCodec);
|
||||
intent.putExtra(CallActivity.EXTRA_AUDIO_BITRATE, audioStartBitrate);
|
||||
intent.putExtra(CallActivity.EXTRA_AUDIOCODEC, audioCodec);
|
||||
intent.putExtra(CallActivity.EXTRA_CPUOVERUSE_DETECTION,
|
||||
cpuOveruseDetection);
|
||||
intent.putExtra(CallActivity.EXTRA_DISPLAY_HUD, displayHud);
|
||||
|
@ -67,13 +67,15 @@ public class PeerConnectionClient {
|
||||
public static final String VIDEO_TRACK_ID = "ARDAMSv0";
|
||||
public static final String AUDIO_TRACK_ID = "ARDAMSa0";
|
||||
private static final String TAG = "PCRTCClient";
|
||||
private static final boolean PREFER_ISAC = false;
|
||||
private static final boolean PREFER_H264 = false;
|
||||
public static final String AUDIO_CODEC_ISAC = "ISAC";
|
||||
public static final String VIDEO_CODEC_VP8 = "VP8";
|
||||
public static final String VIDEO_CODEC_VP9 = "VP9";
|
||||
public static final String VIDEO_CODEC_H264 = "H264";
|
||||
private static final String FIELD_TRIAL_VP9 = "WebRTC-SupportVP9/Enabled/";
|
||||
private static final String VIDEO_CODEC_VP8 = "VP8";
|
||||
private static final String VIDEO_CODEC_VP9 = "VP9";
|
||||
private static final String VIDEO_CODEC_H264 = "H264";
|
||||
private static final String AUDIO_CODEC_OPUS = "opus";
|
||||
private static final String AUDIO_CODEC_ISAC = "ISAC";
|
||||
private static final String VIDEO_CODEC_PARAM_START_BITRATE =
|
||||
"x-google-start-bitrate";
|
||||
private static final String AUDIO_CODEC_PARAM_BITRATE = "maxaveragebitrate";
|
||||
private static final String MAX_VIDEO_WIDTH_CONSTRAINT = "maxWidth";
|
||||
private static final String MIN_VIDEO_WIDTH_CONSTRAINT = "minWidth";
|
||||
private static final String MAX_VIDEO_HEIGHT_CONSTRAINT = "maxHeight";
|
||||
@ -90,9 +92,11 @@ public class PeerConnectionClient {
|
||||
private PeerConnectionFactory factory = null;
|
||||
private PeerConnection peerConnection = null;
|
||||
private VideoSource videoSource;
|
||||
private boolean videoCallEnabled = true;
|
||||
private boolean preferIsac = false;
|
||||
private boolean preferH264 = false;
|
||||
private boolean videoSourceStopped = false;
|
||||
private boolean isError = false;
|
||||
private boolean videoCodecHwAcceleration;
|
||||
private final Timer statsTimer = new Timer();
|
||||
private final PCObserver pcObserver = new PCObserver();
|
||||
private final SDPObserver sdpObserver = new SDPObserver();
|
||||
@ -120,18 +124,34 @@ public class PeerConnectionClient {
|
||||
* Peer connection parameters.
|
||||
*/
|
||||
public static class PeerConnectionParameters {
|
||||
public final boolean videoCallEnabled;
|
||||
public final boolean loopback;
|
||||
public final int videoWidth;
|
||||
public final int videoHeight;
|
||||
public final int videoFps;
|
||||
public final int videoStartBitrate;
|
||||
public final String videoCodec;
|
||||
public final boolean videoCodecHwAcceleration;
|
||||
public final int audioStartBitrate;
|
||||
public final String audioCodec;
|
||||
public final boolean cpuOveruseDetection;
|
||||
|
||||
public PeerConnectionParameters(int videoWidth, int videoHeight,
|
||||
int videoFps, int videoStartBitrate, boolean cpuOveruseDetection) {
|
||||
public PeerConnectionParameters(
|
||||
boolean videoCallEnabled, boolean loopback,
|
||||
int videoWidth, int videoHeight, int videoFps, int videoStartBitrate,
|
||||
String videoCodec, boolean videoCodecHwAcceleration,
|
||||
int audioStartBitrate, String audioCodec,
|
||||
boolean cpuOveruseDetection) {
|
||||
this.videoCallEnabled = videoCallEnabled;
|
||||
this.loopback = loopback;
|
||||
this.videoWidth = videoWidth;
|
||||
this.videoHeight = videoHeight;
|
||||
this.videoFps = videoFps;
|
||||
this.videoStartBitrate = videoStartBitrate;
|
||||
this.videoCodec = videoCodec;
|
||||
this.videoCodecHwAcceleration = videoCodecHwAcceleration;
|
||||
this.audioStartBitrate = audioStartBitrate;
|
||||
this.audioCodec = audioCodec;
|
||||
this.cpuOveruseDetection = cpuOveruseDetection;
|
||||
}
|
||||
}
|
||||
@ -184,18 +204,16 @@ public class PeerConnectionClient {
|
||||
|
||||
public void createPeerConnectionFactory(
|
||||
final Context context,
|
||||
final String videoCodec,
|
||||
final boolean videoCodecHwAcceleration,
|
||||
final EGLContext renderEGLContext,
|
||||
final PeerConnectionParameters peerConnectionParameters,
|
||||
final PeerConnectionEvents events) {
|
||||
this.peerConnectionParameters = peerConnectionParameters;
|
||||
this.events = events;
|
||||
this.videoCodecHwAcceleration = videoCodecHwAcceleration;
|
||||
executor.requestStart();
|
||||
executor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
createPeerConnectionFactoryInternal(
|
||||
context, videoCodec, renderEGLContext);
|
||||
createPeerConnectionFactoryInternal(context, renderEGLContext);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -203,23 +221,29 @@ public class PeerConnectionClient {
|
||||
public void createPeerConnection(
|
||||
final VideoRenderer.Callbacks localRender,
|
||||
final VideoRenderer.Callbacks remoteRender,
|
||||
final SignalingParameters signalingParameters,
|
||||
final PeerConnectionParameters peerConnectionParameters) {
|
||||
final SignalingParameters signalingParameters) {
|
||||
if (peerConnectionParameters == null) {
|
||||
Log.e(TAG, "Creating peer connection without initializing factory.");
|
||||
return;
|
||||
}
|
||||
this.localRender = localRender;
|
||||
this.remoteRender = remoteRender;
|
||||
this.signalingParameters = signalingParameters;
|
||||
this.peerConnectionParameters = peerConnectionParameters;
|
||||
// Merge video constraints from signaling parameters and peer connection
|
||||
// parameters.
|
||||
videoConstraints = signalingParameters.videoConstraints;
|
||||
if (videoConstraints != null && peerConnectionParameters != null) {
|
||||
if (signalingParameters.videoConstraints == null) {
|
||||
videoCallEnabled = false;
|
||||
}
|
||||
if (videoCallEnabled) {
|
||||
int videoWidth = peerConnectionParameters.videoWidth;
|
||||
int videoHeight = peerConnectionParameters.videoHeight;
|
||||
|
||||
// If HW video encoder is supported and video resolution is not
|
||||
// specified force it to HD.
|
||||
if ((videoWidth == 0 || videoHeight == 0) && videoCodecHwAcceleration &&
|
||||
MediaCodecVideoEncoder.isVp8HwSupported()) {
|
||||
if ((videoWidth == 0 || videoHeight == 0)
|
||||
&& peerConnectionParameters.videoCodecHwAcceleration
|
||||
&& MediaCodecVideoEncoder.isVp8HwSupported()) {
|
||||
videoWidth = HD_VIDEO_WIDTH;
|
||||
videoHeight = HD_VIDEO_HEIGHT;
|
||||
}
|
||||
@ -268,19 +292,34 @@ public class PeerConnectionClient {
|
||||
}
|
||||
|
||||
private void createPeerConnectionFactoryInternal(
|
||||
Context context,
|
||||
String videoCodec,
|
||||
EGLContext renderEGLContext) {
|
||||
Context context, EGLContext renderEGLContext) {
|
||||
Log.d(TAG, "Create peer connection factory with EGLContext "
|
||||
+ renderEGLContext);
|
||||
+ renderEGLContext + ". Use video: "
|
||||
+ peerConnectionParameters.videoCallEnabled);
|
||||
videoCallEnabled = peerConnectionParameters.videoCallEnabled;
|
||||
isError = false;
|
||||
if (videoCodec.equals(VIDEO_CODEC_VP9)) {
|
||||
// Check if VP9 is used by default.
|
||||
if (videoCallEnabled && peerConnectionParameters.videoCodec != null
|
||||
&& peerConnectionParameters.videoCodec.equals(VIDEO_CODEC_VP9)) {
|
||||
PeerConnectionFactory.initializeFieldTrials(FIELD_TRIAL_VP9);
|
||||
} else {
|
||||
PeerConnectionFactory.initializeFieldTrials(null);
|
||||
}
|
||||
// Check if H.264 is used by default.
|
||||
preferH264 = false;
|
||||
if (videoCallEnabled && peerConnectionParameters.videoCodec != null
|
||||
&& peerConnectionParameters.videoCodec.equals(VIDEO_CODEC_H264)) {
|
||||
preferH264 = true;
|
||||
}
|
||||
// Check if ISAC is used by default.
|
||||
preferIsac = false;
|
||||
if (peerConnectionParameters.audioCodec != null
|
||||
&& peerConnectionParameters.audioCodec.equals(AUDIO_CODEC_ISAC)) {
|
||||
preferIsac = true;
|
||||
}
|
||||
if (!PeerConnectionFactory.initializeAndroidGlobals(
|
||||
context, true, true, videoCodecHwAcceleration, renderEGLContext)) {
|
||||
context, true, true,
|
||||
peerConnectionParameters.videoCodecHwAcceleration, renderEGLContext)) {
|
||||
events.onPeerConnectionError("Failed to initializeAndroidGlobals");
|
||||
}
|
||||
factory = new PeerConnectionFactory();
|
||||
@ -292,16 +331,23 @@ public class PeerConnectionClient {
|
||||
Log.e(TAG, "Peerconnection factory is not created");
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "Create peer connection. VideoConstraints: "
|
||||
+ videoConstraints.toString());
|
||||
Log.d(TAG, "Create peer connection");
|
||||
if (videoConstraints != null) {
|
||||
Log.d(TAG, "VideoConstraints: " + videoConstraints.toString());
|
||||
}
|
||||
isInitiator = signalingParameters.initiator;
|
||||
queuedRemoteCandidates = new LinkedList<IceCandidate>();
|
||||
|
||||
sdpMediaConstraints = new MediaConstraints();
|
||||
sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair(
|
||||
"OfferToReceiveAudio", "true"));
|
||||
sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair(
|
||||
"OfferToReceiveVideo", "true"));
|
||||
if (videoCallEnabled || peerConnectionParameters.loopback) {
|
||||
sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair(
|
||||
"OfferToReceiveVideo", "true"));
|
||||
} else {
|
||||
sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair(
|
||||
"OfferToReceiveVideo", "false"));
|
||||
}
|
||||
|
||||
MediaConstraints pcConstraints = signalingParameters.pcConstraints;
|
||||
pcConstraints.optional.add(
|
||||
@ -318,7 +364,7 @@ public class PeerConnectionClient {
|
||||
// Logging.Severity.LS_SENSITIVE);
|
||||
|
||||
mediaStream = factory.createLocalMediaStream("ARDAMS");
|
||||
if (videoConstraints != null) {
|
||||
if (videoCallEnabled) {
|
||||
videoCapturer = VideoCapturerAndroid.create(
|
||||
VideoCapturerAndroid.getNameOfFrontFacingDevice());
|
||||
mediaStream.addTrack(createVideoTrack(videoCapturer));
|
||||
@ -355,7 +401,7 @@ public class PeerConnectionClient {
|
||||
}
|
||||
|
||||
public boolean isHDVideo() {
|
||||
if (videoConstraints == null) {
|
||||
if (!videoCallEnabled) {
|
||||
return false;
|
||||
}
|
||||
int minWidth = 0;
|
||||
@ -479,17 +525,23 @@ public class PeerConnectionClient {
|
||||
return;
|
||||
}
|
||||
String sdpDescription = sdp.description;
|
||||
if (PREFER_ISAC) {
|
||||
if (preferIsac) {
|
||||
sdpDescription = preferCodec(sdpDescription, AUDIO_CODEC_ISAC, true);
|
||||
}
|
||||
if (PREFER_H264) {
|
||||
if (videoCallEnabled && preferH264) {
|
||||
sdpDescription = preferCodec(sdpDescription, VIDEO_CODEC_H264, false);
|
||||
}
|
||||
if (peerConnectionParameters.videoStartBitrate > 0) {
|
||||
sdpDescription = setStartBitrate(VIDEO_CODEC_VP8,
|
||||
if (videoCallEnabled && peerConnectionParameters.videoStartBitrate > 0) {
|
||||
sdpDescription = setStartBitrate(VIDEO_CODEC_VP8, true,
|
||||
sdpDescription, peerConnectionParameters.videoStartBitrate);
|
||||
sdpDescription = setStartBitrate(VIDEO_CODEC_VP9,
|
||||
sdpDescription = setStartBitrate(VIDEO_CODEC_VP9, true,
|
||||
sdpDescription, peerConnectionParameters.videoStartBitrate);
|
||||
sdpDescription = setStartBitrate(VIDEO_CODEC_H264, true,
|
||||
sdpDescription, peerConnectionParameters.videoStartBitrate);
|
||||
}
|
||||
if (peerConnectionParameters.audioStartBitrate > 0) {
|
||||
sdpDescription = setStartBitrate(AUDIO_CODEC_OPUS, false,
|
||||
sdpDescription, peerConnectionParameters.audioStartBitrate);
|
||||
}
|
||||
Log.d(TAG, "Set remote SDP.");
|
||||
SessionDescription sdpRemote = new SessionDescription(
|
||||
@ -549,12 +601,13 @@ public class PeerConnectionClient {
|
||||
return localVideoTrack;
|
||||
}
|
||||
|
||||
// Mangle SDP to add video start bitrate.
|
||||
private static String setStartBitrate(String codec,
|
||||
private static String setStartBitrate(String codec, boolean isVideoCodec,
|
||||
String sdpDescription, int bitrateKbps) {
|
||||
String[] lines = sdpDescription.split("\r\n");
|
||||
int lineIndex = -1;
|
||||
int rtpmapLineIndex = -1;
|
||||
boolean sdpFormatUpdated = false;
|
||||
String codecRtpMap = null;
|
||||
// Search for codec rtpmap in format
|
||||
// a=rtpmap:<payload type> <encoding name>/<clock rate> [/<encoding parameters>]
|
||||
String regex = "^a=rtpmap:(\\d+) " + codec + "(/\\d+)+[\r]?$";
|
||||
Pattern codecPattern = Pattern.compile(regex);
|
||||
@ -562,7 +615,7 @@ public class PeerConnectionClient {
|
||||
Matcher codecMatcher = codecPattern.matcher(lines[i]);
|
||||
if (codecMatcher.matches()) {
|
||||
codecRtpMap = codecMatcher.group(1);
|
||||
lineIndex = i;
|
||||
rtpmapLineIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -571,16 +624,46 @@ public class PeerConnectionClient {
|
||||
return sdpDescription;
|
||||
}
|
||||
Log.d(TAG, "Found " + codec + " rtpmap " + codecRtpMap
|
||||
+ " at " + lines[lineIndex]);
|
||||
+ " at " + lines[rtpmapLineIndex]);
|
||||
|
||||
// Check if a=fmtp string already exist in remote SDP for this codec and
|
||||
// update it with new bitrate parameter.
|
||||
regex = "^a=fmtp:" + codecRtpMap + " \\w+=\\d+.*[\r]?$";
|
||||
codecPattern = Pattern.compile(regex);
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
Matcher codecMatcher = codecPattern.matcher(lines[i]);
|
||||
if (codecMatcher.matches()) {
|
||||
Log.d(TAG, "Found " + codec + " " + lines[i]);
|
||||
if (isVideoCodec) {
|
||||
lines[i] += "; " + VIDEO_CODEC_PARAM_START_BITRATE
|
||||
+ "=" + bitrateKbps;
|
||||
} else {
|
||||
lines[i] += "; " + AUDIO_CODEC_PARAM_BITRATE
|
||||
+ "=" + (bitrateKbps * 1000);
|
||||
}
|
||||
Log.d(TAG, "Update remote SDP line: " + lines[i]);
|
||||
sdpFormatUpdated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder newSdpDescription = new StringBuilder();
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
newSdpDescription.append(lines[i]).append("\r\n");
|
||||
if (i == lineIndex) {
|
||||
String bitrateSet = "a=fmtp:" + codecRtpMap
|
||||
+ " x-google-start-bitrate=" + bitrateKbps;
|
||||
Log.d(TAG, "Add bitrate SDP line: " + bitrateSet);
|
||||
// Append new a=fmtp line if no such line exist for a codec.
|
||||
if (!sdpFormatUpdated && i == rtpmapLineIndex) {
|
||||
String bitrateSet;
|
||||
if (isVideoCodec) {
|
||||
bitrateSet = "a=fmtp:" + codecRtpMap + " "
|
||||
+ VIDEO_CODEC_PARAM_START_BITRATE + "=" + bitrateKbps;
|
||||
} else {
|
||||
bitrateSet = "a=fmtp:" + codecRtpMap + " "
|
||||
+ AUDIO_CODEC_PARAM_BITRATE + "=" + (bitrateKbps * 1000);
|
||||
}
|
||||
Log.d(TAG, "Add remote SDP line: " + bitrateSet);
|
||||
newSdpDescription.append(bitrateSet).append("\r\n");
|
||||
}
|
||||
|
||||
}
|
||||
return newSdpDescription.toString();
|
||||
}
|
||||
@ -652,7 +735,7 @@ public class PeerConnectionClient {
|
||||
}
|
||||
|
||||
private void switchCameraInternal() {
|
||||
if (videoConstraints == null) {
|
||||
if (!videoCallEnabled) {
|
||||
return; // No video is sent.
|
||||
}
|
||||
Log.d(TAG, "Switch camera");
|
||||
@ -770,10 +853,10 @@ public class PeerConnectionClient {
|
||||
return;
|
||||
}
|
||||
String sdpDescription = origSdp.description;
|
||||
if (PREFER_ISAC) {
|
||||
if (preferIsac) {
|
||||
sdpDescription = preferCodec(sdpDescription, AUDIO_CODEC_ISAC, true);
|
||||
}
|
||||
if (PREFER_H264) {
|
||||
if (videoCallEnabled && preferH264) {
|
||||
sdpDescription = preferCodec(sdpDescription, VIDEO_CODEC_H264, false);
|
||||
}
|
||||
final SessionDescription sdp = new SessionDescription(
|
||||
|
@ -39,12 +39,18 @@ import android.preference.Preference;
|
||||
public class SettingsActivity extends Activity
|
||||
implements OnSharedPreferenceChangeListener{
|
||||
private SettingsFragment settingsFragment;
|
||||
private String keyprefVideoCall;
|
||||
private String keyprefResolution;
|
||||
private String keyprefFps;
|
||||
private String keyprefStartBitrateType;
|
||||
private String keyprefStartBitrateValue;
|
||||
private String keyprefStartVideoBitrateType;
|
||||
private String keyprefStartVideoBitrateValue;
|
||||
private String keyPrefVideoCodec;
|
||||
private String keyprefHwCodec;
|
||||
|
||||
private String keyprefStartAudioBitrateType;
|
||||
private String keyprefStartAudioBitrateValue;
|
||||
private String keyPrefAudioCodec;
|
||||
|
||||
private String keyprefCpuUsageDetection;
|
||||
private String keyPrefRoomServerUrl;
|
||||
private String keyPrefDisplayHud;
|
||||
@ -52,12 +58,18 @@ public class SettingsActivity extends Activity
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
keyprefVideoCall = getString(R.string.pref_videocall_key);
|
||||
keyprefResolution = getString(R.string.pref_resolution_key);
|
||||
keyprefFps = getString(R.string.pref_fps_key);
|
||||
keyprefStartBitrateType = getString(R.string.pref_startbitrate_key);
|
||||
keyprefStartBitrateValue = getString(R.string.pref_startbitratevalue_key);
|
||||
keyprefStartVideoBitrateType = getString(R.string.pref_startvideobitrate_key);
|
||||
keyprefStartVideoBitrateValue = getString(R.string.pref_startvideobitratevalue_key);
|
||||
keyPrefVideoCodec = getString(R.string.pref_videocodec_key);
|
||||
keyprefHwCodec = getString(R.string.pref_hwcodec_key);
|
||||
|
||||
keyprefStartAudioBitrateType = getString(R.string.pref_startaudiobitrate_key);
|
||||
keyprefStartAudioBitrateValue = getString(R.string.pref_startaudiobitratevalue_key);
|
||||
keyPrefAudioCodec = getString(R.string.pref_audiocodec_key);
|
||||
|
||||
keyprefCpuUsageDetection = getString(R.string.pref_cpu_usage_detection_key);
|
||||
keyPrefRoomServerUrl = getString(R.string.pref_room_server_url_key);
|
||||
keyPrefDisplayHud = getString(R.string.pref_displayhud_key);
|
||||
@ -76,13 +88,20 @@ public class SettingsActivity extends Activity
|
||||
SharedPreferences sharedPreferences =
|
||||
settingsFragment.getPreferenceScreen().getSharedPreferences();
|
||||
sharedPreferences.registerOnSharedPreferenceChangeListener(this);
|
||||
updateSummaryB(sharedPreferences, keyprefVideoCall);
|
||||
updateSummary(sharedPreferences, keyprefResolution);
|
||||
updateSummary(sharedPreferences, keyprefFps);
|
||||
updateSummary(sharedPreferences, keyprefStartBitrateType);
|
||||
updateSummaryBitrate(sharedPreferences, keyprefStartBitrateValue);
|
||||
setBitrateEnable(sharedPreferences);
|
||||
updateSummary(sharedPreferences, keyprefStartVideoBitrateType);
|
||||
updateSummaryBitrate(sharedPreferences, keyprefStartVideoBitrateValue);
|
||||
setVideoBitrateEnable(sharedPreferences);
|
||||
updateSummary(sharedPreferences, keyPrefVideoCodec);
|
||||
updateSummaryB(sharedPreferences, keyprefHwCodec);
|
||||
|
||||
updateSummary(sharedPreferences, keyprefStartAudioBitrateType);
|
||||
updateSummaryBitrate(sharedPreferences, keyprefStartAudioBitrateValue);
|
||||
setAudioBitrateEnable(sharedPreferences);
|
||||
updateSummary(sharedPreferences, keyPrefAudioCodec);
|
||||
|
||||
updateSummaryB(sharedPreferences, keyprefCpuUsageDetection);
|
||||
updateSummary(sharedPreferences, keyPrefRoomServerUrl);
|
||||
updateSummaryB(sharedPreferences, keyPrefDisplayHud);
|
||||
@ -101,18 +120,26 @@ public class SettingsActivity extends Activity
|
||||
String key) {
|
||||
if (key.equals(keyprefResolution)
|
||||
|| key.equals(keyprefFps)
|
||||
|| key.equals(keyprefStartBitrateType)
|
||||
|| key.equals(keyPrefRoomServerUrl)
|
||||
|| key.equals(keyPrefVideoCodec)) {
|
||||
|| key.equals(keyprefStartVideoBitrateType)
|
||||
|| key.equals(keyPrefVideoCodec)
|
||||
|| key.equals(keyprefStartAudioBitrateType)
|
||||
|| key.equals(keyPrefAudioCodec)
|
||||
|| key.equals(keyPrefRoomServerUrl)) {
|
||||
updateSummary(sharedPreferences, key);
|
||||
} else if (key.equals(keyprefStartBitrateValue)) {
|
||||
} else if (key.equals(keyprefStartVideoBitrateValue)
|
||||
|| key.equals(keyprefStartAudioBitrateValue)) {
|
||||
updateSummaryBitrate(sharedPreferences, key);
|
||||
} else if (key.equals(keyprefCpuUsageDetection)
|
||||
|| key.equals(keyprefHwCodec) || key.equals(keyPrefDisplayHud)) {
|
||||
} else if (key.equals(keyprefVideoCall)
|
||||
|| key.equals(keyprefHwCodec)
|
||||
|| key.equals(keyprefCpuUsageDetection)
|
||||
|| key.equals(keyPrefDisplayHud)) {
|
||||
updateSummaryB(sharedPreferences, key);
|
||||
}
|
||||
if (key.equals(keyprefStartBitrateType)) {
|
||||
setBitrateEnable(sharedPreferences);
|
||||
if (key.equals(keyprefStartVideoBitrateType)) {
|
||||
setVideoBitrateEnable(sharedPreferences);
|
||||
}
|
||||
if (key.equals(keyprefStartAudioBitrateType)) {
|
||||
setAudioBitrateEnable(sharedPreferences);
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,12 +162,25 @@ public class SettingsActivity extends Activity
|
||||
: getString(R.string.pref_value_disabled));
|
||||
}
|
||||
|
||||
private void setBitrateEnable(SharedPreferences sharedPreferences) {
|
||||
private void setVideoBitrateEnable(SharedPreferences sharedPreferences) {
|
||||
Preference bitratePreferenceValue =
|
||||
settingsFragment.findPreference(keyprefStartBitrateValue);
|
||||
String bitrateTypeDefault = getString(R.string.pref_startbitrate_default);
|
||||
settingsFragment.findPreference(keyprefStartVideoBitrateValue);
|
||||
String bitrateTypeDefault = getString(R.string.pref_startvideobitrate_default);
|
||||
String bitrateType = sharedPreferences.getString(
|
||||
keyprefStartBitrateType, bitrateTypeDefault);
|
||||
keyprefStartVideoBitrateType, bitrateTypeDefault);
|
||||
if (bitrateType.equals(bitrateTypeDefault)) {
|
||||
bitratePreferenceValue.setEnabled(false);
|
||||
} else {
|
||||
bitratePreferenceValue.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void setAudioBitrateEnable(SharedPreferences sharedPreferences) {
|
||||
Preference bitratePreferenceValue =
|
||||
settingsFragment.findPreference(keyprefStartAudioBitrateValue);
|
||||
String bitrateTypeDefault = getString(R.string.pref_startaudiobitrate_default);
|
||||
String bitrateType = sharedPreferences.getString(
|
||||
keyprefStartAudioBitrateType, bitrateTypeDefault);
|
||||
if (bitrateType.equals(bitrateTypeDefault)) {
|
||||
bitratePreferenceValue.setEnabled(false);
|
||||
} else {
|
||||
|
@ -39,7 +39,7 @@ import java.util.Scanner;
|
||||
* Asynchronous http requests implementation.
|
||||
*/
|
||||
public class AsyncHttpURLConnection {
|
||||
private static final int HTTP_TIMEOUT_MS = 5000;
|
||||
private static final int HTTP_TIMEOUT_MS = 8000;
|
||||
private final String method;
|
||||
private final String url;
|
||||
private final String message;
|
||||
|
Loading…
x
Reference in New Issue
Block a user