Bug 889615 - Add Granular logging to Mediapipeline. r=abr

This commit is contained in:
Suhas Nandakumar 2013-07-03 11:40:36 -07:00
parent e5a37986c8
commit 8725b367e1
16 changed files with 241 additions and 226 deletions

View File

@ -240,7 +240,7 @@ nsresult DtlsIdentity::ParseFingerprint(const std::string fp,
for (size_t i=0; i<fp.length(); i++) {
if (offset >= size) {
// Note: no known way for offset to get > size
MOZ_MTLOG(PR_LOG_ERROR, "Fingerprint too long for buffer");
MOZ_MTLOG(ML_ERROR, "Fingerprint too long for buffer");
return NS_ERROR_INVALID_ARG;
}
@ -251,7 +251,7 @@ nsresult DtlsIdentity::ParseFingerprint(const std::string fp,
} else if ((fp[i] >= 'A') && (fp[i] <= 'F')) {
val |= fp[i] - 'A' + 10;
} else {
MOZ_MTLOG(PR_LOG_ERROR, "Invalid fingerprint value " << fp[i]);
MOZ_MTLOG(ML_ERROR, "Invalid fingerprint value " << fp[i]);
return NS_ERROR_ILLEGAL_VALUE;
}

View File

@ -23,6 +23,13 @@
#if defined(PR_LOGGING)
#define ML_EMERG 1
#define ML_ERROR 2
#define ML_WARNING 3
#define ML_NOTICE 4
#define ML_INFO 5
#define ML_DEBUG 6
// PR_LOGGING is on --> make useful MTLOG macros
#define MOZ_MTLOG_MODULE(n) \
static PRLogModuleInfo* getLogModule() { \

View File

@ -242,14 +242,14 @@ nsresult NrIceTurnServer::ToNicerTurnStruct(nr_ice_turn_server *server) const {
int NrIceCtx::select_pair(void *obj,nr_ice_media_stream *stream,
int component_id, nr_ice_cand_pair **potentials,
int potential_ct) {
MOZ_MTLOG(PR_LOG_DEBUG, "select pair called: potential_ct = "
MOZ_MTLOG(ML_DEBUG, "select pair called: potential_ct = "
<< potential_ct);
return 0;
}
int NrIceCtx::stream_ready(void *obj, nr_ice_media_stream *stream) {
MOZ_MTLOG(PR_LOG_DEBUG, "stream_ready called");
MOZ_MTLOG(ML_DEBUG, "stream_ready called");
// Get the ICE ctx
NrIceCtx *ctx = static_cast<NrIceCtx *>(obj);
@ -265,7 +265,7 @@ int NrIceCtx::stream_ready(void *obj, nr_ice_media_stream *stream) {
}
int NrIceCtx::stream_failed(void *obj, nr_ice_media_stream *stream) {
MOZ_MTLOG(PR_LOG_DEBUG, "stream_failed called");
MOZ_MTLOG(ML_DEBUG, "stream_failed called");
// Get the ICE ctx
NrIceCtx *ctx = static_cast<NrIceCtx *>(obj);
@ -280,7 +280,7 @@ int NrIceCtx::stream_failed(void *obj, nr_ice_media_stream *stream) {
}
int NrIceCtx::ice_completed(void *obj, nr_ice_peer_ctx *pctx) {
MOZ_MTLOG(PR_LOG_DEBUG, "ice_completed called");
MOZ_MTLOG(ML_DEBUG, "ice_completed called");
// Get the ICE ctx
NrIceCtx *ctx = static_cast<NrIceCtx *>(obj);
@ -364,7 +364,7 @@ RefPtr<NrIceCtx> NrIceCtx::Create(const std::string& name,
r = nr_ice_ctx_create(const_cast<char *>(name.c_str()), flags,
&ctx->ctx_);
if (r) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't create ICE ctx for '" << name << "'");
MOZ_MTLOG(ML_ERROR, "Couldn't create ICE ctx for '" << name << "'");
return nullptr;
}
@ -387,7 +387,7 @@ RefPtr<NrIceCtx> NrIceCtx::Create(const std::string& name,
const_cast<char *>(peer_name.c_str()),
&ctx->peer_);
if (r) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't create ICE peer ctx for '" << name << "'");
MOZ_MTLOG(ML_ERROR, "Couldn't create ICE peer ctx for '" << name << "'");
return nullptr;
}
@ -402,7 +402,7 @@ RefPtr<NrIceCtx> NrIceCtx::Create(const std::string& name,
NrIceCtx::~NrIceCtx() {
MOZ_MTLOG(PR_LOG_DEBUG, "Destroying ICE ctx '" << name_ <<"'");
MOZ_MTLOG(ML_DEBUG, "Destroying ICE ctx '" << name_ <<"'");
nr_ice_peer_ctx_destroy(&peer_);
nr_ice_ctx_destroy(&ctx_);
delete ice_handler_vtbl_;
@ -426,7 +426,7 @@ void NrIceCtx::destroy_peer_ctx() {
nsresult NrIceCtx::SetControlling(Controlling controlling) {
peer_->controlling = (controlling == ICE_CONTROLLING)? 1 : 0;
MOZ_MTLOG(PR_LOG_DEBUG, "ICE ctx " << name_ << " setting controlling to" <<
MOZ_MTLOG(ML_DEBUG, "ICE ctx " << name_ << " setting controlling to" <<
controlling);
return NS_OK;
}
@ -442,14 +442,14 @@ nsresult NrIceCtx::SetStunServers(const std::vector<NrIceStunServer>&
for (size_t i=0; i < stun_servers.size(); ++i) {
nsresult rv = stun_servers[i].ToNicerStunStruct(&servers[i]);
if (NS_FAILED(rv)) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't set STUN server for '" << name_ << "'");
MOZ_MTLOG(ML_ERROR, "Couldn't set STUN server for '" << name_ << "'");
return NS_ERROR_FAILURE;
}
}
int r = nr_ice_ctx_set_stun_servers(ctx_, servers, stun_servers.size());
if (r) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't set STUN server for '" << name_ << "'");
MOZ_MTLOG(ML_ERROR, "Couldn't set STUN server for '" << name_ << "'");
return NS_ERROR_FAILURE;
}
@ -469,14 +469,14 @@ nsresult NrIceCtx::SetTurnServers(const std::vector<NrIceTurnServer>&
for (size_t i=0; i < turn_servers.size(); ++i) {
nsresult rv = turn_servers[i].ToNicerTurnStruct(&servers[i]);
if (NS_FAILED(rv)) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't set TURN server for '" << name_ << "'");
MOZ_MTLOG(ML_ERROR, "Couldn't set TURN server for '" << name_ << "'");
return NS_ERROR_FAILURE;
}
}
int r = nr_ice_ctx_set_turn_servers(ctx_, servers, turn_servers.size());
if (r) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't set TURN server for '" << name_ << "'");
MOZ_MTLOG(ML_ERROR, "Couldn't set TURN server for '" << name_ << "'");
return NS_ERROR_FAILURE;
}
@ -489,7 +489,7 @@ nsresult NrIceCtx::SetResolver(nr_resolver *resolver) {
int r = nr_ice_ctx_set_resolver(ctx_, resolver);
if (r) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't set resolver for '" << name_ << "'");
MOZ_MTLOG(ML_ERROR, "Couldn't set resolver for '" << name_ << "'");
return NS_ERROR_FAILURE;
}
@ -499,8 +499,8 @@ nsresult NrIceCtx::SetResolver(nr_resolver *resolver) {
nsresult NrIceCtx::StartGathering() {
MOZ_ASSERT(ctx_->state == ICE_CTX_INIT);
if (ctx_->state != ICE_CTX_INIT) {
MOZ_MTLOG(PR_LOG_ERROR, "ICE ctx in the wrong state for gathering: '"
<< name_ << "'");
MOZ_MTLOG(ML_ERROR, "ICE ctx in the wrong state for gathering: '"
<< name_ << "'");
SetState(ICE_CTX_FAILED);
return NS_ERROR_FAILURE;
}
@ -509,8 +509,8 @@ nsresult NrIceCtx::StartGathering() {
this);
if (r && r != R_WOULDBLOCK) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't gather ICE candidates for '"
<< name_ << "'");
MOZ_MTLOG(ML_ERROR, "Couldn't gather ICE candidates for '"
<< name_ << "'");
SetState(ICE_CTX_FAILED);
return NS_ERROR_FAILURE;
}
@ -521,8 +521,8 @@ nsresult NrIceCtx::StartGathering() {
}
void NrIceCtx::EmitAllCandidates() {
MOZ_MTLOG(PR_LOG_NOTICE, "Gathered all ICE candidates for '"
<< name_ << "'");
MOZ_MTLOG(ML_NOTICE, "Gathered all ICE candidates for '"
<< name_ << "'");
for(size_t i=0; i<streams_.size(); ++i) {
streams_[i]->EmitAllCandidates();
@ -548,8 +548,8 @@ std::vector<std::string> NrIceCtx::GetGlobalAttributes() {
r = nr_ice_get_global_attributes(ctx_, &attrs, &attrct);
if (r) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't get ufrag and password for '"
<< name_ << "'");
MOZ_MTLOG(ML_ERROR, "Couldn't get ufrag and password for '"
<< name_ << "'");
return ret;
}
@ -574,8 +574,8 @@ nsresult NrIceCtx::ParseGlobalAttributes(std::vector<std::string> attrs) {
&attrs_in[0] : nullptr,
attrs_in.size());
if (r) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't parse global attributes for "
<< name_ << "'");
MOZ_MTLOG(ML_ERROR, "Couldn't parse global attributes for "
<< name_ << "'");
return NS_ERROR_FAILURE;
}
@ -587,8 +587,8 @@ nsresult NrIceCtx::StartChecks() {
r=nr_ice_peer_ctx_pair_candidates(peer_);
if (r) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't pair candidates on "
<< name_ << "'");
MOZ_MTLOG(ML_ERROR, "Couldn't pair candidates on "
<< name_ << "'");
SetState(ICE_CTX_FAILED);
return NS_ERROR_FAILURE;
}
@ -596,11 +596,11 @@ nsresult NrIceCtx::StartChecks() {
r = nr_ice_peer_ctx_start_checks2(peer_,1);
if (r) {
if (r == R_NOT_FOUND) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't start peer checks on "
<< name_ << "' assuming trickle ICE");
MOZ_MTLOG(ML_ERROR, "Couldn't start peer checks on "
<< name_ << "' assuming trickle ICE");
} else {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't start peer checks on "
<< name_ << "'");
MOZ_MTLOG(ML_ERROR, "Couldn't start peer checks on "
<< name_ << "'");
SetState(ICE_CTX_FAILED);
return NS_ERROR_FAILURE;
}
@ -624,7 +624,7 @@ nsresult NrIceCtx::Finalize() {
int r = nr_ice_ctx_finalize(ctx_, peer_);
if (r) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't finalize "
MOZ_MTLOG(ML_ERROR, "Couldn't finalize "
<< name_ << "'");
return NS_ERROR_FAILURE;
}
@ -636,8 +636,8 @@ void NrIceCtx::SetState(State state) {
if (state == state_)
return;
MOZ_MTLOG(PR_LOG_DEBUG, "NrIceCtx(" << name_ << "): state " <<
state_ << "->" << state);
MOZ_MTLOG(ML_DEBUG, "NrIceCtx(" << name_ << "): state " <<
state_ << "->" << state);
state_ = state;
switch(state_) {

View File

@ -84,8 +84,8 @@ NrIceMediaStream::Create(NrIceCtx *ctx,
const_cast<char *>(name.c_str()),
components, &stream->stream_);
if (r) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't create ICE media stream for '"
<< name << "'");
MOZ_MTLOG(ML_ERROR, "Couldn't create ICE media stream for '"
<< name << "'");
return nullptr;
}
@ -115,8 +115,8 @@ nsresult NrIceMediaStream::ParseAttributes(std::vector<std::string>&
&attributes_in[0] : nullptr,
attributes_in.size());
if (r) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't parse attributes for stream "
<< name_ << "'");
MOZ_MTLOG(ML_ERROR, "Couldn't parse attributes for stream "
<< name_ << "'");
return NS_ERROR_FAILURE;
}
@ -127,7 +127,7 @@ nsresult NrIceMediaStream::ParseAttributes(std::vector<std::string>&
nsresult NrIceMediaStream::ParseTrickleCandidate(const std::string& candidate) {
int r;
MOZ_MTLOG(PR_LOG_DEBUG, "NrIceCtx(" << ctx_->name() << ")/STREAM(" <<
MOZ_MTLOG(ML_DEBUG, "NrIceCtx(" << ctx_->name() << ")/STREAM(" <<
name() << ") : parsing trickle candidate " << candidate);
r = nr_ice_peer_ctx_parse_trickle_candidate(ctx_->peer(),
@ -137,12 +137,12 @@ nsresult NrIceMediaStream::ParseTrickleCandidate(const std::string& candidate) {
);
if (r) {
if (r == R_ALREADY) {
MOZ_MTLOG(PR_LOG_ERROR, "Trickle candidates are redundant for stream '"
<< name_ << "' because it is completed");
MOZ_MTLOG(ML_ERROR, "Trickle candidates are redundant for stream '"
<< name_ << "' because it is completed");
} else {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't parse trickle candidate for stream '"
<< name_ << "'");
MOZ_MTLOG(ML_ERROR, "Couldn't parse trickle candidate for stream '"
<< name_ << "'");
return NS_ERROR_FAILURE;
}
}
@ -158,7 +158,7 @@ void NrIceMediaStream::EmitAllCandidates() {
r = nr_ice_media_stream_get_attributes(stream_,
&attrs, &attrct);
if (r) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't get ICE candidates for '"
MOZ_MTLOG(ML_ERROR, "Couldn't get ICE candidates for '"
<< name_ << "'");
return;
}
@ -180,8 +180,8 @@ nsresult NrIceMediaStream::GetDefaultCandidate(int component,
r = nr_ice_media_stream_get_default_candidate(stream_,
component, &cand);
if (r) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't get default ICE candidate for '"
<< name_ << "'");
MOZ_MTLOG(ML_ERROR, "Couldn't get default ICE candidate for '"
<< name_ << "'");
return NS_ERROR_NOT_AVAILABLE;
}
@ -210,8 +210,8 @@ std::vector<std::string> NrIceMediaStream::GetCandidates() const {
r = nr_ice_media_stream_get_attributes(stream_,
&attrs, &attrct);
if (r) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't get ICE candidates for '"
<< name_ << "'");
MOZ_MTLOG(ML_ERROR, "Couldn't get ICE candidates for '"
<< name_ << "'");
return ret;
}
@ -235,7 +235,7 @@ nsresult NrIceMediaStream::SendPacket(int component_id,
component_id,
const_cast<unsigned char *>(data), len);
if (r) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't send media on '" << name_ << "'");
MOZ_MTLOG(ML_ERROR, "Couldn't send media on '" << name_ << "'");
if (r == R_WOULDBLOCK) {
return NS_BASE_STREAM_WOULD_BLOCK;
}
@ -248,13 +248,13 @@ nsresult NrIceMediaStream::SendPacket(int component_id,
void NrIceMediaStream::Ready() {
MOZ_MTLOG(PR_LOG_DEBUG, "Marking stream ready '" << name_ << "'");
MOZ_MTLOG(ML_DEBUG, "Marking stream ready '" << name_ << "'");
state_ = ICE_OPEN;
SignalReady(this);
}
void NrIceMediaStream::Close() {
MOZ_MTLOG(PR_LOG_DEBUG, "Marking stream closed '" << name_ << "'");
MOZ_MTLOG(ML_DEBUG, "Marking stream closed '" << name_ << "'");
state_ = ICE_CLOSED;
stream_ = nullptr;
}

View File

@ -93,7 +93,7 @@ nsresult NrIceResolver::Init() {
MOZ_ASSERT(NS_SUCCEEDED(rv));
dns_ = do_GetService(NS_DNSSERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
MOZ_MTLOG(PR_LOG_ERROR, "Could not acquire DNS service");
MOZ_MTLOG(ML_ERROR, "Could not acquire DNS service");
}
return rv;
}
@ -104,7 +104,7 @@ nr_resolver *NrIceResolver::AllocateResolver() {
int r = nr_resolver_create_int((void *)this, vtbl_, &resolver);
MOZ_ASSERT(!r);
if(r) {
MOZ_MTLOG(PR_LOG_ERROR, "nr_resolver_create_int failed");
MOZ_MTLOG(ML_ERROR, "nr_resolver_create_int failed");
return nullptr;
}
// We must be available to allocators until they all call DestroyResolver,
@ -152,7 +152,7 @@ int NrIceResolver::resolve(nr_resolver_resource *resource,
nsCOMPtr<PendingResolution> pr;
if (resource->transport_protocol != IPPROTO_UDP) {
MOZ_MTLOG(PR_LOG_ERROR, "Only UDP is supported.");
MOZ_MTLOG(ML_ERROR, "Only UDP is supported.");
ABORT(R_NOT_FOUND);
}
pr = new PendingResolution(sts_thread_, resource->port? resource->port : 3478,
@ -160,7 +160,7 @@ int NrIceResolver::resolve(nr_resolver_resource *resource,
if (NS_FAILED(dns_->AsyncResolve(nsAutoCString(resource->domain_name),
nsIDNSService::RESOLVE_DISABLE_IPV6, pr,
sts_thread_, getter_AddRefs(pr->request_)))) {
MOZ_MTLOG(PR_LOG_ERROR, "AsyncResolve failed.");
MOZ_MTLOG(ML_ERROR, "AsyncResolve failed.");
ABORT(R_NOT_FOUND);
}
// Because the C API offers no "finished" method to release the handle we

View File

@ -78,10 +78,10 @@ class TransportLayerLossy : public TransportLayer {
~TransportLayerLossy () {}
virtual TransportResult SendPacket(const unsigned char *data, size_t len) {
MOZ_MTLOG(PR_LOG_NOTICE, LAYER_INFO << "SendPacket(" << len << ")");
MOZ_MTLOG(ML_NOTICE, LAYER_INFO << "SendPacket(" << len << ")");
if (loss_mask_ & (1 << (packet_ % 32))) {
MOZ_MTLOG(PR_LOG_NOTICE, "Dropping packet");
MOZ_MTLOG(ML_NOTICE, "Dropping packet");
++packet_;
return len;
}

View File

@ -63,7 +63,7 @@ nsresult TransportFlow::PushLayer(TransportLayer *layer) {
// Don't allow pushes once we are in error state.
if (state_ == TransportLayer::TS_ERROR) {
MOZ_MTLOG(PR_LOG_ERROR, id_ + ": Can't call PushLayer in error state for flow ");
MOZ_MTLOG(ML_ERROR, id_ + ": Can't call PushLayer in error state for flow");
return NS_ERROR_FAILURE;
}
@ -74,7 +74,7 @@ nsresult TransportFlow::PushLayer(TransportLayer *layer) {
ClearLayers(layers_.get());
// Set ourselves to have failed.
MOZ_MTLOG(PR_LOG_ERROR, id_ << ": Layer initialization failed; invalidating");
MOZ_MTLOG(ML_ERROR, id_ << ": Layer initialization failed; invalidating");
StateChangeInt(TransportLayer::TS_ERROR);
return rv;
@ -104,13 +104,14 @@ nsresult TransportFlow::PushLayers(nsAutoPtr<std::queue<TransportLayer *> > laye
MOZ_ASSERT(!layers->empty());
if (layers->empty()) {
MOZ_MTLOG(PR_LOG_ERROR, id_ << ": Can't call PushLayers with empty layers");
MOZ_MTLOG(ML_ERROR, id_ << ": Can't call PushLayers with empty layers");
return NS_ERROR_INVALID_ARG;
}
// Don't allow pushes once we are in error state.
if (state_ == TransportLayer::TS_ERROR) {
MOZ_MTLOG(PR_LOG_ERROR, id_ << ": Can't call PushLayers in error state for flow ");
MOZ_MTLOG(ML_ERROR,
id_ << ": Can't call PushLayers in error state for flow ");
ClearLayers(layers.get());
return NS_ERROR_FAILURE;
}
@ -128,7 +129,8 @@ nsresult TransportFlow::PushLayers(nsAutoPtr<std::queue<TransportLayer *> > laye
rv = layer->Init();
if (NS_FAILED(rv)) {
MOZ_MTLOG(PR_LOG_ERROR, id_ << ": Layer initialization failed; invalidating flow ");
MOZ_MTLOG(ML_ERROR,
id_ << ": Layer initialization failed; invalidating flow ");
break;
}

View File

@ -32,7 +32,7 @@ nsresult TransportLayer::Init() {
void TransportLayer::Inserted(TransportFlow *flow, TransportLayer *downward) {
downward_ = downward;
flow_id_ = flow->id();
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << "Inserted: downward='" <<
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Inserted: downward='" <<
(downward ? downward->id(): "none") << "'");
WasInserted();
@ -40,7 +40,7 @@ void TransportLayer::Inserted(TransportFlow *flow, TransportLayer *downward) {
void TransportLayer::SetState(State state) {
if (state != state_) {
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << "state " << state_ << "->" << state);
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "state " << state_ << "->" << state);
state_ = state;
SignalStateChange(this, state);
}

View File

@ -37,9 +37,9 @@ static PRDescIdentity transport_layer_identity = PR_INVALID_IO_LAYER;
// (e.g., after cert check).
#define UNIMPLEMENTED \
MOZ_MTLOG(PR_LOG_ERROR, \
MOZ_MTLOG(ML_ERROR, \
"Call to unimplemented function "<< __FUNCTION__); \
MOZ_ASSERT(false); \
MOZ_ASSERT(false); \
PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0)
@ -361,13 +361,13 @@ nsresult TransportLayerDtls::InitInternal() {
target_ = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't get socket transport service");
MOZ_MTLOG(ML_ERROR, "Couldn't get socket transport service");
return rv;
}
timer_ = do_CreateInstance(NS_TIMER_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't get timer");
MOZ_MTLOG(ML_ERROR, "Couldn't get timer");
return rv;
}
@ -424,18 +424,19 @@ bool TransportLayerDtls::Setup() {
SECStatus rv;
if (!downward_) {
MOZ_MTLOG(PR_LOG_ERROR, "DTLS layer with nothing below. This is useless");
MOZ_MTLOG(ML_ERROR, "DTLS layer with nothing below. This is useless");
return false;
}
nspr_io_adapter_ = new TransportLayerNSPRAdapter(downward_);
if (!identity_) {
MOZ_MTLOG(PR_LOG_ERROR, "Can't start DTLS without an identity");
MOZ_MTLOG(ML_ERROR, "Can't start DTLS without an identity");
return false;
}
if (verification_mode_ == VERIFY_UNSET) {
MOZ_MTLOG(PR_LOG_ERROR, "Can't start DTLS without specifying a verification mode");
MOZ_MTLOG(ML_ERROR,
"Can't start DTLS without specifying a verification mode");
return false;
}
@ -465,34 +466,34 @@ bool TransportLayerDtls::Setup() {
pr_fd.forget(); // ownership transfered to ssl_fd;
if (role_ == CLIENT) {
MOZ_MTLOG(PR_LOG_DEBUG, "Setting up DTLS as client");
MOZ_MTLOG(ML_DEBUG, "Setting up DTLS as client");
rv = SSL_GetClientAuthDataHook(ssl_fd, GetClientAuthDataHook,
this);
if (rv != SECSuccess) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't set identity");
MOZ_MTLOG(ML_ERROR, "Couldn't set identity");
return false;
}
} else {
MOZ_MTLOG(PR_LOG_DEBUG, "Setting up DTLS as server");
MOZ_MTLOG(ML_DEBUG, "Setting up DTLS as server");
// Server side
rv = SSL_ConfigSecureServer(ssl_fd, identity_->cert(),
identity_->privkey(),
kt_rsa);
if (rv != SECSuccess) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't set identity");
MOZ_MTLOG(ML_ERROR, "Couldn't set identity");
return false;
}
// Insist on a certificate from the client
rv = SSL_OptionSet(ssl_fd, SSL_REQUEST_CERTIFICATE, PR_TRUE);
if (rv != SECSuccess) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't request certificate");
MOZ_MTLOG(ML_ERROR, "Couldn't request certificate");
return false;
}
rv = SSL_OptionSet(ssl_fd, SSL_REQUIRE_CERTIFICATE, PR_TRUE);
if (rv != SECSuccess) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't require certificate");
MOZ_MTLOG(ML_ERROR, "Couldn't require certificate");
return false;
}
}
@ -506,43 +507,43 @@ bool TransportLayerDtls::Setup() {
rv = SSL_VersionRangeSet(ssl_fd, &version_range);
if (rv != SECSuccess) {
MOZ_MTLOG(PR_LOG_ERROR, "Can't disable SSLv3");
MOZ_MTLOG(ML_ERROR, "Can't disable SSLv3");
return false;
}
rv = SSL_OptionSet(ssl_fd, SSL_ENABLE_SESSION_TICKETS, PR_FALSE);
if (rv != SECSuccess) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't disable session tickets");
MOZ_MTLOG(ML_ERROR, "Couldn't disable session tickets");
return false;
}
rv = SSL_OptionSet(ssl_fd, SSL_NO_CACHE, PR_TRUE);
if (rv != SECSuccess) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't disable session caching");
MOZ_MTLOG(ML_ERROR, "Couldn't disable session caching");
return false;
}
rv = SSL_OptionSet(ssl_fd, SSL_ENABLE_DEFLATE, PR_FALSE);
if (rv != SECSuccess) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't disable deflate");
MOZ_MTLOG(ML_ERROR, "Couldn't disable deflate");
return false;
}
rv = SSL_OptionSet(ssl_fd, SSL_ENABLE_RENEGOTIATION, SSL_RENEGOTIATE_NEVER);
if (rv != SECSuccess) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't disable renegotiation");
MOZ_MTLOG(ML_ERROR, "Couldn't disable renegotiation");
return false;
}
rv = SSL_OptionSet(ssl_fd, SSL_ENABLE_FALSE_START, PR_FALSE);
if (rv != SECSuccess) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't disable false start");
MOZ_MTLOG(ML_ERROR, "Couldn't disable false start");
return false;
}
rv = SSL_OptionSet(ssl_fd, SSL_NO_LOCKS, PR_TRUE);
if (rv != SECSuccess) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't disable locks");
MOZ_MTLOG(ML_ERROR, "Couldn't disable locks");
return false;
}
@ -553,7 +554,7 @@ bool TransportLayerDtls::Setup() {
srtp_ciphers_.size());
if (rv != SECSuccess) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't set SRTP cipher suite");
MOZ_MTLOG(ML_ERROR, "Couldn't set SRTP cipher suite");
return false;
}
}
@ -562,14 +563,14 @@ bool TransportLayerDtls::Setup() {
rv = SSL_AuthCertificateHook(ssl_fd, AuthCertificateHook,
reinterpret_cast<void *>(this));
if (rv != SECSuccess) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't set certificate validation hook");
MOZ_MTLOG(ML_ERROR, "Couldn't set certificate validation hook");
return false;
}
// Now start the handshake
rv = SSL_ResetHandshake(ssl_fd, role_ == SERVER ? PR_TRUE : PR_FALSE);
if (rv != SECSuccess) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't reset handshake");
MOZ_MTLOG(ML_ERROR, "Couldn't reset handshake");
return false;
}
ssl_fd_ = ssl_fd.forget();
@ -588,7 +589,7 @@ bool TransportLayerDtls::Setup() {
void TransportLayerDtls::StateChange(TransportLayer *layer, State state) {
if (state <= state_) {
MOZ_MTLOG(PR_LOG_ERROR, "Lower layer state is going backwards from ours");
MOZ_MTLOG(ML_ERROR, "Lower layer state is going backwards from ours");
SetState(TS_ERROR);
return;
}
@ -599,26 +600,28 @@ void TransportLayerDtls::StateChange(TransportLayer *layer, State state) {
break;
case TS_INIT:
MOZ_MTLOG(PR_LOG_ERROR, LAYER_INFO << "State change of lower layer to INIT forbidden");
MOZ_MTLOG(ML_ERROR,
LAYER_INFO << "State change of lower layer to INIT forbidden");
SetState(TS_ERROR);
break;
case TS_CONNECTING:
MOZ_MTLOG(PR_LOG_ERROR, LAYER_INFO << "Lower lower is connecting.");
MOZ_MTLOG(ML_ERROR, LAYER_INFO << "Lower lower is connecting.");
break;
case TS_OPEN:
MOZ_MTLOG(PR_LOG_ERROR, LAYER_INFO << "Lower lower is now open; starting TLS");
MOZ_MTLOG(ML_ERROR,
LAYER_INFO << "Lower lower is now open; starting TLS");
Handshake();
break;
case TS_CLOSED:
MOZ_MTLOG(PR_LOG_ERROR, LAYER_INFO << "Lower lower is now closed");
MOZ_MTLOG(ML_ERROR, LAYER_INFO << "Lower lower is now closed");
SetState(TS_CLOSED);
break;
case TS_ERROR:
MOZ_MTLOG(PR_LOG_ERROR, LAYER_INFO << "Lower lower experienced an error");
MOZ_MTLOG(ML_ERROR, LAYER_INFO << "Lower lower experienced an error");
SetState(TS_ERROR);
break;
}
@ -633,9 +636,10 @@ void TransportLayerDtls::Handshake() {
SECStatus rv = SSL_ForceHandshake(ssl_fd_);
if (rv == SECSuccess) {
MOZ_MTLOG(PR_LOG_NOTICE, LAYER_INFO << "****** SSL handshake completed ******");
MOZ_MTLOG(ML_NOTICE,
LAYER_INFO << "****** SSL handshake completed ******");
if (!cert_ok_) {
MOZ_MTLOG(PR_LOG_ERROR, LAYER_INFO << "Certificate check never occurred");
MOZ_MTLOG(ML_ERROR, LAYER_INFO << "Certificate check never occurred");
SetState(TS_ERROR);
return;
}
@ -645,21 +649,21 @@ void TransportLayerDtls::Handshake() {
switch(err) {
case SSL_ERROR_RX_MALFORMED_HANDSHAKE:
if (mode_ != DGRAM) {
MOZ_MTLOG(PR_LOG_ERROR, LAYER_INFO << "Malformed TLS message");
MOZ_MTLOG(ML_ERROR, LAYER_INFO << "Malformed TLS message");
SetState(TS_ERROR);
} else {
MOZ_MTLOG(PR_LOG_ERROR, LAYER_INFO << "Malformed DTLS message; ignoring");
MOZ_MTLOG(ML_ERROR, LAYER_INFO << "Malformed DTLS message; ignoring");
}
// Fall through
case PR_WOULD_BLOCK_ERROR:
MOZ_MTLOG(PR_LOG_NOTICE, LAYER_INFO << "Would have blocked");
MOZ_MTLOG(ML_NOTICE, LAYER_INFO << "Would have blocked");
if (mode_ == DGRAM) {
PRIntervalTime timeout;
rv = DTLS_GetHandshakeTimeout(ssl_fd_, &timeout);
if (rv == SECSuccess) {
uint32_t timeout_ms = PR_IntervalToMilliseconds(timeout);
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << "Setting DTLS timeout to " <<
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Setting DTLS timeout to " <<
timeout_ms);
timer_->SetTarget(target_);
timer_->InitWithFuncCallback(TimerCallback,
@ -669,7 +673,7 @@ void TransportLayerDtls::Handshake() {
}
break;
default:
MOZ_MTLOG(PR_LOG_ERROR, LAYER_INFO << "SSL handshake error "<< err);
MOZ_MTLOG(ML_ERROR, LAYER_INFO << "SSL handshake error "<< err);
SetState(TS_ERROR);
break;
}
@ -680,10 +684,11 @@ void TransportLayerDtls::PacketReceived(TransportLayer* layer,
const unsigned char *data,
size_t len) {
CheckThread();
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << "PacketReceived(" << len << ")");
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "PacketReceived(" << len << ")");
if (state_ != TS_CONNECTING && state_ != TS_OPEN) {
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << "Discarding packet in inappropriate state");
MOZ_MTLOG(ML_DEBUG,
LAYER_INFO << "Discarding packet in inappropriate state");
return;
}
@ -701,7 +706,7 @@ void TransportLayerDtls::PacketReceived(TransportLayer* layer,
int32_t rv = PR_Recv(ssl_fd_, buf, sizeof(buf), 0, PR_INTERVAL_NO_WAIT);
if (rv > 0) {
// We have data
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << "Read " << rv << " bytes from NSS");
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Read " << rv << " bytes from NSS");
SignalPacketReceived(this, buf, rv);
} else if (rv == 0) {
SetState(TS_CLOSED);
@ -710,9 +715,9 @@ void TransportLayerDtls::PacketReceived(TransportLayer* layer,
if (err == PR_WOULD_BLOCK_ERROR) {
// This gets ignored
MOZ_MTLOG(PR_LOG_NOTICE, LAYER_INFO << "Would have blocked");
MOZ_MTLOG(ML_NOTICE, LAYER_INFO << "Would have blocked");
} else {
MOZ_MTLOG(PR_LOG_NOTICE, LAYER_INFO << "NSS Error " << err);
MOZ_MTLOG(ML_NOTICE, LAYER_INFO << "NSS Error " << err);
SetState(TS_ERROR);
}
}
@ -723,8 +728,8 @@ TransportResult TransportLayerDtls::SendPacket(const unsigned char *data,
size_t len) {
CheckThread();
if (state_ != TS_OPEN) {
MOZ_MTLOG(PR_LOG_ERROR, LAYER_INFO << "Can't call SendPacket() in state "
<< state_);
MOZ_MTLOG(ML_ERROR, LAYER_INFO << "Can't call SendPacket() in state "
<< state_);
return TE_ERROR;
}
@ -732,7 +737,7 @@ TransportResult TransportLayerDtls::SendPacket(const unsigned char *data,
if (rv > 0) {
// We have data
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << "Wrote " << rv << " bytes to SSL Layer");
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Wrote " << rv << " bytes to SSL Layer");
return rv;
}
@ -745,11 +750,11 @@ TransportResult TransportLayerDtls::SendPacket(const unsigned char *data,
if (err == PR_WOULD_BLOCK_ERROR) {
// This gets ignored
MOZ_MTLOG(PR_LOG_NOTICE, LAYER_INFO << "Would have blocked");
MOZ_MTLOG(ML_NOTICE, LAYER_INFO << "Would have blocked");
return TE_WOULDBLOCK;
}
MOZ_MTLOG(PR_LOG_NOTICE, LAYER_INFO << "NSS Error " << err);
MOZ_MTLOG(ML_NOTICE, LAYER_INFO << "NSS Error " << err);
SetState(TS_ERROR);
return TE_ERROR;
}
@ -758,13 +763,13 @@ SECStatus TransportLayerDtls::GetClientAuthDataHook(void *arg, PRFileDesc *fd,
CERTDistNames *caNames,
CERTCertificate **pRetCert,
SECKEYPrivateKey **pRetKey) {
MOZ_MTLOG(PR_LOG_DEBUG, "Server requested client auth");
MOZ_MTLOG(ML_DEBUG, "Server requested client auth");
TransportLayerDtls *stream = reinterpret_cast<TransportLayerDtls *>(arg);
stream->CheckThread();
if (!stream->identity_) {
MOZ_MTLOG(PR_LOG_ERROR, "No identity available");
MOZ_MTLOG(ML_ERROR, "No identity available");
PR_SetError(SSL_ERROR_NO_CERTIFICATE, 0);
return SECFailure;
}
@ -797,7 +802,7 @@ nsresult TransportLayerDtls::GetSrtpCipher(uint16_t *cipher) {
CheckThread();
SECStatus rv = SSL_GetSRTPCipher(ssl_fd_, cipher);
if (rv != SECSuccess) {
MOZ_MTLOG(PR_LOG_DEBUG, "No SRTP cipher negotiated");
MOZ_MTLOG(ML_DEBUG, "No SRTP cipher negotiated");
return NS_ERROR_FAILURE;
}
@ -820,7 +825,7 @@ nsresult TransportLayerDtls::ExportKeyingMaterial(const std::string& label,
out,
outlen);
if (rv != SECSuccess) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't export SSL keying material");
MOZ_MTLOG(ML_ERROR, "Couldn't export SSL keying material");
return NS_ERROR_FAILURE;
}
@ -843,7 +848,8 @@ TransportLayerDtls::CheckDigest(const RefPtr<VerificationDigest>&
unsigned char computed_digest[kMaxDigestLength];
size_t computed_digest_len;
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << "Checking digest, algorithm=" << digest->algorithm_);
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Checking digest, algorithm="
<< digest->algorithm_);
nsresult res =
DtlsIdentity::ComputeFingerprint(peer_cert,
digest->algorithm_,
@ -851,23 +857,23 @@ TransportLayerDtls::CheckDigest(const RefPtr<VerificationDigest>&
sizeof(computed_digest),
&computed_digest_len);
if (NS_FAILED(res)) {
MOZ_MTLOG(PR_LOG_ERROR, "Could not compute peer fingerprint for digest " <<
digest->algorithm_);
MOZ_MTLOG(ML_ERROR, "Could not compute peer fingerprint for digest " <<
digest->algorithm_);
// Go to end
PR_SetError(SSL_ERROR_BAD_CERTIFICATE, 0);
return SECFailure;
}
if (computed_digest_len != digest->len_) {
MOZ_MTLOG(PR_LOG_ERROR, "Digest is wrong length " << digest->len_ <<
" should be " << computed_digest_len << " for algorithm " <<
digest->algorithm_);
MOZ_MTLOG(ML_ERROR, "Digest is wrong length " << digest->len_ <<
" should be " << computed_digest_len << " for algorithm " <<
digest->algorithm_);
PR_SetError(SSL_ERROR_BAD_CERTIFICATE, 0);
return SECFailure;
}
if (memcmp(digest->value_, computed_digest, computed_digest_len) != 0) {
MOZ_MTLOG(PR_LOG_ERROR, "Digest does not match");
MOZ_MTLOG(ML_ERROR, "Digest does not match");
PR_SetError(SSL_ERROR_BAD_CERTIFICATE, 0);
return SECFailure;
}
@ -933,14 +939,14 @@ SECStatus TransportLayerDtls::AuthCertificateHook(PRFileDesc *fd,
default:
MOZ_CRASH(); // Can't happen
}
return SECFailure;
}
void TransportLayerDtls::TimerCallback(nsITimer *timer, void *arg) {
TransportLayerDtls *dtls = reinterpret_cast<TransportLayerDtls *>(arg);
MOZ_MTLOG(PR_LOG_DEBUG, "DTLS timer expired");
MOZ_MTLOG(ML_DEBUG, "DTLS timer expired");
dtls->Handshake();
}

View File

@ -113,7 +113,7 @@ TransportResult TransportLayerIce::SendPacket(const unsigned char *data,
TE_WOULDBLOCK : TE_ERROR;
}
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << " SendPacket(" << len << ") succeeded");
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << " SendPacket(" << len << ") succeeded");
return len;
}
@ -142,7 +142,7 @@ void TransportLayerIce::IcePacketReceived(NrIceMediaStream *stream, int componen
if (component_ != component)
return;
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << "PacketReceived(" << stream->name() << ","
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "PacketReceived(" << stream->name() << ","
<< component << "," << len << ")");
SignalPacketReceived(this, data, len);
}

View File

@ -26,7 +26,7 @@ void TransportLayerLogging::WasInserted() {
TransportResult
TransportLayerLogging::SendPacket(const unsigned char *data, size_t len) {
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << "SendPacket(" << len << ")");
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "SendPacket(" << len << ")");
if (downward_) {
return downward_->SendPacket(data, len);
@ -37,7 +37,7 @@ TransportLayerLogging::SendPacket(const unsigned char *data, size_t len) {
}
void TransportLayerLogging::StateChange(TransportLayer *layer, State state) {
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << "Received StateChange to " << state);
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Received StateChange to " << state);
SetState(state);
}
@ -45,7 +45,7 @@ void TransportLayerLogging::StateChange(TransportLayer *layer, State state) {
void TransportLayerLogging::PacketReceived(TransportLayer* layer,
const unsigned char *data,
size_t len) {
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << "PacketReceived(" << len << ")");
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "PacketReceived(" << len << ")");
SignalPacketReceived(this, data, len);
}

View File

@ -62,10 +62,10 @@ void TransportLayerLoopback::Connect(TransportLayerLoopback* peer) {
TransportResult
TransportLayerLoopback::SendPacket(const unsigned char *data, size_t len) {
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << "SendPacket(" << len << ")");
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "SendPacket(" << len << ")");
if (!peer_) {
MOZ_MTLOG(PR_LOG_ERROR, "Discarding packet because peer not attached");
MOZ_MTLOG(ML_ERROR, "Discarding packet because peer not attached");
return TE_ERROR;
}
@ -78,7 +78,7 @@ TransportLayerLoopback::SendPacket(const unsigned char *data, size_t len) {
nsresult TransportLayerLoopback::QueuePacket(const unsigned char *data,
size_t len) {
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << " Enqueuing packet of length " << len);
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << " Enqueuing packet of length " << len);
MOZ_ASSERT(packets_lock_);
PR_Lock(packets_lock_);
@ -100,7 +100,7 @@ void TransportLayerLoopback::DeliverPackets() {
QueuedPacket *packet = packets_.front();
packets_.pop();
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << " Delivering packet of length " <<
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << " Delivering packet of length " <<
packet->len());
SignalPacketReceived(this, packet->data(), packet->len());

View File

@ -31,7 +31,7 @@ nsresult TransportLayerPrsock::InitInternal() {
stservice_ = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
if (!NS_SUCCEEDED(rv)) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't get socket transport service");
MOZ_MTLOG(ML_ERROR, "Couldn't get socket transport service");
return rv;
}
@ -44,7 +44,7 @@ void TransportLayerPrsock::Import(PRFileDesc *fd, nsresult *result) {
return;
}
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << "Importing()");
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Importing()");
fd_ = fd;
handler_ = new SocketHandler(this, fd);
@ -60,27 +60,27 @@ void TransportLayerPrsock::Import(PRFileDesc *fd, nsresult *result) {
}
int TransportLayerPrsock::SendPacket(const unsigned char *data, size_t len) {
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << "SendPacket(" << len << ")");
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "SendPacket(" << len << ")");
if (state_ != TS_OPEN) {
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << "Can't send packet on closed interface");
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Can't send packet on closed interface");
return TE_INTERNAL;
}
int32_t status;
status = PR_Write(fd_, data, len);
if (status >= 0) {
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << "Wrote " << len << " bytes");
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Wrote " << len << " bytes");
return status;
}
PRErrorCode err = PR_GetError();
if (err == PR_WOULD_BLOCK_ERROR) {
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << "Write blocked");
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Write blocked");
return TE_WOULDBLOCK;
}
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << "Write error; channel closed");
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Write error; channel closed");
SetState(TS_ERROR);
return TE_ERROR;
}
@ -90,23 +90,23 @@ void TransportLayerPrsock::OnSocketReady(PRFileDesc *fd, int16_t outflags) {
return;
}
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << "OnSocketReady(flags=" << outflags << ")");
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "OnSocketReady(flags=" << outflags << ")");
unsigned char buf[1600];
int32_t rv = PR_Read(fd, buf, sizeof(buf));
if (rv > 0) {
// Successful read
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << "Read " << rv << " bytes");
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Read " << rv << " bytes");
SignalPacketReceived(this, buf, rv);
} else if (rv == 0) {
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << "Read 0 bytes; channel closed");
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Read 0 bytes; channel closed");
SetState(TS_CLOSED);
} else {
PRErrorCode err = PR_GetError();
if (err != PR_WOULD_BLOCK_ERROR) {
MOZ_MTLOG(PR_LOG_DEBUG, LAYER_INFO << "Read error; channel closed");
MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Read error; channel closed");
SetState(TS_ERROR);
}
}

