| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 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 28 matching lines...) Expand all Loading... |
| 39 #include "webrtc/base/basictypes.h" | 39 #include "webrtc/base/basictypes.h" |
| 40 #include "webrtc/base/checks.h" | 40 #include "webrtc/base/checks.h" |
| 41 #include "webrtc/base/gunit.h" | 41 #include "webrtc/base/gunit.h" |
| 42 #include "webrtc/base/stringutils.h" | 42 #include "webrtc/base/stringutils.h" |
| 43 #include "webrtc/config.h" | 43 #include "webrtc/config.h" |
| 44 #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" | 44 #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" |
| 45 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 45 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
| 46 | 46 |
| 47 namespace cricket { | 47 namespace cricket { |
| 48 | 48 |
| 49 static const char kFakeDefaultDeviceName[] = "Fake Default"; | |
| 50 static const int kFakeDefaultDeviceId = -1; | |
| 51 static const char kFakeDeviceName[] = "Fake Device"; | |
| 52 #ifdef WIN32 | |
| 53 static const int kFakeDeviceId = 0; | |
| 54 #else | |
| 55 static const int kFakeDeviceId = 1; | |
| 56 #endif | |
| 57 | |
| 58 static const int kOpusBandwidthNb = 4000; | 49 static const int kOpusBandwidthNb = 4000; |
| 59 static const int kOpusBandwidthMb = 6000; | 50 static const int kOpusBandwidthMb = 6000; |
| 60 static const int kOpusBandwidthWb = 8000; | 51 static const int kOpusBandwidthWb = 8000; |
| 61 static const int kOpusBandwidthSwb = 12000; | 52 static const int kOpusBandwidthSwb = 12000; |
| 62 static const int kOpusBandwidthFb = 20000; | 53 static const int kOpusBandwidthFb = 20000; |
| 63 | 54 |
| 64 #define WEBRTC_CHECK_CHANNEL(channel) \ | 55 #define WEBRTC_CHECK_CHANNEL(channel) \ |
| 65 if (channels_.find(channel) == channels_.end()) return -1; | 56 if (channels_.find(channel) == channels_.end()) return -1; |
| 66 | 57 |
| 67 class FakeAudioProcessing : public webrtc::AudioProcessing { | 58 class FakeAudioProcessing : public webrtc::AudioProcessing { |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 WEBRTC_CHECK_CHANNEL(channel); | 522 WEBRTC_CHECK_CHANNEL(channel); |
| 532 if (_stricmp(channels_[channel]->send_codec.plname, "opus") != 0) { | 523 if (_stricmp(channels_[channel]->send_codec.plname, "opus") != 0) { |
| 533 // Return -1 if current send codec is not Opus. | 524 // Return -1 if current send codec is not Opus. |
| 534 return -1; | 525 return -1; |
| 535 } | 526 } |
| 536 channels_[channel]->opus_dtx = enable_dtx; | 527 channels_[channel]->opus_dtx = enable_dtx; |
| 537 return 0; | 528 return 0; |
| 538 } | 529 } |
| 539 | 530 |
| 540 // webrtc::VoEHardware | 531 // webrtc::VoEHardware |
| 541 WEBRTC_FUNC(GetNumOfRecordingDevices, (int& num)) { | 532 WEBRTC_STUB(GetNumOfRecordingDevices, (int& num)); |
| 542 return GetNumDevices(num); | 533 WEBRTC_STUB(GetNumOfPlayoutDevices, (int& num)); |
| 543 } | 534 WEBRTC_STUB(GetRecordingDeviceName, (int i, char* name, char* guid)); |
| 544 WEBRTC_FUNC(GetNumOfPlayoutDevices, (int& num)) { | 535 WEBRTC_STUB(GetPlayoutDeviceName, (int i, char* name, char* guid)); |
| 545 return GetNumDevices(num); | |
| 546 } | |
| 547 WEBRTC_FUNC(GetRecordingDeviceName, (int i, char* name, char* guid)) { | |
| 548 return GetDeviceName(i, name, guid); | |
| 549 } | |
| 550 WEBRTC_FUNC(GetPlayoutDeviceName, (int i, char* name, char* guid)) { | |
| 551 return GetDeviceName(i, name, guid); | |
| 552 } | |
| 553 WEBRTC_STUB(SetRecordingDevice, (int, webrtc::StereoChannel)); | 536 WEBRTC_STUB(SetRecordingDevice, (int, webrtc::StereoChannel)); |
| 554 WEBRTC_STUB(SetPlayoutDevice, (int)); | 537 WEBRTC_STUB(SetPlayoutDevice, (int)); |
| 555 WEBRTC_STUB(SetAudioDeviceLayer, (webrtc::AudioLayers)); | 538 WEBRTC_STUB(SetAudioDeviceLayer, (webrtc::AudioLayers)); |
| 556 WEBRTC_STUB(GetAudioDeviceLayer, (webrtc::AudioLayers&)); | 539 WEBRTC_STUB(GetAudioDeviceLayer, (webrtc::AudioLayers&)); |
| 557 WEBRTC_FUNC(SetRecordingSampleRate, (unsigned int samples_per_sec)) { | 540 WEBRTC_FUNC(SetRecordingSampleRate, (unsigned int samples_per_sec)) { |
| 558 recording_sample_rate_ = samples_per_sec; | 541 recording_sample_rate_ = samples_per_sec; |
| 559 return 0; | 542 return 0; |
| 560 } | 543 } |
| 561 WEBRTC_FUNC_CONST(RecordingSampleRate, (unsigned int* samples_per_sec)) { | 544 WEBRTC_FUNC_CONST(RecordingSampleRate, (unsigned int* samples_per_sec)) { |
| 562 *samples_per_sec = recording_sample_rate_; | 545 *samples_per_sec = recording_sample_rate_; |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 ASSERT(ch != channels_.end()); | 784 ASSERT(ch != channels_.end()); |
| 802 return ch->second->neteq_capacity; | 785 return ch->second->neteq_capacity; |
| 803 } | 786 } |
| 804 bool GetNetEqFastAccelerate() const { | 787 bool GetNetEqFastAccelerate() const { |
| 805 auto ch = channels_.find(last_channel_); | 788 auto ch = channels_.find(last_channel_); |
| 806 ASSERT(ch != channels_.end()); | 789 ASSERT(ch != channels_.end()); |
| 807 return ch->second->neteq_fast_accelerate; | 790 return ch->second->neteq_fast_accelerate; |
| 808 } | 791 } |
| 809 | 792 |
| 810 private: | 793 private: |
| 811 int GetNumDevices(int& num) { | |
| 812 #ifdef WIN32 | |
| 813 num = 1; | |
| 814 #else | |
| 815 // On non-Windows platforms VE adds a special entry for the default device, | |
| 816 // so if there is one physical device then there are two entries in the | |
| 817 // list. | |
| 818 num = 2; | |
| 819 #endif | |
| 820 return 0; | |
| 821 } | |
| 822 | |
| 823 int GetDeviceName(int i, char* name, char* guid) { | |
| 824 const char *s; | |
| 825 #ifdef WIN32 | |
| 826 if (0 == i) { | |
| 827 s = kFakeDeviceName; | |
| 828 } else { | |
| 829 return -1; | |
| 830 } | |
| 831 #else | |
| 832 // See comment above. | |
| 833 if (0 == i) { | |
| 834 s = kFakeDefaultDeviceName; | |
| 835 } else if (1 == i) { | |
| 836 s = kFakeDeviceName; | |
| 837 } else { | |
| 838 return -1; | |
| 839 } | |
| 840 #endif | |
| 841 strcpy(name, s); | |
| 842 guid[0] = '\0'; | |
| 843 return 0; | |
| 844 } | |
| 845 | |
| 846 bool inited_; | 794 bool inited_; |
| 847 int last_channel_; | 795 int last_channel_; |
| 848 std::map<int, Channel*> channels_; | 796 std::map<int, Channel*> channels_; |
| 849 bool fail_create_channel_; | 797 bool fail_create_channel_; |
| 850 int num_set_send_codecs_; // how many times we call SetSendCodec(). | 798 int num_set_send_codecs_; // how many times we call SetSendCodec(). |
| 851 bool ec_enabled_; | 799 bool ec_enabled_; |
| 852 bool ec_metrics_enabled_; | 800 bool ec_metrics_enabled_; |
| 853 bool cng_enabled_; | 801 bool cng_enabled_; |
| 854 bool ns_enabled_; | 802 bool ns_enabled_; |
| 855 bool agc_enabled_; | 803 bool agc_enabled_; |
| 856 bool highpass_filter_enabled_; | 804 bool highpass_filter_enabled_; |
| 857 bool stereo_swapping_enabled_; | 805 bool stereo_swapping_enabled_; |
| 858 bool typing_detection_enabled_; | 806 bool typing_detection_enabled_; |
| 859 webrtc::EcModes ec_mode_; | 807 webrtc::EcModes ec_mode_; |
| 860 webrtc::AecmModes aecm_mode_; | 808 webrtc::AecmModes aecm_mode_; |
| 861 webrtc::NsModes ns_mode_; | 809 webrtc::NsModes ns_mode_; |
| 862 webrtc::AgcModes agc_mode_; | 810 webrtc::AgcModes agc_mode_; |
| 863 webrtc::AgcConfig agc_config_; | 811 webrtc::AgcConfig agc_config_; |
| 864 webrtc::VoiceEngineObserver* observer_; | 812 webrtc::VoiceEngineObserver* observer_; |
| 865 int playout_fail_channel_; | 813 int playout_fail_channel_; |
| 866 int send_fail_channel_; | 814 int send_fail_channel_; |
| 867 int recording_sample_rate_; | 815 int recording_sample_rate_; |
| 868 int playout_sample_rate_; | 816 int playout_sample_rate_; |
| 869 FakeAudioProcessing audio_processing_; | 817 FakeAudioProcessing audio_processing_; |
| 870 }; | 818 }; |
| 871 | 819 |
| 872 } // namespace cricket | 820 } // namespace cricket |
| 873 | 821 |
| 874 #endif // TALK_SESSION_PHONE_FAKEWEBRTCVOICEENGINE_H_ | 822 #endif // TALK_SESSION_PHONE_FAKEWEBRTCVOICEENGINE_H_ |
| OLD | NEW |