001// Copyright (c) FIRST and other WPILib contributors. 002// Open Source Software; you can modify and/or share it under the terms of 003// the WPILib BSD license file in the root directory of this project. 004 005package edu.wpi.first.cscore; 006 007import edu.wpi.first.util.RawFrame; 008import edu.wpi.first.util.RuntimeLoader; 009import java.io.IOException; 010import java.nio.ByteBuffer; 011import java.util.concurrent.atomic.AtomicBoolean; 012import java.util.function.Consumer; 013 014/** CameraServer JNI. */ 015public class CameraServerJNI { 016 static boolean libraryLoaded = false; 017 018 /** Sets whether JNI should be loaded in the static block. */ 019 public static class Helper { 020 private static AtomicBoolean extractOnStaticLoad = new AtomicBoolean(true); 021 022 /** 023 * Returns true if the JNI should be loaded in the static block. 024 * 025 * @return True if the JNI should be loaded in the static block. 026 */ 027 public static boolean getExtractOnStaticLoad() { 028 return extractOnStaticLoad.get(); 029 } 030 031 /** 032 * Sets whether the JNI should be loaded in the static block. 033 * 034 * @param load Whether the JNI should be loaded in the static block. 035 */ 036 public static void setExtractOnStaticLoad(boolean load) { 037 extractOnStaticLoad.set(load); 038 } 039 040 /** Utility class. */ 041 private Helper() {} 042 } 043 044 static { 045 if (Helper.getExtractOnStaticLoad()) { 046 try { 047 RuntimeLoader.loadLibrary("cscorejni"); 048 } catch (IOException ex) { 049 ex.printStackTrace(); 050 System.exit(1); 051 } 052 libraryLoaded = true; 053 } 054 } 055 056 /** 057 * Force load the library. 058 * 059 * @throws IOException if library load failed 060 */ 061 public static synchronized void forceLoad() throws IOException { 062 if (libraryLoaded) { 063 return; 064 } 065 RuntimeLoader.loadLibrary("cscorejni"); 066 libraryLoaded = true; 067 } 068 069 // 070 // Property Functions 071 // 072 073 /** 074 * Returns property kind. 075 * 076 * @param property Property handle. 077 * @return Property kind. 078 */ 079 public static native int getPropertyKind(int property); 080 081 /** 082 * Returns property name. 083 * 084 * @param property Property handle. 085 * @return Property name. 086 */ 087 public static native String getPropertyName(int property); 088 089 /** 090 * Returns property value. 091 * 092 * @param property Property handle. 093 * @return Property value. 094 */ 095 public static native int getProperty(int property); 096 097 /** 098 * Sets property value. 099 * 100 * @param property Property handle. 101 * @param value Property value. 102 */ 103 public static native void setProperty(int property, int value); 104 105 /** 106 * Returns property minimum. 107 * 108 * @param property Property handle. 109 * @return Property minimum. 110 */ 111 public static native int getPropertyMin(int property); 112 113 /** 114 * Returns property maximum. 115 * 116 * @param property Property handle. 117 * @return Property maximum. 118 */ 119 public static native int getPropertyMax(int property); 120 121 /** 122 * Returns property step. 123 * 124 * @param property Property handle. 125 * @return Property step. 126 */ 127 public static native int getPropertyStep(int property); 128 129 /** 130 * Returns property default value. 131 * 132 * @param property Property handle. 133 * @return Property default value. 134 */ 135 public static native int getPropertyDefault(int property); 136 137 /** 138 * Returns property value as a string. 139 * 140 * @param property Property handle. 141 * @return Property value as a string. 142 */ 143 public static native String getStringProperty(int property); 144 145 /** 146 * Sets property value to a string. 147 * 148 * @param property Property handle. 149 * @param value Property value string. 150 */ 151 public static native void setStringProperty(int property, String value); 152 153 /** 154 * Returns enum of possible property value strings. 155 * 156 * @param property Property handle. 157 * @return Enum of possible property value strings. 158 */ 159 public static native String[] getEnumPropertyChoices(int property); 160 161 // 162 // Source Creation Functions 163 // 164 165 /** 166 * Creates a new USB camera by device. 167 * 168 * @param name USB camera name. 169 * @param dev USB camera device number. 170 * @return USB camera handle. 171 */ 172 public static native int createUsbCameraDev(String name, int dev); 173 174 /** 175 * Creates a new USB camera by path. 176 * 177 * @param name USB camera name. 178 * @param path USB camera path. 179 * @return USB camera handle. 180 */ 181 public static native int createUsbCameraPath(String name, String path); 182 183 /** 184 * Creates an HTTP camera. 185 * 186 * @param name HTTP camera name. 187 * @param url HTTP camera stream URL. 188 * @param kind HTTP camera kind. 189 * @return HTTP camera handle. 190 */ 191 public static native int createHttpCamera(String name, String url, int kind); 192 193 /** 194 * Creates an HTTP camera from multiple URLs. 195 * 196 * @param name HTTP camera name. 197 * @param urls HTTP camera stream URLs. 198 * @param kind HTTP camera kind. 199 * @return HTTP camera handle. 200 */ 201 public static native int createHttpCameraMulti(String name, String[] urls, int kind); 202 203 /** 204 * Creates a raw source. 205 * 206 * @param name Source name. 207 * @param isCv true for a Cv source. 208 * @param pixelFormat Pixel format. 209 * @param width Image width. 210 * @param height Image height. 211 * @param fps Source frames per second. 212 * @return Raw source handle. 213 */ 214 public static native int createRawSource( 215 String name, boolean isCv, int pixelFormat, int width, int height, int fps); 216 217 // 218 // Source Functions 219 // 220 221 /** 222 * Returns source kind. 223 * 224 * @param source Source handle. 225 * @return Source kind. 226 */ 227 public static native int getSourceKind(int source); 228 229 /** 230 * Returns source name. 231 * 232 * @param source Source handle. 233 * @return Source name. 234 */ 235 public static native String getSourceName(int source); 236 237 /** 238 * Returns source description. 239 * 240 * @param source Source handle. 241 * @return Source description. 242 */ 243 public static native String getSourceDescription(int source); 244 245 /** 246 * Returns source's last frame time. 247 * 248 * @param source Source handle. 249 * @return Source's last frame time. 250 */ 251 public static native long getSourceLastFrameTime(int source); 252 253 /** 254 * Sets source connection strategy. 255 * 256 * @param source Source handle. 257 * @param strategy Connection strategy. 258 */ 259 public static native void setSourceConnectionStrategy(int source, int strategy); 260 261 /** 262 * Returns true if source is connected. 263 * 264 * @param source Source handle. 265 * @return True if source is connected. 266 */ 267 public static native boolean isSourceConnected(int source); 268 269 /** 270 * Returns true if source is enabled. 271 * 272 * @param source Source handle. 273 * @return True if source is enabled. 274 */ 275 public static native boolean isSourceEnabled(int source); 276 277 /** 278 * Returns source property. 279 * 280 * @param source Source handle. 281 * @param name Source property name. 282 * @return Source property. 283 */ 284 public static native int getSourceProperty(int source, String name); 285 286 /** 287 * Returns list of source property handles. 288 * 289 * @param source Source handle. 290 * @return List of source property handles. 291 */ 292 public static native int[] enumerateSourceProperties(int source); 293 294 /** 295 * Returns source video mode. 296 * 297 * @param source Source handle. 298 * @return Source video mode. 299 */ 300 public static native VideoMode getSourceVideoMode(int source); 301 302 /** 303 * Sets source video mode. 304 * 305 * @param source Source handle. 306 * @param pixelFormat Pixel format. 307 * @param width Image width. 308 * @param height Image height. 309 * @param fps Source frames per second. 310 * @return True if set succeeded. 311 */ 312 public static native boolean setSourceVideoMode( 313 int source, int pixelFormat, int width, int height, int fps); 314 315 /** 316 * Sets source pixel format. 317 * 318 * @param source Source handle. 319 * @param pixelFormat Source pixel format. 320 * @return True if set succeeded. 321 */ 322 public static native boolean setSourcePixelFormat(int source, int pixelFormat); 323 324 /** 325 * Sets source resolution. 326 * 327 * @param source Source handle. 328 * @param width Image width. 329 * @param height Image height. 330 * @return True if set succeeded. 331 */ 332 public static native boolean setSourceResolution(int source, int width, int height); 333 334 /** 335 * Sets source FPS. 336 * 337 * @param source Source handle. 338 * @param fps Source frames per second. 339 * @return True if set succeeded. 340 */ 341 public static native boolean setSourceFPS(int source, int fps); 342 343 /** 344 * Sets source configuration JSON. 345 * 346 * @param source Source handle. 347 * @param config Configuration JSON. 348 * @return True if set succeeded. 349 */ 350 public static native boolean setSourceConfigJson(int source, String config); 351 352 /** 353 * Returns source configuration JSON. 354 * 355 * @param source Source handle. 356 * @return Source configuration JSON. 357 */ 358 public static native String getSourceConfigJson(int source); 359 360 /** 361 * Returns list of source's supported video modes. 362 * 363 * @param source Source handle. 364 * @return List of source's supported video modes. 365 */ 366 public static native VideoMode[] enumerateSourceVideoModes(int source); 367 368 /** 369 * Returns list of source sinks. 370 * 371 * @param source Source handle. 372 * @return List of source sinks. 373 */ 374 public static native int[] enumerateSourceSinks(int source); 375 376 /** 377 * Copies source. 378 * 379 * @param source Source handle. 380 * @return New source handle. 381 */ 382 public static native int copySource(int source); 383 384 /** 385 * Releases source. 386 * 387 * @param source Source handle. 388 */ 389 public static native void releaseSource(int source); 390 391 // 392 // Camera Source Common Property Functions 393 // 394 395 /** 396 * Sets camera brightness. 397 * 398 * @param source Source handle. 399 * @param brightness Brightness. 400 */ 401 public static native void setCameraBrightness(int source, int brightness); 402 403 /** 404 * Returns camera brightness. 405 * 406 * @param source Source handle. 407 * @return Camera brightness. 408 */ 409 public static native int getCameraBrightness(int source); 410 411 /** 412 * Sets camera white balance to auto. 413 * 414 * @param source Source handle. 415 */ 416 public static native void setCameraWhiteBalanceAuto(int source); 417 418 /** 419 * Sets camera white balance to "hold current". 420 * 421 * @param source Source handle. 422 */ 423 public static native void setCameraWhiteBalanceHoldCurrent(int source); 424 425 /** 426 * Sets camera white balance to the given value. 427 * 428 * @param source Source handle. 429 * @param value White balance. 430 */ 431 public static native void setCameraWhiteBalanceManual(int source, int value); 432 433 /** 434 * Sets camera exposure to auto. 435 * 436 * @param source Source handle. 437 */ 438 public static native void setCameraExposureAuto(int source); 439 440 /** 441 * Sets camera exposure to "hold current". 442 * 443 * @param source Source handle. 444 */ 445 public static native void setCameraExposureHoldCurrent(int source); 446 447 /** 448 * Sets camera exposure to the given value. 449 * 450 * @param source Source handle. 451 * @param value Exposure. 452 */ 453 public static native void setCameraExposureManual(int source, int value); 454 455 // 456 // UsbCamera Source Functions 457 // 458 459 /** 460 * Sets USB camera path. 461 * 462 * @param source Source handle. 463 * @param path USB camera path. 464 */ 465 public static native void setUsbCameraPath(int source, String path); 466 467 /** 468 * Returns USB camera path. 469 * 470 * @param source Source handle. 471 * @return USB camera path. 472 */ 473 public static native String getUsbCameraPath(int source); 474 475 /** 476 * Returns USB camera info. 477 * 478 * @param source Source handle. 479 * @return USB camera info. 480 */ 481 public static native UsbCameraInfo getUsbCameraInfo(int source); 482 483 // 484 // HttpCamera Source Functions 485 // 486 487 /** 488 * Returns HTTP camera kind. 489 * 490 * @param source Source handle. 491 * @return HTTP camera kind. 492 */ 493 public static native int getHttpCameraKind(int source); 494 495 /** 496 * Sets HTTP camera URLs. 497 * 498 * @param source Source handle. 499 * @param urls HTTP camera URLs. 500 */ 501 public static native void setHttpCameraUrls(int source, String[] urls); 502 503 /** 504 * Returns HTTP camera URLs. 505 * 506 * @param source Source handle. 507 * @return HTTP camera URLs. 508 */ 509 public static native String[] getHttpCameraUrls(int source); 510 511 // 512 // Image Source Functions 513 // 514 515 /** 516 * Puts raw frame into source. 517 * 518 * @param source Source handle. 519 * @param frame Frame handle. 520 */ 521 public static native void putRawSourceFrame(int source, long frame); 522 523 /** 524 * Puts raw frame into source. 525 * 526 * @param source Source handle. 527 * @param data Frame byte buffer. 528 * @param size Frame size. 529 * @param width Frame width. 530 * @param height Frame height. 531 * @param stride Frame stride. 532 * @param pixelFormat Frame pixel format. 533 */ 534 public static native void putRawSourceFrameBB( 535 int source, ByteBuffer data, int size, int width, int height, int stride, int pixelFormat); 536 537 /** 538 * Puts raw frame into source. 539 * 540 * @param source Source handle. 541 * @param data Frame handle. 542 * @param size Frame size. 543 * @param width Frame width. 544 * @param height Frame height. 545 * @param stride Frame stride. 546 * @param pixelFormat Frame pixel format. 547 */ 548 public static native void putRawSourceFrameData( 549 int source, long data, int size, int width, int height, int stride, int pixelFormat); 550 551 /** 552 * Notify source error. 553 * 554 * @param source Source handle. 555 * @param msg Error message. 556 */ 557 public static native void notifySourceError(int source, String msg); 558 559 /** 560 * Sets whether source is connected. 561 * 562 * @param source Source handle. 563 * @param connected True if source is connected. 564 */ 565 public static native void setSourceConnected(int source, boolean connected); 566 567 /** 568 * Sets source description. 569 * 570 * @param source Source handle. 571 * @param description Source description. 572 */ 573 public static native void setSourceDescription(int source, String description); 574 575 /** 576 * Creates a source property. 577 * 578 * @param source Source handle. 579 * @param name Property name. 580 * @param kind Property kind. 581 * @param minimum Property minimum. 582 * @param maximum Property maximum. 583 * @param step Property step. 584 * @param defaultValue Property default value. 585 * @param value Property value. 586 * @return Source property handle. 587 */ 588 public static native int createSourceProperty( 589 int source, 590 String name, 591 int kind, 592 int minimum, 593 int maximum, 594 int step, 595 int defaultValue, 596 int value); 597 598 /** 599 * Sets list of possible property values. 600 * 601 * @param source Source handle. 602 * @param property Property handle. 603 * @param choices List of possible property values. 604 */ 605 public static native void setSourceEnumPropertyChoices( 606 int source, int property, String[] choices); 607 608 // 609 // Sink Creation Functions 610 // 611 612 /** 613 * Creates an MJPEG server. 614 * 615 * @param name MJPEG server name. 616 * @param listenAddress IP address at which server should listen. 617 * @param port Port on which server should listen. 618 * @return MJPEG server handle. 619 */ 620 public static native int createMjpegServer(String name, String listenAddress, int port); 621 622 /** 623 * Creates a raw sink. 624 * 625 * @param name Sink name. 626 * @param isCv true for a Cv source. 627 * @return Raw sink handle. 628 */ 629 public static native int createRawSink(String name, boolean isCv); 630 631 // 632 // Sink Functions 633 // 634 635 /** 636 * Returns sink kind. 637 * 638 * @param sink Sink handle. 639 * @return Sink kind. 640 */ 641 public static native int getSinkKind(int sink); 642 643 /** 644 * Returns sink name. 645 * 646 * @param sink Sink handle. 647 * @return Sink name. 648 */ 649 public static native String getSinkName(int sink); 650 651 /** 652 * Returns sink description. 653 * 654 * @param sink Sink handle. 655 * @return Sink description. 656 */ 657 public static native String getSinkDescription(int sink); 658 659 /** 660 * Returns sink property. 661 * 662 * @param sink Sink handle. 663 * @param name Property name. 664 * @return Sink property handle. 665 */ 666 public static native int getSinkProperty(int sink, String name); 667 668 /** 669 * Returns list of sink property handles. 670 * 671 * @param sink Sink handle. 672 * @return List of sink property handles. 673 */ 674 public static native int[] enumerateSinkProperties(int sink); 675 676 /** 677 * Sets sink configuration JSON. 678 * 679 * @param sink Sink handle. 680 * @param config Configuration JSON. 681 * @return True if set succeeded. 682 */ 683 public static native boolean setSinkConfigJson(int sink, String config); 684 685 /** 686 * Returns sink configuration JSON. 687 * 688 * @param sink Sink handle. 689 * @return Sink configuration JSON. 690 */ 691 public static native String getSinkConfigJson(int sink); 692 693 /** 694 * Sets sink source. 695 * 696 * @param sink Sink handle. 697 * @param source Source handle. 698 */ 699 public static native void setSinkSource(int sink, int source); 700 701 /** 702 * Returns sink source property. 703 * 704 * @param sink Sink handle. 705 * @param name Property name. 706 * @return Sink source property handle. 707 */ 708 public static native int getSinkSourceProperty(int sink, String name); 709 710 /** 711 * Returns sink source. 712 * 713 * @param sink Sink handle. 714 * @return Sink source handle. 715 */ 716 public static native int getSinkSource(int sink); 717 718 /** 719 * Copies sink. 720 * 721 * @param sink Sink handle. 722 * @return New sink handle. 723 */ 724 public static native int copySink(int sink); 725 726 /** 727 * Releases sink. 728 * 729 * @param sink Sink handle. 730 */ 731 public static native void releaseSink(int sink); 732 733 // 734 // MjpegServer Sink Functions 735 // 736 737 /** 738 * Returns MJPEG server listen address. 739 * 740 * @param sink Sink handle. 741 * @return MJPEG server listen address. 742 */ 743 public static native String getMjpegServerListenAddress(int sink); 744 745 /** 746 * Returns MJPEG server port. 747 * 748 * @param sink Sink handle. 749 * @return MJPEG server port. 750 */ 751 public static native int getMjpegServerPort(int sink); 752 753 // 754 // Image Sink Functions 755 // 756 757 /** 758 * Sets sink description. 759 * 760 * @param sink Sink handle. 761 * @param description Sink description. 762 */ 763 public static native void setSinkDescription(int sink, String description); 764 765 /** 766 * Returns raw sink frame. 767 * 768 * @param sink Sink handle. 769 * @param frame Raw frame. 770 * @param nativeObj Native object. 771 * @return Raw sink frame handle. 772 */ 773 public static native long grabRawSinkFrame(int sink, RawFrame frame, long nativeObj); 774 775 /** 776 * Returns raw sink frame timeout. 777 * 778 * @param sink Sink handle. 779 * @param frame Raw frame. 780 * @param nativeObj Native object. 781 * @param timeout Timeout in seconds. 782 * @return Raw sink frame timeout. 783 */ 784 public static native long grabRawSinkFrameTimeout( 785 int sink, RawFrame frame, long nativeObj, double timeout); 786 787 /** 788 * Returns sink error message. 789 * 790 * @param sink Sink handle. 791 * @return Sink error message. 792 */ 793 public static native String getSinkError(int sink); 794 795 /** 796 * Sets sink enable. 797 * 798 * @param sink Sink handle. 799 * @param enabled True if sink should be enabled. 800 */ 801 public static native void setSinkEnabled(int sink, boolean enabled); 802 803 // 804 // Listener Functions 805 // 806 807 /** 808 * Adds listener. 809 * 810 * @param listener Video event callback. 811 * @param eventMask Event mask. 812 * @param immediateNotify True to immediately notify on event. 813 * @return Listener handle. 814 */ 815 public static native int addListener( 816 Consumer<VideoEvent> listener, int eventMask, boolean immediateNotify); 817 818 /** 819 * Removes listener. 820 * 821 * @param handle Listener handle. 822 */ 823 public static native void removeListener(int handle); 824 825 /** 826 * Creates listener poller. 827 * 828 * @return Listener poller handle. 829 */ 830 public static native int createListenerPoller(); 831 832 /** 833 * Destroys listener poller. 834 * 835 * @param poller Listener poller handle. 836 */ 837 public static native void destroyListenerPoller(int poller); 838 839 /** 840 * Add polled listener. 841 * 842 * @param poller Poller handle. 843 * @param eventMask Event mask. 844 * @param immediateNotify True to immediately notify on event. 845 * @return Polled listener handle. 846 */ 847 public static native int addPolledListener(int poller, int eventMask, boolean immediateNotify); 848 849 /** 850 * Polls listener. 851 * 852 * @param poller Poller handle. 853 * @return List of video events. 854 * @throws InterruptedException if polling was interrupted. 855 */ 856 public static native VideoEvent[] pollListener(int poller) throws InterruptedException; 857 858 /** 859 * Polls listener with timeout. 860 * 861 * @param poller Poller handle. 862 * @param timeout Timeout in seconds. 863 * @return List of video events. 864 * @throws InterruptedException if polling was interrupted. 865 */ 866 public static native VideoEvent[] pollListenerTimeout(int poller, double timeout) 867 throws InterruptedException; 868 869 /** 870 * Cancels poll listener. 871 * 872 * @param poller Poller handle. 873 */ 874 public static native void cancelPollListener(int poller); 875 876 // 877 // Telemetry Functions 878 // 879 880 /** Telemetry kind. */ 881 public enum TelemetryKind { 882 /** kSourceBytesReceived. */ 883 kSourceBytesReceived(1), 884 /** kSourceFramesReceived. */ 885 kSourceFramesReceived(2); 886 887 private final int value; 888 889 TelemetryKind(int value) { 890 this.value = value; 891 } 892 893 /** 894 * Returns telemetry kind value. 895 * 896 * @return Telemetry kind value. 897 */ 898 public int getValue() { 899 return value; 900 } 901 } 902 903 /** 904 * Sets telemetry period. 905 * 906 * @param seconds Telemetry period in seconds. 907 */ 908 public static native void setTelemetryPeriod(double seconds); 909 910 /** 911 * Returns telemetry elapsed time. 912 * 913 * @return Telemetry elapsed time. 914 */ 915 public static native double getTelemetryElapsedTime(); 916 917 /** 918 * Returns telemetry value. 919 * 920 * @param handle Telemetry handle. 921 * @param kind Telemetry kind. 922 * @return Telemetry value. 923 */ 924 public static native long getTelemetryValue(int handle, int kind); 925 926 /** 927 * Returns telemetry value. 928 * 929 * @param handle Telemetry handle. 930 * @param kind Telemetry kind. 931 * @return Telemetry value. 932 */ 933 public static long getTelemetryValue(int handle, TelemetryKind kind) { 934 return getTelemetryValue(handle, kind.getValue()); 935 } 936 937 /** 938 * Returns telemetry average value. 939 * 940 * @param handle Telemetry handle. 941 * @param kind Telemetry kind. 942 * @return Telemetry average value. 943 */ 944 public static native double getTelemetryAverageValue(int handle, int kind); 945 946 /** 947 * Returns telemetry average value. 948 * 949 * @param handle Telemetry handle. 950 * @param kind Telemetry kind. 951 * @return Telemetry average value. 952 */ 953 public static double getTelemetryAverageValue(int handle, TelemetryKind kind) { 954 return getTelemetryAverageValue(handle, kind.getValue()); 955 } 956 957 // 958 // Logging Functions 959 // 960 961 /** Logger functional interface. */ 962 @FunctionalInterface 963 public interface LoggerFunction { 964 /** 965 * Log a string. 966 * 967 * @param level Log level. 968 * @param file Log file. 969 * @param line Line number. 970 * @param msg Log message. 971 */ 972 void apply(int level, String file, int line, String msg); 973 } 974 975 /** 976 * Sets logger. 977 * 978 * @param func Logger function. 979 * @param minLevel Minimum logging level. 980 */ 981 public static native void setLogger(LoggerFunction func, int minLevel); 982 983 // 984 // Utility Functions 985 // 986 987 /** 988 * Returns list of USB cameras. 989 * 990 * @return List of USB cameras. 991 */ 992 public static native UsbCameraInfo[] enumerateUsbCameras(); 993 994 /** 995 * Returns list of sources. 996 * 997 * @return List of sources. 998 */ 999 public static native int[] enumerateSources(); 1000 1001 /** 1002 * Returns list of sinks. 1003 * 1004 * @return List of sinks. 1005 */ 1006 public static native int[] enumerateSinks(); 1007 1008 /** 1009 * Returns hostname. 1010 * 1011 * @return Hostname. 1012 */ 1013 public static native String getHostname(); 1014 1015 /** 1016 * Returns list of network interfaces. 1017 * 1018 * @return List of network interfaces. 1019 */ 1020 public static native String[] getNetworkInterfaces(); 1021 1022 /** Runs main run loop. */ 1023 public static native void runMainRunLoop(); 1024 1025 /** 1026 * Runs main run loop with timeout. 1027 * 1028 * @param timeoutSeconds Timeout in seconds. 1029 * @return 3 on timeout, 2 on signal, 1 on other. 1030 */ 1031 public static native int runMainRunLoopTimeout(double timeoutSeconds); 1032 1033 /** Stops main run loop. */ 1034 public static native void stopMainRunLoop(); 1035 1036 /** Utility class. */ 1037 private CameraServerJNI() {} 1038}