Update talk to 58127566 together with

https://webrtc-codereview.appspot.com/5309005/.

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@5277 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
wu@webrtc.org 2013-12-13 00:21:03 +00:00
parent a92baead39
commit a9890800e0
93 changed files with 473 additions and 278 deletions

View File

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

View File

@ -117,13 +117,6 @@ class MediaConstraintsInterface {
// stripped by Chrome before passed down to Libjingle.
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:
// Dtor protected as objects shouldn't be deleted via this interface
virtual ~MediaConstraintsInterface() {}

View File

@ -105,12 +105,21 @@ struct CreateVideoSourceParams : public talk_base::MessageData {
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 {
MSG_INIT_FACTORY = 1,
MSG_TERMINATE_FACTORY,
MSG_CREATE_PEERCONNECTION,
MSG_CREATE_AUDIOSOURCE,
MSG_CREATE_VIDEOSOURCE,
MSG_START_AEC_DUMP,
};
} // namespace
@ -223,6 +232,12 @@ void PeerConnectionFactory::OnMessage(talk_base::Message* msg) {
pdata->source = CreateVideoSource_s(pdata->capturer, pdata->constraints);
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);
}
bool PeerConnectionFactory::StartAecDump_s(FILE* file) {
return channel_manager_->StartAecDump(file);
}
scoped_refptr<PeerConnectionInterface>
PeerConnectionFactory::CreatePeerConnection(
const PeerConnectionInterface::IceServers& configuration,
@ -361,6 +380,12 @@ scoped_refptr<AudioTrackInterface> PeerConnectionFactory::CreateAudioTrack(
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() {
return channel_manager_.get();
}

View File

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

View File

@ -393,11 +393,9 @@ class PeerConnectionFactoryInterface : public talk_base::RefCountInterface {
class Options {
public:
Options() :
enable_aec_dump(false),
disable_encryption(false),
disable_sctp_data_channels(false) {
}
bool enable_aec_dump;
bool disable_encryption;
bool disable_sctp_data_channels;
};
@ -442,6 +440,12 @@ class PeerConnectionFactoryInterface : public talk_base::RefCountInterface {
CreateAudioTrack(const std::string& label,
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:
// Dtor and ctor protected as objects shouldn't be created or deleted via
// this interface.

View File

@ -31,9 +31,30 @@
#include "talk/base/dscp.h"
#include "talk/base/sigslot.h"
#include "talk/base/socket.h"
#include "talk/base/timeutils.h"
namespace talk_base {
// This structure will have the information about when packet is actually
// received by socket.
struct PacketTime {
PacketTime() : timestamp(0), not_before(0) {}
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
// buffered since it is acceptable to drop packets under high load.
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
// connected TCP sockets.
sigslot::signal4<AsyncPacketSocket*, const char*, size_t,
const SocketAddress&> SignalReadPacket;
sigslot::signal5<AsyncPacketSocket*, const char*, size_t,
const SocketAddress&,
const PacketTime&> SignalReadPacket;
// Emitted when the socket is currently able to send.
sigslot::signal1<AsyncPacketSocket*> SignalReadyToSend;

View File

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

View File

@ -128,7 +128,8 @@ void AsyncUDPSocket::OnReadEvent(AsyncSocket* socket) {
// TODO: Make sure that we got all of the packet.
// 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) {

View File

@ -107,7 +107,7 @@ NATServer::~NATServer() {
void NATServer::OnInternalPacket(
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.
SocketAddress dest_addr;
@ -132,7 +132,7 @@ void NATServer::OnInternalPacket(
void NATServer::OnExternalPacket(
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();

View File

@ -79,9 +79,11 @@ class NATServer : public sigslot::has_slots<> {
// Packets received on one of the networks.
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,
size_t size, const SocketAddress& remote_addr);
size_t size, const SocketAddress& remote_addr,
const PacketTime& packet_time);
private:
typedef std::set<SocketAddress, AddrCmp> AddressSet;

View File

@ -135,7 +135,8 @@ bool TestClient::ready_to_send() const {
}
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_);
packets_->push_back(new Packet(remote_addr, buf, size));
}

View File

@ -94,7 +94,8 @@ class TestClient : public sigslot::has_slots<> {
Socket::ConnState GetState();
// Slot for packets read on the socket.
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);
CriticalSection crit_;

View File

@ -67,7 +67,8 @@ class TestEchoServer : public sigslot::has_slots<> {
}
}
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);
}
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(); }
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));
uint32 prev = reinterpret_cast<const uint32*>(buf)[0];
uint32 result = Next(prev);

View File

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

View File

@ -42,6 +42,8 @@ static const int64 kNumMicrosecsPerMillisec = kNumMicrosecsPerSec /
kNumMillisecsPerSec;
static const int64 kNumNanosecsPerMillisec = kNumNanosecsPerSec /
kNumMillisecsPerSec;
static const int64 kNumNanosecsPerMicrosec = kNumNanosecsPerSec /
kNumMicrosecsPerSec;
// January 1970, in NTP milliseconds.
static const int64 kJan1970AsNtpMillisecs = INT64_C(2208988800000);
@ -50,6 +52,8 @@ typedef uint32 TimeStamp;
// Returns the current time in milliseconds.
uint32 Time();
// Returns the current time in microseconds.
uint64 TimeMicros();
// Returns the current time in nanoseconds.
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,
const SocketAddress& remote_addr) {
const SocketAddress& remote_addr,
const PacketTime& packet_time) {
ASSERT_EQ(socket.get(), s);
ASSERT_GE(size, 4U);

View File

@ -191,10 +191,12 @@ template <class Base> class RtpHelper : public Base {
return true;
}
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()));
}
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()));
}
virtual void OnReadyToSend(bool ready) {
@ -776,6 +778,8 @@ class FakeVoiceEngine : public FakeBaseEngine {
bool SetLocalMonitor(bool enable) { return true; }
bool StartAecDump(FILE* file) { return false; }
bool RegisterProcessor(uint32 ssrc, VoiceProcessor* voice_processor,
MediaProcessorDirection direction) {
if (direction == MPD_RX) {

View File

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

View File

@ -315,7 +315,8 @@ bool FileVoiceChannel::RemoveSendStream(uint32 ssrc) {
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);
}
@ -360,7 +361,8 @@ bool FileVideoChannel::RemoveSendStream(uint32 ssrc) {
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);
}

View File

@ -133,6 +133,7 @@ class FileMediaEngine : public MediaEngineInterface {
virtual bool FindVideoCodec(const VideoCodec& codec) { return true; }
virtual void SetVoiceLogging(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) {
return true;
@ -232,8 +233,10 @@ class FileVoiceChannel : public VoiceMediaChannel {
virtual bool GetStats(VoiceMediaInfo* info) { return true; }
// Implement pure virtual methods of MediaChannel.
virtual void OnPacketReceived(talk_base::Buffer* packet);
virtual void OnRtcpReceived(talk_base::Buffer* packet) {}
virtual void OnPacketReceived(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 bool AddSendStream(const StreamParams& sp);
virtual bool RemoveSendStream(uint32 ssrc);
@ -298,8 +301,10 @@ class FileVideoChannel : public VideoMediaChannel {
virtual bool RequestIntraFrame() { return false; }
// Implement pure virtual methods of MediaChannel.
virtual void OnPacketReceived(talk_base::Buffer* packet);
virtual void OnRtcpReceived(talk_base::Buffer* packet) {}
virtual void OnPacketReceived(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 bool AddSendStream(const StreamParams& sp);
virtual bool RemoveSendStream(uint32 ssrc);

View File

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

View File

@ -276,19 +276,21 @@ bool HybridVideoMediaChannel::GetStats(VideoMediaInfo* 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;
if (active_channel_) {
active_channel_->OnPacketReceived(packet);
active_channel_->OnPacketReceived(packet, packet_time);
} else {
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;
if (active_channel_) {
active_channel_->OnRtcpReceived(packet);
active_channel_->OnRtcpReceived(packet, packet_time);
} else {
LOG(LS_INFO) << "HybridVideoChannel: Eating early RTCP packet";
}

View File

@ -87,8 +87,10 @@ class HybridVideoMediaChannel : public VideoMediaChannel {
virtual bool GetStats(VideoMediaInfo* info);
virtual void OnPacketReceived(talk_base::Buffer* packet);
virtual void OnRtcpReceived(talk_base::Buffer* packet);
virtual void OnPacketReceived(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 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.
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.
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.
virtual void OnReadyToSend(bool ready) = 0;
// Creates a new outgoing media stream with SSRCs and CNAME as described
@ -1131,25 +1133,15 @@ class DataMediaChannel : public MediaChannel {
virtual ~DataMediaChannel() {}
virtual bool SetSendBandwidth(bool autobw, int bps) = 0;
virtual bool SetSendCodecs(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; }
// TODO(pthatcher): Implement this.
virtual bool GetStats(DataMediaInfo* info) { return true; }
virtual bool SetSend(bool send) = 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(
const SendDataParams& params,

View File

@ -135,6 +135,9 @@ class MediaEngineInterface {
virtual void SetVoiceLogging(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.
virtual bool RegisterVoiceProcessor(uint32 ssrc,
VoiceProcessor* video_processor,
@ -253,6 +256,10 @@ class CompositeMediaEngine : public MediaEngineInterface {
video_.SetLogging(min_sev, filter);
}
virtual bool StartAecDump(FILE* file) {
return voice_.StartAecDump(file);
}
virtual bool RegisterVoiceProcessor(uint32 ssrc,
VoiceProcessor* processor,
MediaProcessorDirection direction) {

View File

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

View File

@ -115,8 +115,10 @@ class RtpDataMediaChannel : public DataMediaChannel {
receiving_ = receive;
return true;
}
virtual void OnPacketReceived(talk_base::Buffer* packet);
virtual void OnRtcpReceived(talk_base::Buffer* packet) {}
virtual void OnPacketReceived(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 bool SendData(
const SendDataParams& params,

View File

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

View File

@ -981,7 +981,7 @@ class VideoMediaChannelTest : public testing::Test,
EXPECT_TRUE(SetSend(true));
EXPECT_TRUE(channel_->SetRender(true));
EXPECT_EQ(0, renderer_.num_rendered_frames());
channel_->OnPacketReceived(&packet1);
channel_->OnPacketReceived(&packet1, talk_base::PacketTime());
SetRendererAsDefault();
EXPECT_TRUE(SendFrame());
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.
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="
<< packet->length() << ", sending: " << sending_;
// 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,
SendDataResult* result = NULL);
// 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.
talk_base::Thread* worker_thread() const { return worker_thread_; }
@ -170,7 +171,8 @@ class SctpDataMediaChannel : public DataMediaChannel,
const std::vector<RtpHeaderExtension>& extensions) { return true; }
virtual bool SetSendCodecs(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) {}
// Helper for debugging.

View File

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

View File

@ -339,14 +339,12 @@ class FakeWebRtcVideoEngine
};
class Capturer : public webrtc::ViEExternalCapture {
public:
Capturer() : channel_id_(-1), denoising_(false),
last_capture_time_(0), incoming_frame_num_(0) { }
Capturer() : channel_id_(-1), denoising_(false), last_capture_time_(0) { }
int channel_id() const { return channel_id_; }
void set_channel_id(int channel_id) { channel_id_ = channel_id; }
bool denoising() const { return denoising_; }
void set_denoising(bool denoising) { denoising_ = denoising; }
int64 last_capture_time() const { return last_capture_time_; }
int incoming_frame_num() const { return incoming_frame_num_; }
int64 last_capture_time() { return last_capture_time_; }
// From ViEExternalCapture
virtual int IncomingFrame(unsigned char* videoFrame,
@ -361,7 +359,6 @@ class FakeWebRtcVideoEngine
const webrtc::ViEVideoFrameI420& video_frame,
unsigned long long captureTime) {
last_capture_time_ = captureTime;
++incoming_frame_num_;
return 0;
}
@ -369,7 +366,6 @@ class FakeWebRtcVideoEngine
int channel_id_;
bool denoising_;
int64 last_capture_time_;
int incoming_frame_num_;
};
FakeWebRtcVideoEngine(const cricket::VideoCodec* const* codecs,
@ -412,16 +408,6 @@ class FakeWebRtcVideoEngine
int GetLastCapturer() const { return last_capturer_; }
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) {
fail_alloc_capturer_ = fail_alloc_capturer;
}
@ -827,7 +813,12 @@ class FakeWebRtcVideoEngine
}
WEBRTC_STUB(RegisterSendTransport, (const int, webrtc::Transport&));
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));
#endif
WEBRTC_STUB(ReceivedRTCPPacket, (const int, const void*, const int));
// Not using WEBRTC_STUB due to bool return value
virtual bool IsIPv6Enabled(int channel) { return true; }

View File

@ -2118,6 +2118,18 @@ bool WebRtcVideoMediaChannel::GetSendChannelKey(uint32 local_ssrc,
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(
uint32 local_ssrc) {
uint32 key;
@ -2480,7 +2492,8 @@ bool WebRtcVideoMediaChannel::RequestIntraFrame() {
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
// any multiplexed streams, just send it to the default channel. Otherwise,
// 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(
which_channel,
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()));
#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.
// Even sender reports can contain attached report blocks.
// Receiving channels need sender reports in order to create
@ -2846,23 +2865,20 @@ bool WebRtcVideoMediaChannel::GetRenderer(uint32 ssrc,
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,
const VideoFrame* frame) {
// If the |capturer| is registered to any send channel, then send the frame
// to those send channels.
bool capturer_is_channel_owned = false;
for (SendChannelMap::iterator iter = send_channels_.begin();
iter != send_channels_.end(); ++iter) {
WebRtcVideoChannelSendInfo* send_channel = iter->second;
if (send_channel->video_capturer() == capturer) {
SendFrame(send_channel, frame, capturer->IsScreencast());
capturer_is_channel_owned = true;
}
}
if (capturer_is_channel_owned) {
// If there's send channel registers to the |capturer|, then only send the
// frame to that channel and return. Otherwise send the frame to the default
// channel, which currently taking frames from the engine.
WebRtcVideoChannelSendInfo* send_channel = GetSendChannel(capturer);
if (send_channel) {
SendFrame(send_channel, frame, capturer->IsScreencast());
return;
}
// 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.
for (SendChannelMap::iterator iter = send_channels_.begin();

View File

@ -266,8 +266,10 @@ class WebRtcVideoMediaChannel : public talk_base::MessageHandler,
virtual bool SendIntraFrame();
virtual bool RequestIntraFrame();
virtual void OnPacketReceived(talk_base::Buffer* packet);
virtual void OnRtcpReceived(talk_base::Buffer* packet);
virtual void OnPacketReceived(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 bool MuteStream(uint32 ssrc, bool on);
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.
// For all other channels the returned key will be the same as the local ssrc.
bool GetSendChannelKey(uint32 local_ssrc, uint32* key);
WebRtcVideoChannelSendInfo* GetSendChannel(VideoCapturer* video_capturer);
WebRtcVideoChannelSendInfo* GetSendChannel(uint32 local_ssrc);
// Creates a new unique key that can be used for inserting a new send channel
// into |send_channels_|

View File

@ -1216,41 +1216,6 @@ TEST_F(WebRtcVideoEngineTestFake, SetOptionsWithDenoising) {
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
TEST_F(WebRtcVideoEngineTestFake, DISABLED_SendReceiveBitratesStats) {

View File

@ -1433,6 +1433,22 @@ bool WebRtcVoiceEngine::SetAudioDeviceModule(webrtc::AudioDeviceModule* adm,
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(
uint32 ssrc,
VoiceProcessor* voice_processor,
@ -1590,7 +1606,7 @@ void WebRtcVoiceEngine::StartAecDump(const std::string& filename) {
// Start dumping AEC when we are not dumping.
if (voe_wrapper_->processing()->StartDebugRecording(
filename.c_str()) != webrtc::AudioProcessing::kNoError) {
LOG_RTCERR0(StartDebugRecording);
LOG_RTCERR1(StartDebugRecording, filename.c_str());
} else {
is_dumping_aec_ = true;
}
@ -2821,7 +2837,8 @@ bool WebRtcVoiceMediaChannel::InsertDtmf(uint32 ssrc, int event,
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
// any multiplexed streams, just send it to the default channel. Otherwise,
// 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()));
}
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.
// Even sender reports can contain attached report blocks.
// Receiving channels need sender reports in order to create

View File

@ -174,6 +174,9 @@ class WebRtcVoiceEngine
bool SetAudioDeviceModule(webrtc::AudioDeviceModule* adm,
webrtc::AudioDeviceModule* adm_sc);
// Starts AEC dump using existing file.
bool StartAecDump(FILE* file);
// Check whether the supplied trace should be ignored.
bool ShouldIgnoreTrace(const std::string& trace);
@ -356,8 +359,10 @@ class WebRtcVoiceMediaChannel
virtual bool CanInsertDtmf();
virtual bool InsertDtmf(uint32 ssrc, int event, int duration, int flags);
virtual void OnPacketReceived(talk_base::Buffer* packet);
virtual void OnRtcpReceived(talk_base::Buffer* packet);
virtual void OnPacketReceived(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 bool MuteStream(uint32 ssrc, bool on);
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) {
talk_base::Buffer packet(data, len);
channel_->OnPacketReceived(&packet);
channel_->OnPacketReceived(&packet, talk_base::PacketTime());
}
virtual void TearDown() {
delete soundclip_;

View File

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

View File

@ -109,7 +109,8 @@ class AsyncStunTCPSocketTest : public testing::Test,
}
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));
}

View File

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

View File

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

View File

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

View File

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

View File

@ -1227,8 +1227,9 @@ void P2PTransportChannel::OnPortDestroyed(PortInterface* port) {
}
// We data is available, let listeners know
void P2PTransportChannel::OnReadPacket(Connection *connection, const char *data,
size_t len) {
void P2PTransportChannel::OnReadPacket(
Connection *connection, const char *data, size_t len,
const talk_base::PacketTime& packet_time) {
ASSERT(worker_thread_ == talk_base::Thread::Current());
// 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;
// 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) {

View File

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

View File

@ -613,7 +613,8 @@ class P2PTransportChannelTestBase : public testing::Test,
rch->OnCandidate(c);
}
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);
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;
std::string remote_ufrag;
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();
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 (!pruned_ && (write_state_ == STATE_WRITE_TIMEOUT)) {

View File

@ -32,6 +32,7 @@
#include <vector>
#include <map>
#include "talk/base/asyncpacketsocket.h"
#include "talk/base/network.h"
#include "talk/base/proxyinfo.h"
#include "talk/base/ratetracker.h"
@ -45,10 +46,6 @@
#include "talk/p2p/base/stunrequest.h"
#include "talk/p2p/base/transport.h"
namespace talk_base {
class AsyncPacketSocket;
}
namespace cricket {
class Connection;
@ -240,7 +237,8 @@ class Port : public PortInterface, public talk_base::MessageHandler,
// TODO(mallinath) - Make it pure virtual.
virtual bool HandleIncomingPacket(
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);
return false;
}
@ -470,12 +468,14 @@ class Connection : public talk_base::MessageHandler,
// Error if Send() returns < 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;
// 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.
void OnReadyToSend();

View File

@ -1049,7 +1049,8 @@ TEST_F(PortTest, TestLoopbackCallAsIce) {
IceMessage* msg = lport->last_stun_msg();
EXPECT_EQ(STUN_BINDING_REQUEST, msg->type());
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);
msg = lport->last_stun_msg();
EXPECT_EQ(STUN_BINDING_RESPONSE, msg->type());
@ -1082,7 +1083,7 @@ TEST_F(PortTest, TestLoopbackCallAsIce) {
lport->Reset();
talk_base::scoped_ptr<ByteBuffer> buf(new ByteBuffer());
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);
msg = lport->last_stun_msg();
EXPECT_EQ(STUN_BINDING_ERROR_RESPONSE, msg->type());
@ -1120,7 +1121,8 @@ TEST_F(PortTest, TestIceRoleConflict) {
EXPECT_EQ(STUN_BINDING_REQUEST, msg->type());
// Send rport binding request to lport.
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);
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());
// Send rport binding request to lport.
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);
EXPECT_EQ(STUN_BINDING_RESPONSE, lport->last_stun_msg()->type());
uint32 last_ping_received1 = lconn->last_ping_received();
@ -1910,7 +1913,7 @@ TEST_F(PortTest, TestHandleStunBindingIndication) {
// Adding a delay of 100ms.
talk_base::Thread::Current()->ProcessMessages(100);
// 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();
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.
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.
EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, ch1.conn()->write_state(),
kTimeout);

View File

@ -257,7 +257,7 @@ void RawTransportChannel::OnReadPacket(
PortInterface* port, const char* data, size_t size,
const talk_base::SocketAddress& addr) {
ASSERT(port_ == port);
SignalReadPacket(this, data, size, 0);
SignalReadPacket(this, data, size, talk_base::CreatePacketTime(0), 0);
}
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);
// Called when a packet is received on this socket.
void OnReadPacket(talk_base::AsyncPacketSocket* socket,
const char* data, size_t size,
const talk_base::SocketAddress& remote_addr);
void OnReadPacket(
talk_base::AsyncPacketSocket* socket,
const char* data, size_t size,
const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time);
// Called when the socket is currently able to send.
void OnReadyToSend(talk_base::AsyncPacketSocket* socket);
@ -393,9 +394,11 @@ int RelayPort::GetError() {
void RelayPort::OnReadPacket(
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)) {
conn->OnReadPacket(data, size);
conn->OnReadPacket(data, size, packet_time);
} else {
Port::OnReadPacket(data, size, remote_addr, proto);
}
@ -682,9 +685,11 @@ void RelayEntry::OnSocketClose(talk_base::AsyncPacketSocket* socket,
HandleConnectFailure(socket);
}
void RelayEntry::OnReadPacket(talk_base::AsyncPacketSocket* socket,
const char* data, size_t size,
const talk_base::SocketAddress& remote_addr) {
void RelayEntry::OnReadPacket(
talk_base::AsyncPacketSocket* socket,
const char* data, size_t size,
const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time) {
// ASSERT(remote_addr == port_->server_addr());
// 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.
if (!port_->HasMagicCookie(data, size)) {
if (locked_) {
port_->OnReadPacket(data, size, ext_addr_, PROTO_UDP);
port_->OnReadPacket(data, size, ext_addr_, PROTO_UDP, packet_time);
} else {
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.
port_->OnReadPacket(data_attr->bytes(), data_attr->length(), remote_addr2,
PROTO_UDP);
PROTO_UDP, packet_time);
}
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.
void OnReadPacket(const char* data, size_t size,
const talk_base::SocketAddress& remote_addr,
ProtocolType proto);
ProtocolType proto,
const talk_base::PacketTime& packet_time);
private:
friend class RelayEntry;

View File

@ -78,7 +78,8 @@ class RelayPortTest : public testing::Test,
void OnReadPacket(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) {
received_packet_count_[socket]++;
}

View File

@ -198,7 +198,8 @@ void RelayServer::OnReadEvent(talk_base::AsyncSocket* socket) {
void RelayServer::OnInternalPacket(
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.
talk_base::SocketAddressPair ap(remote_addr, socket->GetLocalAddress());
@ -242,7 +243,8 @@ void RelayServer::OnInternalPacket(
void RelayServer::OnExternalPacket(
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.
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.
void OnInternalPacket(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);
void OnExternalPacket(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);
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,
size_t size, int flags) {
size_t size, const talk_base::PacketTime& time, int flags) {
if (memcmp(buf, name.c_str(), name.size()) != 0)
return; // drop packet if packet doesn't belong to this channel. This
// can happen when transport channels are muxed together.

View File

@ -254,9 +254,10 @@ void UDPPort::OnLocalAddressReady(talk_base::AsyncPacketSocket* socket,
MaybePrepareStunCandidate();
}
void UDPPort::OnReadPacket(talk_base::AsyncPacketSocket* socket,
const char* data, size_t size,
const talk_base::SocketAddress& remote_addr) {
void UDPPort::OnReadPacket(
talk_base::AsyncPacketSocket* socket, const char* data, size_t size,
const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time) {
ASSERT(socket == socket_);
// 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)) {
conn->OnReadPacket(data, size);
conn->OnReadPacket(data, size, packet_time);
} else {
Port::OnReadPacket(data, size, remote_addr, PROTO_UDP);
}

View File

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

View File

@ -42,7 +42,8 @@ StunServer::~StunServer() {
void StunServer::OnPacket(
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.
talk_base::ByteBuffer bbuf(buf, size);
StunMessage msg;

View File

@ -47,7 +47,8 @@ class StunServer : public sigslot::has_slots<> {
// Slot for AsyncSocket.PacketRead:
void OnPacket(
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:
void OnBindingRequest(StunMessage* msg,

View File

@ -218,7 +218,8 @@ talk_base::AsyncPacketSocket* TCPPort::GetIncoming(
void TCPPort::OnReadPacket(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) {
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);
}
void TCPConnection::OnReadPacket(talk_base::AsyncPacketSocket* socket,
const char* data, size_t size,
const talk_base::SocketAddress& remote_addr) {
void TCPConnection::OnReadPacket(
talk_base::AsyncPacketSocket* socket, const char* data, size_t size,
const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time) {
ASSERT(socket == socket_);
Connection::OnReadPacket(data, size);
Connection::OnReadPacket(data, size, packet_time);
}
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.
void OnReadPacket(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);
void OnReadyToSend(talk_base::AsyncPacketSocket* socket);
@ -137,7 +138,8 @@ class TCPConnection : public Connection {
void OnClose(talk_base::AsyncPacketSocket* socket, int error);
void OnReadPacket(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);
void OnReadyToSend(talk_base::AsyncPacketSocket* socket);
talk_base::AsyncPacketSocket* socket_;

View File

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

View File

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

View File

@ -90,7 +90,7 @@ class TransportChannelProxy : public TransportChannel,
void OnReadableState(TransportChannel* channel);
void OnWritableState(TransportChannel* channel);
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 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);
}
void TurnPort::OnReadPacket(talk_base::AsyncPacketSocket* socket,
const char* data, size_t size,
const talk_base::SocketAddress& remote_addr) {
void TurnPort::OnReadPacket(
talk_base::AsyncPacketSocket* socket, const char* data, size_t size,
const talk_base::SocketAddress& remote_addr,
const talk_base::PacketTime& packet_time) {
ASSERT(socket == socket_.get());
ASSERT(remote_addr == server_address_.address);
@ -373,9 +374,9 @@ void TurnPort::OnReadPacket(talk_base::AsyncPacketSocket* socket,
// a response to a previous request.
uint16 msg_type = talk_base::GetBE16(data);
if (IsTurnChannelData(msg_type)) {
HandleChannelData(msg_type, data, size);
HandleChannelData(msg_type, data, size, packet_time);
} else if (msg_type == TURN_DATA_INDICATION) {
HandleDataIndication(data, size);
HandleDataIndication(data, size, packet_time);
} else {
// This must be a response for one of our requests.
// Check success responses, but not errors, for MESSAGE-INTEGRITY.
@ -460,7 +461,8 @@ void TurnPort::OnAllocateRequestTimeout() {
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.
talk_base::ByteBuffer buf(data, size);
TurnMessage msg;
@ -495,11 +497,13 @@ void TurnPort::HandleDataIndication(const char* data, size_t size) {
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,
size_t size) {
size_t size,
const talk_base::PacketTime& packet_time) {
// Read the message, and process according to RFC5766, Section 11.6.
// 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
@ -531,13 +535,14 @@ void TurnPort::HandleChannelData(int channel_id, const char* data,
}
DispatchPacket(data + TURN_CHANNEL_HEADER_SIZE, len, entry->address(),
PROTO_UDP);
PROTO_UDP, packet_time);
}
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)) {
conn->OnReadPacket(data, size);
conn->OnReadPacket(data, size, packet_time);
} else {
Port::OnReadPacket(data, size, remote_addr, proto);
}

View File

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

View File

@ -118,13 +118,15 @@ class TurnPortTest : public testing::Test,
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));
}
void OnUdpPortComplete(Port* port) {
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));
}

View File

@ -109,7 +109,8 @@ class TurnServer::Allocation : public talk_base::MessageHandler,
void OnExternalPacket(talk_base::AsyncPacketSocket* socket,
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);
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,
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.
if (size < TURN_CHANNEL_HEADER_SIZE) {
return;
@ -838,7 +840,8 @@ void TurnServer::Allocation::HandleChannelData(const char* data, size_t size) {
void TurnServer::Allocation::OnExternalPacket(
talk_base::AsyncPacketSocket* socket,
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);
Channel* channel = FindChannel(addr);
if (channel) {

View File

@ -33,13 +33,13 @@
#include <set>
#include <string>
#include "talk/base/asyncpacketsocket.h"
#include "talk/base/messagequeue.h"
#include "talk/base/sigslot.h"
#include "talk/base/socketaddress.h"
#include "talk/p2p/base/portinterface.h"
namespace talk_base {
class AsyncPacketSocket;
class ByteBuffer;
class PacketSocketFactory;
class Thread;
@ -123,7 +123,8 @@ class TurnServer : public sigslot::has_slots<> {
typedef std::map<Connection, Allocation*> AllocationMap;
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);

View File

@ -149,7 +149,9 @@ class AllocationSequence : public talk_base::MessageHandler,
void OnReadPacket(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);
void OnPortDestroyed(PortInterface* port);
BasicPortAllocatorSession* session_;
@ -1024,13 +1026,15 @@ void AllocationSequence::CreateTurnPort(const RelayServerConfig& config) {
void AllocationSequence::OnReadPacket(
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());
for (std::deque<Port*>::iterator iter = ports.begin();
iter != ports.end(); ++iter) {
// We have only one port in the queue.
// 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;
}
}

View File

@ -610,7 +610,9 @@ void BaseChannel::OnWritableState(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
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.
bool rtcp = PacketIsRtcp(channel, data, len);
talk_base::Buffer packet(data, len);
HandlePacket(rtcp, &packet);
HandlePacket(rtcp, &packet, packet_time);
}
void BaseChannel::OnReadyToSend(TransportChannel* channel) {
@ -774,7 +776,8 @@ bool BaseChannel::WantsPacket(bool rtcp, talk_base::Buffer* packet) {
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)) {
return;
}
@ -843,9 +846,9 @@ void BaseChannel::HandlePacket(bool rtcp, talk_base::Buffer* packet) {
// Push it down to the media channel.
if (!rtcp) {
media_channel_->OnPacketReceived(packet);
media_channel_->OnPacketReceived(packet, packet_time);
} 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,
const char* data, size_t len, int flags) {
BaseChannel::OnChannelRead(channel, data, len, flags);
const char* data, size_t len,
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
// media, this will disable the timeout.

View File

@ -265,8 +265,11 @@ class BaseChannel
// From TransportChannel
void OnWritableState(TransportChannel* channel);
virtual void OnChannelRead(TransportChannel* channel, const char* data,
size_t len, int flags);
virtual void OnChannelRead(TransportChannel* channel,
const char* data,
size_t len,
const talk_base::PacketTime& packet_time,
int flags);
void OnReadyToSend(TransportChannel* channel);
bool PacketIsRtcp(const TransportChannel* channel, const char* data,
@ -274,7 +277,8 @@ class BaseChannel
bool SendPacket(bool rtcp, talk_base::Buffer* packet,
talk_base::DiffServCodePoint dscp);
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.
void OnNewLocalDescription(BaseSession* session, ContentAction action);
@ -441,7 +445,9 @@ class VoiceChannel : public BaseChannel {
private:
// overrides from BaseChannel
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 const ContentInfo* GetFirstContent(const SessionDescription* sdesc);
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();
transport_channel->SignalReadPacket(
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);
}

View File

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

View File

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

View File

@ -340,7 +340,9 @@ void PseudoTcpChannel::OnChannelWritableState(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 << ")";
ASSERT(worker_thread_->IsCurrent());
CritScope lock(&cs_);

View File

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

View File

@ -677,6 +677,22 @@ struct OverUseDetectorOptions {
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
#endif // WEBRTC_COMMON_TYPES_H_

View File

@ -105,7 +105,8 @@ void VideoChannelTransport::IncomingRTPPacket(
const int32_t packet_length,
const char* /*from_ip*/,
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(

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) {
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,

View File

@ -65,7 +65,8 @@ class WEBRTC_DLLEXPORT ViENetwork {
// the RTP header and payload.
virtual int ReceivedRTPPacket(const int video_channel,
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
// be passed to VideoEngine using this function.

View File

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

View File

@ -1612,14 +1612,16 @@ int32_t ViEChannel::DeregisterSendTransport() {
}
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());
if (!external_transport_) {
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(

View File

@ -262,7 +262,8 @@ class ViEChannel
// Incoming packet from external transport.
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.
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,
const int length) {
const int length,
const PacketTime& packet_time) {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%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);
return -1;
}
return vie_channel->ReceivedRTPPacket(data, length);
return vie_channel->ReceivedRTPPacket(data, length, packet_time);
}
int ViENetworkImpl::ReceivedRTCPPacket(const int video_channel,

View File

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

View File

@ -177,9 +177,10 @@ bool ViEReceiver::SetReceiveAbsoluteSendTimeStatus(bool enable, int id) {
}
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),
rtp_packet_length);
rtp_packet_length, packet_time);
}
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 rtp_packet_length) {
int rtp_packet_length,
const PacketTime& packet_time) {
// TODO(mflodman) Change decrypt to get rid of this cast.
int8_t* tmp_ptr = const_cast<int8_t*>(rtp_packet);
unsigned char* received_packet = reinterpret_cast<unsigned char*>(tmp_ptr);
@ -256,7 +258,13 @@ int ViEReceiver::InsertRTPPacket(const int8_t* rtp_packet,
return -1;
}
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);
header.payload_type_frequency = kVideoPayloadTypeFrequency;

View File

@ -18,6 +18,7 @@
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "webrtc/typedefs.h"
#include "webrtc/video_engine/include/vie_network.h"
#include "webrtc/video_engine/vie_defines.h"
namespace webrtc {
@ -70,7 +71,8 @@ class ViEReceiver : public RtpData {
int StopRTPDump();
// Receives packets from external transport.
int ReceivedRTPPacket(const void* rtp_packet, int rtp_packet_length);
int ReceivedRTPPacket(const void* rtp_packet, int rtp_packet_length,
const PacketTime& packet_time);
int ReceivedRTCPPacket(const void* rtcp_packet, int rtcp_packet_length);
virtual bool OnRecoveredPacket(const uint8_t* packet,
int packet_length) OVERRIDE;
@ -86,7 +88,8 @@ class ViEReceiver : public RtpData {
ReceiveStatistics* GetReceiveStatistics() const;
private:
int InsertRTPPacket(const int8_t* rtp_packet, int rtp_packet_length);
int InsertRTPPacket(const int8_t* rtp_packet, int rtp_packet_length,
const PacketTime& packet_time);
bool ReceivePacket(const uint8_t* packet, int packet_length,
const RTPHeader& header, bool in_order);
// Parses and handles for instance RTX and RED headers.