|
|
|
|
@ -12,37 +12,23 @@
|
|
|
|
|
#include "webrtc/base/logging.h"
|
|
|
|
|
#include "webrtc/common_video/h264/profile_level_id.h"
|
|
|
|
|
#include "webrtc/media/base/codec.h"
|
|
|
|
|
#include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.h"
|
|
|
|
|
#include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_decoder.h"
|
|
|
|
|
#include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.h"
|
|
|
|
|
#include "webrtc/system_wrappers/include/field_trial.h"
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
const char kHighProfileExperiment[] = "WebRTC-H264HighProfile";
|
|
|
|
|
|
|
|
|
|
bool IsHighProfileEnabled() {
|
|
|
|
|
return field_trial::FindFullName(kHighProfileExperiment) == "Enabled";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// VideoToolboxVideoEncoderFactory
|
|
|
|
|
|
|
|
|
|
VideoToolboxVideoEncoderFactory::VideoToolboxVideoEncoderFactory() {
|
|
|
|
|
// TODO(magjed): Enumerate actual level instead of using hardcoded level 3.1.
|
|
|
|
|
// Level 3.1 is 1280x720@30fps which is enough for now.
|
|
|
|
|
const H264::Level level = H264::kLevel3_1;
|
|
|
|
|
|
|
|
|
|
cricket::VideoCodec constrained_high(cricket::kH264CodecName);
|
|
|
|
|
const H264::ProfileLevelId constrained_high_profile(
|
|
|
|
|
H264::kProfileConstrainedHigh, level);
|
|
|
|
|
constrained_high.SetParam(
|
|
|
|
|
cricket::kH264FmtpProfileLevelId,
|
|
|
|
|
*H264::ProfileLevelIdToString(constrained_high_profile));
|
|
|
|
|
constrained_high.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, "1");
|
|
|
|
|
constrained_high.SetParam(cricket::kH264FmtpPacketizationMode, "1");
|
|
|
|
|
supported_codecs_.push_back(constrained_high);
|
|
|
|
|
|
|
|
|
|
cricket::VideoCodec constrained_baseline(cricket::kH264CodecName);
|
|
|
|
|
const H264::ProfileLevelId constrained_baseline_profile(
|
|
|
|
|
H264::kProfileConstrainedBaseline, level);
|
|
|
|
|
constrained_baseline.SetParam(
|
|
|
|
|
cricket::kH264FmtpProfileLevelId,
|
|
|
|
|
*H264::ProfileLevelIdToString(constrained_baseline_profile));
|
|
|
|
|
constrained_baseline.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, "1");
|
|
|
|
|
constrained_baseline.SetParam(cricket::kH264FmtpPacketizationMode, "1");
|
|
|
|
|
supported_codecs_.push_back(constrained_baseline);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VideoToolboxVideoEncoderFactory::~VideoToolboxVideoEncoderFactory() {}
|
|
|
|
|
@ -65,6 +51,34 @@ void VideoToolboxVideoEncoderFactory::DestroyVideoEncoder(
|
|
|
|
|
|
|
|
|
|
const std::vector<cricket::VideoCodec>&
|
|
|
|
|
VideoToolboxVideoEncoderFactory::supported_codecs() const {
|
|
|
|
|
supported_codecs_.clear();
|
|
|
|
|
|
|
|
|
|
// TODO(magjed): Enumerate actual level instead of using hardcoded level 3.1.
|
|
|
|
|
// Level 3.1 is 1280x720@30fps which is enough for now.
|
|
|
|
|
const H264::Level level = H264::kLevel3_1;
|
|
|
|
|
|
|
|
|
|
if (IsHighProfileEnabled()) {
|
|
|
|
|
cricket::VideoCodec constrained_high(cricket::kH264CodecName);
|
|
|
|
|
const H264::ProfileLevelId constrained_high_profile(
|
|
|
|
|
H264::kProfileConstrainedHigh, level);
|
|
|
|
|
constrained_high.SetParam(
|
|
|
|
|
cricket::kH264FmtpProfileLevelId,
|
|
|
|
|
*H264::ProfileLevelIdToString(constrained_high_profile));
|
|
|
|
|
constrained_high.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, "1");
|
|
|
|
|
constrained_high.SetParam(cricket::kH264FmtpPacketizationMode, "1");
|
|
|
|
|
supported_codecs_.push_back(constrained_high);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cricket::VideoCodec constrained_baseline(cricket::kH264CodecName);
|
|
|
|
|
const H264::ProfileLevelId constrained_baseline_profile(
|
|
|
|
|
H264::kProfileConstrainedBaseline, level);
|
|
|
|
|
constrained_baseline.SetParam(
|
|
|
|
|
cricket::kH264FmtpProfileLevelId,
|
|
|
|
|
*H264::ProfileLevelIdToString(constrained_baseline_profile));
|
|
|
|
|
constrained_baseline.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, "1");
|
|
|
|
|
constrained_baseline.SetParam(cricket::kH264FmtpPacketizationMode, "1");
|
|
|
|
|
supported_codecs_.push_back(constrained_baseline);
|
|
|
|
|
|
|
|
|
|
return supported_codecs_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|