(Auto)update libjingle 71099685-> 71107853
git-svn-id: http://webrtc.googlecode.com/svn/trunk@6674 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
a4da771914
commit
b92f6f9371
@ -59,8 +59,9 @@ const char SessionDescriptionInterface::kAnswer[] = "answer";
|
|||||||
const int JsepSessionDescription::kDefaultVideoCodecId = 100;
|
const int JsepSessionDescription::kDefaultVideoCodecId = 100;
|
||||||
const int JsepSessionDescription::kDefaultVideoCodecFramerate = 30;
|
const int JsepSessionDescription::kDefaultVideoCodecFramerate = 30;
|
||||||
const char JsepSessionDescription::kDefaultVideoCodecName[] = "VP8";
|
const char JsepSessionDescription::kDefaultVideoCodecName[] = "VP8";
|
||||||
const int JsepSessionDescription::kMaxVideoCodecWidth = 1280;
|
// Used as default max video codec size before we have it in signaling.
|
||||||
const int JsepSessionDescription::kMaxVideoCodecHeight = 720;
|
const int JsepSessionDescription::kMaxVideoCodecWidth = 3840;
|
||||||
|
const int JsepSessionDescription::kMaxVideoCodecHeight = 2160;
|
||||||
const int JsepSessionDescription::kDefaultVideoCodecPreference = 1;
|
const int JsepSessionDescription::kDefaultVideoCodecPreference = 1;
|
||||||
|
|
||||||
SessionDescriptionInterface* CreateSessionDescription(const std::string& type,
|
SessionDescriptionInterface* CreateSessionDescription(const std::string& type,
|
||||||
|
@ -178,7 +178,7 @@ class VideoEngineTest : public testing::Test {
|
|||||||
engine_.codecs()[0].name,
|
engine_.codecs()[0].name,
|
||||||
1280, 800, 30, 0);
|
1280, 800, 30, 0);
|
||||||
|
|
||||||
// set max settings of 1280x960x30
|
// set max settings of 1280x800x30
|
||||||
EXPECT_TRUE(engine_.SetDefaultEncoderConfig(
|
EXPECT_TRUE(engine_.SetDefaultEncoderConfig(
|
||||||
cricket::VideoEncoderConfig(max_settings)));
|
cricket::VideoEncoderConfig(max_settings)));
|
||||||
|
|
||||||
@ -313,6 +313,43 @@ class VideoEngineTest : public testing::Test {
|
|||||||
EXPECT_PRED4(IsEqualRes, out, 160, 120, 10);
|
EXPECT_PRED4(IsEqualRes, out, 160, 120, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is the new way of constraining codec size, where we no longer maintain
|
||||||
|
// a list of the supported formats. Instead, CanSendCodec will just downscale
|
||||||
|
// the resolution by 2 until the width is below clamp.
|
||||||
|
void ConstrainNewCodec2Body() {
|
||||||
|
cricket::VideoCodec empty, in, out;
|
||||||
|
cricket::VideoCodec max_settings(engine_.codecs()[0].id,
|
||||||
|
engine_.codecs()[0].name,
|
||||||
|
1280, 800, 30, 0);
|
||||||
|
|
||||||
|
// Set max settings of 1280x800x30
|
||||||
|
EXPECT_TRUE(engine_.SetDefaultEncoderConfig(
|
||||||
|
cricket::VideoEncoderConfig(max_settings)));
|
||||||
|
|
||||||
|
// Don't constrain the max resolution
|
||||||
|
in = max_settings;
|
||||||
|
EXPECT_TRUE(engine_.CanSendCodec(in, empty, &out));
|
||||||
|
EXPECT_PRED2(IsEqualCodec, out, in);
|
||||||
|
|
||||||
|
// Constrain resolution greater than the max width.
|
||||||
|
in.width = 1380;
|
||||||
|
in.height = 800;
|
||||||
|
EXPECT_TRUE(engine_.CanSendCodec(in, empty, &out));
|
||||||
|
EXPECT_PRED4(IsEqualRes, out, 690, 400, 30);
|
||||||
|
|
||||||
|
// Don't constrain resolution when only the height is greater than max.
|
||||||
|
in.width = 960;
|
||||||
|
in.height = 1280;
|
||||||
|
EXPECT_TRUE(engine_.CanSendCodec(in, empty, &out));
|
||||||
|
EXPECT_PRED4(IsEqualRes, out, 960, 1280, 30);
|
||||||
|
|
||||||
|
// Don't constrain smaller format.
|
||||||
|
in.width = 640;
|
||||||
|
in.height = 480;
|
||||||
|
EXPECT_TRUE(engine_.CanSendCodec(in, empty, &out));
|
||||||
|
EXPECT_PRED4(IsEqualRes, out, 640, 480, 30);
|
||||||
|
}
|
||||||
|
|
||||||
void ConstrainRunningCodecBody() {
|
void ConstrainRunningCodecBody() {
|
||||||
cricket::VideoCodec in, out, current;
|
cricket::VideoCodec in, out, current;
|
||||||
cricket::VideoCodec max_settings(engine_.codecs()[0].id,
|
cricket::VideoCodec max_settings(engine_.codecs()[0].id,
|
||||||
|
@ -841,32 +841,9 @@ const WebRtcVideoEngine::VideoCodecPref
|
|||||||
{kRtxCodecName, 96, 100, 3},
|
{kRtxCodecName, 96, 100, 3},
|
||||||
};
|
};
|
||||||
|
|
||||||
// The formats are sorted by the descending order of width. We use the order to
|
const VideoFormatPod WebRtcVideoEngine::kDefaultMaxVideoFormat =
|
||||||
// find the next format for CPU and bandwidth adaptation.
|
|
||||||
const VideoFormatPod WebRtcVideoEngine::kVideoFormats[] = {
|
|
||||||
{1280, 800, FPS_TO_INTERVAL(30), FOURCC_ANY},
|
|
||||||
{1280, 720, FPS_TO_INTERVAL(30), FOURCC_ANY},
|
|
||||||
{960, 600, FPS_TO_INTERVAL(30), FOURCC_ANY},
|
|
||||||
{960, 540, FPS_TO_INTERVAL(30), FOURCC_ANY},
|
|
||||||
{640, 400, FPS_TO_INTERVAL(30), FOURCC_ANY},
|
|
||||||
{640, 360, FPS_TO_INTERVAL(30), FOURCC_ANY},
|
|
||||||
{640, 480, FPS_TO_INTERVAL(30), FOURCC_ANY},
|
|
||||||
{480, 300, FPS_TO_INTERVAL(30), FOURCC_ANY},
|
|
||||||
{480, 270, FPS_TO_INTERVAL(30), FOURCC_ANY},
|
|
||||||
{480, 360, FPS_TO_INTERVAL(30), FOURCC_ANY},
|
|
||||||
{320, 200, FPS_TO_INTERVAL(30), FOURCC_ANY},
|
|
||||||
{320, 180, FPS_TO_INTERVAL(30), FOURCC_ANY},
|
|
||||||
{320, 240, FPS_TO_INTERVAL(30), FOURCC_ANY},
|
|
||||||
{240, 150, FPS_TO_INTERVAL(30), FOURCC_ANY},
|
|
||||||
{240, 135, FPS_TO_INTERVAL(30), FOURCC_ANY},
|
|
||||||
{240, 180, FPS_TO_INTERVAL(30), FOURCC_ANY},
|
|
||||||
{160, 100, FPS_TO_INTERVAL(30), FOURCC_ANY},
|
|
||||||
{160, 90, FPS_TO_INTERVAL(30), FOURCC_ANY},
|
|
||||||
{160, 120, FPS_TO_INTERVAL(30), FOURCC_ANY},
|
|
||||||
};
|
|
||||||
|
|
||||||
const VideoFormatPod WebRtcVideoEngine::kDefaultVideoFormat =
|
|
||||||
{640, 400, FPS_TO_INTERVAL(30), FOURCC_ANY};
|
{640, 400, FPS_TO_INTERVAL(30), FOURCC_ANY};
|
||||||
|
// TODO(ronghuawu): Change to 640x360.
|
||||||
|
|
||||||
static void UpdateVideoCodec(const cricket::VideoFormat& video_format,
|
static void UpdateVideoCodec(const cricket::VideoFormat& video_format,
|
||||||
webrtc::VideoCodec* target_codec) {
|
webrtc::VideoCodec* target_codec) {
|
||||||
@ -970,9 +947,10 @@ void WebRtcVideoEngine::Construct(ViEWrapper* vie_wrapper,
|
|||||||
// by the server with a jec in response to our reported system info.
|
// by the server with a jec in response to our reported system info.
|
||||||
VideoCodec max_codec(kVideoCodecPrefs[0].payload_type,
|
VideoCodec max_codec(kVideoCodecPrefs[0].payload_type,
|
||||||
kVideoCodecPrefs[0].name,
|
kVideoCodecPrefs[0].name,
|
||||||
kDefaultVideoFormat.width,
|
kDefaultMaxVideoFormat.width,
|
||||||
kDefaultVideoFormat.height,
|
kDefaultMaxVideoFormat.height,
|
||||||
VideoFormat::IntervalToFps(kDefaultVideoFormat.interval),
|
VideoFormat::IntervalToFps(
|
||||||
|
kDefaultMaxVideoFormat.interval),
|
||||||
0);
|
0);
|
||||||
if (!SetDefaultCodec(max_codec)) {
|
if (!SetDefaultCodec(max_codec)) {
|
||||||
LOG(LS_ERROR) << "Failed to initialize list of supported codec types";
|
LOG(LS_ERROR) << "Failed to initialize list of supported codec types";
|
||||||
@ -1163,37 +1141,31 @@ int WebRtcVideoEngine::GetLastEngineError() {
|
|||||||
|
|
||||||
// Checks to see whether we comprehend and could receive a particular codec
|
// Checks to see whether we comprehend and could receive a particular codec
|
||||||
bool WebRtcVideoEngine::FindCodec(const VideoCodec& in) {
|
bool WebRtcVideoEngine::FindCodec(const VideoCodec& in) {
|
||||||
for (int i = 0; i < ARRAY_SIZE(kVideoFormats); ++i) {
|
if (encoder_factory_) {
|
||||||
const VideoFormat fmt(kVideoFormats[i]);
|
const std::vector<WebRtcVideoEncoderFactory::VideoCodec>& codecs =
|
||||||
if ((in.width == 0 && in.height == 0) ||
|
encoder_factory_->codecs();
|
||||||
(fmt.width == in.width && fmt.height == in.height)) {
|
for (size_t j = 0; j < codecs.size(); ++j) {
|
||||||
if (encoder_factory_) {
|
VideoCodec codec(GetExternalVideoPayloadType(static_cast<int>(j)),
|
||||||
const std::vector<WebRtcVideoEncoderFactory::VideoCodec>& codecs =
|
codecs[j].name, 0, 0, 0, 0);
|
||||||
encoder_factory_->codecs();
|
if (codec.Matches(in))
|
||||||
for (size_t j = 0; j < codecs.size(); ++j) {
|
return true;
|
||||||
VideoCodec codec(GetExternalVideoPayloadType(static_cast<int>(j)),
|
}
|
||||||
codecs[j].name, 0, 0, 0, 0);
|
}
|
||||||
if (codec.Matches(in))
|
for (size_t j = 0; j < ARRAY_SIZE(kVideoCodecPrefs); ++j) {
|
||||||
return true;
|
VideoCodec codec(kVideoCodecPrefs[j].payload_type,
|
||||||
}
|
kVideoCodecPrefs[j].name, 0, 0, 0, 0);
|
||||||
}
|
if (codec.Matches(in)) {
|
||||||
for (size_t j = 0; j < ARRAY_SIZE(kVideoCodecPrefs); ++j) {
|
return true;
|
||||||
VideoCodec codec(kVideoCodecPrefs[j].payload_type,
|
|
||||||
kVideoCodecPrefs[j].name, 0, 0, 0, 0);
|
|
||||||
if (codec.Matches(in)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Given the requested codec, returns true if we can send that codec type and
|
// Given the requested codec, returns true if we can send that codec type and
|
||||||
// updates out with the best quality we could send for that codec. If current is
|
// updates out with the best quality we could send for that codec.
|
||||||
// not empty, we constrain out so that its aspect ratio matches current's.
|
// TODO(ronghuawu): Remove |current| from the interface.
|
||||||
bool WebRtcVideoEngine::CanSendCodec(const VideoCodec& requested,
|
bool WebRtcVideoEngine::CanSendCodec(const VideoCodec& requested,
|
||||||
const VideoCodec& current,
|
const VideoCodec& /* current */,
|
||||||
VideoCodec* out) {
|
VideoCodec* out) {
|
||||||
if (!out) {
|
if (!out) {
|
||||||
return false;
|
return false;
|
||||||
@ -1226,44 +1198,16 @@ bool WebRtcVideoEngine::CanSendCodec(const VideoCodec& requested,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pick the best quality that is within their and our bounds and has the
|
// Reduce the requested size by /= 2 until it's width under
|
||||||
// correct aspect ratio.
|
// |local_max->width|.
|
||||||
for (int j = 0; j < ARRAY_SIZE(kVideoFormats); ++j) {
|
out->width = requested.width;
|
||||||
const VideoFormat format(kVideoFormats[j]);
|
out->height = requested.height;
|
||||||
|
while (out->width > local_max->width) {
|
||||||
// Skip any format that is larger than the local or remote maximums, or
|
out->width /= 2;
|
||||||
// smaller than the current best match
|
out->height /= 2;
|
||||||
if (format.width > requested.width || format.height > requested.height ||
|
|
||||||
format.width > local_max->width ||
|
|
||||||
(format.width < out->width && format.height < out->height)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool better = false;
|
|
||||||
|
|
||||||
// Check any further constraints on this prospective format
|
|
||||||
if (!out->width || !out->height) {
|
|
||||||
// If we don't have any matches yet, this is the best so far.
|
|
||||||
better = true;
|
|
||||||
} else if (current.width && current.height) {
|
|
||||||
// current is set so format must match its ratio exactly.
|
|
||||||
better =
|
|
||||||
(format.width * current.height == format.height * current.width);
|
|
||||||
} else {
|
|
||||||
// Prefer closer aspect ratios i.e
|
|
||||||
// format.aspect - requested.aspect < out.aspect - requested.aspect
|
|
||||||
better = abs(format.width * requested.height * out->height -
|
|
||||||
requested.width * format.height * out->height) <
|
|
||||||
abs(out->width * format.height * requested.height -
|
|
||||||
requested.width * format.height * out->height);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (better) {
|
|
||||||
out->width = format.width;
|
|
||||||
out->height = format.height;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (out->width > 0) {
|
|
||||||
|
if (out->width > 0 && out->height > 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1703,10 +1647,7 @@ bool WebRtcVideoMediaChannel::SetSendCodecs(
|
|||||||
// Match with local video codec list.
|
// Match with local video codec list.
|
||||||
std::vector<webrtc::VideoCodec> send_codecs;
|
std::vector<webrtc::VideoCodec> send_codecs;
|
||||||
VideoCodec checked_codec;
|
VideoCodec checked_codec;
|
||||||
VideoCodec current; // defaults to 0x0
|
VideoCodec dummy_current; // Will be ignored by CanSendCodec.
|
||||||
if (sending_) {
|
|
||||||
ConvertToCricketVideoCodec(*send_codec_, ¤t);
|
|
||||||
}
|
|
||||||
std::map<int, int> primary_rtx_pt_mapping;
|
std::map<int, int> primary_rtx_pt_mapping;
|
||||||
bool nack_enabled = nack_enabled_;
|
bool nack_enabled = nack_enabled_;
|
||||||
bool remb_enabled = remb_enabled_;
|
bool remb_enabled = remb_enabled_;
|
||||||
@ -1722,7 +1663,7 @@ bool WebRtcVideoMediaChannel::SetSendCodecs(
|
|||||||
if (iter->GetParam(kCodecParamAssociatedPayloadType, &rtx_primary_type)) {
|
if (iter->GetParam(kCodecParamAssociatedPayloadType, &rtx_primary_type)) {
|
||||||
primary_rtx_pt_mapping[rtx_primary_type] = rtx_type;
|
primary_rtx_pt_mapping[rtx_primary_type] = rtx_type;
|
||||||
}
|
}
|
||||||
} else if (engine()->CanSendCodec(*iter, current, &checked_codec)) {
|
} else if (engine()->CanSendCodec(*iter, dummy_current, &checked_codec)) {
|
||||||
webrtc::VideoCodec wcodec;
|
webrtc::VideoCodec wcodec;
|
||||||
if (engine()->ConvertFromCricketVideoCodec(checked_codec, &wcodec)) {
|
if (engine()->ConvertFromCricketVideoCodec(checked_codec, &wcodec)) {
|
||||||
if (send_codecs.empty()) {
|
if (send_codecs.empty()) {
|
||||||
@ -4084,6 +4025,7 @@ void WebRtcVideoMediaChannel::MaybeChangeBitrates(
|
|||||||
codec->startBitrate = current_target_bitrate;
|
codec->startBitrate = current_target_bitrate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebRtcVideoMediaChannel::OnMessage(talk_base::Message* msg) {
|
void WebRtcVideoMediaChannel::OnMessage(talk_base::Message* msg) {
|
||||||
|
@ -189,7 +189,7 @@ class WebRtcVideoEngine : public sigslot::has_slots<>,
|
|||||||
|
|
||||||
static const VideoCodecPref kVideoCodecPrefs[];
|
static const VideoCodecPref kVideoCodecPrefs[];
|
||||||
static const VideoFormatPod kVideoFormats[];
|
static const VideoFormatPod kVideoFormats[];
|
||||||
static const VideoFormatPod kDefaultVideoFormat;
|
static const VideoFormatPod kDefaultMaxVideoFormat;
|
||||||
|
|
||||||
void Construct(ViEWrapper* vie_wrapper,
|
void Construct(ViEWrapper* vie_wrapper,
|
||||||
ViETraceWrapper* tracing,
|
ViETraceWrapper* tracing,
|
||||||
|
@ -2188,7 +2188,9 @@ TEST_F(WebRtcVideoEngineTest, FindCodec) {
|
|||||||
EXPECT_TRUE(engine_.FindCodec(vp8_diff_id));
|
EXPECT_TRUE(engine_.FindCodec(vp8_diff_id));
|
||||||
|
|
||||||
cricket::VideoCodec vp8_diff_res(104, "VP8", 320, 111, 30, 0);
|
cricket::VideoCodec vp8_diff_res(104, "VP8", 320, 111, 30, 0);
|
||||||
EXPECT_FALSE(engine_.FindCodec(vp8_diff_res));
|
// FindCodec ignores the codec size.
|
||||||
|
// Test that FindCodec can accept uncommon codec size.
|
||||||
|
EXPECT_TRUE(engine_.FindCodec(vp8_diff_res));
|
||||||
|
|
||||||
// PeerConnection doesn't negotiate the resolution at this point.
|
// PeerConnection doesn't negotiate the resolution at this point.
|
||||||
// Test that FindCodec can handle the case when width/height is 0.
|
// Test that FindCodec can handle the case when width/height is 0.
|
||||||
@ -2232,11 +2234,8 @@ TEST_F(WebRtcVideoEngineTest, StartupShutdown) {
|
|||||||
engine_.Terminate();
|
engine_.Terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_PRE_VIDEOENGINE_INIT(WebRtcVideoEngineTest, ConstrainNewCodec)
|
TEST_PRE_VIDEOENGINE_INIT(WebRtcVideoEngineTest, ConstrainNewCodec2)
|
||||||
TEST_POST_VIDEOENGINE_INIT(WebRtcVideoEngineTest, ConstrainNewCodec)
|
TEST_POST_VIDEOENGINE_INIT(WebRtcVideoEngineTest, ConstrainNewCodec2)
|
||||||
|
|
||||||
TEST_PRE_VIDEOENGINE_INIT(WebRtcVideoEngineTest, ConstrainRunningCodec)
|
|
||||||
TEST_POST_VIDEOENGINE_INIT(WebRtcVideoEngineTest, ConstrainRunningCodec)
|
|
||||||
|
|
||||||
// TODO(juberti): Figure out why ViE is munging the COM refcount.
|
// TODO(juberti): Figure out why ViE is munging the COM refcount.
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
Loading…
x
Reference in New Issue
Block a user