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