webrtc/api
Evan Shrubsole 1d2f30b8b9 Add utility WaitUntil for testing for an eventual condition
This replaces the WaitUntilCondition function that was used in the
peer_connection_encodings_integrationtest previously. Along with that it
adds tests and improved error message printing.

As a drive-by, matchers were added for RTCError as these are the return
type of this utility function.

Bug: webrtc:381524905
Change-Id: If7ff18692396d3996b5b289f2d2c92520226003e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/369980
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Evan Shrubsole <eshr@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43494}
2024-12-04 13:51:30 +00:00
..
adaptation Deprecate rtc::RefCountInterface 2024-06-07 09:47:26 +00:00
audio Deprecate AudioProcessingBuilder in favor of the BuiltinAudioProcessingBuilder 2024-11-08 09:54:53 +00:00
audio_codecs Opus decoder: stereo decoding by default (behind field trial) 2024-11-22 07:37:10 +00:00
call Rename PacketOptions.is_retransmit to is_media. 2024-10-28 13:45:23 +00:00
crypto [iwyu][1\n] Applying to api/[a-s]* 2024-06-19 06:19:20 +00:00
environment Comment unused variables in implemented functions 7\n 2024-10-28 12:04:15 +00:00
g3doc Reland "Migrate WebRTC documentation to new renderer" 2023-01-31 09:30:04 +00:00
metronome Comment unused variables in implemented functions 7\n 2024-10-28 12:04:15 +00:00
neteq Reland "Add InsertPacket method that takes RtpPacketInfo." 2024-11-26 09:42:11 +00:00
numerics [iwyu][1\n] Applying to api/[a-s]* 2024-06-19 06:19:20 +00:00
rtc_event_log Comment unused variables in implemented functions 7\n 2024-10-28 12:04:15 +00:00
stats Rename corruption related metrics according to WebRTC's Statistics API. 2024-11-08 11:57:59 +00:00
task_queue Comment unused variables in implemented functions 7\n 2024-10-28 12:04:15 +00:00
test Add utility WaitUntil for testing for an eventual condition 2024-12-04 13:51:30 +00:00
transport Comment unused variables in implemented functions 7\n 2024-10-28 12:04:15 +00:00
units Add default constructor to relative units types 2024-11-26 17:59:08 +00:00
video Fix corruption score not being calculated on higher spatial layers. 2024-12-02 14:46:45 +00:00
video_codecs Replace cricket::LeastCommonMultiple and cricket::GreatestCommonDivisor with std::lcm and std::gcd. 2024-11-07 13:30:28 +00:00
voip Deprecate AudioProcessingBuilder in favor of the BuiltinAudioProcessingBuilder 2024-11-08 09:54:53 +00:00
array_view.h [reland] Comment unused variables in implemented functions 2024-10-16 11:40:33 +00:00
array_view_unittest.cc Comment unused variables in implemented functions 3\n 2024-10-22 11:58:48 +00:00
async_dns_resolver.h Apply include-cleaner to api direct files 2024-09-10 08:29:26 +00:00
audio_options.cc Apply include-cleaner to api direct files (2/2). 2024-09-19 19:28:49 +00:00
audio_options.h Migrate absl::optional to std::optional 2024-09-02 12:16:47 +00:00
BUILD.gn Add utility WaitUntil for testing for an eventual condition 2024-12-04 13:51:30 +00:00
candidate.cc [iwyu][1\n] Applying to api/[a-s]* 2024-06-19 06:19:20 +00:00
candidate.h [iwyu][1\n] Applying to api/[a-s]* 2024-06-19 06:19:20 +00:00
candidate_unittest.cc [iwyu][1\n] Applying to api/[a-s]* 2024-06-19 06:19:20 +00:00
create_peerconnection_factory.cc Rename AudioProcessingFactory to Builder 2024-10-29 16:34:01 +00:00
create_peerconnection_factory.h [iwyu][1\n] Applying to api/[a-s]* 2024-06-19 06:19:20 +00:00
data_channel_interface.cc Comment unused variables in implemented functions 6\n 2024-10-28 11:59:51 +00:00
data_channel_interface.h Comment unused variables in implemented functions 6\n 2024-10-28 11:59:51 +00:00
DEPS Add utility WaitUntil for testing for an eventual condition 2024-12-04 13:51:30 +00:00
dtls_transport_interface.cc Migrate absl::optional to std::optional 2024-09-02 12:16:47 +00:00
dtls_transport_interface.h Migrate absl::optional to std::optional 2024-09-02 12:16:47 +00:00
dtmf_sender_interface.h [reland] Comment unused variables in implemented functions 2024-10-16 11:40:33 +00:00
enable_media.cc Deprecate PeerConnectionFactoryDependencies::audio_processing 2024-11-22 13:21:24 +00:00
enable_media.h Mark EnableMedia with RTC_EXPORT 2023-10-31 22:15:21 +00:00
enable_media_with_defaults.cc Deprecate PeerConnectionFactoryDependencies::audio_processing 2024-11-22 13:21:24 +00:00
enable_media_with_defaults.h Add EnableMediaWithDefaults to replace SetMediaEngineDefaults 2023-11-01 11:47:59 +00:00
fec_controller.h Apply include-cleaner to api direct files 2024-09-10 08:29:26 +00:00
fec_controller_override.h Define FecControllerOverride and plumb it down to VideoEncoder 2019-06-28 15:57:22 +00:00
field_trials.cc [iwyu][1\n] Applying to api/[a-s]* 2024-06-19 06:19:20 +00:00
field_trials.h Add FieldTrialsRegistry that verifies looked up field trials 2022-10-24 09:12:30 +00:00
field_trials_registry.cc [iwyu][1\n] Applying to api/[a-s]* 2024-06-19 06:19:20 +00:00
field_trials_registry.h Add FieldTrialsRegistry that verifies looked up field trials 2022-10-24 09:12:30 +00:00
field_trials_unittest.cc [iwyu][1\n] Applying to api/[a-s]* 2024-06-19 06:19:20 +00:00
field_trials_view.h Cleanup FieldTrialView 2023-03-27 17:06:33 +00:00
frame_transformer_factory.cc Pass receive_time through frame transformer 2024-08-02 07:01:33 +00:00
frame_transformer_factory.h [iwyu][1\n] Applying to api/[a-s]* 2024-06-19 06:19:20 +00:00
frame_transformer_interface.cc Add passkey to TransformableFrameInterface to prevent external impls 2024-05-16 13:12:51 +00:00
frame_transformer_interface.h Rename capture_time_identifier to presentation_timestamp 2024-10-28 12:11:38 +00:00
function_view.h [reland] Comment unused variables in implemented functions 2024-10-16 11:40:33 +00:00
function_view_unittest.cc Format almost everything. 2019-07-08 13:45:15 +00:00
ice_transport_factory.cc [iwyu][1\n] Applying to api/[a-s]* 2024-06-19 06:19:20 +00:00
ice_transport_factory.h [iwyu][1\n] Applying to api/[a-s]* 2024-06-19 06:19:20 +00:00
ice_transport_interface.h Apply include-cleaner to api direct files 2024-09-10 08:29:26 +00:00
jsep.cc Comment unused variables in implemented functions 7\n 2024-10-28 12:04:15 +00:00
jsep.h Add AbslStringify for SessionDescriptionInterface 2024-10-07 12:43:15 +00:00
jsep_ice_candidate.cc Apply include-cleaner to api direct files 2024-09-10 08:29:26 +00:00
jsep_ice_candidate.h Remove RTC_DISALLOW_COPY_AND_ASSIGN more. 2022-01-20 11:00:18 +00:00
jsep_session_description.h Apply include-cleaner to api direct files 2024-09-10 08:29:26 +00:00
jsep_unittest.cc Add AbslStringify for SessionDescriptionInterface 2024-10-07 12:43:15 +00:00
legacy_stats_types.cc Apply include-cleaner to api direct files 2024-09-10 08:29:26 +00:00
legacy_stats_types.h [iwyu][1\n] Applying to api/[a-s]* 2024-06-19 06:19:20 +00:00
location.h Implement support for Chrome task origin tracing. #2/4 2023-02-27 13:17:38 +00:00
make_ref_counted.h Allow scoped_refptr to be used with absl nullability annotation 2024-09-27 13:14:24 +00:00
media_stream_interface.cc Comment unused variables in implemented functions 4\n 2024-10-22 11:59:50 +00:00
media_stream_interface.h [reland] Comment unused variables in implemented functions 2024-10-16 11:40:33 +00:00
media_stream_track.h Use string_view to pass track ids to constructors 2022-05-30 10:28:57 +00:00
media_types.cc Apply include-cleaner to api direct files 2024-09-10 08:29:26 +00:00
media_types.h Revert "Define cricket::MediaType in terms of webrtc::MediaType" 2021-05-12 17:06:58 +00:00
network_state_predictor.h Apply include-cleaner to api direct files 2024-09-10 08:29:26 +00:00
notifier.h Apply include-cleaner to api direct files 2024-09-10 08:29:26 +00:00
OWNERS Rearrange api/OWNERS to show who's backup OWNERS 2022-10-07 05:56:08 +00:00
packet_socket_factory.h Apply include-cleaner to api direct files 2024-09-10 08:29:26 +00:00
peer_connection_interface.cc Make PC capability APIs pure virtual 2024-12-04 08:27:45 +00:00
peer_connection_interface.h Make PC capability APIs pure virtual 2024-12-04 08:27:45 +00:00
priority.h Make PriorityValue constructor explicit 2024-08-01 18:18:04 +00:00
README.md Discourage structs in api 2023-09-07 10:41:49 +00:00
ref_count.h Move RefCountInterface to api/ and webrtc: namespace 2023-10-31 14:02:50 +00:00
ref_counted_base.h Apply include-cleaner to api direct files 2024-09-10 08:29:26 +00:00
rtc_error.cc Apply include-cleaner to api direct files 2024-09-10 08:29:26 +00:00
rtc_error.h Add utility WaitUntil for testing for an eventual condition 2024-12-04 13:51:30 +00:00
rtc_error_unittest.cc Add utility WaitUntil for testing for an eventual condition 2024-12-04 13:51:30 +00:00
rtc_event_log_output.h Include-what-you-use api/rtc_event_log_output* 2024-06-16 15:13:29 +00:00
rtc_event_log_output_file.cc Include-what-you-use api/rtc_event_log_output* 2024-06-16 15:13:29 +00:00
rtc_event_log_output_file.h Include-what-you-use api/rtc_event_log_output* 2024-06-16 15:13:29 +00:00
rtc_event_log_output_file_unittest.cc Include-what-you-use api/rtc_event_log_output* 2024-06-16 15:13:29 +00:00
rtp_headers.cc Apply include-cleaner to api direct files 2024-09-10 08:29:26 +00:00
rtp_headers.h Migrate absl::optional to std::optional 2024-09-02 12:16:47 +00:00
rtp_packet_info.cc [iwyu][1\n] Applying to api/[a-s]* 2024-06-19 06:19:20 +00:00
rtp_packet_info.h Migrate absl::optional to std::optional 2024-09-02 12:16:47 +00:00
rtp_packet_info_unittest.cc Migrate absl::optional to std::optional 2024-09-02 12:16:47 +00:00
rtp_packet_infos.h [iwyu][1\n] Applying to api/[a-s]* 2024-06-19 06:19:20 +00:00
rtp_packet_infos_unittest.cc [iwyu][1\n] Applying to api/[a-s]* 2024-06-19 06:19:20 +00:00
rtp_packet_sender.h Comment unused variables in implemented functions 7\n 2024-10-28 12:04:15 +00:00
rtp_parameters.cc Delete requested_resolution, the old name for scale_resolution_down_to. 2024-10-28 09:59:55 +00:00
rtp_parameters.h Delete requested_resolution, the old name for scale_resolution_down_to. 2024-10-28 09:59:55 +00:00
rtp_parameters_unittest.cc Apply include-cleaner to api direct files 2024-09-10 08:29:26 +00:00
rtp_receiver_interface.cc Comment unused variables in implemented functions 7\n 2024-10-28 12:04:15 +00:00
rtp_receiver_interface.h [reland] Comment unused variables in implemented functions 2024-10-16 11:40:33 +00:00
rtp_sender_interface.cc Comment unused variables in implemented functions 4\n 2024-10-22 11:59:50 +00:00
rtp_sender_interface.h Comment unused variables in implemented functions 7\n 2024-10-28 12:04:15 +00:00
rtp_transceiver_direction.h RtpTransceiverInterface: add header_extensions_to_offer() 2020-03-16 13:16:42 +00:00
rtp_transceiver_interface.cc Comment unused variables in implemented functions 7\n 2024-10-28 12:04:15 +00:00
rtp_transceiver_interface.h Migrate absl::optional to std::optional 2024-09-02 12:16:47 +00:00
scoped_refptr.h Allow scoped_refptr to be used with absl nullability annotation 2024-09-27 13:14:24 +00:00
scoped_refptr_unittest.cc [iwyu][1\n] Applying to api/[a-s]* 2024-06-19 06:19:20 +00:00
sctp_transport_interface.cc Apply include-cleaner to api direct files (2/2). 2024-09-19 19:28:49 +00:00
sctp_transport_interface.h Migrate absl::optional to std::optional 2024-09-02 12:16:47 +00:00
sequence_checker.h [iwyu][1\n] Applying to api/[a-s]* 2024-06-19 06:19:20 +00:00
sequence_checker_unittest.cc [iwyu][1\n] Applying to api/[a-s]* 2024-06-19 06:19:20 +00:00
set_local_description_observer_interface.h Move all api/ files to use webrtc::RefCountInterface 2023-10-31 15:45:12 +00:00
set_remote_description_observer_interface.h Move all api/ files to use webrtc::RefCountInterface 2023-10-31 15:45:12 +00:00
turn_customizer.h Make header files self contained. 2022-10-08 08:38:36 +00:00
uma_metrics.h Removing enum used for removed UMA metrics WebRTC.PeerConnection.Simulcast.ApplyLocalDescription and WebRTC.PeerConnection.Simulcast.ApplyRemoteDescription 2023-07-13 09:00:52 +00:00
video_track_source_constraints.h Migrate absl::optional to std::optional 2024-09-02 12:16:47 +00:00
video_track_source_proxy_factory.h Apply include-cleaner to api direct files 2024-09-10 08:29:26 +00:00
webrtc_key_value_config.h Apply include-cleaner to api direct files (2/2). 2024-09-19 19:28:49 +00:00

