OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 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 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 // TODO(thaloun): Replace with explicit checks of before & after values. | 764 // TODO(thaloun): Replace with explicit checks of before & after values. |
765 bool options_changed_; | 765 bool options_changed_; |
766 bool fail_create_channel_; | 766 bool fail_create_channel_; |
767 std::vector<RtpHeaderExtension> rtp_header_extensions_; | 767 std::vector<RtpHeaderExtension> rtp_header_extensions_; |
768 }; | 768 }; |
769 | 769 |
770 class FakeVoiceEngine : public FakeBaseEngine { | 770 class FakeVoiceEngine : public FakeBaseEngine { |
771 public: | 771 public: |
772 FakeVoiceEngine() | 772 FakeVoiceEngine() |
773 : output_volume_(-1), | 773 : output_volume_(-1), |
774 delay_offset_(0), | 774 delay_offset_(0) { |
775 rx_processor_(NULL), | |
776 tx_processor_(NULL) { | |
777 // Add a fake audio codec. Note that the name must not be "" as there are | 775 // Add a fake audio codec. Note that the name must not be "" as there are |
778 // sanity checks against that. | 776 // sanity checks against that. |
779 codecs_.push_back(AudioCodec(101, "fake_audio_codec", 0, 0, 1, 0)); | 777 codecs_.push_back(AudioCodec(101, "fake_audio_codec", 0, 0, 1, 0)); |
780 } | 778 } |
781 bool Init(rtc::Thread* worker_thread) { return true; } | 779 bool Init(rtc::Thread* worker_thread) { return true; } |
782 void Terminate() {} | 780 void Terminate() {} |
783 int GetCapabilities() { return AUDIO_SEND | AUDIO_RECV; } | 781 int GetCapabilities() { return AUDIO_SEND | AUDIO_RECV; } |
784 webrtc::VoiceEngine* GetVoE() { return nullptr; } | 782 webrtc::VoiceEngine* GetVoE() { return nullptr; } |
785 AudioOptions GetOptions() const { | 783 AudioOptions GetOptions() const { |
786 return options_; | 784 return options_; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 bool SetOutputVolume(int level) { | 829 bool SetOutputVolume(int level) { |
832 output_volume_ = level; | 830 output_volume_ = level; |
833 options_changed_ = true; | 831 options_changed_ = true; |
834 return true; | 832 return true; |
835 } | 833 } |
836 | 834 |
837 int GetInputLevel() { return 0; } | 835 int GetInputLevel() { return 0; } |
838 | 836 |
839 bool StartAecDump(rtc::PlatformFile file) { return false; } | 837 bool StartAecDump(rtc::PlatformFile file) { return false; } |
840 | 838 |
841 bool RegisterProcessor(uint32 ssrc, VoiceProcessor* voice_processor, | |
842 MediaProcessorDirection direction) { | |
843 if (direction == MPD_RX) { | |
844 rx_processor_ = voice_processor; | |
845 return true; | |
846 } else if (direction == MPD_TX) { | |
847 tx_processor_ = voice_processor; | |
848 return true; | |
849 } | |
850 return false; | |
851 } | |
852 | |
853 bool UnregisterProcessor(uint32 ssrc, VoiceProcessor* voice_processor, | |
854 MediaProcessorDirection direction) { | |
855 bool unregistered = false; | |
856 if (direction & MPD_RX) { | |
857 rx_processor_ = NULL; | |
858 unregistered = true; | |
859 } | |
860 if (direction & MPD_TX) { | |
861 tx_processor_ = NULL; | |
862 unregistered = true; | |
863 } | |
864 return unregistered; | |
865 } | |
866 | |
867 private: | 839 private: |
868 std::vector<FakeVoiceMediaChannel*> channels_; | 840 std::vector<FakeVoiceMediaChannel*> channels_; |
869 std::vector<AudioCodec> codecs_; | 841 std::vector<AudioCodec> codecs_; |
870 int output_volume_; | 842 int output_volume_; |
871 int delay_offset_; | 843 int delay_offset_; |
872 std::string in_device_; | 844 std::string in_device_; |
873 std::string out_device_; | 845 std::string out_device_; |
874 VoiceProcessor* rx_processor_; | |
875 VoiceProcessor* tx_processor_; | |
876 AudioOptions options_; | 846 AudioOptions options_; |
877 | 847 |
878 friend class FakeMediaEngine; | 848 friend class FakeMediaEngine; |
879 }; | 849 }; |
880 | 850 |
881 class FakeVideoEngine : public FakeBaseEngine { | 851 class FakeVideoEngine : public FakeBaseEngine { |
882 public: | 852 public: |
883 FakeVideoEngine() : capture_(false) { | 853 FakeVideoEngine() : capture_(false) { |
884 // Add a fake video codec. Note that the name must not be "" as there are | 854 // Add a fake video codec. Note that the name must not be "" as there are |
885 // sanity checks against that. | 855 // sanity checks against that. |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 return voice_.options_changed_ || video_.options_changed_; | 968 return voice_.options_changed_ || video_.options_changed_; |
999 } | 969 } |
1000 void clear_options_changed() { | 970 void clear_options_changed() { |
1001 video_.options_changed_ = false; | 971 video_.options_changed_ = false; |
1002 voice_.options_changed_ = false; | 972 voice_.options_changed_ = false; |
1003 } | 973 } |
1004 void set_fail_create_channel(bool fail) { | 974 void set_fail_create_channel(bool fail) { |
1005 voice_.set_fail_create_channel(fail); | 975 voice_.set_fail_create_channel(fail); |
1006 video_.set_fail_create_channel(fail); | 976 video_.set_fail_create_channel(fail); |
1007 } | 977 } |
1008 bool voice_processor_registered(MediaProcessorDirection direction) const { | |
1009 if (direction == MPD_RX) { | |
1010 return voice_.rx_processor_ != NULL; | |
1011 } else if (direction == MPD_TX) { | |
1012 return voice_.tx_processor_ != NULL; | |
1013 } | |
1014 return false; | |
1015 } | |
1016 }; | 978 }; |
1017 | 979 |
1018 // CompositeMediaEngine with FakeVoiceEngine to expose SetAudioCodecs to | 980 // CompositeMediaEngine with FakeVoiceEngine to expose SetAudioCodecs to |
1019 // establish a media connectionwith minimum set of audio codes required | 981 // establish a media connectionwith minimum set of audio codes required |
1020 template <class VIDEO> | 982 template <class VIDEO> |
1021 class CompositeMediaEngineWithFakeVoiceEngine : | 983 class CompositeMediaEngineWithFakeVoiceEngine : |
1022 public CompositeMediaEngine<FakeVoiceEngine, VIDEO> { | 984 public CompositeMediaEngine<FakeVoiceEngine, VIDEO> { |
1023 public: | 985 public: |
1024 CompositeMediaEngineWithFakeVoiceEngine() {} | 986 CompositeMediaEngineWithFakeVoiceEngine() {} |
1025 virtual ~CompositeMediaEngineWithFakeVoiceEngine() {} | 987 virtual ~CompositeMediaEngineWithFakeVoiceEngine() {} |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 | 1033 |
1072 private: | 1034 private: |
1073 std::vector<FakeDataMediaChannel*> channels_; | 1035 std::vector<FakeDataMediaChannel*> channels_; |
1074 std::vector<DataCodec> data_codecs_; | 1036 std::vector<DataCodec> data_codecs_; |
1075 DataChannelType last_channel_type_; | 1037 DataChannelType last_channel_type_; |
1076 }; | 1038 }; |
1077 | 1039 |
1078 } // namespace cricket | 1040 } // namespace cricket |
1079 | 1041 |
1080 #endif // TALK_MEDIA_BASE_FAKEMEDIAENGINE_H_ | 1042 #endif // TALK_MEDIA_BASE_FAKEMEDIAENGINE_H_ |
OLD | NEW |