OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 // Flag used by optionsmessagehandler_unittest for checking whether any | 767 // Flag used by optionsmessagehandler_unittest for checking whether any |
768 // relevant setting has been updated. | 768 // relevant setting has been updated. |
769 // TODO(thaloun): Replace with explicit checks of before & after values. | 769 // TODO(thaloun): Replace with explicit checks of before & after values. |
770 bool options_changed_; | 770 bool options_changed_; |
771 bool fail_create_channel_; | 771 bool fail_create_channel_; |
772 RtpCapabilities capabilities_; | 772 RtpCapabilities capabilities_; |
773 }; | 773 }; |
774 | 774 |
775 class FakeVoiceEngine : public FakeBaseEngine { | 775 class FakeVoiceEngine : public FakeBaseEngine { |
776 public: | 776 public: |
777 FakeVoiceEngine(webrtc::AudioDeviceModule* adm, | 777 FakeVoiceEngine() { |
778 const rtc::scoped_refptr<webrtc::AudioEncoderFactory>& | |
779 audio_encoder_factory, | |
780 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& | |
781 audio_decoder_factory, | |
782 rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer, | |
783 rtc::scoped_refptr<webrtc::AudioProcessing> apm) { | |
784 // Add a fake audio codec. Note that the name must not be "" as there are | 778 // Add a fake audio codec. Note that the name must not be "" as there are |
785 // sanity checks against that. | 779 // sanity checks against that. |
786 codecs_.push_back(AudioCodec(101, "fake_audio_codec", 0, 0, 1)); | 780 codecs_.push_back(AudioCodec(101, "fake_audio_codec", 0, 0, 1)); |
787 } | 781 } |
788 void Init() {} | 782 void Init() {} |
789 rtc::scoped_refptr<webrtc::AudioState> GetAudioState() const { | 783 rtc::scoped_refptr<webrtc::AudioState> GetAudioState() const { |
790 return rtc::scoped_refptr<webrtc::AudioState>(); | 784 return rtc::scoped_refptr<webrtc::AudioState>(); |
791 } | 785 } |
792 | 786 |
793 VoiceMediaChannel* CreateChannel(webrtc::Call* call, | 787 VoiceMediaChannel* CreateChannel(webrtc::Call* call, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 }; | 830 }; |
837 | 831 |
838 class FakeVideoEngine : public FakeBaseEngine { | 832 class FakeVideoEngine : public FakeBaseEngine { |
839 public: | 833 public: |
840 FakeVideoEngine() : capture_(false) { | 834 FakeVideoEngine() : capture_(false) { |
841 // Add a fake video codec. Note that the name must not be "" as there are | 835 // Add a fake video codec. Note that the name must not be "" as there are |
842 // sanity checks against that. | 836 // sanity checks against that. |
843 codecs_.push_back(VideoCodec(0, "fake_video_codec")); | 837 codecs_.push_back(VideoCodec(0, "fake_video_codec")); |
844 } | 838 } |
845 | 839 |
846 void Init() {} | |
847 | |
848 bool SetOptions(const VideoOptions& options) { | 840 bool SetOptions(const VideoOptions& options) { |
849 options_ = options; | 841 options_ = options; |
850 options_changed_ = true; | 842 options_changed_ = true; |
851 return true; | 843 return true; |
852 } | 844 } |
853 | 845 |
854 VideoMediaChannel* CreateChannel(webrtc::Call* call, | 846 VideoMediaChannel* CreateChannel(webrtc::Call* call, |
855 const MediaConfig& config, | 847 const MediaConfig& config, |
856 const VideoOptions& options) { | 848 const VideoOptions& options) { |
857 if (fail_create_channel_) { | 849 if (fail_create_channel_) { |
(...skipping 30 matching lines...) Expand all Loading... |
888 bool capture_; | 880 bool capture_; |
889 VideoOptions options_; | 881 VideoOptions options_; |
890 | 882 |
891 friend class FakeMediaEngine; | 883 friend class FakeMediaEngine; |
892 }; | 884 }; |
893 | 885 |
894 class FakeMediaEngine : | 886 class FakeMediaEngine : |
895 public CompositeMediaEngine<FakeVoiceEngine, FakeVideoEngine> { | 887 public CompositeMediaEngine<FakeVoiceEngine, FakeVideoEngine> { |
896 public: | 888 public: |
897 FakeMediaEngine() | 889 FakeMediaEngine() |
898 : CompositeMediaEngine<FakeVoiceEngine, FakeVideoEngine>(nullptr, | 890 : CompositeMediaEngine<FakeVoiceEngine, FakeVideoEngine>(std::tuple<>(), |
899 nullptr, | 891 std::tuple<>()) { |
900 nullptr, | 892 } |
901 nullptr, | 893 |
902 nullptr) {} | |
903 virtual ~FakeMediaEngine() {} | 894 virtual ~FakeMediaEngine() {} |
904 | 895 |
905 void SetAudioCodecs(const std::vector<AudioCodec>& codecs) { | 896 void SetAudioCodecs(const std::vector<AudioCodec>& codecs) { |
906 voice_.SetCodecs(codecs); | 897 voice().SetCodecs(codecs); |
907 } | 898 } |
908 void SetVideoCodecs(const std::vector<VideoCodec>& codecs) { | 899 void SetVideoCodecs(const std::vector<VideoCodec>& codecs) { |
909 video_.SetCodecs(codecs); | 900 video().SetCodecs(codecs); |
910 } | 901 } |
911 | 902 |
912 void SetAudioRtpHeaderExtensions( | 903 void SetAudioRtpHeaderExtensions( |
913 const std::vector<RtpExtension>& extensions) { | 904 const std::vector<RtpExtension>& extensions) { |
914 voice_.set_rtp_header_extensions(extensions); | 905 voice().set_rtp_header_extensions(extensions); |
915 } | 906 } |
916 void SetVideoRtpHeaderExtensions( | 907 void SetVideoRtpHeaderExtensions( |
917 const std::vector<RtpExtension>& extensions) { | 908 const std::vector<RtpExtension>& extensions) { |
918 video_.set_rtp_header_extensions(extensions); | 909 video().set_rtp_header_extensions(extensions); |
919 } | 910 } |
920 | 911 |
921 void SetAudioRtpHeaderExtensions( | 912 void SetAudioRtpHeaderExtensions( |
922 const std::vector<cricket::RtpHeaderExtension>& extensions) { | 913 const std::vector<cricket::RtpHeaderExtension>& extensions) { |
923 voice_.set_rtp_header_extensions(extensions); | 914 voice().set_rtp_header_extensions(extensions); |
924 } | 915 } |
925 void SetVideoRtpHeaderExtensions( | 916 void SetVideoRtpHeaderExtensions( |
926 const std::vector<cricket::RtpHeaderExtension>& extensions) { | 917 const std::vector<cricket::RtpHeaderExtension>& extensions) { |
927 video_.set_rtp_header_extensions(extensions); | 918 video().set_rtp_header_extensions(extensions); |
928 } | 919 } |
929 | 920 |
930 FakeVoiceMediaChannel* GetVoiceChannel(size_t index) { | 921 FakeVoiceMediaChannel* GetVoiceChannel(size_t index) { |
931 return voice_.GetChannel(index); | 922 return voice().GetChannel(index); |
932 } | 923 } |
933 FakeVideoMediaChannel* GetVideoChannel(size_t index) { | 924 FakeVideoMediaChannel* GetVideoChannel(size_t index) { |
934 return video_.GetChannel(index); | 925 return video().GetChannel(index); |
935 } | 926 } |
936 | 927 |
937 bool capture() const { return video_.capture_; } | 928 bool capture() const { return video().capture_; } |
938 bool options_changed() const { | 929 bool options_changed() const { return video().options_changed_; } |
939 return video_.options_changed_; | 930 void clear_options_changed() { video().options_changed_ = false; } |
940 } | |
941 void clear_options_changed() { | |
942 video_.options_changed_ = false; | |
943 } | |
944 void set_fail_create_channel(bool fail) { | 931 void set_fail_create_channel(bool fail) { |
945 voice_.set_fail_create_channel(fail); | 932 voice().set_fail_create_channel(fail); |
946 video_.set_fail_create_channel(fail); | 933 video().set_fail_create_channel(fail); |
947 } | 934 } |
948 }; | 935 }; |
949 | 936 |
950 // Have to come afterwards due to declaration order | 937 // Have to come afterwards due to declaration order |
951 inline FakeVoiceMediaChannel::~FakeVoiceMediaChannel() { | 938 inline FakeVoiceMediaChannel::~FakeVoiceMediaChannel() { |
952 if (engine_) { | 939 if (engine_) { |
953 engine_->UnregisterChannel(this); | 940 engine_->UnregisterChannel(this); |
954 } | 941 } |
955 } | 942 } |
956 | 943 |
(...skipping 28 matching lines...) Expand all Loading... |
985 virtual const std::vector<DataCodec>& data_codecs() { return data_codecs_; } | 972 virtual const std::vector<DataCodec>& data_codecs() { return data_codecs_; } |
986 | 973 |
987 private: | 974 private: |
988 std::vector<FakeDataMediaChannel*> channels_; | 975 std::vector<FakeDataMediaChannel*> channels_; |
989 std::vector<DataCodec> data_codecs_; | 976 std::vector<DataCodec> data_codecs_; |
990 }; | 977 }; |
991 | 978 |
992 } // namespace cricket | 979 } // namespace cricket |
993 | 980 |
994 #endif // WEBRTC_MEDIA_BASE_FAKEMEDIAENGINE_H_ | 981 #endif // WEBRTC_MEDIA_BASE_FAKEMEDIAENGINE_H_ |
OLD | NEW |