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

Commit b531677

Browse files
taste1981jianjunznotorcaPiasyJinChengShi
authored
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 04c1b44 commit b531677

File tree

92 files changed

+5358
-35
lines changed

Some content is hidden

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

92 files changed

+5358
-35
lines changed

BUILD.gn

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,25 @@ config("common_inherited_config") {
160160
target_gen_dir,
161161
]
162162
}
163+
if (build_with_owt) {
164+
include_dirs = [
165+
# The overrides must be included first as that is the mechanism for
166+
# selecting the override headers in Chromium.
167+
#"../webrtc_overrides",
168+
169+
# Allow includes to be prefixed with webrtc/ in case it is not an
170+
# immediate subdirectory of the top-level.
171+
".",
172+
173+
# Just like the root WebRTC directory is added to include path, the
174+
# corresponding directory tree with generated files needs to be added too.
175+
# Note: this path does not change depending on the current target, e.g.
176+
# it is always "//gen/third_party/webrtc" when building with Chromium.
177+
# See also: http://cs.chromium.org/?q=%5C"default_include_dirs
178+
# https://gn.googlesource.com/gn/+/master/docs/reference.md#target_gen_dir
179+
target_gen_dir,
180+
]
181+
}
163182
if (is_posix || is_fuchsia) {
164183
defines += [ "WEBRTC_POSIX" ]
165184
}
@@ -204,6 +223,10 @@ config("common_inherited_config") {
204223
if (is_ubsan) {
205224
cflags += [ "-fsanitize=float-cast-overflow" ]
206225
}
226+
227+
if (!rtc_use_h265) {
228+
defines += [ "DISABLE_H265" ]
229+
}
207230
}
208231

