tree: 1d4c0f0d6af7e1738728e84010c903ea9c9d4d8e [path history] [tgz]
  1. adaptation/
  2. audio/
  3. audio_codecs/
  4. call/
  5. crypto/
  6. environment/
  7. g3doc/
  8. metronome/
  9. neteq/
  10. numerics/
  11. rtc_event_log/
  12. stats/
  13. task_queue/
  14. test/
  15. transport/
  16. units/
  17. video/
  18. video_codecs/
  19. voip/
  20. array_view.h
  21. array_view_unittest.cc
  22. async_dns_resolver.h
  23. audio_options.cc
  24. audio_options.h
  25. BUILD.gn
  26. candidate.cc
  27. candidate.h
  28. candidate_unittest.cc
  29. create_peerconnection_factory.cc
  30. create_peerconnection_factory.h
  31. data_channel_interface.cc
  32. data_channel_interface.h
  33. DEPS
  34. dtls_transport_interface.cc
  35. dtls_transport_interface.h
  36. dtmf_sender_interface.h
  37. enable_media.cc
  38. enable_media.h
  39. enable_media_with_defaults.cc
  40. enable_media_with_defaults.h
  41. fec_controller.h
  42. fec_controller_override.h
  43. field_trials.cc
  44. field_trials.h
  45. field_trials_registry.cc
  46. field_trials_registry.h
  47. field_trials_unittest.cc
  48. field_trials_view.h
  49. frame_transformer_factory.cc
  50. frame_transformer_factory.h
  51. frame_transformer_interface.cc
  52. frame_transformer_interface.h
  53. function_view.h
  54. function_view_unittest.cc
  55. ice_transport_factory.cc
  56. ice_transport_factory.h
  57. ice_transport_interface.h
  58. jsep.cc
  59. jsep.h
  60. jsep_ice_candidate.cc
  61. jsep_ice_candidate.h
  62. jsep_session_description.h
  63. jsep_unittest.cc
  64. legacy_stats_types.cc
  65. legacy_stats_types.h
  66. location.h
  67. make_ref_counted.h
  68. media_stream_interface.cc
  69. media_stream_interface.h
  70. media_stream_track.h
  71. media_types.cc
  72. media_types.h
  73. network_state_predictor.h
  74. notifier.h
  75. OWNERS
  76. packet_socket_factory.h
  77. peer_connection_interface.cc
  78. peer_connection_interface.h
  79. priority.h
  80. README.md
  81. ref_count.h
  82. ref_counted_base.h
  83. rtc_error.cc
  84. rtc_error.h
  85. rtc_error_unittest.cc
  86. rtc_event_log_output.h
  87. rtc_event_log_output_file.cc
  88. rtc_event_log_output_file.h
  89. rtc_event_log_output_file_unittest.cc
  90. rtp_headers.cc
  91. rtp_headers.h
  92. rtp_packet_info.cc
  93. rtp_packet_info.h
  94. rtp_packet_info_unittest.cc
  95. rtp_packet_infos.h
  96. rtp_packet_infos_unittest.cc
  97. rtp_packet_sender.h
  98. rtp_parameters.cc
  99. rtp_parameters.h
  100. rtp_parameters_unittest.cc
  101. rtp_receiver_interface.cc
  102. rtp_receiver_interface.h
  103. rtp_sender_interface.cc
  104. rtp_sender_interface.h
  105. rtp_transceiver_direction.h
  106. rtp_transceiver_interface.cc
  107. rtp_transceiver_interface.h
  108. scoped_refptr.h
  109. scoped_refptr_unittest.cc
  110. sctp_transport_interface.cc
  111. sctp_transport_interface.h
  112. sequence_checker.h
  113. sequence_checker_unittest.cc
  114. set_local_description_observer_interface.h
  115. set_remote_description_observer_interface.h
  116. turn_customizer.h
  117. uma_metrics.h
  118. video_track_source_constraints.h
  119. video_track_source_proxy_factory.h
  120. webrtc_key_value_config.h
api/README.md

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/. It’s not always possible to avoid this, but be aware that it adds to a small mountain of technical debt that we’re 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 won’t 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.