/*
* Copyright 2014 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
package org.appspot.apprtc;
import android.content.Context;
import android.os.Environment;
import android.os.ParcelFileDescriptor;
import android.support.annotation.Nullable;
import android.util.Log;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.appspot.apprtc.AppRTCClient.SignalingParameters;
import org.webrtc.AudioSource;
import org.webrtc.AudioTrack;
import org.webrtc.CameraVideoCapturer;
import org.webrtc.CandidatePairChangeEvent;
import org.webrtc.DataChannel;
import org.webrtc.DefaultVideoDecoderFactory;
import org.webrtc.DefaultVideoEncoderFactory;
import org.webrtc.EglBase;
import org.webrtc.IceCandidate;
import org.webrtc.Logging;
import org.webrtc.MediaConstraints;
import org.webrtc.MediaStream;
import org.webrtc.MediaStreamTrack;
import org.webrtc.PeerConnection;
import org.webrtc.PeerConnection.IceConnectionState;
import org.webrtc.PeerConnection.PeerConnectionState;
import org.webrtc.PeerConnectionFactory;
import org.webrtc.RtpParameters;
import org.webrtc.RtpReceiver;
import org.webrtc.RtpSender;
import org.webrtc.RtpTransceiver;
import org.webrtc.SdpObserver;
import org.webrtc.SessionDescription;
import org.webrtc.SoftwareVideoDecoderFactory;
import org.webrtc.SoftwareVideoEncoderFactory;
import org.webrtc.StatsObserver;
import org.webrtc.StatsReport;
import org.webrtc.SurfaceTextureHelper;
import org.webrtc.VideoCapturer;
import org.webrtc.VideoDecoderFactory;
import org.webrtc.VideoEncoderFactory;
import org.webrtc.VideoSink;
import org.webrtc.VideoSource;
import org.webrtc.VideoTrack;
import org.webrtc.audio.AudioDeviceModule;
import org.webrtc.audio.JavaAudioDeviceModule;
import org.webrtc.audio.JavaAudioDeviceModule.AudioRecordErrorCallback;
import org.webrtc.audio.JavaAudioDeviceModule.AudioRecordStateCallback;
import org.webrtc.audio.JavaAudioDeviceModule.AudioTrackErrorCallback;
import org.webrtc.audio.JavaAudioDeviceModule.AudioTrackStateCallback;
/**
* Peer connection client implementation.
*
* <p>All public methods are routed to local looper thread.
* All PeerConnectionEvents callbacks are invoked from the same looper thread.
* This class is a singleton.
*/
public class PeerConnectionClient {
public static final String VIDEO_TRACK_ID = "ARDAMSv0";
public static final String AUDIO_TRACK_ID = "ARDAMSa0";
public static final String VIDEO_TRACK_TYPE = "video";
private static final String TAG = "PCRTCClient";
private static final String VIDEO_CODEC_VP8 = "VP8";
private static final String VIDEO_CODEC_VP9 = "VP9";
private static final String VIDEO_CODEC_H264 = "H264";
private static final String VIDEO_CODEC_H264_BASELINE = "H264 Baseline";
private static final String VIDEO_CODEC_H264_HIGH = "H264 High";
private static final String AUDIO_CODEC_OPUS = "opus";
private static final String AUDIO_CODEC_ISAC = "ISAC";
private static final String VIDEO_CODEC_PARAM_START_BITRATE = "x-google-start-bitrate";
private static final String VIDEO_FLEXFEC_FIELDTRIAL =
"WebRTC-FlexFEC-03-Advertised/Enabled/WebRTC-FlexFEC-03/Enabled/";
private static final String VIDEO_VP8_INTEL_HW_ENCODER_FIELDTRIAL = "WebRTC-IntelVP8/Enabled/";
private static final String DISABLE_WEBRTC_AGC_FIELDTRIAL =
"WebRTC-Audio-MinimizeResamplingOnMobile/Enabled/";
private static final String AUDIO_CODEC_PARAM_BITRATE = "maxaveragebitrate";
private static final String AUDIO_ECHO_CANCELLATION_CONSTRAINT = "googEchoCancellation";
private static final String AUDIO_AUTO_GAIN_CONTROL_CONSTRAINT = "googAutoGainControl";
private static final String AUDIO_HIGH_PASS_FILTER_CONSTRAINT = "googHighpassFilter";
private static final String AUDIO_NOISE_SUPPRESSION_CONSTRAINT = "googNoiseSuppression";
private static final String DTLS_SRTP_KEY_AGREEMENT_CONSTRAINT = "DtlsSrtpKeyAgreement";
private static final int HD_VIDEO_WIDTH = 1280;
private static final int HD_VIDEO_HEIGHT = 720;
private static final int BPS_IN_KBPS = 1000;
private static final String RTCEVENTLOG_OUTPUT_DIR_NAME = "rtc_event_log";
// Executor thread is started once in private ctor and is used for all
// peer connection API calls to ensure new peer connection factory is
// created on the same thread as previously destroyed factory.
private static final ExecutorService executor = Executors.newSingleThreadExecutor();
private final PCObserver pcObserver = new PCObserver();
private final SDPObserver sdpObserver = new SDPObserver();
private final Timer statsTimer = new Timer();
private final EglBase rootEglBase;
private final Context appContext;
private final PeerConnectionParameters peerConnectionParameters;
private final PeerConnectionEvents events;
@Nullable
private PeerConnectionFactory factory;
@Nullable
private PeerConnection peerConnection;
@Nullable
private AudioSource audioSource;
@Nullable
private SurfaceTextureHelper surfaceTextureHelper;
@Nullable
private VideoSource videoSource;
private boolean preferIsac;
private boolean videoCapturerStopped;
private boolean isError;
@Nullable
private VideoSink localRender;
@Nullable
private List<VideoSink> remoteRenders;
private SignalingParameters signalingParameters;
private int videoWidth;
private int videoHeight;
private int videoFps;
private MediaConstraints audioConstraints;
private MediaConstraints sdpMediaConstraints;
// Queued remote ICE candidates are consumed only after both local and
// remote descriptions are set. Similarly local ICE candidates are sent to
// remote peer after both local and remote description are set.
@Nullable
private List<IceCandidate> queuedRemoteCandidates;
private boolean isInitiator;
@Nullable
private SessionDescription localDescription; // either offer or answer description
@Nullable
private VideoCapturer videoCapturer;
// enableVideo is set to true if video should be rendered and sent.
private boolean renderVideo = true;
@Nullable
private VideoTrack localVideoTrack;
@Nullable
private VideoTrack remoteVideoTrack;
@Nullable
private RtpSender localVideoSender;
// enableAudio is set to true if audio should be sent.
private boolean enableAudio = true;
@Nullable
private AudioTrack localAudioTrack;
@Nullable
private DataChannel dataChannel;
private final boolean dataChannelEnabled;
// Enable RtcEventLog.
@Nullable
private RtcEventLog rtcEventLog;
// Implements the WebRtcAudioRecordSamplesReadyCallback interface and writes
// recorded audio samples to an output file.
@Nullable
private RecordedAudioToFileController saveRecordedAudioToFile;
/**
* Peer connection parameters.
*/
public static class DataChannelParameters {
public final boolean ordered;
public final int maxRetransmitTimeMs;
public final int maxRetransmits;
public final String protocol;
public final boolean negotiated;
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
webrtc-m89-android.7z (25个子文件)
webrtc-m89-android
org
appspot
apprtc
DirectRTCClient.java 12KB
AppRTCBluetoothManager.java 22KB
PeerConnectionClient.java 55KB
SettingsFragment.java 822B
ConnectActivity.java 27KB
TCPChannelClient.java 10KB
CallFragment.java 5KB
AppRTCClient.java 4KB
CallActivity.java 38KB
RecordedAudioToFileController.java 5KB
RoomParametersFetcher.java 9KB
WebSocketRTCClient.java 15KB
UnhandledExceptionHandler.java 3KB
WebSocketChannelClient.java 10KB
RtcEventLog.java 2KB
CaptureQualityController.java 4KB
AppRTCAudioManager.java 23KB
CpuMonitor.java 18KB
SettingsActivity.java 14KB
HudFragment.java 7KB
util
AsyncHttpURLConnection.java 4KB
AppRTCUtils.java 2KB
AppRTCProximitySensor.java 6KB
libs
armeabi-v7a
libjingle_peerconnection_so.so 4.25MB
libjingle-peerconnection-11139.jar 931KB
共 25 条
- 1
命运之手
- 粉丝: 461
- 资源: 102
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0