Update libjingle to 52300956

R=wu@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/2213004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4744 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
sergeyu@chromium.org 2013-09-13 23:48:58 +00:00
parent 48af652ea5
commit a59696b2a5
21 changed files with 171 additions and 88 deletions

View File

@ -194,7 +194,8 @@ bool DataChannel::SendControl(const talk_base::Buffer* buffer) {
void DataChannel::SetReceiveSsrc(uint32 receive_ssrc) {
if (receive_ssrc_set_) {
ASSERT(session_->data_channel_type() == cricket::DCT_RTP ||
receive_ssrc_ == send_ssrc_);
!send_ssrc_set_ ||
receive_ssrc_ == send_ssrc_);
return;
}
receive_ssrc_ = receive_ssrc;
@ -210,7 +211,8 @@ void DataChannel::RemotePeerRequestClose() {
void DataChannel::SetSendSsrc(uint32 send_ssrc) {
if (send_ssrc_set_) {
ASSERT(session_->data_channel_type() == cricket::DCT_RTP ||
receive_ssrc_ == send_ssrc_);
!receive_ssrc_set_ ||
receive_ssrc_ == send_ssrc_);
return;
}
send_ssrc_ = send_ssrc;

View File

@ -95,6 +95,9 @@ class SctpDataChannelTest : public testing::Test {
true);
ASSERT_TRUE(session_.Initialize(&constraints,
new FakeIdentityService()));
webrtc_data_channel_ = webrtc::DataChannel::Create(&session_, "test", NULL);
ASSERT_TRUE(media_stream_signaling_->AddDataChannel(webrtc_data_channel_));
talk_base::scoped_refptr<CreateSessionDescriptionObserverForTest> observer
= new CreateSessionDescriptionObserverForTest();
session_.CreateOffer(observer.get(), NULL);
@ -102,12 +105,9 @@ class SctpDataChannelTest : public testing::Test {
ASSERT_TRUE(observer->description() != NULL);
ASSERT_TRUE(session_.SetLocalDescription(observer->ReleaseDescription(),
NULL));
webrtc_data_channel_ = webrtc::DataChannel::Create(&session_, "test", NULL);
// Connect to the media channel.
webrtc_data_channel_->SetSendSsrc(kFakeSsrc);
webrtc_data_channel_->SetReceiveSsrc(kFakeSsrc);
session_.data_channel()->SignalReadyToSendData(true);
}

View File

@ -51,6 +51,8 @@ const char MediaConstraintsInterface::kNoiseSuppression[] =
"googNoiseSuppression";
const char MediaConstraintsInterface::kHighpassFilter[] =
"googHighpassFilter";
const char MediaConstraintsInterface::kTypingNoiseDetection[] =
"googTypingNoiseDetection";
const char MediaConstraintsInterface::kInternalAecDump[] = "internalAecDump";
namespace {
@ -90,6 +92,8 @@ bool FromConstraints(const MediaConstraintsInterface::Constraints& constraints,
options->highpass_filter.Set(value);
else if (iter->key == MediaConstraintsInterface::kInternalAecDump)
options->aec_dump.Set(value);
else if (iter->key == MediaConstraintsInterface::kTypingNoiseDetection)
options->typing_detection.Set(value);
else
success = false;
}

View File

@ -80,6 +80,7 @@ class MediaConstraintsInterface {
static const char kExperimentalAutoGainControl[]; // googAutoGainControl2
static const char kNoiseSuppression[]; // googNoiseSuppression
static const char kHighpassFilter[]; // googHighpassFilter
static const char kTypingNoiseDetection[]; // googTypingNoiseDetection
// Google-specific constraint keys for a local video source
static const char kNoiseReduction[]; // googNoiseReduction

View File

@ -225,6 +225,10 @@ bool MediaStreamSignaling::AllocateSctpId(int* id) {
return true;
}
bool MediaStreamSignaling::HasDataChannels() const {
return !data_channels_.empty();
}
bool MediaStreamSignaling::AddDataChannel(DataChannel* data_channel) {
ASSERT(data_channel != NULL);
if (data_channels_.find(data_channel->label()) != data_channels_.end()) {

View File

@ -187,6 +187,8 @@ class MediaStreamSignaling {
// be offered in a SessionDescription.
void RemoveLocalStream(MediaStreamInterface* local_stream);
// Checks if any data channel has been added.
bool HasDataChannels() const;
// Adds |data_channel| to the collection of DataChannels that will be
// be offered in a SessionDescription.
bool AddDataChannel(DataChannel* data_channel);

View File

@ -1087,7 +1087,8 @@ TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTestOfferDtlsButNotSdes) {
// This test sets up a Jsep call between two parties, and the callee only
// accept to receive video.
TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTestAnswerVideo) {
// BUG=https://code.google.com/p/webrtc/issues/detail?id=2288
TEST_F(JsepPeerConnectionP2PTestClient, DISABLED_LocalP2PTestAnswerVideo) {
ASSERT_TRUE(CreateTestClients());
receiving_client()->SetReceiveAudioVideo(false, true);
LocalP2PTest();

View File

@ -398,8 +398,8 @@ StatsReport* StatsCollector::PrepareReport(uint32 ssrc,
std::string track_id;
if (it == reports_.end()) {
if (!session()->GetTrackIdBySsrc(ssrc, &track_id)) {
LOG(LS_ERROR) << "The SSRC " << ssrc
<< " is not associated with a track";
LOG(LS_WARNING) << "The SSRC " << ssrc
<< " is not associated with a track";
return NULL;
}
} else {

View File

@ -1319,8 +1319,13 @@ void BuildRtpContentAttributes(
// We should always use the default bandwidth for RTP-based data
// channels. Don't allow SDP to set the bandwidth, because that
// would give JS the opportunity to "break the Internet".
// TODO(pthatcher): But we need to temporarily allow the SDP to control
// this for backwards-compatibility. Once we don't need that any
// more, remove this.
bool support_dc_sdp_bandwidth_temporarily = true;
if (media_desc->bandwidth() >= 1000 &&
media_type != cricket::MEDIA_TYPE_DATA) {
(media_type != cricket::MEDIA_TYPE_DATA ||
support_dc_sdp_bandwidth_temporarily)) {
InitLine(kLineTypeSessionBandwidth, kApplicationSpecificMaximum, &os);
os << kSdpDelimiterColon << (media_desc->bandwidth() / 1000);
AddLine(os.str(), message);
@ -2112,7 +2117,13 @@ bool ParseMediaDescription(const std::string& message,
// We should always use the default bandwidth for RTP-based data
// channels. Don't allow SDP to set the bandwidth, because that
// would give JS the opportunity to "break the Internet".
content->set_bandwidth(cricket::kAutoBandwidth);
// TODO(pthatcher): But we need to temporarily allow the SDP to control
// this for backwards-compatibility. Once we don't need that any
// more, remove this.
bool support_dc_sdp_bandwidth_temporarily = true;
if (!support_dc_sdp_bandwidth_temporarily) {
content->set_bandwidth(cricket::kAutoBandwidth);
}
} else {
LOG(LS_WARNING) << "Unsupported media type: " << line;
continue;

View File

@ -1440,10 +1440,13 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithDataChannelAndBandwidth) {
// We want to test that serializing data content ignores bandwidth
// settings (it should always be the default). Thus, we don't do
// the following:
// InjectAfter("a=mid:data_content_name\r\n",
// "b=AS:100\r\n",
// &expected_sdp);
EXPECT_EQ(message, expected_sdp);
// TODO(pthatcher): We need to temporarily allow the SDP to control
// this for backwards-compatibility. Once we don't need that any
// more, remove this.
InjectAfter("a=mid:data_content_name\r\na=sendrecv\r\n",
"b=AS:100\r\n",
&expected_sdp);
EXPECT_EQ(expected_sdp, message);
}
TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithExtmap) {
@ -1764,9 +1767,12 @@ TEST_F(WebRtcSdpTest, DeserializeSdpWithRtpDataChannelsAndBandwidth) {
// We want to test that deserializing data content ignores bandwidth
// settings (it should always be the default). Thus, we don't do
// the following:
// DataContentDescription* dcd = static_cast<DataContentDescription*>(
// GetFirstDataContent(&desc_)->description);
// dcd->set_bandwidth(100 * 1000);
// TODO(pthatcher): We need to temporarily allow the SDP to control
// this for backwards-compatibility. Once we don't need that any
// more, remove this.
DataContentDescription* dcd = static_cast<DataContentDescription*>(
GetFirstDataContent(&desc_)->description);
dcd->set_bandwidth(100 * 1000);
ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion));
std::string sdp_with_bandwidth = kSdpString;

View File

@ -422,6 +422,17 @@ bool WebRtcSession::Initialize(
// mandatory constraints can be fulfilled. Note that |constraints|
// can be null.
bool value;
// Enable DTLS by default if |dtls_identity_service| is valid.
bool dtls_enabled = (dtls_identity_service != NULL);
// |constraints| can override the default |dtls_enabled| value.
if (FindConstraint(
constraints,
MediaConstraintsInterface::kEnableDtlsSrtp,
&value, NULL)) {
dtls_enabled = value;
}
// Enable creation of RTP data channels if the kEnableRtpDataChannels is set.
// It takes precendence over the kEnableSctpDataChannels constraint.
if (FindConstraint(
@ -434,11 +445,6 @@ bool WebRtcSession::Initialize(
constraints,
MediaConstraintsInterface::kEnableSctpDataChannels,
&value, NULL) && value;
bool dtls_enabled = FindConstraint(
constraints,
MediaConstraintsInterface::kEnableDtlsSrtp,
&value, NULL) && value;
// DTLS has to be enabled to use SCTP.
if (sctp_enabled && dtls_enabled) {
LOG(LS_INFO) << "Allowing SCTP data engine.";
@ -467,7 +473,7 @@ bool WebRtcSession::Initialize(
this,
id(),
data_channel_type_,
constraints));
dtls_enabled));
webrtc_session_desc_factory_->SignalIdentityReady.connect(
this, &WebRtcSession::OnIdentityReady);

View File

@ -314,9 +314,6 @@ class WebRtcSessionTest : public testing::Test {
}
void InitWithDtls(bool identity_request_should_fail = false) {
constraints_.reset(new FakeConstraints());
constraints_->AddOptional(
webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, true);
FakeIdentityService* identity_service = new FakeIdentityService();
identity_service->set_should_fail(identity_request_should_fail);
Init(identity_service);
@ -2482,19 +2479,29 @@ TEST_F(WebRtcSessionTest, TestRtpDataChannelConstraintTakesPrecedence) {
webrtc::MediaConstraintsInterface::kEnableRtpDataChannels, true);
constraints_->AddOptional(
webrtc::MediaConstraintsInterface::kEnableSctpDataChannels, true);
constraints_->AddOptional(
webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, true);
Init(new FakeIdentityService());
InitWithDtls(false);
SetLocalDescriptionWithDataChannel();
EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type());
}
TEST_F(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) {
constraints_.reset(new FakeConstraints());
constraints_->AddOptional(
webrtc::MediaConstraintsInterface::kEnableSctpDataChannels, true);
InitWithDtls(false);
talk_base::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer(NULL));
EXPECT_TRUE(offer->description()->GetContentByName("data") == NULL);
}
TEST_F(WebRtcSessionTest, TestSctpDataChannelWithoutDtls) {
constraints_.reset(new FakeConstraints());
constraints_->AddOptional(
webrtc::MediaConstraintsInterface::kEnableSctpDataChannels, true);
Init(NULL);
constraints_->AddOptional(
webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, false);
InitWithDtls(false);
SetLocalDescriptionWithDataChannel();
EXPECT_EQ(cricket::DCT_NONE, data_engine_->last_channel_type());
@ -2506,9 +2513,7 @@ TEST_F(WebRtcSessionTest, TestSctpDataChannelWithDtls) {
constraints_.reset(new FakeConstraints());
constraints_->AddOptional(
webrtc::MediaConstraintsInterface::kEnableSctpDataChannels, true);
constraints_->AddOptional(
webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, true);
Init(new FakeIdentityService());
InitWithDtls(false);
SetLocalDescriptionWithDataChannel();
EXPECT_EQ(cricket::DCT_SCTP, data_engine_->last_channel_type());

View File

@ -113,7 +113,7 @@ WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory(
WebRtcSession* session,
const std::string& session_id,
cricket::DataChannelType dct,
const MediaConstraintsInterface* constraints)
bool dtls_enabled)
: signaling_thread_(signaling_thread),
mediastream_signaling_(mediastream_signaling),
session_desc_factory_(channel_manager, &transport_desc_factory_),
@ -132,38 +132,31 @@ WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory(
// By default SRTP-SDES is enabled in WebRtc.
set_secure(cricket::SEC_REQUIRED);
// Enable DTLS-SRTP if the constraint is set.
bool dtls_enabled = false;
if (!FindConstraint(
constraints, MediaConstraintsInterface::kEnableDtlsSrtp,
&dtls_enabled, NULL) ||
!dtls_enabled) {
return;
}
// DTLS is enabled.
if (identity_service_.get()) {
identity_request_observer_ =
new talk_base::RefCountedObject<WebRtcIdentityRequestObserver>();
if (dtls_enabled) {
if (identity_service_.get()) {
identity_request_observer_ =
new talk_base::RefCountedObject<WebRtcIdentityRequestObserver>();
identity_request_observer_->SignalRequestFailed.connect(
this, &WebRtcSessionDescriptionFactory::OnIdentityRequestFailed);
identity_request_observer_->SignalIdentityReady.connect(
this, &WebRtcSessionDescriptionFactory::OnIdentityReady);
identity_request_observer_->SignalRequestFailed.connect(
this, &WebRtcSessionDescriptionFactory::OnIdentityRequestFailed);
identity_request_observer_->SignalIdentityReady.connect(
this, &WebRtcSessionDescriptionFactory::OnIdentityReady);
if (identity_service_->RequestIdentity(kWebRTCIdentityName,
kWebRTCIdentityName,
identity_request_observer_)) {
LOG(LS_VERBOSE) << "DTLS-SRTP enabled; sent DTLS identity request.";
identity_request_state_ = IDENTITY_WAITING;
if (identity_service_->RequestIdentity(kWebRTCIdentityName,
kWebRTCIdentityName,
identity_request_observer_)) {
LOG(LS_VERBOSE) << "DTLS-SRTP enabled; sent DTLS identity request.";
identity_request_state_ = IDENTITY_WAITING;
} else {
LOG(LS_ERROR) << "Failed to send DTLS identity request.";
identity_request_state_ = IDENTITY_FAILED;
}
} else {
LOG(LS_ERROR) << "Failed to send DTLS identity request.";
identity_request_state_ = IDENTITY_FAILED;
identity_request_state_ = IDENTITY_WAITING;
// Do not generate the identity in the constructor since the caller has
// not got a chance to connect to SignalIdentityReady.
signaling_thread_->Post(this, MSG_GENERATE_IDENTITY, NULL);
}
} else {
identity_request_state_ = IDENTITY_WAITING;
// Do not generate the identity in the constructor since the caller has
// not got a chance to connect to SignalIdentityReady.
signaling_thread_->Post(this, MSG_GENERATE_IDENTITY, NULL);
}
}
@ -197,7 +190,8 @@ void WebRtcSessionDescriptionFactory::CreateOffer(
return;
}
if (data_channel_type_ == cricket::DCT_SCTP) {
if (data_channel_type_ == cricket::DCT_SCTP &&
mediastream_signaling_->HasDataChannels()) {
options.data_channel_type = cricket::DCT_SCTP;
}
@ -249,7 +243,8 @@ void WebRtcSessionDescriptionFactory::CreateAnswer(
PostCreateSessionDescriptionFailed(observer, error);
return;
}
if (data_channel_type_ == cricket::DCT_SCTP) {
if (data_channel_type_ == cricket::DCT_SCTP &&
mediastream_signaling_->HasDataChannels()) {
options.data_channel_type = cricket::DCT_SCTP;
}

View File

@ -102,7 +102,7 @@ class WebRtcSessionDescriptionFactory : public talk_base::MessageHandler,
WebRtcSession* session,
const std::string& session_id,
cricket::DataChannelType dct,
const MediaConstraintsInterface* constraints);
bool dtls_enabled);
virtual ~WebRtcSessionDescriptionFactory();
static void CopyCandidatesFromSessionDescription(

View File

@ -132,6 +132,7 @@ TEST_F(MacAsyncSocketTest, TestConnectWithDnsLookupIPv6) {
SocketTest::TestConnectWithDnsLookupIPv6();
}
// BUG=https://code.google.com/p/webrtc/issues/detail?id=2272
TEST_F(MacAsyncSocketTest, DISABLED_TestConnectFailIPv4) {
SocketTest::TestConnectFailIPv4();
}

View File

@ -270,6 +270,13 @@ bool SctpDataMediaChannel::OpenSctpSocket() {
return false;
}
uint32_t nodelay = 1;
if (usrsctp_setsockopt(sock_, IPPROTO_SCTP, SCTP_NODELAY, &nodelay,
sizeof(nodelay))) {
LOG_ERRNO(LS_ERROR) << debug_name_ << "Failed to set SCTP_NODELAY.";
return false;
}
// Subscribe to SCTP event notifications.
int event_types[] = {SCTP_ASSOC_CHANGE,
SCTP_PEER_ADDR_CHANGE,

View File

@ -459,7 +459,6 @@ class WebRtcVideoChannelRecvInfo {
DecoderMap registered_decoders_;
};
#ifdef USE_WEBRTC_DEV_BRANCH
class WebRtcOveruseObserver : public webrtc::CpuOveruseObserver {
public:
explicit WebRtcOveruseObserver(CoordinatedVideoAdapter* video_adapter)
@ -499,7 +498,6 @@ class WebRtcOveruseObserver : public webrtc::CpuOveruseObserver {
talk_base::CriticalSection crit_;
};
#endif
class WebRtcVideoChannelSendInfo : public sigslot::has_slots<> {
public:
@ -517,9 +515,7 @@ class WebRtcVideoChannelSendInfo : public sigslot::has_slots<> {
capturer_updated_(false),
interval_(0),
video_adapter_(new CoordinatedVideoAdapter) {
#ifdef USE_WEBRTC_DEV_BRANCH
overuse_observer_.reset(new WebRtcOveruseObserver(video_adapter_.get()));
#endif
SignalCpuAdaptationUnable.repeat(video_adapter_->SignalCpuAdaptationUnable);
if (cpu_monitor) {
cpu_monitor->SignalUpdate.connect(
@ -573,11 +569,9 @@ class WebRtcVideoChannelSendInfo : public sigslot::has_slots<> {
int CurrentAdaptReason() const {
return video_adapter_->adapt_reason();
}
#ifdef USE_WEBRTC_DEV_BRANCH
webrtc::CpuOveruseObserver* overuse_observer() {
return overuse_observer_.get();
}
#endif
StreamParams* stream_params() { return stream_params_.get(); }
void set_stream_params(const StreamParams& sp) {
@ -639,10 +633,8 @@ class WebRtcVideoChannelSendInfo : public sigslot::has_slots<> {
}
void SetCpuOveruseDetection(bool enable) {
#ifdef USE_WEBRTC_DEV_BRANCH
overuse_observer_->Enable(enable);
video_adapter_->set_cpu_adaptation(enable);
#endif
}
void ProcessFrame(const VideoFrame& original_frame, bool mute,
@ -697,9 +689,7 @@ class WebRtcVideoChannelSendInfo : public sigslot::has_slots<> {
int64 interval_;
talk_base::scoped_ptr<CoordinatedVideoAdapter> video_adapter_;
#ifdef USE_WEBRTC_DEV_BRANCH
talk_base::scoped_ptr<WebRtcOveruseObserver> overuse_observer_;
#endif
};
const WebRtcVideoEngine::VideoCodecPref
@ -2251,7 +2241,10 @@ bool WebRtcVideoMediaChannel::GetStats(VideoMediaInfo* info) {
unsigned int ssrc;
// Get receiver statistics and build VideoReceiverInfo, if we have data.
if (engine_->vie()->rtp()->GetRemoteSSRC(channel->channel_id(), ssrc) != 0)
// Skip the default channel (ssrc == 0).
if (engine_->vie()->rtp()->GetRemoteSSRC(
channel->channel_id(), ssrc) != 0 ||
ssrc == 0)
continue;
unsigned int bytes_sent, packets_sent, bytes_recv, packets_recv;
@ -3036,13 +3029,11 @@ bool WebRtcVideoMediaChannel::ConfigureSending(int channel_id,
new WebRtcVideoChannelSendInfo(channel_id, vie_capture,
external_capture,
engine()->cpu_monitor()));
#ifdef USE_WEBRTC_DEV_BRANCH
if (engine()->vie()->base()->RegisterCpuOveruseObserver(
channel_id, send_channel->overuse_observer())) {
LOG_RTCERR1(RegisterCpuOveruseObserver, channel_id);
return false;
}
#endif
send_channel->ApplyCpuOptions(options_);
send_channel->SignalCpuAdaptationUnable.connect(this,
&WebRtcVideoMediaChannel::OnCpuAdaptationUnable);

View File

@ -125,16 +125,19 @@ static const int kOpusStereoBitrate = 64000;
static const int kOpusMinBitrate = 6000;
static const int kOpusMaxBitrate = 510000;
#if defined(CHROMEOS)
// Ensure we open the file in a writeable path on ChromeOS. This workaround
// can be removed when it's possible to specify a filename for audio option
// based AEC dumps.
// Ensure we open the file in a writeable path on ChromeOS and Android. This
// workaround can be removed when it's possible to specify a filename for audio
// option based AEC dumps.
//
// TODO(grunell): Use a string in the options instead of hardcoding it here
// and let the embedder choose the filename (crbug.com/264223).
//
// NOTE(ajm): Don't use this hardcoded /tmp path on non-ChromeOS platforms.
// NOTE(ajm): Don't use hardcoded paths on platforms not explicitly specified
// below.
#if defined(CHROMEOS)
static const char kAecDumpByAudioOptionFilename[] = "/tmp/audio.aecdump";
#elif defined(ANDROID)
static const char kAecDumpByAudioOptionFilename[] = "/sdcard/audio.aecdump";
#else
static const char kAecDumpByAudioOptionFilename[] = "audio.aecdump";
#endif

View File

@ -2824,10 +2824,6 @@ TEST(WebRtcVoiceEngineTest, HasCorrectCodecs) {
cricket::AudioCodec(96, "G722", 16000, 0, 1, 0)));
EXPECT_TRUE(engine.FindCodec(
cricket::AudioCodec(96, "red", 8000, 0, 1, 0)));
#ifndef USE_WEBRTC_DEV_BRANCH
EXPECT_TRUE(engine.FindCodec(
cricket::AudioCodec(96, "CN", 48000, 0, 1, 0)));
#endif
EXPECT_TRUE(engine.FindCodec(
cricket::AudioCodec(96, "CN", 32000, 0, 1, 0)));
EXPECT_TRUE(engine.FindCodec(

View File

@ -670,7 +670,16 @@ VideoCapturer* ChannelManager::CreateVideoCapturer() {
}
return NULL;
}
return device_manager_->CreateVideoCapturer(device);
VideoCapturer* capturer = device_manager_->CreateVideoCapturer(device);
if (capturer && default_video_encoder_config_.max_codec.id != 0) {
// For now, use the aspect ratio of the default_video_encoder_config_,
// which may be different than the native aspect ratio of the start
// format the camera may use.
capturer->UpdateAspectRatio(
default_video_encoder_config_.max_codec.width,
default_video_encoder_config_.max_codec.height);
}
return capturer;
}
bool ChannelManager::SetCaptureDevice_w(const Device* cam_device) {

View File

@ -204,6 +204,45 @@ TEST_F(ChannelManagerTest, SetDefaultVideoEncoderConfig) {
EXPECT_EQ(config, fme_->default_video_encoder_config());
}
struct GetCapturerFrameSize : public sigslot::has_slots<> {
void OnVideoFrame(VideoCapturer* capturer, const VideoFrame* frame) {
width = frame->GetWidth();
height = frame->GetHeight();
}
GetCapturerFrameSize(VideoCapturer* capturer) : width(0), height(0) {
capturer->SignalVideoFrame.connect(this,
&GetCapturerFrameSize::OnVideoFrame);
static_cast<FakeVideoCapturer*>(capturer)->CaptureFrame();
}
size_t width;
size_t height;
};
TEST_F(ChannelManagerTest, DefaultCapturerAspectRatio) {
VideoCodec codec(100, "VP8", 640, 360, 30, 0);
VideoFormat format(640, 360, 33, FOURCC_ANY);
VideoEncoderConfig config(codec, 1, 2);
EXPECT_TRUE(cm_->Init());
// A capturer created before the default encoder config is set will have no
// set aspect ratio, so it'll be 4:3 (based on the fake video capture impl).
VideoCapturer* capturer = cm_->CreateVideoCapturer();
ASSERT_TRUE(capturer != NULL);
EXPECT_EQ(CS_RUNNING, capturer->Start(format));
GetCapturerFrameSize size(capturer);
EXPECT_EQ(640u, size.width);
EXPECT_EQ(480u, size.height);
delete capturer;
// Try again, but with the encoder config set to 16:9.
EXPECT_TRUE(cm_->SetDefaultVideoEncoderConfig(config));
capturer = cm_->CreateVideoCapturer();
ASSERT_TRUE(capturer != NULL);
EXPECT_EQ(CS_RUNNING, capturer->Start(format));
GetCapturerFrameSize cropped_size(capturer);
EXPECT_EQ(640u, cropped_size.width);
EXPECT_EQ(360u, cropped_size.height);
delete capturer;
}
// Test that SetDefaultVideoCodec passes through the right values.
TEST_F(ChannelManagerTest, SetDefaultVideoCodecBeforeInit) {
cricket::VideoCodec codec(96, "G264", 1280, 720, 60, 0);