/*
* Copyright 2013 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.webrtc;
import static com.google.common.truth.Truth.assertThat;
import static java.util.Collections.singletonList;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import android.support.annotation.Nullable;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.MediumTest;
import android.support.test.filters.SmallTest;
import java.io.File;
import java.lang.ref.WeakReference;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.TreeSet;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.DisabledTest;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.webrtc.Metrics.HistogramInfo;
import org.webrtc.PeerConnection.IceConnectionState;
import org.webrtc.PeerConnection.IceGatheringState;
import org.webrtc.PeerConnection.PeerConnectionState;
import org.webrtc.PeerConnection.SignalingState;
import org.webrtc.PeerConnection.TlsCertPolicy;
import org.webrtc.RtpParameters;
import org.webrtc.RtpParameters.Encoding;
import org.webrtc.RtpTransceiver;
import org.webrtc.RtpTransceiver.RtpTransceiverInit;
/** End-to-end tests for PeerConnection.java. */
@RunWith(BaseJUnit4ClassRunner.class)
public class PeerConnectionTest {
private static final int TIMEOUT_SECONDS = 20;
private @Nullable TreeSet<String> threadsBeforeTest;
@Before
public void setUp() {
PeerConnectionFactory.initialize(PeerConnectionFactory.InitializationOptions
.builder(InstrumentationRegistry.getTargetContext())
.setNativeLibraryName(TestConstants.NATIVE_LIBRARY)
.createInitializationOptions());
}
private static class ObserverExpectations
implements PeerConnection.Observer, VideoSink, DataChannel.Observer, StatsObserver,
RTCStatsCollectorCallback, RtpReceiver.Observer {
private final String name;
private int expectedIceCandidates;
private int expectedErrors;
private int expectedRenegotiations;
private int expectedWidth;
private int expectedHeight;
private int expectedFramesDelivered;
private int expectedTracksAdded;
private Queue<SignalingState> expectedSignalingChanges = new ArrayDeque<>();
private Queue<IceConnectionState> expectedIceConnectionChanges = new ArrayDeque<>();
private Queue<PeerConnectionState> expectedConnectionChanges = new ArrayDeque<>();
private Queue<IceGatheringState> expectedIceGatheringChanges = new ArrayDeque<>();
private Queue<String> expectedAddStreamLabels = new ArrayDeque<>();
private Queue<String> expectedRemoveStreamLabels = new ArrayDeque<>();
private final List<IceCandidate> gotIceCandidates = new ArrayList<>();
private Map<MediaStream, WeakReference<VideoSink>> videoSinks = new IdentityHashMap<>();
private DataChannel dataChannel;
private Queue<DataChannel.Buffer> expectedBuffers = new ArrayDeque<>();
private Queue<DataChannel.State> expectedStateChanges = new ArrayDeque<>();
private Queue<String> expectedRemoteDataChannelLabels = new ArrayDeque<>();
private int expectedOldStatsCallbacks;
private int expectedNewStatsCallbacks;
private List<StatsReport[]> gotStatsReports = new ArrayList<>();
private final HashSet<MediaStream> gotRemoteStreams = new HashSet<>();
private int expectedFirstAudioPacket;
private int expectedFirstVideoPacket;
public ObserverExpectations(String name) {
this.name = name;
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void setDataChannel(DataChannel dataChannel) {
assertNull(this.dataChannel);
this.dataChannel = dataChannel;
this.dataChannel.registerObserver(this);
assertNotNull(this.dataChannel);
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void expectIceCandidates(int count) {
expectedIceCandidates += count;
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onIceCandidate(IceCandidate candidate) {
--expectedIceCandidates;
// We don't assert expectedIceCandidates >= 0 because it's hard to know
// how many to expect, in general. We only use expectIceCandidates to
// assert a minimal count.
synchronized (gotIceCandidates) {
gotIceCandidates.add(candidate);
gotIceCandidates.notifyAll();
}
}
@Override
public void onIceCandidatesRemoved(IceCandidate[] candidates) {}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void setExpectedResolution(int width, int height) {
expectedWidth = width;
expectedHeight = height;
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void expectFramesDelivered(int count) {
expectedFramesDelivered += count;
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onFrame(VideoFrame frame) {
if (expectedFramesDelivered <= 0) {
return;
}
assertTrue(expectedWidth > 0);
assertTrue(expectedHeight > 0);
assertEquals(expectedWidth, frame.getRotatedWidth());
assertEquals(expectedHeight, frame.getRotatedHeight());
--expectedFramesDelivered;
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void expectSignalingChange(SignalingState newState) {
expectedSignalingChanges.add(newState);
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onSignalingChange(SignalingState newState) {
assertEquals(expectedSignalingChanges.remove(), newState);
}
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void expectIceConnectionChange(IceConnectionState newState) {
expectedIceConnectionChanges.add(newState);
}
@Override
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void onIceConnectionChange(IceConnectionState newState) {
// TODO(bemasc): remove once delivery of ICECompleted is reliable
// (https://cod
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
webrtc源码 (2000个子文件)
nsx_core.c 86KB
isac.c 81KB
lpc_tables.c 81KB
transform_mips.c 77KB
entropy_coding.c 64KB
entropy_coding.c 62KB
nsx_core_mips.c 54KB
ns_core.c 50KB
encode.c 48KB
isacfix.c 48KB
analog_agc.c 42KB
lpc_tables.c 36KB
fft4g.c 36KB
bandwidth_estimator.c 34KB
lpc_masking_model.c 32KB
bandwidth_estimator.c 30KB
decode_plc.c 26KB
fft.c 26KB
vad_core.c 26KB
constants.c 25KB
pitch_estimator.c 25KB
encode.c 24KB
digital_agc.c 23KB
nsx_core_neon.c 23KB
resample_by_2_internal.c 20KB
complex_fft_mips.c 19KB
filters_mips.c 19KB
opus_interface.c 19KB
lattice_mips.c 18KB
transform_neon.c 18KB
encode_lpc_swb.c 17KB
lpc_analysis.c 17KB
encode.c 17KB
resample.c 16KB
min_max_operations_mips.c 16KB
filterbanks.c 16KB
pitch_filter.c 15KB
entropy_coding_mips.c 15KB
isac_vad.c 15KB
pitch_lag_tables.c 15KB
fft.c 15KB
filterbanks_mips.c 14KB
cb_search.c 14KB
vad_filterbank.c 14KB
simpleKenny.c 14KB
pitch_lag_tables.c 13KB
arith_routines_logist.c 12KB
g722_encode.c 12KB
enhancer_interface.c 12KB
pitch_estimator.c 12KB
unpack_bits.c 12KB
g722_decode.c 12KB
lattice.c 12KB
pack_bits.c 11KB
lpc_masking_model_mips.c 11KB
filterbanks_neon.c 11KB
arith_routines_hist.c 11KB
do_plc.c 11KB
resample_by_2_mips.c 10KB
decode.c 10KB
pitch_estimator_mips.c 10KB
iLBC_testprogram.c 10KB
main.c 10KB
downsample_fast_mips.c 10KB
nsx_core_c.c 10KB
pa_ringbuffer.c 10KB
complex_fft.c 10KB
spl_sqrt_floor_mips.c 9KB
complex_bit_reverse_mips.c 9KB
entropy_coding_neon.c 9KB
downsample_fast_neon.c 9KB
arith_routines_logist.c 9KB
decode.c 9KB
ilbc.c 9KB
arith_routines_hist.c 9KB
splitting_filter.c 8KB
pitch_gain_tables.c 8KB
lpc_shape_swb16_tables.c 8KB
pitch_filter.c 8KB
transform.c 8KB
decode.c 8KB
min_max_operations_neon.c 8KB
levinson_durbin.c 8KB
filter_ar_fast_q12_mips.c 8KB
resample_fractional.c 8KB
spectrum_ar_model_tables.c 8KB
pitch_filter_mips.c 7KB
spectrum_ar_model_tables.c 7KB
pitch_gain_tables.c 7KB
iLBC_test.c 7KB
ring_buffer.c 7KB
decode_residual.c 7KB
randomization_functions.c 6KB
transform_tables.c 6KB
lattice_neon.c 6KB
smooth.c 6KB
cross_correlation_mips.c 6KB
iLBC_testLib.c 6KB
lattice.c 6KB
resample_by_2.c 6KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
幸福专买店
- 粉丝: 9
- 资源: 24
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功