Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(504)

Side by Side Diff: talk/session/media/channel_unittest.cc

Issue 1219663008: Remove media sinks from Channel. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « talk/session/media/channel.cc ('k') | talk/session/media/mediarecorder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
28 #include "talk/media/base/fakemediaengine.h" 28 #include "talk/media/base/fakemediaengine.h"
29 #include "talk/media/base/fakertp.h" 29 #include "talk/media/base/fakertp.h"
30 #include "talk/media/base/fakescreencapturerfactory.h" 30 #include "talk/media/base/fakescreencapturerfactory.h"
31 #include "talk/media/base/fakevideocapturer.h" 31 #include "talk/media/base/fakevideocapturer.h"
32 #include "talk/media/base/mediachannel.h" 32 #include "talk/media/base/mediachannel.h"
33 #include "talk/media/base/rtpdump.h" 33 #include "talk/media/base/rtpdump.h"
34 #include "talk/media/base/screencastid.h" 34 #include "talk/media/base/screencastid.h"
35 #include "talk/media/base/testutils.h" 35 #include "talk/media/base/testutils.h"
36 #include "webrtc/p2p/base/fakesession.h" 36 #include "webrtc/p2p/base/fakesession.h"
37 #include "talk/session/media/channel.h" 37 #include "talk/session/media/channel.h"
38 #include "talk/session/media/mediarecorder.h"
39 #include "talk/session/media/typingmonitor.h" 38 #include "talk/session/media/typingmonitor.h"
40 #include "webrtc/base/fileutils.h" 39 #include "webrtc/base/fileutils.h"
41 #include "webrtc/base/gunit.h" 40 #include "webrtc/base/gunit.h"
42 #include "webrtc/base/helpers.h" 41 #include "webrtc/base/helpers.h"
43 #include "webrtc/base/logging.h" 42 #include "webrtc/base/logging.h"
44 #include "webrtc/base/pathutils.h" 43 #include "webrtc/base/pathutils.h"
45 #include "webrtc/base/signalthread.h" 44 #include "webrtc/base/signalthread.h"
46 #include "webrtc/base/ssladapter.h" 45 #include "webrtc/base/ssladapter.h"
47 #include "webrtc/base/sslidentity.h" 46 #include "webrtc/base/sslidentity.h"
48 #include "webrtc/base/window.h" 47 #include "webrtc/base/window.h"
(...skipping 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 channel1_->StopMediaMonitor(); 1550 channel1_->StopMediaMonitor();
1552 channel2_->StopMediaMonitor(); 1551 channel2_->StopMediaMonitor();
1553 // Ensure a restart of a stopped monitor works. 1552 // Ensure a restart of a stopped monitor works.
1554 channel1_->StartMediaMonitor(100); 1553 channel1_->StartMediaMonitor(100);
1555 EXPECT_TRUE_WAIT(media_info_callbacks1_ > 0, kTimeout); 1554 EXPECT_TRUE_WAIT(media_info_callbacks1_ > 0, kTimeout);
1556 channel1_->StopMediaMonitor(); 1555 channel1_->StopMediaMonitor();
1557 // Ensure stopping a stopped monitor is OK. 1556 // Ensure stopping a stopped monitor is OK.
1558 channel1_->StopMediaMonitor(); 1557 channel1_->StopMediaMonitor();
1559 } 1558 }
1560 1559
1561 void TestMediaSinks() {
1562 CreateChannels(0, 0);
1563 EXPECT_TRUE(SendInitiate());
1564 EXPECT_TRUE(SendAccept());
1565 EXPECT_FALSE(channel1_->HasSendSinks(cricket::SINK_POST_CRYPTO));
1566 EXPECT_FALSE(channel1_->HasRecvSinks(cricket::SINK_POST_CRYPTO));
1567 EXPECT_FALSE(channel1_->HasSendSinks(cricket::SINK_PRE_CRYPTO));
1568 EXPECT_FALSE(channel1_->HasRecvSinks(cricket::SINK_PRE_CRYPTO));
1569
1570 rtc::Pathname path;
1571 EXPECT_TRUE(rtc::Filesystem::GetTemporaryFolder(path, true, NULL));
1572 path.SetFilename("sink-test.rtpdump");
1573 rtc::scoped_ptr<cricket::RtpDumpSink> sink(
1574 new cricket::RtpDumpSink(Open(path.pathname())));
1575 sink->set_packet_filter(cricket::PF_ALL);
1576 EXPECT_TRUE(sink->Enable(true));
1577 channel1_->RegisterSendSink(
1578 sink.get(), &cricket::RtpDumpSink::OnPacket, cricket::SINK_POST_CRYPTO);
1579 EXPECT_TRUE(channel1_->HasSendSinks(cricket::SINK_POST_CRYPTO));
1580 EXPECT_FALSE(channel1_->HasRecvSinks(cricket::SINK_POST_CRYPTO));
1581 EXPECT_FALSE(channel1_->HasSendSinks(cricket::SINK_PRE_CRYPTO));
1582 EXPECT_FALSE(channel1_->HasRecvSinks(cricket::SINK_PRE_CRYPTO));
1583
1584 // The first packet is recorded with header + data.
1585 EXPECT_TRUE(SendRtp1());
1586 // The second packet is recorded with header only.
1587 sink->set_packet_filter(cricket::PF_RTPHEADER);
1588 EXPECT_TRUE(SendRtp1());
1589 // The third packet is not recorded since sink is disabled.
1590 EXPECT_TRUE(sink->Enable(false));
1591 EXPECT_TRUE(SendRtp1());
1592 // The fourth packet is not recorded since sink is unregistered.
1593 EXPECT_TRUE(sink->Enable(true));
1594 channel1_->UnregisterSendSink(sink.get(), cricket::SINK_POST_CRYPTO);
1595 EXPECT_TRUE(SendRtp1());
1596 sink.reset(); // This will close the file.
1597
1598 // Read the recorded file and verify two packets.
1599 rtc::scoped_ptr<rtc::StreamInterface> stream(
1600 rtc::Filesystem::OpenFile(path, "rb"));
1601
1602 cricket::RtpDumpReader reader(stream.get());
1603 cricket::RtpDumpPacket packet;
1604 EXPECT_EQ(rtc::SR_SUCCESS, reader.ReadPacket(&packet));
1605 std::string read_packet(reinterpret_cast<const char*>(&packet.data[0]),
1606 packet.data.size());
1607 EXPECT_EQ(rtp_packet_, read_packet);
1608
1609 EXPECT_EQ(rtc::SR_SUCCESS, reader.ReadPacket(&packet));
1610 size_t len = 0;
1611 packet.GetRtpHeaderLen(&len);
1612 EXPECT_EQ(len, packet.data.size());
1613 EXPECT_EQ(0, memcmp(&packet.data[0], rtp_packet_.c_str(), len));
1614
1615 EXPECT_EQ(rtc::SR_EOS, reader.ReadPacket(&packet));
1616
1617 // Delete the file for media recording.
1618 stream.reset();
1619 EXPECT_TRUE(rtc::Filesystem::DeleteFile(path));
1620 }
1621
1622 void TestSetContentFailure() { 1560 void TestSetContentFailure() {
1623 CreateChannels(0, 0); 1561 CreateChannels(0, 0);
1624 typename T::Content content; 1562 typename T::Content content;
1625 cricket::SessionDescription* sdesc_loc = new cricket::SessionDescription(); 1563 cricket::SessionDescription* sdesc_loc = new cricket::SessionDescription();
1626 cricket::SessionDescription* sdesc_rem = new cricket::SessionDescription(); 1564 cricket::SessionDescription* sdesc_rem = new cricket::SessionDescription();
1627 1565
1628 // Set up the session description. 1566 // Set up the session description.
1629 CreateContent(0, kPcmuCodec, kH264Codec, &content); 1567 CreateContent(0, kPcmuCodec, kH264Codec, &content);
1630 sdesc_loc->AddContent(cricket::CN_AUDIO, cricket::NS_JINGLE_RTP, 1568 sdesc_loc->AddContent(cricket::CN_AUDIO, cricket::NS_JINGLE_RTP,
1631 new cricket::AudioContentDescription()); 1569 new cricket::AudioContentDescription());
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
2309 2247
2310 ASSERT_EQ(3U, media_channel1_->dtmf_info_queue().size()); 2248 ASSERT_EQ(3U, media_channel1_->dtmf_info_queue().size());
2311 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[0], 2249 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[0],
2312 1, 3, 100, cricket::DF_SEND)); 2250 1, 3, 100, cricket::DF_SEND));
2313 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[1], 2251 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[1],
2314 2, 5, 110, cricket::DF_PLAY)); 2252 2, 5, 110, cricket::DF_PLAY));
2315 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[2], 2253 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[2],
2316 3, 7, 120, cricket::DF_PLAY | cricket::DF_SEND)); 2254 3, 7, 120, cricket::DF_PLAY | cricket::DF_SEND));
2317 } 2255 }
2318 2256
2319 TEST_F(VoiceChannelTest, TestMediaSinks) {
2320 Base::TestMediaSinks();
2321 }
2322
2323 TEST_F(VoiceChannelTest, TestSetContentFailure) { 2257 TEST_F(VoiceChannelTest, TestSetContentFailure) {
2324 Base::TestSetContentFailure(); 2258 Base::TestSetContentFailure();
2325 } 2259 }
2326 2260
2327 TEST_F(VoiceChannelTest, TestSendTwoOffers) { 2261 TEST_F(VoiceChannelTest, TestSendTwoOffers) {
2328 Base::TestSendTwoOffers(); 2262 Base::TestSendTwoOffers();
2329 } 2263 }
2330 2264
2331 TEST_F(VoiceChannelTest, TestReceiveTwoOffers) { 2265 TEST_F(VoiceChannelTest, TestReceiveTwoOffers) {
2332 Base::TestReceiveTwoOffers(); 2266 Base::TestReceiveTwoOffers();
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
2670 } 2604 }
2671 2605
2672 TEST_F(VideoChannelTest, SendWithWritabilityLoss) { 2606 TEST_F(VideoChannelTest, SendWithWritabilityLoss) {
2673 Base::SendWithWritabilityLoss(); 2607 Base::SendWithWritabilityLoss();
2674 } 2608 }
2675 2609
2676 TEST_F(VideoChannelTest, TestMediaMonitor) { 2610 TEST_F(VideoChannelTest, TestMediaMonitor) {
2677 Base::TestMediaMonitor(); 2611 Base::TestMediaMonitor();
2678 } 2612 }
2679 2613
2680 TEST_F(VideoChannelTest, TestMediaSinks) {
2681 Base::TestMediaSinks();
2682 }
2683
2684 TEST_F(VideoChannelTest, TestSetContentFailure) { 2614 TEST_F(VideoChannelTest, TestSetContentFailure) {
2685 Base::TestSetContentFailure(); 2615 Base::TestSetContentFailure();
2686 } 2616 }
2687 2617
2688 TEST_F(VideoChannelTest, TestSendTwoOffers) { 2618 TEST_F(VideoChannelTest, TestSendTwoOffers) {
2689 Base::TestSendTwoOffers(); 2619 Base::TestSendTwoOffers();
2690 } 2620 }
2691 2621
2692 TEST_F(VideoChannelTest, TestReceiveTwoOffers) { 2622 TEST_F(VideoChannelTest, TestReceiveTwoOffers) {
2693 Base::TestReceiveTwoOffers(); 2623 Base::TestReceiveTwoOffers();
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
3000 }; 2930 };
3001 rtc::Buffer payload(data, 3); 2931 rtc::Buffer payload(data, 3);
3002 cricket::SendDataResult result; 2932 cricket::SendDataResult result;
3003 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); 2933 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result));
3004 EXPECT_EQ(params.ssrc, 2934 EXPECT_EQ(params.ssrc,
3005 media_channel1_->last_sent_data_params().ssrc); 2935 media_channel1_->last_sent_data_params().ssrc);
3006 EXPECT_EQ("foo", media_channel1_->last_sent_data()); 2936 EXPECT_EQ("foo", media_channel1_->last_sent_data());
3007 } 2937 }
3008 2938
3009 // TODO(pthatcher): TestSetReceiver? 2939 // TODO(pthatcher): TestSetReceiver?
OLDNEW
« no previous file with comments | « talk/session/media/channel.cc ('k') | talk/session/media/mediarecorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698