R=mallinath@webrtc.org, niklas.enbom@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/5719004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5274 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
wu@webrtc.org 2013-12-12 22:40:39 +00:00
parent 451745ec05
commit a129b6cd13
101 changed files with 490 additions and 290 deletions

View File

@ -54,8 +54,6 @@ const char MediaConstraintsInterface::kHighpassFilter[] =
const char MediaConstraintsInterface::kTypingNoiseDetection[] = const char MediaConstraintsInterface::kTypingNoiseDetection[] =
"googTypingNoiseDetection"; "googTypingNoiseDetection";
const char MediaConstraintsInterface::kAudioMirroring[] = "googAudioMirroring"; const char MediaConstraintsInterface::kAudioMirroring[] = "googAudioMirroring";
// TODO(perkj): Remove kInternalAecDump once its not used by Chrome.
const char MediaConstraintsInterface::kInternalAecDump[] = "deprecatedAecDump";
namespace { namespace {
@ -129,8 +127,6 @@ void LocalAudioSource::Initialize(
return; return;
} }
options_.SetAll(audio_options); options_.SetAll(audio_options);
if (options.enable_aec_dump)
options_.aec_dump.Set(true);
source_state_ = kLive; source_state_ = kLive;
} }

View File

@ -117,13 +117,6 @@ class MediaConstraintsInterface {
// stripped by Chrome before passed down to Libjingle. // stripped by Chrome before passed down to Libjingle.
static const char kInternalConstraintPrefix[]; static const char kInternalConstraintPrefix[];
// These constraints are for internal use only, representing Chrome command
// line flags. So they are prefixed with "internal" so JS values will be
// removed.
// Used by a local audio source.
// TODO(perkj): Remove once Chrome use PeerConnectionFactory::SetOptions.
static const char kInternalAecDump[]; // internalAecDump
protected: protected:
// Dtor protected as objects shouldn't be deleted via this interface // Dtor protected as objects shouldn't be deleted via this interface
virtual ~MediaConstraintsInterface() {} virtual ~MediaConstraintsInterface() {}

View File

@ -105,12 +105,21 @@ struct CreateVideoSourceParams : public talk_base::MessageData {
scoped_refptr<webrtc::VideoSourceInterface> source; scoped_refptr<webrtc::VideoSourceInterface> source;
}; };
struct StartAecDumpParams : public talk_base::MessageData {
explicit StartAecDumpParams(FILE* aec_dump_file)
: aec_dump_file(aec_dump_file) {
}
FILE* aec_dump_file;
bool result;
};
enum { enum {
MSG_INIT_FACTORY = 1, MSG_INIT_FACTORY = 1,
MSG_TERMINATE_FACTORY, MSG_TERMINATE_FACTORY,
MSG_CREATE_PEERCONNECTION, MSG_CREATE_PEERCONNECTION,
MSG_CREATE_AUDIOSOURCE, MSG_CREATE_AUDIOSOURCE,
MSG_CREATE_VIDEOSOURCE, MSG_CREATE_VIDEOSOURCE,
MSG_START_AEC_DUMP,
}; };
} // namespace } // namespace
@ -223,6 +232,12 @@ void PeerConnectionFactory::OnMessage(talk_base::Message* msg) {
pdata->source = CreateVideoSource_s(pdata->capturer, pdata->constraints); pdata->source = CreateVideoSource_s(pdata->capturer, pdata->constraints);
break; break;
} }
case MSG_START_AEC_DUMP: {
StartAecDumpParams* pdata =
static_cast<StartAecDumpParams*>(msg->pdata);
pdata->result = StartAecDump_s(pdata->aec_dump_file);
break;
}
} }
} }
@ -274,6 +289,10 @@ PeerConnectionFactory::CreateVideoSource_s(
return VideoSourceProxy::Create(signaling_thread_, source); return VideoSourceProxy::Create(signaling_thread_, source);
} }
bool PeerConnectionFactory::StartAecDump_s(FILE* file) {
return channel_manager_->StartAecDump(file);
}
scoped_refptr<PeerConnectionInterface> scoped_refptr<PeerConnectionInterface>
PeerConnectionFactory::CreatePeerConnection( PeerConnectionFactory::CreatePeerConnection(
const PeerConnectionInterface::IceServers& configuration, const PeerConnectionInterface::IceServers& configuration,
@ -361,6 +380,12 @@ scoped_refptr<AudioTrackInterface> PeerConnectionFactory::CreateAudioTrack(
return AudioTrackProxy::Create(signaling_thread_, track); return AudioTrackProxy::Create(signaling_thread_, track);
} }
bool PeerConnectionFactory::StartAecDump(FILE* file) {
StartAecDumpParams params(file);
signaling_thread_->Send(this, MSG_START_AEC_DUMP, &params);
return params.result;
}
cricket::ChannelManager* PeerConnectionFactory::channel_manager() { cricket::ChannelManager* PeerConnectionFactory::channel_manager() {
return channel_manager_.get(); return channel_manager_.get();
} }

View File

@ -78,6 +78,8 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface,
CreateAudioTrack(const std::string& id, CreateAudioTrack(const std::string& id,
AudioSourceInterface* audio_source); AudioSourceInterface* audio_source);
virtual bool StartAecDump(FILE* file);
virtual cricket::ChannelManager* channel_manager(); virtual cricket::ChannelManager* channel_manager();
virtual talk_base::Thread* signaling_thread(); virtual talk_base::Thread* signaling_thread();
virtual talk_base::Thread* worker_thread(); virtual talk_base::Thread* worker_thread();
@ -93,7 +95,6 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface,
cricket::WebRtcVideoDecoderFactory* video_decoder_factory); cricket::WebRtcVideoDecoderFactory* video_decoder_factory);
virtual ~PeerConnectionFactory(); virtual ~PeerConnectionFactory();
private: private:
bool Initialize_s(); bool Initialize_s();
void Terminate_s(); void Terminate_s();
@ -108,6 +109,8 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface,
PortAllocatorFactoryInterface* allocator_factory, PortAllocatorFactoryInterface* allocator_factory,
DTLSIdentityServiceInterface* dtls_identity_service, DTLSIdentityServiceInterface* dtls_identity_service,
PeerConnectionObserver* observer); PeerConnectionObserver* observer);
bool StartAecDump_s(FILE* file);
// Implements talk_base::MessageHandler. // Implements talk_base::MessageHandler.
void OnMessage(talk_base::Message* msg); void OnMessage(talk_base::Message* msg);

View File

