File tree 4 files changed +84
-0
lines changed
4 files changed +84
-0
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ set(LIBDATACHANNEL_SOURCES
75
75
${CMAKE_CURRENT_SOURCE_DIR} /src/rtppacketizationconfig.cpp
76
76
${CMAKE_CURRENT_SOURCE_DIR} /src/rtcpsrreporter.cpp
77
77
${CMAKE_CURRENT_SOURCE_DIR} /src/rtppacketizer.cpp
78
+ ${CMAKE_CURRENT_SOURCE_DIR} /src/rtpdepacketizer.cpp
78
79
${CMAKE_CURRENT_SOURCE_DIR} /src/h264rtppacketizer.cpp
79
80
${CMAKE_CURRENT_SOURCE_DIR} /src/h264rtpdepacketizer.cpp
80
81
${CMAKE_CURRENT_SOURCE_DIR} /src/nalunit.cpp
@@ -111,6 +112,7 @@ set(LIBDATACHANNEL_HEADERS
111
112
${CMAKE_CURRENT_SOURCE_DIR} /include /rtc/rtppacketizationconfig.hpp
112
113
${CMAKE_CURRENT_SOURCE_DIR} /include /rtc/rtcpsrreporter.hpp
113
114
${CMAKE_CURRENT_SOURCE_DIR} /include /rtc/rtppacketizer.hpp
115
+ ${CMAKE_CURRENT_SOURCE_DIR} /include /rtc/rtpdepacketizer.hpp
114
116
${CMAKE_CURRENT_SOURCE_DIR} /include /rtc/h264rtppacketizer.hpp
115
117
${CMAKE_CURRENT_SOURCE_DIR} /include /rtc/h264rtpdepacketizer.hpp
116
118
${CMAKE_CURRENT_SOURCE_DIR} /include /rtc/nalunit.hpp
Original file line number Diff line number Diff line change 38
38
#include " rtcpreceivingsession.hpp"
39
39
#include " rtcpsrreporter.hpp"
40
40
#include " rtppacketizer.hpp"
41
+ #include " rtpdepacketizer.hpp"
41
42
42
43
#endif // RTC_ENABLE_MEDIA
Original file line number Diff line number Diff line change
1
+ /* *
2
+ * Copyright (c) 2024 Paul-Louis Ageneau
3
+ *
4
+ * This Source Code Form is subject to the terms of the Mozilla Public
5
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
6
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7
+ */
8
+
9
+ #ifndef RTC_RTP_DEPACKETIZER_H
10
+ #define RTC_RTP_DEPACKETIZER_H
11
+
12
+ #if RTC_ENABLE_MEDIA
13
+
14
+ #include " mediahandler.hpp"
15
+ #include " message.hpp"
16
+
17
+ namespace rtc {
18
+
19
+ class RTC_CPP_EXPORT RtpDepacketizer : public MediaHandler {
20
+ public:
21
+ RtpDepacketizer () = default ;
22
+ virtual ~RtpDepacketizer () = default ;
23
+
24
+ virtual void incoming (message_vector &messages, const message_callback &send) override ;
25
+ };
26
+
27
+ using OpusRtpDepacketizer = RtpDepacketizer;
28
+ using AACRtpDepacketizer = RtpDepacketizer;
29
+
30
+ } // namespace rtc
31
+
32
+ #endif /* RTC_ENABLE_MEDIA */
33
+
34
+ #endif /* RTC_RTP_DEPACKETIZER_H */
Original file line number Diff line number Diff line change
1
+ /* *
2
+ * Copyright (c) 2024 Paul-Louis Ageneau
3
+ *
4
+ * This Source Code Form is subject to the terms of the Mozilla Public
5
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
6
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7
+ */
8
+
9
+ #if RTC_ENABLE_MEDIA
10
+
11
+ #include " rtpdepacketizer.hpp"
12
+ #include " rtp.hpp"
13
+
14
+ #include " impl/logcounter.hpp"
15
+
16
+ #include < cmath>
17
+ #include < cstring>
18
+
19
+ namespace rtc {
20
+
21
+ void RtpDepacketizer::incoming ([[maybe_unused]] message_vector &messages,
22
+ [[maybe_unused]] const message_callback &send) {
23
+ message_vector result;
24
+ for (auto &message : messages) {
25
+ if (message->type == Message::Control) {
26
+ result.push_back (std::move (message));
27
+ continue ;
28
+ }
29
+
30
+ if (message->size () < sizeof (RtpHeader)) {
31
+ PLOG_VERBOSE << " RTP packet is too small, size=" << message->size ();
32
+ continue ;
33
+ }
34
+
35
+ auto pkt = reinterpret_cast <const rtc::RtpHeader *>(message->data ());
36
+ auto headerSize = sizeof (rtc::RtpHeader) + pkt->csrcCount () + pkt->getExtensionHeaderSize ();
37
+ result.push_back (make_message (message->begin () + headerSize, message->end (),
38
+ Message::Binary, 0 , nullptr ,
39
+ std::make_shared<FrameInfo>(pkt->timestamp ())));
40
+ }
41
+
42
+ messages.swap (result);
43
+ }
44
+
45
+ } // namespace rtc
46
+
47
+ #endif /* RTC_ENABLE_MEDIA */
You can’t perform that action at this time.
0 commit comments