Home | History | Annotate | Download | only in webrtcdemo
      1 /*
      2  *  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
      3  *
      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
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 package org.webrtc.webrtcdemo;
     12 
     13 public class VideoEngine {
     14   private final long nativeVideoEngine;
     15 
     16   // Keep in sync (including this comment) with webrtc/common_types.h:TraceLevel
     17   public enum TraceLevel {
     18     TRACE_NONE(0x0000),
     19     TRACE_STATE_INFO(0x0001),
     20     TRACE_WARNING(0x0002),
     21     TRACE_ERROR(0x0004),
     22     TRACE_CRITICAL(0x0008),
     23     TRACE_API_CALL(0x0010),
     24     TRACE_DEFAULT(0x00ff),
     25     TRACE_MODULE_CALL(0x0020),
     26     TRACE_MEMORY(0x0100),
     27     TRACE_TIMER(0x0200),
     28     TRACE_STREAM(0x0400),
     29     TRACE_DEBUG(0x0800),
     30     TRACE_INFO(0x1000),
     31     TRACE_TERSE_INFO(0x2000),
     32     TRACE_ALL(0xffff);
     33 
     34     public final int level;
     35     TraceLevel(int level) {
     36       this.level = level;
     37     }
     38   };
     39 
     40   // Keep in sync (including this comment) with
     41   // webrtc/video_engine/include/vie_rtp_rtcp.h:ViEKeyFrameRequestMethod
     42   public enum VieKeyFrameRequestMethod {
     43     KEY_FRAME_REQUEST_NONE, KEY_FRAME_REQUEST_PLI_RTCP,
     44     KEY_FRAME_REQUEST_FIR_RTP, KEY_FRAME_REQUEST_FIR_RTCP
     45   }
     46 
     47   // Keep in sync (including this comment) with
     48   // webrtc/common_types.h:RtpDirections
     49   public enum RtpDirections { INCOMING, OUTGOING }
     50 
     51   public VideoEngine() {
     52     nativeVideoEngine = create();
     53   }
     54 
     55   // API comments can be found in VideoEngine's native APIs. Not all native
     56   // APIs are available.
     57   private static native long create();
     58   public native int init();
     59   public native int setVoiceEngine(VoiceEngine voe);
     60   public native void dispose();
     61   public native int startSend(int channel);
     62   public native int stopRender(int channel);
     63   public native int stopSend(int channel);
     64   public native int startReceive(int channel);
     65   public native int stopReceive(int channel);
     66   public native int createChannel();
     67   public native int deleteChannel(int channel);
     68   public native int connectAudioChannel(int videoChannel, int voiceChannel);
     69   public native int setLocalReceiver(int channel, int port);
     70   public native int setSendDestination(int channel, int port, String ipAddr);
     71   public native int numberOfCodecs();
     72   public native VideoCodecInst getCodec(int index);
     73   public native int setReceiveCodec(int channel, VideoCodecInst codec);
     74   public native int setSendCodec(int channel, VideoCodecInst codec);
     75   public native int addRenderer(int channel, Object glSurface, int zOrder,
     76       float left, float top,
     77       float right, float bottom);
     78   public native int removeRenderer(int channel);
     79   public native int registerExternalReceiveCodec(int channel, int plType,
     80       MediaCodecVideoDecoder decoder, boolean internal_source);
     81   public native int deRegisterExternalReceiveCodec(int channel, int plType);
     82   public native int startRender(int channel);
     83   public native int numberOfCaptureDevices();
     84   public native CameraDesc getCaptureDevice(int index);
     85   public native int allocateCaptureDevice(CameraDesc camera);
     86   public native int connectCaptureDevice(int cameraId, int channel);
     87   public native int startCapture(int cameraId);
     88   public native int stopCapture(int cameraId);
     89   public native int releaseCaptureDevice(int cameraId);
     90   public native int getOrientation(CameraDesc camera);
     91   public native int setRotateCapturedFrames(int cameraId, int degrees);
     92   public native int setNackStatus(int channel, boolean enable);
     93   public int setKeyFrameRequestMethod(int channel,
     94       VieKeyFrameRequestMethod requestMethod) {
     95     return setKeyFrameRequestMethod(channel, requestMethod.ordinal());
     96   }
     97   private native int setKeyFrameRequestMethod(int channel,
     98       int requestMethod);
     99   public native RtcpStatistics getReceivedRtcpStatistics(int channel);
    100   public native int registerObserver(int channel,
    101       VideoDecodeEncodeObserver callback);
    102   public native int deregisterObserver(int channel);
    103   public native int setTraceFile(String fileName,
    104       boolean fileCounter);
    105   public int setTraceFilter(TraceLevel filter) {
    106     return nativeSetTraceFilter(filter.level);
    107   }
    108   private native int nativeSetTraceFilter(int filter);
    109   public int startRtpDump(int channel, String file,
    110       RtpDirections direction) {
    111     return startRtpDump(channel, file, direction.ordinal());
    112   }
    113   private native int startRtpDump(int channel, String file,
    114       int direction);
    115   public int stopRtpDump(int channel, RtpDirections direction) {
    116     return stopRtpDump(channel, direction.ordinal());
    117   }
    118   private native int stopRtpDump(int channel, int direction);
    119   public native int setLocalSSRC(int channel, int ssrc);
    120 }
    121