Skip to content

Commit ebff363

Browse files
committed
Bug 1828517 - Vendor libwebrtc from dc39aebd08
Upstream commit: https://webrtc.googlesource.com/src/+/dc39aebd08a845849b255122fcd5167308e122d2 Add GetRTPVideoHeaderCodecSpecifics() to metadata. This will allow exposing VP8, VP9 and H264-specific RTP header metadata in JavaScript (behind a flag). This information appears to be necessary for cloning (w3c/webrtc-encoded-transform#161), and cloning should be the same as "new frame + setMetadata + setBytes", ergo this should be exposed. Bug: webrtc:14709 Change-Id: Ie71c05f40689bbd529dc4674a07a87c7910b22d5 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/290880 Reviewed-by: Harald Alvestrand <[email protected]> Commit-Queue: Henrik Boström <[email protected]> Cr-Commit-Position: refs/heads/main@{#39101}
1 parent f40adee commit ebff363

File tree

8 files changed

+97
-0
lines changed

8 files changed

+97
-0
lines changed

third_party/libwebrtc/README.moz-ff-commit

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20919,3 +20919,6 @@ e7e53feace
2091920919
# MOZ_LIBWEBRTC_SRC=/home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
2092020920
# base of lastest vendoring
2092120921
bb25641dd9
20922+
# MOZ_LIBWEBRTC_SRC=/home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
20923+
# base of lastest vendoring
20924+
dc39aebd08

third_party/libwebrtc/README.mozilla

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13968,3 +13968,5 @@ libwebrtc updated from /home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-l
1396813968
libwebrtc updated from /home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2023-04-21T15:46:57.324015.
1396913969
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
1397013970
libwebrtc updated from /home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2023-04-21T15:47:55.588434.
13971+
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
13972+
libwebrtc updated from /home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2023-04-21T15:48:50.614212.

third_party/libwebrtc/api/video/BUILD.gn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,14 @@ rtc_source_set("video_frame_metadata") {
337337
":video_frame_type",
338338
":video_rtp_headers",
339339
"..:array_view",
340+
"../../modules/video_coding:codec_globals_headers",
340341
"../../rtc_base/system:rtc_export",
341342
"../transport/rtp:dependency_descriptor",
342343
]
343344
absl_deps = [
344345
"//third_party/abseil-cpp/absl/container:inlined_vector",
345346
"//third_party/abseil-cpp/absl/types:optional",
347+
"//third_party/abseil-cpp/absl/types:variant",
346348
]
347349
}
348350

third_party/libwebrtc/api/video/DEPS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ specific_include_rules = {
4545
"+rtc_base/ref_count.h",
4646
],
4747

48+
"video_frame_metadata\.h": [
49+
"+modules/video_coding/codecs/h264/include/h264_globals.h",
50+
"+modules/video_coding/codecs/vp8/include/vp8_globals.h",
51+
"+modules/video_coding/codecs/vp9/include/vp9_globals.h",
52+
],
53+
4854
"video_stream_decoder_create.cc": [
4955
"+video/video_stream_decoder_impl.h",
5056
],

third_party/libwebrtc/api/video/video_frame_metadata.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
#include "api/video/video_frame_metadata.h"
1212

13+
#include <utility>
14+
1315
namespace webrtc {
1416

1517
VideoFrameMetadata::VideoFrameMetadata() = default;
@@ -124,4 +126,14 @@ void VideoFrameMetadata::SetCodec(VideoCodecType codec) {
124126
codec_ = codec;
125127
}
126128

129+
const RTPVideoHeaderCodecSpecifics&
130+
VideoFrameMetadata::GetRTPVideoHeaderCodecSpecifics() const {
131+
return codec_specifics_;
132+
}
133+
134+
void VideoFrameMetadata::SetRTPVideoHeaderCodecSpecifics(
135+
RTPVideoHeaderCodecSpecifics codec_specifics) {
136+
codec_specifics_ = std::move(codec_specifics);
137+
}
138+
127139
} // namespace webrtc

third_party/libwebrtc/api/video/video_frame_metadata.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,25 @@
1515

1616
#include "absl/container/inlined_vector.h"
1717
#include "absl/types/optional.h"
18+
#include "absl/types/variant.h"
1819
#include "api/array_view.h"
1920
#include "api/transport/rtp/dependency_descriptor.h"
2021
#include "api/video/video_codec_type.h"
2122
#include "api/video/video_content_type.h"
2223
#include "api/video/video_frame_type.h"
2324
#include "api/video/video_rotation.h"
25+
#include "modules/video_coding/codecs/h264/include/h264_globals.h"
26+
#include "modules/video_coding/codecs/vp8/include/vp8_globals.h"
27+
#include "modules/video_coding/codecs/vp9/include/vp9_globals.h"
2428
#include "rtc_base/system/rtc_export.h"
2529

