OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2009 Google Inc. | 3 * Copyright 2009 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1552 // Ensure a restart of a stopped monitor works. | 1552 // Ensure a restart of a stopped monitor works. |
1553 channel1_->StartMediaMonitor(100); | 1553 channel1_->StartMediaMonitor(100); |
1554 EXPECT_TRUE_WAIT(media_info_callbacks1_ > 0, kTimeout); | 1554 EXPECT_TRUE_WAIT(media_info_callbacks1_ > 0, kTimeout); |
1555 channel1_->StopMediaMonitor(); | 1555 channel1_->StopMediaMonitor(); |
1556 // Ensure stopping a stopped monitor is OK. | 1556 // Ensure stopping a stopped monitor is OK. |
1557 channel1_->StopMediaMonitor(); | 1557 channel1_->StopMediaMonitor(); |
1558 } | 1558 } |
1559 | 1559 |
1560 void TestSetContentFailure() { | 1560 void TestSetContentFailure() { |
1561 CreateChannels(0, 0); | 1561 CreateChannels(0, 0); |
1562 typename T::Content content; | |
1563 cricket::SessionDescription* sdesc_loc = new cricket::SessionDescription(); | |
1564 cricket::SessionDescription* sdesc_rem = new cricket::SessionDescription(); | |
1565 | 1562 |
1566 // Set up the session description. | 1563 auto sdesc = cricket::SessionDescription(); |
1567 CreateContent(0, kPcmuCodec, kH264Codec, &content); | 1564 sdesc.AddContent(cricket::CN_AUDIO, cricket::NS_JINGLE_RTP, |
1568 sdesc_loc->AddContent(cricket::CN_AUDIO, cricket::NS_JINGLE_RTP, | 1565 new cricket::AudioContentDescription()); |
1569 new cricket::AudioContentDescription()); | 1566 sdesc.AddContent(cricket::CN_VIDEO, cricket::NS_JINGLE_RTP, |
1570 sdesc_loc->AddContent(cricket::CN_VIDEO, cricket::NS_JINGLE_RTP, | 1567 new cricket::VideoContentDescription()); |
1571 new cricket::VideoContentDescription()); | |
1572 session1_.set_local_description(sdesc_loc); | |
1573 sdesc_rem->AddContent(cricket::CN_AUDIO, cricket::NS_JINGLE_RTP, | |
1574 new cricket::AudioContentDescription()); | |
1575 sdesc_rem->AddContent(cricket::CN_VIDEO, cricket::NS_JINGLE_RTP, | |
1576 new cricket::VideoContentDescription()); | |
1577 session1_.set_remote_description(sdesc_rem); | |
1578 | 1568 |
1579 // Test failures in SetLocalContent. | 1569 std::string err; |
1580 media_channel1_->set_fail_set_recv_codecs(true); | 1570 media_channel1_->set_fail_set_recv_codecs(true); |
1581 session1_.SetError(cricket::BaseSession::ERROR_NONE, ""); | 1571 EXPECT_FALSE(channel1_->PushdownLocalDescription( |
1582 session1_.SetState(cricket::BaseSession::STATE_SENTINITIATE); | 1572 &sdesc, cricket::CA_OFFER, &err)); |
1583 EXPECT_EQ(cricket::BaseSession::ERROR_CONTENT, session1_.error()); | 1573 EXPECT_FALSE(channel1_->PushdownLocalDescription( |
1584 media_channel1_->set_fail_set_recv_codecs(true); | 1574 &sdesc, cricket::CA_ANSWER, &err)); |
1585 session1_.SetError(cricket::BaseSession::ERROR_NONE, ""); | |
1586 session1_.SetState(cricket::BaseSession::STATE_SENTACCEPT); | |
1587 EXPECT_EQ(cricket::BaseSession::ERROR_CONTENT, session1_.error()); | |
1588 | 1575 |
1589 // Test failures in SetRemoteContent. | |
1590 media_channel1_->set_fail_set_send_codecs(true); | 1576 media_channel1_->set_fail_set_send_codecs(true); |
1591 session1_.SetError(cricket::BaseSession::ERROR_NONE, ""); | 1577 EXPECT_FALSE(channel1_->PushdownRemoteDescription( |
1592 session1_.SetState(cricket::BaseSession::STATE_RECEIVEDINITIATE); | 1578 &sdesc, cricket::CA_OFFER, &err)); |
1593 EXPECT_EQ(cricket::BaseSession::ERROR_CONTENT, session1_.error()); | |
1594 media_channel1_->set_fail_set_send_codecs(true); | 1579 media_channel1_->set_fail_set_send_codecs(true); |
1595 session1_.SetError(cricket::BaseSession::ERROR_NONE, ""); | 1580 EXPECT_FALSE(channel1_->PushdownRemoteDescription( |
1596 session1_.SetState(cricket::BaseSession::STATE_RECEIVEDACCEPT); | 1581 &sdesc, cricket::CA_ANSWER, &err)); |
1597 EXPECT_EQ(cricket::BaseSession::ERROR_CONTENT, session1_.error()); | |
1598 } | 1582 } |
1599 | 1583 |
1600 void TestSendTwoOffers() { | 1584 void TestSendTwoOffers() { |
1601 CreateChannels(0, 0); | 1585 CreateChannels(0, 0); |
1602 | 1586 |
1603 // Set up the initial session description. | 1587 std::string err; |
1604 cricket::SessionDescription* sdesc = CreateSessionDescriptionWithStream(1); | 1588 rtc::scoped_ptr<cricket::SessionDescription> sdesc1( |
1605 session1_.set_local_description(sdesc); | 1589 CreateSessionDescriptionWithStream(1)); |
1606 | 1590 EXPECT_TRUE(channel1_->PushdownLocalDescription( |
1607 session1_.SetError(cricket::BaseSession::ERROR_NONE, ""); | 1591 sdesc1.get(), cricket::CA_OFFER, &err)); |
1608 session1_.SetState(cricket::BaseSession::STATE_SENTINITIATE); | |
1609 EXPECT_EQ(cricket::BaseSession::ERROR_NONE, session1_.error()); | |
1610 EXPECT_TRUE(media_channel1_->HasSendStream(1)); | 1592 EXPECT_TRUE(media_channel1_->HasSendStream(1)); |
1611 | 1593 |
1612 // Update the local description and set the state again. | 1594 rtc::scoped_ptr<cricket::SessionDescription> sdesc2( |
1613 sdesc = CreateSessionDescriptionWithStream(2); | 1595 CreateSessionDescriptionWithStream(2)); |
1614 session1_.set_local_description(sdesc); | 1596 EXPECT_TRUE(channel1_->PushdownLocalDescription( |
1615 | 1597 sdesc2.get(), cricket::CA_OFFER, &err)); |
1616 session1_.SetState(cricket::BaseSession::STATE_SENTINITIATE); | |
1617 EXPECT_EQ(cricket::BaseSession::ERROR_NONE, session1_.error()); | |
1618 EXPECT_FALSE(media_channel1_->HasSendStream(1)); | 1598 EXPECT_FALSE(media_channel1_->HasSendStream(1)); |
1619 EXPECT_TRUE(media_channel1_->HasSendStream(2)); | 1599 EXPECT_TRUE(media_channel1_->HasSendStream(2)); |
1620 } | 1600 } |
1621 | 1601 |
1622 void TestReceiveTwoOffers() { | 1602 void TestReceiveTwoOffers() { |
1623 CreateChannels(0, 0); | 1603 CreateChannels(0, 0); |
1624 | 1604 |
1625 // Set up the initial session description. | 1605 std::string err; |
1626 cricket::SessionDescription* sdesc = CreateSessionDescriptionWithStream(1); | 1606 rtc::scoped_ptr<cricket::SessionDescription> sdesc1( |
1627 session1_.set_remote_description(sdesc); | 1607 CreateSessionDescriptionWithStream(1)); |
1628 | 1608 EXPECT_TRUE(channel1_->PushdownRemoteDescription( |
1629 session1_.SetError(cricket::BaseSession::ERROR_NONE, ""); | 1609 sdesc1.get(), cricket::CA_OFFER, &err)); |
1630 session1_.SetState(cricket::BaseSession::STATE_RECEIVEDINITIATE); | |
1631 EXPECT_EQ(cricket::BaseSession::ERROR_NONE, session1_.error()); | |
1632 EXPECT_TRUE(media_channel1_->HasRecvStream(1)); | 1610 EXPECT_TRUE(media_channel1_->HasRecvStream(1)); |
1633 | 1611 |
1634 sdesc = CreateSessionDescriptionWithStream(2); | 1612 rtc::scoped_ptr<cricket::SessionDescription> sdesc2( |
1635 session1_.set_remote_description(sdesc); | 1613 CreateSessionDescriptionWithStream(2)); |
1636 session1_.SetState(cricket::BaseSession::STATE_RECEIVEDINITIATE); | 1614 EXPECT_TRUE(channel1_->PushdownRemoteDescription( |
1637 EXPECT_EQ(cricket::BaseSession::ERROR_NONE, session1_.error()); | 1615 sdesc2.get(), cricket::CA_OFFER, &err)); |
1638 EXPECT_FALSE(media_channel1_->HasRecvStream(1)); | 1616 EXPECT_FALSE(media_channel1_->HasRecvStream(1)); |
1639 EXPECT_TRUE(media_channel1_->HasRecvStream(2)); | 1617 EXPECT_TRUE(media_channel1_->HasRecvStream(2)); |
1640 } | 1618 } |
1641 | 1619 |
1642 void TestSendPrAnswer() { | 1620 void TestSendPrAnswer() { |
1643 CreateChannels(0, 0); | 1621 CreateChannels(0, 0); |
1644 | 1622 |
1645 // Set up the initial session description. | 1623 std::string err; |
1646 cricket::SessionDescription* sdesc = CreateSessionDescriptionWithStream(1); | 1624 // Receive offer |
1647 session1_.set_remote_description(sdesc); | 1625 rtc::scoped_ptr<cricket::SessionDescription> sdesc1( |
1648 | 1626 CreateSessionDescriptionWithStream(1)); |
1649 session1_.SetError(cricket::BaseSession::ERROR_NONE, ""); | 1627 EXPECT_TRUE(channel1_->PushdownRemoteDescription( |
1650 session1_.SetState(cricket::BaseSession::STATE_RECEIVEDINITIATE); | 1628 sdesc1.get(), cricket::CA_OFFER, &err)); |
1651 EXPECT_EQ(cricket::BaseSession::ERROR_NONE, session1_.error()); | |
1652 EXPECT_TRUE(media_channel1_->HasRecvStream(1)); | 1629 EXPECT_TRUE(media_channel1_->HasRecvStream(1)); |
1653 | 1630 |
1654 // Send PRANSWER | 1631 // Send PR answer |
1655 sdesc = CreateSessionDescriptionWithStream(2); | 1632 rtc::scoped_ptr<cricket::SessionDescription> sdesc2( |
1656 session1_.set_local_description(sdesc); | 1633 CreateSessionDescriptionWithStream(2)); |
1657 | 1634 EXPECT_TRUE(channel1_->PushdownLocalDescription( |
1658 session1_.SetState(cricket::BaseSession::STATE_SENTPRACCEPT); | 1635 sdesc2.get(), cricket::CA_PRANSWER, &err)); |
1659 EXPECT_EQ(cricket::BaseSession::ERROR_NONE, session1_.error()); | |
1660 EXPECT_TRUE(media_channel1_->HasRecvStream(1)); | 1636 EXPECT_TRUE(media_channel1_->HasRecvStream(1)); |
1661 EXPECT_TRUE(media_channel1_->HasSendStream(2)); | 1637 EXPECT_TRUE(media_channel1_->HasSendStream(2)); |
1662 | 1638 |
1663 // Send ACCEPT | 1639 // Send answer |
1664 sdesc = CreateSessionDescriptionWithStream(3); | 1640 rtc::scoped_ptr<cricket::SessionDescription> sdesc3( |
1665 session1_.set_local_description(sdesc); | 1641 CreateSessionDescriptionWithStream(3)); |
1666 | 1642 EXPECT_TRUE(channel1_->PushdownLocalDescription( |
1667 session1_.SetState(cricket::BaseSession::STATE_SENTACCEPT); | 1643 sdesc3.get(), cricket::CA_ANSWER, &err)); |
1668 EXPECT_EQ(cricket::BaseSession::ERROR_NONE, session1_.error()); | |
1669 EXPECT_TRUE(media_channel1_->HasRecvStream(1)); | 1644 EXPECT_TRUE(media_channel1_->HasRecvStream(1)); |
1670 EXPECT_FALSE(media_channel1_->HasSendStream(2)); | 1645 EXPECT_FALSE(media_channel1_->HasSendStream(2)); |
1671 EXPECT_TRUE(media_channel1_->HasSendStream(3)); | 1646 EXPECT_TRUE(media_channel1_->HasSendStream(3)); |
1672 } | 1647 } |
1673 | 1648 |
1674 void TestReceivePrAnswer() { | 1649 void TestReceivePrAnswer() { |
1675 CreateChannels(0, 0); | 1650 CreateChannels(0, 0); |
1676 | 1651 |
1677 // Set up the initial session description. | 1652 std::string err; |
1678 cricket::SessionDescription* sdesc = CreateSessionDescriptionWithStream(1); | 1653 // Send offer |
1679 session1_.set_local_description(sdesc); | 1654 rtc::scoped_ptr<cricket::SessionDescription> sdesc1( |
1680 | 1655 CreateSessionDescriptionWithStream(1)); |
1681 session1_.SetError(cricket::BaseSession::ERROR_NONE, ""); | 1656 EXPECT_TRUE(channel1_->PushdownLocalDescription( |
1682 session1_.SetState(cricket::BaseSession::STATE_SENTINITIATE); | 1657 sdesc1.get(), cricket::CA_OFFER, &err)); |
1683 EXPECT_EQ(cricket::BaseSession::ERROR_NONE, session1_.error()); | |
1684 EXPECT_TRUE(media_channel1_->HasSendStream(1)); | 1658 EXPECT_TRUE(media_channel1_->HasSendStream(1)); |
1685 | 1659 |
1686 // Receive PRANSWER | 1660 // Receive PR answer |
1687 sdesc = CreateSessionDescriptionWithStream(2); | 1661 rtc::scoped_ptr<cricket::SessionDescription> sdesc2( |
1688 session1_.set_remote_description(sdesc); | 1662 CreateSessionDescriptionWithStream(2)); |
1689 | 1663 EXPECT_TRUE(channel1_->PushdownRemoteDescription( |
1690 session1_.SetState(cricket::BaseSession::STATE_RECEIVEDPRACCEPT); | 1664 sdesc2.get(), cricket::CA_PRANSWER, &err)); |
1691 EXPECT_EQ(cricket::BaseSession::ERROR_NONE, session1_.error()); | |
1692 EXPECT_TRUE(media_channel1_->HasSendStream(1)); | 1665 EXPECT_TRUE(media_channel1_->HasSendStream(1)); |
1693 EXPECT_TRUE(media_channel1_->HasRecvStream(2)); | 1666 EXPECT_TRUE(media_channel1_->HasRecvStream(2)); |
1694 | 1667 |
1695 // Receive ACCEPT | 1668 // Receive answer |
1696 sdesc = CreateSessionDescriptionWithStream(3); | 1669 rtc::scoped_ptr<cricket::SessionDescription> sdesc3( |
1697 session1_.set_remote_description(sdesc); | 1670 CreateSessionDescriptionWithStream(3)); |
1698 | 1671 EXPECT_TRUE(channel1_->PushdownRemoteDescription( |
1699 session1_.SetState(cricket::BaseSession::STATE_RECEIVEDACCEPT); | 1672 sdesc3.get(), cricket::CA_ANSWER, &err)); |
1700 EXPECT_EQ(cricket::BaseSession::ERROR_NONE, session1_.error()); | |
1701 EXPECT_TRUE(media_channel1_->HasSendStream(1)); | 1673 EXPECT_TRUE(media_channel1_->HasSendStream(1)); |
1702 EXPECT_FALSE(media_channel1_->HasRecvStream(2)); | 1674 EXPECT_FALSE(media_channel1_->HasRecvStream(2)); |
1703 EXPECT_TRUE(media_channel1_->HasRecvStream(3)); | 1675 EXPECT_TRUE(media_channel1_->HasRecvStream(3)); |
1704 } | 1676 } |
1705 | 1677 |
1706 void TestFlushRtcp() { | 1678 void TestFlushRtcp() { |
1707 bool send_rtcp1; | 1679 bool send_rtcp1; |
1708 | 1680 |
1709 CreateChannels(RTCP, RTCP); | 1681 CreateChannels(RTCP, RTCP); |
1710 EXPECT_TRUE(SendInitiate()); | 1682 EXPECT_TRUE(SendInitiate()); |
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2930 }; | 2902 }; |
2931 rtc::Buffer payload(data, 3); | 2903 rtc::Buffer payload(data, 3); |
2932 cricket::SendDataResult result; | 2904 cricket::SendDataResult result; |
2933 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); | 2905 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); |
2934 EXPECT_EQ(params.ssrc, | 2906 EXPECT_EQ(params.ssrc, |
2935 media_channel1_->last_sent_data_params().ssrc); | 2907 media_channel1_->last_sent_data_params().ssrc); |
2936 EXPECT_EQ("foo", media_channel1_->last_sent_data()); | 2908 EXPECT_EQ("foo", media_channel1_->last_sent_data()); |
2937 } | 2909 } |
2938 | 2910 |
2939 // TODO(pthatcher): TestSetReceiver? | 2911 // TODO(pthatcher): TestSetReceiver? |
OLD | NEW |