Wire up packet_id / send time callbacks to webrtc via libjingle.

BUG=webrtc:4173

Review URL: https://codereview.webrtc.org/1363573002

Cr-Commit-Position: refs/heads/master@{#10289}
This commit is contained in:
stefan 2015-10-15 07:26:07 -07:00 committed by Commit bot
parent 543b6ca30a
commit c1aeaf0dc3
63 changed files with 560 additions and 206 deletions

View File

@ -0,0 +1,55 @@
/*
* libjingle
* Copyright 2015 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TALK_APP_WEBRTC_FAKEMEDIACONTROLLER_H_
#define TALK_APP_WEBRTC_FAKEMEDIACONTROLLER_H_
#include "talk/app/webrtc/mediacontroller.h"
#include "webrtc/base/checks.h"
namespace cricket {
class FakeMediaController : public webrtc::MediaControllerInterface {
public:
explicit FakeMediaController(cricket::ChannelManager* channel_manager,
webrtc::Call* call)
: channel_manager_(channel_manager), call_(call) {
RTC_DCHECK(nullptr != channel_manager_);
RTC_DCHECK(nullptr != call_);
}
~FakeMediaController() override {}
webrtc::Call* call_w() override { return call_; }
cricket::ChannelManager* channel_manager() const override {
return channel_manager_;
}
private:
cricket::ChannelManager* channel_manager_;
webrtc::Call* call_;
};
} // namespace cricket
#endif // TALK_APP_WEBRTC_FAKEMEDIACONTROLLER_H_

View File

@ -27,6 +27,7 @@
#include "talk/app/webrtc/mediacontroller.h" #include "talk/app/webrtc/mediacontroller.h"
#include "talk/session/media/channelmanager.h"
#include "webrtc/base/bind.h" #include "webrtc/base/bind.h"
#include "webrtc/base/checks.h" #include "webrtc/base/checks.h"
#include "webrtc/call.h" #include "webrtc/call.h"
@ -37,14 +38,16 @@ const int kMinBandwidthBps = 30000;
const int kStartBandwidthBps = 300000; const int kStartBandwidthBps = 300000;
const int kMaxBandwidthBps = 2000000; const int kMaxBandwidthBps = 2000000;
class MediaController : public webrtc::MediaControllerInterface { class MediaController : public webrtc::MediaControllerInterface,
public sigslot::has_slots<> {
public: public:
MediaController(rtc::Thread* worker_thread, MediaController(rtc::Thread* worker_thread,
webrtc::VoiceEngine* voice_engine) cricket::ChannelManager* channel_manager)
: worker_thread_(worker_thread) { : worker_thread_(worker_thread), channel_manager_(channel_manager) {
RTC_DCHECK(nullptr != worker_thread); RTC_DCHECK(nullptr != worker_thread);
worker_thread_->Invoke<void>( worker_thread_->Invoke<void>(
rtc::Bind(&MediaController::Construct_w, this, voice_engine)); rtc::Bind(&MediaController::Construct_w, this,
channel_manager_->media_engine()->GetVoE()));
} }
~MediaController() override { ~MediaController() override {
worker_thread_->Invoke<void>( worker_thread_->Invoke<void>(
@ -56,6 +59,10 @@ class MediaController : public webrtc::MediaControllerInterface {
return call_.get(); return call_.get();
} }
cricket::ChannelManager* channel_manager() const override {
return channel_manager_;
}
private: private:
void Construct_w(webrtc::VoiceEngine* voice_engine) { void Construct_w(webrtc::VoiceEngine* voice_engine) {
RTC_DCHECK(worker_thread_->IsCurrent()); RTC_DCHECK(worker_thread_->IsCurrent());
@ -68,10 +75,11 @@ class MediaController : public webrtc::MediaControllerInterface {
} }
void Destruct_w() { void Destruct_w() {
RTC_DCHECK(worker_thread_->IsCurrent()); RTC_DCHECK(worker_thread_->IsCurrent());
call_.reset(nullptr); call_.reset();
} }
rtc::Thread* worker_thread_; rtc::Thread* const worker_thread_;
cricket::ChannelManager* const channel_manager_;
rtc::scoped_ptr<webrtc::Call> call_; rtc::scoped_ptr<webrtc::Call> call_;
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(MediaController); RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(MediaController);
@ -81,7 +89,8 @@ class MediaController : public webrtc::MediaControllerInterface {
namespace webrtc { namespace webrtc {
MediaControllerInterface* MediaControllerInterface::Create( MediaControllerInterface* MediaControllerInterface::Create(
rtc::Thread* worker_thread, webrtc::VoiceEngine* voice_engine) { rtc::Thread* worker_thread,
return new MediaController(worker_thread, voice_engine); cricket::ChannelManager* channel_manager) {
return new MediaController(worker_thread, channel_manager);
} }
} // namespace webrtc } // namespace webrtc

View File

@ -30,6 +30,10 @@
#include "webrtc/base/thread.h" #include "webrtc/base/thread.h"
namespace cricket {
class ChannelManager;
} // namespace cricket
namespace webrtc { namespace webrtc {
class Call; class Call;
class VoiceEngine; class VoiceEngine;
@ -38,11 +42,13 @@ class VoiceEngine;
// in the future will create and own RtpSenders and RtpReceivers. // in the future will create and own RtpSenders and RtpReceivers.
class MediaControllerInterface { class MediaControllerInterface {
public: public:
static MediaControllerInterface* Create(rtc::Thread* worker_thread, static MediaControllerInterface* Create(
webrtc::VoiceEngine* voice_engine); rtc::Thread* worker_thread,
cricket::ChannelManager* channel_manager);
virtual ~MediaControllerInterface() {} virtual ~MediaControllerInterface() {}
virtual webrtc::Call* call_w() = 0; virtual webrtc::Call* call_w() = 0;
virtual cricket::ChannelManager* channel_manager() const = 0;
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -630,12 +630,14 @@ bool PeerConnection::Initialize(
// No step delay is used while allocating ports. // No step delay is used while allocating ports.
port_allocator_->set_step_delay(cricket::kMinimumStepDelay); port_allocator_->set_step_delay(cricket::kMinimumStepDelay);
remote_stream_factory_.reset(new RemoteMediaStreamFactory( media_controller_.reset(factory_->CreateMediaController());
factory_->signaling_thread(), factory_->channel_manager()));
session_.reset(new WebRtcSession( remote_stream_factory_.reset(new RemoteMediaStreamFactory(
factory_->channel_manager(), factory_->signaling_thread(), factory_->signaling_thread(), media_controller_->channel_manager()));
factory_->worker_thread(), port_allocator_.get()));
session_.reset(
new WebRtcSession(media_controller_.get(), factory_->signaling_thread(),
factory_->worker_thread(), port_allocator_.get()));
stats_.reset(new StatsCollector(this)); stats_.reset(new StatsCollector(this));
// Initialize the WebRtcSession. It creates transport channels etc. // Initialize the WebRtcSession. It creates transport channels etc.

View File

@ -361,6 +361,7 @@ class PeerConnection : public PeerConnectionInterface,
IceGatheringState ice_gathering_state_; IceGatheringState ice_gathering_state_;
rtc::scoped_ptr<cricket::PortAllocator> port_allocator_; rtc::scoped_ptr<cricket::PortAllocator> port_allocator_;
rtc::scoped_ptr<MediaControllerInterface> media_controller_;
// Streams added via AddStream. // Streams added via AddStream.
rtc::scoped_refptr<StreamCollection> local_streams_; rtc::scoped_refptr<StreamCollection> local_streams_;

View File

@ -279,9 +279,11 @@ PeerConnectionFactory::CreateAudioTrack(const std::string& id,
return AudioTrackProxy::Create(signaling_thread_, track); return AudioTrackProxy::Create(signaling_thread_, track);
} }
cricket::ChannelManager* PeerConnectionFactory::channel_manager() { webrtc::MediaControllerInterface* PeerConnectionFactory::CreateMediaController()
const {
RTC_DCHECK(signaling_thread_->IsCurrent()); RTC_DCHECK(signaling_thread_->IsCurrent());
return channel_manager_.get(); return MediaControllerInterface::Create(worker_thread_,
channel_manager_.get());
} }
rtc::Thread* PeerConnectionFactory::signaling_thread() { rtc::Thread* PeerConnectionFactory::signaling_thread() {

View File

@ -31,6 +31,7 @@
#include <string> #include <string>
#include "talk/app/webrtc/dtlsidentitystore.h" #include "talk/app/webrtc/dtlsidentitystore.h"
#include "talk/app/webrtc/mediacontroller.h"
#include "talk/app/webrtc/mediastreaminterface.h" #include "talk/app/webrtc/mediastreaminterface.h"
#include "talk/app/webrtc/peerconnectioninterface.h" #include "talk/app/webrtc/peerconnectioninterface.h"
#include "talk/session/media/channelmanager.h" #include "talk/session/media/channelmanager.h"
@ -80,7 +81,7 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface {
bool StartAecDump(rtc::PlatformFile file) override; bool StartAecDump(rtc::PlatformFile file) override;
virtual cricket::ChannelManager* channel_manager(); virtual webrtc::MediaControllerInterface* CreateMediaController() const;
virtual rtc::Thread* signaling_thread(); virtual rtc::Thread* signaling_thread();
virtual rtc::Thread* worker_thread(); virtual rtc::Thread* worker_thread();
const Options& options() const { return options_; } const Options& options() const { return options_; }

View File

@ -84,8 +84,8 @@ const uint32_t kSsrcOfTrack = 1234;
class MockWebRtcSession : public webrtc::WebRtcSession { class MockWebRtcSession : public webrtc::WebRtcSession {
public: public:
explicit MockWebRtcSession(cricket::ChannelManager* channel_manager) explicit MockWebRtcSession(webrtc::MediaControllerInterface* media_controller)
: WebRtcSession(channel_manager, : WebRtcSession(media_controller,
rtc::Thread::Current(), rtc::Thread::Current(),
rtc::Thread::Current(), rtc::Thread::Current(),
nullptr) {} nullptr) {}
@ -506,7 +506,10 @@ class StatsCollectorTest : public testing::Test {
: media_engine_(new cricket::FakeMediaEngine()), : media_engine_(new cricket::FakeMediaEngine()),
channel_manager_( channel_manager_(
new cricket::ChannelManager(media_engine_, rtc::Thread::Current())), new cricket::ChannelManager(media_engine_, rtc::Thread::Current())),
session_(channel_manager_.get()) { media_controller_(
webrtc::MediaControllerInterface::Create(rtc::Thread::Current(),
channel_manager_.get())),
session_(media_controller_.get()) {
// By default, we ignore session GetStats calls. // By default, we ignore session GetStats calls.
EXPECT_CALL(session_, GetTransportStats(_)).WillRepeatedly(Return(false)); EXPECT_CALL(session_, GetTransportStats(_)).WillRepeatedly(Return(false));
// Add default returns for mock classes. // Add default returns for mock classes.
@ -760,6 +763,7 @@ class StatsCollectorTest : public testing::Test {
cricket::FakeMediaEngine* media_engine_; cricket::FakeMediaEngine* media_engine_;
rtc::scoped_ptr<cricket::ChannelManager> channel_manager_; rtc::scoped_ptr<cricket::ChannelManager> channel_manager_;
rtc::scoped_ptr<webrtc::MediaControllerInterface> media_controller_;
MockWebRtcSession session_; MockWebRtcSession session_;
MockPeerConnection pc_; MockPeerConnection pc_;
FakeDataChannelProvider data_channel_provider_; FakeDataChannelProvider data_channel_provider_;
@ -825,8 +829,8 @@ TEST_F(StatsCollectorTest, BytesCounterHandles64Bits) {
Return(true))); Return(true)));
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
cricket::VideoChannel video_channel(rtc::Thread::Current(), cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel,
media_channel, NULL, kVideoChannelName, false); nullptr, kVideoChannelName, false);
StatsReports reports; // returned values. StatsReports reports; // returned values.
cricket::VideoSenderInfo video_sender_info; cricket::VideoSenderInfo video_sender_info;
cricket::VideoMediaInfo stats_read; cricket::VideoMediaInfo stats_read;
@ -871,8 +875,8 @@ TEST_F(StatsCollectorTest, BandwidthEstimationInfoIsReported) {
Return(true))); Return(true)));
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
cricket::VideoChannel video_channel(rtc::Thread::Current(), cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel,
media_channel, NULL, kVideoChannelName, false); nullptr, kVideoChannelName, false);
StatsReports reports; // returned values. StatsReports reports; // returned values.
cricket::VideoSenderInfo video_sender_info; cricket::VideoSenderInfo video_sender_info;
@ -946,8 +950,8 @@ TEST_F(StatsCollectorTest, TrackObjectExistsWithoutUpdateStats) {
StatsCollectorForTest stats(&pc_); StatsCollectorForTest stats(&pc_);
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
cricket::VideoChannel video_channel(rtc::Thread::Current(), cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel,
media_channel, NULL, "video", false); nullptr, "video", false);
AddOutgoingVideoTrackStats(); AddOutgoingVideoTrackStats();
stats.AddStream(stream_); stats.AddStream(stream_);
@ -982,8 +986,8 @@ TEST_F(StatsCollectorTest, TrackAndSsrcObjectExistAfterUpdateSsrcStats) {
Return(true))); Return(true)));
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
cricket::VideoChannel video_channel(rtc::Thread::Current(), cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel,
media_channel, NULL, kVideoChannelName, false); nullptr, kVideoChannelName, false);
AddOutgoingVideoTrackStats(); AddOutgoingVideoTrackStats();
stats.AddStream(stream_); stats.AddStream(stream_);
@ -1046,8 +1050,8 @@ TEST_F(StatsCollectorTest, TransportObjectLinkedFromSsrcObject) {
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
// The transport_name known by the video channel. // The transport_name known by the video channel.
const std::string kVcName("vcname"); const std::string kVcName("vcname");
cricket::VideoChannel video_channel(rtc::Thread::Current(), cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel,
media_channel, NULL, kVcName, false); nullptr, kVcName, false);
AddOutgoingVideoTrackStats(); AddOutgoingVideoTrackStats();
stats.AddStream(stream_); stats.AddStream(stream_);
@ -1104,8 +1108,8 @@ TEST_F(StatsCollectorTest, RemoteSsrcInfoIsAbsent) {
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
// The transport_name known by the video channel. // The transport_name known by the video channel.
const std::string kVcName("vcname"); const std::string kVcName("vcname");
cricket::VideoChannel video_channel(rtc::Thread::Current(), cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel,
media_channel, NULL, kVcName, false); nullptr, kVcName, false);
AddOutgoingVideoTrackStats(); AddOutgoingVideoTrackStats();
stats.AddStream(stream_); stats.AddStream(stream_);
@ -1130,8 +1134,8 @@ TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) {
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
// The transport_name known by the video channel. // The transport_name known by the video channel.
const std::string kVcName("vcname"); const std::string kVcName("vcname");
cricket::VideoChannel video_channel(rtc::Thread::Current(), cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel,
media_channel, NULL, kVcName, false); nullptr, kVcName, false);
AddOutgoingVideoTrackStats(); AddOutgoingVideoTrackStats();
stats.AddStream(stream_); stats.AddStream(stream_);
@ -1185,8 +1189,8 @@ TEST_F(StatsCollectorTest, ReportsFromRemoteTrack) {
Return(true))); Return(true)));
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
cricket::VideoChannel video_channel(rtc::Thread::Current(), cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel,
media_channel, NULL, kVideoChannelName, false); nullptr, kVideoChannelName, false);
AddIncomingVideoTrackStats(); AddIncomingVideoTrackStats();
stats.AddStream(stream_); stats.AddStream(stream_);
@ -1494,8 +1498,8 @@ TEST_F(StatsCollectorTest, GetStatsFromLocalAudioTrack) {
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
// The transport_name known by the voice channel. // The transport_name known by the voice channel.
const std::string kVcName("vcname"); const std::string kVcName("vcname");
cricket::VoiceChannel voice_channel(rtc::Thread::Current(), cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_,
media_engine_, media_channel, NULL, kVcName, false); media_channel, nullptr, kVcName, false);
AddOutgoingAudioTrackStats(); AddOutgoingAudioTrackStats();
stats.AddStream(stream_); stats.AddStream(stream_);
stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack);
@ -1529,8 +1533,8 @@ TEST_F(StatsCollectorTest, GetStatsFromRemoteStream) {
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
// The transport_name known by the voice channel. // The transport_name known by the voice channel.
const std::string kVcName("vcname"); const std::string kVcName("vcname");
cricket::VoiceChannel voice_channel(rtc::Thread::Current(), cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_,
media_engine_, media_channel, NULL, kVcName, false); media_channel, nullptr, kVcName, false);
AddIncomingAudioTrackStats(); AddIncomingAudioTrackStats();
stats.AddStream(stream_); stats.AddStream(stream_);
@ -1558,8 +1562,8 @@ TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) {
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
// The transport_name known by the voice channel. // The transport_name known by the voice channel.
const std::string kVcName("vcname"); const std::string kVcName("vcname");
cricket::VoiceChannel voice_channel(rtc::Thread::Current(), cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_,
media_engine_, media_channel, NULL, kVcName, false); media_channel, nullptr, kVcName, false);
AddOutgoingAudioTrackStats(); AddOutgoingAudioTrackStats();
stats.AddStream(stream_); stats.AddStream(stream_);
stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack);
@ -1619,8 +1623,8 @@ TEST_F(StatsCollectorTest, LocalAndRemoteTracksWithSameSsrc) {
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
// The transport_name known by the voice channel. // The transport_name known by the voice channel.
const std::string kVcName("vcname"); const std::string kVcName("vcname");
cricket::VoiceChannel voice_channel(rtc::Thread::Current(), cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_,
media_engine_, media_channel, NULL, kVcName, false); media_channel, nullptr, kVcName, false);
// Create a local stream with a local audio track and adds it to the stats. // Create a local stream with a local audio track and adds it to the stats.
AddOutgoingAudioTrackStats(); AddOutgoingAudioTrackStats();
@ -1706,8 +1710,8 @@ TEST_F(StatsCollectorTest, TwoLocalTracksWithSameSsrc) {
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
// The transport_name known by the voice channel. // The transport_name known by the voice channel.
const std::string kVcName("vcname"); const std::string kVcName("vcname");
cricket::VoiceChannel voice_channel(rtc::Thread::Current(), cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_,
media_engine_, media_channel, NULL, kVcName, false); media_channel, nullptr, kVcName, false);
// Create a local stream with a local audio track and adds it to the stats. // Create a local stream with a local audio track and adds it to the stats.
AddOutgoingAudioTrackStats(); AddOutgoingAudioTrackStats();

View File

@ -25,6 +25,9 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef TALK_APP_WEBRTC_TEST_FAKEDATACHANNELPROVIDER_H_
#define TALK_APP_WEBRTC_TEST_FAKEDATACHANNELPROVIDER_H_
#include "talk/app/webrtc/datachannel.h" #include "talk/app/webrtc/datachannel.h"
class FakeDataChannelProvider : public webrtc::DataChannelProviderInterface { class FakeDataChannelProvider : public webrtc::DataChannelProviderInterface {
@ -155,3 +158,4 @@ class FakeDataChannelProvider : public webrtc::DataChannelProviderInterface {
std::set<uint32_t> send_ssrcs_; std::set<uint32_t> send_ssrcs_;
std::set<uint32_t> recv_ssrcs_; std::set<uint32_t> recv_ssrcs_;
}; };
#endif // TALK_APP_WEBRTC_TEST_FAKEDATACHANNELPROVIDER_H_

View File

@ -51,7 +51,9 @@
#include "webrtc/base/logging.h" #include "webrtc/base/logging.h"
#include "webrtc/base/stringencode.h" #include "webrtc/base/stringencode.h"
#include "webrtc/base/stringutils.h" #include "webrtc/base/stringutils.h"
#include "webrtc/call.h"
#include "webrtc/p2p/base/portallocator.h" #include "webrtc/p2p/base/portallocator.h"
#include "webrtc/p2p/base/transportchannel.h"
using cricket::ContentInfo; using cricket::ContentInfo;
using cricket::ContentInfos; using cricket::ContentInfos;
@ -529,7 +531,7 @@ class IceRestartAnswerLatch {
bool ice_restart_; bool ice_restart_;
}; };
WebRtcSession::WebRtcSession(cricket::ChannelManager* channel_manager, WebRtcSession::WebRtcSession(webrtc::MediaControllerInterface* media_controller,
rtc::Thread* signaling_thread, rtc::Thread* signaling_thread,
rtc::Thread* worker_thread, rtc::Thread* worker_thread,
cricket::PortAllocator* port_allocator) cricket::PortAllocator* port_allocator)
@ -543,7 +545,8 @@ WebRtcSession::WebRtcSession(cricket::ChannelManager* channel_manager,
transport_controller_(new cricket::TransportController(signaling_thread, transport_controller_(new cricket::TransportController(signaling_thread,
worker_thread, worker_thread,
port_allocator)), port_allocator)),
channel_manager_(channel_manager), media_controller_(media_controller),
channel_manager_(media_controller_->channel_manager()),
ice_observer_(NULL), ice_observer_(NULL),
ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), ice_connection_state_(PeerConnectionInterface::kIceConnectionNew),
ice_connection_receiving_(true), ice_connection_receiving_(true),
@ -763,9 +766,6 @@ bool WebRtcSession::Initialize(
cricket::PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE); cricket::PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE);
} }
media_controller_.reset(MediaControllerInterface::Create(
worker_thread(), channel_manager_->media_engine()->GetVoE()));
return true; return true;
} }
@ -1844,7 +1844,7 @@ bool WebRtcSession::CreateChannels(const SessionDescription* desc) {
bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content) { bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content) {
voice_channel_.reset(channel_manager_->CreateVoiceChannel( voice_channel_.reset(channel_manager_->CreateVoiceChannel(
media_controller_.get(), transport_controller_.get(), content->name, true, media_controller_, transport_controller_.get(), content->name, true,
audio_options_)); audio_options_));
if (!voice_channel_) { if (!voice_channel_) {
return false; return false;
@ -1854,12 +1854,14 @@ bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content) {
this, &WebRtcSession::OnDtlsSetupFailure); this, &WebRtcSession::OnDtlsSetupFailure);
SignalVoiceChannelCreated(); SignalVoiceChannelCreated();
voice_channel_->transport_channel()->SignalSentPacket.connect(
this, &WebRtcSession::OnSentPacket_w);
return true; return true;
} }
bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content) { bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content) {
video_channel_.reset(channel_manager_->CreateVideoChannel( video_channel_.reset(channel_manager_->CreateVideoChannel(
media_controller_.get(), transport_controller_.get(), content->name, true, media_controller_, transport_controller_.get(), content->name, true,
video_options_)); video_options_));
if (!video_channel_) { if (!video_channel_) {
return false; return false;
@ -1869,6 +1871,8 @@ bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content) {
this, &WebRtcSession::OnDtlsSetupFailure); this, &WebRtcSession::OnDtlsSetupFailure);
SignalVideoChannelCreated(); SignalVideoChannelCreated();
video_channel_->transport_channel()->SignalSentPacket.connect(
this, &WebRtcSession::OnSentPacket_w);
return true; return true;
} }
@ -1889,6 +1893,8 @@ bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content) {
this, &WebRtcSession::OnDtlsSetupFailure); this, &WebRtcSession::OnDtlsSetupFailure);
SignalDataChannelCreated(); SignalDataChannelCreated();
data_channel_->transport_channel()->SignalSentPacket.connect(
this, &WebRtcSession::OnSentPacket_w);
return true; return true;
} }
@ -2205,4 +2211,10 @@ void WebRtcSession::ReportNegotiatedCiphers(
} }
} }
void WebRtcSession::OnSentPacket_w(cricket::TransportChannel* channel,
const rtc::SentPacket& sent_packet) {
RTC_DCHECK(worker_thread()->IsCurrent());
media_controller_->call_w()->OnSentPacket(sent_packet);
}
} // namespace webrtc } // namespace webrtc

View File

@ -151,7 +151,7 @@ class WebRtcSession : public AudioProviderInterface,
ERROR_TRANSPORT = 2, // transport error of some kind ERROR_TRANSPORT = 2, // transport error of some kind
}; };
WebRtcSession(cricket::ChannelManager* channel_manager, WebRtcSession(webrtc::MediaControllerInterface* media_controller,
rtc::Thread* signaling_thread, rtc::Thread* signaling_thread,
rtc::Thread* worker_thread, rtc::Thread* worker_thread,
cricket::PortAllocator* port_allocator); cricket::PortAllocator* port_allocator);
@ -458,6 +458,9 @@ class WebRtcSession : public AudioProviderInterface,
void ReportNegotiatedCiphers(const cricket::TransportStats& stats); void ReportNegotiatedCiphers(const cricket::TransportStats& stats);
void OnSentPacket_w(cricket::TransportChannel* channel,
const rtc::SentPacket& sent_packet);
rtc::Thread* const signaling_thread_; rtc::Thread* const signaling_thread_;
rtc::Thread* const worker_thread_; rtc::Thread* const worker_thread_;
cricket::PortAllocator* const port_allocator_; cricket::PortAllocator* const port_allocator_;
@ -470,7 +473,7 @@ class WebRtcSession : public AudioProviderInterface,
bool initial_offerer_ = false; bool initial_offerer_ = false;
rtc::scoped_ptr<cricket::TransportController> transport_controller_; rtc::scoped_ptr<cricket::TransportController> transport_controller_;
rtc::scoped_ptr<MediaControllerInterface> media_controller_; MediaControllerInterface* media_controller_;
rtc::scoped_ptr<cricket::VoiceChannel> voice_channel_; rtc::scoped_ptr<cricket::VoiceChannel> voice_channel_;
rtc::scoped_ptr<cricket::VideoChannel> video_channel_; rtc::scoped_ptr<cricket::VideoChannel> video_channel_;
rtc::scoped_ptr<cricket::DataChannel> data_channel_; rtc::scoped_ptr<cricket::DataChannel> data_channel_;

View File

@ -28,6 +28,7 @@
#include <vector> #include <vector>
#include "talk/app/webrtc/audiotrack.h" #include "talk/app/webrtc/audiotrack.h"
#include "talk/app/webrtc/fakemediacontroller.h"
#include "talk/app/webrtc/fakemetricsobserver.h" #include "talk/app/webrtc/fakemetricsobserver.h"
#include "talk/app/webrtc/jsepicecandidate.h" #include "talk/app/webrtc/jsepicecandidate.h"
#include "talk/app/webrtc/jsepsessiondescription.h" #include "talk/app/webrtc/jsepsessiondescription.h"
@ -44,6 +45,7 @@
#include "talk/media/base/fakemediaengine.h" #include "talk/media/base/fakemediaengine.h"
#include "talk/media/base/fakevideorenderer.h" #include "talk/media/base/fakevideorenderer.h"
#include "talk/media/base/mediachannel.h" #include "talk/media/base/mediachannel.h"
#include "talk/media/webrtc/fakewebrtccall.h"
#include "webrtc/p2p/base/stunserver.h" #include "webrtc/p2p/base/stunserver.h"
#include "webrtc/p2p/base/teststunserver.h" #include "webrtc/p2p/base/teststunserver.h"
#include "webrtc/p2p/base/testturnserver.h" #include "webrtc/p2p/base/testturnserver.h"
@ -245,12 +247,15 @@ class MockIceObserver : public webrtc::IceObserver {
class WebRtcSessionForTest : public webrtc::WebRtcSession { class WebRtcSessionForTest : public webrtc::WebRtcSession {
public: public:
WebRtcSessionForTest(cricket::ChannelManager* cmgr, WebRtcSessionForTest(webrtc::MediaControllerInterface* media_controller,
rtc::Thread* signaling_thread, rtc::Thread* signaling_thread,
rtc::Thread* worker_thread, rtc::Thread* worker_thread,
cricket::PortAllocator* port_allocator, cricket::PortAllocator* port_allocator,
webrtc::IceObserver* ice_observer) webrtc::IceObserver* ice_observer)
: WebRtcSession(cmgr, signaling_thread, worker_thread, port_allocator) { : WebRtcSession(media_controller,
signaling_thread,
worker_thread,
port_allocator) {
RegisterIceObserver(ice_observer); RegisterIceObserver(ice_observer);
} }
virtual ~WebRtcSessionForTest() {} virtual ~WebRtcSessionForTest() {}
@ -360,24 +365,31 @@ class WebRtcSessionTest
// TODO Investigate why ChannelManager crashes, if it's created // TODO Investigate why ChannelManager crashes, if it's created
// after stun_server. // after stun_server.
WebRtcSessionTest() WebRtcSessionTest()
: media_engine_(new cricket::FakeMediaEngine()), : media_engine_(new cricket::FakeMediaEngine()),
data_engine_(new cricket::FakeDataEngine()), data_engine_(new cricket::FakeDataEngine()),
channel_manager_(new cricket::ChannelManager( channel_manager_(
media_engine_, data_engine_, new cricket::CaptureManager(), new cricket::ChannelManager(media_engine_,
rtc::Thread::Current())), data_engine_,
tdesc_factory_(new cricket::TransportDescriptionFactory()), new cricket::CaptureManager(),
desc_factory_(new cricket::MediaSessionDescriptionFactory( rtc::Thread::Current())),
channel_manager_.get(), tdesc_factory_.get())), fake_call_(webrtc::Call::Config()),
pss_(new rtc::PhysicalSocketServer), media_controller_(
vss_(new rtc::VirtualSocketServer(pss_.get())), webrtc::MediaControllerInterface::Create(rtc::Thread::Current(),
fss_(new rtc::FirewallSocketServer(vss_.get())), channel_manager_.get())),
ss_scope_(fss_.get()), tdesc_factory_(new cricket::TransportDescriptionFactory()),
stun_socket_addr_(rtc::SocketAddress(kStunAddrHost, desc_factory_(
cricket::STUN_SERVER_PORT)), new cricket::MediaSessionDescriptionFactory(channel_manager_.get(),
stun_server_(cricket::TestStunServer::Create(Thread::Current(), tdesc_factory_.get())),
stun_socket_addr_)), pss_(new rtc::PhysicalSocketServer),
turn_server_(Thread::Current(), kTurnUdpIntAddr, kTurnUdpExtAddr), vss_(new rtc::VirtualSocketServer(pss_.get())),
metrics_observer_(new rtc::RefCountedObject<FakeMetricsObserver>()) { fss_(new rtc::FirewallSocketServer(vss_.get())),
ss_scope_(fss_.get()),
stun_socket_addr_(
rtc::SocketAddress(kStunAddrHost, cricket::STUN_SERVER_PORT)),
stun_server_(cricket::TestStunServer::Create(Thread::Current(),
stun_socket_addr_)),
turn_server_(Thread::Current(), kTurnUdpIntAddr, kTurnUdpExtAddr),
metrics_observer_(new rtc::RefCountedObject<FakeMetricsObserver>()) {
cricket::ServerAddresses stun_servers; cricket::ServerAddresses stun_servers;
stun_servers.insert(stun_socket_addr_); stun_servers.insert(stun_socket_addr_);
allocator_.reset(new cricket::BasicPortAllocator( allocator_.reset(new cricket::BasicPortAllocator(
@ -405,7 +417,7 @@ class WebRtcSessionTest
const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { const PeerConnectionInterface::RTCConfiguration& rtc_configuration) {
ASSERT_TRUE(session_.get() == NULL); ASSERT_TRUE(session_.get() == NULL);
session_.reset(new WebRtcSessionForTest( session_.reset(new WebRtcSessionForTest(
channel_manager_.get(), rtc::Thread::Current(), rtc::Thread::Current(), media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(),
allocator_.get(), &observer_)); allocator_.get(), &observer_));
session_->SignalDataChannelOpenMessage.connect( session_->SignalDataChannelOpenMessage.connect(
this, &WebRtcSessionTest::OnDataChannelOpenMessage); this, &WebRtcSessionTest::OnDataChannelOpenMessage);
@ -1226,8 +1238,7 @@ class WebRtcSessionTest
// -> Failed. // -> Failed.
// The Gathering state should go: New -> Gathering -> Completed. // The Gathering state should go: New -> Gathering -> Completed.
void TestLoopbackCall(const LoopbackNetworkConfiguration& config) { void SetupLoopbackCall() {
LoopbackNetworkManager loopback_network_manager(this, config);
Init(); Init();
SendAudioVideoStream1(); SendAudioVideoStream1();
SessionDescriptionInterface* offer = CreateOffer(); SessionDescriptionInterface* offer = CreateOffer();
@ -1238,30 +1249,29 @@ class WebRtcSessionTest
EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew,
observer_.ice_connection_state_); observer_.ice_connection_state_);
EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringGathering, EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringGathering,
observer_.ice_gathering_state_, observer_.ice_gathering_state_, kIceCandidatesTimeout);
kIceCandidatesTimeout);
EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout);
EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete, EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete,
observer_.ice_gathering_state_, observer_.ice_gathering_state_, kIceCandidatesTimeout);
kIceCandidatesTimeout);
std::string sdp; std::string sdp;
offer->ToString(&sdp); offer->ToString(&sdp);
SessionDescriptionInterface* desc = SessionDescriptionInterface* desc = webrtc::CreateSessionDescription(
webrtc::CreateSessionDescription( JsepSessionDescription::kAnswer, sdp, nullptr);
JsepSessionDescription::kAnswer, sdp, nullptr);
ASSERT_TRUE(desc != NULL); ASSERT_TRUE(desc != NULL);
SetRemoteDescriptionWithoutError(desc); SetRemoteDescriptionWithoutError(desc);
EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionChecking, EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionChecking,
observer_.ice_connection_state_, observer_.ice_connection_state_, kIceCandidatesTimeout);
kIceCandidatesTimeout);
// The ice connection state is "Connected" too briefly to catch in a test. // The ice connection state is "Connected" too briefly to catch in a test.
EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted, EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
observer_.ice_connection_state_, observer_.ice_connection_state_, kIceCandidatesTimeout);
kIceCandidatesTimeout); }
void TestLoopbackCall(const LoopbackNetworkConfiguration& config) {
LoopbackNetworkManager loopback_network_manager(this, config);
SetupLoopbackCall();
config.VerifyBestConnectionAfterIceConverge(metrics_observer_); config.VerifyBestConnectionAfterIceConverge(metrics_observer_);
// Adding firewall rule to block ping requests, which should cause // Adding firewall rule to block ping requests, which should cause
// transport channel failure. // transport channel failure.
@ -1300,6 +1310,25 @@ class WebRtcSessionTest
TestLoopbackCall(config); TestLoopbackCall(config);
} }
void TestPacketOptions() {
media_controller_.reset(
new cricket::FakeMediaController(channel_manager_.get(), &fake_call_));
LoopbackNetworkConfiguration config;
LoopbackNetworkManager loopback_network_manager(this, config);
SetupLoopbackCall();
uint8_t test_packet[15] = {0};
rtc::PacketOptions options;
options.packet_id = 10;
media_engine_->GetVideoChannel(0)
->SendRtp(test_packet, sizeof(test_packet), options);
const int kPacketTimeout = 2000;
EXPECT_EQ_WAIT(fake_call_.last_sent_packet().packet_id, 10, kPacketTimeout);
EXPECT_GT(fake_call_.last_sent_packet().send_time_ms, -1);
}
// Adds CN codecs to FakeMediaEngine and MediaDescriptionFactory. // Adds CN codecs to FakeMediaEngine and MediaDescriptionFactory.
void AddCNCodecs() { void AddCNCodecs() {
const cricket::AudioCodec kCNCodec1(102, "CN", 8000, 0, 1, 0); const cricket::AudioCodec kCNCodec1(102, "CN", 8000, 0, 1, 0);
@ -1406,6 +1435,8 @@ class WebRtcSessionTest
cricket::FakeMediaEngine* media_engine_; cricket::FakeMediaEngine* media_engine_;
cricket::FakeDataEngine* data_engine_; cricket::FakeDataEngine* data_engine_;
rtc::scoped_ptr<cricket::ChannelManager> channel_manager_; rtc::scoped_ptr<cricket::ChannelManager> channel_manager_;
cricket::FakeCall fake_call_;
rtc::scoped_ptr<webrtc::MediaControllerInterface> media_controller_;
rtc::scoped_ptr<cricket::TransportDescriptionFactory> tdesc_factory_; rtc::scoped_ptr<cricket::TransportDescriptionFactory> tdesc_factory_;
rtc::scoped_ptr<cricket::MediaSessionDescriptionFactory> desc_factory_; rtc::scoped_ptr<cricket::MediaSessionDescriptionFactory> desc_factory_;
rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_; rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_;
@ -4154,6 +4185,10 @@ TEST_F(WebRtcSessionTest, CreateOffersAndShutdown) {
} }
} }
TEST_F(WebRtcSessionTest, TestPacketOptionsAndOnPacketSent) {
TestPacketOptions();
}
// TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test
// currently fails because upon disconnection and reconnection OnIceComplete is // currently fails because upon disconnection and reconnection OnIceComplete is
// called more than once without returning to IceGatheringGathering. // called more than once without returning to IceGatheringGathering.

View File

@ -46,6 +46,7 @@
'target_name': 'libjingle_peerconnection_so', 'target_name': 'libjingle_peerconnection_so',
'type': 'shared_library', 'type': 'shared_library',
'dependencies': [ 'dependencies': [
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:field_trial_default',
'libjingle_peerconnection', 'libjingle_peerconnection',
], ],
'sources': [ 'sources': [
@ -432,8 +433,8 @@
'<(webrtc_root)/webrtc.gyp:webrtc', '<(webrtc_root)/webrtc.gyp:webrtc',
'<(webrtc_root)/voice_engine/voice_engine.gyp:voice_engine', '<(webrtc_root)/voice_engine/voice_engine.gyp:voice_engine',
'<(webrtc_root)/sound/sound.gyp:rtc_sound', '<(webrtc_root)/sound/sound.gyp:rtc_sound',
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:metrics_default',
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers', '<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers',
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers_default',
'<(webrtc_root)/libjingle/xmllite/xmllite.gyp:rtc_xmllite', '<(webrtc_root)/libjingle/xmllite/xmllite.gyp:rtc_xmllite',
'<(webrtc_root)/libjingle/xmpp/xmpp.gyp:rtc_xmpp', '<(webrtc_root)/libjingle/xmpp/xmpp.gyp:rtc_xmpp',
'<(webrtc_root)/p2p/p2p.gyp:rtc_p2p', '<(webrtc_root)/p2p/p2p.gyp:rtc_p2p',

View File

@ -142,6 +142,7 @@
'dependencies': [ 'dependencies': [
'<(webrtc_root)/base/base_tests.gyp:rtc_base_tests_utils', '<(webrtc_root)/base/base_tests.gyp:rtc_base_tests_utils',
'libjingle.gyp:libjingle', 'libjingle.gyp:libjingle',
'libjingle.gyp:libjingle_peerconnection',
'libjingle.gyp:libjingle_p2p', 'libjingle.gyp:libjingle_p2p',
'libjingle_unittest_main', 'libjingle_unittest_main',
], ],
@ -344,6 +345,7 @@
'includes': [ 'build/objc_app.gypi' ], 'includes': [ 'build/objc_app.gypi' ],
'dependencies': [ 'dependencies': [
'<(webrtc_root)/base/base_tests.gyp:rtc_base_tests_utils', '<(webrtc_root)/base/base_tests.gyp:rtc_base_tests_utils',
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:field_trial_default',
'libjingle.gyp:libjingle_peerconnection_objc', 'libjingle.gyp:libjingle_peerconnection_objc',
], ],
'sources': [ 'sources': [
@ -375,6 +377,7 @@
'includes': [ 'build/objc_app.gypi' ], 'includes': [ 'build/objc_app.gypi' ],
'dependencies': [ 'dependencies': [
'<(webrtc_root)/base/base_tests.gyp:rtc_base_tests_utils', '<(webrtc_root)/base/base_tests.gyp:rtc_base_tests_utils',
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:field_trial_default',
'<(DEPTH)/third_party/ocmock/ocmock.gyp:ocmock', '<(DEPTH)/third_party/ocmock/ocmock.gyp:ocmock',
'<(webrtc_root)/libjingle_examples.gyp:apprtc_signaling', '<(webrtc_root)/libjingle_examples.gyp:apprtc_signaling',
], ],

View File

@ -124,6 +124,10 @@ const char kRtpVideoRotationHeaderExtension[] = "urn:3gpp:video-orientation";
const char kRtpVideoRotation6BitsHeaderExtensionForTesting[] = const char kRtpVideoRotation6BitsHeaderExtensionForTesting[] =
"urn:3gpp:video-orientation:6"; "urn:3gpp:video-orientation:6";
const int kRtpTransportSequenceNumberHeaderExtensionDefaultId = 5;
const char kRtpTransportSequenceNumberHeaderExtension[] =
"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions";
const int kNumDefaultUnsignalledVideoRecvStreams = 0; const int kNumDefaultUnsignalledVideoRecvStreams = 0;
const char kVp8CodecName[] = "VP8"; const char kVp8CodecName[] = "VP8";

View File

@ -154,6 +154,11 @@ extern const char kRtpVideoRotationHeaderExtension[];
// We don't support 6 bit CVO. Added here for testing purpose. // We don't support 6 bit CVO. Added here for testing purpose.
extern const char kRtpVideoRotation6BitsHeaderExtensionForTesting[]; extern const char kRtpVideoRotation6BitsHeaderExtensionForTesting[];
// Header extension for transport sequence number, see url for details:
// http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions
extern const int kRtpTransportSequenceNumberHeaderExtensionDefaultId;
extern const char kRtpTransportSequenceNumberHeaderExtension[];
extern const int kNumDefaultUnsignalledVideoRecvStreams; extern const int kNumDefaultUnsignalledVideoRecvStreams;
extern const char kVp8CodecName[]; extern const char kVp8CodecName[];

View File

@ -69,18 +69,18 @@ template <class Base> class RtpHelper : public Base {
const std::list<std::string>& rtp_packets() const { return rtp_packets_; } const std::list<std::string>& rtp_packets() const { return rtp_packets_; }
const std::list<std::string>& rtcp_packets() const { return rtcp_packets_; } const std::list<std::string>& rtcp_packets() const { return rtcp_packets_; }
bool SendRtp(const void* data, int len) { bool SendRtp(const void* data, int len, const rtc::PacketOptions& options) {
if (!sending_) { if (!sending_) {
return false; return false;
} }
rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len, rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len,
kMaxRtpPacketLen); kMaxRtpPacketLen);
return Base::SendPacket(&packet); return Base::SendPacket(&packet, options);
} }
bool SendRtcp(const void* data, int len) { bool SendRtcp(const void* data, int len) {
rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len, rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len,
kMaxRtpPacketLen); kMaxRtpPacketLen);
return Base::SendRtcp(&packet); return Base::SendRtcp(&packet, rtc::PacketOptions());
} }
bool CheckRtp(const void* data, int len) { bool CheckRtp(const void* data, int len) {

View File

@ -129,7 +129,7 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface,
protected: protected:
virtual bool SendPacket(rtc::Buffer* packet, virtual bool SendPacket(rtc::Buffer* packet,
rtc::DiffServCodePoint dscp) { const rtc::PacketOptions& options) {
rtc::CritScope cs(&crit_); rtc::CritScope cs(&crit_);
uint32_t cur_ssrc = 0; uint32_t cur_ssrc = 0;
@ -155,7 +155,7 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface,
} }
virtual bool SendRtcp(rtc::Buffer* packet, virtual bool SendRtcp(rtc::Buffer* packet,
rtc::DiffServCodePoint dscp) { const rtc::PacketOptions& options) {
rtc::CritScope cs(&crit_); rtc::CritScope cs(&crit_);
rtcp_packets_.push_back(*packet); rtcp_packets_.push_back(*packet);
if (!conf_) { if (!conf_) {

View File

@ -504,12 +504,10 @@ class MediaChannel : public sigslot::has_slots<> {
class NetworkInterface { class NetworkInterface {
public: public:
enum SocketType { ST_RTP, ST_RTCP }; enum SocketType { ST_RTP, ST_RTCP };
virtual bool SendPacket( virtual bool SendPacket(rtc::Buffer* packet,
rtc::Buffer* packet, const rtc::PacketOptions& options) = 0;
rtc::DiffServCodePoint dscp = rtc::DSCP_NO_CHANGE) = 0; virtual bool SendRtcp(rtc::Buffer* packet,
virtual bool SendRtcp( const rtc::PacketOptions& options) = 0;
rtc::Buffer* packet,
rtc::DiffServCodePoint dscp = rtc::DSCP_NO_CHANGE) = 0;
virtual int SetOption(SocketType type, rtc::Socket::Option opt, virtual int SetOption(SocketType type, rtc::Socket::Option opt,
int option) = 0; int option) = 0;
virtual ~NetworkInterface() {} virtual ~NetworkInterface() {}
@ -553,12 +551,12 @@ class MediaChannel : public sigslot::has_slots<> {
} }
// Base method to send packet using NetworkInterface. // Base method to send packet using NetworkInterface.
bool SendPacket(rtc::Buffer* packet) { bool SendPacket(rtc::Buffer* packet, const rtc::PacketOptions& options) {
return DoSendPacket(packet, false); return DoSendPacket(packet, false, options);
} }
bool SendRtcp(rtc::Buffer* packet) { bool SendRtcp(rtc::Buffer* packet, const rtc::PacketOptions& options) {
return DoSendPacket(packet, true); return DoSendPacket(packet, true, options);
} }
int SetOption(NetworkInterface::SocketType type, int SetOption(NetworkInterface::SocketType type,
@ -587,13 +585,15 @@ class MediaChannel : public sigslot::has_slots<> {
} }
private: private:
bool DoSendPacket(rtc::Buffer* packet, bool rtcp) { bool DoSendPacket(rtc::Buffer* packet,
bool rtcp,
const rtc::PacketOptions& options) {
rtc::CritScope cs(&network_interface_crit_); rtc::CritScope cs(&network_interface_crit_);
if (!network_interface_) if (!network_interface_)
return false; return false;
return (!rtcp) ? network_interface_->SendPacket(packet) : return (!rtcp) ? network_interface_->SendPacket(packet, options)
network_interface_->SendRtcp(packet); : network_interface_->SendRtcp(packet, options);
} }
// |network_interface_| can be accessed from the worker_thread and // |network_interface_| can be accessed from the worker_thread and

View File

@ -359,7 +359,7 @@ bool RtpDataMediaChannel::SendData(
<< ", timestamp=" << header.timestamp << ", timestamp=" << header.timestamp
<< ", len=" << payload.size(); << ", len=" << payload.size();
MediaChannel::SendPacket(&packet); MediaChannel::SendPacket(&packet, rtc::PacketOptions());
send_limiter_->Use(packet_len, now); send_limiter_->Use(packet_len, now);
if (result) { if (result) {
*result = SDR_SUCCESS; *result = SDR_SUCCESS;

View File

@ -984,7 +984,7 @@ void SctpDataMediaChannel::OnPacketFromSctpToNetwork(
<< " even after adding " << kSctpOverhead << " even after adding " << kSctpOverhead
<< " extra SCTP overhead"; << " extra SCTP overhead";
} }
MediaChannel::SendPacket(buffer); MediaChannel::SendPacket(buffer, rtc::PacketOptions());
} }
bool SctpDataMediaChannel::SendQueuedStreamResets() { bool SctpDataMediaChannel::SendQueuedStreamResets() {

View File

@ -64,7 +64,7 @@ class SctpFakeNetworkInterface : public cricket::MediaChannel::NetworkInterface,
protected: protected:
// Called to send raw packet down the wire (e.g. SCTP an packet). // Called to send raw packet down the wire (e.g. SCTP an packet).
virtual bool SendPacket(rtc::Buffer* packet, virtual bool SendPacket(rtc::Buffer* packet,
rtc::DiffServCodePoint dscp) { const rtc::PacketOptions& options) {
LOG(LS_VERBOSE) << "SctpFakeNetworkInterface::SendPacket"; LOG(LS_VERBOSE) << "SctpFakeNetworkInterface::SendPacket";
// TODO(ldixon): Can/should we use Buffer.TransferTo here? // TODO(ldixon): Can/should we use Buffer.TransferTo here?
@ -93,7 +93,7 @@ class SctpFakeNetworkInterface : public cricket::MediaChannel::NetworkInterface,
// TODO(ldixon): Refactor parent NetworkInterface class so these are not // TODO(ldixon): Refactor parent NetworkInterface class so these are not
// required. They are RTC specific and should be in an appropriate subclass. // required. They are RTC specific and should be in an appropriate subclass.
virtual bool SendRtcp(rtc::Buffer* packet, virtual bool SendRtcp(rtc::Buffer* packet,
rtc::DiffServCodePoint dscp) { const rtc::PacketOptions& options) {
LOG(LS_WARNING) << "Unsupported: SctpFakeNetworkInterface::SendRtcp."; LOG(LS_WARNING) << "Unsupported: SctpFakeNetworkInterface::SendRtcp.";
return false; return false;
} }

View File

@ -202,8 +202,7 @@ FakeCall::FakeCall(const webrtc::Call::Config& config)
: config_(config), : config_(config),
network_state_(webrtc::kNetworkUp), network_state_(webrtc::kNetworkUp),
num_created_send_streams_(0), num_created_send_streams_(0),
num_created_receive_streams_(0) { num_created_receive_streams_(0) {}
}
FakeCall::~FakeCall() { FakeCall::~FakeCall() {
EXPECT_EQ(0u, video_send_streams_.size()); EXPECT_EQ(0u, video_send_streams_.size());
@ -367,4 +366,8 @@ void FakeCall::SetBitrateConfig(
void FakeCall::SignalNetworkState(webrtc::NetworkState state) { void FakeCall::SignalNetworkState(webrtc::NetworkState state) {
network_state_ = state; network_state_ = state;
} }
void FakeCall::OnSentPacket(const rtc::SentPacket& sent_packet) {
last_sent_packet_ = sent_packet;
}
} // namespace cricket } // namespace cricket

View File

@ -164,6 +164,7 @@ class FakeCall : public webrtc::Call, public webrtc::PacketReceiver {
const std::vector<FakeAudioReceiveStream*>& GetAudioReceiveStreams(); const std::vector<FakeAudioReceiveStream*>& GetAudioReceiveStreams();
const FakeAudioReceiveStream* GetAudioReceiveStream(uint32_t ssrc); const FakeAudioReceiveStream* GetAudioReceiveStream(uint32_t ssrc);
rtc::SentPacket last_sent_packet() const { return last_sent_packet_; }
webrtc::NetworkState GetNetworkState() const; webrtc::NetworkState GetNetworkState() const;
int GetNumCreatedSendStreams() const; int GetNumCreatedSendStreams() const;
int GetNumCreatedReceiveStreams() const; int GetNumCreatedReceiveStreams() const;
@ -200,9 +201,11 @@ class FakeCall : public webrtc::Call, public webrtc::PacketReceiver {
void SetBitrateConfig( void SetBitrateConfig(
const webrtc::Call::Config::BitrateConfig& bitrate_config) override; const webrtc::Call::Config::BitrateConfig& bitrate_config) override;
void SignalNetworkState(webrtc::NetworkState state) override; void SignalNetworkState(webrtc::NetworkState state) override;
void OnSentPacket(const rtc::SentPacket& sent_packet) override;
webrtc::Call::Config config_; webrtc::Call::Config config_;
webrtc::NetworkState network_state_; webrtc::NetworkState network_state_;
rtc::SentPacket last_sent_packet_;
webrtc::Call::Stats stats_; webrtc::Call::Stats stats_;
std::vector<FakeVideoSendStream*> video_send_streams_; std::vector<FakeVideoSendStream*> video_send_streams_;
std::vector<FakeVideoReceiveStream*> video_receive_streams_; std::vector<FakeVideoReceiveStream*> video_receive_streams_;

View File

@ -557,6 +557,11 @@ WebRtcVideoEngine2::WebRtcVideoEngine2()
rtp_header_extensions_.push_back( rtp_header_extensions_.push_back(
RtpHeaderExtension(kRtpVideoRotationHeaderExtension, RtpHeaderExtension(kRtpVideoRotationHeaderExtension,
kRtpVideoRotationHeaderExtensionDefaultId)); kRtpVideoRotationHeaderExtensionDefaultId));
if (webrtc::field_trial::FindFullName("WebRTC-SendSideBwe") == "Enabled") {
rtp_header_extensions_.push_back(RtpHeaderExtension(
kRtpTransportSequenceNumberHeaderExtension,
kRtpTransportSequenceNumberHeaderExtensionDefaultId));
}
} }
WebRtcVideoEngine2::~WebRtcVideoEngine2() { WebRtcVideoEngine2::~WebRtcVideoEngine2() {
@ -1651,12 +1656,14 @@ bool WebRtcVideoChannel2::SendRtp(const uint8_t* data,
size_t len, size_t len,
const webrtc::PacketOptions& options) { const webrtc::PacketOptions& options) {
rtc::Buffer packet(data, len, kMaxRtpPacketLen); rtc::Buffer packet(data, len, kMaxRtpPacketLen);
return MediaChannel::SendPacket(&packet); rtc::PacketOptions rtc_options;
rtc_options.packet_id = options.packet_id;
return MediaChannel::SendPacket(&packet, rtc_options);
} }
bool WebRtcVideoChannel2::SendRtcp(const uint8_t* data, size_t len) { bool WebRtcVideoChannel2::SendRtcp(const uint8_t* data, size_t len) {
rtc::Buffer packet(data, len, kMaxRtpPacketLen); rtc::Buffer packet(data, len, kMaxRtpPacketLen);
return MediaChannel::SendRtcp(&packet); return MediaChannel::SendRtcp(&packet, rtc::PacketOptions());
} }
void WebRtcVideoChannel2::StartAllSendStreams() { void WebRtcVideoChannel2::StartAllSendStreams() {

View File

@ -40,6 +40,7 @@
#include "webrtc/base/arraysize.h" #include "webrtc/base/arraysize.h"
#include "webrtc/base/gunit.h" #include "webrtc/base/gunit.h"
#include "webrtc/base/stringutils.h" #include "webrtc/base/stringutils.h"
#include "webrtc/test/field_trial.h"
#include "webrtc/video_encoder.h" #include "webrtc/video_encoder.h"
namespace { namespace {
@ -108,9 +109,13 @@ void VerifySendStreamHasRtxTypes(const webrtc::VideoSendStream::Config& config,
namespace cricket { namespace cricket {
class WebRtcVideoEngine2Test : public ::testing::Test { class WebRtcVideoEngine2Test : public ::testing::Test {
public: public:
WebRtcVideoEngine2Test() : WebRtcVideoEngine2Test(nullptr) {} WebRtcVideoEngine2Test() : WebRtcVideoEngine2Test("") {}
WebRtcVideoEngine2Test(WebRtcVoiceEngine* voice_engine) explicit WebRtcVideoEngine2Test(const char* field_trials)
: call_(webrtc::Call::Create(webrtc::Call::Config())), : WebRtcVideoEngine2Test(nullptr, field_trials) {}
WebRtcVideoEngine2Test(WebRtcVoiceEngine* voice_engine,
const char* field_trials)
: override_field_trials_(field_trials),
call_(webrtc::Call::Create(webrtc::Call::Config())),
engine_() { engine_() {
std::vector<VideoCodec> engine_codecs = engine_.codecs(); std::vector<VideoCodec> engine_codecs = engine_.codecs();
RTC_DCHECK(!engine_codecs.empty()); RTC_DCHECK(!engine_codecs.empty());
@ -144,6 +149,7 @@ class WebRtcVideoEngine2Test : public ::testing::Test {
cricket::WebRtcVideoDecoderFactory* decoder_factory, cricket::WebRtcVideoDecoderFactory* decoder_factory,
const std::vector<VideoCodec>& codecs); const std::vector<VideoCodec>& codecs);
webrtc::test::ScopedFieldTrials override_field_trials_;
// Used in WebRtcVideoEngine2VoiceTest, but defined here so it's properly // Used in WebRtcVideoEngine2VoiceTest, but defined here so it's properly
// initialized when the constructor is called. // initialized when the constructor is called.
rtc::scoped_ptr<webrtc::Call> call_; rtc::scoped_ptr<webrtc::Call> call_;
@ -258,6 +264,26 @@ TEST_F(WebRtcVideoEngine2Test, SupportsAbsoluteSenderTimeHeaderExtension) {
FAIL() << "Absolute Sender Time extension not in header-extension list."; FAIL() << "Absolute Sender Time extension not in header-extension list.";
} }
class WebRtcVideoEngine2WithSendSideBweTest : public WebRtcVideoEngine2Test {
public:
WebRtcVideoEngine2WithSendSideBweTest()
: WebRtcVideoEngine2Test("WebRTC-SendSideBwe/Enabled/") {}
};
TEST_F(WebRtcVideoEngine2WithSendSideBweTest,
SupportsTransportSequenceNumberHeaderExtension) {
std::vector<RtpHeaderExtension> extensions = engine_.rtp_header_extensions();
ASSERT_FALSE(extensions.empty());
for (size_t i = 0; i < extensions.size(); ++i) {
if (extensions[i].uri == kRtpTransportSequenceNumberHeaderExtension) {
EXPECT_EQ(kRtpTransportSequenceNumberHeaderExtensionDefaultId,
extensions[i].id);
return;
}
}
FAIL() << "Transport sequence number extension not in header-extension list.";
}
TEST_F(WebRtcVideoEngine2Test, SupportsVideoRotationHeaderExtension) { TEST_F(WebRtcVideoEngine2Test, SupportsVideoRotationHeaderExtension) {
std::vector<RtpHeaderExtension> extensions = engine_.rtp_header_extensions(); std::vector<RtpHeaderExtension> extensions = engine_.rtp_header_extensions();
ASSERT_FALSE(extensions.empty()); ASSERT_FALSE(extensions.empty());
@ -895,7 +921,9 @@ TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_SendVp8HdAndReceiveAdaptedVp8Vga) {
class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test { class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test {
public: public:
WebRtcVideoChannel2Test() : last_ssrc_(0) {} WebRtcVideoChannel2Test() : WebRtcVideoChannel2Test("") {}
explicit WebRtcVideoChannel2Test(const char* field_trials)
: WebRtcVideoEngine2Test(field_trials), last_ssrc_(0) {}
void SetUp() override { void SetUp() override {
fake_call_.reset(new FakeCall(webrtc::Call::Config())); fake_call_.reset(new FakeCall(webrtc::Call::Config()));
engine_.Init(); engine_.Init();
@ -1171,6 +1199,26 @@ TEST_F(WebRtcVideoChannel2Test, RecvAbsoluteSendTimeHeaderExtensions) {
webrtc::RtpExtension::kAbsSendTime); webrtc::RtpExtension::kAbsSendTime);
} }
class WebRtcVideoChannel2WithSendSideBweTest : public WebRtcVideoChannel2Test {
public:
WebRtcVideoChannel2WithSendSideBweTest()
: WebRtcVideoChannel2Test("WebRTC-SendSideBwe/Enabled/") {}
};
// Test support for transport sequence number header extension.
TEST_F(WebRtcVideoChannel2WithSendSideBweTest,
SendTransportSequenceNumberHeaderExtensions) {
TestSetSendRtpHeaderExtensions(
kRtpTransportSequenceNumberHeaderExtension,
webrtc::RtpExtension::kTransportSequenceNumber);
}
TEST_F(WebRtcVideoChannel2WithSendSideBweTest,
RecvTransportSequenceNumberHeaderExtensions) {
TestSetRecvRtpHeaderExtensions(
kRtpTransportSequenceNumberHeaderExtension,
webrtc::RtpExtension::kTransportSequenceNumber);
}
// Test support for video rotation header extension. // Test support for video rotation header extension.
TEST_F(WebRtcVideoChannel2Test, SendVideoRotationHeaderExtensions) { TEST_F(WebRtcVideoChannel2Test, SendVideoRotationHeaderExtensions) {
TestSetSendRtpHeaderExtensions(kRtpVideoRotationHeaderExtension, TestSetSendRtpHeaderExtensions(kRtpVideoRotationHeaderExtension,

View File

@ -52,6 +52,7 @@
#include "webrtc/base/stringutils.h" #include "webrtc/base/stringutils.h"
#include "webrtc/common.h" #include "webrtc/common.h"
#include "webrtc/modules/audio_processing/include/audio_processing.h" #include "webrtc/modules/audio_processing/include/audio_processing.h"
#include "webrtc/system_wrappers/interface/field_trial.h"
namespace cricket { namespace cricket {
namespace { namespace {
@ -431,6 +432,11 @@ void WebRtcVoiceEngine::Construct() {
rtp_header_extensions_.push_back( rtp_header_extensions_.push_back(
RtpHeaderExtension(kRtpAbsoluteSenderTimeHeaderExtension, RtpHeaderExtension(kRtpAbsoluteSenderTimeHeaderExtension,
kRtpAbsoluteSenderTimeHeaderExtensionDefaultId)); kRtpAbsoluteSenderTimeHeaderExtensionDefaultId));
if (webrtc::field_trial::FindFullName("WebRTC-SendSideBwe") == "Enabled") {
rtp_header_extensions_.push_back(RtpHeaderExtension(
kRtpTransportSequenceNumberHeaderExtension,
kRtpTransportSequenceNumberHeaderExtensionDefaultId));
}
options_ = GetDefaultEngineOptions(); options_ = GetDefaultEngineOptions();
} }

View File

@ -226,13 +226,15 @@ class WebRtcVoiceMediaChannel : public VoiceMediaChannel,
const webrtc::PacketOptions& options) override { const webrtc::PacketOptions& options) override {
rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len, rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len,
kMaxRtpPacketLen); kMaxRtpPacketLen);
return VoiceMediaChannel::SendPacket(&packet); rtc::PacketOptions rtc_options;
rtc_options.packet_id = options.packet_id;
return VoiceMediaChannel::SendPacket(&packet, rtc_options);
} }
bool SendRtcp(const uint8_t* data, size_t len) override { bool SendRtcp(const uint8_t* data, size_t len) override {
rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len, rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len,
kMaxRtpPacketLen); kMaxRtpPacketLen);
return VoiceMediaChannel::SendRtcp(&packet); return VoiceMediaChannel::SendRtcp(&packet, rtc::PacketOptions());
} }
void OnError(int error); void OnError(int error);

View File

@ -67,7 +67,7 @@ static void SafeSetError(const std::string& message, std::string* error_desc) {
struct PacketMessageData : public rtc::MessageData { struct PacketMessageData : public rtc::MessageData {
rtc::Buffer packet; rtc::Buffer packet;
rtc::DiffServCodePoint dscp; rtc::PacketOptions options;
}; };
struct ScreencastEventMessageData : public rtc::MessageData { struct ScreencastEventMessageData : public rtc::MessageData {
@ -423,13 +423,13 @@ bool BaseChannel::IsReadyToSend() const {
} }
bool BaseChannel::SendPacket(rtc::Buffer* packet, bool BaseChannel::SendPacket(rtc::Buffer* packet,
rtc::DiffServCodePoint dscp) { const rtc::PacketOptions& options) {
return SendPacket(false, packet, dscp); return SendPacket(false, packet, options);
} }
bool BaseChannel::SendRtcp(rtc::Buffer* packet, bool BaseChannel::SendRtcp(rtc::Buffer* packet,
rtc::DiffServCodePoint dscp) { const rtc::PacketOptions& options) {
return SendPacket(true, packet, dscp); return SendPacket(true, packet, options);
} }
int BaseChannel::SetOption(SocketType type, rtc::Socket::Option opt, int BaseChannel::SetOption(SocketType type, rtc::Socket::Option opt,
@ -498,8 +498,9 @@ bool BaseChannel::PacketIsRtcp(const TransportChannel* channel,
rtcp_mux_filter_.DemuxRtcp(data, static_cast<int>(len))); rtcp_mux_filter_.DemuxRtcp(data, static_cast<int>(len)));
} }
bool BaseChannel::SendPacket(bool rtcp, rtc::Buffer* packet, bool BaseChannel::SendPacket(bool rtcp,
rtc::DiffServCodePoint dscp) { rtc::Buffer* packet,
const rtc::PacketOptions& options) {
// SendPacket gets called from MediaEngine, typically on an encoder thread. // SendPacket gets called from MediaEngine, typically on an encoder thread.
// If the thread is not our worker thread, we will post to our worker // 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 // so that the real work happens on our worker. This avoids us having to
@ -512,7 +513,7 @@ bool BaseChannel::SendPacket(bool rtcp, rtc::Buffer* packet,
int message_id = (!rtcp) ? MSG_RTPPACKET : MSG_RTCPPACKET; int message_id = (!rtcp) ? MSG_RTPPACKET : MSG_RTCPPACKET;
PacketMessageData* data = new PacketMessageData; PacketMessageData* data = new PacketMessageData;
data->packet = packet->Pass(); data->packet = packet->Pass();
data->dscp = dscp; data->options = options;
worker_thread_->Post(this, message_id, data); worker_thread_->Post(this, message_id, data);
return true; return true;
} }
@ -535,7 +536,8 @@ bool BaseChannel::SendPacket(bool rtcp, rtc::Buffer* packet,
return false; return false;
} }
rtc::PacketOptions options(dscp); rtc::PacketOptions updated_options;
updated_options = options;
// Protect if needed. // Protect if needed.
if (srtp_filter_.IsActive()) { if (srtp_filter_.IsActive()) {
bool res; bool res;
@ -551,21 +553,22 @@ bool BaseChannel::SendPacket(bool rtcp, rtc::Buffer* packet,
res = srtp_filter_.ProtectRtp( res = srtp_filter_.ProtectRtp(
data, len, static_cast<int>(packet->capacity()), &len); data, len, static_cast<int>(packet->capacity()), &len);
#else #else
options.packet_time_params.rtp_sendtime_extension_id = updated_options.packet_time_params.rtp_sendtime_extension_id =
rtp_abs_sendtime_extn_id_; rtp_abs_sendtime_extn_id_;
res = srtp_filter_.ProtectRtp( res = srtp_filter_.ProtectRtp(
data, len, static_cast<int>(packet->capacity()), &len, 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 protection succeeds, let's get auth params from srtp.
if (res) { if (res) {
uint8_t* auth_key = NULL; uint8_t* auth_key = NULL;
int key_len; int key_len;
res = srtp_filter_.GetRtpAuthParams( 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) { if (res) {
options.packet_time_params.srtp_auth_key.resize(key_len); updated_options.packet_time_params.srtp_auth_key.resize(key_len);
options.packet_time_params.srtp_auth_key.assign(auth_key, updated_options.packet_time_params.srtp_auth_key.assign(
auth_key + key_len); auth_key, auth_key + key_len);
} }
} }
#endif #endif
@ -605,7 +608,7 @@ bool BaseChannel::SendPacket(bool rtcp, rtc::Buffer* packet,
// Bon voyage. // Bon voyage.
int ret = int ret =
channel->SendPacket(packet->data<char>(), packet->size(), options, channel->SendPacket(packet->data<char>(), packet->size(), updated_options,
(secure() && secure_dtls()) ? PF_SRTP_BYPASS : 0); (secure() && secure_dtls()) ? PF_SRTP_BYPASS : 0);
if (ret != static_cast<int>(packet->size())) { if (ret != static_cast<int>(packet->size())) {
if (channel->GetError() == EWOULDBLOCK) { if (channel->GetError() == EWOULDBLOCK) {
@ -1143,7 +1146,7 @@ bool BaseChannel::UpdateLocalStreams_w(const std::vector<StreamParams>& streams,
it != streams.end(); ++it) { it != streams.end(); ++it) {
if (!GetStreamBySsrc(local_streams_, it->first_ssrc())) { if (!GetStreamBySsrc(local_streams_, it->first_ssrc())) {
if (media_channel()->AddSendStream(*it)) { if (media_channel()->AddSendStream(*it)) {
LOG(LS_INFO) << "Add send ssrc: " << it->ssrcs[0]; LOG(LS_INFO) << "Add send stream ssrc: " << it->ssrcs[0];
} else { } else {
std::ostringstream desc; std::ostringstream desc;
desc << "Failed to add send stream ssrc: " << it->first_ssrc(); desc << "Failed to add send stream ssrc: " << it->first_ssrc();
@ -1244,7 +1247,8 @@ void BaseChannel::OnMessage(rtc::Message *pmsg) {
case MSG_RTPPACKET: case MSG_RTPPACKET:
case MSG_RTCPPACKET: { case MSG_RTCPPACKET: {
PacketMessageData* data = static_cast<PacketMessageData*>(pmsg->pdata); PacketMessageData* data = static_cast<PacketMessageData*>(pmsg->pdata);
SendPacket(pmsg->message_id == MSG_RTCPPACKET, &data->packet, data->dscp); SendPacket(pmsg->message_id == MSG_RTCPPACKET, &data->packet,
data->options);
delete data; // because it is Posted delete data; // because it is Posted
break; break;
} }

View File

@ -199,9 +199,8 @@ class BaseChannel
// NetworkInterface implementation, called by MediaEngine // NetworkInterface implementation, called by MediaEngine
virtual bool SendPacket(rtc::Buffer* packet, virtual bool SendPacket(rtc::Buffer* packet,
rtc::DiffServCodePoint dscp); const rtc::PacketOptions& options);
virtual bool SendRtcp(rtc::Buffer* packet, virtual bool SendRtcp(rtc::Buffer* packet, const rtc::PacketOptions& options);
rtc::DiffServCodePoint dscp);
// From TransportChannel // From TransportChannel
void OnWritableState(TransportChannel* channel); void OnWritableState(TransportChannel* channel);
@ -214,8 +213,9 @@ class BaseChannel
bool PacketIsRtcp(const TransportChannel* channel, const char* data, bool PacketIsRtcp(const TransportChannel* channel, const char* data,
size_t len); size_t len);
bool SendPacket(bool rtcp, rtc::Buffer* packet, bool SendPacket(bool rtcp,
rtc::DiffServCodePoint dscp); rtc::Buffer* packet,
const rtc::PacketOptions& options);
virtual bool WantsPacket(bool rtcp, rtc::Buffer* packet); virtual bool WantsPacket(bool rtcp, rtc::Buffer* packet);
void HandlePacket(bool rtcp, rtc::Buffer* packet, void HandlePacket(bool rtcp, rtc::Buffer* packet,
const rtc::PacketTime& packet_time); const rtc::PacketTime& packet_time);
@ -261,7 +261,7 @@ class BaseChannel
// Helper method to get RTP Absoulute SendTime extension header id if // Helper method to get RTP Absoulute SendTime extension header id if
// present in remote supported extensions list. // present in remote supported extensions list.
void MaybeCacheRtpAbsSendTimeHeaderExtension( void MaybeCacheRtpAbsSendTimeHeaderExtension(
const std::vector<RtpHeaderExtension>& extensions); const std::vector<RtpHeaderExtension>& extensions);
bool CheckSrtpConfig(const std::vector<CryptoParams>& cryptos, bool CheckSrtpConfig(const std::vector<CryptoParams>& cryptos,
bool* dtls, bool* dtls,
@ -470,8 +470,6 @@ class VideoChannel : public BaseChannel {
bool SendIntraFrame(); bool SendIntraFrame();
bool RequestIntraFrame(); bool RequestIntraFrame();
// Configure sending media on the stream with SSRC |ssrc|
// If there is only one sending stream SSRC 0 can be used.
bool SetVideoSend(uint32_t ssrc, bool enable, const VideoOptions* options); bool SetVideoSend(uint32_t ssrc, bool enable, const VideoOptions* options);
private: private:

View File

@ -294,11 +294,13 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
bool SendRtp1() { bool SendRtp1() {
return media_channel1_->SendRtp(rtp_packet_.c_str(), return media_channel1_->SendRtp(rtp_packet_.c_str(),
static_cast<int>(rtp_packet_.size())); static_cast<int>(rtp_packet_.size()),
rtc::PacketOptions());
} }
bool SendRtp2() { bool SendRtp2() {
return media_channel2_->SendRtp(rtp_packet_.c_str(), return media_channel2_->SendRtp(rtp_packet_.c_str(),
static_cast<int>(rtp_packet_.size())); static_cast<int>(rtp_packet_.size()),
rtc::PacketOptions());
} }
bool SendRtcp1() { bool SendRtcp1() {
return media_channel1_->SendRtcp(rtcp_packet_.c_str(), return media_channel1_->SendRtcp(rtcp_packet_.c_str(),
@ -311,13 +313,13 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
// Methods to send custom data. // Methods to send custom data.
bool SendCustomRtp1(uint32_t ssrc, int sequence_number, int pl_type = -1) { bool SendCustomRtp1(uint32_t ssrc, int sequence_number, int pl_type = -1) {
std::string data(CreateRtpData(ssrc, sequence_number, pl_type)); std::string data(CreateRtpData(ssrc, sequence_number, pl_type));
return media_channel1_->SendRtp(data.c_str(), return media_channel1_->SendRtp(data.c_str(), static_cast<int>(data.size()),
static_cast<int>(data.size())); rtc::PacketOptions());
} }
bool SendCustomRtp2(uint32_t ssrc, int sequence_number, int pl_type = -1) { bool SendCustomRtp2(uint32_t ssrc, int sequence_number, int pl_type = -1) {
std::string data(CreateRtpData(ssrc, sequence_number, pl_type)); std::string data(CreateRtpData(ssrc, sequence_number, pl_type));
return media_channel2_->SendRtp(data.c_str(), return media_channel2_->SendRtp(data.c_str(), static_cast<int>(data.size()),
static_cast<int>(data.size())); rtc::PacketOptions());
} }
bool SendCustomRtcp1(uint32_t ssrc) { bool SendCustomRtcp1(uint32_t ssrc) {
std::string data(CreateRtcpData(ssrc)); std::string data(CreateRtcpData(ssrc));
@ -957,7 +959,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
public: public:
LastWordMediaChannel() : T::MediaChannel(NULL, typename T::Options()) {} LastWordMediaChannel() : T::MediaChannel(NULL, typename T::Options()) {}
~LastWordMediaChannel() { ~LastWordMediaChannel() {
T::MediaChannel::SendRtp(kPcmuFrame, sizeof(kPcmuFrame)); T::MediaChannel::SendRtp(kPcmuFrame, sizeof(kPcmuFrame),
rtc::PacketOptions());
T::MediaChannel::SendRtcp(kRtcpReport, sizeof(kRtcpReport)); T::MediaChannel::SendRtcp(kRtcpReport, sizeof(kRtcpReport));
} }
}; };
@ -1709,21 +1712,24 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
&error_handler, &SrtpErrorHandler::OnSrtpError); &error_handler, &SrtpErrorHandler::OnSrtpError);
// Testing failures in sending packets. // Testing failures in sending packets.
EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket))); EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket),
rtc::PacketOptions()));
// The first failure will trigger an error. // The first failure will trigger an error.
EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500); EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500);
EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_); EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_);
error_handler.error_ = cricket::SrtpFilter::ERROR_NONE; error_handler.error_ = cricket::SrtpFilter::ERROR_NONE;
error_handler.mode_ = cricket::SrtpFilter::UNPROTECT; error_handler.mode_ = cricket::SrtpFilter::UNPROTECT;
// The next 250 ms failures will not trigger an error. // The next 250 ms failures will not trigger an error.
EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket))); EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket),
rtc::PacketOptions()));
// Wait for a while to ensure no message comes in. // Wait for a while to ensure no message comes in.
rtc::Thread::Current()->ProcessMessages(200); rtc::Thread::Current()->ProcessMessages(200);
EXPECT_EQ(cricket::SrtpFilter::ERROR_NONE, error_handler.error_); EXPECT_EQ(cricket::SrtpFilter::ERROR_NONE, error_handler.error_);
EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_); EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_);
// Wait for a little more - the error will be triggered again. // Wait for a little more - the error will be triggered again.
rtc::Thread::Current()->ProcessMessages(200); rtc::Thread::Current()->ProcessMessages(200);
EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket))); EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket),
rtc::PacketOptions()));
EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500); EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500);
EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_); EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_);

View File

@ -25,7 +25,7 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "talk/app/webrtc/mediacontroller.h" #include "talk/app/webrtc/fakemediacontroller.h"
#include "talk/media/base/fakecapturemanager.h" #include "talk/media/base/fakecapturemanager.h"
#include "talk/media/base/fakemediaengine.h" #include "talk/media/base/fakemediaengine.h"
#include "talk/media/base/fakevideocapturer.h" #include "talk/media/base/fakevideocapturer.h"
@ -50,37 +50,24 @@ static const VideoCodec kVideoCodecs[] = {
VideoCodec(96, "rtx", 100, 200, 300, 0), VideoCodec(96, "rtx", 100, 200, 300, 0),
}; };
class FakeMediaController : public webrtc::MediaControllerInterface {
public:
explicit FakeMediaController(webrtc::Call* call) : call_(call) {
RTC_DCHECK(nullptr != call);
}
~FakeMediaController() override {}
webrtc::Call* call_w() override { return call_; }
private:
webrtc::Call* call_;
};
class ChannelManagerTest : public testing::Test { class ChannelManagerTest : public testing::Test {
protected: protected:
ChannelManagerTest() ChannelManagerTest()
: fake_call_(webrtc::Call::Config()), : fme_(new cricket::FakeMediaEngine()),
fake_mc_(&fake_call_), fdme_(new cricket::FakeDataEngine()),
fme_(NULL), fcm_(new cricket::FakeCaptureManager()),
fcm_(NULL), cm_(new cricket::ChannelManager(fme_,
cm_(NULL) {} fdme_,
fcm_,
rtc::Thread::Current())),
fake_call_(webrtc::Call::Config()),
fake_mc_(cm_, &fake_call_),
transport_controller_(
new cricket::FakeTransportController(ICEROLE_CONTROLLING)) {}
virtual void SetUp() { virtual void SetUp() {
fme_ = new cricket::FakeMediaEngine();
fme_->SetAudioCodecs(MAKE_VECTOR(kAudioCodecs)); fme_->SetAudioCodecs(MAKE_VECTOR(kAudioCodecs));
fme_->SetVideoCodecs(MAKE_VECTOR(kVideoCodecs)); fme_->SetVideoCodecs(MAKE_VECTOR(kVideoCodecs));
fdme_ = new cricket::FakeDataEngine();
fcm_ = new cricket::FakeCaptureManager();
cm_ = new cricket::ChannelManager(
fme_, fdme_, fcm_, rtc::Thread::Current());
transport_controller_ =
new cricket::FakeTransportController(ICEROLE_CONTROLLING);
} }
virtual void TearDown() { virtual void TearDown() {
@ -93,12 +80,12 @@ class ChannelManagerTest : public testing::Test {
} }
rtc::Thread worker_; rtc::Thread worker_;
cricket::FakeCall fake_call_;
cricket::FakeMediaController fake_mc_;
cricket::FakeMediaEngine* fme_; cricket::FakeMediaEngine* fme_;
cricket::FakeDataEngine* fdme_; cricket::FakeDataEngine* fdme_;
cricket::FakeCaptureManager* fcm_; cricket::FakeCaptureManager* fcm_;
cricket::ChannelManager* cm_; cricket::ChannelManager* cm_;
cricket::FakeCall fake_call_;
cricket::FakeMediaController fake_mc_;
cricket::FakeTransportController* transport_controller_; cricket::FakeTransportController* transport_controller_;
}; };

View File

@ -34,10 +34,11 @@ struct PacketTimeUpdateParams {
// This structure holds meta information for the packet which is about to send // This structure holds meta information for the packet which is about to send
// over network. // over network.
struct PacketOptions { struct PacketOptions {
PacketOptions() : dscp(DSCP_NO_CHANGE) {} PacketOptions() : dscp(DSCP_NO_CHANGE), packet_id(-1) {}
explicit PacketOptions(DiffServCodePoint dscp) : dscp(dscp) {} explicit PacketOptions(DiffServCodePoint dscp) : dscp(dscp), packet_id(-1) {}
DiffServCodePoint dscp; DiffServCodePoint dscp;
int packet_id; // 16 bits, -1 represents "not set".
PacketTimeUpdateParams packet_time_params; PacketTimeUpdateParams packet_time_params;
}; };
@ -109,6 +110,9 @@ class AsyncPacketSocket : public sigslot::has_slots<> {
const SocketAddress&, const SocketAddress&,
const PacketTime&> SignalReadPacket; const PacketTime&> SignalReadPacket;
// Emitted each time a packet is sent.
sigslot::signal2<AsyncPacketSocket*, const SentPacket&> SignalSentPacket;
// Emitted when the socket is currently able to send. // Emitted when the socket is currently able to send.
sigslot::signal1<AsyncPacketSocket*> SignalReadyToSend; sigslot::signal1<AsyncPacketSocket*> SignalReadyToSend;

View File

@ -268,6 +268,9 @@ int AsyncTCPSocket::Send(const void *pv, size_t cb,
return res; return res;
} }
rtc::SentPacket sent_packet(options.packet_id, rtc::Time());
SignalSentPacket(this, sent_packet);
// We claim to have sent the whole thing, even if we only sent partial // We claim to have sent the whole thing, even if we only sent partial
return static_cast<int>(cb); return static_cast<int>(cb);
} }

View File

@ -60,13 +60,19 @@ SocketAddress AsyncUDPSocket::GetRemoteAddress() const {
int AsyncUDPSocket::Send(const void *pv, size_t cb, int AsyncUDPSocket::Send(const void *pv, size_t cb,
const rtc::PacketOptions& options) { const rtc::PacketOptions& options) {
return socket_->Send(pv, cb); rtc::SentPacket sent_packet(options.packet_id, rtc::Time());
int ret = socket_->Send(pv, cb);
SignalSentPacket(this, sent_packet);
return ret;
} }
int AsyncUDPSocket::SendTo(const void *pv, size_t cb, int AsyncUDPSocket::SendTo(const void *pv, size_t cb,
const SocketAddress& addr, const SocketAddress& addr,
const rtc::PacketOptions& options) { const rtc::PacketOptions& options) {
return socket_->SendTo(pv, cb, addr); rtc::SentPacket sent_packet(options.packet_id, rtc::Time());
int ret = socket_->SendTo(pv, cb, addr);
SignalSentPacket(this, sent_packet);
return ret;
} }
int AsyncUDPSocket::Close() { int AsyncUDPSocket::Close() {

View File

@ -29,6 +29,7 @@
'dependencies': [ 'dependencies': [
'base.gyp:rtc_base', 'base.gyp:rtc_base',
'<(DEPTH)/testing/gtest.gyp:gtest', '<(DEPTH)/testing/gtest.gyp:gtest',
'<(webrtc_root)/test/test.gyp:field_trial',
], ],
'direct_dependent_settings': { 'direct_dependent_settings': {
'defines': [ 'defines': [

View File

@ -124,6 +124,15 @@ inline bool IsBlockingError(int e) {
return (e == EWOULDBLOCK) || (e == EAGAIN) || (e == EINPROGRESS); return (e == EWOULDBLOCK) || (e == EAGAIN) || (e == EINPROGRESS);
} }
struct SentPacket {
SentPacket() : packet_id(-1), send_time_ms(-1) {}
SentPacket(int packet_id, int64_t send_time_ms)
: packet_id(packet_id), send_time_ms(send_time_ms) {}
int packet_id;
int64_t send_time_ms;
};
// General interface for the socket implementations of various networks. The // General interface for the socket implementations of various networks. The
// methods match those of normal UNIX sockets very closely. // methods match those of normal UNIX sockets very closely.
class Socket { class Socket {

View File

@ -19,9 +19,16 @@
#include "webrtc/base/gunit.h" #include "webrtc/base/gunit.h"
#include "webrtc/base/logging.h" #include "webrtc/base/logging.h"
#include "webrtc/base/ssladapter.h" #include "webrtc/base/ssladapter.h"
#include "webrtc/test/field_trial.h"
DEFINE_bool(help, false, "prints this message"); DEFINE_bool(help, false, "prints this message");
DEFINE_string(log, "", "logging options to use"); DEFINE_string(log, "", "logging options to use");
DEFINE_string(
force_fieldtrials,
"",
"Field trials control experimental feature code which can be forced. "
"E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
" will assign the group Enable to field trial WebRTC-FooFeature.");
#if defined(WEBRTC_WIN) #if defined(WEBRTC_WIN)
DEFINE_int(crt_break_alloc, -1, "memory allocation to break on"); DEFINE_int(crt_break_alloc, -1, "memory allocation to break on");
DEFINE_bool(default_error_handlers, false, DEFINE_bool(default_error_handlers, false,
@ -61,6 +68,8 @@ int main(int argc, char** argv) {
return 0; return 0;
} }
webrtc::test::InitFieldTrialsFromString(FLAG_force_fieldtrials);
#if defined(WEBRTC_WIN) #if defined(WEBRTC_WIN)
if (!FLAG_default_error_handlers) { if (!FLAG_default_error_handlers) {
// Make sure any errors don't throw dialogs hanging the test run. // Make sure any errors don't throw dialogs hanging the test run.

View File

@ -16,6 +16,7 @@
#include "webrtc/common_types.h" #include "webrtc/common_types.h"
#include "webrtc/audio_receive_stream.h" #include "webrtc/audio_receive_stream.h"
#include "webrtc/audio_send_stream.h" #include "webrtc/audio_send_stream.h"
#include "webrtc/base/socket.h"
#include "webrtc/video_receive_stream.h" #include "webrtc/video_receive_stream.h"
#include "webrtc/video_send_stream.h" #include "webrtc/video_send_stream.h"
@ -137,6 +138,8 @@ class Call {
const Config::BitrateConfig& bitrate_config) = 0; const Config::BitrateConfig& bitrate_config) = 0;
virtual void SignalNetworkState(NetworkState state) = 0; virtual void SignalNetworkState(NetworkState state) = 0;
virtual void OnSentPacket(const rtc::SentPacket& sent_packet) = 0;
virtual ~Call() {} virtual ~Call() {}
}; };

View File

@ -77,6 +77,8 @@ class Call : public webrtc::Call, public PacketReceiver {
const webrtc::Call::Config::BitrateConfig& bitrate_config) override; const webrtc::Call::Config::BitrateConfig& bitrate_config) override;
void SignalNetworkState(NetworkState state) override; void SignalNetworkState(NetworkState state) override;
void OnSentPacket(const rtc::SentPacket& sent_packet) override;
private: private:
DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet, DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet,
size_t length); size_t length);
@ -411,6 +413,10 @@ void Call::SignalNetworkState(NetworkState state) {
} }
} }
void Call::OnSentPacket(const rtc::SentPacket& sent_packet) {
channel_group_->OnSentPacket(sent_packet);
}
void Call::ConfigureSync(const std::string& sync_group) { void Call::ConfigureSync(const std::string& sync_group) {
// Set sync only if there was no previous one. // Set sync only if there was no previous one.
if (config_.voice_engine == nullptr || sync_group.empty()) if (config_.voice_engine == nullptr || sync_group.empty())

View File

@ -36,7 +36,7 @@ const char* RtpExtension::kVideoRotation = "urn:3gpp:video-orientation";
const char* RtpExtension::kAudioLevel = const char* RtpExtension::kAudioLevel =
"urn:ietf:params:rtp-hdrext:ssrc-audio-level"; "urn:ietf:params:rtp-hdrext:ssrc-audio-level";
const char* RtpExtension::kTransportSequenceNumber = const char* RtpExtension::kTransportSequenceNumber =
"http://www.webrtc.org/experiments/rtp-hdrext/transport-sequence-number"; "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions";
bool RtpExtension::IsSupportedForAudio(const std::string& name) { bool RtpExtension::IsSupportedForAudio(const std::string& name) {
return name == webrtc::RtpExtension::kAbsSendTime || return name == webrtc::RtpExtension::kAbsSendTime ||

View File

@ -81,6 +81,7 @@
], ],
'dependencies': [ 'dependencies': [
'../talk/libjingle.gyp:libjingle_peerconnection', '../talk/libjingle.gyp:libjingle_peerconnection',
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:field_trial_default',
'<@(libjingle_tests_additional_deps)', '<@(libjingle_tests_additional_deps)',
], ],
'conditions': [ 'conditions': [
@ -139,6 +140,7 @@
'target_name': 'apprtc_common', 'target_name': 'apprtc_common',
'type': 'static_library', 'type': 'static_library',
'dependencies': [ 'dependencies': [
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:field_trial_default',
'../talk/libjingle.gyp:libjingle_peerconnection_objc', '../talk/libjingle.gyp:libjingle_peerconnection_objc',
], ],
'sources': [ 'sources': [

View File

@ -49,11 +49,17 @@ void TransportFeedbackAdapter::SetBitrateEstimator(
} }
} }
void TransportFeedbackAdapter::OnPacketSent(const PacketInfo& info) { void TransportFeedbackAdapter::OnSentPacket(const PacketInfo& info) {
rtc::CritScope cs(&lock_); rtc::CritScope cs(&lock_);
send_time_history_.AddAndRemoveOld(info); send_time_history_.AddAndRemoveOld(info);
} }
void TransportFeedbackAdapter::UpdateSendTime(uint16_t sequence_number,
int64_t send_time_ms) {
rtc::CritScope cs(&lock_);
send_time_history_.UpdateSendTime(sequence_number, send_time_ms);
}
void TransportFeedbackAdapter::OnTransportFeedback( void TransportFeedbackAdapter::OnTransportFeedback(
const rtcp::TransportFeedback& feedback) { const rtcp::TransportFeedback& feedback) {
int64_t timestamp_us = feedback.GetBaseTimeUs(); int64_t timestamp_us = feedback.GetBaseTimeUs();

View File

@ -33,7 +33,9 @@ class TransportFeedbackAdapter : public TransportFeedbackObserver,
ProcessThread* process_thread); ProcessThread* process_thread);
virtual ~TransportFeedbackAdapter(); virtual ~TransportFeedbackAdapter();
void OnPacketSent(const PacketInfo& info) override; void OnSentPacket(const PacketInfo& info) override;
void UpdateSendTime(uint16_t sequence_number, int64_t send_time_ms);
void OnTransportFeedback(const rtcp::TransportFeedback& feedback) override; void OnTransportFeedback(const rtcp::TransportFeedback& feedback) override;

View File

@ -103,9 +103,9 @@ class TransportFeedbackAdapterTest : public ::testing::Test {
} }
// Utility method, to reset arrival_time_ms before adding send time. // Utility method, to reset arrival_time_ms before adding send time.
void OnPacketSent(PacketInfo info) { void OnSentPacket(PacketInfo info) {
info.arrival_time_ms = 0; info.arrival_time_ms = 0;
adapter_->OnPacketSent(info); adapter_->OnSentPacket(info);
} }
SimulatedClock clock_; SimulatedClock clock_;
@ -125,7 +125,7 @@ TEST_F(TransportFeedbackAdapterTest, AdaptsFeedbackAndPopulatesSendTimes) {
packets.push_back(PacketInfo(140, 240, 4, 1500, true)); packets.push_back(PacketInfo(140, 240, 4, 1500, true));
for (const PacketInfo& packet : packets) for (const PacketInfo& packet : packets)
OnPacketSent(packet); OnSentPacket(packet);
rtcp::TransportFeedback feedback; rtcp::TransportFeedback feedback;
feedback.WithBase(packets[0].sequence_number, feedback.WithBase(packets[0].sequence_number,
@ -160,7 +160,7 @@ TEST_F(TransportFeedbackAdapterTest, HandlesDroppedPackets) {
for (const PacketInfo& packet : packets) { for (const PacketInfo& packet : packets) {
if (packet.sequence_number >= kSendSideDropBefore) if (packet.sequence_number >= kSendSideDropBefore)
OnPacketSent(packet); OnSentPacket(packet);
} }
rtcp::TransportFeedback feedback; rtcp::TransportFeedback feedback;
@ -199,7 +199,7 @@ TEST_F(TransportFeedbackAdapterTest, SendTimeWrapsBothWays) {
packets.push_back(PacketInfo(kHighArrivalTimeMs, 220, 2, 1500, true)); packets.push_back(PacketInfo(kHighArrivalTimeMs, 220, 2, 1500, true));
for (const PacketInfo& packet : packets) for (const PacketInfo& packet : packets)
OnPacketSent(packet); OnSentPacket(packet);
for (size_t i = 0; i < packets.size(); ++i) { for (size_t i = 0; i < packets.size(); ++i) {
rtc::scoped_ptr<rtcp::TransportFeedback> feedback( rtc::scoped_ptr<rtcp::TransportFeedback> feedback(
@ -263,8 +263,8 @@ TEST_F(TransportFeedbackAdapterTest, TimestampDeltas) {
// Packets will be added to send history. // Packets will be added to send history.
for (const PacketInfo& packet : sent_packets) for (const PacketInfo& packet : sent_packets)
OnPacketSent(packet); OnSentPacket(packet);
OnPacketSent(info); OnSentPacket(info);
// Create expected feedback and send into adapter. // Create expected feedback and send into adapter.
rtc::scoped_ptr<rtcp::TransportFeedback> feedback( rtc::scoped_ptr<rtcp::TransportFeedback> feedback(

View File

@ -313,7 +313,7 @@ class TransportFeedbackObserver {
// Note: Transport-wide sequence number as sequence number. Arrival time // Note: Transport-wide sequence number as sequence number. Arrival time
// must be set to 0. // must be set to 0.
virtual void OnPacketSent(const PacketInfo& info) = 0; virtual void OnSentPacket(const PacketInfo& info) = 0;
virtual void OnTransportFeedback(const rtcp::TransportFeedback& feedback) = 0; virtual void OnTransportFeedback(const rtcp::TransportFeedback& feedback) = 0;
}; };

View File

@ -672,8 +672,8 @@ size_t RTPSender::SendPadData(size_t bytes,
break; break;
if (using_transport_seq && transport_feedback_observer_) { if (using_transport_seq && transport_feedback_observer_) {
transport_feedback_observer_->OnPacketSent(PacketInfo( transport_feedback_observer_->OnSentPacket(
0, now_ms, options.packet_id, length, true)); PacketInfo(0, now_ms, options.packet_id, length, true));
} }
bytes_sent += padding_bytes_in_packet; bytes_sent += padding_bytes_in_packet;
@ -934,7 +934,7 @@ bool RTPSender::PrepareAndSendPacket(uint8_t* buffer,
media_has_been_sent_ = true; media_has_been_sent_ = true;
} }
if (using_transport_seq && transport_feedback_observer_) { if (using_transport_seq && transport_feedback_observer_) {
transport_feedback_observer_->OnPacketSent( transport_feedback_observer_->OnSentPacket(
PacketInfo(0, now_ms, options.packet_id, length, true)); PacketInfo(0, now_ms, options.packet_id, length, true));
} }
UpdateRtpStats(buffer_to_send_ptr, length, rtp_header, send_over_rtx, UpdateRtpStats(buffer_to_send_ptr, length, rtp_header, send_over_rtx,

View File

@ -101,6 +101,8 @@ DtlsTransportChannelWrapper::DtlsTransportChannelWrapper(
&DtlsTransportChannelWrapper::OnWritableState); &DtlsTransportChannelWrapper::OnWritableState);
channel_->SignalReadPacket.connect(this, channel_->SignalReadPacket.connect(this,
&DtlsTransportChannelWrapper::OnReadPacket); &DtlsTransportChannelWrapper::OnReadPacket);
channel_->SignalSentPacket.connect(
this, &DtlsTransportChannelWrapper::OnSentPacket);
channel_->SignalReadyToSend.connect(this, channel_->SignalReadyToSend.connect(this,
&DtlsTransportChannelWrapper::OnReadyToSend); &DtlsTransportChannelWrapper::OnReadyToSend);
channel_->SignalGatheringState.connect( channel_->SignalGatheringState.connect(
@ -510,6 +512,14 @@ void DtlsTransportChannelWrapper::OnReadPacket(
} }
} }
void DtlsTransportChannelWrapper::OnSentPacket(
TransportChannel* channel,
const rtc::SentPacket& sent_packet) {
ASSERT(rtc::Thread::Current() == worker_thread_);
SignalSentPacket(this, sent_packet);
}
void DtlsTransportChannelWrapper::OnReadyToSend(TransportChannel* channel) { void DtlsTransportChannelWrapper::OnReadyToSend(TransportChannel* channel) {
if (writable()) { if (writable()) {
SignalReadyToSend(this); SignalReadyToSend(this);

View File

@ -209,6 +209,8 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl {
void OnWritableState(TransportChannel* channel); void OnWritableState(TransportChannel* channel);
void OnReadPacket(TransportChannel* channel, const char* data, size_t size, void OnReadPacket(TransportChannel* channel, const char* data, size_t size,
const rtc::PacketTime& packet_time, int flags); const rtc::PacketTime& packet_time, int flags);
void OnSentPacket(TransportChannel* channel,
const rtc::SentPacket& sent_packet);
void OnReadyToSend(TransportChannel* channel); void OnReadyToSend(TransportChannel* channel);
void OnReceivingState(TransportChannel* channel); void OnReceivingState(TransportChannel* channel);
void OnDtlsEvent(rtc::StreamInterface* stream_, int sig, int err); void OnDtlsEvent(rtc::StreamInterface* stream_, int sig, int err);
@ -223,7 +225,8 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl {
Transport* transport_; // The transport_ that created us. Transport* transport_; // The transport_ that created us.
rtc::Thread* worker_thread_; // Everything should occur on this thread. rtc::Thread* worker_thread_; // Everything should occur on this thread.
TransportChannelImpl* channel_; // Underlying channel, owned by transport_. // Underlying channel, owned by transport_.
TransportChannelImpl* const channel_;
rtc::scoped_ptr<rtc::SSLStreamAdapter> dtls_; // The DTLS stream rtc::scoped_ptr<rtc::SSLStreamAdapter> dtls_; // The DTLS stream
StreamInterfaceChannel* downward_; // Wrapper for channel_, owned by dtls_. StreamInterfaceChannel* downward_; // Wrapper for channel_, owned by dtls_.
std::vector<std::string> srtp_ciphers_; // SRTP ciphers to use with DTLS. std::vector<std::string> srtp_ciphers_; // SRTP ciphers to use with DTLS.

View File

@ -33,6 +33,7 @@ static const char kIceUfrag1[] = "TESTICEUFRAG0001";
static const char kIcePwd1[] = "TESTICEPWD00000000000001"; static const char kIcePwd1[] = "TESTICEPWD00000000000001";
static const size_t kPacketNumOffset = 8; static const size_t kPacketNumOffset = 8;
static const size_t kPacketHeaderLen = 12; static const size_t kPacketHeaderLen = 12;
static const int kFakePacketId = 0x1234;
static bool IsRtpLeadByte(uint8_t b) { static bool IsRtpLeadByte(uint8_t b) {
return ((b & 0xC0) == 0x80); return ((b & 0xC0) == 0x80);
@ -86,6 +87,8 @@ class DtlsTestClient : public sigslot::has_slots<> {
&DtlsTestClient::OnTransportChannelWritableState); &DtlsTestClient::OnTransportChannelWritableState);
channel->SignalReadPacket.connect(this, channel->SignalReadPacket.connect(this,
&DtlsTestClient::OnTransportChannelReadPacket); &DtlsTestClient::OnTransportChannelReadPacket);
channel->SignalSentPacket.connect(
this, &DtlsTestClient::OnTransportChannelSentPacket);
channels_.push_back(channel); channels_.push_back(channel);
// Hook the raw packets so that we can verify they are encrypted. // Hook the raw packets so that we can verify they are encrypted.
@ -259,6 +262,7 @@ class DtlsTestClient : public sigslot::has_slots<> {
// Only set the bypass flag if we've activated DTLS. // Only set the bypass flag if we've activated DTLS.
int flags = (certificate_ && srtp) ? cricket::PF_SRTP_BYPASS : 0; int flags = (certificate_ && srtp) ? cricket::PF_SRTP_BYPASS : 0;
rtc::PacketOptions packet_options; rtc::PacketOptions packet_options;
packet_options.packet_id = kFakePacketId;
int rv = channels_[channel]->SendPacket( int rv = channels_[channel]->SendPacket(
packet.get(), size, packet_options, flags); packet.get(), size, packet_options, flags);
ASSERT_GT(rv, 0); ASSERT_GT(rv, 0);
@ -338,6 +342,13 @@ class DtlsTestClient : public sigslot::has_slots<> {
ASSERT_EQ(expected_flags, flags); ASSERT_EQ(expected_flags, flags);
} }
void OnTransportChannelSentPacket(cricket::TransportChannel* channel,
const rtc::SentPacket& sent_packet) {
sent_packet_ = sent_packet;
}
rtc::SentPacket sent_packet() const { return sent_packet_; }
// Hook into the raw packet stream to make sure DTLS packets are encrypted. // Hook into the raw packet stream to make sure DTLS packets are encrypted.
void OnFakeTransportChannelReadPacket(cricket::TransportChannel* channel, void OnFakeTransportChannelReadPacket(cricket::TransportChannel* channel,
const char* data, size_t size, const char* data, size_t size,
@ -378,6 +389,7 @@ class DtlsTestClient : public sigslot::has_slots<> {
bool negotiated_dtls_; bool negotiated_dtls_;
bool received_dtls_client_hello_; bool received_dtls_client_hello_;
bool received_dtls_server_hello_; bool received_dtls_server_hello_;
rtc::SentPacket sent_packet_;
}; };
@ -558,6 +570,15 @@ TEST_F(DtlsTransportChannelTest, TestTransfer) {
TestTransfer(0, 1000, 100, false); TestTransfer(0, 1000, 100, false);
} }
// Connect without DTLS, and transfer some data.
TEST_F(DtlsTransportChannelTest, TestOnSentPacket) {
ASSERT_TRUE(Connect());
EXPECT_EQ(client1_.sent_packet().send_time_ms, -1);
TestTransfer(0, 1000, 100, false);
EXPECT_EQ(kFakePacketId, client1_.sent_packet().packet_id);
EXPECT_GE(client1_.sent_packet().send_time_ms, 0);
}
// Create two channels without DTLS, and transfer some data. // Create two channels without DTLS, and transfer some data.
TEST_F(DtlsTransportChannelTest, TestTransferTwoChannels) { TEST_F(DtlsTransportChannelTest, TestTransferTwoChannels) {
SetChannelCount(2); SetChannelCount(2);

View File

@ -31,10 +31,12 @@ namespace cricket {
class FakeTransport; class FakeTransport;
namespace {
struct PacketMessageData : public rtc::MessageData { struct PacketMessageData : public rtc::MessageData {
PacketMessageData(const char* data, size_t len) : packet(data, len) {} PacketMessageData(const char* data, size_t len) : packet(data, len) {}
rtc::Buffer packet; rtc::Buffer packet;
}; };
} // namespace
// Fake transport channel class, which can be passed to anything that needs a // Fake transport channel class, which can be passed to anything that needs a
// transport channel. Can be informed of another FakeTransportChannel via // transport channel. Can be informed of another FakeTransportChannel via
@ -208,6 +210,8 @@ class FakeTransportChannel : public TransportChannelImpl,
} else { } else {
rtc::Thread::Current()->Send(this, 0, packet); rtc::Thread::Current()->Send(this, 0, packet);
} }
rtc::SentPacket sent_packet(options.packet_id, rtc::Time());
SignalSentPacket(this, sent_packet);
return static_cast<int>(len); return static_cast<int>(len);
} }
int SetOption(rtc::Socket::Option opt, int value) override { return true; } int SetOption(rtc::Socket::Option opt, int value) override { return true; }

View File

@ -435,6 +435,7 @@ void P2PTransportChannel::OnPortReady(PortAllocatorSession *session,
port->SignalDestroyed.connect(this, &P2PTransportChannel::OnPortDestroyed); port->SignalDestroyed.connect(this, &P2PTransportChannel::OnPortDestroyed);
port->SignalRoleConflict.connect( port->SignalRoleConflict.connect(
this, &P2PTransportChannel::OnRoleConflict); this, &P2PTransportChannel::OnRoleConflict);
port->SignalSentPacket.connect(this, &P2PTransportChannel::OnSentPacket);
// Attempt to create a connection from this new port to all of the remote // Attempt to create a connection from this new port to all of the remote
// candidates that we were given so far. // candidates that we were given so far.
@ -1356,6 +1357,13 @@ void P2PTransportChannel::OnReadPacket(Connection* connection,
} }
} }
void P2PTransportChannel::OnSentPacket(PortInterface* port,
const rtc::SentPacket& sent_packet) {
ASSERT(worker_thread_ == rtc::Thread::Current());
SignalSentPacket(this, sent_packet);
}
void P2PTransportChannel::OnReadyToSend(Connection* connection) { void P2PTransportChannel::OnReadyToSend(Connection* connection) {
if (connection == best_connection_ && writable()) { if (connection == best_connection_ && writable()) {
SignalReadyToSend(this); SignalReadyToSend(this);

View File

@ -207,6 +207,7 @@ class P2PTransportChannel : public TransportChannelImpl,
void OnConnectionStateChange(Connection* connection); void OnConnectionStateChange(Connection* connection);
void OnReadPacket(Connection *connection, const char *data, size_t len, void OnReadPacket(Connection *connection, const char *data, size_t len,
const rtc::PacketTime& packet_time); const rtc::PacketTime& packet_time);
void OnSentPacket(PortInterface* port, const rtc::SentPacket& sent_packet);
void OnReadyToSend(Connection* connection); void OnReadyToSend(Connection* connection);
void OnConnectionDestroyed(Connection *connection); void OnConnectionDestroyed(Connection *connection);

View File

@ -310,6 +310,10 @@ void Port::OnReadPacket(
} }
} }
void Port::OnSentPacket(const rtc::SentPacket& sent_packet) {
PortInterface::SignalSentPacket(this, sent_packet);
}
void Port::OnReadyToSend() { void Port::OnReadyToSend() {
AddressMap::iterator iter = connections_.begin(); AddressMap::iterator iter = connections_.begin();
for (; iter != connections_.end(); ++iter) { for (; iter != connections_.end(); ++iter) {

View File

@ -275,6 +275,9 @@ class Port : public PortInterface, public rtc::MessageHandler,
IceMessage* stun_msg, IceMessage* stun_msg,
const std::string& remote_ufrag); const std::string& remote_ufrag);
// Called when a packet has been sent to the socket.
void OnSentPacket(const rtc::SentPacket& sent_packet);
// Called when the socket is currently able to send. // Called when the socket is currently able to send.
void OnReadyToSend(); void OnReadyToSend();

View File

@ -14,6 +14,7 @@
#include <string> #include <string>
#include "webrtc/p2p/base/transport.h" #include "webrtc/p2p/base/transport.h"
#include "webrtc/base/asyncpacketsocket.h"
#include "webrtc/base/socketaddress.h" #include "webrtc/base/socketaddress.h"
namespace rtc { namespace rtc {
@ -112,6 +113,9 @@ class PortInterface {
sigslot::signal4<PortInterface*, const char*, size_t, sigslot::signal4<PortInterface*, const char*, size_t,
const rtc::SocketAddress&> SignalReadPacket; const rtc::SocketAddress&> SignalReadPacket;
// Emitted each time a packet is sent on this port.
sigslot::signal2<PortInterface*, const rtc::SentPacket&> SignalSentPacket;
virtual std::string ToString() const = 0; virtual std::string ToString() const = 0;
protected: protected:

View File

@ -144,6 +144,10 @@ class RelayEntry : public rtc::MessageHandler,
const char* data, size_t size, const char* data, size_t size,
const rtc::SocketAddress& remote_addr, const rtc::SocketAddress& remote_addr,
const rtc::PacketTime& packet_time); const rtc::PacketTime& packet_time);
void OnSentPacket(rtc::AsyncPacketSocket* socket,
const rtc::SentPacket& sent_packet);
// Called when the socket is currently able to send. // Called when the socket is currently able to send.
void OnReadyToSend(rtc::AsyncPacketSocket* socket); void OnReadyToSend(rtc::AsyncPacketSocket* socket);
@ -508,6 +512,7 @@ void RelayEntry::Connect() {
// Otherwise, create the new connection and configure any socket options. // Otherwise, create the new connection and configure any socket options.
socket->SignalReadPacket.connect(this, &RelayEntry::OnReadPacket); socket->SignalReadPacket.connect(this, &RelayEntry::OnReadPacket);
socket->SignalSentPacket.connect(this, &RelayEntry::OnSentPacket);
socket->SignalReadyToSend.connect(this, &RelayEntry::OnReadyToSend); socket->SignalReadyToSend.connect(this, &RelayEntry::OnReadyToSend);
current_connection_ = new RelayConnection(ra, socket, port()->thread()); current_connection_ = new RelayConnection(ra, socket, port()->thread());
for (size_t i = 0; i < port_->options().size(); ++i) { for (size_t i = 0; i < port_->options().size(); ++i) {
@ -747,6 +752,11 @@ void RelayEntry::OnReadPacket(
PROTO_UDP, packet_time); PROTO_UDP, packet_time);
} }
void RelayEntry::OnSentPacket(rtc::AsyncPacketSocket* socket,
const rtc::SentPacket& sent_packet) {
port_->OnSentPacket(sent_packet);
}
void RelayEntry::OnReadyToSend(rtc::AsyncPacketSocket* socket) { void RelayEntry::OnReadyToSend(rtc::AsyncPacketSocket* socket) {
if (connected()) { if (connected()) {
port_->OnReadyToSend(); port_->OnReadyToSend();

View File

@ -217,6 +217,7 @@ bool UDPPort::Init() {
} }
socket_->SignalReadPacket.connect(this, &UDPPort::OnReadPacket); socket_->SignalReadPacket.connect(this, &UDPPort::OnReadPacket);
} }
socket_->SignalSentPacket.connect(this, &UDPPort::OnSentPacket);
socket_->SignalReadyToSend.connect(this, &UDPPort::OnReadyToSend); socket_->SignalReadyToSend.connect(this, &UDPPort::OnReadyToSend);
socket_->SignalAddressReady.connect(this, &UDPPort::OnLocalAddressReady); socket_->SignalAddressReady.connect(this, &UDPPort::OnLocalAddressReady);
requests_.SignalSendPacket.connect(this, &UDPPort::OnSendPacket); requests_.SignalSendPacket.connect(this, &UDPPort::OnSendPacket);
@ -329,6 +330,11 @@ void UDPPort::OnReadPacket(
} }
} }
void UDPPort::OnSentPacket(rtc::AsyncPacketSocket* socket,
const rtc::SentPacket& sent_packet) {
Port::OnSentPacket(sent_packet);
}
void UDPPort::OnReadyToSend(rtc::AsyncPacketSocket* socket) { void UDPPort::OnReadyToSend(rtc::AsyncPacketSocket* socket) {
Port::OnReadyToSend(); Port::OnReadyToSend();
} }

View File

@ -140,6 +140,9 @@ class UDPPort : public Port {
const rtc::SocketAddress& remote_addr, const rtc::SocketAddress& remote_addr,
const rtc::PacketTime& packet_time); const rtc::PacketTime& packet_time);
void OnSentPacket(rtc::AsyncPacketSocket* socket,
const rtc::SentPacket& sent_packet);
void OnReadyToSend(rtc::AsyncPacketSocket* socket); void OnReadyToSend(rtc::AsyncPacketSocket* socket);
// This method will send STUN binding request if STUN server address is set. // This method will send STUN binding request if STUN server address is set.

View File

@ -48,7 +48,7 @@ enum TransportChannelState {
// between the two sides of a session. // between the two sides of a session.
class TransportChannel : public sigslot::has_slots<> { class TransportChannel : public sigslot::has_slots<> {
public: public:
explicit TransportChannel(const std::string& transport_name, int component) TransportChannel(const std::string& transport_name, int component)
: transport_name_(transport_name), : transport_name_(transport_name),
component_(component), component_(component),
writable_(false), writable_(false),
@ -134,6 +134,9 @@ class TransportChannel : public sigslot::has_slots<> {
sigslot::signal5<TransportChannel*, const char*, sigslot::signal5<TransportChannel*, const char*,
size_t, const rtc::PacketTime&, int> SignalReadPacket; size_t, const rtc::PacketTime&, int> SignalReadPacket;
// Signalled each time a packet is sent on this channel.
sigslot::signal2<TransportChannel*, const rtc::SentPacket&> SignalSentPacket;
// This signal occurs when there is a change in the way that packets are // This signal occurs when there is a change in the way that packets are
// being routed, i.e. to a different remote location. The candidate // being routed, i.e. to a different remote location. The candidate
// indicates where and how we are currently sending media. // indicates where and how we are currently sending media.

View File

@ -17,6 +17,8 @@
namespace webrtc { namespace webrtc {
// TODO(holmer): Look into unifying this with the PacketOptions in
// asyncpacketsocket.h.
struct PacketOptions { struct PacketOptions {
// A 16 bits positive id. Negative ids are invalid and should be interpreted // A 16 bits positive id. Negative ids are invalid and should be interpreted
// as packet_id not being set. // as packet_id not being set.

View File

@ -445,4 +445,11 @@ void ChannelGroup::OnNetworkChanged(uint32_t target_bitrate_bps,
PacedSender::kDefaultPaceMultiplier * target_bitrate_bps / 1000, PacedSender::kDefaultPaceMultiplier * target_bitrate_bps / 1000,
pad_up_to_bitrate_bps / 1000); pad_up_to_bitrate_bps / 1000);
} }
void ChannelGroup::OnSentPacket(const rtc::SentPacket& sent_packet) {
if (transport_feedback_adapter_) {
transport_feedback_adapter_->UpdateSendTime(sent_packet.packet_id,
sent_packet.send_time_ms);
}
}
} // namespace webrtc } // namespace webrtc

View File

@ -18,6 +18,7 @@
#include "webrtc/base/criticalsection.h" #include "webrtc/base/criticalsection.h"
#include "webrtc/base/scoped_ptr.h" #include "webrtc/base/scoped_ptr.h"
#include "webrtc/base/socket.h"
#include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
#include "webrtc/video_receive_stream.h" #include "webrtc/video_receive_stream.h"
#include "webrtc/video_send_stream.h" #include "webrtc/video_send_stream.h"
@ -82,6 +83,8 @@ class ChannelGroup : public BitrateObserver {
uint8_t fraction_loss, uint8_t fraction_loss,
int64_t rtt) override; int64_t rtt) override;
void OnSentPacket(const rtc::SentPacket& sent_packet);
private: private:
typedef std::map<int, ViEChannel*> ChannelMap; typedef std::map<int, ViEChannel*> ChannelMap;
typedef std::map<int, ViEEncoder*> EncoderMap; typedef std::map<int, ViEEncoder*> EncoderMap;