Bug 818714: Set media enabled to FALSE unless added using addStream, r=ehugg

This commit is contained in:
Adam Roach [:abr] 2012-12-19 20:52:32 -06:00
Родитель 99b4d14555
Коммит fb7884b67b
4 изменённых файлов: 89 добавлений и 40 удалений

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

@ -525,6 +525,9 @@ PeerConnectionImpl::CreateDataChannel(const nsACString& aLabel,
CSFLogDebugS(logTag, __FUNCTION__ << ": making DOMDataChannel");
// TODO -- need something like "mCall->addStream(stream_id, 0, DATA);" so
// the SDP can be generated correctly
return NS_NewDOMDataChannel(dataChannel.forget(), mWindow, aRetval);
#else
return NS_OK;

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

@ -3048,7 +3048,7 @@ fsmdef_ev_createanswer (sm_event_t *event) {
* The sdp member of the dcb has local and remote sdp
* this next function fills in the local part
*/
cause = gsmsdp_create_local_sdp(dcb, FALSE, has_audio, has_video, has_data, FALSE);
cause = gsmsdp_create_local_sdp(dcb, TRUE, has_audio, has_video, has_data, FALSE);
if (cause != CC_CAUSE_OK) {
ui_create_answer(evCreateAnswerError, line, call_id, dcb->caller_id.call_instance_id, NULL);
FSM_DEBUG_SM(get_debug_string(FSM_DBG_SDP_BUILD_ERR));
@ -3059,7 +3059,11 @@ fsmdef_ev_createanswer (sm_event_t *event) {
/* TODO(ekr@rtfm.com): The second true is because we are acting as if we are
processing an offer. The first, however, is for an initial offer and we may
want to set that conditionally. */
cause = gsmsdp_negotiate_media_lines(fcb, dcb->sdp, TRUE, TRUE, FALSE, TRUE);
cause = gsmsdp_negotiate_media_lines(fcb, dcb->sdp,
/* initial_offer */ TRUE,
/* offer */ TRUE,
/* notify_stream_added */ FALSE,
/* create_answer */ TRUE);
if (cause != CC_CAUSE_OK) {
ui_create_answer(evCreateAnswerError, line, call_id, dcb->caller_id.call_instance_id, NULL);

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

@ -122,15 +122,33 @@ static const cc_media_cap_table_t *gsmsdp_get_media_capability (fsmdef_dcb_t *dc
*(dcb_p->media_cap_tbl) = g_media_table;
/*
* Turn off two default streams, this is temporary
* until we can handle multiple streams properly
*/
if (sdpmode) {
dcb_p->media_cap_tbl->cap[CC_AUDIO_1].enabled = TRUE;
dcb_p->media_cap_tbl->cap[CC_VIDEO_1].enabled = TRUE;
dcb_p->media_cap_tbl->cap[CC_AUDIO_1].support_direction = SDP_DIRECTION_RECVONLY;
dcb_p->media_cap_tbl->cap[CC_VIDEO_1].support_direction = SDP_DIRECTION_RECVONLY;
/* This needs to change when we handle more than one stream
of each media type at a time. */
dcb_p->media_cap_tbl->cap[CC_AUDIO_1].enabled = FALSE;
dcb_p->media_cap_tbl->cap[CC_VIDEO_1].enabled = FALSE;
/* We initialize as RECVONLY to allow the application to
display incoming media streams, even if it doesn't
plan to send media for those streams. This will be
upgraded to SENDRECV when and if a stream is added. */
dcb_p->media_cap_tbl->cap[CC_AUDIO_1].support_direction =
SDP_DIRECTION_RECVONLY;
dcb_p->media_cap_tbl->cap[CC_VIDEO_1].support_direction =
SDP_DIRECTION_RECVONLY;
/*
* This really should be set to FALSE unless we have added
* a data channel using createDataChannel(). Right now,
* though, those operations are not queued (and, in fact,
* the W3C hasn't specified the proper behavior here anyway, so
* we would only be implementing speculatively) -- so we'll
* always offer data channels until the standard is
* a bit more set.
*/
dcb_p->media_cap_tbl->cap[CC_DATACHANNEL_1].enabled = TRUE;
} else {
dcb_p->media_cap_tbl->cap[CC_DATACHANNEL_1].enabled = FALSE;

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

@ -77,12 +77,15 @@ enum sdpTestFlags
SHOULD_RECV_AUDIO = (1<<1),
SHOULD_INACTIVE_AUDIO = (1<<2),
SHOULD_REJECT_AUDIO = (1<<3),
SHOULD_SEND_VIDEO = (1<<4),
SHOULD_RECV_VIDEO = (1<<5),
SHOULD_INACTIVE_VIDEO = (1<<6),
SHOULD_REJECT_VIDEO = (1<<7),
DONT_CHECK_AUDIO = (1<<8),
DONT_CHECK_VIDEO = (1<<9),
SHOULD_OMIT_AUDIO = (1<<4),
DONT_CHECK_AUDIO = (1<<5),
SHOULD_SEND_VIDEO = (1<<8),
SHOULD_RECV_VIDEO = (1<<9),
SHOULD_INACTIVE_VIDEO = (1<<10),
SHOULD_REJECT_VIDEO = (1<<11),
SHOULD_OMIT_VIDEO = (1<<12),
DONT_CHECK_VIDEO = (1<<13),
SHOULD_SENDRECV_AUDIO = SHOULD_SEND_AUDIO | SHOULD_RECV_AUDIO,
SHOULD_SENDRECV_VIDEO = SHOULD_SEND_VIDEO | SHOULD_RECV_VIDEO,
@ -90,11 +93,11 @@ enum sdpTestFlags
AUDIO_FLAGS = SHOULD_SEND_AUDIO | SHOULD_RECV_AUDIO
| SHOULD_INACTIVE_AUDIO | SHOULD_REJECT_AUDIO
| DONT_CHECK_AUDIO,
| DONT_CHECK_AUDIO | SHOULD_OMIT_AUDIO,
VIDEO_FLAGS = SHOULD_SEND_VIDEO | SHOULD_RECV_VIDEO
| SHOULD_INACTIVE_VIDEO | SHOULD_REJECT_VIDEO
| DONT_CHECK_VIDEO
| DONT_CHECK_VIDEO | SHOULD_OMIT_VIDEO
};
enum offerAnswerFlags
@ -712,21 +715,26 @@ private:
ASSERT_NE(sdp.find("c=IN IP4"), std::string::npos);
ASSERT_NE(sdp.find("a=fingerprint:sha-256"), std::string::npos);
cout << "SDPSanityCheck flags = " << std::hex << std::showbase
cout << "SDPSanityCheck flags for "
<< (offer ? "offer" : "answer")
<< " = " << std::hex << std::showbase
<< flags << std::dec
<< ((flags & SHOULD_SEND_AUDIO)?" SHOULD_SEND_AUDIO":"")
<< ((flags & SHOULD_RECV_AUDIO)?" SHOULD_RECV_AUDIO":"")
<< ((flags & SHOULD_INACTIVE_AUDIO)?" SHOULD_INACTIVE_AUDIO":"")
<< ((flags & SHOULD_REJECT_AUDIO)?" SHOULD_REJECT_AUDIO":"")
<< ((flags & SHOULD_OMIT_AUDIO)?" SHOULD_OMIT_AUDIO":"")
<< ((flags & DONT_CHECK_AUDIO)?" DONT_CHECK_AUDIO":"")
<< ((flags & SHOULD_SEND_VIDEO)?" SHOULD_SEND_VIDEO":"")
<< ((flags & SHOULD_RECV_VIDEO)?" SHOULD_RECV_VIDEO":"")
<< ((flags & SHOULD_INACTIVE_VIDEO)?" SHOULD_INACTIVE_VIDEO":"")
<< ((flags & SHOULD_REJECT_VIDEO)?" SHOULD_REJECT_VIDEO":"")
<< endl;
<< ((flags & SHOULD_OMIT_VIDEO)?" SHOULD_OMIT_VIDEO":"")
<< ((flags & DONT_CHECK_VIDEO)?" DONT_CHECK_VIDEO":"")
if ((flags & AUDIO_FLAGS) && offer) {
ASSERT_NE(sdp.find("a=rtpmap:0 PCMU/8000"), std::string::npos);
}
<< endl;
switch(flags & AUDIO_FLAGS) {
case 0:
@ -735,14 +743,23 @@ private:
case SHOULD_SEND_AUDIO:
ASSERT_NE(sdp.find("a=rtpmap:109 opus/48000"), std::string::npos);
ASSERT_NE(sdp.find(" 0-15\r\na=sendonly"), std::string::npos);
if (offer) {
ASSERT_NE(sdp.find("a=rtpmap:0 PCMU/8000"), std::string::npos);
}
break;
case SHOULD_RECV_AUDIO:
ASSERT_NE(sdp.find("a=rtpmap:109 opus/48000"), std::string::npos);
ASSERT_NE(sdp.find(" 0-15\r\na=recvonly"), std::string::npos);
if (offer) {
ASSERT_NE(sdp.find("a=rtpmap:0 PCMU/8000"), std::string::npos);
}
break;
case SHOULD_SENDRECV_AUDIO:
ASSERT_NE(sdp.find("a=rtpmap:109 opus/48000"), std::string::npos);
ASSERT_NE(sdp.find(" 0-15\r\na=sendrecv"), std::string::npos);
if (offer) {
ASSERT_NE(sdp.find("a=rtpmap:0 PCMU/8000"), std::string::npos);
}
break;
case SHOULD_INACTIVE_AUDIO:
ASSERT_NE(sdp.find("a=rtpmap:109 opus/48000"), std::string::npos);
@ -752,6 +769,9 @@ private:
ASSERT_EQ(sdp.find("a=rtpmap:109 opus/48000"), std::string::npos);
ASSERT_NE(sdp.find("m=audio 0 "), std::string::npos);
break;
case SHOULD_OMIT_AUDIO:
ASSERT_EQ(sdp.find("m=audio"), std::string::npos);
break;
case DONT_CHECK_AUDIO:
break;
default:
@ -781,6 +801,9 @@ private:
case SHOULD_REJECT_VIDEO:
ASSERT_NE(sdp.find("m=video 0 "), std::string::npos);
break;
case SHOULD_OMIT_VIDEO:
ASSERT_EQ(sdp.find("m=video"), std::string::npos);
break;
case DONT_CHECK_VIDEO:
break;
default:
@ -934,7 +957,7 @@ TEST_F(SignalingTest, CreateOfferNoVideoStream)
constraints.setBooleanConstraint("OfferToReceiveAudio", true, false);
constraints.setBooleanConstraint("OfferToReceiveVideo", true, false);
CreateOffer(constraints, OFFER_AUDIO,
SHOULD_SENDRECV_AUDIO | SHOULD_RECV_VIDEO);
SHOULD_SENDRECV_AUDIO | SHOULD_OMIT_VIDEO);
}
TEST_F(SignalingTest, CreateOfferNoAudioStream)
@ -943,7 +966,7 @@ TEST_F(SignalingTest, CreateOfferNoAudioStream)
constraints.setBooleanConstraint("OfferToReceiveAudio", true, false);
constraints.setBooleanConstraint("OfferToReceiveVideo", true, false);
CreateOffer(constraints, OFFER_VIDEO,
SHOULD_RECV_AUDIO | SHOULD_SENDRECV_VIDEO);
SHOULD_OMIT_AUDIO | SHOULD_SENDRECV_VIDEO);
}
TEST_F(SignalingTest, CreateOfferDontReceiveAudio)
@ -1060,8 +1083,8 @@ TEST_F(SignalingTest, OfferAnswerDontAddAudioStreamOnOffer)
answerconstraints.setBooleanConstraint("OfferToReceiveAudio", true, false);
answerconstraints.setBooleanConstraint("OfferToReceiveVideo", true, false);
OfferAnswer(offerconstraints, answerconstraints, OFFER_VIDEO | ANSWER_AV,
false, SHOULD_RECV_AUDIO | SHOULD_SENDRECV_VIDEO,
SHOULD_SEND_AUDIO | SHOULD_SENDRECV_VIDEO);
false, SHOULD_OMIT_AUDIO | SHOULD_SENDRECV_VIDEO,
SHOULD_OMIT_AUDIO | SHOULD_SENDRECV_VIDEO);
}
TEST_F(SignalingTest, OfferAnswerDontAddVideoStreamOnOffer)
@ -1073,8 +1096,8 @@ TEST_F(SignalingTest, OfferAnswerDontAddVideoStreamOnOffer)
answerconstraints.setBooleanConstraint("OfferToReceiveAudio", true, false);
answerconstraints.setBooleanConstraint("OfferToReceiveVideo", true, false);
OfferAnswer(offerconstraints, answerconstraints, OFFER_AUDIO | ANSWER_AV,
false, SHOULD_SENDRECV_AUDIO | SHOULD_RECV_VIDEO,
SHOULD_SENDRECV_AUDIO | SHOULD_SEND_VIDEO);
false, SHOULD_SENDRECV_AUDIO | SHOULD_OMIT_VIDEO,
SHOULD_SENDRECV_AUDIO | SHOULD_OMIT_VIDEO);
}
TEST_F(SignalingTest, OfferAnswerDontAddAudioStreamOnAnswer)
@ -1149,7 +1172,8 @@ TEST_F(SignalingTest, OfferAnswerDontAddVideoStreamOnOfferDontReceiveVideoOnOffe
answerconstraints.setBooleanConstraint("OfferToReceiveAudio", true, false);
answerconstraints.setBooleanConstraint("OfferToReceiveVideo", true, false);
OfferAnswer(offerconstraints, answerconstraints, OFFER_AUDIO | ANSWER_AV,
false, SHOULD_SENDRECV_AUDIO, SHOULD_SENDRECV_AUDIO);
false, SHOULD_SENDRECV_AUDIO | SHOULD_OMIT_VIDEO,
SHOULD_SENDRECV_AUDIO | SHOULD_OMIT_VIDEO);
}
TEST_F(SignalingTest, OfferAnswerDontReceiveAudioNoAudioStreamOnOfferDontReceiveVideoOnAnswer)
@ -1224,16 +1248,6 @@ TEST_F(SignalingTest, OfferAnswerDontAddAudioVideoStreamsOnAnswerNoConstraints)
SHOULD_RECV_AUDIO | SHOULD_RECV_VIDEO);
}
TEST_F(SignalingTest, OfferModifiedAnswer)
{
sipcc::MediaConstraints constraints;
OfferModifiedAnswer(constraints, constraints, SHOULD_SENDRECV_AV,
SHOULD_SENDRECV_AV);
PR_Sleep(kDefaultTimeout * 2); // Wait for completion
a1_.CloseSendStreams();
a2_.CloseReceiveStreams();
}
TEST_F(SignalingTest, FullCall)
{
sipcc::MediaConstraints constraints;
@ -1251,6 +1265,16 @@ TEST_F(SignalingTest, FullCall)
ASSERT_GE(a2_.GetPacketsReceived(0), 40);
}
TEST_F(SignalingTest, OfferModifiedAnswer)
{
sipcc::MediaConstraints constraints;
OfferModifiedAnswer(constraints, constraints, SHOULD_SENDRECV_AV,
SHOULD_SENDRECV_AV);
PR_Sleep(kDefaultTimeout * 2); // Wait for completion
a1_.CloseSendStreams();
a2_.CloseReceiveStreams();
}
TEST_F(SignalingTest, FullCallTrickle)
{
sipcc::MediaConstraints constraints;