209232
# TODO(bugs.webrtc.org/9693): Remove the possibility to suppress this warning
@@ -283,7 +306,7 @@ config("common_config") {
283306

284307
cflags = []
285308

286-
if (build_with_chromium) {
309+
if (build_with_chromium || build_with_owt) {
287310
defines += [
288311
# NOTICE: Since common_inherited_config is used in public_configs for our
289312
# targets, there's no point including the defines in that config here.
@@ -418,10 +441,13 @@ if (!build_with_chromium) {
418441
rtc_static_library("webrtc") {
419442
# Only the root target and the test should depend on this.
420443
visibility = [
421-
"//:default",
422-
"//:webrtc_lib_link_test",
444+
".:default",
445+
":webrtc_lib_link_test",
423446
]
424447

448+
if (build_with_owt) {
449+
visibility += [ "//talk/owt" ]
450+
}
425451
sources = []
426452
complete_static_lib = true
427453
suppressed_configs += [ "//build/config/compiler:thin_archive" ]

api/video/builtin_video_bitrate_allocator_factory.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class BuiltinVideoBitrateAllocatorFactory
3535
case kVideoCodecVP9:
3636
rate_allocator.reset(new SvcRateAllocator(codec));
3737
break;
38+
// TODO: add an allocator here for H.265
3839
default:
3940
rate_allocator.reset(new SimulcastRateAllocator(codec));
4041
}

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
bool SpatialLayer::operator==(const SpatialLayer& other) const {
6074
return (width == other.width && height == other.height &&
6175
maxFramerate == other.maxFramerate &&
@@ -115,6 +129,18 @@ const VideoCodecH264& VideoCodec::H264() const {
115129
return codec_specific_.H264;
116130
}
117131

132+
#ifndef DISABLE_H265
133+
VideoCodecH265* VideoCodec::H265() {
134+
RTC_DCHECK_EQ(codecType, kVideoCodecH265);
135+
return &codec_specific_.H265;
136+
}
137+
138+
const VideoCodecH265& VideoCodec::H265() const {
139+
RTC_DCHECK_EQ(codecType, kVideoCodecH265);
140+
return codec_specific_.H265;
141+
}
142+
#endif
143+
118144
const char* CodecTypeToPayloadString(VideoCodecType type) {
119145
switch (type) {
120146
case kVideoCodecVP8:
@@ -125,9 +151,14 @@ const char* CodecTypeToPayloadString(VideoCodecType type) {
125151
return kPayloadNameAv1;
126152
case kVideoCodecH264:
127153
return kPayloadNameH264;
154+
#ifndef DISABLE_H265
155+
case kVideoCodecH265:
156+
return kPayloadNameH265;
157+
#endif
128158
case kVideoCodecMultiplex:
129159
return kPayloadNameMultiplex;
130160
case kVideoCodecGeneric:
161+
default:
131162
return kPayloadNameGeneric;
132163
}
133164
}
@@ -143,6 +174,10 @@ VideoCodecType PayloadStringToCodecType(const std::string& name) {
143174
return kVideoCodecH264;
144175
if (absl::EqualsIgnoreCase(name, kPayloadNameMultiplex))
145176
return kVideoCodecMultiplex;
177+
#ifndef DISABLE_H265
178+
if (absl::EqualsIgnoreCase(name, kPayloadNameH265))
179+
return kVideoCodecH265;
180+
#endif
146181
return kVideoCodecGeneric;
147182
}
148183

api/video_codecs/video_codec.h

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

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

97117
enum class VideoCodecMode { kRealtimeVideo, kScreensharing };
@@ -159,6 +179,10 @@ class RTC_EXPORT VideoCodec {
159179
const VideoCodecVP9& VP9() const;
160180
VideoCodecH264* H264();
161181
const VideoCodecH264& H264() const;
182+
#ifndef DISABLE_H265
183+
VideoCodecH265* H265();
184+
const VideoCodecH265& H265() const;
185+
#endif
162186

163187
private:
164188
// 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
@@ -320,6 +320,9 @@ class RTC_EXPORT VideoEncoder {
320320
static VideoCodecVP8 GetDefaultVp8Settings();
321321
static VideoCodecVP9 GetDefaultVp9Settings();
322322
static VideoCodecH264 GetDefaultH264Settings();
323+
#ifndef DISABLE_H265
324+
static VideoCodecH265 GetDefaultH265Settings();
325+
#endif
323326

324327
virtual ~VideoEncoder() {}
325328

api/video_codecs/video_encoder_config.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ void VideoEncoderConfig::EncoderSpecificSettings::FillEncoderSpecificSettings(
9393
FillVideoCodecVp8(codec->VP8());
9494
} else if (codec->codecType == kVideoCodecVP9) {
9595
FillVideoCodecVp9(codec->VP9());
96+
#ifndef DISABLE_H265
97+
} else if (codec->codecType == kVideoCodecH265) {
98+
FillVideoCodecH265(codec->H265());
99+
#endif
96100
} else {
97101
RTC_NOTREACHED() << "Encoder specifics set/used for unknown codec type.";
98102
}
@@ -103,6 +107,13 @@ void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecH264(
103107
RTC_NOTREACHED();
104108
}
105109

110+
#ifndef DISABLE_H265
111+
void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecH265(
112+
VideoCodecH265* h265_settings) const {
113+
RTC_NOTREACHED();
114+
}
115+
#endif
116+
106117
void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp8(
107118
VideoCodecVP8* vp8_settings) const {
108119
RTC_NOTREACHED();
@@ -122,6 +133,17 @@ void VideoEncoderConfig::H264EncoderSpecificSettings::FillVideoCodecH264(
122133
*h264_settings = specifics_;
123134
}
124135

136+
#ifndef DISABLE_H265
137+
VideoEncoderConfig::H265EncoderSpecificSettings::H265EncoderSpecificSettings(
138+
const VideoCodecH265& specifics)
139+
: specifics_(specifics) {}
140+
141+
void VideoEncoderConfig::H265EncoderSpecificSettings::FillVideoCodecH265(
142+
VideoCodecH265* h265_settings) const {
143+
*h265_settings = specifics_;
144+
}
145+
#endif
146+
125147
VideoEncoderConfig::Vp8EncoderSpecificSettings::Vp8EncoderSpecificSettings(
126148
const VideoCodecVP8& specifics)
127149
: 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 @@ lint_suppressions_file = "//tools_webrtc/android/suppressions.xml"
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") {

0 commit comments

Comments
 (0)