Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: talk/app/webrtc/webrtcsdp.cc

Issue 1316523002: Convert channel counts to size_t. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Rebase onto cleanup change Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 2042 matching lines...) Expand 10 before | Expand all | Expand 10 after
2053 // 12 QCELP A 8,000 1 2053 // 12 QCELP A 8,000 1
2054 // 13 CN A 8,000 1 2054 // 13 CN A 8,000 1
2055 // 14 MPA A 90,000 (see text) 2055 // 14 MPA A 90,000 (see text)
2056 // 15 G728 A 8,000 1 2056 // 15 G728 A 8,000 1
2057 // 16 DVI4 A 11,025 1 2057 // 16 DVI4 A 11,025 1
2058 // 17 DVI4 A 22,050 1 2058 // 17 DVI4 A 22,050 1
2059 // 18 G729 A 8,000 1 2059 // 18 G729 A 8,000 1
2060 struct StaticPayloadAudioCodec { 2060 struct StaticPayloadAudioCodec {
2061 const char* name; 2061 const char* name;
2062 int clockrate; 2062 int clockrate;
2063 int channels; 2063 size_t channels;
2064 }; 2064 };
2065 static const StaticPayloadAudioCodec kStaticPayloadAudioCodecs[] = { 2065 static const StaticPayloadAudioCodec kStaticPayloadAudioCodecs[] = {
2066 { "PCMU", 8000, 1 }, 2066 { "PCMU", 8000, 1 },
2067 { "reserved", 0, 0 }, 2067 { "reserved", 0, 0 },
2068 { "reserved", 0, 0 }, 2068 { "reserved", 0, 0 },
2069 { "GSM", 8000, 1 }, 2069 { "GSM", 8000, 1 },
2070 { "G723", 8000, 1 }, 2070 { "G723", 8000, 1 },
2071 { "DVI4", 8000, 1 }, 2071 { "DVI4", 8000, 1 },
2072 { "DVI4", 16000, 1 }, 2072 { "DVI4", 16000, 1 },
2073 { "LPC", 8000, 1 }, 2073 { "LPC", 8000, 1 },
(...skipping 18 matching lines...) Expand all
2092 int preference = static_cast<int>(fmts.size()); 2092 int preference = static_cast<int>(fmts.size());
2093 std::vector<int>::const_iterator it = fmts.begin(); 2093 std::vector<int>::const_iterator it = fmts.begin();
2094 bool add_new_codec = false; 2094 bool add_new_codec = false;
2095 for (; it != fmts.end(); ++it) { 2095 for (; it != fmts.end(); ++it) {
2096 int payload_type = *it; 2096 int payload_type = *it;
2097 if (!media_desc->HasCodec(payload_type) && 2097 if (!media_desc->HasCodec(payload_type) &&
2098 payload_type >= 0 && 2098 payload_type >= 0 &&
2099 payload_type < arraysize(kStaticPayloadAudioCodecs)) { 2099 payload_type < arraysize(kStaticPayloadAudioCodecs)) {
2100 std::string encoding_name = kStaticPayloadAudioCodecs[payload_type].name; 2100 std::string encoding_name = kStaticPayloadAudioCodecs[payload_type].name;
2101 int clock_rate = kStaticPayloadAudioCodecs[payload_type].clockrate; 2101 int clock_rate = kStaticPayloadAudioCodecs[payload_type].clockrate;
2102 int channels = kStaticPayloadAudioCodecs[payload_type].channels; 2102 size_t channels = kStaticPayloadAudioCodecs[payload_type].channels;
2103 media_desc->AddCodec(cricket::AudioCodec(payload_type, encoding_name, 2103 media_desc->AddCodec(cricket::AudioCodec(payload_type, encoding_name,
2104 clock_rate, 0, channels, 2104 clock_rate, 0, channels,
2105 preference)); 2105 preference));
2106 add_new_codec = true; 2106 add_new_codec = true;
2107 } 2107 }
2108 --preference; 2108 --preference;
2109 } 2109 }
2110 if (add_new_codec) { 2110 if (add_new_codec) {
2111 media_desc->SortCodecs(); 2111 media_desc->SortCodecs();
2112 } 2112 }
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
2827 session_params = fields[3]; 2827 session_params = fields[3];
2828 } 2828 }
2829 media_desc->AddCrypto(CryptoParams(tag, crypto_suite, key_params, 2829 media_desc->AddCrypto(CryptoParams(tag, crypto_suite, key_params,
2830 session_params)); 2830 session_params));
2831 return true; 2831 return true;
2832 } 2832 }
2833 2833
2834 // Updates or creates a new codec entry in the audio description with according 2834 // Updates or creates a new codec entry in the audio description with according
2835 // to |name|, |clockrate|, |bitrate|, |channels| and |preference|. 2835 // to |name|, |clockrate|, |bitrate|, |channels| and |preference|.
2836 void UpdateCodec(int payload_type, const std::string& name, int clockrate, 2836 void UpdateCodec(int payload_type, const std::string& name, int clockrate,
2837 int bitrate, int channels, int preference, 2837 int bitrate, size_t channels, int preference,
2838 AudioContentDescription* audio_desc) { 2838 AudioContentDescription* audio_desc) {
2839 // Codec may already be populated with (only) optional parameters 2839 // Codec may already be populated with (only) optional parameters
2840 // (from an fmtp). 2840 // (from an fmtp).
2841 cricket::AudioCodec codec = 2841 cricket::AudioCodec codec =
2842 GetCodecWithPayloadType(audio_desc->codecs(), payload_type); 2842 GetCodecWithPayloadType(audio_desc->codecs(), payload_type);
2843 codec.name = name; 2843 codec.name = name;
2844 codec.clockrate = clockrate; 2844 codec.clockrate = clockrate;
2845 codec.bitrate = bitrate; 2845 codec.bitrate = bitrate;
2846 codec.channels = channels; 2846 codec.channels = channels;
2847 codec.preference = preference; 2847 codec.preference = preference;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2926 JsepSessionDescription::kMaxVideoCodecWidth, 2926 JsepSessionDescription::kMaxVideoCodecWidth,
2927 JsepSessionDescription::kMaxVideoCodecHeight, 2927 JsepSessionDescription::kMaxVideoCodecHeight,
2928 JsepSessionDescription::kDefaultVideoCodecFramerate, 2928 JsepSessionDescription::kDefaultVideoCodecFramerate,
2929 preference, video_desc); 2929 preference, video_desc);
2930 } else if (media_type == cricket::MEDIA_TYPE_AUDIO) { 2930 } else if (media_type == cricket::MEDIA_TYPE_AUDIO) {
2931 // RFC 4566 2931 // RFC 4566
2932 // For audio streams, <encoding parameters> indicates the number 2932 // For audio streams, <encoding parameters> indicates the number
2933 // of audio channels. This parameter is OPTIONAL and may be 2933 // of audio channels. This parameter is OPTIONAL and may be
2934 // omitted if the number of channels is one, provided that no 2934 // omitted if the number of channels is one, provided that no
2935 // additional parameters are needed. 2935 // additional parameters are needed.
2936 int channels = 1; 2936 size_t channels = 1;
2937 if (codec_params.size() == 3) { 2937 if (codec_params.size() == 3) {
2938 if (!GetValueFromString(line, codec_params[2], &channels, error)) { 2938 if (!GetValueFromString(line, codec_params[2], &channels, error)) {
2939 return false; 2939 return false;
2940 } 2940 }
2941 } 2941 }
2942 int bitrate = 0; 2942 int bitrate = 0;
2943 // The default behavior for ISAC (bitrate == 0) in webrtcvoiceengine.cc 2943 // The default behavior for ISAC (bitrate == 0) in webrtcvoiceengine.cc
2944 // (specifically FindWebRtcCodec) is bandwidth-adaptive variable bitrate. 2944 // (specifically FindWebRtcCodec) is bandwidth-adaptive variable bitrate.
2945 // The bandwidth adaptation doesn't always work well, so this code 2945 // The bandwidth adaptation doesn't always work well, so this code
2946 // sets a fixed target bitrate instead. 2946 // sets a fixed target bitrate instead.
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
3073 UpdateCodec<AudioContentDescription, cricket::AudioCodec>( 3073 UpdateCodec<AudioContentDescription, cricket::AudioCodec>(
3074 media_desc, payload_type, feedback_param); 3074 media_desc, payload_type, feedback_param);
3075 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { 3075 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) {
3076 UpdateCodec<VideoContentDescription, cricket::VideoCodec>( 3076 UpdateCodec<VideoContentDescription, cricket::VideoCodec>(
3077 media_desc, payload_type, feedback_param); 3077 media_desc, payload_type, feedback_param);
3078 } 3078 }
3079 return true; 3079 return true;
3080 } 3080 }
3081 3081
3082 } // namespace webrtc 3082 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698