Chromium Code Reviews| Index: webrtc/pc/mediasession.cc |
| diff --git a/webrtc/pc/mediasession.cc b/webrtc/pc/mediasession.cc |
| index 328f67593bd434cb214abc74781b9994bbb942bc..39468d9316ba87ac5ed0f8d137c62d4ab1321859 100644 |
| --- a/webrtc/pc/mediasession.cc |
| +++ b/webrtc/pc/mediasession.cc |
| @@ -50,6 +50,11 @@ void GetSupportedCryptoSuiteNames(void (*func)(std::vector<int>*), |
| namespace cricket { |
| +namespace { |
| +std::vector<AudioCodec> MergeAudioCodecLists( |
| + const std::vector<AudioCodec>& send_codecs, |
| + const std::vector<AudioCodec>& recv_codecs); |
| +} |
| // RTP Profile names |
| // http://www.iana.org/assignments/rtp-parameters/rtp-parameters.xml |
| @@ -1252,13 +1257,15 @@ MediaSessionDescriptionFactory::MediaSessionDescriptionFactory( |
| : secure_(SEC_DISABLED), |
| add_legacy_(true), |
| transport_desc_factory_(transport_desc_factory) { |
| - channel_manager->GetSupportedAudioCodecs(&audio_sendrecv_codecs_); |
| + channel_manager->GetSupportedAudioSendCodecs(&audio_send_codecs_); |
| + channel_manager->GetSupportedAudioReceiveCodecs(&audio_recv_codecs_); |
| + channel_manager->GetSupportedAudioSendCodecs(&audio_send_codecs_); |
| channel_manager->GetSupportedAudioRtpHeaderExtensions(&audio_rtp_extensions_); |
| channel_manager->GetSupportedVideoCodecs(&video_codecs_); |
| channel_manager->GetSupportedVideoRtpHeaderExtensions(&video_rtp_extensions_); |
| channel_manager->GetSupportedDataCodecs(&data_codecs_); |
| - audio_send_codecs_ = audio_sendrecv_codecs_; |
| - audio_recv_codecs_ = audio_sendrecv_codecs_; |
| + audio_sendrecv_codecs_ = |
| + MergeAudioCodecLists(audio_send_codecs_, audio_recv_codecs_); |
| } |
| const AudioCodecs& MediaSessionDescriptionFactory::audio_codecs() const { |
|
pthatcher1
2016/05/31 18:26:48
I don't think this is called by anything except on
ossu
2016/06/01 08:34:12
Good call! Will do that.
|
| @@ -1284,32 +1291,8 @@ void MediaSessionDescriptionFactory::set_audio_codecs( |
| const AudioCodecs& send_codecs, const AudioCodecs& recv_codecs) { |
| audio_send_codecs_ = send_codecs; |
| audio_recv_codecs_ = recv_codecs; |
| - audio_sendrecv_codecs_.clear(); |
| - |
| - // Intersect the two lists of codecs, preserving the order of the send codecs. |
| - // If there's any difference in priorities, chances are encoding is more |
| - // expensive than decoding, and high-priority send codecs are likely handled |
| - // better (e.g. through hardware encoder support) than low-priority ones. |
| - // TODO(ossu): This is O(n^2). However, each list should generally be small |
| - // enough for this to not be a problem. They are also nicely local in memory |
| - // like this. |
| - for (const auto& sc : audio_send_codecs_) { |
| - for (const auto& rc : audio_recv_codecs_) { |
| - const size_t send_channels = (sc.channels == 0) ? 1 : sc.channels; |
| - const size_t recv_channels = (rc.channels == 0) ? 1 : rc.channels; |
| - if (sc.clockrate == rc.clockrate && |
| - sc.bitrate == rc.bitrate && |
| - send_channels == recv_channels && |
| - (_stricmp(sc.name.c_str(), rc.name.c_str()) == 0) && |
| - sc.params == rc.params && |
| - sc.feedback_params == rc.feedback_params) { |
| - AudioCodec out_codec = sc; |
| - out_codec.channels = send_channels; |
| - audio_sendrecv_codecs_.push_back(out_codec); |
| - break; |
| - } |
| - } |
| - } |
| + audio_sendrecv_codecs_ = |
| + MergeAudioCodecLists(audio_send_codecs_, audio_recv_codecs_); |
| } |
| SessionDescription* MediaSessionDescriptionFactory::CreateOffer( |
| @@ -2115,4 +2098,36 @@ const DataContentDescription* GetFirstDataContentDescription( |
| GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); |
| } |
| +namespace { |
| +std::vector<AudioCodec> MergeAudioCodecLists( |
|
pthatcher1
2016/05/31 18:26:48
Can you call this MergeSendRecvCodecs?
ossu
2016/06/01 08:34:12
Sure thing!
|
| + const std::vector<AudioCodec>& send_codecs, |
| + const std::vector<AudioCodec>& recv_codecs) { |
| + std::vector<AudioCodec> merged; |
| + // Intersect the two lists of codecs, preserving the order of the send codecs. |
| + // If there's any difference in priorities, chances are encoding is more |
| + // expensive than decoding, and high-priority send codecs are likely handled |
| + // better (e.g. through hardware encoder support) than low-priority ones. |
| + // TODO(ossu): This is O(n^2). However, each list should generally be small |
| + // enough for this to not be a problem. They are also nicely local in memory |
| + // like this. |
| + for (const auto& sc : send_codecs) { |
| + for (const auto& rc : recv_codecs) { |
| + const size_t send_channels = (sc.channels == 0) ? 1 : sc.channels; |
| + const size_t recv_channels = (rc.channels == 0) ? 1 : rc.channels; |
| + if (sc.clockrate == rc.clockrate && sc.bitrate == rc.bitrate && |
|
ossu
2016/05/26 14:18:50
This got clang-formatted. I'll put it back to one
|
| + send_channels == recv_channels && |
| + (_stricmp(sc.name.c_str(), rc.name.c_str()) == 0) && |
| + sc.params == rc.params && sc.feedback_params == rc.feedback_params) { |
| + AudioCodec out_codec = sc; |
| + out_codec.channels = send_channels; |
| + merged.push_back(out_codec); |
| + break; |
| + } |
| + } |
| + } |
| + |
| + return merged; |
| +} |
| +} |
| + |
| } // namespace cricket |