How to write code in the api/ directory

Mostly, just follow the regular style guide, but:

  • Note that api/ code is not exempt from the “.h and .cc files come in pairs” rule, so if you declare something in api/path/to/foo.h, it should be defined in api/path/to/foo.cc.
  • Headers in api/ should, if possible, not #include headers outside api/. Its not always possible to avoid this, but be aware that it adds to a small mountain of technical debt that were trying to shrink.
  • .cc files in api/, on the other hand, are free to #include headers outside api/.
  • Avoid structs in api, prefer classes.

The preferred way for api/ code to access non-api/ code is to call it from a .cc file, so that users of our API headers wont transitively #include non-public headers.

For headers in api/ that need to refer to non-public types, forward declarations are often a lesser evil than including non-public header files. The usual rules still apply, though.

.cc files in api/ should preferably be kept reasonably small. If a substantial implementation is needed, consider putting it with our non-public code, and just call it from the api/ .cc file.

Avoid defining api with structs as it makes harder for the api to evolve. Your struct may gain invariant, or change how it represents data. Evolving struct from the api is particular challenging as it is designed to be used in other code bases and thus needs to be updated independetly from its usage. Class with accessors and setters makes such migration safer. See Google C++ style guide for more.

If you need to evolve existent struct in api, prefer first to convert it into a class.