OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2057 // 12 QCELP A 8,000 1 | 2057 // 12 QCELP A 8,000 1 |
2058 // 13 CN A 8,000 1 | 2058 // 13 CN A 8,000 1 |
2059 // 14 MPA A 90,000 (see text) | 2059 // 14 MPA A 90,000 (see text) |
2060 // 15 G728 A 8,000 1 | 2060 // 15 G728 A 8,000 1 |
2061 // 16 DVI4 A 11,025 1 | 2061 // 16 DVI4 A 11,025 1 |
2062 // 17 DVI4 A 22,050 1 | 2062 // 17 DVI4 A 22,050 1 |
2063 // 18 G729 A 8,000 1 | 2063 // 18 G729 A 8,000 1 |
2064 struct StaticPayloadAudioCodec { | 2064 struct StaticPayloadAudioCodec { |
2065 const char* name; | 2065 const char* name; |
2066 int clockrate; | 2066 int clockrate; |
2067 int channels; | 2067 size_t channels; |
2068 }; | 2068 }; |
2069 static const StaticPayloadAudioCodec kStaticPayloadAudioCodecs[] = { | 2069 static const StaticPayloadAudioCodec kStaticPayloadAudioCodecs[] = { |
2070 { "PCMU", 8000, 1 }, | 2070 { "PCMU", 8000, 1 }, |
2071 { "reserved", 0, 0 }, | 2071 { "reserved", 0, 0 }, |
2072 { "reserved", 0, 0 }, | 2072 { "reserved", 0, 0 }, |
2073 { "GSM", 8000, 1 }, | 2073 { "GSM", 8000, 1 }, |
2074 { "G723", 8000, 1 }, | 2074 { "G723", 8000, 1 }, |
2075 { "DVI4", 8000, 1 }, | 2075 { "DVI4", 8000, 1 }, |
2076 { "DVI4", 16000, 1 }, | 2076 { "DVI4", 16000, 1 }, |
2077 { "LPC", 8000, 1 }, | 2077 { "LPC", 8000, 1 }, |
(...skipping 18 matching lines...) Expand all Loading... |
2096 int preference = static_cast<int>(fmts.size()); | 2096 int preference = static_cast<int>(fmts.size()); |
2097 std::vector<int>::const_iterator it = fmts.begin(); | 2097 std::vector<int>::const_iterator it = fmts.begin(); |
2098 bool add_new_codec = false; | 2098 bool add_new_codec = false; |
2099 for (; it != fmts.end(); ++it) { | 2099 for (; it != fmts.end(); ++it) { |
2100 int payload_type = *it; | 2100 int payload_type = *it; |
2101 if (!media_desc->HasCodec(payload_type) && | 2101 if (!media_desc->HasCodec(payload_type) && |
2102 payload_type >= 0 && | 2102 payload_type >= 0 && |
2103 payload_type < arraysize(kStaticPayloadAudioCodecs)) { | 2103 payload_type < arraysize(kStaticPayloadAudioCodecs)) { |
2104 std::string encoding_name = kStaticPayloadAudioCodecs[payload_type].name; | 2104 std::string encoding_name = kStaticPayloadAudioCodecs[payload_type].name; |
2105 int clock_rate = kStaticPayloadAudioCodecs[payload_type].clockrate; | 2105 int clock_rate = kStaticPayloadAudioCodecs[payload_type].clockrate; |
2106 int channels = kStaticPayloadAudioCodecs[payload_type].channels; | 2106 size_t channels = kStaticPayloadAudioCodecs[payload_type].channels; |
2107 media_desc->AddCodec(cricket::AudioCodec(payload_type, encoding_name, | 2107 media_desc->AddCodec(cricket::AudioCodec(payload_type, encoding_name, |
2108 clock_rate, 0, channels, | 2108 clock_rate, 0, channels, |
2109 preference)); | 2109 preference)); |
2110 add_new_codec = true; | 2110 add_new_codec = true; |
2111 } | 2111 } |
2112 --preference; | 2112 --preference; |
2113 } | 2113 } |
2114 if (add_new_codec) { | 2114 if (add_new_codec) { |
2115 media_desc->SortCodecs(); | 2115 media_desc->SortCodecs(); |
2116 } | 2116 } |
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2831 session_params = fields[3]; | 2831 session_params = fields[3]; |
2832 } | 2832 } |
2833 media_desc->AddCrypto(CryptoParams(tag, crypto_suite, key_params, | 2833 media_desc->AddCrypto(CryptoParams(tag, crypto_suite, key_params, |
2834 session_params)); | 2834 session_params)); |
2835 return true; | 2835 return true; |
2836 } | 2836 } |
2837 | 2837 |
2838 // Updates or creates a new codec entry in the audio description with according | 2838 // Updates or creates a new codec entry in the audio description with according |
2839 // to |name|, |clockrate|, |bitrate|, |channels| and |preference|. | 2839 // to |name|, |clockrate|, |bitrate|, |channels| and |preference|. |
2840 void UpdateCodec(int payload_type, const std::string& name, int clockrate, | 2840 void UpdateCodec(int payload_type, const std::string& name, int clockrate, |
2841 int bitrate, int channels, int preference, | 2841 int bitrate, size_t channels, int preference, |
2842 AudioContentDescription* audio_desc) { | 2842 AudioContentDescription* audio_desc) { |
2843 // Codec may already be populated with (only) optional parameters | 2843 // Codec may already be populated with (only) optional parameters |
2844 // (from an fmtp). | 2844 // (from an fmtp). |
2845 cricket::AudioCodec codec = | 2845 cricket::AudioCodec codec = |
2846 GetCodecWithPayloadType(audio_desc->codecs(), payload_type); | 2846 GetCodecWithPayloadType(audio_desc->codecs(), payload_type); |
2847 codec.name = name; | 2847 codec.name = name; |
2848 codec.clockrate = clockrate; | 2848 codec.clockrate = clockrate; |
2849 codec.bitrate = bitrate; | 2849 codec.bitrate = bitrate; |
2850 codec.channels = channels; | 2850 codec.channels = channels; |
2851 codec.preference = preference; | 2851 codec.preference = preference; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2930 JsepSessionDescription::kMaxVideoCodecWidth, | 2930 JsepSessionDescription::kMaxVideoCodecWidth, |
2931 JsepSessionDescription::kMaxVideoCodecHeight, | 2931 JsepSessionDescription::kMaxVideoCodecHeight, |
2932 JsepSessionDescription::kDefaultVideoCodecFramerate, | 2932 JsepSessionDescription::kDefaultVideoCodecFramerate, |
2933 preference, video_desc); | 2933 preference, video_desc); |
2934 } else if (media_type == cricket::MEDIA_TYPE_AUDIO) { | 2934 } else if (media_type == cricket::MEDIA_TYPE_AUDIO) { |
2935 // RFC 4566 | 2935 // RFC 4566 |
2936 // For audio streams, <encoding parameters> indicates the number | 2936 // For audio streams, <encoding parameters> indicates the number |
2937 // of audio channels. This parameter is OPTIONAL and may be | 2937 // of audio channels. This parameter is OPTIONAL and may be |
2938 // omitted if the number of channels is one, provided that no | 2938 // omitted if the number of channels is one, provided that no |
2939 // additional parameters are needed. | 2939 // additional parameters are needed. |
2940 int channels = 1; | 2940 size_t channels = 1; |
2941 if (codec_params.size() == 3) { | 2941 if (codec_params.size() == 3) { |
2942 if (!GetValueFromString(line, codec_params[2], &channels, error)) { | 2942 if (!GetValueFromString(line, codec_params[2], &channels, error)) { |
2943 return false; | 2943 return false; |
2944 } | 2944 } |
2945 } | 2945 } |
2946 int bitrate = 0; | 2946 int bitrate = 0; |
2947 // The default behavior for ISAC (bitrate == 0) in webrtcvoiceengine.cc | 2947 // The default behavior for ISAC (bitrate == 0) in webrtcvoiceengine.cc |
2948 // (specifically FindWebRtcCodec) is bandwidth-adaptive variable bitrate. | 2948 // (specifically FindWebRtcCodec) is bandwidth-adaptive variable bitrate. |
2949 // The bandwidth adaptation doesn't always work well, so this code | 2949 // The bandwidth adaptation doesn't always work well, so this code |
2950 // sets a fixed target bitrate instead. | 2950 // sets a fixed target bitrate instead. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3077 UpdateCodec<AudioContentDescription, cricket::AudioCodec>( | 3077 UpdateCodec<AudioContentDescription, cricket::AudioCodec>( |
3078 media_desc, payload_type, feedback_param); | 3078 media_desc, payload_type, feedback_param); |
3079 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { | 3079 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { |
3080 UpdateCodec<VideoContentDescription, cricket::VideoCodec>( | 3080 UpdateCodec<VideoContentDescription, cricket::VideoCodec>( |
3081 media_desc, payload_type, feedback_param); | 3081 media_desc, payload_type, feedback_param); |
3082 } | 3082 } |
3083 return true; | 3083 return true; |
3084 } | 3084 } |
3085 | 3085 |
3086 } // namespace webrtc | 3086 } // namespace webrtc |
OLD | NEW |