Packets, chunks, parameters and error causes - the SCTP entities that are sent on the wire - are buffers with fields that are stored in big endian and that generally consist of a fixed header size, and a variable sized part, that can e.g. be encoded sub-fields or serialized strings. The BoundedByteReader and BoundedByteWriter utilities make it easy to read those fields with as much aid from the compiler as possible, by having compile-time assertions that fields are not accessed outside the buffer's span. There are some byte reading functionality already in modules/rtp_rtcp, but that module would be a bit unfortunate to depend on, and doesn't have the compile time bounds checking that is the biggest feature of this abstraction of an rtc::ArrayView. Bug: webrtc:12614 Change-Id: I9fc641aff22221018dda9add4e2c44853c0f64f0 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/212967 Commit-Queue: Victor Boivie <boivie@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Tommi <tommi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#33597}
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 “.hand.ccfiles come in pairs” rule, so if you declare something inapi/path/to/foo.h, it should be defined inapi/path/to/foo.cc. - Headers in
api/should, if possible, not#includeheaders outsideapi/. 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. .ccfiles inapi/, on the other hand, are free to#includeheaders outsideapi/.
That is, 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.