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