Chromium Code Reviews| Index: talk/session/media/mediasession.cc |
| diff --git a/talk/session/media/mediasession.cc b/talk/session/media/mediasession.cc |
| index 2cd2d46d9ca5adbf28f61a83b7b501354a99be75..7413026092f1d6f8c8742e407d48376ac5a5ea01 100644 |
| --- a/talk/session/media/mediasession.cc |
| +++ b/talk/session/media/mediasession.cc |
| @@ -1036,12 +1036,15 @@ static bool CreateMediaContentAnswer( |
| answer->set_direction(MD_RECVONLY); |
| break; |
| case MD_RECVONLY: |
| - answer->set_direction(MD_SENDONLY); |
| + answer->set_direction(answer->streams().empty() ? MD_INACTIVE |
| + : MD_SENDONLY); |
| break; |
| case MD_SENDRECV: |
| - answer->set_direction(MD_SENDRECV); |
| + answer->set_direction(answer->streams().empty() ? MD_RECVONLY |
| + : MD_SENDRECV); |
|
pthatcher
2015/11/23 18:00:52
It looks like this breaks data channels. If we're
|
| break; |
| default: |
| + RTC_DCHECK(false && "MediaContentDescription has unexpected direction."); |
| break; |
| } |
| @@ -1529,8 +1532,18 @@ bool MediaSessionDescriptionFactory::AddAudioContentForOffer( |
| bool secure_transport = (transport_desc_factory_->secure() != SEC_DISABLED); |
| SetMediaProtocol(secure_transport, audio.get()); |
| - if (!options.recv_audio) { |
| - audio->set_direction(MD_SENDONLY); |
| + if (!audio->streams().empty()) { |
| + if (options.recv_audio) { |
| + audio->set_direction(MD_SENDRECV); |
| + } else { |
| + audio->set_direction(MD_SENDONLY); |
| + } |
| + } else { |
| + if (options.recv_audio) { |
| + audio->set_direction(MD_RECVONLY); |
| + } else { |
| + audio->set_direction(MD_INACTIVE); |
| + } |
| } |
| desc->AddContent(CN_AUDIO, NS_JINGLE_RTP, audio.release()); |
| @@ -1574,8 +1587,18 @@ bool MediaSessionDescriptionFactory::AddVideoContentForOffer( |
| bool secure_transport = (transport_desc_factory_->secure() != SEC_DISABLED); |
| SetMediaProtocol(secure_transport, video.get()); |
| - if (!options.recv_video) { |
| - video->set_direction(MD_SENDONLY); |
| + if (!video->streams().empty()) { |
| + if (options.recv_video) { |
| + video->set_direction(MD_SENDRECV); |
| + } else { |
| + video->set_direction(MD_SENDONLY); |
| + } |
| + } else { |
| + if (options.recv_video) { |
| + video->set_direction(MD_RECVONLY); |
| + } else { |
| + video->set_direction(MD_INACTIVE); |
| + } |
| } |
| desc->AddContent(CN_VIDEO, NS_JINGLE_RTP, video.release()); |