-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathwebrtc_lib_link_test.cc
More file actions
130 lines (120 loc) · 5.47 KB
/
Copy pathwebrtc_lib_link_test.cc
File metadata and controls
130 lines (120 loc) · 5.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
* Copyright 2019 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.
*/
#include <cstdio>
#include <memory>
#include <utility>
#include "api/audio/audio_device.h"
#include "api/audio/builtin_audio_processing_builder.h"
#include "api/audio/create_audio_device_module.h"
#include "api/audio_codecs/audio_decoder_factory_template.h"
#include "api/audio_codecs/audio_encoder_factory_template.h"
#include "api/audio_codecs/opus/audio_decoder_opus.h"
#include "api/audio_codecs/opus/audio_encoder_opus.h"
#include "api/create_modular_peer_connection_factory.h"
#include "api/create_peerconnection_factory.h"
#include "api/enable_media.h"
#include "api/environment/environment_factory.h"
#include "api/peer_connection_interface.h"
#include "api/rtc_event_log/rtc_event_log_factory.h"
#include "api/video_codecs/video_decoder_factory_template.h"
// RingRTC change to exclude av1 and h264 factories
// #include "api/video_codecs/video_decoder_factory_template_dav1d_adapter.h"
#include "api/video_codecs/video_decoder_factory_template_libvpx_vp8_adapter.h"
#include "api/video_codecs/video_decoder_factory_template_libvpx_vp9_adapter.h"
// RingRTC change to exclude av1 and h264 factories
// #include "api/video_codecs/video_decoder_factory_template_open_h264_adapter.h"
#include "api/video_codecs/video_encoder_factory_template.h"
// RingRTC change to exclude av1 and h264 factories
// #include "api/video_codecs/video_encoder_factory_template_libaom_av1_adapter.h"
#include "api/video_codecs/video_encoder_factory_template_libvpx_vp8_adapter.h"
#include "api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter.h"
// RingRTC change to exclude av1 and h264 factories
// #include "api/video_codecs/video_encoder_factory_template_open_h264_adapter.h"
#include "rtc_base/thread.h"
namespace webrtc {
void CreateSomeMediaDeps(PeerConnectionFactoryDependencies& media_deps) {
media_deps.adm =
CreateAudioDeviceModule(*media_deps.env, AudioDeviceModule::kDummyAudio);
media_deps.audio_encoder_factory =
CreateAudioEncoderFactory<AudioEncoderOpus>();
media_deps.audio_decoder_factory =
CreateAudioDecoderFactory<AudioDecoderOpus>();
// RingRTC change to exclude av1 and h264 factories
media_deps.video_encoder_factory =
std::make_unique<VideoEncoderFactoryTemplate<
LibvpxVp8EncoderTemplateAdapter,
#if defined(WEBRTC_USE_H264)
OpenH264EncoderTemplateAdapter,
#endif
#if defined(RTC_USE_LIBAOM_AV1_ENCODER)
LibaomAv1EncoderTemplateAdapter,
#endif
LibvpxVp9EncoderTemplateAdapter>>();
// RingRTC change to exclude av1 and h264 factories
media_deps.video_decoder_factory =
std::make_unique<VideoDecoderFactoryTemplate<
LibvpxVp8DecoderTemplateAdapter,
#if defined(WEBRTC_USE_H264)
OpenH264DecoderTemplateAdapter,
#endif
#if defined(RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY)
Dav1dDecoderTemplateAdapter,
#endif
LibvpxVp9DecoderTemplateAdapter>>();
media_deps.audio_processing_builder =
std::make_unique<BuiltinAudioProcessingBuilder>();
}
webrtc::PeerConnectionFactoryDependencies CreateSomePcfDeps() {
PeerConnectionFactoryDependencies pcf_deps;
pcf_deps.env = CreateEnvironment();
pcf_deps.signaling_thread = Thread::Current();
pcf_deps.network_thread = Thread::Current();
pcf_deps.worker_thread = Thread::Current();
pcf_deps.event_log_factory = std::make_unique<RtcEventLogFactory>();
CreateSomeMediaDeps(pcf_deps);
EnableMedia(pcf_deps);
return pcf_deps;
}
// NOTE: These "test cases" should pull in as much of WebRTC as possible to make
// sure most commonly used symbols are actually in libwebrtc.a. It's entirely
// possible these tests won't work at all times (maybe crash even), but that's
// fine.
void TestCase1ModularFactory() {
auto pcf_deps = CreateSomePcfDeps();
auto peer_connection_factory =
CreateModularPeerConnectionFactory(std::move(pcf_deps));
PeerConnectionInterface::RTCConfiguration rtc_config;
auto result = peer_connection_factory->CreatePeerConnectionOrError(
rtc_config, PeerConnectionDependencies(nullptr));
// Creation will fail because of null observer, but that's OK.
printf("peer_connection creation=%s\n", result.ok() ? "succeeded" : "failed");
}
void TestCase2RegularFactory() {
PeerConnectionFactoryDependencies media_deps;
media_deps.env = CreateEnvironment();
CreateSomeMediaDeps(media_deps);
auto peer_connection_factory = CreatePeerConnectionFactory(
Thread::Current(), Thread::Current(), Thread::Current(),
std::move(media_deps.adm), std::move(media_deps.audio_encoder_factory),
std::move(media_deps.audio_decoder_factory),
std::move(media_deps.video_encoder_factory),
std::move(media_deps.video_decoder_factory), nullptr, nullptr);
PeerConnectionInterface::RTCConfiguration rtc_config;
auto result = peer_connection_factory->CreatePeerConnectionOrError(
rtc_config, PeerConnectionDependencies(nullptr));
// Creation will fail because of null observer, but that's OK.
printf("peer_connection creation=%s\n", result.ok() ? "succeeded" : "failed");
}
} // namespace webrtc
int main(int argc, char** argv) {
webrtc::TestCase1ModularFactory();
webrtc::TestCase2RegularFactory();
return 0;
}