Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: webrtc/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java

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
Patch Set: Added file to start automated loopback run Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2014 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 22 matching lines...) Expand all
33 import org.webrtc.MediaStream; 33 import org.webrtc.MediaStream;
34 import org.webrtc.PeerConnection; 34 import org.webrtc.PeerConnection;
35 import org.webrtc.PeerConnection.IceConnectionState; 35 import org.webrtc.PeerConnection.IceConnectionState;
36 import org.webrtc.PeerConnectionFactory; 36 import org.webrtc.PeerConnectionFactory;
37 import org.webrtc.SdpObserver; 37 import org.webrtc.SdpObserver;
38 import org.webrtc.SessionDescription; 38 import org.webrtc.SessionDescription;
39 import org.webrtc.StatsObserver; 39 import org.webrtc.StatsObserver;
40 import org.webrtc.StatsReport; 40 import org.webrtc.StatsReport;
41 import org.webrtc.VideoCapturer; 41 import org.webrtc.VideoCapturer;
42 import org.webrtc.VideoRenderer; 42 import org.webrtc.VideoRenderer;
43 import org.webrtc.VideoCapturerAndroid;
44 import org.webrtc.CameraVideoCapturer;
45 import org.webrtc.FileVideoCapturer;
43 import org.webrtc.VideoSource; 46 import org.webrtc.VideoSource;
44 import org.webrtc.VideoTrack; 47 import org.webrtc.VideoTrack;
45 import org.webrtc.voiceengine.WebRtcAudioManager; 48 import org.webrtc.voiceengine.WebRtcAudioManager;
46 import org.webrtc.voiceengine.WebRtcAudioUtils; 49 import org.webrtc.voiceengine.WebRtcAudioUtils;
47 50
48 import java.io.File; 51 import java.io.File;
49 import java.io.IOException; 52 import java.io.IOException;
50 import java.util.EnumSet; 53 import java.util.EnumSet;
51 import java.util.LinkedList; 54 import java.util.LinkedList;
52 import java.util.Timer; 55 import java.util.Timer;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 public final boolean captureToTexture; 159 public final boolean captureToTexture;
157 public final int audioStartBitrate; 160 public final int audioStartBitrate;
158 public final String audioCodec; 161 public final String audioCodec;
159 public final boolean noAudioProcessing; 162 public final boolean noAudioProcessing;
160 public final boolean aecDump; 163 public final boolean aecDump;
161 public final boolean useOpenSLES; 164 public final boolean useOpenSLES;
162 public final boolean disableBuiltInAEC; 165 public final boolean disableBuiltInAEC;
163 public final boolean disableBuiltInAGC; 166 public final boolean disableBuiltInAGC;
164 public final boolean disableBuiltInNS; 167 public final boolean disableBuiltInNS;
165 public final boolean enableLevelControl; 168 public final boolean enableLevelControl;
169 public final String videoFileAsCamera;
170 public final int videoFileAsCameraWidth;
171 public final int videoFileAsCameraHeight;
166 172
167 public PeerConnectionParameters( 173 public PeerConnectionParameters(
168 boolean videoCallEnabled, boolean loopback, boolean tracing, boolean use Camera2, 174 boolean videoCallEnabled, boolean loopback, boolean tracing, boolean use Camera2,
169 int videoWidth, int videoHeight, int videoFps, 175 int videoWidth, int videoHeight, int videoFps,
170 int videoStartBitrate, String videoCodec, boolean videoCodecHwAccelerati on, 176 int videoStartBitrate, String videoCodec, boolean videoCodecHwAccelerati on,
171 boolean captureToTexture, int audioStartBitrate, String audioCodec, 177 boolean captureToTexture, int audioStartBitrate, String audioCodec,
172 boolean noAudioProcessing, boolean aecDump, boolean useOpenSLES, 178 boolean noAudioProcessing, boolean aecDump, boolean useOpenSLES,
173 boolean disableBuiltInAEC, boolean disableBuiltInAGC, boolean disableBui ltInNS, 179 boolean disableBuiltInAEC, boolean disableBuiltInAGC, boolean disableBui ltInNS,
174 boolean enableLevelControl) { 180 boolean enableLevelControl,
181 String videoFileAsCamera, int videoFileAsCameraWidth, int videoFileAsCam eraHeight) {
182
175 this.videoCallEnabled = videoCallEnabled; 183 this.videoCallEnabled = videoCallEnabled;
176 this.useCamera2 = useCamera2; 184 this.useCamera2 = useCamera2;
177 this.loopback = loopback; 185 this.loopback = loopback;
178 this.tracing = tracing; 186 this.tracing = tracing;
179 this.videoWidth = videoWidth; 187 this.videoWidth = videoWidth;
180 this.videoHeight = videoHeight; 188 this.videoHeight = videoHeight;
181 this.videoFps = videoFps; 189 this.videoFps = videoFps;
182 this.videoStartBitrate = videoStartBitrate; 190 this.videoStartBitrate = videoStartBitrate;
183 this.videoCodec = videoCodec; 191 this.videoCodec = videoCodec;
184 this.videoCodecHwAcceleration = videoCodecHwAcceleration; 192 this.videoCodecHwAcceleration = videoCodecHwAcceleration;
185 this.captureToTexture = captureToTexture; 193 this.captureToTexture = captureToTexture;
186 this.audioStartBitrate = audioStartBitrate; 194 this.audioStartBitrate = audioStartBitrate;
187 this.audioCodec = audioCodec; 195 this.audioCodec = audioCodec;
188 this.noAudioProcessing = noAudioProcessing; 196 this.noAudioProcessing = noAudioProcessing;
189 this.aecDump = aecDump; 197 this.aecDump = aecDump;
190 this.useOpenSLES = useOpenSLES; 198 this.useOpenSLES = useOpenSLES;
191 this.disableBuiltInAEC = disableBuiltInAEC; 199 this.disableBuiltInAEC = disableBuiltInAEC;
192 this.disableBuiltInAGC = disableBuiltInAGC; 200 this.disableBuiltInAGC = disableBuiltInAGC;
193 this.disableBuiltInNS = disableBuiltInNS; 201 this.disableBuiltInNS = disableBuiltInNS;
194 this.enableLevelControl = enableLevelControl; 202 this.enableLevelControl = enableLevelControl;
203 this.videoFileAsCamera = videoFileAsCamera;
204 this.videoFileAsCameraWidth = videoFileAsCameraWidth;
205 this.videoFileAsCameraHeight = videoFileAsCameraHeight;
195 } 206 }
196 } 207 }
197 208
198 /** 209 /**
199 * Peer connection events. 210 * Peer connection events.
200 */ 211 */
201 public interface PeerConnectionEvents { 212 public interface PeerConnectionEvents {
202 /** 213 /**
203 * Callback fired once local SDP is created and set. 214 * Callback fired once local SDP is created and set.
204 */ 215 */
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 reportError(context.getString(R.string.camera2_texture_only_error)); 561 reportError(context.getString(R.string.camera2_texture_only_error));
551 return; 562 return;
552 } 563 }
553 564
554 Logging.d(TAG, "Creating capturer using camera2 API."); 565 Logging.d(TAG, "Creating capturer using camera2 API.");
555 createCapturer(new Camera2Enumerator(context)); 566 createCapturer(new Camera2Enumerator(context));
556 } else { 567 } else {
557 Logging.d(TAG, "Creating capturer using camera1 API."); 568 Logging.d(TAG, "Creating capturer using camera1 API.");
558 createCapturer(new Camera1Enumerator(peerConnectionParameters.captureToT exture)); 569 createCapturer(new Camera1Enumerator(peerConnectionParameters.captureToT exture));
559 } 570 }
560
561 if (videoCapturer == null) { 571 if (videoCapturer == null) {
562 reportError("Failed to open camera"); 572 reportError("Failed to open camera");
563 return; 573 return;
564 } 574 }
575 if (peerConnectionParameters.videoFileAsCamera != null) {
576 CameraVideoCapturer fileVideoCapturer = FileVideoCapturer.create(
577 new File(peerConnectionParameters.videoFileAsCamera),
578 peerConnectionParameters.videoFileAsCameraWidth,
579 peerConnectionParameters.videoFileAsCameraHeight,
580 videoCapturer);
581
582 if (fileVideoCapturer == null) {
583 Log.d(TAG, "Failed to open video file for emulated camera");
584 reportError("Failed to open video file for emulated camera");
585 return;
586 }
587 else {
588 videoCapturer = fileVideoCapturer;
589 }
590 }
565 mediaStream.addTrack(createVideoTrack(videoCapturer)); 591 mediaStream.addTrack(createVideoTrack(videoCapturer));
566 } 592 }
567 593
568 mediaStream.addTrack(createAudioTrack()); 594 mediaStream.addTrack(createAudioTrack());
569 peerConnection.addStream(mediaStream); 595 peerConnection.addStream(mediaStream);
570 596
571 if (peerConnectionParameters.aecDump) { 597 if (peerConnectionParameters.aecDump) {
572 try { 598 try {
573 aecDumpFileDescriptor = ParcelFileDescriptor.open( 599 aecDumpFileDescriptor = ParcelFileDescriptor.open(
574 new File(Environment.getExternalStorageDirectory().getPath() 600 new File(Environment.getExternalStorageDirectory().getPath()
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 public void onCreateFailure(final String error) { 1223 public void onCreateFailure(final String error) {
1198 reportError("createSDP error: " + error); 1224 reportError("createSDP error: " + error);
1199 } 1225 }
1200 1226
1201 @Override 1227 @Override
1202 public void onSetFailure(final String error) { 1228 public void onSetFailure(final String error) {
1203 reportError("setSDP error: " + error); 1229 reportError("setSDP error: " + error);
1204 } 1230 }
1205 } 1231 }
1206 } 1232 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698