View File

@ -39,13 +39,6 @@
using namespace mozilla;
#ifdef DEBUG
// Dial up pipeline logging in debug mode
#define MP_LOG_INFO PR_LOG_WARN
#else
#define MP_LOG_INFO PR_LOG_DEBUG
#endif
// Logging context
MOZ_MTLOG_MODULE("mediapipeline")
@ -55,7 +48,7 @@ static char kDTLSExporterLabel[] = "EXTRACTOR-dtls_srtp";
MediaPipeline::~MediaPipeline() {
MOZ_ASSERT(!stream_); // Check that we have shut down already.
MOZ_MTLOG(PR_LOG_DEBUG, "Destroying MediaPipeline: " << description_);
MOZ_MTLOG(ML_DEBUG, "Destroying MediaPipeline: " << description_);
}
nsresult MediaPipeline::Init() {
@ -83,12 +76,12 @@ nsresult MediaPipeline::Init_s() {
if (rtp_transport_->state() == TransportLayer::TS_OPEN) {
res = TransportReady_s(rtp_transport_);
if (NS_FAILED(res)) {
MOZ_MTLOG(PR_LOG_ERROR, "Error calling TransportReady(); res="
MOZ_MTLOG(ML_ERROR, "Error calling TransportReady(); res="
<< static_cast<uint32_t>(res) << " in " << __FUNCTION__);
return res;
}
} else if (rtp_transport_->state() == TransportLayer::TS_ERROR) {
MOZ_MTLOG(PR_LOG_ERROR, "RTP transport is already in error state");
MOZ_MTLOG(ML_ERROR, "RTP transport is already in error state");
TransportFailed_s(rtp_transport_);
return NS_ERROR_FAILURE;
} else {
@ -99,12 +92,12 @@ nsresult MediaPipeline::Init_s() {
if (rtcp_transport_->state() == TransportLayer::TS_OPEN) {
res = TransportReady_s(rtcp_transport_);
if (NS_FAILED(res)) {
MOZ_MTLOG(PR_LOG_ERROR, "Error calling TransportReady(); res="
MOZ_MTLOG(ML_ERROR, "Error calling TransportReady(); res="
<< static_cast<uint32_t>(res) << " in " << __FUNCTION__);
return res;
}
} else if (rtcp_transport_->state() == TransportLayer::TS_ERROR) {
MOZ_MTLOG(PR_LOG_ERROR, "RTCP transport is already in error state");
MOZ_MTLOG(ML_ERROR, "RTCP transport is already in error state");
TransportFailed_s(rtcp_transport_);
return NS_ERROR_FAILURE;
}
@ -129,7 +122,7 @@ void MediaPipeline::ShutdownTransport_s() {
void MediaPipeline::StateChange(TransportFlow *flow, TransportLayer::State state) {
if (state == TransportLayer::TS_OPEN) {
MOZ_MTLOG(MP_LOG_INFO, "Flow is ready");
MOZ_MTLOG(ML_DEBUG, "Flow is ready");
TransportReady_s(flow);
} else if (state == TransportLayer::TS_CLOSED ||
state == TransportLayer::TS_ERROR) {
@ -145,14 +138,14 @@ nsresult MediaPipeline::TransportReady_s(TransportFlow *flow) {
// TODO(ekr@rtfm.com): implement some kind of notification on
// failure. bug 852665.
if (*state != MP_CONNECTING) {
MOZ_MTLOG(PR_LOG_ERROR, "Transport ready for flow in wrong state:" <<
MOZ_MTLOG(ML_ERROR, "Transport ready for flow in wrong state:" <<
description_ << ": " << (rtcp ? "rtcp" : "rtp"));
return NS_ERROR_FAILURE;
}
nsresult res;
MOZ_MTLOG(MP_LOG_INFO, "Transport ready for pipeline " <<
MOZ_MTLOG(ML_DEBUG, "Transport ready for pipeline " <<
static_cast<void *>(this) << " flow " << description_ << ": " <<
(rtcp ? "rtcp" : "rtp"));
@ -164,7 +157,7 @@ nsresult MediaPipeline::TransportReady_s(TransportFlow *flow) {
uint16_t cipher_suite;
res = dtls->GetSrtpCipher(&cipher_suite);
if (NS_FAILED(res)) {
MOZ_MTLOG(PR_LOG_ERROR, "Failed to negotiate DTLS-SRTP. This is an error");
MOZ_MTLOG(ML_ERROR, "Failed to negotiate DTLS-SRTP. This is an error");
*state = MP_CLOSED;
return res;
}
@ -174,7 +167,7 @@ nsresult MediaPipeline::TransportReady_s(TransportFlow *flow) {
res = dtls->ExportKeyingMaterial(kDTLSExporterLabel, false, "",
srtp_block, sizeof(srtp_block));
if (NS_FAILED(res)) {
MOZ_MTLOG(PR_LOG_ERROR, "Failed to compute DTLS-SRTP keys. This is an error");
MOZ_MTLOG(ML_ERROR, "Failed to compute DTLS-SRTP keys. This is an error");
*state = MP_CLOSED;
MOZ_CRASH(); // TODO: Remove once we have enough field experience to
// know it doesn't happen. bug 798797. Note that the
@ -217,7 +210,7 @@ nsresult MediaPipeline::TransportReady_s(TransportFlow *flow) {
rtp_recv_srtp_ = SrtpFlow::Create(cipher_suite, true,
read_key, SRTP_TOTAL_KEY_LENGTH);
if (!rtp_send_srtp_ || !rtp_recv_srtp_) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't create SRTP flow for RTCP");
MOZ_MTLOG(ML_ERROR, "Couldn't create SRTP flow for RTCP");
*state = MP_CLOSED;
return NS_ERROR_FAILURE;
}
@ -228,14 +221,14 @@ nsresult MediaPipeline::TransportReady_s(TransportFlow *flow) {
rtcp_send_srtp_ = rtp_send_srtp_;
rtcp_recv_srtp_ = rtp_recv_srtp_;
MOZ_MTLOG(MP_LOG_INFO, "Listening for packets received on " <<
MOZ_MTLOG(ML_DEBUG, "Listening for packets received on " <<
static_cast<void *>(dtls->downward()));
dtls->downward()->SignalPacketReceived.connect(this,
&MediaPipeline::
PacketReceived);
} else {
MOZ_MTLOG(MP_LOG_INFO, "Listening for RTP packets received on " <<
MOZ_MTLOG(ML_DEBUG, "Listening for RTP packets received on " <<
static_cast<void *>(dtls->downward()));
dtls->downward()->SignalPacketReceived.connect(this,
@ -250,13 +243,13 @@ nsresult MediaPipeline::TransportReady_s(TransportFlow *flow) {
rtcp_recv_srtp_ = SrtpFlow::Create(cipher_suite, true,
read_key, SRTP_TOTAL_KEY_LENGTH);
if (!rtcp_send_srtp_ || !rtcp_recv_srtp_) {
MOZ_MTLOG(PR_LOG_ERROR, "Couldn't create SRTCP flow for RTCP");
MOZ_MTLOG(ML_ERROR, "Couldn't create SRTCP flow for RTCP");
*state = MP_CLOSED;
return NS_ERROR_FAILURE;
}
MOZ_MTLOG(MP_LOG_INFO, "Listening for RTCP packets received on " <<
static_cast<void *>(dtls->downward()));
MOZ_MTLOG(ML_DEBUG, "Listening for RTCP packets received on " <<
static_cast<void *>(dtls->downward()));
// Start listening
dtls->downward()->SignalPacketReceived.connect(this,
@ -276,7 +269,7 @@ nsresult MediaPipeline::TransportFailed_s(TransportFlow *flow) {
*state = MP_CLOSED;
MOZ_MTLOG(MP_LOG_INFO, "Transport closed for flow " << (rtcp ? "rtcp" : "rtp"));
MOZ_MTLOG(ML_DEBUG, "Transport closed for flow " << (rtcp ? "rtcp" : "rtp"));
NS_WARNING(
"MediaPipeline Transport failed. This is not properly cleaned up yet");
@ -308,7 +301,7 @@ nsresult MediaPipeline::SendPacket(TransportFlow *flow, const void *data,
if (res == TE_WOULDBLOCK)
return NS_OK;
MOZ_MTLOG(PR_LOG_ERROR, "Failed write on stream");
MOZ_MTLOG(ML_ERROR, "Failed write on stream");
return NS_BASE_STREAM_CLOSED;
}
@ -319,7 +312,7 @@ void MediaPipeline::increment_rtp_packets_sent() {
++rtp_packets_sent_;
if (!(rtp_packets_sent_ % 100)) {
MOZ_MTLOG(MP_LOG_INFO, "RTP sent packet count for " << description_
MOZ_MTLOG(ML_DEBUG, "RTP sent packet count for " << description_
<< " Pipeline " << static_cast<void *>(this)
<< " Flow : " << static_cast<void *>(rtp_transport_)
<< ": " << rtp_packets_sent_);
@ -329,7 +322,7 @@ void MediaPipeline::increment_rtp_packets_sent() {
void MediaPipeline::increment_rtcp_packets_sent() {
++rtcp_packets_sent_;
if (!(rtcp_packets_sent_ % 100)) {
MOZ_MTLOG(MP_LOG_INFO, "RTCP sent packet count for " << description_
MOZ_MTLOG(ML_DEBUG, "RTCP sent packet count for " << description_
<< " Pipeline " << static_cast<void *>(this)
<< " Flow : " << static_cast<void *>(rtcp_transport_)
<< ": " << rtcp_packets_sent_);
@ -339,7 +332,7 @@ void MediaPipeline::increment_rtcp_packets_sent() {
void MediaPipeline::increment_rtp_packets_received() {
++rtp_packets_received_;
if (!(rtp_packets_received_ % 100)) {
MOZ_MTLOG(MP_LOG_INFO, "RTP received packet count for " << description_
MOZ_MTLOG(ML_DEBUG, "RTP received packet count for " << description_
<< " Pipeline " << static_cast<void *>(this)
<< " Flow : " << static_cast<void *>(rtp_transport_)
<< ": " << rtp_packets_received_);
@ -349,7 +342,7 @@ void MediaPipeline::increment_rtp_packets_received() {
void MediaPipeline::increment_rtcp_packets_received() {
++rtcp_packets_received_;
if (!(rtcp_packets_received_ % 100)) {
MOZ_MTLOG(MP_LOG_INFO, "RTCP received packet count for " << description_
MOZ_MTLOG(ML_DEBUG, "RTCP received packet count for " << description_
<< " Pipeline " << static_cast<void *>(this)
<< " Flow : " << static_cast<void *>(rtcp_transport_)
<< ": " << rtcp_packets_received_);
@ -360,22 +353,22 @@ void MediaPipeline::RtpPacketReceived(TransportLayer *layer,
const unsigned char *data,
size_t len) {
if (!transport_->pipeline()) {
MOZ_MTLOG(PR_LOG_DEBUG, "Discarding incoming packet; transport disconnected");
MOZ_MTLOG(ML_DEBUG, "Discarding incoming packet; transport disconnected");
return;
}
if (!conduit_) {
MOZ_MTLOG(PR_LOG_DEBUG, "Discarding incoming packet; media disconnected");
MOZ_MTLOG(ML_DEBUG, "Discarding incoming packet; media disconnected");
return;
}
if (rtp_state_ != MP_OPEN) {
MOZ_MTLOG(PR_LOG_DEBUG, "Discarding incoming packet; pipeline not open");
MOZ_MTLOG(ML_DEBUG, "Discarding incoming packet; pipeline not open");
return;
}
if (rtp_transport_->state() != TransportLayer::TS_OPEN) {
MOZ_MTLOG(PR_LOG_ERROR, "Discarding incoming packet; transport not open");
MOZ_MTLOG(ML_ERROR, "Discarding incoming packet; transport not open");
return;
}
@ -408,22 +401,22 @@ void MediaPipeline::RtcpPacketReceived(TransportLayer *layer,
const unsigned char *data,
size_t len) {
if (!transport_->pipeline()) {
MOZ_MTLOG(PR_LOG_DEBUG, "Discarding incoming packet; transport disconnected");
MOZ_MTLOG(ML_DEBUG, "Discarding incoming packet; transport disconnected");
return;
}
if (!conduit_) {
MOZ_MTLOG(PR_LOG_DEBUG, "Discarding incoming packet; media disconnected");
MOZ_MTLOG(ML_DEBUG, "Discarding incoming packet; media disconnected");
return;
}
if (rtcp_state_ != MP_OPEN) {
MOZ_MTLOG(PR_LOG_DEBUG, "Discarding incoming packet; pipeline not open");
MOZ_MTLOG(ML_DEBUG, "Discarding incoming packet; pipeline not open");
return;
}
if (rtcp_transport_->state() != TransportLayer::TS_OPEN) {
MOZ_MTLOG(PR_LOG_ERROR, "Discarding incoming packet; transport not open");
MOZ_MTLOG(ML_ERROR, "Discarding incoming packet; transport not open");
return;
}
@ -488,7 +481,7 @@ void MediaPipeline::PacketReceived(TransportLayer *layer,
const unsigned char *data,
size_t len) {
if (!transport_->pipeline()) {
MOZ_MTLOG(PR_LOG_DEBUG, "Discarding incoming packet; transport disconnected");
MOZ_MTLOG(ML_DEBUG, "Discarding incoming packet; transport disconnected");
return;
}
@ -513,11 +506,9 @@ nsresult MediaPipelineTransmit::Init() {
description_ += "]";
// TODO(ekr@rtfm.com): Check for errors
MOZ_MTLOG(PR_LOG_DEBUG, "Attaching pipeline to stream "
<< static_cast<void *>(stream_) <<
" conduit type=" <<
(conduit_->type() == MediaSessionConduit::AUDIO ?
"audio" : "video"));
MOZ_MTLOG(ML_DEBUG, "Attaching pipeline to stream "
<< static_cast<void *>(stream_) << " conduit type=" <<
(conduit_->type() == MediaSessionConduit::AUDIO ?"audio":"video"));
stream_->AddListener(listener_);
@ -558,7 +549,7 @@ nsresult MediaPipeline::PipelineTransport::SendRtpPacket_s(
return NS_OK; // Detached
if (!pipeline_->rtp_send_srtp_) {
MOZ_MTLOG(PR_LOG_DEBUG, "Couldn't write RTP packet; SRTP not set up yet");
MOZ_MTLOG(ML_DEBUG, "Couldn't write RTP packet; SRTP not set up yet");
return NS_OK;
}
@ -609,7 +600,7 @@ nsresult MediaPipeline::PipelineTransport::SendRtcpPacket_s(
return NS_OK; // Detached
if (!pipeline_->rtcp_send_srtp_) {
MOZ_MTLOG(PR_LOG_DEBUG, "Couldn't write RTCP packet; SRTCP not set up yet");
MOZ_MTLOG(ML_DEBUG, "Couldn't write RTCP packet; SRTCP not set up yet");
return NS_OK;
}
@ -644,10 +635,10 @@ NotifyQueuedTrackChanges(MediaStreamGraph* graph, TrackID tid,
TrackTicks offset,
uint32_t events,
const MediaSegment& queued_media) {
MOZ_MTLOG(PR_LOG_DEBUG, "MediaPipeline::NotifyQueuedTrackChanges()");
MOZ_MTLOG(ML_DEBUG, "MediaPipeline::NotifyQueuedTrackChanges()");
if (!active_) {
MOZ_MTLOG(PR_LOG_DEBUG, "Discarding packets because transport not ready");
MOZ_MTLOG(ML_DEBUG, "Discarding packets because transport not ready");
return;
}
@ -699,7 +690,7 @@ void MediaPipelineTransmit::PipelineListener::ProcessAudioChunk(
if (chunk.mBuffer) {
switch (chunk.mBufferFormat) {
case AUDIO_FORMAT_FLOAT32:
MOZ_MTLOG(PR_LOG_ERROR, "Can't process audio except in 16-bit PCM yet");
MOZ_MTLOG(ML_ERROR, "Can't process audio except in 16-bit PCM yet");
MOZ_ASSERT(PR_FALSE);
return;
break;
@ -816,7 +807,7 @@ void MediaPipelineTransmit::PipelineListener::ProcessVideoChunk(
// Fill Cb/Cr planes
memset(pixelData + yPlaneLen, 0x80, cbcrPlaneLen);
MOZ_MTLOG(PR_LOG_DEBUG, "Sending a black video frame");
MOZ_MTLOG(ML_DEBUG, "Sending a black video frame");
conduit->SendVideoFrame(pixelData, length, size.width, size.height,
mozilla::kVideoI420, 0);
}
@ -878,11 +869,11 @@ void MediaPipelineTransmit::PipelineListener::ProcessVideoChunk(
// modify SendVideoFrame or copy/move the data in the buffer.
// OK, pass it on to the conduit
MOZ_MTLOG(PR_LOG_DEBUG, "Sending a video frame");
MOZ_MTLOG(ML_DEBUG, "Sending a video frame");
// Not much for us to do with an error
conduit->SendVideoFrame(y, length, width, height, mozilla::kVideoI420, 0);
} else {
MOZ_MTLOG(PR_LOG_ERROR, "Unsupported video format");
MOZ_MTLOG(ML_ERROR, "Unsupported video format");
MOZ_ASSERT(PR_FALSE);
return;
}
@ -892,7 +883,7 @@ void MediaPipelineTransmit::PipelineListener::ProcessVideoChunk(
nsresult MediaPipelineReceiveAudio::Init() {
char track_id_string[11];
ASSERT_ON_THREAD(main_thread_);
MOZ_MTLOG(PR_LOG_DEBUG, __FUNCTION__);
MOZ_MTLOG(ML_DEBUG, __FUNCTION__);
// We can replace this when we are allowed to do streams or std::to_string
PR_snprintf(track_id_string, sizeof(track_id_string), "%d", track_id_);
@ -936,7 +927,7 @@ static void AddTrackAndListener(MediaStream* source,
// a track "later".
if (current_end != 0L) {
MOZ_MTLOG(MP_LOG_INFO, "added track @ " << current_end <<
MOZ_MTLOG(ML_DEBUG, "added track @ " << current_end <<
" -> " << MediaTimeToSeconds(current_end));
}
@ -991,7 +982,7 @@ void MediaPipelineReceiveAudio::PipelineListener::
NotifyPull(MediaStreamGraph* graph, StreamTime desired_time) {
MOZ_ASSERT(source_);
if (!source_) {
MOZ_MTLOG(PR_LOG_ERROR, "NotifyPull() called from a non-SourceMediaStream");
MOZ_MTLOG(ML_ERROR, "NotifyPull() called from a non-SourceMediaStream");
return;
}
@ -1017,14 +1008,17 @@ NotifyPull(MediaStreamGraph* graph, StreamTime desired_time) {
if (err != kMediaConduitNoError) {
// Insert silence on conduit/GIPS failure (extremely unlikely)
MOZ_MTLOG(PR_LOG_ERROR, "Audio conduit failed (" << err << ") to return data @ " << played_ticks_ <<
" (desired " << desired_time << " -> " << MediaTimeToSeconds(desired_time) << ")");
MOZ_MTLOG(ML_ERROR, "Audio conduit failed (" << err
<< ") to return data @ " << played_ticks_
<< " (desired " << desired_time << " -> "
<< MediaTimeToSeconds(desired_time) << ")");
MOZ_ASSERT(err == kMediaConduitNoError);
samples_length = (track_rate_/100)*sizeof(uint16_t); // if this is not enough we'll loop and provide more
memset(samples_data, '\0', samples_length);
}
MOZ_MTLOG(PR_LOG_DEBUG, "Audio conduit returned buffer of length " << samples_length);
MOZ_MTLOG(ML_DEBUG, "Audio conduit returned buffer of length "
<< samples_length);
AudioSegment segment;
nsAutoTArray<const int16_t*,1> channels;
@ -1035,7 +1029,7 @@ NotifyPull(MediaStreamGraph* graph, StreamTime desired_time) {
if (source_->AppendToTrack(track_id_, &segment)) {
played_ticks_ += track_rate_/100; // 10ms in TrackTicks
} else {
MOZ_MTLOG(PR_LOG_ERROR, "AppendToTrack failed");
MOZ_MTLOG(ML_ERROR, "AppendToTrack failed");
// we can't un-read the data, but that's ok since we don't want to
// buffer - but don't i-loop!
return;
@ -1046,7 +1040,7 @@ NotifyPull(MediaStreamGraph* graph, StreamTime desired_time) {
nsresult MediaPipelineReceiveVideo::Init() {
char track_id_string[11];
ASSERT_ON_THREAD(main_thread_);
MOZ_MTLOG(PR_LOG_DEBUG, __FUNCTION__);
MOZ_MTLOG(ML_DEBUG, __FUNCTION__);
// We can replace this when we are allowed to do streams or std::to_string
PR_snprintf(track_id_string, sizeof(track_id_string), "%d", track_id_);
@ -1141,7 +1135,7 @@ NotifyPull(MediaStreamGraph* graph, StreamTime desired_time) {
if (source_->AppendToTrack(track_id_, &segment)) {
played_ticks_ = target;
} else {
MOZ_MTLOG(PR_LOG_ERROR, "AppendToTrack failed");
MOZ_MTLOG(ML_ERROR, "AppendToTrack failed");
return;
}
}

View File

@ -38,12 +38,12 @@ RefPtr<SrtpFlow> SrtpFlow::Create(int cipher_suite,
RefPtr<SrtpFlow> flow = new SrtpFlow();
if (!key) {
MOZ_MTLOG(PR_LOG_ERROR, "Null SRTP key specified");
MOZ_MTLOG(ML_ERROR, "Null SRTP key specified");
return NULL;
}
if (key_len != SRTP_TOTAL_KEY_LENGTH) {
MOZ_MTLOG(PR_LOG_ERROR, "Invalid SRTP key length");
MOZ_MTLOG(ML_ERROR, "Invalid SRTP key length");
return NULL;
}
@ -54,17 +54,19 @@ RefPtr<SrtpFlow> SrtpFlow::Create(int cipher_suite,
// since any flow can only have one cipher suite with DTLS-SRTP
switch (cipher_suite) {
case SRTP_AES128_CM_HMAC_SHA1_80:
MOZ_MTLOG(PR_LOG_DEBUG, "Setting SRTP cipher suite SRTP_AES128_CM_HMAC_SHA1_80");
MOZ_MTLOG(ML_DEBUG,
"Setting SRTP cipher suite SRTP_AES128_CM_HMAC_SHA1_80");
crypto_policy_set_aes_cm_128_hmac_sha1_80(&policy.rtp);
crypto_policy_set_aes_cm_128_hmac_sha1_80(&policy.rtcp);
break;
case SRTP_AES128_CM_HMAC_SHA1_32:
MOZ_MTLOG(PR_LOG_DEBUG, "Setting SRTP cipher suite SRTP_AES128_CM_HMAC_SHA1_32");
MOZ_MTLOG(ML_DEBUG,
"Setting SRTP cipher suite SRTP_AES128_CM_HMAC_SHA1_32");
crypto_policy_set_aes_cm_128_hmac_sha1_32(&policy.rtp);
crypto_policy_set_aes_cm_128_hmac_sha1_80(&policy.rtcp); // 80-bit per RFC 5764
break; // S 4.1.2.
default:
MOZ_MTLOG(PR_LOG_ERROR, "Request to set unknown SRTP cipher suite");
MOZ_MTLOG(ML_ERROR, "Request to set unknown SRTP cipher suite");
return NULL;
}
// This key is copied into the srtp_t object, so we don't
@ -81,7 +83,7 @@ RefPtr<SrtpFlow> SrtpFlow::Create(int cipher_suite,
// Now make the session
err_status_t r = srtp_create(&flow->session_, &policy);
if (r != err_status_ok) {
MOZ_MTLOG(PR_LOG_ERROR, "Error creating srtp session");
MOZ_MTLOG(ML_ERROR, "Error creating srtp session");
return NULL;
}
@ -93,30 +95,30 @@ nsresult SrtpFlow::CheckInputs(bool protect, void *in, int in_len,
int max_len, int *out_len) {
MOZ_ASSERT(in);
if (!in) {
MOZ_MTLOG(PR_LOG_ERROR, "NULL input value");
MOZ_MTLOG(ML_ERROR, "NULL input value");
return NS_ERROR_NULL_POINTER;
}
if (in_len < 0) {
MOZ_MTLOG(PR_LOG_ERROR, "Input length is negative");
MOZ_MTLOG(ML_ERROR, "Input length is negative");
return NS_ERROR_ILLEGAL_VALUE;
}
if (max_len < 0) {
MOZ_MTLOG(PR_LOG_ERROR, "Max output length is negative");
MOZ_MTLOG(ML_ERROR, "Max output length is negative");
return NS_ERROR_ILLEGAL_VALUE;
}
if (protect) {
if ((max_len < SRTP_MAX_EXPANSION) ||
((max_len - SRTP_MAX_EXPANSION) < in_len)) {
MOZ_MTLOG(PR_LOG_ERROR, "Output too short");
MOZ_MTLOG(ML_ERROR, "Output too short");
return NS_ERROR_ILLEGAL_VALUE;
}
}
else {
if (in_len > max_len) {
MOZ_MTLOG(PR_LOG_ERROR, "Output too short");
MOZ_MTLOG(ML_ERROR, "Output too short");
return NS_ERROR_ILLEGAL_VALUE;
}
}
@ -134,7 +136,7 @@ nsresult SrtpFlow::ProtectRtp(void *in, int in_len,
err_status_t r = srtp_protect(session_, in, &len);
if (r != err_status_ok) {
MOZ_MTLOG(PR_LOG_ERROR, "Error protecting SRTP packet");
MOZ_MTLOG(ML_ERROR, "Error protecting SRTP packet");
return NS_ERROR_FAILURE;
}
@ -142,7 +144,8 @@ nsresult SrtpFlow::ProtectRtp(void *in, int in_len,
*out_len = len;
MOZ_MTLOG(PR_LOG_DEBUG, "Successfully protected an SRTP packet of len " << *out_len);
MOZ_MTLOG(ML_DEBUG, "Successfully protected an SRTP packet of len "
<< *out_len);
return NS_OK;
}
@ -157,14 +160,15 @@ nsresult SrtpFlow::UnprotectRtp(void *in, int in_len,
err_status_t r = srtp_unprotect(session_, in, &len);
if (r != err_status_ok) {
MOZ_MTLOG(PR_LOG_ERROR, "Error unprotecting SRTP packet");
MOZ_MTLOG(ML_ERROR, "Error unprotecting SRTP packet");
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(len <= max_len);
*out_len = len;
MOZ_MTLOG(PR_LOG_DEBUG, "Successfully unprotected an SRTP packet of len " << *out_len);
MOZ_MTLOG(ML_DEBUG, "Successfully unprotected an SRTP packet of len "
<< *out_len);
return NS_OK;
}
@ -179,14 +183,15 @@ nsresult SrtpFlow::ProtectRtcp(void *in, int in_len,
err_status_t r = srtp_protect_rtcp(session_, in, &len);
if (r != err_status_ok) {
MOZ_MTLOG(PR_LOG_ERROR, "Error protecting SRTCP packet");
MOZ_MTLOG(ML_ERROR, "Error protecting SRTCP packet");
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(len <= max_len);
*out_len = len;
MOZ_MTLOG(PR_LOG_DEBUG, "Successfully protected an SRTCP packet of len " << *out_len);
MOZ_MTLOG(ML_DEBUG, "Successfully protected an SRTCP packet of len "
<< *out_len);
return NS_OK;
}
@ -201,14 +206,15 @@ nsresult SrtpFlow::UnprotectRtcp(void *in, int in_len,
err_status_t r = srtp_unprotect_rtcp(session_, in, &len);
if (r != err_status_ok) {
MOZ_MTLOG(PR_LOG_ERROR, "Error unprotecting SRTCP packet");
MOZ_MTLOG(ML_ERROR, "Error unprotecting SRTCP packet");
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(len <= max_len);
*out_len = len;
MOZ_MTLOG(PR_LOG_DEBUG, "Successfully unprotected an SRTCP packet of len " << *out_len);
MOZ_MTLOG(ML_DEBUG, "Successfully unprotected an SRTCP packet of len "
<< *out_len);
return NS_OK;
}
@ -223,14 +229,14 @@ nsresult SrtpFlow::Init() {
if (!initialized) {
err_status_t r = srtp_init();
if (r != err_status_ok) {
MOZ_MTLOG(PR_LOG_ERROR, "Could not initialize SRTP");
MOZ_MTLOG(ML_ERROR, "Could not initialize SRTP");
MOZ_ASSERT(PR_FALSE);
return NS_ERROR_FAILURE;
}
r = srtp_install_event_handler(&SrtpFlow::srtp_event_handler);
if (r != err_status_ok) {
MOZ_MTLOG(PR_LOG_ERROR, "Could not install SRTP event handler");
MOZ_MTLOG(ML_ERROR, "Could not install SRTP event handler");
MOZ_ASSERT(PR_FALSE);
return NS_ERROR_FAILURE;
}

View File

@ -87,7 +87,7 @@ class TestAgent {
void Start() {
nsresult ret;
MOZ_MTLOG(PR_LOG_DEBUG, "Starting");
MOZ_MTLOG(ML_DEBUG, "Starting");
mozilla::SyncRunnable::DispatchToThread(
test_utils->sts_target(),
@ -107,7 +107,7 @@ class TestAgent {
}
void Stop() {
MOZ_MTLOG(PR_LOG_DEBUG, "Stopping");
MOZ_MTLOG(ML_DEBUG, "Stopping");
if (audio_pipeline_)
audio_pipeline_->ShutdownMedia_m();