 Chromium Code Reviews
 Chromium Code Reviews Issue 2273573003:
  Support for video file instead of camera and output video out to file  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@master
    
  
    Issue 2273573003:
  Support for video file instead of camera and output video out to file  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@master| OLD | NEW | 
|---|---|
| 1 /* | 1 /* | 
| 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 
| 3 * | 3 * | 
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license | 
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source | 
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found | 
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may | 
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. | 
| 9 */ | 9 */ | 
| 10 | 10 | 
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 import android.widget.Toast; | 30 import android.widget.Toast; | 
| 31 | 31 | 
| 32 import org.webrtc.Camera2Enumerator; | 32 import org.webrtc.Camera2Enumerator; | 
| 33 import org.webrtc.EglBase; | 33 import org.webrtc.EglBase; | 
| 34 import org.webrtc.IceCandidate; | 34 import org.webrtc.IceCandidate; | 
| 35 import org.webrtc.PeerConnectionFactory; | 35 import org.webrtc.PeerConnectionFactory; | 
| 36 import org.webrtc.RendererCommon.ScalingType; | 36 import org.webrtc.RendererCommon.ScalingType; | 
| 37 import org.webrtc.SessionDescription; | 37 import org.webrtc.SessionDescription; | 
| 38 import org.webrtc.StatsReport; | 38 import org.webrtc.StatsReport; | 
| 39 import org.webrtc.SurfaceViewRenderer; | 39 import org.webrtc.SurfaceViewRenderer; | 
| 40 import org.webrtc.GlVideoFileDrawer; | |
| 
magjed_webrtc
2016/08/31 13:08:03
The imports should be put in alphabetical order.
 
mandermo
2016/09/16 12:32:30
Done.
 | |
