OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 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 2717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2728 // The following tests verify that session options are created correctly. | 2728 // The following tests verify that session options are created correctly. |
2729 // TODO(deadbeef): Convert these tests to be more end-to-end. Instead of | 2729 // TODO(deadbeef): Convert these tests to be more end-to-end. Instead of |
2730 // "verify options are converted correctly", should be "pass options into | 2730 // "verify options are converted correctly", should be "pass options into |
2731 // CreateOffer and verify the correct offer is produced." | 2731 // CreateOffer and verify the correct offer is produced." |
2732 | 2732 |
2733 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidAudioOption) { | 2733 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidAudioOption) { |
2734 RTCOfferAnswerOptions rtc_options; | 2734 RTCOfferAnswerOptions rtc_options; |
2735 rtc_options.offer_to_receive_audio = RTCOfferAnswerOptions::kUndefined - 1; | 2735 rtc_options.offer_to_receive_audio = RTCOfferAnswerOptions::kUndefined - 1; |
2736 | 2736 |
2737 cricket::MediaSessionOptions options; | 2737 cricket::MediaSessionOptions options; |
2738 EXPECT_FALSE(ExtractMediaSessionOptions(rtc_options, true, &options)); | 2738 EXPECT_FALSE(ExtractMediaSessionOptions(rtc_options, true, false, &options)); |
2739 | 2739 |
2740 rtc_options.offer_to_receive_audio = | 2740 rtc_options.offer_to_receive_audio = |
2741 RTCOfferAnswerOptions::kMaxOfferToReceiveMedia + 1; | 2741 RTCOfferAnswerOptions::kMaxOfferToReceiveMedia + 1; |
2742 EXPECT_FALSE(ExtractMediaSessionOptions(rtc_options, true, &options)); | 2742 EXPECT_FALSE(ExtractMediaSessionOptions(rtc_options, true, false, &options)); |
2743 } | 2743 } |
2744 | 2744 |
2745 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidVideoOption) { | 2745 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidVideoOption) { |
2746 RTCOfferAnswerOptions rtc_options; | 2746 RTCOfferAnswerOptions rtc_options; |
2747 rtc_options.offer_to_receive_video = RTCOfferAnswerOptions::kUndefined - 1; | 2747 rtc_options.offer_to_receive_video = RTCOfferAnswerOptions::kUndefined - 1; |
2748 | 2748 |
2749 cricket::MediaSessionOptions options; | 2749 cricket::MediaSessionOptions options; |
2750 EXPECT_FALSE(ExtractMediaSessionOptions(rtc_options, true, &options)); | 2750 EXPECT_FALSE(ExtractMediaSessionOptions(rtc_options, true, false, &options)); |
2751 | 2751 |
2752 rtc_options.offer_to_receive_video = | 2752 rtc_options.offer_to_receive_video = |
2753 RTCOfferAnswerOptions::kMaxOfferToReceiveMedia + 1; | 2753 RTCOfferAnswerOptions::kMaxOfferToReceiveMedia + 1; |
2754 EXPECT_FALSE(ExtractMediaSessionOptions(rtc_options, true, &options)); | 2754 EXPECT_FALSE(ExtractMediaSessionOptions(rtc_options, true, false, &options)); |
2755 } | 2755 } |
2756 | 2756 |
2757 // Test that a MediaSessionOptions is created for an offer if | 2757 // Test that a MediaSessionOptions is created for an offer if |
2758 // OfferToReceiveAudio and OfferToReceiveVideo options are set. | 2758 // OfferToReceiveAudio and OfferToReceiveVideo options are set. |
2759 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithAudioVideo) { | 2759 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithAudioVideo) { |
2760 RTCOfferAnswerOptions rtc_options; | 2760 RTCOfferAnswerOptions rtc_options; |
2761 rtc_options.offer_to_receive_audio = 1; | 2761 rtc_options.offer_to_receive_audio = 1; |
2762 rtc_options.offer_to_receive_video = 1; | 2762 rtc_options.offer_to_receive_video = 1; |
2763 | 2763 |
2764 cricket::MediaSessionOptions options; | 2764 cricket::MediaSessionOptions options; |
2765 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, true, &options)); | 2765 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, true, true, &options)); |
2766 EXPECT_TRUE(options.has_audio()); | 2766 EXPECT_TRUE(options.has_audio()); |
2767 EXPECT_TRUE(options.has_video()); | 2767 EXPECT_TRUE(options.has_video()); |
2768 EXPECT_TRUE(options.bundle_enabled); | 2768 EXPECT_TRUE(options.bundle_enabled); |
2769 } | 2769 } |
2770 | 2770 |
2771 // Test that the ice_renomination option is set properly. | |
2772 TEST(CreateSessionOptionsTest, GetOptionsWithIceRenomination) { | |
Taylor Brandstetter
2016/08/17 22:02:00
This test can be removed if setting the ice_renomi
honghaiz3
2016/08/19 18:42:01
True but only if we removed it from the ExtractMed
| |
2773 RTCOfferAnswerOptions rtc_options; | |
2774 cricket::MediaSessionOptions options; | |
2775 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, true, false, &options)); | |
2776 for (auto& kv : options.transport_options) { | |
2777 EXPECT_FALSE(kv.second.ice_renomination); | |
2778 } | |
2779 | |
2780 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, true, true, &options)); | |
2781 EXPECT_FALSE(options.transport_options.empty()); | |
2782 for (auto& kv : options.transport_options) { | |
2783 EXPECT_TRUE(kv.second.ice_renomination); | |
2784 } | |
2785 } | |
2786 | |
2771 // Test that a correct MediaSessionOptions is created for an offer if | 2787 // Test that a correct MediaSessionOptions is created for an offer if |
2772 // OfferToReceiveAudio is set. | 2788 // OfferToReceiveAudio is set. |
2773 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithAudio) { | 2789 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithAudio) { |
2774 RTCOfferAnswerOptions rtc_options; | 2790 RTCOfferAnswerOptions rtc_options; |
2775 rtc_options.offer_to_receive_audio = 1; | 2791 rtc_options.offer_to_receive_audio = 1; |
2776 | 2792 |
2777 cricket::MediaSessionOptions options; | 2793 cricket::MediaSessionOptions options; |
2778 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, true, &options)); | 2794 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, true, false, &options)); |
2779 EXPECT_TRUE(options.has_audio()); | 2795 EXPECT_TRUE(options.has_audio()); |
2780 EXPECT_FALSE(options.has_video()); | 2796 EXPECT_FALSE(options.has_video()); |
2781 EXPECT_TRUE(options.bundle_enabled); | 2797 EXPECT_TRUE(options.bundle_enabled); |
2782 } | 2798 } |
2783 | 2799 |
2784 // Test that a correct MediaSessionOptions is created for an offer if | 2800 // Test that a correct MediaSessionOptions is created for an offer if |
2785 // the default OfferOptions are used. | 2801 // the default OfferOptions are used. |
2786 TEST(CreateSessionOptionsTest, GetDefaultMediaSessionOptionsForOffer) { | 2802 TEST(CreateSessionOptionsTest, GetDefaultMediaSessionOptionsForOffer) { |
2787 RTCOfferAnswerOptions rtc_options; | 2803 RTCOfferAnswerOptions rtc_options; |
2788 | 2804 |
2789 cricket::MediaSessionOptions options; | 2805 cricket::MediaSessionOptions options; |
2790 options.transport_options["audio"] = cricket::TransportOptions(); | 2806 options.transport_options["audio"] = cricket::TransportOptions(); |
2791 options.transport_options["video"] = cricket::TransportOptions(); | 2807 options.transport_options["video"] = cricket::TransportOptions(); |
2792 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, true, &options)); | 2808 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, true, false, &options)); |
2793 EXPECT_TRUE(options.has_audio()); | 2809 EXPECT_TRUE(options.has_audio()); |
2794 EXPECT_FALSE(options.has_video()); | 2810 EXPECT_FALSE(options.has_video()); |
2795 EXPECT_TRUE(options.bundle_enabled); | 2811 EXPECT_TRUE(options.bundle_enabled); |
2796 EXPECT_TRUE(options.vad_enabled); | 2812 EXPECT_TRUE(options.vad_enabled); |
2797 EXPECT_FALSE(options.transport_options["audio"].ice_restart); | 2813 EXPECT_FALSE(options.transport_options["audio"].ice_restart); |
2798 EXPECT_FALSE(options.transport_options["video"].ice_restart); | 2814 EXPECT_FALSE(options.transport_options["video"].ice_restart); |
2799 } | 2815 } |
2800 | 2816 |
2801 // Test that a correct MediaSessionOptions is created for an offer if | 2817 // Test that a correct MediaSessionOptions is created for an offer if |
2802 // OfferToReceiveVideo is set. | 2818 // OfferToReceiveVideo is set. |
2803 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithVideo) { | 2819 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithVideo) { |
2804 RTCOfferAnswerOptions rtc_options; | 2820 RTCOfferAnswerOptions rtc_options; |
2805 rtc_options.offer_to_receive_audio = 0; | 2821 rtc_options.offer_to_receive_audio = 0; |
2806 rtc_options.offer_to_receive_video = 1; | 2822 rtc_options.offer_to_receive_video = 1; |
2807 | 2823 |
2808 cricket::MediaSessionOptions options; | 2824 cricket::MediaSessionOptions options; |
2809 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, true, &options)); | 2825 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, true, false, &options)); |
2810 EXPECT_FALSE(options.has_audio()); | 2826 EXPECT_FALSE(options.has_audio()); |
2811 EXPECT_TRUE(options.has_video()); | 2827 EXPECT_TRUE(options.has_video()); |
2812 EXPECT_TRUE(options.bundle_enabled); | 2828 EXPECT_TRUE(options.bundle_enabled); |
2813 } | 2829 } |
2814 | 2830 |
2815 // Test that a correct MediaSessionOptions is created for an offer if | 2831 // Test that a correct MediaSessionOptions is created for an offer if |
2816 // UseRtpMux is set to false. | 2832 // UseRtpMux is set to false. |
2817 TEST(CreateSessionOptionsTest, | 2833 TEST(CreateSessionOptionsTest, |
2818 GetMediaSessionOptionsForOfferWithBundleDisabled) { | 2834 GetMediaSessionOptionsForOfferWithBundleDisabled) { |
2819 RTCOfferAnswerOptions rtc_options; | 2835 RTCOfferAnswerOptions rtc_options; |
2820 rtc_options.offer_to_receive_audio = 1; | 2836 rtc_options.offer_to_receive_audio = 1; |
2821 rtc_options.offer_to_receive_video = 1; | 2837 rtc_options.offer_to_receive_video = 1; |
2822 rtc_options.use_rtp_mux = false; | 2838 rtc_options.use_rtp_mux = false; |
2823 | 2839 |
2824 cricket::MediaSessionOptions options; | 2840 cricket::MediaSessionOptions options; |
2825 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, true, &options)); | 2841 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, true, false, &options)); |
2826 EXPECT_TRUE(options.has_audio()); | 2842 EXPECT_TRUE(options.has_audio()); |
2827 EXPECT_TRUE(options.has_video()); | 2843 EXPECT_TRUE(options.has_video()); |
2828 EXPECT_FALSE(options.bundle_enabled); | 2844 EXPECT_FALSE(options.bundle_enabled); |
2829 } | 2845 } |
2830 | 2846 |
2831 // Test that a correct MediaSessionOptions is created to restart ice if | 2847 // Test that a correct MediaSessionOptions is created to restart ice if |
2832 // IceRestart is set. It also tests that subsequent MediaSessionOptions don't | 2848 // IceRestart is set. It also tests that subsequent MediaSessionOptions don't |
2833 // have |audio_transport_options.ice_restart| etc. set. | 2849 // have |audio_transport_options.ice_restart| etc. set. |
2834 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithIceRestart) { | 2850 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithIceRestart) { |
2835 RTCOfferAnswerOptions rtc_options; | 2851 RTCOfferAnswerOptions rtc_options; |
2836 rtc_options.ice_restart = true; | 2852 rtc_options.ice_restart = true; |
2837 | 2853 |
2838 cricket::MediaSessionOptions options; | 2854 cricket::MediaSessionOptions options; |
2839 options.transport_options["audio"] = cricket::TransportOptions(); | 2855 options.transport_options["audio"] = cricket::TransportOptions(); |
2840 options.transport_options["video"] = cricket::TransportOptions(); | 2856 options.transport_options["video"] = cricket::TransportOptions(); |
2841 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, true, &options)); | 2857 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, true, false, &options)); |
2842 EXPECT_TRUE(options.transport_options["audio"].ice_restart); | 2858 EXPECT_TRUE(options.transport_options["audio"].ice_restart); |
2843 EXPECT_TRUE(options.transport_options["video"].ice_restart); | 2859 EXPECT_TRUE(options.transport_options["video"].ice_restart); |
2844 | 2860 |
2845 rtc_options = RTCOfferAnswerOptions(); | 2861 rtc_options = RTCOfferAnswerOptions(); |
2846 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, true, &options)); | 2862 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, true, false, &options)); |
2847 EXPECT_FALSE(options.transport_options["audio"].ice_restart); | 2863 EXPECT_FALSE(options.transport_options["audio"].ice_restart); |
2848 EXPECT_FALSE(options.transport_options["video"].ice_restart); | 2864 EXPECT_FALSE(options.transport_options["video"].ice_restart); |
2849 } | 2865 } |
2850 | 2866 |
2851 // Test that the MediaConstraints in an answer don't affect if audio and video | 2867 // Test that the MediaConstraints in an answer don't affect if audio and video |
2852 // is offered in an offer but that if kOfferToReceiveAudio or | 2868 // is offered in an offer but that if kOfferToReceiveAudio or |
2853 // kOfferToReceiveVideo constraints are true in an offer, the media type will be | 2869 // kOfferToReceiveVideo constraints are true in an offer, the media type will be |
2854 // included in subsequent answers. | 2870 // included in subsequent answers. |
2855 TEST(CreateSessionOptionsTest, MediaConstraintsInAnswer) { | 2871 TEST(CreateSessionOptionsTest, MediaConstraintsInAnswer) { |
2856 FakeConstraints answer_c; | 2872 FakeConstraints answer_c; |
2857 answer_c.SetMandatoryReceiveAudio(true); | 2873 answer_c.SetMandatoryReceiveAudio(true); |
2858 answer_c.SetMandatoryReceiveVideo(true); | 2874 answer_c.SetMandatoryReceiveVideo(true); |
2859 | 2875 |
2860 cricket::MediaSessionOptions answer_options; | 2876 cricket::MediaSessionOptions answer_options; |
2861 EXPECT_TRUE(ParseConstraintsForAnswer(&answer_c, &answer_options)); | 2877 EXPECT_TRUE(ParseConstraintsForAnswer(&answer_c, &answer_options)); |
2862 EXPECT_TRUE(answer_options.has_audio()); | 2878 EXPECT_TRUE(answer_options.has_audio()); |
2863 EXPECT_TRUE(answer_options.has_video()); | 2879 EXPECT_TRUE(answer_options.has_video()); |
2864 | 2880 |
2865 RTCOfferAnswerOptions rtc_offer_options; | 2881 RTCOfferAnswerOptions rtc_offer_options; |
2866 | 2882 |
2867 cricket::MediaSessionOptions offer_options; | 2883 cricket::MediaSessionOptions offer_options; |
2868 EXPECT_TRUE( | 2884 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_offer_options, false, false, |
2869 ExtractMediaSessionOptions(rtc_offer_options, false, &offer_options)); | 2885 &offer_options)); |
2870 EXPECT_TRUE(offer_options.has_audio()); | 2886 EXPECT_TRUE(offer_options.has_audio()); |
2871 EXPECT_TRUE(offer_options.has_video()); | 2887 EXPECT_TRUE(offer_options.has_video()); |
2872 | 2888 |
2873 RTCOfferAnswerOptions updated_rtc_offer_options; | 2889 RTCOfferAnswerOptions updated_rtc_offer_options; |
2874 updated_rtc_offer_options.offer_to_receive_audio = 1; | 2890 updated_rtc_offer_options.offer_to_receive_audio = 1; |
2875 updated_rtc_offer_options.offer_to_receive_video = 1; | 2891 updated_rtc_offer_options.offer_to_receive_video = 1; |
2876 | 2892 |
2877 cricket::MediaSessionOptions updated_offer_options; | 2893 cricket::MediaSessionOptions updated_offer_options; |
2878 EXPECT_TRUE(ExtractMediaSessionOptions(updated_rtc_offer_options, false, | 2894 EXPECT_TRUE(ExtractMediaSessionOptions(updated_rtc_offer_options, false, |
2879 &updated_offer_options)); | 2895 false, &updated_offer_options)); |
2880 EXPECT_TRUE(updated_offer_options.has_audio()); | 2896 EXPECT_TRUE(updated_offer_options.has_audio()); |
2881 EXPECT_TRUE(updated_offer_options.has_video()); | 2897 EXPECT_TRUE(updated_offer_options.has_video()); |
2882 | 2898 |
2883 // Since an offer has been created with both audio and video, subsequent | 2899 // Since an offer has been created with both audio and video, subsequent |
2884 // offers and answers should contain both audio and video. | 2900 // offers and answers should contain both audio and video. |
2885 // Answers will only contain the media types that exist in the offer | 2901 // Answers will only contain the media types that exist in the offer |
2886 // regardless of the value of |updated_answer_options.has_audio| and | 2902 // regardless of the value of |updated_answer_options.has_audio| and |
2887 // |updated_answer_options.has_video|. | 2903 // |updated_answer_options.has_video|. |
2888 FakeConstraints updated_answer_c; | 2904 FakeConstraints updated_answer_c; |
2889 answer_c.SetMandatoryReceiveAudio(false); | 2905 answer_c.SetMandatoryReceiveAudio(false); |
2890 answer_c.SetMandatoryReceiveVideo(false); | 2906 answer_c.SetMandatoryReceiveVideo(false); |
2891 | 2907 |
2892 cricket::MediaSessionOptions updated_answer_options; | 2908 cricket::MediaSessionOptions updated_answer_options; |
2893 EXPECT_TRUE( | 2909 EXPECT_TRUE( |
2894 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); | 2910 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); |
2895 EXPECT_TRUE(updated_answer_options.has_audio()); | 2911 EXPECT_TRUE(updated_answer_options.has_audio()); |
2896 EXPECT_TRUE(updated_answer_options.has_video()); | 2912 EXPECT_TRUE(updated_answer_options.has_video()); |
2897 } | 2913 } |
OLD | NEW |