@ -393,11 +393,9 @@ class PeerConnectionFactoryInterface : public talk_base::RefCountInterface {
class Options { class Options {
public: public:
Options() : Options() :
enable_aec_dump(false),
disable_encryption(false), disable_encryption(false),
disable_sctp_data_channels(false) { disable_sctp_data_channels(false) {
} }
bool enable_aec_dump;
bool disable_encryption; bool disable_encryption;
bool disable_sctp_data_channels; bool disable_sctp_data_channels;
}; };
@ -442,6 +440,12 @@ class PeerConnectionFactoryInterface : public talk_base::RefCountInterface {
CreateAudioTrack(const std::string& label, CreateAudioTrack(const std::string& label,
AudioSourceInterface* source) = 0; AudioSourceInterface* source) = 0;
// Starts AEC dump using existing file. Takes ownership of |file| and passes
// it on to VoiceEngine (via other objects) immediately, which will take
// the ownerhip.
// TODO(grunell): Remove when Chromium has started to use AEC in each source.
virtual bool StartAecDump(FILE* file) = 0;
protected: protected:
// Dtor and ctor protected as objects shouldn't be created or deleted via // Dtor and ctor protected as objects shouldn't be created or deleted via
// this interface. // this interface.

View File

@ -31,9 +31,30 @@
#include "talk/base/dscp.h" #include "talk/base/dscp.h"
#include "talk/base/sigslot.h" #include "talk/base/sigslot.h"
#include "talk/base/socket.h" #include "talk/base/socket.h"
#include "talk/base/timeutils.h"
namespace talk_base { namespace talk_base {
// This structure will have the information about when packet is actually
// received by socket.
struct PacketTime {
PacketTime() : timestamp(-1), not_before(-1) {}
PacketTime(int64 timestamp, int64 not_before)
: timestamp(timestamp), not_before(not_before) {
}
int64 timestamp; // Receive time after socket delivers the data.
int64 not_before; // Earliest possible time the data could have arrived,
// indicating the potential error in the |timestamp| value,
// in case the system, is busy. For example, the time of
// the last select() call.
// If unknown, this value will be set to zero.
};
inline PacketTime CreatePacketTime(int64 not_before) {
return PacketTime(TimeMicros(), not_before);
}
// Provides the ability to receive packets asynchronously. Sends are not // Provides the ability to receive packets asynchronously. Sends are not
// buffered since it is acceptable to drop packets under high load. // buffered since it is acceptable to drop packets under high load.
class AsyncPacketSocket : public sigslot::has_slots<> { class AsyncPacketSocket : public sigslot::has_slots<> {
@ -78,8 +99,9 @@ class AsyncPacketSocket : public sigslot::has_slots<> {
// Emitted each time a packet is read. Used only for UDP and // Emitted each time a packet is read. Used only for UDP and
// connected TCP sockets. // connected TCP sockets.
sigslot::signal4<AsyncPacketSocket*, const char*, size_t, sigslot::signal5<AsyncPacketSocket*, const char*, size_t,
const SocketAddress&> SignalReadPacket; const SocketAddress&,
const PacketTime&> SignalReadPacket;
// 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

@ -300,7 +300,8 @@ void AsyncTCPSocket::ProcessInput(char * data, size_t* len) {
if (*len < kPacketLenSize + pkt_len) if (*len < kPacketLenSize + pkt_len)
return; return;
SignalReadPacket(this, data + kPacketLenSize, pkt_len, remote_addr); SignalReadPacket(this, data + kPacketLenSize, pkt_len, remote_addr,
CreatePacketTime(0));
*len -= kPacketLenSize + pkt_len; *len -= kPacketLenSize + pkt_len;
if (*len > 0) { if (*len > 0) {

View File

@ -128,7 +128,8 @@ void AsyncUDPSocket::OnReadEvent(AsyncSocket* socket) {
// TODO: Make sure that we got all of the packet. // TODO: Make sure that we got all of the packet.
// If we did not, then we should resize our buffer to be large enough. // If we did not, then we should resize our buffer to be large enough.
SignalReadPacket(this, buf_, (size_t)len, remote_addr); SignalReadPacket(this, buf_, static_cast<size_t>(len), remote_addr,
CreatePacketTime(0));
} }
void AsyncUDPSocket::OnWriteEvent(AsyncSocket* socket) { void AsyncUDPSocket::OnWriteEvent(AsyncSocket* socket) {

View File

@ -107,7 +107,7 @@ NATServer::~NATServer() {
void NATServer::OnInternalPacket( void NATServer::OnInternalPacket(
AsyncPacketSocket* socket, const char* buf, size_t size, AsyncPacketSocket* socket, const char* buf, size_t size,
const SocketAddress& addr) { const SocketAddress& addr, const PacketTime& packet_time) {
// Read the intended destination from the wire. // Read the intended destination from the wire.
SocketAddress dest_addr; SocketAddress dest_addr;
@ -132,7 +132,7 @@ void NATServer::OnInternalPacket(
void NATServer::OnExternalPacket( void NATServer::OnExternalPacket(
AsyncPacketSocket* socket, const char* buf, size_t size, AsyncPacketSocket* socket, const char* buf, size_t size,
const SocketAddress& remote_addr) { const SocketAddress& remote_addr, const PacketTime& packet_time) {
SocketAddress local_addr = socket->GetLocalAddress(); SocketAddress local_addr = socket->GetLocalAddress();

View File

@ -79,9 +79,11 @@ class NATServer : public sigslot::has_slots<> {
// Packets received on one of the networks. // Packets received on one of the networks.
void OnInternalPacket(AsyncPacketSocket* socket, const char* buf, void OnInternalPacket(AsyncPacketSocket* socket, const char* buf,
size_t size, const SocketAddress& addr); size_t size, const SocketAddress& addr,
const PacketTime& packet_time);
void OnExternalPacket(AsyncPacketSocket* socket, const char* buf, void OnExternalPacket(AsyncPacketSocket* socket, const char* buf,
size_t size, const SocketAddress& remote_addr); size_t size, const SocketAddress& remote_addr,
const PacketTime& packet_time);
private: private:
typedef std::set<SocketAddress, AddrCmp> AddressSet; typedef std::set<SocketAddress, AddrCmp> AddressSet;

View File

@ -762,7 +762,7 @@ TEST_F(SSLStreamAdapterTestDTLS,
}; };
// Test a handshake with small MTU // Test a handshake with small MTU
TEST_F(SSLStreamAdapterTestDTLS, DISABLED_TestDTLSConnectWithSmallMtu) { TEST_F(SSLStreamAdapterTestDTLS, TestDTLSConnectWithSmallMtu) {
MAYBE_SKIP_TEST(HaveDtls); MAYBE_SKIP_TEST(HaveDtls);
SetMtu(700); SetMtu(700);
SetHandshakeWait(20000); SetHandshakeWait(20000);

View File

@ -135,7 +135,8 @@ bool TestClient::ready_to_send() const {
} }
void TestClient::OnPacket(AsyncPacketSocket* socket, const char* buf, void TestClient::OnPacket(AsyncPacketSocket* socket, const char* buf,
size_t size, const SocketAddress& remote_addr) { size_t size, const SocketAddress& remote_addr,
const PacketTime& packet_time) {
CritScope cs(&crit_); CritScope cs(&crit_);
packets_->push_back(new Packet(remote_addr, buf, size)); packets_->push_back(new Packet(remote_addr, buf, size));
} }

View File

@ -94,7 +94,8 @@ class TestClient : public sigslot::has_slots<> {
Socket::ConnState GetState(); Socket::ConnState GetState();
// Slot for packets read on the socket. // Slot for packets read on the socket.
void OnPacket(AsyncPacketSocket* socket, const char* buf, size_t len, void OnPacket(AsyncPacketSocket* socket, const char* buf, size_t len,
const SocketAddress& remote_addr); const SocketAddress& remote_addr,
const PacketTime& packet_time);
void OnReadyToSend(AsyncPacketSocket* socket); void OnReadyToSend(AsyncPacketSocket* socket);
CriticalSection crit_; CriticalSection crit_;

View File

@ -67,7 +67,8 @@ class TestEchoServer : public sigslot::has_slots<> {
} }
} }
void OnPacket(AsyncPacketSocket* socket, const char* buf, size_t size, void OnPacket(AsyncPacketSocket* socket, const char* buf, size_t size,
const SocketAddress& remote_addr) { const SocketAddress& remote_addr,
const PacketTime& packet_time) {
socket->Send(buf, size, DSCP_NO_CHANGE); socket->Send(buf, size, DSCP_NO_CHANGE);
} }
void OnClose(AsyncPacketSocket* socket, int err) { void OnClose(AsyncPacketSocket* socket, int err) {

View File

@ -81,7 +81,8 @@ class SocketClient : public TestGenerator, public sigslot::has_slots<> {
SocketAddress address() const { return socket_->GetLocalAddress(); } SocketAddress address() const { return socket_->GetLocalAddress(); }
void OnPacket(AsyncPacketSocket* socket, const char* buf, size_t size, void OnPacket(AsyncPacketSocket* socket, const char* buf, size_t size,
const SocketAddress& remote_addr) { const SocketAddress& remote_addr,
const PacketTime& packet_time) {
EXPECT_EQ(size, sizeof(uint32)); EXPECT_EQ(size, sizeof(uint32));
uint32 prev = reinterpret_cast<const uint32*>(buf)[0]; uint32 prev = reinterpret_cast<const uint32*>(buf)[0];
uint32 result = Next(prev); uint32 result = Next(prev);

View File

@ -94,6 +94,10 @@ uint32 Time() {
return static_cast<uint32>(TimeNanos() / kNumNanosecsPerMillisec); return static_cast<uint32>(TimeNanos() / kNumNanosecsPerMillisec);
} }
uint64 TimeMicros() {
return static_cast<uint64>(TimeNanos() / kNumNanosecsPerMicrosec);
}
#if defined(WIN32) #if defined(WIN32)
static const uint64 kFileTimeToUnixTimeEpochOffset = 116444736000000000ULL; static const uint64 kFileTimeToUnixTimeEpochOffset = 116444736000000000ULL;

View File

@ -42,6 +42,8 @@ static const int64 kNumMicrosecsPerMillisec = kNumMicrosecsPerSec /
kNumMillisecsPerSec; kNumMillisecsPerSec;
static const int64 kNumNanosecsPerMillisec = kNumNanosecsPerSec / static const int64 kNumNanosecsPerMillisec = kNumNanosecsPerSec /
kNumMillisecsPerSec; kNumMillisecsPerSec;
static const int64 kNumNanosecsPerMicrosec = kNumNanosecsPerSec /
kNumMicrosecsPerSec;
// January 1970, in NTP milliseconds. // January 1970, in NTP milliseconds.
static const int64 kJan1970AsNtpMillisecs = INT64_C(2208988800000); static const int64 kJan1970AsNtpMillisecs = INT64_C(2208988800000);
@ -50,6 +52,8 @@ typedef uint32 TimeStamp;
// Returns the current time in milliseconds. // Returns the current time in milliseconds.
uint32 Time(); uint32 Time();
// Returns the current time in microseconds.
uint64 TimeMicros();
// Returns the current time in nanoseconds. // Returns the current time in nanoseconds.
uint64 TimeNanos(); uint64 TimeNanos();

View File

@ -97,7 +97,8 @@ struct Receiver : public MessageHandler, public sigslot::has_slots<> {
} }
void OnReadPacket(AsyncPacketSocket* s, const char* data, size_t size, void OnReadPacket(AsyncPacketSocket* s, const char* data, size_t size,
const SocketAddress& remote_addr) { const SocketAddress& remote_addr,
const PacketTime& packet_time) {
ASSERT_EQ(socket.get(), s); ASSERT_EQ(socket.get(), s);
ASSERT_GE(size, 4U); ASSERT_GE(size, 4U);

View File

@ -71,9 +71,9 @@
'extension': 'isolate', 'extension': 'isolate',
'inputs': [ 'inputs': [
# Files that are known to be involved in this step. # Files that are known to be involved in this step.
'<(DEPTH)/tools/swarming_client/isolate.py', '<(DEPTH)/tools/swarm_client/isolate.py',
'<(DEPTH)/tools/swarming_client/run_isolated.py', '<(DEPTH)/tools/swarm_client/run_isolated.py',
'<(DEPTH)/tools/swarming_client/googletest/run_test_cases.py', '<(DEPTH)/tools/swarm_client/googletest/run_test_cases.py',
# Disable file tracking by the build driver for now. This means the # Disable file tracking by the build driver for now. This means the
# project must have the proper build-time dependency for their runtime # project must have the proper build-time dependency for their runtime
@ -94,7 +94,7 @@
["test_isolation_outdir==''", { ["test_isolation_outdir==''", {
'action': [ 'action': [
'python', 'python',
'<(DEPTH)/tools/swarming_client/isolate.py', '<(DEPTH)/tools/swarm_client/isolate.py',
'<(test_isolation_mode)', '<(test_isolation_mode)',
# GYP will eliminate duplicate arguments so '<(PRODUCT_DIR)' cannot # GYP will eliminate duplicate arguments so '<(PRODUCT_DIR)' cannot
# be provided twice. To work around this behavior, append '/'. # be provided twice. To work around this behavior, append '/'.
@ -114,7 +114,7 @@
}, { }, {
'action': [ 'action': [
'python', 'python',
'<(DEPTH)/tools/swarming_client/isolate.py', '<(DEPTH)/tools/swarm_client/isolate.py',
'<(test_isolation_mode)', '<(test_isolation_mode)',
'--outdir', '<(test_isolation_outdir)', '--outdir', '<(test_isolation_outdir)',
# See comment above. # See comment above.

View File

@ -11,6 +11,6 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target. # Project target.
target=android-19 target=android-17
java.compilerargs=-Xlint:all -Werror java.compilerargs=-Xlint:all -Werror

View File

@ -30,6 +30,7 @@
'variables': { 'variables': {
'command': [ 'command': [
'../testing/test_env.py', '../testing/test_env.py',
'../tools/swarm_client/googletest/run_test_cases.py',
'<(PRODUCT_DIR)/libjingle_media_unittest<(EXECUTABLE_SUFFIX)', '<(PRODUCT_DIR)/libjingle_media_unittest<(EXECUTABLE_SUFFIX)',
], ],
'isolate_dependency_tracked': [ 'isolate_dependency_tracked': [
@ -38,7 +39,7 @@
'<(PRODUCT_DIR)/libjingle_media_unittest<(EXECUTABLE_SUFFIX)', '<(PRODUCT_DIR)/libjingle_media_unittest<(EXECUTABLE_SUFFIX)',
], ],
'isolate_dependency_untracked': [ 'isolate_dependency_untracked': [
'../tools/swarming_client/', '../tools/swarm_client/',
], ],
}, },
}], }],

View File

@ -30,6 +30,7 @@
'variables': { 'variables': {
'command': [ 'command': [
'../testing/test_env.py', '../testing/test_env.py',
'../tools/swarm_client/googletest/run_test_cases.py',
'<(PRODUCT_DIR)/libjingle_p2p_unittest<(EXECUTABLE_SUFFIX)', '<(PRODUCT_DIR)/libjingle_p2p_unittest<(EXECUTABLE_SUFFIX)',
], ],
'isolate_dependency_tracked': [ 'isolate_dependency_tracked': [
@ -37,7 +38,7 @@
'<(PRODUCT_DIR)/libjingle_p2p_unittest<(EXECUTABLE_SUFFIX)', '<(PRODUCT_DIR)/libjingle_p2p_unittest<(EXECUTABLE_SUFFIX)',
], ],
'isolate_dependency_untracked': [ 'isolate_dependency_untracked': [
'../tools/swarming_client/', '../tools/swarm_client/',
], ],
}, },
}], }],

View File

@ -30,6 +30,7 @@
'variables': { 'variables': {
'command': [ 'command': [
'../testing/test_env.py', '../testing/test_env.py',
'../tools/swarm_client/googletest/run_test_cases.py',
'<(PRODUCT_DIR)/libjingle_peerconnection_unittest<(EXECUTABLE_SUFFIX)', '<(PRODUCT_DIR)/libjingle_peerconnection_unittest<(EXECUTABLE_SUFFIX)',
], ],
'isolate_dependency_tracked': [ 'isolate_dependency_tracked': [
@ -37,7 +38,7 @@
'<(PRODUCT_DIR)/libjingle_peerconnection_unittest<(EXECUTABLE_SUFFIX)', '<(PRODUCT_DIR)/libjingle_peerconnection_unittest<(EXECUTABLE_SUFFIX)',
], ],
'isolate_dependency_untracked': [ 'isolate_dependency_untracked': [
'../tools/swarming_client/', '../tools/swarm_client/',
], ],
}, },
}], }],

View File

@ -30,6 +30,7 @@
'variables': { 'variables': {
'command': [ 'command': [
'../testing/test_env.py', '../testing/test_env.py',
'../tools/swarm_client/googletest/run_test_cases.py',
'<(PRODUCT_DIR)/libjingle_sound_unittest<(EXECUTABLE_SUFFIX)', '<(PRODUCT_DIR)/libjingle_sound_unittest<(EXECUTABLE_SUFFIX)',
], ],
'isolate_dependency_tracked': [ 'isolate_dependency_tracked': [
@ -37,7 +38,7 @@
'<(PRODUCT_DIR)/libjingle_sound_unittest<(EXECUTABLE_SUFFIX)', '<(PRODUCT_DIR)/libjingle_sound_unittest<(EXECUTABLE_SUFFIX)',
], ],
'isolate_dependency_untracked': [ 'isolate_dependency_untracked': [
'../tools/swarming_client/', '../tools/swarm_client/',
], ],
}, },
}], }],

View File

@ -30,6 +30,7 @@
'variables': { 'variables': {
'command': [ 'command': [
'../testing/test_env.py', '../testing/test_env.py',
'../tools/swarm_client/googletest/run_test_cases.py',
'<(PRODUCT_DIR)/libjingle_unittest<(EXECUTABLE_SUFFIX)', '<(PRODUCT_DIR)/libjingle_unittest<(EXECUTABLE_SUFFIX)',
], ],
'isolate_dependency_tracked': [ 'isolate_dependency_tracked': [
@ -37,7 +38,7 @@
'<(PRODUCT_DIR)/libjingle_unittest<(EXECUTABLE_SUFFIX)', '<(PRODUCT_DIR)/libjingle_unittest<(EXECUTABLE_SUFFIX)',
], ],
'isolate_dependency_untracked': [ 'isolate_dependency_untracked': [
'../tools/swarming_client/', '../tools/swarm_client/',
], ],
}, },
}], }],

View File

@ -191,10 +191,12 @@ template <class Base> class RtpHelper : public Base {
return true; return true;
} }
void set_playout(bool playout) { playout_ = playout; } void set_playout(bool playout) { playout_ = playout; }
virtual void OnPacketReceived(talk_base::Buffer* packet) { virtual void OnPacketReceived(talk_base::Buffer* packet,
const talk_base::PacketTime& packet_time) {
rtp_packets_.push_back(std::string(packet->data(), packet->length())); rtp_packets_.push_back(std::string(packet->data(), packet->length()));
} }
virtual void OnRtcpReceived(talk_base::Buffer* packet) { virtual void OnRtcpReceived(talk_base::Buffer* packet,
const talk_base::PacketTime& packet_time) {
rtcp_packets_.push_back(std::string(packet->data(), packet->length())); rtcp_packets_.push_back(std::string(packet->data(), packet->length()));
} }
virtual void OnReadyToSend(bool ready) { virtual void OnReadyToSend(bool ready) {
@ -776,6 +778,8 @@ class FakeVoiceEngine : public FakeBaseEngine {
bool SetLocalMonitor(bool enable) { return true; } bool SetLocalMonitor(bool enable) { return true; }
bool StartAecDump(FILE* file) { return false; }
bool RegisterProcessor(uint32 ssrc, VoiceProcessor* voice_processor, bool RegisterProcessor(uint32 ssrc, VoiceProcessor* voice_processor,
MediaProcessorDirection direction) { MediaProcessorDirection direction) {
if (direction == MPD_RX) { if (direction == MPD_RX) {

View File

@ -201,9 +201,11 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface,
msg->pdata); msg->pdata);
if (dest_) { if (dest_) {
if (msg->message_id == ST_RTP) { if (msg->message_id == ST_RTP) {
dest_->OnPacketReceived(&msg_data->data()); dest_->OnPacketReceived(&msg_data->data(),
talk_base::CreatePacketTime(0));
} else { } else {
dest_->OnRtcpReceived(&msg_data->data()); dest_->OnRtcpReceived(&msg_data->data(),
talk_base::CreatePacketTime(0));
} }
} }
delete msg_data; delete msg_data;

View File

@ -315,7 +315,8 @@ bool FileVoiceChannel::RemoveSendStream(uint32 ssrc) {
return true; return true;
} }
void FileVoiceChannel::OnPacketReceived(talk_base::Buffer* packet) { void FileVoiceChannel::OnPacketReceived(
talk_base::Buffer* packet, const talk_base::PacketTime& packet_time) {
rtp_sender_receiver_->OnPacketReceived(packet); rtp_sender_receiver_->OnPacketReceived(packet);
} }
@ -360,7 +361,8 @@ bool FileVideoChannel::RemoveSendStream(uint32 ssrc) {
return true; return true;
} }
void FileVideoChannel::OnPacketReceived(talk_base::Buffer* packet) { void FileVideoChannel::OnPacketReceived(
talk_base::Buffer* packet, const talk_base::PacketTime& packet_time) {
rtp_sender_receiver_->OnPacketReceived(packet); rtp_sender_receiver_->OnPacketReceived(packet);
} }

View File

@ -133,6 +133,7 @@ class FileMediaEngine : public MediaEngineInterface {
virtual bool FindVideoCodec(const VideoCodec& codec) { return true; } virtual bool FindVideoCodec(const VideoCodec& codec) { return true; }
virtual void SetVoiceLogging(int min_sev, const char* filter) {} virtual void SetVoiceLogging(int min_sev, const char* filter) {}
virtual void SetVideoLogging(int min_sev, const char* filter) {} virtual void SetVideoLogging(int min_sev, const char* filter) {}
virtual bool StartAecDump(FILE* file) { return false; }
virtual bool RegisterVideoProcessor(VideoProcessor* processor) { virtual bool RegisterVideoProcessor(VideoProcessor* processor) {
return true; return true;
@ -232,8 +233,10 @@ class FileVoiceChannel : public VoiceMediaChannel {
virtual bool GetStats(VoiceMediaInfo* info) { return true; } virtual bool GetStats(VoiceMediaInfo* info) { return true; }
// Implement pure virtual methods of MediaChannel. // Implement pure virtual methods of MediaChannel.
virtual void OnPacketReceived(talk_base::Buffer* packet); virtual void OnPacketReceived(talk_base::Buffer* packet,
virtual void OnRtcpReceived(talk_base::Buffer* packet) {} const talk_base::PacketTime& packet_time);
virtual void OnRtcpReceived(talk_base::Buffer* packet,
const talk_base::PacketTime& packet_time) {}
virtual void OnReadyToSend(bool ready) {} virtual void OnReadyToSend(bool ready) {}
virtual bool AddSendStream(const StreamParams& sp); virtual bool AddSendStream(const StreamParams& sp);
virtual bool RemoveSendStream(uint32 ssrc); virtual bool RemoveSendStream(uint32 ssrc);
@ -298,8 +301,10 @@ class FileVideoChannel : public VideoMediaChannel {
virtual bool RequestIntraFrame() { return false; } virtual bool RequestIntraFrame() { return false; }
// Implement pure virtual methods of MediaChannel. // Implement pure virtual methods of MediaChannel.
virtual void OnPacketReceived(talk_base::Buffer* packet); virtual void OnPacketReceived(talk_base::Buffer* packet,
virtual void OnRtcpReceived(talk_base::Buffer* packet) {} const talk_base::PacketTime& packet_time);
virtual void OnRtcpReceived(talk_base::Buffer* packet,
const talk_base::PacketTime& packet_time) {}
virtual void OnReadyToSend(bool ready) {} virtual void OnReadyToSend(bool ready) {}
virtual bool AddSendStream(const StreamParams& sp); virtual bool AddSendStream(const StreamParams& sp);
virtual bool RemoveSendStream(uint32 ssrc); virtual bool RemoveSendStream(uint32 ssrc);

View File

@ -63,7 +63,7 @@ class FileNetworkInterface : public MediaChannel::NetworkInterface {
if (!packet) return false; if (!packet) return false;
if (media_channel_) { if (media_channel_) {
media_channel_->OnPacketReceived(packet); media_channel_->OnPacketReceived(packet, talk_base::PacketTime());
} }
if (dump_writer_.get() && if (dump_writer_.get() &&
talk_base::SR_SUCCESS != dump_writer_->WriteRtpPacket( talk_base::SR_SUCCESS != dump_writer_->WriteRtpPacket(

View File

@ -276,19 +276,21 @@ bool HybridVideoMediaChannel::GetStats(VideoMediaInfo* info) {
active_channel_->GetStats(info); active_channel_->GetStats(info);
} }
void HybridVideoMediaChannel::OnPacketReceived(talk_base::Buffer* packet) { void HybridVideoMediaChannel::OnPacketReceived(
talk_base::Buffer* packet, const talk_base::PacketTime& packet_time) {
// Eat packets until we have an active channel; // Eat packets until we have an active channel;
if (active_channel_) { if (active_channel_) {
active_channel_->OnPacketReceived(packet); active_channel_->OnPacketReceived(packet, packet_time);
} else { } else {
LOG(LS_INFO) << "HybridVideoChannel: Eating early RTP packet"; LOG(LS_INFO) << "HybridVideoChannel: Eating early RTP packet";
} }
} }
void HybridVideoMediaChannel::OnRtcpReceived(talk_base::Buffer* packet) { void HybridVideoMediaChannel::OnRtcpReceived(
talk_base::Buffer* packet, const talk_base::PacketTime& packet_time) {
// Eat packets until we have an active channel; // Eat packets until we have an active channel;
if (active_channel_) { if (active_channel_) {
active_channel_->OnRtcpReceived(packet); active_channel_->OnRtcpReceived(packet, packet_time);
} else { } else {
LOG(LS_INFO) << "HybridVideoChannel: Eating early RTCP packet"; LOG(LS_INFO) << "HybridVideoChannel: Eating early RTCP packet";
} }

View File

@ -87,8 +87,10 @@ class HybridVideoMediaChannel : public VideoMediaChannel {
virtual bool GetStats(VideoMediaInfo* info); virtual bool GetStats(VideoMediaInfo* info);
virtual void OnPacketReceived(talk_base::Buffer* packet); virtual void OnPacketReceived(talk_base::Buffer* packet,
virtual void OnRtcpReceived(talk_base::Buffer* packet); const talk_base::PacketTime& packet_time);
virtual void OnRtcpReceived(talk_base::Buffer* packet,
const talk_base::PacketTime& packet_time);
virtual void OnReadyToSend(bool ready); virtual void OnReadyToSend(bool ready);
virtual void UpdateAspectRatio(int ratio_w, int ratio_h); virtual void UpdateAspectRatio(int ratio_w, int ratio_h);

View File

@ -509,9 +509,11 @@ class MediaChannel : public sigslot::has_slots<> {
} }
// Called when a RTP packet is received. // Called when a RTP packet is received.
virtual void OnPacketReceived(talk_base::Buffer* packet) = 0; virtual void OnPacketReceived(talk_base::Buffer* packet,
const talk_base::PacketTime& packet_time) = 0;
// Called when a RTCP packet is received. // Called when a RTCP packet is received.
virtual void OnRtcpReceived(talk_base::Buffer* packet) = 0; virtual void OnRtcpReceived(talk_base::Buffer* packet,
const talk_base::PacketTime& packet_time) = 0;
// Called when the socket's ability to send has changed. // Called when the socket's ability to send has changed.
virtual void OnReadyToSend(bool ready) = 0; virtual void OnReadyToSend(bool ready) = 0;
// Creates a new outgoing media stream with SSRCs and CNAME as described // Creates a new outgoing media stream with SSRCs and CNAME as described
@ -1131,25 +1133,15 @@ class DataMediaChannel : public MediaChannel {
virtual ~DataMediaChannel() {} virtual ~DataMediaChannel() {}
virtual bool SetSendBandwidth(bool autobw, int bps) = 0;
virtual bool SetSendCodecs(const std::vector<DataCodec>& codecs) = 0; virtual bool SetSendCodecs(const std::vector<DataCodec>& codecs) = 0;
virtual bool SetRecvCodecs(const std::vector<DataCodec>& codecs) = 0; virtual bool SetRecvCodecs(const std::vector<DataCodec>& codecs) = 0;
virtual bool SetRecvRtpHeaderExtensions(
const std::vector<RtpHeaderExtension>& extensions) = 0;
virtual bool SetSendRtpHeaderExtensions(
const std::vector<RtpHeaderExtension>& extensions) = 0;
virtual bool AddSendStream(const StreamParams& sp) = 0;
virtual bool RemoveSendStream(uint32 ssrc) = 0;
virtual bool AddRecvStream(const StreamParams& sp) = 0;
virtual bool RemoveRecvStream(uint32 ssrc) = 0;
virtual bool MuteStream(uint32 ssrc, bool on) { return false; } virtual bool MuteStream(uint32 ssrc, bool on) { return false; }
// TODO(pthatcher): Implement this. // TODO(pthatcher): Implement this.
virtual bool GetStats(DataMediaInfo* info) { return true; } virtual bool GetStats(DataMediaInfo* info) { return true; }
virtual bool SetSend(bool send) = 0; virtual bool SetSend(bool send) = 0;
virtual bool SetReceive(bool receive) = 0; virtual bool SetReceive(bool receive) = 0;
virtual void OnPacketReceived(talk_base::Buffer* packet) = 0;
virtual void OnRtcpReceived(talk_base::Buffer* packet) = 0;
virtual bool SendData( virtual bool SendData(
const SendDataParams& params, const SendDataParams& params,

View File

@ -135,6 +135,9 @@ class MediaEngineInterface {
virtual void SetVoiceLogging(int min_sev, const char* filter) = 0; virtual void SetVoiceLogging(int min_sev, const char* filter) = 0;
virtual void SetVideoLogging(int min_sev, const char* filter) = 0; virtual void SetVideoLogging(int min_sev, const char* filter) = 0;
// Starts AEC dump using existing file.
virtual bool StartAecDump(FILE* file) = 0;
// Voice processors for effects. // Voice processors for effects.
virtual bool RegisterVoiceProcessor(uint32 ssrc, virtual bool RegisterVoiceProcessor(uint32 ssrc,
VoiceProcessor* video_processor, VoiceProcessor* video_processor,
@ -253,6 +256,10 @@ class CompositeMediaEngine : public MediaEngineInterface {
video_.SetLogging(min_sev, filter); video_.SetLogging(min_sev, filter);
} }
virtual bool StartAecDump(FILE* file) {
return voice_.StartAecDump(file);
}
virtual bool RegisterVoiceProcessor(uint32 ssrc, virtual bool RegisterVoiceProcessor(uint32 ssrc,
VoiceProcessor* processor, VoiceProcessor* processor,
MediaProcessorDirection direction) { MediaProcessorDirection direction) {

View File

@ -230,7 +230,8 @@ bool RtpDataMediaChannel::RemoveRecvStream(uint32 ssrc) {
return true; return true;
} }
void RtpDataMediaChannel::OnPacketReceived(talk_base::Buffer* packet) { void RtpDataMediaChannel::OnPacketReceived(
talk_base::Buffer* packet, const talk_base::PacketTime& packet_time) {
RtpHeader header; RtpHeader header;
if (!GetRtpHeader(packet->data(), packet->length(), &header)) { if (!GetRtpHeader(packet->data(), packet->length(), &header)) {
// Don't want to log for every corrupt packet. // Don't want to log for every corrupt packet.

View File

@ -115,8 +115,10 @@ class RtpDataMediaChannel : public DataMediaChannel {
receiving_ = receive; receiving_ = receive;
return true; return true;
} }
virtual void OnPacketReceived(talk_base::Buffer* packet); virtual void OnPacketReceived(talk_base::Buffer* packet,
virtual void OnRtcpReceived(talk_base::Buffer* packet) {} const talk_base::PacketTime& packet_time);
virtual void OnRtcpReceived(talk_base::Buffer* packet,
const talk_base::PacketTime& packet_time) {}
virtual void OnReadyToSend(bool ready) {} virtual void OnReadyToSend(bool ready) {}
virtual bool SendData( virtual bool SendData(
const SendDataParams& params, const SendDataParams& params,

View File

@ -423,13 +423,13 @@ TEST_F(RtpDataMediaChannelTest, ReceiveData) {
talk_base::scoped_ptr<cricket::RtpDataMediaChannel> dmc(CreateChannel()); talk_base::scoped_ptr<cricket::RtpDataMediaChannel> dmc(CreateChannel());
// SetReceived not called. // SetReceived not called.
dmc->OnPacketReceived(&packet); dmc->OnPacketReceived(&packet, talk_base::PacketTime());
EXPECT_FALSE(HasReceivedData()); EXPECT_FALSE(HasReceivedData());
dmc->SetReceive(true); dmc->SetReceive(true);
// Unknown payload id // Unknown payload id
dmc->OnPacketReceived(&packet); dmc->OnPacketReceived(&packet, talk_base::PacketTime());
EXPECT_FALSE(HasReceivedData()); EXPECT_FALSE(HasReceivedData());
cricket::DataCodec codec; cricket::DataCodec codec;
@ -440,7 +440,7 @@ TEST_F(RtpDataMediaChannelTest, ReceiveData) {
ASSERT_TRUE(dmc->SetRecvCodecs(codecs)); ASSERT_TRUE(dmc->SetRecvCodecs(codecs));
// Unknown stream // Unknown stream
dmc->OnPacketReceived(&packet); dmc->OnPacketReceived(&packet, talk_base::PacketTime());
EXPECT_FALSE(HasReceivedData()); EXPECT_FALSE(HasReceivedData());
cricket::StreamParams stream; cricket::StreamParams stream;
@ -448,7 +448,7 @@ TEST_F(RtpDataMediaChannelTest, ReceiveData) {
ASSERT_TRUE(dmc->AddRecvStream(stream)); ASSERT_TRUE(dmc->AddRecvStream(stream));
// Finally works! // Finally works!
dmc->OnPacketReceived(&packet); dmc->OnPacketReceived(&packet, talk_base::PacketTime());
EXPECT_TRUE(HasReceivedData()); EXPECT_TRUE(HasReceivedData());
EXPECT_EQ("abcde", GetReceivedData()); EXPECT_EQ("abcde", GetReceivedData());
EXPECT_EQ(5U, GetReceivedDataLen()); EXPECT_EQ(5U, GetReceivedDataLen());
@ -463,6 +463,6 @@ TEST_F(RtpDataMediaChannelTest, InvalidRtpPackets) {
talk_base::scoped_ptr<cricket::RtpDataMediaChannel> dmc(CreateChannel()); talk_base::scoped_ptr<cricket::RtpDataMediaChannel> dmc(CreateChannel());
// Too short // Too short
dmc->OnPacketReceived(&packet); dmc->OnPacketReceived(&packet, talk_base::PacketTime());
EXPECT_FALSE(HasReceivedData()); EXPECT_FALSE(HasReceivedData());
} }

View File

@ -981,7 +981,7 @@ class VideoMediaChannelTest : public testing::Test,
EXPECT_TRUE(SetSend(true)); EXPECT_TRUE(SetSend(true));
EXPECT_TRUE(channel_->SetRender(true)); EXPECT_TRUE(channel_->SetRender(true));
EXPECT_EQ(0, renderer_.num_rendered_frames()); EXPECT_EQ(0, renderer_.num_rendered_frames());
channel_->OnPacketReceived(&packet1); channel_->OnPacketReceived(&packet1, talk_base::PacketTime());
SetRendererAsDefault(); SetRendererAsDefault();
EXPECT_TRUE(SendFrame()); EXPECT_TRUE(SendFrame());
EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout); EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout);

View File

@ -542,7 +542,8 @@ bool SctpDataMediaChannel::SendData(
} }
// Called by network interface when a packet has been received. // Called by network interface when a packet has been received.
void SctpDataMediaChannel::OnPacketReceived(talk_base::Buffer* packet) { void SctpDataMediaChannel::OnPacketReceived(
talk_base::Buffer* packet, const talk_base::PacketTime& packet_time) {
LOG(LS_VERBOSE) << debug_name_ << "->OnPacketReceived(...): " << " length=" LOG(LS_VERBOSE) << debug_name_ << "->OnPacketReceived(...): " << " length="
<< packet->length() << ", sending: " << sending_; << packet->length() << ", sending: " << sending_;
// Only give receiving packets to usrsctp after if connected. This enables two // Only give receiving packets to usrsctp after if connected. This enables two

View File

@ -149,7 +149,8 @@ class SctpDataMediaChannel : public DataMediaChannel,
const talk_base::Buffer& payload, const talk_base::Buffer& payload,
SendDataResult* result = NULL); SendDataResult* result = NULL);
// A packet is received from the network interface. Posted to OnMessage. // A packet is received from the network interface. Posted to OnMessage.
virtual void OnPacketReceived(talk_base::Buffer* packet); virtual void OnPacketReceived(talk_base::Buffer* packet,
const talk_base::PacketTime& packet_time);
// Exposed to allow Post call from c-callbacks. // Exposed to allow Post call from c-callbacks.
talk_base::Thread* worker_thread() const { return worker_thread_; } talk_base::Thread* worker_thread() const { return worker_thread_; }
@ -170,7 +171,8 @@ class SctpDataMediaChannel : public DataMediaChannel,
const std::vector<RtpHeaderExtension>& extensions) { return true; } const std::vector<RtpHeaderExtension>& extensions) { return true; }
virtual bool SetSendCodecs(const std::vector<DataCodec>& codecs); virtual bool SetSendCodecs(const std::vector<DataCodec>& codecs);
virtual bool SetRecvCodecs(const std::vector<DataCodec>& codecs); virtual bool SetRecvCodecs(const std::vector<DataCodec>& codecs);
virtual void OnRtcpReceived(talk_base::Buffer* packet) {} virtual void OnRtcpReceived(talk_base::Buffer* packet,
const talk_base::PacketTime& packet_time) {}
virtual void OnReadyToSend(bool ready) {} virtual void OnReadyToSend(bool ready) {}
// Helper for debugging. // Helper for debugging.

View File

@ -84,7 +84,7 @@ class SctpFakeNetworkInterface : public cricket::MediaChannel::NetworkInterface,
static_cast<talk_base::TypedMessageData<talk_base::Buffer*>*>( static_cast<talk_base::TypedMessageData<talk_base::Buffer*>*>(
msg->pdata)->data(); msg->pdata)->data();
if (dest_) { if (dest_) {
dest_->OnPacketReceived(buffer); dest_->OnPacketReceived(buffer, talk_base::PacketTime());
} }
delete buffer; delete buffer;
} }

View File

@ -339,14 +339,12 @@ class FakeWebRtcVideoEngine
}; };
class Capturer : public webrtc::ViEExternalCapture { class Capturer : public webrtc::ViEExternalCapture {
public: public:
Capturer() : channel_id_(-1), denoising_(false), Capturer() : channel_id_(-1), denoising_(false), last_capture_time_(0) { }
last_capture_time_(0), incoming_frame_num_(0) { }
int channel_id() const { return channel_id_; } int channel_id() const { return channel_id_; }
void set_channel_id(int channel_id) { channel_id_ = channel_id; } void set_channel_id(int channel_id) { channel_id_ = channel_id; }
bool denoising() const { return denoising_; } bool denoising() const { return denoising_; }
void set_denoising(bool denoising) { denoising_ = denoising; } void set_denoising(bool denoising) { denoising_ = denoising; }
int64 last_capture_time() const { return last_capture_time_; } int64 last_capture_time() { return last_capture_time_; }
int incoming_frame_num() const { return incoming_frame_num_; }
// From ViEExternalCapture // From ViEExternalCapture
virtual int IncomingFrame(unsigned char* videoFrame, virtual int IncomingFrame(unsigned char* videoFrame,
@ -361,7 +359,6 @@ class FakeWebRtcVideoEngine
const webrtc::ViEVideoFrameI420& video_frame, const webrtc::ViEVideoFrameI420& video_frame,
unsigned long long captureTime) { unsigned long long captureTime) {
last_capture_time_ = captureTime; last_capture_time_ = captureTime;
++incoming_frame_num_;
return 0; return 0;
} }
@ -369,7 +366,6 @@ class FakeWebRtcVideoEngine
int channel_id_; int channel_id_;
bool denoising_; bool denoising_;
int64 last_capture_time_; int64 last_capture_time_;
int incoming_frame_num_;
}; };
FakeWebRtcVideoEngine(const cricket::VideoCodec* const* codecs, FakeWebRtcVideoEngine(const cricket::VideoCodec* const* codecs,
@ -412,16 +408,6 @@ class FakeWebRtcVideoEngine
int GetLastCapturer() const { return last_capturer_; } int GetLastCapturer() const { return last_capturer_; }
int GetNumCapturers() const { return static_cast<int>(capturers_.size()); } int GetNumCapturers() const { return static_cast<int>(capturers_.size()); }
int GetIncomingFrameNum(int channel_id) const {
for (std::map<int, Capturer*>::const_iterator iter = capturers_.begin();
iter != capturers_.end(); ++iter) {
Capturer* capturer = iter->second;
if (capturer->channel_id() == channel_id) {
return capturer->incoming_frame_num();
}
}
return -1;
}
void set_fail_alloc_capturer(bool fail_alloc_capturer) { void set_fail_alloc_capturer(bool fail_alloc_capturer) {
fail_alloc_capturer_ = fail_alloc_capturer; fail_alloc_capturer_ = fail_alloc_capturer;
} }
@ -827,7 +813,12 @@ class FakeWebRtcVideoEngine
} }
WEBRTC_STUB(RegisterSendTransport, (const int, webrtc::Transport&)); WEBRTC_STUB(RegisterSendTransport, (const int, webrtc::Transport&));
WEBRTC_STUB(DeregisterSendTransport, (const int)); WEBRTC_STUB(DeregisterSendTransport, (const int));
#ifdef USE_WEBRTC_DEV_BRANCH
WEBRTC_STUB(ReceivedRTPPacket, (const int, const void*, const int,
const webrtc::PacketTime&));
#else
WEBRTC_STUB(ReceivedRTPPacket, (const int, const void*, const int)); WEBRTC_STUB(ReceivedRTPPacket, (const int, const void*, const int));
#endif
WEBRTC_STUB(ReceivedRTCPPacket, (const int, const void*, const int)); WEBRTC_STUB(ReceivedRTCPPacket, (const int, const void*, const int));
// Not using WEBRTC_STUB due to bool return value // Not using WEBRTC_STUB due to bool return value
virtual bool IsIPv6Enabled(int channel) { return true; } virtual bool IsIPv6Enabled(int channel) { return true; }

View File

@ -2118,6 +2118,18 @@ bool WebRtcVideoMediaChannel::GetSendChannelKey(uint32 local_ssrc,
return true; return true;
} }
WebRtcVideoChannelSendInfo* WebRtcVideoMediaChannel::GetSendChannel(
VideoCapturer* video_capturer) {
for (SendChannelMap::iterator iter = send_channels_.begin();
iter != send_channels_.end(); ++iter) {
WebRtcVideoChannelSendInfo* send_channel = iter->second;
if (send_channel->video_capturer() == video_capturer) {
return send_channel;
}
}
return NULL;
}
WebRtcVideoChannelSendInfo* WebRtcVideoMediaChannel::GetSendChannel( WebRtcVideoChannelSendInfo* WebRtcVideoMediaChannel::GetSendChannel(
uint32 local_ssrc) { uint32 local_ssrc) {
uint32 key; uint32 key;
@ -2480,7 +2492,8 @@ bool WebRtcVideoMediaChannel::RequestIntraFrame() {
return false; return false;
} }
void WebRtcVideoMediaChannel::OnPacketReceived(talk_base::Buffer* packet) { void WebRtcVideoMediaChannel::OnPacketReceived(
talk_base::Buffer* packet, const talk_base::PacketTime& packet_time) {
// Pick which channel to send this packet to. If this packet doesn't match // Pick which channel to send this packet to. If this packet doesn't match
// any multiplexed streams, just send it to the default channel. Otherwise, // any multiplexed streams, just send it to the default channel. Otherwise,
// send it to the specific decoder instance for that stream. // send it to the specific decoder instance for that stream.
@ -2495,10 +2508,16 @@ void WebRtcVideoMediaChannel::OnPacketReceived(talk_base::Buffer* packet) {
engine()->vie()->network()->ReceivedRTPPacket( engine()->vie()->network()->ReceivedRTPPacket(
which_channel, which_channel,
packet->data(), packet->data(),
#ifdef USE_WEBRTC_DEV_BRANCH
static_cast<int>(packet->length()),
webrtc::PacketTime(packet_time.timestamp, packet_time.not_before));
#else
static_cast<int>(packet->length())); static_cast<int>(packet->length()));
#endif
} }
void WebRtcVideoMediaChannel::OnRtcpReceived(talk_base::Buffer* packet) { void WebRtcVideoMediaChannel::OnRtcpReceived(
talk_base::Buffer* packet, const talk_base::PacketTime& packet_time) {
// Sending channels need all RTCP packets with feedback information. // Sending channels need all RTCP packets with feedback information.
// Even sender reports can contain attached report blocks. // Even sender reports can contain attached report blocks.
// Receiving channels need sender reports in order to create // Receiving channels need sender reports in order to create
@ -2846,23 +2865,20 @@ bool WebRtcVideoMediaChannel::GetRenderer(uint32 ssrc,
return true; return true;
} }
// TODO(zhurunz): Add unittests to test this function.
// TODO(thorcarpenter): This is broken. One capturer registered on two ssrc
// will not send any video to the second ssrc send channel. We should remove
// GetSendChannel(capturer) and pass in an ssrc here.
void WebRtcVideoMediaChannel::SendFrame(VideoCapturer* capturer, void WebRtcVideoMediaChannel::SendFrame(VideoCapturer* capturer,
const VideoFrame* frame) { const VideoFrame* frame) {
// If the |capturer| is registered to any send channel, then send the frame // If there's send channel registers to the |capturer|, then only send the
// to those send channels. // frame to that channel and return. Otherwise send the frame to the default
bool capturer_is_channel_owned = false; // channel, which currently taking frames from the engine.
for (SendChannelMap::iterator iter = send_channels_.begin(); WebRtcVideoChannelSendInfo* send_channel = GetSendChannel(capturer);
iter != send_channels_.end(); ++iter) { if (send_channel) {
WebRtcVideoChannelSendInfo* send_channel = iter->second;
if (send_channel->video_capturer() == capturer) {
SendFrame(send_channel, frame, capturer->IsScreencast()); SendFrame(send_channel, frame, capturer->IsScreencast());
capturer_is_channel_owned = true;
}
}
if (capturer_is_channel_owned) {
return; return;
} }
// TODO(hellner): Remove below for loop once the captured frame no longer // TODO(hellner): Remove below for loop once the captured frame no longer
// come from the engine, i.e. the engine no longer owns a capturer. // come from the engine, i.e. the engine no longer owns a capturer.
for (SendChannelMap::iterator iter = send_channels_.begin(); for (SendChannelMap::iterator iter = send_channels_.begin();

View File

@ -266,8 +266,10 @@ class WebRtcVideoMediaChannel : public talk_base::MessageHandler,
virtual bool SendIntraFrame(); virtual bool SendIntraFrame();
virtual bool RequestIntraFrame(); virtual bool RequestIntraFrame();
virtual void OnPacketReceived(talk_base::Buffer* packet); virtual void OnPacketReceived(talk_base::Buffer* packet,
virtual void OnRtcpReceived(talk_base::Buffer* packet); const talk_base::PacketTime& packet_time);
virtual void OnRtcpReceived(talk_base::Buffer* packet,
const talk_base::PacketTime& packet_time);
virtual void OnReadyToSend(bool ready); virtual void OnReadyToSend(bool ready);
virtual bool MuteStream(uint32 ssrc, bool on); virtual bool MuteStream(uint32 ssrc, bool on);
virtual bool SetRecvRtpHeaderExtensions( virtual bool SetRecvRtpHeaderExtensions(
@ -364,6 +366,7 @@ class WebRtcVideoMediaChannel : public talk_base::MessageHandler,
// If the local ssrc correspond to that of the default channel the key is 0. // If the local ssrc correspond to that of the default channel the key is 0.
// For all other channels the returned key will be the same as the local ssrc. // For all other channels the returned key will be the same as the local ssrc.
bool GetSendChannelKey(uint32 local_ssrc, uint32* key); bool GetSendChannelKey(uint32 local_ssrc, uint32* key);
WebRtcVideoChannelSendInfo* GetSendChannel(VideoCapturer* video_capturer);
WebRtcVideoChannelSendInfo* GetSendChannel(uint32 local_ssrc); WebRtcVideoChannelSendInfo* GetSendChannel(uint32 local_ssrc);
// Creates a new unique key that can be used for inserting a new send channel // Creates a new unique key that can be used for inserting a new send channel
// into |send_channels_| // into |send_channels_|

View File

@ -1216,41 +1216,6 @@ TEST_F(WebRtcVideoEngineTestFake, SetOptionsWithDenoising) {
EXPECT_FALSE(vie_.GetCaptureDenoising(capture_id)); EXPECT_FALSE(vie_.GetCaptureDenoising(capture_id));
} }
TEST_F(WebRtcVideoEngineTestFake, MultipleSendStreamsWithOneCapturer) {
EXPECT_TRUE(SetupEngine());
cricket::FakeVideoCapturer capturer;
for (unsigned int i = 0; i < sizeof(kSsrcs2)/sizeof(kSsrcs2[0]); ++i) {
EXPECT_TRUE(channel_->AddSendStream(
cricket::StreamParams::CreateLegacy(kSsrcs2[i])));
// Register the capturer to the ssrc.
EXPECT_TRUE(channel_->SetCapturer(kSsrcs2[i], &capturer));
}
const int channel0 = vie_.GetChannelFromLocalSsrc(kSsrcs2[0]);
ASSERT_NE(-1, channel0);
const int channel1 = vie_.GetChannelFromLocalSsrc(kSsrcs2[1]);
ASSERT_NE(-1, channel1);
ASSERT_NE(channel0, channel1);
std::vector<cricket::VideoCodec> codecs;
codecs.push_back(kVP8Codec);
EXPECT_TRUE(channel_->SetSendCodecs(codecs));
cricket::WebRtcVideoFrame frame;
const size_t pixel_width = 1;
const size_t pixel_height = 1;
const int64 elapsed_time = 0;
const int64 time_stamp = 0;
EXPECT_TRUE(frame.InitToBlack(kVP8Codec.width, kVP8Codec.height,
pixel_width, pixel_height,
elapsed_time, time_stamp));
channel_->SendFrame(&capturer, &frame);
// Both channels should have received the frame.
EXPECT_EQ(1, vie_.GetIncomingFrameNum(channel0));
EXPECT_EQ(1, vie_.GetIncomingFrameNum(channel1));
}
// Disabled since its flaky: b/11288120 // Disabled since its flaky: b/11288120
TEST_F(WebRtcVideoEngineTestFake, DISABLED_SendReceiveBitratesStats) { TEST_F(WebRtcVideoEngineTestFake, DISABLED_SendReceiveBitratesStats) {

View File

@ -1433,6 +1433,22 @@ bool WebRtcVoiceEngine::SetAudioDeviceModule(webrtc::AudioDeviceModule* adm,
return true; return true;
} }
bool WebRtcVoiceEngine::StartAecDump(FILE* file) {
#ifdef USE_WEBRTC_DEV_BRANCH
StopAecDump();
if (voe_wrapper_->processing()->StartDebugRecording(file) !=
webrtc::AudioProcessing::kNoError) {
LOG_RTCERR1(StartDebugRecording, "FILE*");
fclose(file);
return false;
}
is_dumping_aec_ = true;
return true;
#else
return false;
#endif
}
bool WebRtcVoiceEngine::RegisterProcessor( bool WebRtcVoiceEngine::RegisterProcessor(
uint32 ssrc, uint32 ssrc,
VoiceProcessor* voice_processor, VoiceProcessor* voice_processor,
@ -1590,7 +1606,7 @@ void WebRtcVoiceEngine::StartAecDump(const std::string& filename) {
// Start dumping AEC when we are not dumping. // Start dumping AEC when we are not dumping.
if (voe_wrapper_->processing()->StartDebugRecording( if (voe_wrapper_->processing()->StartDebugRecording(
filename.c_str()) != webrtc::AudioProcessing::kNoError) { filename.c_str()) != webrtc::AudioProcessing::kNoError) {
LOG_RTCERR0(StartDebugRecording); LOG_RTCERR1(StartDebugRecording, filename.c_str());
} else { } else {
is_dumping_aec_ = true; is_dumping_aec_ = true;
} }
@ -2821,7 +2837,8 @@ bool WebRtcVoiceMediaChannel::InsertDtmf(uint32 ssrc, int event,
return true; return true;
} }
void WebRtcVoiceMediaChannel::OnPacketReceived(talk_base::Buffer* packet) { void WebRtcVoiceMediaChannel::OnPacketReceived(
talk_base::Buffer* packet, const talk_base::PacketTime& packet_time) {
// Pick which channel to send this packet to. If this packet doesn't match // Pick which channel to send this packet to. If this packet doesn't match
// any multiplexed streams, just send it to the default channel. Otherwise, // any multiplexed streams, just send it to the default channel. Otherwise,
// send it to the specific decoder instance for that stream. // send it to the specific decoder instance for that stream.
@ -2854,7 +2871,8 @@ void WebRtcVoiceMediaChannel::OnPacketReceived(talk_base::Buffer* packet) {
static_cast<unsigned int>(packet->length())); static_cast<unsigned int>(packet->length()));
} }
void WebRtcVoiceMediaChannel::OnRtcpReceived(talk_base::Buffer* packet) { void WebRtcVoiceMediaChannel::OnRtcpReceived(
talk_base::Buffer* packet, const talk_base::PacketTime& packet_time) {
// Sending channels need all RTCP packets with feedback information. // Sending channels need all RTCP packets with feedback information.
// Even sender reports can contain attached report blocks. // Even sender reports can contain attached report blocks.
// Receiving channels need sender reports in order to create // Receiving channels need sender reports in order to create

View File

@ -174,6 +174,9 @@ class WebRtcVoiceEngine
bool SetAudioDeviceModule(webrtc::AudioDeviceModule* adm, bool SetAudioDeviceModule(webrtc::AudioDeviceModule* adm,
webrtc::AudioDeviceModule* adm_sc); webrtc::AudioDeviceModule* adm_sc);
// Starts AEC dump using existing file.
bool StartAecDump(FILE* file);
// Check whether the supplied trace should be ignored. // Check whether the supplied trace should be ignored.
bool ShouldIgnoreTrace(const std::string& trace); bool ShouldIgnoreTrace(const std::string& trace);
@ -356,8 +359,10 @@ class WebRtcVoiceMediaChannel
virtual bool CanInsertDtmf(); virtual bool CanInsertDtmf();
virtual bool InsertDtmf(uint32 ssrc, int event, int duration, int flags); virtual bool InsertDtmf(uint32 ssrc, int event, int duration, int flags);
virtual void OnPacketReceived(talk_base::Buffer* packet); virtual void OnPacketReceived(talk_base::Buffer* packet,
virtual void OnRtcpReceived(talk_base::Buffer* packet); const talk_base::PacketTime& packet_time);
virtual void OnRtcpReceived(talk_base::Buffer* packet,
const talk_base::PacketTime& packet_time);
virtual void OnReadyToSend(bool ready) {} virtual void OnReadyToSend(bool ready) {}
virtual bool MuteStream(uint32 ssrc, bool on); virtual bool MuteStream(uint32 ssrc, bool on);
virtual bool SetSendBandwidth(bool autobw, int bps); virtual bool SetSendBandwidth(bool autobw, int bps);

View File

@ -139,7 +139,7 @@ class WebRtcVoiceEngineTestFake : public testing::Test {
} }
void DeliverPacket(const void* data, int len) { void DeliverPacket(const void* data, int len) {
talk_base::Buffer packet(data, len); talk_base::Buffer packet(data, len);
channel_->OnPacketReceived(&packet); channel_->OnPacketReceived(&packet, talk_base::PacketTime());
} }
virtual void TearDown() { virtual void TearDown() {
delete soundclip_; delete soundclip_;

View File

@ -126,7 +126,8 @@ void AsyncStunTCPSocket::ProcessInput(char* data, size_t* len) {
return; return;
} }
SignalReadPacket(this, data, expected_pkt_len, remote_addr); SignalReadPacket(this, data, expected_pkt_len, remote_addr,
talk_base::CreatePacketTime(0));
*len -= actual_length; *len -= actual_length;
if (*len > 0) { if (*len > 0) {

View File

@ -109,7 +109,8 @@ class AsyncStunTCPSocketTest : public testing::Test,
} }
void OnReadPacket(talk_base::AsyncPacketSocket* socket, const char* data, void OnReadPacket(talk_base::AsyncPacketSocket* socket, const char* data,
size_t len, const talk_base::SocketAddress& remote_addr) { size_t len, const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time) {
recv_packets_.push_back(std::string(data, len)); recv_packets_.push_back(std::string(data, len));
} }

View File

@ -446,9 +446,9 @@ void DtlsTransportChannelWrapper::OnWritableState(TransportChannel* channel) {
} }
} }
void DtlsTransportChannelWrapper::OnReadPacket(TransportChannel* channel, void DtlsTransportChannelWrapper::OnReadPacket(
const char* data, size_t size, TransportChannel* channel, const char* data, size_t size,
int flags) { const talk_base::PacketTime& packet_time, int flags) {
ASSERT(talk_base::Thread::Current() == worker_thread_); ASSERT(talk_base::Thread::Current() == worker_thread_);
ASSERT(channel == channel_); ASSERT(channel == channel_);
ASSERT(flags == 0); ASSERT(flags == 0);
@ -456,7 +456,7 @@ void DtlsTransportChannelWrapper::OnReadPacket(TransportChannel* channel,
switch (dtls_state_) { switch (dtls_state_) {
case STATE_NONE: case STATE_NONE:
// We are not doing DTLS // We are not doing DTLS
SignalReadPacket(this, data, size, 0); SignalReadPacket(this, data, size, packet_time, 0);
break; break;
case STATE_OFFERED: case STATE_OFFERED:
@ -500,7 +500,7 @@ void DtlsTransportChannelWrapper::OnReadPacket(TransportChannel* channel,
ASSERT(!srtp_ciphers_.empty()); ASSERT(!srtp_ciphers_.empty());
// Signal this upwards as a bypass packet. // Signal this upwards as a bypass packet.
SignalReadPacket(this, data, size, PF_SRTP_BYPASS); SignalReadPacket(this, data, size, packet_time, PF_SRTP_BYPASS);
} }
break; break;
case STATE_CLOSED: case STATE_CLOSED:
@ -535,7 +535,7 @@ void DtlsTransportChannelWrapper::OnDtlsEvent(talk_base::StreamInterface* dtls,
char buf[kMaxDtlsPacketLen]; char buf[kMaxDtlsPacketLen];
size_t read; size_t read;
if (dtls_->Read(buf, sizeof(buf), &read, NULL) == talk_base::SR_SUCCESS) { if (dtls_->Read(buf, sizeof(buf), &read, NULL) == talk_base::SR_SUCCESS) {
SignalReadPacket(this, buf, read, 0); SignalReadPacket(this, buf, read, talk_base::CreatePacketTime(0), 0);
} }
} }
if (sig & talk_base::SE_CLOSE) { if (sig & talk_base::SE_CLOSE) {

View File

@ -225,7 +225,7 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl {
void OnReadableState(TransportChannel* channel); void OnReadableState(TransportChannel* channel);
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,
int flags); const talk_base::PacketTime& packet_time, int flags);
void OnReadyToSend(TransportChannel* channel); void OnReadyToSend(TransportChannel* channel);
void OnDtlsEvent(talk_base::StreamInterface* stream_, int sig, int err); void OnDtlsEvent(talk_base::StreamInterface* stream_, int sig, int err);
bool SetupDtls(); bool SetupDtls();

View File

@ -307,6 +307,7 @@ class DtlsTestClient : public sigslot::has_slots<> {
void OnTransportChannelReadPacket(cricket::TransportChannel* channel, void OnTransportChannelReadPacket(cricket::TransportChannel* channel,
const char* data, size_t size, const char* data, size_t size,
const talk_base::PacketTime& packet_time,
int flags) { int flags) {
uint32 packet_num = 0; uint32 packet_num = 0;
ASSERT_TRUE(VerifyPacket(data, size, &packet_num)); ASSERT_TRUE(VerifyPacket(data, size, &packet_num));
@ -320,6 +321,7 @@ class DtlsTestClient : public sigslot::has_slots<> {
// 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,
const talk_base::PacketTime& time,
int flags) { int flags) {
// Flags shouldn't be set on the underlying TransportChannel packets. // Flags shouldn't be set on the underlying TransportChannel packets.
ASSERT_EQ(0, flags); ASSERT_EQ(0, flags);

View File

@ -204,7 +204,8 @@ class FakeTransportChannel : public TransportChannelImpl,
PacketMessageData* data = static_cast<PacketMessageData*>( PacketMessageData* data = static_cast<PacketMessageData*>(
msg->pdata); msg->pdata);
dest_->SignalReadPacket(dest_, data->packet.data(), dest_->SignalReadPacket(dest_, data->packet.data(),
data->packet.length(), 0); data->packet.length(),
talk_base::CreatePacketTime(0), 0);
delete data; delete data;
} }

View File

@ -1227,8 +1227,9 @@ void P2PTransportChannel::OnPortDestroyed(PortInterface* port) {
} }
// We data is available, let listeners know // We data is available, let listeners know
void P2PTransportChannel::OnReadPacket(Connection *connection, const char *data, void P2PTransportChannel::OnReadPacket(
size_t len) { Connection *connection, const char *data, size_t len,
const talk_base::PacketTime& packet_time) {
ASSERT(worker_thread_ == talk_base::Thread::Current()); ASSERT(worker_thread_ == talk_base::Thread::Current());
// Do not deliver, if packet doesn't belong to the correct transport channel. // Do not deliver, if packet doesn't belong to the correct transport channel.
@ -1236,7 +1237,7 @@ void P2PTransportChannel::OnReadPacket(Connection *connection, const char *data,
return; return;
// Let the client know of an incoming packet // Let the client know of an incoming packet
SignalReadPacket(this, data, len, 0); SignalReadPacket(this, data, len, packet_time, 0);
} }
void P2PTransportChannel::OnReadyToSend(Connection* connection) { void P2PTransportChannel::OnReadyToSend(Connection* connection) {

View File

@ -40,6 +40,7 @@
#include <map> #include <map>
#include <vector> #include <vector>
#include <string> #include <string>
#include "talk/base/asyncpacketsocket.h"
#include "talk/base/sigslot.h" #include "talk/base/sigslot.h"
#include "talk/p2p/base/candidate.h" #include "talk/p2p/base/candidate.h"
#include "talk/p2p/base/portinterface.h" #include "talk/p2p/base/portinterface.h"
@ -207,8 +208,9 @@ class P2PTransportChannel : public TransportChannelImpl,
void OnPortDestroyed(PortInterface* port); void OnPortDestroyed(PortInterface* port);
void OnRoleConflict(PortInterface* port); void OnRoleConflict(PortInterface* port);
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 talk_base::PacketTime& packet_time);
void OnReadyToSend(Connection* connection); void OnReadyToSend(Connection* connection);
void OnConnectionDestroyed(Connection *connection); void OnConnectionDestroyed(Connection *connection);

View File

@ -613,7 +613,8 @@ class P2PTransportChannelTestBase : public testing::Test,
rch->OnCandidate(c); rch->OnCandidate(c);
} }
void OnReadPacket(cricket::TransportChannel* channel, const char* data, void OnReadPacket(cricket::TransportChannel* channel, const char* data,
size_t len, int flags) { size_t len, const talk_base::PacketTime& packet_time,
int flags) {
std::list<std::string>& packets = GetPacketList(channel); std::list<std::string>& packets = GetPacketList(channel);
packets.push_front(std::string(data, len)); packets.push_front(std::string(data, len));
} }

View File

@ -924,7 +924,8 @@ void Connection::OnSendStunPacket(const void* data, size_t size,
} }
} }
void Connection::OnReadPacket(const char* data, size_t size) { void Connection::OnReadPacket(
const char* data, size_t size, const talk_base::PacketTime& packet_time) {
talk_base::scoped_ptr<IceMessage> msg; talk_base::scoped_ptr<IceMessage> msg;
std::string remote_ufrag; std::string remote_ufrag;
const talk_base::SocketAddress& addr(remote_candidate_.address()); const talk_base::SocketAddress& addr(remote_candidate_.address());
@ -938,7 +939,7 @@ void Connection::OnReadPacket(const char* data, size_t size) {
last_data_received_ = talk_base::Time(); last_data_received_ = talk_base::Time();
recv_rate_tracker_.Update(size); recv_rate_tracker_.Update(size);
SignalReadPacket(this, data, size); SignalReadPacket(this, data, size, packet_time);
// If timed out sending writability checks, start up again // If timed out sending writability checks, start up again
if (!pruned_ && (write_state_ == STATE_WRITE_TIMEOUT)) { if (!pruned_ && (write_state_ == STATE_WRITE_TIMEOUT)) {

View File

@ -32,6 +32,7 @@
#include <vector> #include <vector>
#include <map> #include <map>
#include "talk/base/asyncpacketsocket.h"
#include "talk/base/network.h" #include "talk/base/network.h"
#include "talk/base/proxyinfo.h" #include "talk/base/proxyinfo.h"
#include "talk/base/ratetracker.h" #include "talk/base/ratetracker.h"
@ -45,10 +46,6 @@
#include "talk/p2p/base/stunrequest.h" #include "talk/p2p/base/stunrequest.h"
#include "talk/p2p/base/transport.h" #include "talk/p2p/base/transport.h"
namespace talk_base {
class AsyncPacketSocket;
}
namespace cricket { namespace cricket {
class Connection; class Connection;
@ -240,7 +237,8 @@ class Port : public PortInterface, public talk_base::MessageHandler,
// TODO(mallinath) - Make it pure virtual. // TODO(mallinath) - Make it pure virtual.
virtual bool HandleIncomingPacket( virtual bool HandleIncomingPacket(
talk_base::AsyncPacketSocket* socket, const char* data, size_t size, talk_base::AsyncPacketSocket* socket, const char* data, size_t size,
const talk_base::SocketAddress& remote_addr) { const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time) {
ASSERT(false); ASSERT(false);
return false; return false;
} }
@ -470,12 +468,14 @@ class Connection : public talk_base::MessageHandler,
// Error if Send() returns < 0 // Error if Send() returns < 0
virtual int GetError() = 0; virtual int GetError() = 0;
sigslot::signal3<Connection*, const char*, size_t> SignalReadPacket; sigslot::signal4<Connection*, const char*, size_t,
const talk_base::PacketTime&> SignalReadPacket;
sigslot::signal1<Connection*> SignalReadyToSend; sigslot::signal1<Connection*> SignalReadyToSend;
// Called when a packet is received on this connection. // Called when a packet is received on this connection.
void OnReadPacket(const char* data, size_t size); void OnReadPacket(const char* data, size_t size,
const talk_base::PacketTime& packet_time);
// Called when the socket is currently able to send. // Called when the socket is currently able to send.
void OnReadyToSend(); void OnReadyToSend();

View File

@ -1049,7 +1049,8 @@ TEST_F(PortTest, TestLoopbackCallAsIce) {
IceMessage* msg = lport->last_stun_msg(); IceMessage* msg = lport->last_stun_msg();
EXPECT_EQ(STUN_BINDING_REQUEST, msg->type()); EXPECT_EQ(STUN_BINDING_REQUEST, msg->type());
conn->OnReadPacket(lport->last_stun_buf()->Data(), conn->OnReadPacket(lport->last_stun_buf()->Data(),
lport->last_stun_buf()->Length()); lport->last_stun_buf()->Length(),
talk_base::PacketTime());
ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000); ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000);
msg = lport->last_stun_msg(); msg = lport->last_stun_msg();
EXPECT_EQ(STUN_BINDING_RESPONSE, msg->type()); EXPECT_EQ(STUN_BINDING_RESPONSE, msg->type());
@ -1082,7 +1083,7 @@ TEST_F(PortTest, TestLoopbackCallAsIce) {
lport->Reset(); lport->Reset();
talk_base::scoped_ptr<ByteBuffer> buf(new ByteBuffer()); talk_base::scoped_ptr<ByteBuffer> buf(new ByteBuffer());
WriteStunMessage(modified_req.get(), buf.get()); WriteStunMessage(modified_req.get(), buf.get());
conn1->OnReadPacket(buf->Data(), buf->Length()); conn1->OnReadPacket(buf->Data(), buf->Length(), talk_base::PacketTime());
ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000); ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000);
msg = lport->last_stun_msg(); msg = lport->last_stun_msg();
EXPECT_EQ(STUN_BINDING_ERROR_RESPONSE, msg->type()); EXPECT_EQ(STUN_BINDING_ERROR_RESPONSE, msg->type());
@ -1120,7 +1121,8 @@ TEST_F(PortTest, TestIceRoleConflict) {
EXPECT_EQ(STUN_BINDING_REQUEST, msg->type()); EXPECT_EQ(STUN_BINDING_REQUEST, msg->type());
// Send rport binding request to lport. // Send rport binding request to lport.
lconn->OnReadPacket(rport->last_stun_buf()->Data(), lconn->OnReadPacket(rport->last_stun_buf()->Data(),
rport->last_stun_buf()->Length()); rport->last_stun_buf()->Length(),
talk_base::PacketTime());
ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000); ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000);
EXPECT_EQ(STUN_BINDING_RESPONSE, lport->last_stun_msg()->type()); EXPECT_EQ(STUN_BINDING_RESPONSE, lport->last_stun_msg()->type());
@ -1902,7 +1904,8 @@ TEST_F(PortTest, TestHandleStunBindingIndication) {
EXPECT_EQ(STUN_BINDING_REQUEST, msg->type()); EXPECT_EQ(STUN_BINDING_REQUEST, msg->type());
// Send rport binding request to lport. // Send rport binding request to lport.
lconn->OnReadPacket(rport->last_stun_buf()->Data(), lconn->OnReadPacket(rport->last_stun_buf()->Data(),
rport->last_stun_buf()->Length()); rport->last_stun_buf()->Length(),
talk_base::PacketTime());
ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000); ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000);
EXPECT_EQ(STUN_BINDING_RESPONSE, lport->last_stun_msg()->type()); EXPECT_EQ(STUN_BINDING_RESPONSE, lport->last_stun_msg()->type());
uint32 last_ping_received1 = lconn->last_ping_received(); uint32 last_ping_received1 = lconn->last_ping_received();
@ -1910,7 +1913,7 @@ TEST_F(PortTest, TestHandleStunBindingIndication) {
// Adding a delay of 100ms. // Adding a delay of 100ms.
talk_base::Thread::Current()->ProcessMessages(100); talk_base::Thread::Current()->ProcessMessages(100);
// Pinging lconn using stun indication message. // Pinging lconn using stun indication message.
lconn->OnReadPacket(buf->Data(), buf->Length()); lconn->OnReadPacket(buf->Data(), buf->Length(), talk_base::PacketTime());
uint32 last_ping_received2 = lconn->last_ping_received(); uint32 last_ping_received2 = lconn->last_ping_received();
EXPECT_GT(last_ping_received2, last_ping_received1); EXPECT_GT(last_ping_received2, last_ping_received1);
} }
@ -2272,7 +2275,8 @@ TEST_F(PortTest, TestIceLiteConnectivity) {
// Feeding the respone message from litemode to the full mode connection. // Feeding the respone message from litemode to the full mode connection.
ch1.conn()->OnReadPacket(ice_lite_port->last_stun_buf()->Data(), ch1.conn()->OnReadPacket(ice_lite_port->last_stun_buf()->Data(),
ice_lite_port->last_stun_buf()->Length()); ice_lite_port->last_stun_buf()->Length(),
talk_base::PacketTime());
// Verifying full mode connection becomes writable from the response. // Verifying full mode connection becomes writable from the response.
EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, ch1.conn()->write_state(), EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, ch1.conn()->write_state(),
kTimeout); kTimeout);

View File

@ -257,7 +257,7 @@ void RawTransportChannel::OnReadPacket(
PortInterface* port, const char* data, size_t size, PortInterface* port, const char* data, size_t size,
const talk_base::SocketAddress& addr) { const talk_base::SocketAddress& addr) {
ASSERT(port_ == port); ASSERT(port_ == port);
SignalReadPacket(this, data, size, 0); SignalReadPacket(this, data, size, talk_base::CreatePacketTime(0), 0);
} }
void RawTransportChannel::OnMessage(talk_base::Message* msg) { void RawTransportChannel::OnMessage(talk_base::Message* msg) {

View File

@ -155,10 +155,11 @@ class RelayEntry : public talk_base::MessageHandler,
void OnSocketClose(talk_base::AsyncPacketSocket* socket, int error); void OnSocketClose(talk_base::AsyncPacketSocket* socket, int error);
// Called when a packet is received on this socket. // Called when a packet is received on this socket.
void OnReadPacket(talk_base::AsyncPacketSocket* socket, void OnReadPacket(
talk_base::AsyncPacketSocket* socket,
const char* data, size_t size, const char* data, size_t size,
const talk_base::SocketAddress& remote_addr); const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time);
// Called when the socket is currently able to send. // Called when the socket is currently able to send.
void OnReadyToSend(talk_base::AsyncPacketSocket* socket); void OnReadyToSend(talk_base::AsyncPacketSocket* socket);
@ -393,9 +394,11 @@ int RelayPort::GetError() {
void RelayPort::OnReadPacket( void RelayPort::OnReadPacket(
const char* data, size_t size, const char* data, size_t size,
const talk_base::SocketAddress& remote_addr, ProtocolType proto) { const talk_base::SocketAddress& remote_addr,
ProtocolType proto,
const talk_base::PacketTime& packet_time) {
if (Connection* conn = GetConnection(remote_addr)) { if (Connection* conn = GetConnection(remote_addr)) {
conn->OnReadPacket(data, size); conn->OnReadPacket(data, size, packet_time);
} else { } else {
Port::OnReadPacket(data, size, remote_addr, proto); Port::OnReadPacket(data, size, remote_addr, proto);
} }
@ -682,9 +685,11 @@ void RelayEntry::OnSocketClose(talk_base::AsyncPacketSocket* socket,
HandleConnectFailure(socket); HandleConnectFailure(socket);
} }
void RelayEntry::OnReadPacket(talk_base::AsyncPacketSocket* socket, void RelayEntry::OnReadPacket(
talk_base::AsyncPacketSocket* socket,
const char* data, size_t size, const char* data, size_t size,
const talk_base::SocketAddress& remote_addr) { const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time) {
// ASSERT(remote_addr == port_->server_addr()); // ASSERT(remote_addr == port_->server_addr());
// TODO: are we worried about this? // TODO: are we worried about this?
@ -698,7 +703,7 @@ void RelayEntry::OnReadPacket(talk_base::AsyncPacketSocket* socket,
// by the server, The actual remote address is the one we recorded. // by the server, The actual remote address is the one we recorded.
if (!port_->HasMagicCookie(data, size)) { if (!port_->HasMagicCookie(data, size)) {
if (locked_) { if (locked_) {
port_->OnReadPacket(data, size, ext_addr_, PROTO_UDP); port_->OnReadPacket(data, size, ext_addr_, PROTO_UDP, packet_time);
} else { } else {
LOG(WARNING) << "Dropping packet: entry not locked"; LOG(WARNING) << "Dropping packet: entry not locked";
} }
@ -751,7 +756,7 @@ void RelayEntry::OnReadPacket(talk_base::AsyncPacketSocket* socket,
// Process the actual data and remote address in the normal manner. // Process the actual data and remote address in the normal manner.
port_->OnReadPacket(data_attr->bytes(), data_attr->length(), remote_addr2, port_->OnReadPacket(data_attr->bytes(), data_attr->length(), remote_addr2,
PROTO_UDP); PROTO_UDP, packet_time);
} }
void RelayEntry::OnReadyToSend(talk_base::AsyncPacketSocket* socket) { void RelayEntry::OnReadyToSend(talk_base::AsyncPacketSocket* socket) {

View File

@ -99,7 +99,8 @@ class RelayPort : public Port {
// Dispatches the given packet to the port or connection as appropriate. // Dispatches the given packet to the port or connection as appropriate.
void OnReadPacket(const char* data, size_t size, void OnReadPacket(const char* data, size_t size,
const talk_base::SocketAddress& remote_addr, const talk_base::SocketAddress& remote_addr,
ProtocolType proto); ProtocolType proto,
const talk_base::PacketTime& packet_time);
private: private:
friend class RelayEntry; friend class RelayEntry;

View File

@ -78,7 +78,8 @@ class RelayPortTest : public testing::Test,
void OnReadPacket(talk_base::AsyncPacketSocket* socket, void OnReadPacket(talk_base::AsyncPacketSocket* socket,
const char* data, size_t size, const char* data, size_t size,
const talk_base::SocketAddress& remote_addr) { const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time) {
received_packet_count_[socket]++; received_packet_count_[socket]++;
} }

View File

@ -198,7 +198,8 @@ void RelayServer::OnReadEvent(talk_base::AsyncSocket* socket) {
void RelayServer::OnInternalPacket( void RelayServer::OnInternalPacket(
talk_base::AsyncPacketSocket* socket, const char* bytes, size_t size, talk_base::AsyncPacketSocket* socket, const char* bytes, size_t size,
const talk_base::SocketAddress& remote_addr) { const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time) {
// Get the address of the connection we just received on. // Get the address of the connection we just received on.
talk_base::SocketAddressPair ap(remote_addr, socket->GetLocalAddress()); talk_base::SocketAddressPair ap(remote_addr, socket->GetLocalAddress());
@ -242,7 +243,8 @@ void RelayServer::OnInternalPacket(
void RelayServer::OnExternalPacket( void RelayServer::OnExternalPacket(
talk_base::AsyncPacketSocket* socket, const char* bytes, size_t size, talk_base::AsyncPacketSocket* socket, const char* bytes, size_t size,
const talk_base::SocketAddress& remote_addr) { const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time) {
// Get the address of the connection we just received on. // Get the address of the connection we just received on.
talk_base::SocketAddressPair ap(remote_addr, socket->GetLocalAddress()); talk_base::SocketAddressPair ap(remote_addr, socket->GetLocalAddress());

View File

@ -104,10 +104,12 @@ class RelayServer : public talk_base::MessageHandler,
// Called when a packet is received by the server on one of its sockets. // Called when a packet is received by the server on one of its sockets.
void OnInternalPacket(talk_base::AsyncPacketSocket* socket, void OnInternalPacket(talk_base::AsyncPacketSocket* socket,
const char* bytes, size_t size, const char* bytes, size_t size,
const talk_base::SocketAddress& remote_addr); const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time);
void OnExternalPacket(talk_base::AsyncPacketSocket* socket, void OnExternalPacket(talk_base::AsyncPacketSocket* socket,
const char* bytes, size_t size, const char* bytes, size_t size,
const talk_base::SocketAddress& remote_addr); const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time);
void OnReadEvent(talk_base::AsyncSocket* socket); void OnReadEvent(talk_base::AsyncSocket* socket);

View File

@ -814,7 +814,7 @@ struct ChannelHandler : sigslot::has_slots<> {
} }
void OnReadPacket(cricket::TransportChannel* p, const char* buf, void OnReadPacket(cricket::TransportChannel* p, const char* buf,
size_t size, int flags) { size_t size, const talk_base::PacketTime& time, int flags) {
if (memcmp(buf, name.c_str(), name.size()) != 0) if (memcmp(buf, name.c_str(), name.size()) != 0)
return; // drop packet if packet doesn't belong to this channel. This return; // drop packet if packet doesn't belong to this channel. This
// can happen when transport channels are muxed together. // can happen when transport channels are muxed together.

View File

@ -254,9 +254,10 @@ void UDPPort::OnLocalAddressReady(talk_base::AsyncPacketSocket* socket,
MaybePrepareStunCandidate(); MaybePrepareStunCandidate();
} }
void UDPPort::OnReadPacket(talk_base::AsyncPacketSocket* socket, void UDPPort::OnReadPacket(
const char* data, size_t size, talk_base::AsyncPacketSocket* socket, const char* data, size_t size,
const talk_base::SocketAddress& remote_addr) { const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time) {
ASSERT(socket == socket_); ASSERT(socket == socket_);
// Look for a response from the STUN server. // Look for a response from the STUN server.
@ -269,7 +270,7 @@ void UDPPort::OnReadPacket(talk_base::AsyncPacketSocket* socket,
} }
if (Connection* conn = GetConnection(remote_addr)) { if (Connection* conn = GetConnection(remote_addr)) {
conn->OnReadPacket(data, size); conn->OnReadPacket(data, size, packet_time);
} else { } else {
Port::OnReadPacket(data, size, remote_addr, PROTO_UDP); Port::OnReadPacket(data, size, remote_addr, PROTO_UDP);
} }

View File

@ -97,9 +97,10 @@ class UDPPort : public Port {
virtual bool HandleIncomingPacket( virtual bool HandleIncomingPacket(
talk_base::AsyncPacketSocket* socket, const char* data, size_t size, talk_base::AsyncPacketSocket* socket, const char* data, size_t size,
const talk_base::SocketAddress& remote_addr) { const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time) {
// All packets given to UDP port will be consumed. // All packets given to UDP port will be consumed.
OnReadPacket(socket, data, size, remote_addr); OnReadPacket(socket, data, size, remote_addr, packet_time);
return true; return true;
} }
@ -131,7 +132,9 @@ class UDPPort : public Port {
const talk_base::SocketAddress& address); const talk_base::SocketAddress& address);
void OnReadPacket(talk_base::AsyncPacketSocket* socket, void OnReadPacket(talk_base::AsyncPacketSocket* socket,
const char* data, size_t size, const char* data, size_t size,
const talk_base::SocketAddress& remote_addr); const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time);
void OnReadyToSend(talk_base::AsyncPacketSocket* socket); void OnReadyToSend(talk_base::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

@ -99,13 +99,16 @@ class StunPortTest : public testing::Test,
} }
void OnReadPacket(talk_base::AsyncPacketSocket* socket, const char* data, void OnReadPacket(talk_base::AsyncPacketSocket* socket, const char* data,
size_t size, const talk_base::SocketAddress& remote_addr) { size_t size, const talk_base::SocketAddress& remote_addr,
stun_port_->HandleIncomingPacket(socket, data, size, remote_addr); const talk_base::PacketTime& packet_time) {
stun_port_->HandleIncomingPacket(
socket, data, size, remote_addr, talk_base::PacketTime());
} }
void SendData(const char* data, size_t len) { void SendData(const char* data, size_t len) {
stun_port_->HandleIncomingPacket( stun_port_->HandleIncomingPacket(
socket_.get(), data, len, talk_base::SocketAddress("22.22.22.22", 0)); socket_.get(), data, len, talk_base::SocketAddress("22.22.22.22", 0),
talk_base::PacketTime());
} }
protected: protected:

View File

@ -42,7 +42,8 @@ StunServer::~StunServer() {
void StunServer::OnPacket( void StunServer::OnPacket(
talk_base::AsyncPacketSocket* socket, const char* buf, size_t size, talk_base::AsyncPacketSocket* socket, const char* buf, size_t size,
const talk_base::SocketAddress& remote_addr) { const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time) {
// Parse the STUN message; eat any messages that fail to parse. // Parse the STUN message; eat any messages that fail to parse.
talk_base::ByteBuffer bbuf(buf, size); talk_base::ByteBuffer bbuf(buf, size);
StunMessage msg; StunMessage msg;

View File

@ -47,7 +47,8 @@ class StunServer : public sigslot::has_slots<> {
// Slot for AsyncSocket.PacketRead: // Slot for AsyncSocket.PacketRead:
void OnPacket( void OnPacket(
talk_base::AsyncPacketSocket* socket, const char* buf, size_t size, talk_base::AsyncPacketSocket* socket, const char* buf, size_t size,
const talk_base::SocketAddress& remote_addr); const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time);
// Handlers for the different types of STUN/TURN requests: // Handlers for the different types of STUN/TURN requests:
void OnBindingRequest(StunMessage* msg, void OnBindingRequest(StunMessage* msg,

View File

@ -218,7 +218,8 @@ talk_base::AsyncPacketSocket* TCPPort::GetIncoming(
void TCPPort::OnReadPacket(talk_base::AsyncPacketSocket* socket, void TCPPort::OnReadPacket(talk_base::AsyncPacketSocket* socket,
const char* data, size_t size, const char* data, size_t size,
const talk_base::SocketAddress& remote_addr) { const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time) {
Port::OnReadPacket(data, size, remote_addr, PROTO_TCP); Port::OnReadPacket(data, size, remote_addr, PROTO_TCP);
} }
@ -310,11 +311,12 @@ void TCPConnection::OnClose(talk_base::AsyncPacketSocket* socket, int error) {
set_write_state(STATE_WRITE_TIMEOUT); set_write_state(STATE_WRITE_TIMEOUT);
} }
void TCPConnection::OnReadPacket(talk_base::AsyncPacketSocket* socket, void TCPConnection::OnReadPacket(
const char* data, size_t size, talk_base::AsyncPacketSocket* socket, const char* data, size_t size,
const talk_base::SocketAddress& remote_addr) { const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time) {
ASSERT(socket == socket_); ASSERT(socket == socket_);
Connection::OnReadPacket(data, size); Connection::OnReadPacket(data, size, packet_time);
} }
void TCPConnection::OnReadyToSend(talk_base::AsyncPacketSocket* socket) { void TCPConnection::OnReadyToSend(talk_base::AsyncPacketSocket* socket) {

View File

@ -102,7 +102,8 @@ class TCPPort : public Port {
// Receives packet signal from the local TCP Socket. // Receives packet signal from the local TCP Socket.
void OnReadPacket(talk_base::AsyncPacketSocket* socket, void OnReadPacket(talk_base::AsyncPacketSocket* socket,
const char* data, size_t size, const char* data, size_t size,
const talk_base::SocketAddress& remote_addr); const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time);
void OnReadyToSend(talk_base::AsyncPacketSocket* socket); void OnReadyToSend(talk_base::AsyncPacketSocket* socket);
@ -137,7 +138,8 @@ class TCPConnection : public Connection {
void OnClose(talk_base::AsyncPacketSocket* socket, int error); void OnClose(talk_base::AsyncPacketSocket* socket, int error);
void OnReadPacket(talk_base::AsyncPacketSocket* socket, void OnReadPacket(talk_base::AsyncPacketSocket* socket,
const char* data, size_t size, const char* data, size_t size,
const talk_base::SocketAddress& remote_addr); const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time);
void OnReadyToSend(talk_base::AsyncPacketSocket* socket); void OnReadyToSend(talk_base::AsyncPacketSocket* socket);
talk_base::AsyncPacketSocket* socket_; talk_base::AsyncPacketSocket* socket_;

View File

@ -31,6 +31,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "talk/base/asyncpacketsocket.h"
#include "talk/base/basictypes.h" #include "talk/base/basictypes.h"
#include "talk/base/dscp.h" #include "talk/base/dscp.h"
#include "talk/base/sigslot.h" #include "talk/base/sigslot.h"
@ -122,8 +123,8 @@ class TransportChannel : public sigslot::has_slots<> {
size_t result_len) = 0; size_t result_len) = 0;
// Signalled each time a packet is received on this channel. // Signalled each time a packet is received on this channel.
sigslot::signal4<TransportChannel*, const char*, sigslot::signal5<TransportChannel*, const char*,
size_t, int> SignalReadPacket; size_t, const talk_base::PacketTime&, int> SignalReadPacket;
// 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

View File

@ -234,12 +234,12 @@ void TransportChannelProxy::OnWritableState(TransportChannel* channel) {
// Note: SignalWritableState fired by set_readable. // Note: SignalWritableState fired by set_readable.
} }
void TransportChannelProxy::OnReadPacket(TransportChannel* channel, void TransportChannelProxy::OnReadPacket(
const char* data, size_t size, TransportChannel* channel, const char* data, size_t size,
int flags) { const talk_base::PacketTime& packet_time, int flags) {
ASSERT(talk_base::Thread::Current() == worker_thread_); ASSERT(talk_base::Thread::Current() == worker_thread_);
ASSERT(channel == impl_); ASSERT(channel == impl_);
SignalReadPacket(this, data, size, flags); SignalReadPacket(this, data, size, packet_time, flags);
} }
void TransportChannelProxy::OnReadyToSend(TransportChannel* channel) { void TransportChannelProxy::OnReadyToSend(TransportChannel* channel) {

View File

@ -90,7 +90,7 @@ class TransportChannelProxy : public TransportChannel,
void OnReadableState(TransportChannel* channel); void OnReadableState(TransportChannel* channel);
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,
int flags); const talk_base::PacketTime& packet_time, int flags);
void OnReadyToSend(TransportChannel* channel); void OnReadyToSend(TransportChannel* channel);
void OnRouteChange(TransportChannel* channel, const Candidate& candidate); void OnRouteChange(TransportChannel* channel, const Candidate& candidate);

View File

@ -356,9 +356,10 @@ int TurnPort::SendTo(const void* data, size_t size,
return static_cast<int>(size); return static_cast<int>(size);
} }
void TurnPort::OnReadPacket(talk_base::AsyncPacketSocket* socket, void TurnPort::OnReadPacket(
const char* data, size_t size, talk_base::AsyncPacketSocket* socket, const char* data, size_t size,
const talk_base::SocketAddress& remote_addr) { const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time) {
ASSERT(socket == socket_.get()); ASSERT(socket == socket_.get());
ASSERT(remote_addr == server_address_.address); ASSERT(remote_addr == server_address_.address);
@ -373,9 +374,9 @@ void TurnPort::OnReadPacket(talk_base::AsyncPacketSocket* socket,
// a response to a previous request. // a response to a previous request.
uint16 msg_type = talk_base::GetBE16(data); uint16 msg_type = talk_base::GetBE16(data);
if (IsTurnChannelData(msg_type)) { if (IsTurnChannelData(msg_type)) {
HandleChannelData(msg_type, data, size); HandleChannelData(msg_type, data, size, packet_time);
} else if (msg_type == TURN_DATA_INDICATION) { } else if (msg_type == TURN_DATA_INDICATION) {
HandleDataIndication(data, size); HandleDataIndication(data, size, packet_time);
} else { } else {
// This must be a response for one of our requests. // This must be a response for one of our requests.
// Check success responses, but not errors, for MESSAGE-INTEGRITY. // Check success responses, but not errors, for MESSAGE-INTEGRITY.
@ -460,7 +461,8 @@ void TurnPort::OnAllocateRequestTimeout() {
OnAllocateError(); OnAllocateError();
} }
void TurnPort::HandleDataIndication(const char* data, size_t size) { void TurnPort::HandleDataIndication(const char* data, size_t size,
const talk_base::PacketTime& packet_time) {
// Read in the message, and process according to RFC5766, Section 10.4. // Read in the message, and process according to RFC5766, Section 10.4.
talk_base::ByteBuffer buf(data, size); talk_base::ByteBuffer buf(data, size);
TurnMessage msg; TurnMessage msg;
@ -495,11 +497,13 @@ void TurnPort::HandleDataIndication(const char* data, size_t size) {
return; return;
} }
DispatchPacket(data_attr->bytes(), data_attr->length(), ext_addr, PROTO_UDP); DispatchPacket(data_attr->bytes(), data_attr->length(), ext_addr,
PROTO_UDP, packet_time);
} }
void TurnPort::HandleChannelData(int channel_id, const char* data, void TurnPort::HandleChannelData(int channel_id, const char* data,
size_t size) { size_t size,
const talk_base::PacketTime& packet_time) {
// Read the message, and process according to RFC5766, Section 11.6. // Read the message, and process according to RFC5766, Section 11.6.
// 0 1 2 3 // 0 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@ -531,13 +535,14 @@ void TurnPort::HandleChannelData(int channel_id, const char* data,
} }
DispatchPacket(data + TURN_CHANNEL_HEADER_SIZE, len, entry->address(), DispatchPacket(data + TURN_CHANNEL_HEADER_SIZE, len, entry->address(),
PROTO_UDP); PROTO_UDP, packet_time);
} }
void TurnPort::DispatchPacket(const char* data, size_t size, void TurnPort::DispatchPacket(const char* data, size_t size,
const talk_base::SocketAddress& remote_addr, ProtocolType proto) { const talk_base::SocketAddress& remote_addr,
ProtocolType proto, const talk_base::PacketTime& packet_time) {
if (Connection* conn = GetConnection(remote_addr)) { if (Connection* conn = GetConnection(remote_addr)) {
conn->OnReadPacket(data, size); conn->OnReadPacket(data, size, packet_time);
} else { } else {
Port::OnReadPacket(data, size, remote_addr, proto); Port::OnReadPacket(data, size, remote_addr, proto);
} }

View File

@ -32,11 +32,11 @@
#include <string> #include <string>
#include <list> #include <list>
#include "talk/base/asyncpacketsocket.h"
#include "talk/p2p/base/port.h" #include "talk/p2p/base/port.h"
#include "talk/p2p/client/basicportallocator.h" #include "talk/p2p/client/basicportallocator.h"
namespace talk_base { namespace talk_base {
class AsyncPacketSocket;
class AsyncResolver; class AsyncResolver;
class SignalThread; class SignalThread;
} }
@ -79,9 +79,10 @@ class TurnPort : public Port {
virtual int SetOption(talk_base::Socket::Option opt, int value); virtual int SetOption(talk_base::Socket::Option opt, int value);
virtual int GetOption(talk_base::Socket::Option opt, int* value); virtual int GetOption(talk_base::Socket::Option opt, int* value);
virtual int GetError(); virtual int GetError();
virtual void OnReadPacket(talk_base::AsyncPacketSocket* socket, virtual void OnReadPacket(
const char* data, size_t size, talk_base::AsyncPacketSocket* socket, const char* data, size_t size,
const talk_base::SocketAddress& remote_addr); const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time);
virtual void OnReadyToSend(talk_base::AsyncPacketSocket* socket); virtual void OnReadyToSend(talk_base::AsyncPacketSocket* socket);
void OnSocketConnect(talk_base::AsyncPacketSocket* socket); void OnSocketConnect(talk_base::AsyncPacketSocket* socket);
@ -134,10 +135,13 @@ class TurnPort : public Port {
void OnAllocateError(); void OnAllocateError();
void OnAllocateRequestTimeout(); void OnAllocateRequestTimeout();
void HandleDataIndication(const char* data, size_t size); void HandleDataIndication(const char* data, size_t size,
void HandleChannelData(int channel_id, const char* data, size_t size); const talk_base::PacketTime& packet_time);
void HandleChannelData(int channel_id, const char* data, size_t size,
const talk_base::PacketTime& packet_time);
void DispatchPacket(const char* data, size_t size, void DispatchPacket(const char* data, size_t size,
const talk_base::SocketAddress& remote_addr, ProtocolType proto); const talk_base::SocketAddress& remote_addr,
ProtocolType proto, const talk_base::PacketTime& packet_time);
bool ScheduleRefresh(int lifetime); bool ScheduleRefresh(int lifetime);
void SendRequest(StunRequest* request, int delay); void SendRequest(StunRequest* request, int delay);

View File

@ -118,13 +118,15 @@ class TurnPortTest : public testing::Test,
turn_create_permission_success_ = true; turn_create_permission_success_ = true;
} }
} }
void OnTurnReadPacket(Connection* conn, const char* data, size_t size) { void OnTurnReadPacket(Connection* conn, const char* data, size_t size,
const talk_base::PacketTime& packet_time) {
turn_packets_.push_back(talk_base::Buffer(data, size)); turn_packets_.push_back(talk_base::Buffer(data, size));
} }
void OnUdpPortComplete(Port* port) { void OnUdpPortComplete(Port* port) {
udp_ready_ = true; udp_ready_ = true;
} }
void OnUdpReadPacket(Connection* conn, const char* data, size_t size) { void OnUdpReadPacket(Connection* conn, const char* data, size_t size,
const talk_base::PacketTime& packet_time) {
udp_packets_.push_back(talk_base::Buffer(data, size)); udp_packets_.push_back(talk_base::Buffer(data, size));
} }

View File

@ -109,7 +109,8 @@ class TurnServer::Allocation : public talk_base::MessageHandler,
void OnExternalPacket(talk_base::AsyncPacketSocket* socket, void OnExternalPacket(talk_base::AsyncPacketSocket* socket,
const char* data, size_t size, const char* data, size_t size,
const talk_base::SocketAddress& addr); const talk_base::SocketAddress& addr,
const talk_base::PacketTime& packet_time);
static int ComputeLifetime(const TurnMessage* msg); static int ComputeLifetime(const TurnMessage* msg);
bool HasPermission(const talk_base::IPAddress& addr); bool HasPermission(const talk_base::IPAddress& addr);
@ -280,7 +281,8 @@ void TurnServer::OnInternalSocketClose(talk_base::AsyncPacketSocket* socket,
void TurnServer::OnInternalPacket(talk_base::AsyncPacketSocket* socket, void TurnServer::OnInternalPacket(talk_base::AsyncPacketSocket* socket,
const char* data, size_t size, const char* data, size_t size,
const talk_base::SocketAddress& addr) { const talk_base::SocketAddress& addr,
const talk_base::PacketTime& packet_time) {
// Fail if the packet is too small to even contain a channel header. // Fail if the packet is too small to even contain a channel header.
if (size < TURN_CHANNEL_HEADER_SIZE) { if (size < TURN_CHANNEL_HEADER_SIZE) {
return; return;
@ -838,7 +840,8 @@ void TurnServer::Allocation::HandleChannelData(const char* data, size_t size) {
void TurnServer::Allocation::OnExternalPacket( void TurnServer::Allocation::OnExternalPacket(
talk_base::AsyncPacketSocket* socket, talk_base::AsyncPacketSocket* socket,
const char* data, size_t size, const char* data, size_t size,
const talk_base::SocketAddress& addr) { const talk_base::SocketAddress& addr,
const talk_base::PacketTime& packet_time) {
ASSERT(external_socket_.get() == socket); ASSERT(external_socket_.get() == socket);
Channel* channel = FindChannel(addr); Channel* channel = FindChannel(addr);
if (channel) { if (channel) {

View File

@ -33,13 +33,13 @@
#include <set> #include <set>
#include <string> #include <string>
#include "talk/base/asyncpacketsocket.h"
#include "talk/base/messagequeue.h" #include "talk/base/messagequeue.h"
#include "talk/base/sigslot.h" #include "talk/base/sigslot.h"
#include "talk/base/socketaddress.h" #include "talk/base/socketaddress.h"
#include "talk/p2p/base/portinterface.h" #include "talk/p2p/base/portinterface.h"
namespace talk_base { namespace talk_base {
class AsyncPacketSocket;
class ByteBuffer; class ByteBuffer;
class PacketSocketFactory; class PacketSocketFactory;
class Thread; class Thread;
@ -123,7 +123,8 @@ class TurnServer : public sigslot::has_slots<> {
typedef std::map<Connection, Allocation*> AllocationMap; typedef std::map<Connection, Allocation*> AllocationMap;
void OnInternalPacket(talk_base::AsyncPacketSocket* socket, const char* data, void OnInternalPacket(talk_base::AsyncPacketSocket* socket, const char* data,
size_t size, const talk_base::SocketAddress& address); size_t size, const talk_base::SocketAddress& address,
const talk_base::PacketTime& packet_time);
void OnNewInternalConnection(talk_base::AsyncSocket* socket); void OnNewInternalConnection(talk_base::AsyncSocket* socket);

View File

@ -149,7 +149,9 @@ class AllocationSequence : public talk_base::MessageHandler,
void OnReadPacket(talk_base::AsyncPacketSocket* socket, void OnReadPacket(talk_base::AsyncPacketSocket* socket,
const char* data, size_t size, const char* data, size_t size,
const talk_base::SocketAddress& remote_addr); const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time);
void OnPortDestroyed(PortInterface* port); void OnPortDestroyed(PortInterface* port);
BasicPortAllocatorSession* session_; BasicPortAllocatorSession* session_;
@ -1024,13 +1026,15 @@ void AllocationSequence::CreateTurnPort(const RelayServerConfig& config) {
void AllocationSequence::OnReadPacket( void AllocationSequence::OnReadPacket(
talk_base::AsyncPacketSocket* socket, const char* data, size_t size, talk_base::AsyncPacketSocket* socket, const char* data, size_t size,
const talk_base::SocketAddress& remote_addr) { const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time) {
ASSERT(socket == udp_socket_.get()); ASSERT(socket == udp_socket_.get());
for (std::deque<Port*>::iterator iter = ports.begin(); for (std::deque<Port*>::iterator iter = ports.begin();
iter != ports.end(); ++iter) { iter != ports.end(); ++iter) {
// We have only one port in the queue. // We have only one port in the queue.
// TODO(mallinath) - Add shared socket support to Relay and Turn ports. // TODO(mallinath) - Add shared socket support to Relay and Turn ports.
if ((*iter)->HandleIncomingPacket(socket, data, size, remote_addr)) { if ((*iter)->HandleIncomingPacket(
socket, data, size, remote_addr, packet_time)) {
break; break;
} }
} }

View File

@ -610,7 +610,9 @@ void BaseChannel::OnWritableState(TransportChannel* channel) {
} }
void BaseChannel::OnChannelRead(TransportChannel* channel, void BaseChannel::OnChannelRead(TransportChannel* channel,
const char* data, size_t len, int flags) { const char* data, size_t len,
const talk_base::PacketTime& packet_time,
int flags) {
// OnChannelRead gets called from P2PSocket; now pass data to MediaEngine // OnChannelRead gets called from P2PSocket; now pass data to MediaEngine
ASSERT(worker_thread_ == talk_base::Thread::Current()); ASSERT(worker_thread_ == talk_base::Thread::Current());
@ -618,7 +620,7 @@ void BaseChannel::OnChannelRead(TransportChannel* channel,
// transport. We feed RTP traffic into the demuxer to determine if it is RTCP. // transport. We feed RTP traffic into the demuxer to determine if it is RTCP.
bool rtcp = PacketIsRtcp(channel, data, len); bool rtcp = PacketIsRtcp(channel, data, len);
talk_base::Buffer packet(data, len); talk_base::Buffer packet(data, len);
HandlePacket(rtcp, &packet); HandlePacket(rtcp, &packet, packet_time);
} }
void BaseChannel::OnReadyToSend(TransportChannel* channel) { void BaseChannel::OnReadyToSend(TransportChannel* channel) {
@ -774,7 +776,8 @@ bool BaseChannel::WantsPacket(bool rtcp, talk_base::Buffer* packet) {
return true; return true;
} }
void BaseChannel::HandlePacket(bool rtcp, talk_base::Buffer* packet) { void BaseChannel::HandlePacket(bool rtcp, talk_base::Buffer* packet,
const talk_base::PacketTime& packet_time) {
if (!WantsPacket(rtcp, packet)) { if (!WantsPacket(rtcp, packet)) {
return; return;
} }
@ -843,9 +846,9 @@ void BaseChannel::HandlePacket(bool rtcp, talk_base::Buffer* packet) {
// Push it down to the media channel. // Push it down to the media channel.
if (!rtcp) { if (!rtcp) {
media_channel_->OnPacketReceived(packet); media_channel_->OnPacketReceived(packet, packet_time);
} else { } else {
media_channel_->OnRtcpReceived(packet); media_channel_->OnRtcpReceived(packet, packet_time);
} }
} }
@ -1645,8 +1648,10 @@ void VoiceChannel::GetActiveStreams_w(AudioInfo::StreamList* actives) {
} }
void VoiceChannel::OnChannelRead(TransportChannel* channel, void VoiceChannel::OnChannelRead(TransportChannel* channel,
const char* data, size_t len, int flags) { const char* data, size_t len,
BaseChannel::OnChannelRead(channel, data, len, flags); const talk_base::PacketTime& packet_time,
int flags) {
BaseChannel::OnChannelRead(channel, data, len, packet_time, flags);
// Set a flag when we've received an RTP packet. If we're waiting for early // Set a flag when we've received an RTP packet. If we're waiting for early
// media, this will disable the timeout. // media, this will disable the timeout.

View File

@ -265,8 +265,11 @@ class BaseChannel
// From TransportChannel // From TransportChannel
void OnWritableState(TransportChannel* channel); void OnWritableState(TransportChannel* channel);
virtual void OnChannelRead(TransportChannel* channel, const char* data, virtual void OnChannelRead(TransportChannel* channel,
size_t len, int flags); const char* data,
size_t len,
const talk_base::PacketTime& packet_time,
int flags);
void OnReadyToSend(TransportChannel* channel); void OnReadyToSend(TransportChannel* channel);
bool PacketIsRtcp(const TransportChannel* channel, const char* data, bool PacketIsRtcp(const TransportChannel* channel, const char* data,
@ -274,7 +277,8 @@ class BaseChannel
bool SendPacket(bool rtcp, talk_base::Buffer* packet, bool SendPacket(bool rtcp, talk_base::Buffer* packet,
talk_base::DiffServCodePoint dscp); talk_base::DiffServCodePoint dscp);
virtual bool WantsPacket(bool rtcp, talk_base::Buffer* packet); virtual bool WantsPacket(bool rtcp, talk_base::Buffer* packet);
void HandlePacket(bool rtcp, talk_base::Buffer* packet); void HandlePacket(bool rtcp, talk_base::Buffer* packet,
const talk_base::PacketTime& packet_time);
// Apply the new local/remote session description. // Apply the new local/remote session description.
void OnNewLocalDescription(BaseSession* session, ContentAction action); void OnNewLocalDescription(BaseSession* session, ContentAction action);
@ -441,7 +445,9 @@ class VoiceChannel : public BaseChannel {
private: private:
// overrides from BaseChannel // overrides from BaseChannel
virtual void OnChannelRead(TransportChannel* channel, virtual void OnChannelRead(TransportChannel* channel,
const char* data, size_t len, int flags); const char* data, size_t len,
const talk_base::PacketTime& packet_time,
int flags);
virtual void ChangeState(); virtual void ChangeState();
virtual const ContentInfo* GetFirstContent(const SessionDescription* sdesc); virtual const ContentInfo* GetFirstContent(const SessionDescription* sdesc);
virtual bool SetLocalContent_w(const MediaContentDescription* content, virtual bool SetLocalContent_w(const MediaContentDescription* content,

View File

@ -1775,7 +1775,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
channel2_->transport_channel(); channel2_->transport_channel();
transport_channel->SignalReadPacket( transport_channel->SignalReadPacket(
transport_channel, reinterpret_cast<const char*>(kBadPacket), transport_channel, reinterpret_cast<const char*>(kBadPacket),
sizeof(kBadPacket), 0); sizeof(kBadPacket), talk_base::PacketTime(), 0);
EXPECT_EQ_WAIT(T::MediaChannel::ERROR_PLAY_SRTP_ERROR, error_, 500); EXPECT_EQ_WAIT(T::MediaChannel::ERROR_PLAY_SRTP_ERROR, error_, 500);
} }

View File

@ -947,4 +947,9 @@ bool ChannelManager::SetAudioOptions(const AudioOptions& options) {
return true; return true;
} }
bool ChannelManager::StartAecDump(FILE* file) {
return worker_thread_->Invoke<bool>(
Bind(&MediaEngineInterface::StartAecDump, media_engine_.get(), file));
}
} // namespace cricket } // namespace cricket

View File

@ -214,6 +214,9 @@ class ChannelManager : public talk_base::MessageHandler,
void SetVideoCaptureDeviceMaxFormat(const std::string& usb_id, void SetVideoCaptureDeviceMaxFormat(const std::string& usb_id,
const VideoFormat& max_format); const VideoFormat& max_format);
// Starts AEC dump using existing file.
bool StartAecDump(FILE* file);
sigslot::repeater0<> SignalDevicesChange; sigslot::repeater0<> SignalDevicesChange;
sigslot::signal2<VideoCapturer*, CaptureState> SignalVideoCaptureStateChange; sigslot::signal2<VideoCapturer*, CaptureState> SignalVideoCaptureStateChange;

View File

@ -340,7 +340,9 @@ void PseudoTcpChannel::OnChannelWritableState(TransportChannel* channel) {
} }
void PseudoTcpChannel::OnChannelRead(TransportChannel* channel, void PseudoTcpChannel::OnChannelRead(TransportChannel* channel,
const char* data, size_t size, int flags) { const char* data, size_t size,
const talk_base::PacketTime& packet_time,
int flags) {
//LOG_F(LS_VERBOSE) << "(" << size << ")"; //LOG_F(LS_VERBOSE) << "(" << size << ")";
ASSERT(worker_thread_->IsCurrent()); ASSERT(worker_thread_->IsCurrent());
CritScope lock(&cs_); CritScope lock(&cs_);

View File

@ -111,7 +111,7 @@ class PseudoTcpChannel
// Worker thread methods // Worker thread methods
void OnChannelWritableState(TransportChannel* channel); void OnChannelWritableState(TransportChannel* channel);
void OnChannelRead(TransportChannel* channel, const char* data, size_t size, void OnChannelRead(TransportChannel* channel, const char* data, size_t size,
int flags); const talk_base::PacketTime& packet_time, int flags);
void OnChannelConnectionChanged(TransportChannel* channel, void OnChannelConnectionChanged(TransportChannel* channel,
const Candidate& candidate); const Candidate& candidate);

View File

@ -677,6 +677,22 @@ struct OverUseDetectorOptions {
double initial_threshold; double initial_threshold;
}; };
// This structure will have the information about when packet is actually
// received by socket.
struct PacketTime {
PacketTime() : timestamp(-1), max_error_us(-1) {}
PacketTime(int64_t timestamp, int64_t max_error_us)
: timestamp(timestamp), max_error_us(max_error_us) {
}
int64_t timestamp; // Receive time after socket delivers the data.
int64_t max_error_us; // Earliest possible time the data could have arrived,
// indicating the potential error in the |timestamp|
// value,in case the system is busy.
// For example, the time of the last select() call.
// If unknown, this value will be set to zero.
};
} // namespace webrtc } // namespace webrtc
#endif // WEBRTC_COMMON_TYPES_H_ #endif // WEBRTC_COMMON_TYPES_H_

View File

@ -105,7 +105,8 @@ void VideoChannelTransport::IncomingRTPPacket(
const int32_t packet_length, const int32_t packet_length,
const char* /*from_ip*/, const char* /*from_ip*/,
const uint16_t /*from_port*/) { const uint16_t /*from_port*/) {
vie_network_->ReceivedRTPPacket(channel_, incoming_rtp_packet, packet_length); vie_network_->ReceivedRTPPacket(
channel_, incoming_rtp_packet, packet_length, PacketTime());
} }
void VideoChannelTransport::IncomingRTCPPacket( void VideoChannelTransport::IncomingRTCPPacket(

View File

@ -161,7 +161,8 @@ bool VideoReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) {
bool VideoReceiveStream::DeliverRtp(const uint8_t* packet, size_t length) { bool VideoReceiveStream::DeliverRtp(const uint8_t* packet, size_t length) {
return network_->ReceivedRTPPacket( return network_->ReceivedRTPPacket(
channel_, packet, static_cast<int>(length)) == 0; channel_, packet, static_cast<int>(length),
PacketTime()) == 0;
} }
int32_t VideoReceiveStream::RenderFrame(const uint32_t stream_id, int32_t VideoReceiveStream::RenderFrame(const uint32_t stream_id,

View File

@ -65,7 +65,8 @@ class WEBRTC_DLLEXPORT ViENetwork {
// the RTP header and payload. // the RTP header and payload.
virtual int ReceivedRTPPacket(const int video_channel, virtual int ReceivedRTPPacket(const int video_channel,
const void* data, const void* data,
const int length) = 0; const int length,
const PacketTime& packet_time) = 0;
// When using external transport for a channel, received RTCP packets should // When using external transport for a channel, received RTCP packets should
// be passed to VideoEngine using this function. // be passed to VideoEngine using this function.

View File

@ -458,7 +458,8 @@ bool TbExternalTransport::ViEExternalTransportProcess()
} }
_vieNetwork.ReceivedRTPPacket(destination_channel, _vieNetwork.ReceivedRTPPacket(destination_channel,
packet->packetBuffer, packet->packetBuffer,
packet->length); packet->length,
webrtc::PacketTime());
delete packet; delete packet;
packet = NULL; packet = NULL;
} }

View File

@ -1612,14 +1612,16 @@ int32_t ViEChannel::DeregisterSendTransport() {
} }
int32_t ViEChannel::ReceivedRTPPacket( int32_t ViEChannel::ReceivedRTPPacket(
const void* rtp_packet, const int32_t rtp_packet_length) { const void* rtp_packet, const int32_t rtp_packet_length,
const PacketTime& packet_time) {
{ {
CriticalSectionScoped cs(callback_cs_.get()); CriticalSectionScoped cs(callback_cs_.get());
if (!external_transport_) { if (!external_transport_) {
return -1; return -1;
} }
} }
return vie_receiver_.ReceivedRTPPacket(rtp_packet, rtp_packet_length); return vie_receiver_.ReceivedRTPPacket(
rtp_packet, rtp_packet_length, packet_time);
} }
int32_t ViEChannel::ReceivedRTCPPacket( int32_t ViEChannel::ReceivedRTCPPacket(

View File

@ -262,7 +262,8 @@ class ViEChannel
// Incoming packet from external transport. // Incoming packet from external transport.
int32_t ReceivedRTPPacket(const void* rtp_packet, int32_t ReceivedRTPPacket(const void* rtp_packet,
const int32_t rtp_packet_length); const int32_t rtp_packet_length,
const PacketTime& packet_time);
// Incoming packet from external transport. // Incoming packet from external transport.
int32_t ReceivedRTCPPacket(const void* rtcp_packet, int32_t ReceivedRTCPPacket(const void* rtcp_packet,

View File

@ -141,7 +141,8 @@ int ViENetworkImpl::DeregisterSendTransport(const int video_channel) {
} }
int ViENetworkImpl::ReceivedRTPPacket(const int video_channel, const void* data, int ViENetworkImpl::ReceivedRTPPacket(const int video_channel, const void* data,
const int length) { const int length,
const PacketTime& packet_time) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel), ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d, data: -, length: %d)", __FUNCTION__, "%s(channel: %d, data: -, length: %d)", __FUNCTION__,
@ -156,7 +157,7 @@ int ViENetworkImpl::ReceivedRTPPacket(const int video_channel, const void* data,
shared_data_->SetLastError(kViENetworkInvalidChannelId); shared_data_->SetLastError(kViENetworkInvalidChannelId);
return -1; return -1;
} }
return vie_channel->ReceivedRTPPacket(data, length); return vie_channel->ReceivedRTPPacket(data, length, packet_time);
} }
int ViENetworkImpl::ReceivedRTCPPacket(const int video_channel, int ViENetworkImpl::ReceivedRTCPPacket(const int video_channel,

View File

@ -32,7 +32,8 @@ class ViENetworkImpl
virtual int DeregisterSendTransport(const int video_channel); virtual int DeregisterSendTransport(const int video_channel);
virtual int ReceivedRTPPacket(const int video_channel, virtual int ReceivedRTPPacket(const int video_channel,
const void* data, const void* data,
const int length); const int length,
const PacketTime& packet_time);
virtual int ReceivedRTCPPacket(const int video_channel, virtual int ReceivedRTCPPacket(const int video_channel,
const void* data, const void* data,
const int length); const int length);

View File

@ -177,9 +177,10 @@ bool ViEReceiver::SetReceiveAbsoluteSendTimeStatus(bool enable, int id) {
} }
int ViEReceiver::ReceivedRTPPacket(const void* rtp_packet, int ViEReceiver::ReceivedRTPPacket(const void* rtp_packet,
int rtp_packet_length) { int rtp_packet_length,
const PacketTime& packet_time) {
return InsertRTPPacket(static_cast<const int8_t*>(rtp_packet), return InsertRTPPacket(static_cast<const int8_t*>(rtp_packet),
rtp_packet_length); rtp_packet_length, packet_time);
} }
int ViEReceiver::ReceivedRTCPPacket(const void* rtcp_packet, int ViEReceiver::ReceivedRTCPPacket(const void* rtcp_packet,
@ -211,7 +212,8 @@ bool ViEReceiver::OnRecoveredPacket(const uint8_t* rtp_packet,
} }
int ViEReceiver::InsertRTPPacket(const int8_t* rtp_packet, int ViEReceiver::InsertRTPPacket(const int8_t* rtp_packet,
int rtp_packet_length) { int rtp_packet_length,
const PacketTime& packet_time) {
// TODO(mflodman) Change decrypt to get rid of this cast. // TODO(mflodman) Change decrypt to get rid of this cast.
int8_t* tmp_ptr = const_cast<int8_t*>(rtp_packet); int8_t* tmp_ptr = const_cast<int8_t*>(rtp_packet);
unsigned char* received_packet = reinterpret_cast<unsigned char*>(tmp_ptr); unsigned char* received_packet = reinterpret_cast<unsigned char*>(tmp_ptr);
@ -256,7 +258,13 @@ int ViEReceiver::InsertRTPPacket(const int8_t* rtp_packet,
return -1; return -1;
} }
int payload_length = received_packet_length - header.headerLength; int payload_length = received_packet_length - header.headerLength;
remote_bitrate_estimator_->IncomingPacket(TickTime::MillisecondTimestamp(), int64_t arrival_time_ms;
if (packet_time.timestamp != -1)
arrival_time_ms = (packet_time.timestamp + 500) / 1000;
else
arrival_time_ms = TickTime::MillisecondTimestamp();
remote_bitrate_estimator_->IncomingPacket(arrival_time_ms,
payload_length, header); payload_length, header);
header.payload_type_frequency = kVideoPayloadTypeFrequency; header.payload_type_frequency = kVideoPayloadTypeFrequency;

Some files were not shown because too many files have changed in this diff Show More