Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit fff6b8b

Browse files
taste1981jianjunznotorcaPiasyJinChengShi
committed
Update M83 code to work with owt-sdk (#68)
* Add HEVC support for iOS/Android * Some changes for building with OWT * Enable openssl * Add create_peerconnection_factory to WebRTC.framework. (#46) * Set kVTCompressionPropertyKey_RealTime to true. (#51) * H265 packetization_mode setting fix (#53) * add H.265 QP parsing logic (#47) * Fix linux build error. (#54) * Add h264 prefix NAL parser implmentation for enabling frame-marking for h.264 (#58) * Make hevc rtp depacketizer/tracker conforming to h.264 design Co-authored-by: jianjunz <[email protected]> Co-authored-by: Cyril Lashkevich <[email protected]> Co-authored-by: Piasy <[email protected]> Co-authored-by: ShiJinCheng <[email protected]>
1 parent b15b291 commit fff6b8b

File tree

89 files changed

+5332
-31
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+5332
-31
lines changed

BUILD.gn

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,25 @@ config("common_inherited_config") {
164164
target_gen_dir,
165165
]
166166
}
167+
if (build_with_owt) {
168+
include_dirs = [
169+
# The overrides must be included first as that is the mechanism for
170+
# selecting the override headers in Chromium.
171+
#"../webrtc_overrides",
172+
173+
# Allow includes to be prefixed with webrtc/ in case it is not an
174+
# immediate subdirectory of the top-level.
175+
".",
176+
177+
# Just like the root WebRTC directory is added to include path, the
178+
# corresponding directory tree with generated files needs to be added too.
179+
# Note: this path does not change depending on the current target, e.g.
180+
# it is always "//gen/third_party/webrtc" when building with Chromium.
181+
# See also: http://cs.chromium.org/?q=%5C"default_include_dirs
182+
# https://gn.googlesource.com/gn/+/master/docs/reference.md#target_gen_dir
183+
target_gen_dir,
184+
]
185+
}
167186
if (is_posix || is_fuchsia) {
168187
defines += [ "WEBRTC_POSIX" ]
169188
}
@@ -208,6 +227,10 @@ config("common_inherited_config") {
208227
if (is_ubsan) {
209228
cflags += [ "-fsanitize=float-cast-overflow" ]
210229
}
230+
231+
if (!rtc_use_h265) {
232+
defines += [ "DISABLE_H265" ]
233+
}
211234
}
212235

213236
# TODO(bugs.webrtc.org/9693): Remove the possibility to suppress this warning
@@ -295,7 +318,7 @@ config("common_config") {
295318

296319
cflags = []
297320

298-
if (build_with_chromium) {
321+
if (build_with_chromium || build_with_owt) {
299322
defines += [
300323
# NOTICE: Since common_inherited_config is used in public_configs for our
301324
# targets, there's no point including the defines in that config here.
@@ -430,10 +453,13 @@ if (!build_with_chromium) {
430453
rtc_static_library("webrtc") {
431454
# Only the root target and the test should depend on this.
432455
visibility = [
433-
"//:default",
434-
"//:webrtc_lib_link_test",
456+
".:default",
457+
":webrtc_lib_link_test",
435458
]
436459

460+
if (build_with_owt) {
461+
visibility += [ "//talk/owt" ]
462+
}
437463
sources = []
438464
complete_static_lib = true
439465
suppressed_configs += [ "//build/config/compiler:thin_archive" ]

api/video/video_codec_type.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ enum VideoCodecType {
2222
kVideoCodecVP9,
2323
kVideoCodecAV1,
2424
kVideoCodecH264,
25+
#ifndef DISABLE_H265
26+
kVideoCodecH265,
27+
#endif
2528
kVideoCodecMultiplex,
2629
};
2730

api/video_codecs/video_codec.cc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ constexpr char kPayloadNameVp9[] = "VP9";
2525
// frozen.
2626
constexpr char kPayloadNameAv1[] = "AV1X";
2727
constexpr char kPayloadNameH264[] = "H264";
28+
#ifndef DISABLE_H265
29+
constexpr char kPayloadNameH265[] = "H265";
30+
#endif
2831
constexpr char kPayloadNameGeneric[] = "Generic";
2932
constexpr char kPayloadNameMultiplex[] = "Multiplex";
3033
} // namespace
@@ -56,6 +59,17 @@ bool VideoCodecH264::operator==(const VideoCodecH264& other) const {
5659
numberOfTemporalLayers == other.numberOfTemporalLayers);
5760
}
5861

62+
#ifndef DISABLE_H265
63+
bool VideoCodecH265::operator==(const VideoCodecH265& other) const {
64+
return (frameDroppingOn == other.frameDroppingOn &&
65+
keyFrameInterval == other.keyFrameInterval &&
66+
vpsLen == other.vpsLen && spsLen == other.spsLen &&
67+
ppsLen == other.ppsLen &&
68+
(spsLen == 0 || memcmp(spsData, other.spsData, spsLen) == 0) &&
69+
(ppsLen == 0 || memcmp(ppsData, other.ppsData, ppsLen) == 0));
70+
}
71+
#endif
72+
5973
VideoCodec::VideoCodec()
6074
: codecType(kVideoCodecGeneric),
6175
width(0),
@@ -105,6 +119,18 @@ const VideoCodecH264& VideoCodec::H264() const {
105119
return codec_specific_.H264;
106120
}
107121

122+
#ifndef DISABLE_H265
123+
VideoCodecH265* VideoCodec::H265() {
124+
RTC_DCHECK_EQ(codecType, kVideoCodecH265);
125+
return &codec_specific_.H265;
126+
}
127+
128+
const VideoCodecH265& VideoCodec::H265() const {
129+
RTC_DCHECK_EQ(codecType, kVideoCodecH265);
130+
return codec_specific_.H265;
131+
}
132+
#endif
133+
108134
const char* CodecTypeToPayloadString(VideoCodecType type) {
109135
switch (type) {
110136
case kVideoCodecVP8:
@@ -115,9 +141,14 @@ const char* CodecTypeToPayloadString(VideoCodecType type) {
115141
return kPayloadNameAv1;
116142
case kVideoCodecH264:
117143
return kPayloadNameH264;
144+
#ifndef DISABLE_H265
145+
case kVideoCodecH265:
146+
return kPayloadNameH265;
147+
#endif
118148
case kVideoCodecMultiplex:
119149
return kPayloadNameMultiplex;
120150
case kVideoCodecGeneric:
151+
default:
121152
return kPayloadNameGeneric;
122153
}
123154
RTC_CHECK_NOTREACHED();
@@ -134,6 +165,10 @@ VideoCodecType PayloadStringToCodecType(const std::string& name) {
134165
return kVideoCodecH264;
135166
if (absl::EqualsIgnoreCase(name, kPayloadNameMultiplex))
136167
return kVideoCodecMultiplex;
168+
#ifndef DISABLE_H265
169+
if (absl::EqualsIgnoreCase(name, kPayloadNameH265))
170+
return kVideoCodecH265;
171+
#endif
137172
return kVideoCodecGeneric;
138173
}
139174

api/video_codecs/video_codec.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,23 @@ struct VideoCodecH264 {
8585
uint8_t numberOfTemporalLayers;
8686
};
8787

88+
#ifndef DISABLE_H265
89+
struct VideoCodecH265 {
90+
bool operator==(const VideoCodecH265& other) const;
91+
bool operator!=(const VideoCodecH265& other) const {
92+
return !(*this == other);
93+
}
94+
bool frameDroppingOn;
95+
int keyFrameInterval;
96+
const uint8_t* vpsData;
97+
size_t vpsLen;
98+
const uint8_t* spsData;
99+
size_t spsLen;
100+
const uint8_t* ppsData;
101+
size_t ppsLen;
102+
};
103+
#endif
104+
88105
// Translates from name of codec to codec type and vice versa.
89106
RTC_EXPORT const char* CodecTypeToPayloadString(VideoCodecType type);
90107
RTC_EXPORT VideoCodecType PayloadStringToCodecType(const std::string& name);
@@ -93,6 +110,9 @@ union VideoCodecUnion {
93110
VideoCodecVP8 VP8;
94111
VideoCodecVP9 VP9;
95112
VideoCodecH264 H264;
113+
#ifndef DISABLE_H265
114+
VideoCodecH265 H265;
115+
#endif
96116
};
97117

98118
enum class VideoCodecMode { kRealtimeVideo, kScreensharing };
@@ -170,6 +190,10 @@ class RTC_EXPORT VideoCodec {
170190
const VideoCodecVP9& VP9() const;
171191
VideoCodecH264* H264();
172192
const VideoCodecH264& H264() const;
193+
#ifndef DISABLE_H265
194+
VideoCodecH265* H265();
195+
const VideoCodecH265& H265() const;
196+
#endif
173197

174198
private:
175199
// TODO(hta): Consider replacing the union with a pointer type.

api/video_codecs/video_encoder.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,23 @@ VideoCodecH264 VideoEncoder::GetDefaultH264Settings() {
6060
return h264_settings;
6161
}
6262

63+
#ifndef DISABLE_H265
64+
VideoCodecH265 VideoEncoder::GetDefaultH265Settings() {
65+
VideoCodecH265 h265_settings;
66+
memset(&h265_settings, 0, sizeof(h265_settings));
67+
68+
// h265_settings.profile = kProfileBase;
69+
h265_settings.frameDroppingOn = true;
70+
h265_settings.keyFrameInterval = 3000;
71+
h265_settings.spsData = nullptr;
72+
h265_settings.spsLen = 0;
73+
h265_settings.ppsData = nullptr;
74+
h265_settings.ppsLen = 0;
75+
76+
return h265_settings;
77+
}
78+
#endif
79+
6380
VideoEncoder::ScalingSettings::ScalingSettings() = default;
6481

6582
VideoEncoder::ScalingSettings::ScalingSettings(KOff) : ScalingSettings() {}

api/video_codecs/video_encoder.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,9 @@ class RTC_EXPORT VideoEncoder {
336336
static VideoCodecVP8 GetDefaultVp8Settings();
337337
static VideoCodecVP9 GetDefaultVp9Settings();
338338
static VideoCodecH264 GetDefaultH264Settings();
339+
#ifndef DISABLE_H265
340+
static VideoCodecH265 GetDefaultH265Settings();
341+
#endif
339342

340343
virtual ~VideoEncoder() {}
341344

api/video_codecs/video_encoder_config.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ void VideoEncoderConfig::EncoderSpecificSettings::FillEncoderSpecificSettings(
9595
FillVideoCodecVp8(codec->VP8());
9696
} else if (codec->codecType == kVideoCodecVP9) {
9797
FillVideoCodecVp9(codec->VP9());
98+
#ifndef DISABLE_H265
99+
} else if (codec->codecType == kVideoCodecH265) {
100+
FillVideoCodecH265(codec->H265());
101+
#endif
98102
} else {
99103
RTC_NOTREACHED() << "Encoder specifics set/used for unknown codec type.";
100104
}
@@ -105,6 +109,13 @@ void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecH264(
105109
RTC_NOTREACHED();
106110
}
107111

112+
#ifndef DISABLE_H265
113+
void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecH265(
114+
VideoCodecH265* h265_settings) const {
115+
RTC_NOTREACHED();
116+
}
117+
#endif
118+
108119
void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp8(
109120
VideoCodecVP8* vp8_settings) const {
110121
RTC_NOTREACHED();
@@ -124,6 +135,17 @@ void VideoEncoderConfig::H264EncoderSpecificSettings::FillVideoCodecH264(
124135
*h264_settings = specifics_;
125136
}
126137

138+
#ifndef DISABLE_H265
139+
VideoEncoderConfig::H265EncoderSpecificSettings::H265EncoderSpecificSettings(
140+
const VideoCodecH265& specifics)
141+
: specifics_(specifics) {}
142+
143+
void VideoEncoderConfig::H265EncoderSpecificSettings::FillVideoCodecH265(
144+
VideoCodecH265* h265_settings) const {
145+
*h265_settings = specifics_;
146+
}
147+
#endif
148+
127149
VideoEncoderConfig::Vp8EncoderSpecificSettings::Vp8EncoderSpecificSettings(
128150
const VideoCodecVP8& specifics)
129151
: specifics_(specifics) {}

api/video_codecs/video_encoder_config.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ class VideoEncoderConfig {
8484
virtual void FillVideoCodecVp8(VideoCodecVP8* vp8_settings) const;
8585
virtual void FillVideoCodecVp9(VideoCodecVP9* vp9_settings) const;
8686
virtual void FillVideoCodecH264(VideoCodecH264* h264_settings) const;
87+
#ifndef DISABLE_H265
88+
virtual void FillVideoCodecH265(VideoCodecH265* h265_settings) const;
89+
#endif
8790

8891
private:
8992
~EncoderSpecificSettings() override {}
@@ -99,6 +102,16 @@ class VideoEncoderConfig {
99102
VideoCodecH264 specifics_;
100103
};
101104

105+
#ifndef DISABLE_H265
106+
class H265EncoderSpecificSettings : public EncoderSpecificSettings {
107+
public:
108+
explicit H265EncoderSpecificSettings(const VideoCodecH265& specifics);
109+
void FillVideoCodecH265(VideoCodecH265* h265_settings) const override;
110+
111+
private:
112+
VideoCodecH265 specifics_;
113+
};
114+
#endif
102115
class Vp8EncoderSpecificSettings : public EncoderSpecificSettings {
103116
public:
104117
explicit Vp8EncoderSpecificSettings(const VideoCodecVP8& specifics);

build_overrides/build.gni

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ ubsan_vptr_blacklist_path =
3535
# so we just ignore that assert. See https://crbug.com/648948 for more info.
3636
ignore_elf32_limitations = true
3737

38+
if (is_win || is_ios || is_android) {
39+
rtc_use_h265 = true
40+
} else {
41+
rtc_use_h265 = false
42+
}
43+
3844
# Use bundled hermetic Xcode installation maintainted by Chromium,
3945
# except for local iOS builds where it's unsupported.
4046
if (host_os == "mac") {

call/rtp_payload_params.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ void PopulateRtpWithCodecSpecifics(const CodecSpecificInfo& info,
9595
rtp->simulcastIdx = spatial_index.value_or(0);
9696
return;
9797
}
98+
#ifndef DISABLE_H265
99+
case kVideoCodecH265: {
100+
auto& h265_header = rtp->video_type_header.emplace<RTPVideoHeaderH265>();
101+
h265_header.packetization_mode =
102+
info.codecSpecific.H265.packetization_mode;
103+
}
104+
return;
105+
#endif
98106
case kVideoCodecMultiplex:
99107
case kVideoCodecGeneric:
100108
rtp->codec = kVideoCodecGeneric;
@@ -286,6 +294,9 @@ void RtpPayloadParams::SetGeneric(const CodecSpecificInfo* codec_specific_info,
286294
is_keyframe, rtp_video_header);
287295
}
288296
return;
297+
#ifndef DISABLE_H265
298+
case VideoCodecType::kVideoCodecH265:
299+
#endif
289300
case VideoCodecType::kVideoCodecMultiplex:
290301
return;
291302
}

0 commit comments

Comments
 (0)