| 41 import org.webrtc.GlRectDrawer; | |
| 40 | 42 | 
| 41 /** | 43 /** | 
| 42 * Activity for peer connection call setup, call waiting | 44 * Activity for peer connection call setup, call waiting | 
| 43 * and call view. | 45 * and call view. | 
| 44 */ | 46 */ | 
| 45 public class CallActivity extends Activity | 47 public class CallActivity extends Activity | 
| 46 implements AppRTCClient.SignalingEvents, | 48 implements AppRTCClient.SignalingEvents, | 
| 47 PeerConnectionClient.PeerConnectionEvents, | 49 PeerConnectionClient.PeerConnectionEvents, | 
| 48 CallFragment.OnCallEvents { | 50 CallFragment.OnCallEvents { | 
| 49 | 51 | 
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 "org.appspot.apprtc.DISABLE_BUILT_IN_NS"; | 91 "org.appspot.apprtc.DISABLE_BUILT_IN_NS"; | 
| 90 public static final String EXTRA_ENABLE_LEVEL_CONTROL = | 92 public static final String EXTRA_ENABLE_LEVEL_CONTROL = | 
| 91 "org.appspot.apprtc.ENABLE_LEVEL_CONTROL"; | 93 "org.appspot.apprtc.ENABLE_LEVEL_CONTROL"; | 
| 92 public static final String EXTRA_DISPLAY_HUD = | 94 public static final String EXTRA_DISPLAY_HUD = | 
| 93 "org.appspot.apprtc.DISPLAY_HUD"; | 95 "org.appspot.apprtc.DISPLAY_HUD"; | 
| 94 public static final String EXTRA_TRACING = "org.appspot.apprtc.TRACING"; | 96 public static final String EXTRA_TRACING = "org.appspot.apprtc.TRACING"; | 
| 95 public static final String EXTRA_CMDLINE = | 97 public static final String EXTRA_CMDLINE = | 
| 96 "org.appspot.apprtc.CMDLINE"; | 98 "org.appspot.apprtc.CMDLINE"; | 
| 97 public static final String EXTRA_RUNTIME = | 99 public static final String EXTRA_RUNTIME = | 
| 98 "org.appspot.apprtc.RUNTIME"; | 100 "org.appspot.apprtc.RUNTIME"; | 
| 101 public static final String EXTRA_VIDEO_FILE_AS_CAMERA = | |
| 102 "org.appspot.apprtc.VIDEO_FILE_AS_CAMERA"; | |
| 103 public static final String EXTRA_VIDEO_FILE_AS_CAMERA_WIDTH = | |
| 
magjed_webrtc
2016/08/31 13:08:03
Why do we have to send width and height separately
 
mandermo
2016/09/16 12:32:30
Video container .yuv does not contain width and he
 
magjed_webrtc
2016/09/16 13:46:25
Ok, then I prefer if we use a container that conta
 
mandermo
2016/09/23 15:12:03
Change to .y4m with width and height and conversio
 | |
| 104 "org.appspot.apprtc.VIDEO_FILE_AS_CAMERA_WIDTH"; | |
| 105 public static final String EXTRA_VIDEO_FILE_AS_CAMERA_HEIGHT = | |
| 106 "org.appspot.apprtc.VIDEO_FILE_AS_CAMERA_HEIGHT"; | |
| 107 public static final String EXTRA_SAVE_REMOTE_VIDEO_TO_FILE = | |
| 108 "org.appspot.apprtc.SAVE_REMOTE_VIDEO_TO_FILE"; | |
| 109 public static final String EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_WIDTH = | |
| 110 "org.appspot.apprtc.SAVE_REMOTE_VIDEO_TO_FILE_WIDTH"; | |
| 111 public static final String EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_HEIGHT = | |
| 112 "org.appspot.apprtc.SAVE_REMOTE_VIDEO_TO_FILE_HEIGHT"; | |
| 99 private static final String TAG = "CallRTCClient"; | 113 private static final String TAG = "CallRTCClient"; | 
| 100 | 114 | 
| 101 // List of mandatory application permissions. | 115 // List of mandatory application permissions. | 
| 102 private static final String[] MANDATORY_PERMISSIONS = { | 116 private static final String[] MANDATORY_PERMISSIONS = { | 
| 103 "android.permission.MODIFY_AUDIO_SETTINGS", | 117 "android.permission.MODIFY_AUDIO_SETTINGS", | 
| 104 "android.permission.RECORD_AUDIO", | 118 "android.permission.RECORD_AUDIO", | 
| 105 "android.permission.INTERNET" | 119 "android.permission.INTERNET" | 
| 106 }; | 120 }; | 
| 107 | 121 | 
| 108 // Peer connection statistics callback period in ms. | 122 // Peer connection statistics callback period in ms. | 
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 View.OnClickListener listener = new View.OnClickListener() { | 200 View.OnClickListener listener = new View.OnClickListener() { | 
| 187 @Override | 201 @Override | 
| 188 public void onClick(View view) { | 202 public void onClick(View view) { | 
| 189 toggleCallControlFragmentVisibility(); | 203 toggleCallControlFragmentVisibility(); | 
| 190 } | 204 } | 
| 191 }; | 205 }; | 
| 192 | 206 | 
| 193 localRender.setOnClickListener(listener); | 207 localRender.setOnClickListener(listener); | 
| 194 remoteRender.setOnClickListener(listener); | 208 remoteRender.setOnClickListener(listener); | 
| 195 | 209 | 
| 210 final Intent intent = getIntent(); | |
| 211 | |
| 196 // Create video renderers. | 212 // Create video renderers. | 
| 197 rootEglBase = EglBase.create(); | 213 rootEglBase = EglBase.create(); | 
| 198 localRender.init(rootEglBase.getEglBaseContext(), null); | 214 localRender.init(rootEglBase.getEglBaseContext(), null); | 
| 199 remoteRender.init(rootEglBase.getEglBaseContext(), null); | 215 String saveRemoteVideoToFile = intent.getStringExtra(EXTRA_SAVE_REMOTE_VIDEO _TO_FILE); | 
| 216 | |
| 217 if (saveRemoteVideoToFile != null) { | |
| 218 int videoOutWidth = intent.getIntExtra(EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_WID TH, 0); | |
| 219 int videoOutHeight = intent.getIntExtra(EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_HE IGHT, 0); | |
| 220 GlVideoFileDrawer drawer = new GlVideoFileDrawer( | |
| 221 saveRemoteVideoToFile, videoOutWidth, videoOutHeight, | |
| 222 rootEglBase.getEglBaseContext(), new GlRectDrawer()); | |
| 223 remoteRender.init(rootEglBase.getEglBaseContext(), null, EglBase.CONFIG_PL AIN, drawer); | |
| 224 } | |
| 225 else { | |
| 226 remoteRender.init(rootEglBase.getEglBaseContext(), null); | |
| 227 } | |
| 200 localRender.setZOrderMediaOverlay(true); | 228 localRender.setZOrderMediaOverlay(true); | 
| 201 updateVideoView(); | 229 updateVideoView(); | 
| 202 | 230 | 
| 203 // Check for mandatory permissions. | 231 // Check for mandatory permissions. | 
| 204 for (String permission : MANDATORY_PERMISSIONS) { | 232 for (String permission : MANDATORY_PERMISSIONS) { | 
| 205 if (checkCallingOrSelfPermission(permission) != PackageManager.PERMISSION_ GRANTED) { | 233 if (checkCallingOrSelfPermission(permission) != PackageManager.PERMISSION_ GRANTED) { | 
| 206 logAndToast("Permission " + permission + " is not granted"); | 234 logAndToast("Permission " + permission + " is not granted"); | 
| 207 setResult(RESULT_CANCELED); | 235 setResult(RESULT_CANCELED); | 
| 208 finish(); | 236 finish(); | 
| 209 return; | 237 return; | 
| 210 } | 238 } | 
| 211 } | 239 } | 
| 212 | 240 | 
| 213 // Get Intent parameters. | 241 // Get Intent parameters. | 
| 214 final Intent intent = getIntent(); | |
| 215 Uri roomUri = intent.getData(); | 242 Uri roomUri = intent.getData(); | 
| 216 if (roomUri == null) { | 243 if (roomUri == null) { | 
| 217 logAndToast(getString(R.string.missing_url)); | 244 logAndToast(getString(R.string.missing_url)); | 
| 218 Log.e(TAG, "Didn't get any URL in intent!"); | 245 Log.e(TAG, "Didn't get any URL in intent!"); | 
| 219 setResult(RESULT_CANCELED); | 246 setResult(RESULT_CANCELED); | 
| 220 finish(); | 247 finish(); | 
| 221 return; | 248 return; | 
| 222 } | 249 } | 
| 223 String roomId = intent.getStringExtra(EXTRA_ROOMID); | 250 String roomId = intent.getStringExtra(EXTRA_ROOMID); | 
| 251 Log.d(TAG, "Room ID: " + roomId); | |
| 224 if (roomId == null || roomId.length() == 0) { | 252 if (roomId == null || roomId.length() == 0) { | 
| 225 logAndToast(getString(R.string.missing_url)); | 253 logAndToast(getString(R.string.missing_url)); | 
| 226 Log.e(TAG, "Incorrect room ID in intent!"); | 254 Log.e(TAG, "Incorrect room ID in intent!"); | 
| 227 setResult(RESULT_CANCELED); | 255 setResult(RESULT_CANCELED); | 
| 228 finish(); | 256 finish(); | 
| 229 return; | 257 return; | 
| 230 } | 258 } | 
| 231 | 259 | 
| 232 boolean loopback = intent.getBooleanExtra(EXTRA_LOOPBACK, false); | 260 boolean loopback = intent.getBooleanExtra(EXTRA_LOOPBACK, false); | 
| 233 boolean tracing = intent.getBooleanExtra(EXTRA_TRACING, false); | 261 boolean tracing = intent.getBooleanExtra(EXTRA_TRACING, false); | 
| (...skipping 14 matching lines...) Expand all Loading... | |
| 248 intent.getBooleanExtra(EXTRA_HWCODEC_ENABLED, true), | 276 intent.getBooleanExtra(EXTRA_HWCODEC_ENABLED, true), | 
| 249 intent.getBooleanExtra(EXTRA_CAPTURETOTEXTURE_ENABLED, false), | 277 intent.getBooleanExtra(EXTRA_CAPTURETOTEXTURE_ENABLED, false), | 
| 250 intent.getIntExtra(EXTRA_AUDIO_BITRATE, 0), | 278 intent.getIntExtra(EXTRA_AUDIO_BITRATE, 0), | 
| 251 intent.getStringExtra(EXTRA_AUDIOCODEC), | 279 intent.getStringExtra(EXTRA_AUDIOCODEC), | 
| 252 intent.getBooleanExtra(EXTRA_NOAUDIOPROCESSING_ENABLED, false), | 280 intent.getBooleanExtra(EXTRA_NOAUDIOPROCESSING_ENABLED, false), | 
| 253 intent.getBooleanExtra(EXTRA_AECDUMP_ENABLED, false), | 281 intent.getBooleanExtra(EXTRA_AECDUMP_ENABLED, false), | 
| 254 intent.getBooleanExtra(EXTRA_OPENSLES_ENABLED, false), | 282 intent.getBooleanExtra(EXTRA_OPENSLES_ENABLED, false), | 
| 255 intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_AEC, false), | 283 intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_AEC, false), | 
| 256 intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_AGC, false), | 284 intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_AGC, false), | 
| 257 intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_NS, false), | 285 intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_NS, false), | 
| 258 intent.getBooleanExtra(EXTRA_ENABLE_LEVEL_CONTROL, false)); | 286 intent.getBooleanExtra(EXTRA_ENABLE_LEVEL_CONTROL, false), | 
| 287 intent.getStringExtra(EXTRA_VIDEO_FILE_AS_CAMERA), | |
| 288 intent.getIntExtra(EXTRA_VIDEO_FILE_AS_CAMERA_WIDTH, 0), | |
| 289 intent.getIntExtra(EXTRA_VIDEO_FILE_AS_CAMERA_HEIGHT, 0)); | |
| 259 commandLineRun = intent.getBooleanExtra(EXTRA_CMDLINE, false); | 290 commandLineRun = intent.getBooleanExtra(EXTRA_CMDLINE, false); | 
| 260 runTimeMs = intent.getIntExtra(EXTRA_RUNTIME, 0); | 291 runTimeMs = intent.getIntExtra(EXTRA_RUNTIME, 0); | 
| 261 | 292 | 
| 293 Log.d(TAG, "VIDEO_FILE: '" + intent.getStringExtra(EXTRA_VIDEO_FILE_AS_CAMER A) + "'"); | |
| 294 | |
| 262 // Create connection client. Use DirectRTCClient if room name is an IP other wise use the | 295 // Create connection client. Use DirectRTCClient if room name is an IP other wise use the | 
| 263 // standard WebSocketRTCClient. | 296 // standard WebSocketRTCClient. | 
| 264 if (loopback || !DirectRTCClient.IP_PATTERN.matcher(roomId).matches()) { | 297 if (loopback || !DirectRTCClient.IP_PATTERN.matcher(roomId).matches()) { | 
| 265 appRtcClient = new WebSocketRTCClient(this); | 298 appRtcClient = new WebSocketRTCClient(this); | 
| 266 } else { | 299 } else { | 
| 267 Log.i(TAG, "Using DirectRTCClient because room name looks like an IP."); | 300 Log.i(TAG, "Using DirectRTCClient because room name looks like an IP."); | 
| 268 appRtcClient = new DirectRTCClient(this); | 301 appRtcClient = new DirectRTCClient(this); | 
| 269 } | 302 } | 
| 270 // Create connection parameters. | 303 // Create connection parameters. | 
| 271 roomConnectionParameters = new RoomConnectionParameters( | 304 roomConnectionParameters = new RoomConnectionParameters( | 
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 725 } | 758 } | 
| 726 } | 759 } | 
| 727 }); | 760 }); | 
| 728 } | 761 } | 
| 729 | 762 | 
| 730 @Override | 763 @Override | 
| 731 public void onPeerConnectionError(final String description) { | 764 public void onPeerConnectionError(final String description) { | 
| 732 reportError(description); | 765 reportError(description); | 
| 733 } | 766 } | 
| 734 } | 767 } | 
| OLD | NEW |