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

Side by Side Diff: webrtc/api/androidtests/src/org/webrtc/VideoCapturerAndroidTestFixtures.java

Issue 2010763003: Android: Add FramerateRange class (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Make constant static Created 4 years, 6 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
« no previous file with comments | « no previous file | webrtc/api/java/android/org/webrtc/CameraEnumerationAndroid.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 package org.webrtc; 10 package org.webrtc;
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 } 282 }
283 283
284 static public void cameraEventsInvoked(VideoCapturerAndroid capturer, CameraEv ents events, 284 static public void cameraEventsInvoked(VideoCapturerAndroid capturer, CameraEv ents events,
285 Context appContext) throws InterruptedException { 285 Context appContext) throws InterruptedException {
286 final List<CaptureFormat> formats = capturer.getSupportedFormats(); 286 final List<CaptureFormat> formats = capturer.getSupportedFormats();
287 final CameraEnumerationAndroid.CaptureFormat format = formats.get(0); 287 final CameraEnumerationAndroid.CaptureFormat format = formats.get(0);
288 288
289 final SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.creat e( 289 final SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.creat e(
290 "SurfaceTextureHelper test" /* threadName */, null /* sharedContext */); 290 "SurfaceTextureHelper test" /* threadName */, null /* sharedContext */);
291 final FakeCapturerObserver observer = new FakeCapturerObserver(); 291 final FakeCapturerObserver observer = new FakeCapturerObserver();
292 capturer.startCapture(format.width, format.height, format.maxFramerate, 292 capturer.startCapture(format.width, format.height, format.framerate.max,
293 surfaceTextureHelper, appContext, observer); 293 surfaceTextureHelper, appContext, observer);
294 // Make sure camera is started and first frame is received and then stop it. 294 // Make sure camera is started and first frame is received and then stop it.
295 assertTrue(observer.WaitForCapturerToStart()); 295 assertTrue(observer.WaitForCapturerToStart());
296 observer.WaitForNextCapturedFrame(); 296 observer.WaitForNextCapturedFrame();
297 capturer.stopCapture(); 297 capturer.stopCapture();
298 if (capturer.isCapturingToTexture()) { 298 if (capturer.isCapturingToTexture()) {
299 surfaceTextureHelper.returnTextureFrame(); 299 surfaceTextureHelper.returnTextureFrame();
300 } 300 }
301 release(capturer); 301 release(capturer);
302 surfaceTextureHelper.dispose(); 302 surfaceTextureHelper.dispose();
303 303
304 assertTrue(events.onCameraOpeningCalled); 304 assertTrue(events.onCameraOpeningCalled);
305 assertTrue(events.onFirstFrameAvailableCalled); 305 assertTrue(events.onFirstFrameAvailableCalled);
306 } 306 }
307 307
308 static public void cameraCallsAfterStop( 308 static public void cameraCallsAfterStop(
309 VideoCapturerAndroid capturer, Context appContext) throws InterruptedExcep tion { 309 VideoCapturerAndroid capturer, Context appContext) throws InterruptedExcep tion {
310 final List<CaptureFormat> formats = capturer.getSupportedFormats(); 310 final List<CaptureFormat> formats = capturer.getSupportedFormats();
311 final CameraEnumerationAndroid.CaptureFormat format = formats.get(0); 311 final CameraEnumerationAndroid.CaptureFormat format = formats.get(0);
312 312
313 final SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.creat e( 313 final SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.creat e(
314 "SurfaceTextureHelper test" /* threadName */, null /* sharedContext */); 314 "SurfaceTextureHelper test" /* threadName */, null /* sharedContext */);
315 final FakeCapturerObserver observer = new FakeCapturerObserver(); 315 final FakeCapturerObserver observer = new FakeCapturerObserver();
316 capturer.startCapture(format.width, format.height, format.maxFramerate, 316 capturer.startCapture(format.width, format.height, format.framerate.max,
317 surfaceTextureHelper, appContext, observer); 317 surfaceTextureHelper, appContext, observer);
318 // Make sure camera is started and then stop it. 318 // Make sure camera is started and then stop it.
319 assertTrue(observer.WaitForCapturerToStart()); 319 assertTrue(observer.WaitForCapturerToStart());
320 capturer.stopCapture(); 320 capturer.stopCapture();
321 if (capturer.isCapturingToTexture()) { 321 if (capturer.isCapturingToTexture()) {
322 surfaceTextureHelper.returnTextureFrame(); 322 surfaceTextureHelper.returnTextureFrame();
323 } 323 }
324 324
325 // We can't change |capturer| at this point, but we should not crash. 325 // We can't change |capturer| at this point, but we should not crash.
326 capturer.switchCamera(null); 326 capturer.switchCamera(null);
(...skipping 29 matching lines...) Expand all
356 356
357 static public void startStopWithDifferentResolutions(VideoCapturerAndroid capt urer, 357 static public void startStopWithDifferentResolutions(VideoCapturerAndroid capt urer,
358 Context appContext) throws InterruptedException { 358 Context appContext) throws InterruptedException {
359 final SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.creat e( 359 final SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.creat e(
360 "SurfaceTextureHelper test" /* threadName */, null /* sharedContext */); 360 "SurfaceTextureHelper test" /* threadName */, null /* sharedContext */);
361 FakeCapturerObserver observer = new FakeCapturerObserver(); 361 FakeCapturerObserver observer = new FakeCapturerObserver();
362 List<CaptureFormat> formats = capturer.getSupportedFormats(); 362 List<CaptureFormat> formats = capturer.getSupportedFormats();
363 363
364 for(int i = 0; i < 3 ; ++i) { 364 for(int i = 0; i < 3 ; ++i) {
365 CameraEnumerationAndroid.CaptureFormat format = formats.get(i); 365 CameraEnumerationAndroid.CaptureFormat format = formats.get(i);
366 capturer.startCapture(format.width, format.height, format.maxFramerate, 366 capturer.startCapture(format.width, format.height, format.framerate.max,
367 surfaceTextureHelper, appContext, observer); 367 surfaceTextureHelper, appContext, observer);
368 assertTrue(observer.WaitForCapturerToStart()); 368 assertTrue(observer.WaitForCapturerToStart());
369 observer.WaitForNextCapturedFrame(); 369 observer.WaitForNextCapturedFrame();
370 370
371 // Check the frame size. The actual width and height depend on how the cap turer is mounted. 371 // Check the frame size. The actual width and height depend on how the cap turer is mounted.
372 final boolean identicalResolution = (observer.frameWidth() == format.width 372 final boolean identicalResolution = (observer.frameWidth() == format.width
373 && observer.frameHeight() == format.height); 373 && observer.frameHeight() == format.height);
374 final boolean flippedResolution = (observer.frameWidth() == format.height 374 final boolean flippedResolution = (observer.frameWidth() == format.height
375 && observer.frameHeight() == format.width); 375 && observer.frameHeight() == format.width);
376 if (!identicalResolution && !flippedResolution) { 376 if (!identicalResolution && !flippedResolution) {
(...skipping 28 matching lines...) Expand all
405 405
406 static public void startWhileCameraIsAlreadyOpen( 406 static public void startWhileCameraIsAlreadyOpen(
407 VideoCapturerAndroid capturer, Context appContext) throws InterruptedExcep tion { 407 VideoCapturerAndroid capturer, Context appContext) throws InterruptedExcep tion {
408 final List<CaptureFormat> formats = capturer.getSupportedFormats(); 408 final List<CaptureFormat> formats = capturer.getSupportedFormats();
409 final CameraEnumerationAndroid.CaptureFormat format = formats.get(0); 409 final CameraEnumerationAndroid.CaptureFormat format = formats.get(0);
410 Camera camera = Camera.open(capturer.getCurrentCameraId()); 410 Camera camera = Camera.open(capturer.getCurrentCameraId());
411 411
412 final SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.creat e( 412 final SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.creat e(
413 "SurfaceTextureHelper test" /* threadName */, null /* sharedContext */); 413 "SurfaceTextureHelper test" /* threadName */, null /* sharedContext */);
414 final FakeCapturerObserver observer = new FakeCapturerObserver(); 414 final FakeCapturerObserver observer = new FakeCapturerObserver();
415 capturer.startCapture(format.width, format.height, format.maxFramerate, 415 capturer.startCapture(format.width, format.height, format.framerate.max,
416 surfaceTextureHelper, appContext, observer); 416 surfaceTextureHelper, appContext, observer);
417 417
418 if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.LOLLIP OP_MR1) { 418 if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.LOLLIP OP_MR1) {
419 // The first opened camera client will be evicted. 419 // The first opened camera client will be evicted.
420 assertTrue(observer.WaitForCapturerToStart()); 420 assertTrue(observer.WaitForCapturerToStart());
421 capturer.stopCapture(); 421 capturer.stopCapture();
422 } else { 422 } else {
423 assertFalse(observer.WaitForCapturerToStart()); 423 assertFalse(observer.WaitForCapturerToStart());
424 } 424 }
425 425
426 release(capturer); 426 release(capturer);
427 camera.release(); 427 camera.release();
428 surfaceTextureHelper.dispose(); 428 surfaceTextureHelper.dispose();
429 } 429 }
430 430
431 static public void startWhileCameraIsAlreadyOpenAndCloseCamera( 431 static public void startWhileCameraIsAlreadyOpenAndCloseCamera(
432 VideoCapturerAndroid capturer, Context appContext) throws InterruptedExcep tion { 432 VideoCapturerAndroid capturer, Context appContext) throws InterruptedExcep tion {
433 final List<CaptureFormat> formats = capturer.getSupportedFormats(); 433 final List<CaptureFormat> formats = capturer.getSupportedFormats();
434 final CameraEnumerationAndroid.CaptureFormat format = formats.get(0); 434 final CameraEnumerationAndroid.CaptureFormat format = formats.get(0);
435 Camera camera = Camera.open(capturer.getCurrentCameraId()); 435 Camera camera = Camera.open(capturer.getCurrentCameraId());
436 436
437 final SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.creat e( 437 final SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.creat e(
438 "SurfaceTextureHelper test" /* threadName */, null /* sharedContext */); 438 "SurfaceTextureHelper test" /* threadName */, null /* sharedContext */);
439 final FakeCapturerObserver observer = new FakeCapturerObserver(); 439 final FakeCapturerObserver observer = new FakeCapturerObserver();
440 capturer.startCapture(format.width, format.height, format.maxFramerate, 440 capturer.startCapture(format.width, format.height, format.framerate.max,
441 surfaceTextureHelper, appContext, observer); 441 surfaceTextureHelper, appContext, observer);
442 waitUntilIdle(capturer); 442 waitUntilIdle(capturer);
443 443
444 camera.release(); 444 camera.release();
445 445
446 // Make sure camera is started and first frame is received and then stop it. 446 // Make sure camera is started and first frame is received and then stop it.
447 assertTrue(observer.WaitForCapturerToStart()); 447 assertTrue(observer.WaitForCapturerToStart());
448 observer.WaitForNextCapturedFrame(); 448 observer.WaitForNextCapturedFrame();
449 capturer.stopCapture(); 449 capturer.stopCapture();
450 if (capturer.isCapturingToTexture()) { 450 if (capturer.isCapturingToTexture()) {
451 surfaceTextureHelper.returnTextureFrame(); 451 surfaceTextureHelper.returnTextureFrame();
452 } 452 }
453 release(capturer); 453 release(capturer);
454 surfaceTextureHelper.dispose(); 454 surfaceTextureHelper.dispose();
455 } 455 }
456 456
457 static public void startWhileCameraIsAlreadyOpenAndStop( 457 static public void startWhileCameraIsAlreadyOpenAndStop(
458 VideoCapturerAndroid capturer, Context appContext) throws InterruptedExcep tion { 458 VideoCapturerAndroid capturer, Context appContext) throws InterruptedExcep tion {
459 final List<CaptureFormat> formats = capturer.getSupportedFormats(); 459 final List<CaptureFormat> formats = capturer.getSupportedFormats();
460 final CameraEnumerationAndroid.CaptureFormat format = formats.get(0); 460 final CameraEnumerationAndroid.CaptureFormat format = formats.get(0);
461 Camera camera = Camera.open(capturer.getCurrentCameraId()); 461 Camera camera = Camera.open(capturer.getCurrentCameraId());
462 462
463 final SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.creat e( 463 final SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.creat e(
464 "SurfaceTextureHelper test" /* threadName */, null /* sharedContext */); 464 "SurfaceTextureHelper test" /* threadName */, null /* sharedContext */);
465 final FakeCapturerObserver observer = new FakeCapturerObserver(); 465 final FakeCapturerObserver observer = new FakeCapturerObserver();
466 capturer.startCapture(format.width, format.height, format.maxFramerate, 466 capturer.startCapture(format.width, format.height, format.framerate.max,
467 surfaceTextureHelper, appContext, observer); 467 surfaceTextureHelper, appContext, observer);
468 capturer.stopCapture(); 468 capturer.stopCapture();
469 release(capturer); 469 release(capturer);
470 camera.release(); 470 camera.release();
471 surfaceTextureHelper.dispose(); 471 surfaceTextureHelper.dispose();
472 } 472 }
473 473
474 static public void returnBufferLate(VideoCapturerAndroid capturer, 474 static public void returnBufferLate(VideoCapturerAndroid capturer,
475 Context appContext) throws InterruptedException { 475 Context appContext) throws InterruptedException {
476 final SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.creat e( 476 final SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.creat e(
477 "SurfaceTextureHelper test" /* threadName */, null /* sharedContext */); 477 "SurfaceTextureHelper test" /* threadName */, null /* sharedContext */);
478 FakeCapturerObserver observer = new FakeCapturerObserver(); 478 FakeCapturerObserver observer = new FakeCapturerObserver();
479 479
480 List<CaptureFormat> formats = capturer.getSupportedFormats(); 480 List<CaptureFormat> formats = capturer.getSupportedFormats();
481 CameraEnumerationAndroid.CaptureFormat format = formats.get(0); 481 CameraEnumerationAndroid.CaptureFormat format = formats.get(0);
482 capturer.startCapture(format.width, format.height, format.maxFramerate, 482 capturer.startCapture(format.width, format.height, format.framerate.max,
483 surfaceTextureHelper, appContext, observer); 483 surfaceTextureHelper, appContext, observer);
484 assertTrue(observer.WaitForCapturerToStart()); 484 assertTrue(observer.WaitForCapturerToStart());
485 485
486 observer.WaitForNextCapturedFrame(); 486 observer.WaitForNextCapturedFrame();
487 capturer.stopCapture(); 487 capturer.stopCapture();
488 List<Long> listOftimestamps = observer.getCopyAndResetListOftimeStamps(); 488 List<Long> listOftimestamps = observer.getCopyAndResetListOftimeStamps();
489 assertTrue(listOftimestamps.size() >= 1); 489 assertTrue(listOftimestamps.size() >= 1);
490 490
491 format = formats.get(1); 491 format = formats.get(1);
492 capturer.startCapture(format.width, format.height, format.maxFramerate, 492 capturer.startCapture(format.width, format.height, format.framerate.max,
493 surfaceTextureHelper, appContext, observer); 493 surfaceTextureHelper, appContext, observer);
494 observer.WaitForCapturerToStart(); 494 observer.WaitForCapturerToStart();
495 if (capturer.isCapturingToTexture()) { 495 if (capturer.isCapturingToTexture()) {
496 surfaceTextureHelper.returnTextureFrame(); 496 surfaceTextureHelper.returnTextureFrame();
497 } 497 }
498 498
499 observer.WaitForNextCapturedFrame(); 499 observer.WaitForNextCapturedFrame();
500 capturer.stopCapture(); 500 capturer.stopCapture();
501 501
502 listOftimestamps = observer.getCopyAndResetListOftimeStamps(); 502 listOftimestamps = observer.getCopyAndResetListOftimeStamps();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 VideoCapturerAndroid capturer, 546 VideoCapturerAndroid capturer,
547 CameraEvents events, Context appContext) throws InterruptedException { 547 CameraEvents events, Context appContext) throws InterruptedException {
548 assertTrue("Not capturing to textures.", capturer.isCapturingToTexture()); 548 assertTrue("Not capturing to textures.", capturer.isCapturingToTexture());
549 549
550 final List<CaptureFormat> formats = capturer.getSupportedFormats(); 550 final List<CaptureFormat> formats = capturer.getSupportedFormats();
551 final CameraEnumerationAndroid.CaptureFormat format = formats.get(0); 551 final CameraEnumerationAndroid.CaptureFormat format = formats.get(0);
552 552
553 final SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.creat e( 553 final SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.creat e(
554 "SurfaceTextureHelper test" /* threadName */, null /* sharedContext */); 554 "SurfaceTextureHelper test" /* threadName */, null /* sharedContext */);
555 final FakeCapturerObserver observer = new FakeCapturerObserver(); 555 final FakeCapturerObserver observer = new FakeCapturerObserver();
556 capturer.startCapture(format.width, format.height, format.maxFramerate, 556 capturer.startCapture(format.width, format.height, format.framerate.max,
557 surfaceTextureHelper, appContext, observer); 557 surfaceTextureHelper, appContext, observer);
558 // Make sure camera is started. 558 // Make sure camera is started.
559 assertTrue(observer.WaitForCapturerToStart()); 559 assertTrue(observer.WaitForCapturerToStart());
560 // Since we don't return the buffer, we should get a starvation message if w e are 560 // Since we don't return the buffer, we should get a starvation message if w e are
561 // capturing to a texture. 561 // capturing to a texture.
562 assertEquals("Camera failure. Client must return video buffers.", 562 assertEquals("Camera failure. Client must return video buffers.",
563 events.WaitForCameraFreezed()); 563 events.WaitForCameraFreezed());
564 564
565 capturer.stopCapture(); 565 capturer.stopCapture();
566 if (capturer.isCapturingToTexture()) { 566 if (capturer.isCapturingToTexture()) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 source.stop(); 603 source.stop();
604 track.dispose(); 604 track.dispose();
605 source.dispose(); 605 source.dispose();
606 factory.dispose(); 606 factory.dispose();
607 assertTrue(capturer.isDisposed()); 607 assertTrue(capturer.isDisposed());
608 608
609 assertTrue(gotExpectedResolution); 609 assertTrue(gotExpectedResolution);
610 } 610 }
611 611
612 } 612 }
OLDNEW
« no previous file with comments | « no previous file | webrtc/api/java/android/org/webrtc/CameraEnumerationAndroid.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698