Chromium Code Reviews| Index: talk/session/media/channel.cc |
| diff --git a/talk/session/media/channel.cc b/talk/session/media/channel.cc |
| index fc998c2531e0d564447a359da9363d117ffe6d5c..4ff90569f17925e4ae89b9d5ae938421281a98a3 100644 |
| --- a/talk/session/media/channel.cc |
| +++ b/talk/session/media/channel.cc |
| @@ -30,6 +30,7 @@ |
| #include "talk/media/base/constants.h" |
| #include "talk/media/base/rtputils.h" |
| #include "webrtc/p2p/base/transportchannel.h" |
| +#include "talk/app/webrtc/mediacontroller.h" |
| #include "talk/session/media/channelmanager.h" |
| #include "webrtc/base/bind.h" |
| #include "webrtc/base/buffer.h" |
| @@ -37,6 +38,7 @@ |
| #include "webrtc/base/common.h" |
| #include "webrtc/base/dscp.h" |
| #include "webrtc/base/logging.h" |
| +#include "webrtc/common_types.h" |
| namespace cricket { |
| @@ -171,12 +173,14 @@ void RtpSendParametersFromMediaDescription( |
| BaseChannel::BaseChannel(rtc::Thread* thread, |
| MediaChannel* media_channel, |
| + webrtc::MediaControllerInterface* media_controller, |
| TransportController* transport_controller, |
| const std::string& content_name, |
| bool rtcp) |
| : worker_thread_(thread), |
| transport_controller_(transport_controller), |
| media_channel_(media_channel), |
| + media_controller_(media_controller), |
| content_name_(content_name), |
| rtcp_transport_enabled_(rtcp), |
| transport_channel_(nullptr), |
| @@ -343,6 +347,7 @@ void BaseChannel::ConnectToTransportChannel(TransportChannel* tc) { |
| tc->SignalWritableState.connect(this, &BaseChannel::OnWritableState); |
| tc->SignalReadPacket.connect(this, &BaseChannel::OnChannelRead); |
| + tc->SignalSentPacket.connect(this, &BaseChannel::OnPacketSent); |
| tc->SignalReadyToSend.connect(this, &BaseChannel::OnReadyToSend); |
| } |
| @@ -431,13 +436,13 @@ bool BaseChannel::IsReadyToSend() const { |
| } |
| bool BaseChannel::SendPacket(rtc::Buffer* packet, |
| - rtc::DiffServCodePoint dscp) { |
| - return SendPacket(false, packet, dscp); |
| + const rtc::PacketOptions& options) { |
| + return SendPacket(false, packet, options); |
| } |
| bool BaseChannel::SendRtcp(rtc::Buffer* packet, |
| - rtc::DiffServCodePoint dscp) { |
| - return SendPacket(true, packet, dscp); |
| + const rtc::PacketOptions& options) { |
| + return SendPacket(true, packet, options); |
| } |
| int BaseChannel::SetOption(SocketType type, rtc::Socket::Option opt, |
| @@ -477,6 +482,16 @@ void BaseChannel::OnChannelRead(TransportChannel* channel, |
| HandlePacket(rtcp, &packet, packet_time); |
| } |
| +void BaseChannel::OnPacketSent(TransportChannel* channel, |
| + const rtc::SentPacket& sent_packet) { |
| + if (!media_controller_) |
| + return; |
|
pthatcher1
2015/10/05 18:30:13
{}s please
stefan-webrtc
2015/10/07 16:55:25
This code has now been removed.
|
| + ASSERT(channel == transport_channel_ || channel == rtcp_transport_channel_); |
| + webrtc::SentPacket webrtc_sent_packet(sent_packet.packet_id, |
| + sent_packet.send_time_ms); |
|
pthatcher1
2015/10/05 18:30:13
Similarly, can we have just one SentPacket struct?
|
| + media_controller_->OnPacketSent(webrtc_sent_packet); |
|
pthatcher1
2015/10/05 18:30:13
Would it make sense for this to be media_controlle
|
| +} |
| + |
| void BaseChannel::OnReadyToSend(TransportChannel* channel) { |
| ASSERT(channel == transport_channel_ || channel == rtcp_transport_channel_); |
| SetReadyToSend(channel == rtcp_transport_channel_, true); |
| @@ -506,8 +521,9 @@ bool BaseChannel::PacketIsRtcp(const TransportChannel* channel, |
| rtcp_mux_filter_.DemuxRtcp(data, static_cast<int>(len))); |
| } |
| -bool BaseChannel::SendPacket(bool rtcp, rtc::Buffer* packet, |
| - rtc::DiffServCodePoint dscp) { |
| +bool BaseChannel::SendPacket(bool rtcp, |
| + rtc::Buffer* packet, |
| + const rtc::PacketOptions& options) { |
| // SendPacket gets called from MediaEngine, typically on an encoder thread. |
| // If the thread is not our worker thread, we will post to our worker |
| // so that the real work happens on our worker. This avoids us having to |
| @@ -520,7 +536,7 @@ bool BaseChannel::SendPacket(bool rtcp, rtc::Buffer* packet, |
| int message_id = (!rtcp) ? MSG_RTPPACKET : MSG_RTCPPACKET; |
| PacketMessageData* data = new PacketMessageData; |
| data->packet = packet->Pass(); |
| - data->dscp = dscp; |
| + data->dscp = options.dscp; |
| worker_thread_->Post(this, message_id, data); |
| return true; |
| } |
| @@ -543,7 +559,8 @@ bool BaseChannel::SendPacket(bool rtcp, rtc::Buffer* packet, |
| return false; |
| } |
| - rtc::PacketOptions options(dscp); |
| + rtc::PacketOptions updated_options; |
| + updated_options = options; |
| // Protect if needed. |
| if (srtp_filter_.IsActive()) { |
| bool res; |
| @@ -559,21 +576,22 @@ bool BaseChannel::SendPacket(bool rtcp, rtc::Buffer* packet, |
| res = srtp_filter_.ProtectRtp( |
| data, len, static_cast<int>(packet->capacity()), &len); |
| #else |
| - options.packet_time_params.rtp_sendtime_extension_id = |
| + updated_options.packet_time_params.rtp_sendtime_extension_id = |
| rtp_abs_sendtime_extn_id_; |
| res = srtp_filter_.ProtectRtp( |
| data, len, static_cast<int>(packet->capacity()), &len, |
| - &options.packet_time_params.srtp_packet_index); |
| + &updated_options.packet_time_params.srtp_packet_index); |
| // If protection succeeds, let's get auth params from srtp. |
| if (res) { |
| uint8* auth_key = NULL; |
| int key_len; |
| res = srtp_filter_.GetRtpAuthParams( |
| - &auth_key, &key_len, &options.packet_time_params.srtp_auth_tag_len); |
| + &auth_key, &key_len, |
| + &updated_options.packet_time_params.srtp_auth_tag_len); |
| if (res) { |
| - options.packet_time_params.srtp_auth_key.resize(key_len); |
| - options.packet_time_params.srtp_auth_key.assign(auth_key, |
| - auth_key + key_len); |
| + updated_options.packet_time_params.srtp_auth_key.resize(key_len); |
| + updated_options.packet_time_params.srtp_auth_key.assign( |
| + auth_key, auth_key + key_len); |
| } |
| } |
| #endif |
| @@ -1278,11 +1296,13 @@ void BaseChannel::FlushRtcpMessages() { |
| VoiceChannel::VoiceChannel(rtc::Thread* thread, |
| MediaEngineInterface* media_engine, |
| VoiceMediaChannel* media_channel, |
| + webrtc::MediaControllerInterface* media_controller, |
| TransportController* transport_controller, |
| const std::string& content_name, |
| bool rtcp) |
| : BaseChannel(thread, |
| media_channel, |
| + media_controller, |
| transport_controller, |
| content_name, |
| rtcp), |
| @@ -1596,11 +1616,13 @@ void VoiceChannel::GetSrtpCryptoSuiteNames( |
| VideoChannel::VideoChannel(rtc::Thread* thread, |
| VideoMediaChannel* media_channel, |
| + webrtc::MediaControllerInterface* media_controller, |
| TransportController* transport_controller, |
| const std::string& content_name, |
| bool rtcp) |
| : BaseChannel(thread, |
| media_channel, |
| + media_controller, |
| transport_controller, |
| content_name, |
| rtcp), |
| @@ -1991,6 +2013,7 @@ DataChannel::DataChannel(rtc::Thread* thread, |
| bool rtcp) |
| : BaseChannel(thread, |
| media_channel, |
| + nullptr, |
| transport_controller, |
| content_name, |
| rtcp), |