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

Side by Side Diff: talk/media/webrtc/webrtcvoiceengine_unittest.cc

Issue 1325023005: Remove Channel::SetRingbackTone() and Channel::PlayRingbackTone(), and the code beneath it (within … (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years, 3 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/media/webrtc/webrtcvoiceengine.cc ('k') | talk/session/media/channel.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 2008 Google Inc. 3 * Copyright 2008 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 static const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1, 0); 51 static const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1, 0);
52 static const cricket::AudioCodec kRedCodec(117, "red", 8000, 0, 1, 0); 52 static const cricket::AudioCodec kRedCodec(117, "red", 8000, 0, 1, 0);
53 static const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1, 0); 53 static const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1, 0);
54 static const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1, 0); 54 static const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1, 0);
55 static const cricket::AudioCodec 55 static const cricket::AudioCodec
56 kTelephoneEventCodec(106, "telephone-event", 8000, 0, 1, 0); 56 kTelephoneEventCodec(106, "telephone-event", 8000, 0, 1, 0);
57 static const cricket::AudioCodec* const kAudioCodecs[] = { 57 static const cricket::AudioCodec* const kAudioCodecs[] = {
58 &kPcmuCodec, &kIsacCodec, &kOpusCodec, &kG722CodecVoE, &kRedCodec, 58 &kPcmuCodec, &kIsacCodec, &kOpusCodec, &kG722CodecVoE, &kRedCodec,
59 &kCn8000Codec, &kCn16000Codec, &kTelephoneEventCodec, 59 &kCn8000Codec, &kCn16000Codec, &kTelephoneEventCodec,
60 }; 60 };
61 const char kRingbackTone[] = "RIFF____WAVE____ABCD1234";
62 static uint32 kSsrc1 = 0x99; 61 static uint32 kSsrc1 = 0x99;
63 static uint32 kSsrc2 = 0x98; 62 static uint32 kSsrc2 = 0x98;
64 63
65 class FakeVoEWrapper : public cricket::VoEWrapper { 64 class FakeVoEWrapper : public cricket::VoEWrapper {
66 public: 65 public:
67 explicit FakeVoEWrapper(cricket::FakeWebRtcVoiceEngine* engine) 66 explicit FakeVoEWrapper(cricket::FakeWebRtcVoiceEngine* engine)
68 : cricket::VoEWrapper(engine, // processing 67 : cricket::VoEWrapper(engine, // processing
69 engine, // base 68 engine, // base
70 engine, // codec 69 engine, // codec
71 engine, // dtmf 70 engine, // dtmf
(...skipping 2480 matching lines...) Expand 10 before | Expand all | Expand 10 after
2552 // Test the InsertDtmf on specified send stream as caller. 2551 // Test the InsertDtmf on specified send stream as caller.
2553 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCaller) { 2552 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCaller) {
2554 TestInsertDtmf(kSsrc1, true); 2553 TestInsertDtmf(kSsrc1, true);
2555 } 2554 }
2556 2555
2557 // Test the InsertDtmf on specified send stream as callee. 2556 // Test the InsertDtmf on specified send stream as callee.
2558 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) { 2557 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) {
2559 TestInsertDtmf(kSsrc1, false); 2558 TestInsertDtmf(kSsrc1, false);
2560 } 2559 }
2561 2560
2562 // Test that we can play a ringback tone properly in a single-stream call.
2563 TEST_F(WebRtcVoiceEngineTestFake, PlayRingback) {
2564 EXPECT_TRUE(SetupEngine());
2565 int channel_num = voe_.GetLastChannel();
2566 EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num));
2567 // Check we fail if no ringback tone specified.
2568 EXPECT_FALSE(channel_->PlayRingbackTone(0, true, true));
2569 EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num));
2570 // Check we can set and play a ringback tone.
2571 EXPECT_TRUE(channel_->SetRingbackTone(
2572 kRingbackTone, static_cast<int>(strlen(kRingbackTone))));
2573 EXPECT_TRUE(channel_->PlayRingbackTone(0, true, true));
2574 EXPECT_EQ(1, voe_.IsPlayingFileLocally(channel_num));
2575 // Check we can stop the tone manually.
2576 EXPECT_TRUE(channel_->PlayRingbackTone(0, false, false));
2577 EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num));
2578 // Check we stop the tone if a packet arrives.
2579 EXPECT_TRUE(channel_->PlayRingbackTone(0, true, true));
2580 EXPECT_EQ(1, voe_.IsPlayingFileLocally(channel_num));
2581 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame));
2582 EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num));
2583 }
2584
2585 // Test that we can play a ringback tone properly in a multi-stream call.
2586 TEST_F(WebRtcVoiceEngineTestFake, PlayRingbackWithMultipleStreams) {
2587 EXPECT_TRUE(SetupEngine());
2588 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
2589 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
2590 int channel_num = voe_.GetLastChannel();
2591 EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num));
2592 // Check we fail if no ringback tone specified.
2593 EXPECT_FALSE(channel_->PlayRingbackTone(2, true, true));
2594 EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num));
2595 // Check we can set and play a ringback tone on the correct ssrc.
2596 EXPECT_TRUE(channel_->SetRingbackTone(
2597 kRingbackTone, static_cast<int>(strlen(kRingbackTone))));
2598 EXPECT_FALSE(channel_->PlayRingbackTone(77, true, true));
2599 EXPECT_TRUE(channel_->PlayRingbackTone(2, true, true));
2600 EXPECT_EQ(1, voe_.IsPlayingFileLocally(channel_num));
2601 // Check we can stop the tone manually.
2602 EXPECT_TRUE(channel_->PlayRingbackTone(2, false, false));
2603 EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num));
2604 // Check we stop the tone if a packet arrives, but only with the right SSRC.
2605 EXPECT_TRUE(channel_->PlayRingbackTone(2, true, true));
2606 EXPECT_EQ(1, voe_.IsPlayingFileLocally(channel_num));
2607 // Send a packet with SSRC 1; the tone should not stop.
2608 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame));
2609 EXPECT_EQ(1, voe_.IsPlayingFileLocally(channel_num));
2610 // Send a packet with SSRC 2; the tone should stop.
2611 char packet[sizeof(kPcmuFrame)];
2612 memcpy(packet, kPcmuFrame, sizeof(kPcmuFrame));
2613 rtc::SetBE32(packet + 8, 2);
2614 DeliverPacket(packet, sizeof(packet));
2615 EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num));
2616 }
2617
2618 TEST_F(WebRtcVoiceEngineTestFake, MediaEngineCallbackOnError) { 2561 TEST_F(WebRtcVoiceEngineTestFake, MediaEngineCallbackOnError) {
2619 rtc::scoped_ptr<ChannelErrorListener> listener; 2562 rtc::scoped_ptr<ChannelErrorListener> listener;
2620 cricket::WebRtcVoiceMediaChannel* media_channel; 2563 cricket::WebRtcVoiceMediaChannel* media_channel;
2621 unsigned int ssrc = 0; 2564 unsigned int ssrc = 0;
2622 2565
2623 EXPECT_TRUE(SetupEngine()); 2566 EXPECT_TRUE(SetupEngine());
2624 send_parameters_.options = options_conference_; 2567 send_parameters_.options = options_conference_;
2625 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 2568 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2626 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); 2569 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE));
2627 2570
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after
3525 cricket::WebRtcVoiceEngine engine; 3468 cricket::WebRtcVoiceEngine engine;
3526 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); 3469 EXPECT_TRUE(engine.Init(rtc::Thread::Current()));
3527 rtc::scoped_ptr<webrtc::Call> call( 3470 rtc::scoped_ptr<webrtc::Call> call(
3528 webrtc::Call::Create(webrtc::Call::Config())); 3471 webrtc::Call::Create(webrtc::Call::Config()));
3529 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(), 3472 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(),
3530 call.get()); 3473 call.get());
3531 cricket::AudioRecvParameters parameters; 3474 cricket::AudioRecvParameters parameters;
3532 parameters.codecs = engine.codecs(); 3475 parameters.codecs = engine.codecs();
3533 EXPECT_TRUE(channel.SetRecvParameters(parameters)); 3476 EXPECT_TRUE(channel.SetRecvParameters(parameters));
3534 } 3477 }
OLDNEW
« no previous file with comments | « talk/media/webrtc/webrtcvoiceengine.cc ('k') | talk/session/media/channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698