| 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 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 : output_volume_(-1) { | 715 : output_volume_(-1) { |
| 716 // Add a fake audio codec. Note that the name must not be "" as there are | 716 // Add a fake audio codec. Note that the name must not be "" as there are |
| 717 // sanity checks against that. | 717 // sanity checks against that. |
| 718 codecs_.push_back(AudioCodec(101, "fake_audio_codec", 0, 0, 1, 0)); | 718 codecs_.push_back(AudioCodec(101, "fake_audio_codec", 0, 0, 1, 0)); |
| 719 } | 719 } |
| 720 bool Init(rtc::Thread* worker_thread) { return true; } | 720 bool Init(rtc::Thread* worker_thread) { return true; } |
| 721 void Terminate() {} | 721 void Terminate() {} |
| 722 rtc::scoped_refptr<webrtc::AudioState> GetAudioState() const { | 722 rtc::scoped_refptr<webrtc::AudioState> GetAudioState() const { |
| 723 return rtc::scoped_refptr<webrtc::AudioState>(); | 723 return rtc::scoped_refptr<webrtc::AudioState>(); |
| 724 } | 724 } |
| 725 AudioOptions GetOptions() const { | |
| 726 return options_; | |
| 727 } | |
| 728 bool SetOptions(const AudioOptions& options) { | |
| 729 options_ = options; | |
| 730 options_changed_ = true; | |
| 731 return true; | |
| 732 } | |
| 733 | 725 |
| 734 VoiceMediaChannel* CreateChannel(webrtc::Call* call, | 726 VoiceMediaChannel* CreateChannel(webrtc::Call* call, |
| 735 const AudioOptions& options) { | 727 const AudioOptions& options) { |
| 736 if (fail_create_channel_) { | 728 if (fail_create_channel_) { |
| 737 return nullptr; | 729 return nullptr; |
| 738 } | 730 } |
| 739 | 731 |
| 740 FakeVoiceMediaChannel* ch = new FakeVoiceMediaChannel(this, options); | 732 FakeVoiceMediaChannel* ch = new FakeVoiceMediaChannel(this, options); |
| 741 channels_.push_back(ch); | 733 channels_.push_back(ch); |
| 742 return ch; | 734 return ch; |
| 743 } | 735 } |
| 744 FakeVoiceMediaChannel* GetChannel(size_t index) { | 736 FakeVoiceMediaChannel* GetChannel(size_t index) { |
| 745 return (channels_.size() > index) ? channels_[index] : NULL; | 737 return (channels_.size() > index) ? channels_[index] : NULL; |
| 746 } | 738 } |
| 747 void UnregisterChannel(VoiceMediaChannel* channel) { | 739 void UnregisterChannel(VoiceMediaChannel* channel) { |
| 748 channels_.erase(std::find(channels_.begin(), channels_.end(), channel)); | 740 channels_.erase(std::find(channels_.begin(), channels_.end(), channel)); |
| 749 } | 741 } |
| 750 | 742 |
| 751 const std::vector<AudioCodec>& codecs() { return codecs_; } | 743 const std::vector<AudioCodec>& codecs() { return codecs_; } |
| 752 void SetCodecs(const std::vector<AudioCodec> codecs) { codecs_ = codecs; } | 744 void SetCodecs(const std::vector<AudioCodec> codecs) { codecs_ = codecs; } |
| 753 | 745 |
| 754 bool SetDevices(const Device* in_device, const Device* out_device) { | |
| 755 in_device_ = (in_device) ? in_device->name : ""; | |
| 756 out_device_ = (out_device) ? out_device->name : ""; | |
| 757 options_changed_ = true; | |
| 758 return true; | |
| 759 } | |
| 760 | |
| 761 bool GetOutputVolume(int* level) { | 746 bool GetOutputVolume(int* level) { |
| 762 *level = output_volume_; | 747 *level = output_volume_; |
| 763 return true; | 748 return true; |
| 764 } | 749 } |
| 765 | |
| 766 bool SetOutputVolume(int level) { | 750 bool SetOutputVolume(int level) { |
| 767 output_volume_ = level; | 751 output_volume_ = level; |
| 768 options_changed_ = true; | |
| 769 return true; | 752 return true; |
| 770 } | 753 } |
| 771 | 754 |
| 772 int GetInputLevel() { return 0; } | 755 int GetInputLevel() { return 0; } |
| 773 | 756 |
| 774 bool StartAecDump(rtc::PlatformFile file) { return false; } | 757 bool StartAecDump(rtc::PlatformFile file) { return false; } |
| 775 | 758 |
| 776 void StopAecDump() {} | 759 void StopAecDump() {} |
| 777 | 760 |
| 778 bool StartRtcEventLog(rtc::PlatformFile file) { return false; } | 761 bool StartRtcEventLog(rtc::PlatformFile file) { return false; } |
| 779 | 762 |
| 780 void StopRtcEventLog() {} | 763 void StopRtcEventLog() {} |
| 781 | 764 |
| 782 private: | 765 private: |
| 783 std::vector<FakeVoiceMediaChannel*> channels_; | 766 std::vector<FakeVoiceMediaChannel*> channels_; |
| 784 std::vector<AudioCodec> codecs_; | 767 std::vector<AudioCodec> codecs_; |
| 785 int output_volume_; | 768 int output_volume_; |
| 786 std::string in_device_; | |
| 787 std::string out_device_; | |
| 788 AudioOptions options_; | |
| 789 | 769 |
| 790 friend class FakeMediaEngine; | 770 friend class FakeMediaEngine; |
| 791 }; | 771 }; |
| 792 | 772 |
| 793 class FakeVideoEngine : public FakeBaseEngine { | 773 class FakeVideoEngine : public FakeBaseEngine { |
| 794 public: | 774 public: |
| 795 FakeVideoEngine() : capture_(false) { | 775 FakeVideoEngine() : capture_(false) { |
| 796 // Add a fake video codec. Note that the name must not be "" as there are | 776 // Add a fake video codec. Note that the name must not be "" as there are |
| 797 // sanity checks against that. | 777 // sanity checks against that. |
| 798 codecs_.push_back(VideoCodec(0, "fake_video_codec", 0, 0, 0, 0)); | 778 codecs_.push_back(VideoCodec(0, "fake_video_codec", 0, 0, 0, 0)); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 std::string in_device_; | 836 std::string in_device_; |
| 857 bool capture_; | 837 bool capture_; |
| 858 VideoOptions options_; | 838 VideoOptions options_; |
| 859 | 839 |
| 860 friend class FakeMediaEngine; | 840 friend class FakeMediaEngine; |
| 861 }; | 841 }; |
| 862 | 842 |
| 863 class FakeMediaEngine : | 843 class FakeMediaEngine : |
| 864 public CompositeMediaEngine<FakeVoiceEngine, FakeVideoEngine> { | 844 public CompositeMediaEngine<FakeVoiceEngine, FakeVideoEngine> { |
| 865 public: | 845 public: |
| 866 FakeMediaEngine() { | 846 FakeMediaEngine() {} |
| 867 voice_ = FakeVoiceEngine(); | |
| 868 video_ = FakeVideoEngine(); | |
| 869 } | |
| 870 virtual ~FakeMediaEngine() {} | 847 virtual ~FakeMediaEngine() {} |
| 871 | 848 |
| 872 void SetAudioCodecs(const std::vector<AudioCodec>& codecs) { | 849 void SetAudioCodecs(const std::vector<AudioCodec>& codecs) { |
| 873 voice_.SetCodecs(codecs); | 850 voice_.SetCodecs(codecs); |
| 874 } | 851 } |
| 875 void SetVideoCodecs(const std::vector<VideoCodec>& codecs) { | 852 void SetVideoCodecs(const std::vector<VideoCodec>& codecs) { |
| 876 video_.SetCodecs(codecs); | 853 video_.SetCodecs(codecs); |
| 877 } | 854 } |
| 878 | 855 |
| 879 void SetAudioRtpHeaderExtensions( | 856 void SetAudioRtpHeaderExtensions( |
| 880 const std::vector<RtpHeaderExtension>& extensions) { | 857 const std::vector<RtpHeaderExtension>& extensions) { |
| 881 voice_.set_rtp_header_extensions(extensions); | 858 voice_.set_rtp_header_extensions(extensions); |
| 882 } | 859 } |
| 883 void SetVideoRtpHeaderExtensions( | 860 void SetVideoRtpHeaderExtensions( |
| 884 const std::vector<RtpHeaderExtension>& extensions) { | 861 const std::vector<RtpHeaderExtension>& extensions) { |
| 885 video_.set_rtp_header_extensions(extensions); | 862 video_.set_rtp_header_extensions(extensions); |
| 886 } | 863 } |
| 887 | 864 |
| 888 FakeVoiceMediaChannel* GetVoiceChannel(size_t index) { | 865 FakeVoiceMediaChannel* GetVoiceChannel(size_t index) { |
| 889 return voice_.GetChannel(index); | 866 return voice_.GetChannel(index); |
| 890 } | 867 } |
| 891 FakeVideoMediaChannel* GetVideoChannel(size_t index) { | 868 FakeVideoMediaChannel* GetVideoChannel(size_t index) { |
| 892 return video_.GetChannel(index); | 869 return video_.GetChannel(index); |
| 893 } | 870 } |
| 894 | 871 |
| 895 AudioOptions audio_options() const { return voice_.options_; } | |
| 896 int output_volume() const { return voice_.output_volume_; } | 872 int output_volume() const { return voice_.output_volume_; } |
| 897 const VideoEncoderConfig& default_video_encoder_config() const { | 873 const VideoEncoderConfig& default_video_encoder_config() const { |
| 898 return video_.default_encoder_config_; | 874 return video_.default_encoder_config_; |
| 899 } | 875 } |
| 900 const std::string& audio_in_device() const { return voice_.in_device_; } | |
| 901 const std::string& audio_out_device() const { return voice_.out_device_; } | |
| 902 bool capture() const { return video_.capture_; } | 876 bool capture() const { return video_.capture_; } |
| 903 bool options_changed() const { | 877 bool options_changed() const { |
| 904 return voice_.options_changed_ || video_.options_changed_; | 878 return video_.options_changed_; |
| 905 } | 879 } |
| 906 void clear_options_changed() { | 880 void clear_options_changed() { |
| 907 video_.options_changed_ = false; | 881 video_.options_changed_ = false; |
| 908 voice_.options_changed_ = false; | |
| 909 } | 882 } |
| 910 void set_fail_create_channel(bool fail) { | 883 void set_fail_create_channel(bool fail) { |
| 911 voice_.set_fail_create_channel(fail); | 884 voice_.set_fail_create_channel(fail); |
| 912 video_.set_fail_create_channel(fail); | 885 video_.set_fail_create_channel(fail); |
| 913 } | 886 } |
| 914 }; | 887 }; |
| 915 | 888 |
| 916 // CompositeMediaEngine with FakeVoiceEngine to expose SetAudioCodecs to | 889 // CompositeMediaEngine with FakeVoiceEngine to expose SetAudioCodecs to |
| 917 // establish a media connectionwith minimum set of audio codes required | 890 // establish a media connectionwith minimum set of audio codes required |
| 918 template <class VIDEO> | 891 template <class VIDEO> |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 | 942 |
| 970 private: | 943 private: |
| 971 std::vector<FakeDataMediaChannel*> channels_; | 944 std::vector<FakeDataMediaChannel*> channels_; |
| 972 std::vector<DataCodec> data_codecs_; | 945 std::vector<DataCodec> data_codecs_; |
| 973 DataChannelType last_channel_type_; | 946 DataChannelType last_channel_type_; |
| 974 }; | 947 }; |
| 975 | 948 |
| 976 } // namespace cricket | 949 } // namespace cricket |
| 977 | 950 |
| 978 #endif // TALK_MEDIA_BASE_FAKEMEDIAENGINE_H_ | 951 #endif // TALK_MEDIA_BASE_FAKEMEDIAENGINE_H_ |
| OLD | NEW |