The goal of the Real-time Transport Protocol (RTP) library is to provide RTP Serializer and Deserializer functionalities. Along with this, RTP library also provide codec packetization and depacketization functionality for G.711, VP8, Opus and H.264 codecs.
Real-Time Transport Protocol (RTP), as defined in RFC 3550, is a data transport protocol used to deliver real-time data such as audio or video over IP networks. An RTP packet comprises of a header followed by the payload.
A RTP packet consist of following fields followed by an optional RTP Header extension.
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|V=2|P|X| CC |M| PT | Sequence Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Timestamp |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Synchronization Source (SSRC) identifier |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Contributing Source (CSRC[0..15]) identifiers |
| .... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
RTP Header extension:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Profile | Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Header Extension |
| .... |
1. Call `Rtp_Init()` to initialize the RTP Context.
2. Initialize an RtpPacket_t with the desired values.
3. Call `Rtp_Serialize()` to serialize the RtpPacket_t passed.
1. Call `Rtp_Init()` to initialize the RTP Context.
2. Pass the serialized packet along with its length to `Rtp_DeSerialize()` to
deserialize the packet.
1. Call `<Codec>Packetization_Init()` to intitializae the particular codec context.
2. In case of H.264 Codec packetization -
- Call `H264Packetizer_AddFrame()` to add a frame OR
- Call `H264Packetizer_AddNalu()` repeatedly to add NALUs of a frame.
3. For all codes other than H.264, call `<Codec>Packetizer_AddFrame()` to add a frame.
4. Call `<Codec>Packetizer_GetPacket()` repeatedly to retrieve the packets
until `<Codec>_RESULT_NO_MORE_PACKETS` is returned.
1. Call `<Codec>Depacketization_Init()` to initialize the codec context.
2. Call `<Codec>Depacketizer_AddPacket()` repeatedly to add all packets received
corresponding to one frame.
3. In case of H.264 Codec depacketization -
- Call `H264Depacketizer_GetFrame()` to get a frame OR
- Call `H264Depacketizer_GetNalu()` iteratively to get NALUs one by one until
H264_RESULT_NO_MORE_NALUS is returned.
4. For all codes other than H.264, Call `<Codec>Depacketizer_GetFrame()` to get the
complete frame once all packets are added.
- For running unit tests:
- C99 compiler like gcc.
- CMake 3.13.0 or later.
- Ruby 2.0.0 or later (It is required for the CMock test framework that we use).
- For running the coverage target, gcov and lcov are required.
By default, the submodules in this repository are configured with update=none
in .gitmodules to avoid increasing clone time and disk space
usage of other repositories.
To build unit tests, the submodule dependency of CMock is required. Use the following command to clone the submodule:
git submodule update --checkout --init --recursive test/CMock
-
Go to the root directory of this repository. (Make sure that the CMock submodule is cloned as described in Checkout CMock Submodule).
-
Run the following command to generate Makefiles:
cmake -S test/unit-test -B build/ -G "Unix Makefiles" \ -DCMAKE_BUILD_TYPE=Debug \ -DBUILD_CLONE_SUBMODULES=ON \ -DCMAKE_C_FLAGS='--coverage -Wall -Wextra -Werror -DNDEBUG'
-
Run the following command to build the library and unit tests:
make -C build all
-
Run the following command to execute all tests and view results:
cd build && ctest -E system --output-on-failure
-
Run Unit Tests in Steps to build Unit Tests.
-
Generate coverage report in 'build/coverage' folder:
make coverage
git submodule update --init --recursive --checkout test/CMock
cmake -S test/unit-test -B build/ -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DBUILD_CLONE_SUBMODULES=ON -DCMAKE_C_FLAGS='--coverage -Wall -Wextra -Werror -DNDEBUG -DLIBRARY_LOG_LEVEL=LOG_DEBUG'
make -C build all
cd build
ctest -E system --output-on-failure
make coverage
This project is licensed under the Apache-2.0 License.