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 2033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2044 // 12 QCELP A 8,000 1 | 2044 // 12 QCELP A 8,000 1 |
2045 // 13 CN A 8,000 1 | 2045 // 13 CN A 8,000 1 |
2046 // 14 MPA A 90,000 (see text) | 2046 // 14 MPA A 90,000 (see text) |
2047 // 15 G728 A 8,000 1 | 2047 // 15 G728 A 8,000 1 |
2048 // 16 DVI4 A 11,025 1 | 2048 // 16 DVI4 A 11,025 1 |
2049 // 17 DVI4 A 22,050 1 | 2049 // 17 DVI4 A 22,050 1 |
2050 // 18 G729 A 8,000 1 | 2050 // 18 G729 A 8,000 1 |
2051 struct StaticPayloadAudioCodec { | 2051 struct StaticPayloadAudioCodec { |
2052 const char* name; | 2052 const char* name; |
2053 int clockrate; | 2053 int clockrate; |
2054 int channels; | 2054 size_t channels; |
2055 }; | 2055 }; |
2056 static const StaticPayloadAudioCodec kStaticPayloadAudioCodecs[] = { | 2056 static const StaticPayloadAudioCodec kStaticPayloadAudioCodecs[] = { |
2057 { "PCMU", 8000, 1 }, | 2057 { "PCMU", 8000, 1 }, |
2058 { "reserved", 0, 0 }, | 2058 { "reserved", 0, 0 }, |
2059 { "reserved", 0, 0 }, | 2059 { "reserved", 0, 0 }, |
2060 { "GSM", 8000, 1 }, | 2060 { "GSM", 8000, 1 }, |
2061 { "G723", 8000, 1 }, | 2061 { "G723", 8000, 1 }, |
2062 { "DVI4", 8000, 1 }, | 2062 { "DVI4", 8000, 1 }, |
2063 { "DVI4", 16000, 1 }, | 2063 { "DVI4", 16000, 1 }, |
2064 { "LPC", 8000, 1 }, | 2064 { "LPC", 8000, 1 }, |
(...skipping 18 matching lines...) Expand all Loading... |
2083 int preference = static_cast<int>(fmts.size()); | 2083 int preference = static_cast<int>(fmts.size()); |
2084 std::vector<int>::const_iterator it = fmts.begin(); | 2084 std::vector<int>::const_iterator it = fmts.begin(); |
2085 bool add_new_codec = false; | 2085 bool add_new_codec = false; |
2086 for (; it != fmts.end(); ++it) { | 2086 for (; it != fmts.end(); ++it) { |
2087 int payload_type = *it; | 2087 int payload_type = *it; |
2088 if (!media_desc->HasCodec(payload_type) && | 2088 if (!media_desc->HasCodec(payload_type) && |
2089 payload_type >= 0 && | 2089 payload_type >= 0 && |
2090 payload_type < ARRAY_SIZE(kStaticPayloadAudioCodecs)) { | 2090 payload_type < ARRAY_SIZE(kStaticPayloadAudioCodecs)) { |
2091 std::string encoding_name = kStaticPayloadAudioCodecs[payload_type].name; | 2091 std::string encoding_name = kStaticPayloadAudioCodecs[payload_type].name; |
2092 int clock_rate = kStaticPayloadAudioCodecs[payload_type].clockrate; | 2092 int clock_rate = kStaticPayloadAudioCodecs[payload_type].clockrate; |
2093 int channels = kStaticPayloadAudioCodecs[payload_type].channels; | 2093 size_t channels = kStaticPayloadAudioCodecs[payload_type].channels; |
2094 media_desc->AddCodec(cricket::AudioCodec(payload_type, encoding_name, | 2094 media_desc->AddCodec(cricket::AudioCodec(payload_type, encoding_name, |
2095 clock_rate, 0, channels, | 2095 clock_rate, 0, channels, |
2096 preference)); | 2096 preference)); |
2097 add_new_codec = true; | 2097 add_new_codec = true; |
2098 } | 2098 } |
2099 --preference; | 2099 --preference; |
2100 } | 2100 } |
2101 if (add_new_codec) { | 2101 if (add_new_codec) { |
2102 media_desc->SortCodecs(); | 2102 media_desc->SortCodecs(); |
2103 } | 2103 } |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2825 session_params = fields[3]; | 2825 session_params = fields[3]; |
2826 } | 2826 } |
2827 media_desc->AddCrypto(CryptoParams(tag, crypto_suite, key_params, | 2827 media_desc->AddCrypto(CryptoParams(tag, crypto_suite, key_params, |
2828 session_params)); | 2828 session_params)); |
2829 return true; | 2829 return true; |
2830 } | 2830 } |
2831 | 2831 |
2832 // Updates or creates a new codec entry in the audio description with according | 2832 // Updates or creates a new codec entry in the audio description with according |
2833 // to |name|, |clockrate|, |bitrate|, |channels| and |preference|. | 2833 // to |name|, |clockrate|, |bitrate|, |channels| and |preference|. |
2834 void UpdateCodec(int payload_type, const std::string& name, int clockrate, | 2834 void UpdateCodec(int payload_type, const std::string& name, int clockrate, |
2835 int bitrate, int channels, int preference, | 2835 int bitrate, size_t channels, int preference, |
2836 AudioContentDescription* audio_desc) { | 2836 AudioContentDescription* audio_desc) { |
2837 // Codec may already be populated with (only) optional parameters | 2837 // Codec may already be populated with (only) optional parameters |
2838 // (from an fmtp). | 2838 // (from an fmtp). |
2839 cricket::AudioCodec codec = | 2839 cricket::AudioCodec codec = |
2840 GetCodecWithPayloadType(audio_desc->codecs(), payload_type); | 2840 GetCodecWithPayloadType(audio_desc->codecs(), payload_type); |
2841 codec.name = name; | 2841 codec.name = name; |
2842 codec.clockrate = clockrate; | 2842 codec.clockrate = clockrate; |
2843 codec.bitrate = bitrate; | 2843 codec.bitrate = bitrate; |
2844 codec.channels = channels; | 2844 codec.channels = channels; |
2845 codec.preference = preference; | 2845 codec.preference = preference; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2924 JsepSessionDescription::kMaxVideoCodecWidth, | 2924 JsepSessionDescription::kMaxVideoCodecWidth, |
2925 JsepSessionDescription::kMaxVideoCodecHeight, | 2925 JsepSessionDescription::kMaxVideoCodecHeight, |
2926 JsepSessionDescription::kDefaultVideoCodecFramerate, | 2926 JsepSessionDescription::kDefaultVideoCodecFramerate, |
2927 preference, video_desc); | 2927 preference, video_desc); |
2928 } else if (media_type == cricket::MEDIA_TYPE_AUDIO) { | 2928 } else if (media_type == cricket::MEDIA_TYPE_AUDIO) { |
2929 // RFC 4566 | 2929 // RFC 4566 |
2930 // For audio streams, <encoding parameters> indicates the number | 2930 // For audio streams, <encoding parameters> indicates the number |
2931 // of audio channels. This parameter is OPTIONAL and may be | 2931 // of audio channels. This parameter is OPTIONAL and may be |
2932 // omitted if the number of channels is one, provided that no | 2932 // omitted if the number of channels is one, provided that no |
2933 // additional parameters are needed. | 2933 // additional parameters are needed. |
2934 int channels = 1; | 2934 size_t channels = 1; |
2935 if (codec_params.size() == 3) { | 2935 if (codec_params.size() == 3) { |
2936 if (!GetValueFromString(line, codec_params[2], &channels, error)) { | 2936 if (!GetValueFromString(line, codec_params[2], &channels, error)) { |
2937 return false; | 2937 return false; |
2938 } | 2938 } |
2939 } | 2939 } |
2940 int bitrate = 0; | 2940 int bitrate = 0; |
2941 // The default behavior for ISAC (bitrate == 0) in webrtcvoiceengine.cc | 2941 // The default behavior for ISAC (bitrate == 0) in webrtcvoiceengine.cc |
2942 // (specifically FindWebRtcCodec) is bandwidth-adaptive variable bitrate. | 2942 // (specifically FindWebRtcCodec) is bandwidth-adaptive variable bitrate. |
2943 // The bandwidth adaptation doesn't always work well, so this code | 2943 // The bandwidth adaptation doesn't always work well, so this code |
2944 // sets a fixed target bitrate instead. | 2944 // sets a fixed target bitrate instead. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3071 UpdateCodec<AudioContentDescription, cricket::AudioCodec>( | 3071 UpdateCodec<AudioContentDescription, cricket::AudioCodec>( |
3072 media_desc, payload_type, feedback_param); | 3072 media_desc, payload_type, feedback_param); |
3073 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { | 3073 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { |
3074 UpdateCodec<VideoContentDescription, cricket::VideoCodec>( | 3074 UpdateCodec<VideoContentDescription, cricket::VideoCodec>( |
3075 media_desc, payload_type, feedback_param); | 3075 media_desc, payload_type, feedback_param); |
3076 } | 3076 } |
3077 return true; | 3077 return true; |
3078 } | 3078 } |
3079 | 3079 |
3080 } // namespace webrtc | 3080 } // namespace webrtc |
OLD | NEW |