2630
namespace webrtc {
2731

32+
using RTPVideoHeaderCodecSpecifics = absl::variant<absl::monostate,
33+
RTPVideoHeaderVP8,
34+
RTPVideoHeaderVP9,
35+
RTPVideoHeaderH264>;
36+
2837
// A subset of metadata from the RTP video header, exposed in insertable streams
2938
// API.
3039
class RTC_EXPORT VideoFrameMetadata {
@@ -74,6 +83,11 @@ class RTC_EXPORT VideoFrameMetadata {
7483
VideoCodecType GetCodec() const;
7584
void SetCodec(VideoCodecType codec);
7685

86+
// Which varient is used depends on the VideoCodecType from GetCodecs().
87+
const RTPVideoHeaderCodecSpecifics& GetRTPVideoHeaderCodecSpecifics() const;
88+
void SetRTPVideoHeaderCodecSpecifics(
89+
RTPVideoHeaderCodecSpecifics codec_specifics);
90+
7791
private:
7892
VideoFrameType frame_type_ = VideoFrameType::kEmptyFrame;
7993
int16_t width_ = 0;
@@ -91,6 +105,7 @@ class RTC_EXPORT VideoFrameMetadata {
91105
bool is_last_frame_in_picture_ = true;
92106
uint8_t simulcast_idx_ = 0;
93107
VideoCodecType codec_ = VideoCodecType::kVideoCodecGeneric;
108+
RTPVideoHeaderCodecSpecifics codec_specifics_;
94109
};
95110
} // namespace webrtc
96111

third_party/libwebrtc/modules/rtp_rtcp/source/rtp_video_header.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,23 @@ VideoFrameMetadata RTPVideoHeader::GetAsMetadata() const {
3838
metadata.SetIsLastFrameInPicture(is_last_frame_in_picture);
3939
metadata.SetSimulcastIdx(simulcastIdx);
4040
metadata.SetCodec(codec);
41+
switch (codec) {
42+
case VideoCodecType::kVideoCodecVP8:
43+
metadata.SetRTPVideoHeaderCodecSpecifics(
44+
absl::get<RTPVideoHeaderVP8>(video_type_header));
45+
break;
46+
case VideoCodecType::kVideoCodecVP9:
47+
metadata.SetRTPVideoHeaderCodecSpecifics(
48+
absl::get<RTPVideoHeaderVP9>(video_type_header));
49+
break;
50+
case VideoCodecType::kVideoCodecH264:
51+
metadata.SetRTPVideoHeaderCodecSpecifics(
52+
absl::get<RTPVideoHeaderH264>(video_type_header));
53+
break;
54+
default:
55+
// Codec-specifics are not supported for this codec.
56+
break;
57+
}
4158
return metadata;
4259
}
4360

third_party/libwebrtc/modules/rtp_rtcp/source/rtp_video_header_unittest.cc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,49 @@ TEST(RTPVideoHeaderTest, GetAsMetadataGetSimulcastIdx) {
158158
TEST(RTPVideoHeaderTest, GetAsMetadataGetCodec) {
159159
RTPVideoHeader video_header;
160160
video_header.codec = VideoCodecType::kVideoCodecVP9;
161+
video_header.video_type_header = RTPVideoHeaderVP9();
161162
VideoFrameMetadata metadata = video_header.GetAsMetadata();
162163
EXPECT_EQ(metadata.GetCodec(), VideoCodecType::kVideoCodecVP9);
163164
}
164165

166+
TEST(RTPVideoHeaderTest, GetAsMetadataGetRTPVideoHeaderCodecSpecifics) {
167+
RTPVideoHeader video_header;
168+
{
169+
video_header.codec = VideoCodecType::kVideoCodecVP8;
170+
RTPVideoHeaderVP8 vp8_specifics;
171+
vp8_specifics.InitRTPVideoHeaderVP8();
172+
vp8_specifics.pictureId = 42;
173+
video_header.video_type_header = vp8_specifics;
174+
VideoFrameMetadata metadata = video_header.GetAsMetadata();
175+
EXPECT_EQ(
176+
absl::get<RTPVideoHeaderVP8>(metadata.GetRTPVideoHeaderCodecSpecifics())
177+
.pictureId,
178+
vp8_specifics.pictureId);
179+
}
180+
{
181+
video_header.codec = VideoCodecType::kVideoCodecVP9;
182+
RTPVideoHeaderVP9 vp9_specifics;
183+
vp9_specifics.InitRTPVideoHeaderVP9();
184+
vp9_specifics.max_picture_id = 42;
185+
video_header.video_type_header = vp9_specifics;
186+
VideoFrameMetadata metadata = video_header.GetAsMetadata();
187+
EXPECT_EQ(
188+
absl::get<RTPVideoHeaderVP9>(metadata.GetRTPVideoHeaderCodecSpecifics())
189+
.max_picture_id,
190+
vp9_specifics.max_picture_id);
191+
}
192+
{
193+
video_header.codec = VideoCodecType::kVideoCodecH264;
194+
RTPVideoHeaderH264 h264_specifics;
195+
h264_specifics.nalu_type = 42;
196+
video_header.video_type_header = h264_specifics;
197+
VideoFrameMetadata metadata = video_header.GetAsMetadata();
198+
EXPECT_EQ(absl::get<RTPVideoHeaderH264>(
199+
metadata.GetRTPVideoHeaderCodecSpecifics())
200+
.nalu_type,
201+
h264_specifics.nalu_type);
202+
}
203+
}
204+
165205
} // namespace
166206
} // namespace webrtc

0 commit comments

Comments
 (0)