Support more H264 profiles for internal software codec
Care should be taken when landing this, because it will affect users of WebRTC. I'm thinking primarily of Chromium. Chromium will start to support High profile and Baseline profile using SW codecs with this CL. Clients who do SDP munging without looking at the H264 profile might switch from Constrained Baseline to High profile with this change. Bug: webrtc:8317 Change-Id: Idca3a6b761a66d9e521b913b850c6ae14381f1f4 Reviewed-on: https://webrtc-review.googlesource.com/6341 Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> Commit-Queue: Magnus Jedvert <magjed@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20190}
This commit is contained in:
committed by
Commit Bot
parent
8081073677
commit
8deb818086
5
modules/video_coding/codecs/h264/DEPS
Normal file
5
modules/video_coding/codecs/h264/DEPS
Normal file
@ -0,0 +1,5 @@
|
||||
include_rules = [
|
||||
"+third_party/ffmpeg",
|
||||
"+third_party/openh264",
|
||||
"+media/base",
|
||||
]
|
||||
@ -12,6 +12,7 @@
|
||||
#include "modules/video_coding/codecs/h264/include/h264.h"
|
||||
|
||||
#include "api/video_codecs/sdp_video_format.h"
|
||||
#include "media/base/h264_profile_level_id.h"
|
||||
|
||||
#if defined(WEBRTC_USE_H264)
|
||||
#include "modules/video_coding/codecs/h264/h264_decoder_impl.h"
|
||||
@ -29,7 +30,7 @@ namespace {
|
||||
bool g_rtc_use_h264 = true;
|
||||
#endif
|
||||
|
||||
// If any H.264 codec is supported (iOS HW or OpenH264/FFmpeg).
|
||||
// If H.264 OpenH264/FFmpeg codec is supported.
|
||||
bool IsH264CodecSupported() {
|
||||
#if defined(WEBRTC_USE_H264)
|
||||
return g_rtc_use_h264;
|
||||
@ -38,6 +39,16 @@ bool IsH264CodecSupported() {
|
||||
#endif
|
||||
}
|
||||
|
||||
SdpVideoFormat CreateH264Format(H264::Profile profile, H264::Level level) {
|
||||
const rtc::Optional<std::string> profile_string =
|
||||
H264::ProfileLevelIdToString(H264::ProfileLevelId(profile, level));
|
||||
RTC_CHECK(profile_string);
|
||||
return SdpVideoFormat(cricket::kH264CodecName,
|
||||
{{cricket::kH264FmtpProfileLevelId, *profile_string},
|
||||
{cricket::kH264FmtpLevelAsymmetryAllowed, "1"},
|
||||
{cricket::kH264FmtpPacketizationMode, "1"}});
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void DisableRtcUseH264() {
|
||||
@ -49,15 +60,15 @@ void DisableRtcUseH264() {
|
||||
std::vector<SdpVideoFormat> SupportedH264Codecs() {
|
||||
if (!IsH264CodecSupported())
|
||||
return std::vector<SdpVideoFormat>();
|
||||
std::vector<SdpVideoFormat> codecs;
|
||||
|
||||
codecs.push_back(SdpVideoFormat(
|
||||
cricket::kH264CodecName, {{cricket::kH264FmtpProfileLevelId,
|
||||
cricket::kH264ProfileLevelConstrainedBaseline},
|
||||
{cricket::kH264FmtpLevelAsymmetryAllowed, "1"},
|
||||
{cricket::kH264FmtpPacketizationMode, "1"}}));
|
||||
|
||||
return codecs;
|
||||
// We only support encoding Constrained Baseline Profile (CBP), but the
|
||||
// decoder supports more profiles. We can list all profiles here that are
|
||||
// supported by the decoder and that are also supersets of CBP, i.e. the
|
||||
// decoder for that profile is required to be able to decode CBP. This means
|
||||
// we can encode and send CBP even though we negotiated a potentially
|
||||
// higher profile. See the H264 spec for more information.
|
||||
return {CreateH264Format(H264::kProfileHigh, H264::kLevel3_1),
|
||||
CreateH264Format(H264::kProfileConstrainedBaseline, H264::kLevel3_1),
|
||||
CreateH264Format(H264::kProfileBaseline, H264::kLevel3_1)};
|
||||
}
|
||||
|
||||
H264Encoder* H264Encoder::Create(const cricket::VideoCodec& codec) {
|
||||
|
||||
Reference in New Issue
Block a user