Bug 1376873 - Use VP8SimulcastAdapter in VideoConduit; r=ng

The VP8SimulcastAdapter automatically handles cropping to accomodate
constraints on VP8 simulcast streams that each stream have exactly half the
width and height of the higher resolution stream before it.

This also adjusts min_bitrate_estimate in
test_peerConnection_simulcastOddResolution.html to compensate for changes in
the simulcast resolutions chosen by the webrtc.org code.

Differential Revision: https://phabricator.services.mozilla.com/D7482

--HG--
extra : rebase_source : b7ea403f7c9d6175a34eb11c7af17dd12ee55c31
This commit is contained in:
Andreas Pehrson 2018-09-21 16:45:47 +02:00
Родитель 0cf790ab2b
Коммит 30610de2f0
3 изменённых файлов: 69 добавлений и 32 удалений

Просмотреть файл

@ -89,10 +89,8 @@
runNetworkTest(async () => { runNetworkTest(async () => {
await pushPrefs(['media.peerconnection.simulcast', true], await pushPrefs(['media.peerconnection.simulcast', true],
['media.peerconnection.video.lock_scaling', true], ['media.peerconnection.video.lock_scaling', true],
// 180Kbps was determined empirically, set well-higher than // 240Kbps was determined empirically
// the 80Kbps+overhead needed for the two simulcast streams. ['media.peerconnection.video.min_bitrate_estimate', 240*1000]);
// 100Kbps was apparently too low.
['media.peerconnection.video.min_bitrate_estimate', 180*1000]);
let emitter, helper; let emitter, helper;

Просмотреть файл

@ -22,6 +22,8 @@
#include "pk11pub.h" #include "pk11pub.h"
#include "api/video_codecs/sdp_video_format.h"
#include "media/engine/vp8_encoder_simulcast_proxy.h"
#include "webrtc/common_types.h" #include "webrtc/common_types.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
@ -1751,34 +1753,7 @@ WebrtcVideoConduit::CreateEncoder(webrtc::VideoCodecType aType,
break; break;
case webrtc::VideoCodecType::kVideoCodecVP8: case webrtc::VideoCodecType::kVideoCodecVP8:
#ifdef MOZ_WEBRTC_MEDIACODEC encoder.reset(new webrtc::VP8EncoderSimulcastProxy(this));
// attempt to get a encoder
enabled = mozilla::Preferences::GetBool(
"media.navigator.hardware.vp8_encode.acceleration_enabled", false);
if (enabled) {
nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
if (gfxInfo) {
int32_t status;
nsCString discardFailureId;
if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(
nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_ENCODE,
discardFailureId, &status))) {
if (status != nsIGfxInfo::FEATURE_STATUS_OK) {
NS_WARNING("VP8 encoder hardware is not whitelisted: disabling.\n");
} else {
encoder = MediaCodecVideoCodec::CreateEncoder(
MediaCodecVideoCodec::CodecType::CODEC_VP8);
}
}
}
}
#endif
// Use a software VP8 encoder as a fallback.
if (!encoder) {
encoder = webrtc::VP8Encoder::Create();
}
break; break;
case webrtc::VideoCodecType::kVideoCodecVP9: case webrtc::VideoCodecType::kVideoCodecVP9:
@ -1791,6 +1766,59 @@ WebrtcVideoConduit::CreateEncoder(webrtc::VideoCodecType aType,
return encoder; return encoder;
} }
std::vector<webrtc::SdpVideoFormat>
WebrtcVideoConduit::GetSupportedFormats() const
{
MOZ_ASSERT_UNREACHABLE("Unexpected call");
CSFLogError(LOGTAG, "Unexpected call to GetSupportedFormats()");
return {webrtc::SdpVideoFormat("VP8")};
}
WebrtcVideoConduit::CodecInfo
WebrtcVideoConduit::QueryVideoEncoder(const webrtc::SdpVideoFormat& format) const
{
MOZ_ASSERT_UNREACHABLE("Unexpected call");
CSFLogError(LOGTAG, "Unexpected call to QueryVideoEncoder()");
CodecInfo info;
info.is_hardware_accelerated = false;
info.has_internal_source = false;
return info;
}
std::unique_ptr<webrtc::VideoEncoder>
WebrtcVideoConduit::CreateVideoEncoder(const webrtc::SdpVideoFormat& format)
{
MOZ_ASSERT(format.name == "VP8");
std::unique_ptr<webrtc::VideoEncoder> encoder = nullptr;
#ifdef MOZ_WEBRTC_MEDIACODEC
// attempt to get a encoder
enabled = mozilla::Preferences::GetBool(
"media.navigator.hardware.vp8_encode.acceleration_enabled", false);
if (enabled) {
nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
if (gfxInfo) {
int32_t status;
nsCString discardFailureId;
if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(
nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_ENCODE,
discardFailureId, &status))) {
if (status != nsIGfxInfo::FEATURE_STATUS_OK) {
NS_WARNING("VP8 encoder hardware is not whitelisted: disabling.\n");
} else {
encoder = MediaCodecVideoCodec::CreateEncoder(
MediaCodecVideoCodec::CodecType::CODEC_VP8);
}
}
}
}
#endif
// Use a software VP8 encoder as a fallback.
encoder = webrtc::VP8Encoder::Create();
return encoder;
}
// XXX we need to figure out how to feed back changes in preferred capture // XXX we need to figure out how to feed back changes in preferred capture
// resolution to the getUserMedia source. // resolution to the getUserMedia source.
void void

Просмотреть файл

@ -21,6 +21,7 @@
// conflicts with #include of scoped_ptr.h // conflicts with #include of scoped_ptr.h
#undef FF #undef FF
// Video Engine Includes // Video Engine Includes
#include "api/video_codecs/video_encoder_factory.h"
#include "webrtc/call/call.h" #include "webrtc/call/call.h"
#include "webrtc/common_types.h" #include "webrtc/common_types.h"
#ifdef FF #ifdef FF
@ -28,6 +29,7 @@
#endif #endif
#include "webrtc/api/video_codecs/video_decoder.h" #include "webrtc/api/video_codecs/video_decoder.h"
#include "webrtc/api/video_codecs/video_encoder.h" #include "webrtc/api/video_codecs/video_encoder.h"
#include "webrtc/api/video_codecs/sdp_video_format.h"
#include "webrtc/common_video/include/i420_buffer_pool.h" #include "webrtc/common_video/include/i420_buffer_pool.h"
#include "webrtc/media/base/videosinkinterface.h" #include "webrtc/media/base/videosinkinterface.h"
#include "webrtc/media/base/videoadapter.h" #include "webrtc/media/base/videoadapter.h"
@ -72,6 +74,7 @@ class WebrtcVideoDecoder : public VideoDecoder
*/ */
class WebrtcVideoConduit : public VideoSessionConduit class WebrtcVideoConduit : public VideoSessionConduit
, public webrtc::Transport , public webrtc::Transport
, public webrtc::VideoEncoderFactory
, public rtc::VideoSinkInterface<webrtc::VideoFrame> , public rtc::VideoSinkInterface<webrtc::VideoFrame>
, public rtc::VideoSourceInterface<webrtc::VideoFrame> , public rtc::VideoSourceInterface<webrtc::VideoFrame>
{ {
@ -462,6 +465,14 @@ private:
std::unique_ptr<webrtc::VideoEncoder> CreateEncoder(webrtc::VideoCodecType aType, std::unique_ptr<webrtc::VideoEncoder> CreateEncoder(webrtc::VideoCodecType aType,
bool enable_simulcast); bool enable_simulcast);
// webrtc::VideoEncoderFactory
std::vector<webrtc::SdpVideoFormat> GetSupportedFormats() const override;
CodecInfo QueryVideoEncoder(const webrtc::SdpVideoFormat& format) const override;
std::unique_ptr<webrtc::VideoEncoder> CreateVideoEncoder(
const webrtc::SdpVideoFormat& format) override;
MediaConduitErrorCode DeliverPacket(const void *data, int len) override; MediaConduitErrorCode DeliverPacket(const void *data, int len) override;
bool RequiresNewSendStream(const VideoCodecConfig& newConfig) const; bool RequiresNewSendStream(const VideoCodecConfig& newConfig) const;