Bug 1402334 - Build mediapipeline using unified build; r=drno

This replaces MOZ_MTLOG with CSFLog, which is already set up to handle having
a shared LazyLogModule used from difference source files.

MozReview-Commit-ID: KNUKL92aWcw

--HG--
extra : rebase_source : 6d9eb3421c364f941c4cdf6d40217d2b853faacb
This commit is contained in:
Dan Minor 2017-10-02 14:29:20 -04:00
parent 5e6e96008c
commit 85e0a8d5b0
5 changed files with 158 additions and 149 deletions

View File

@ -9,6 +9,7 @@
#include "MediaStreamGraphImpl.h"
#include <inttypes.h>
#include <math.h>
#include "nspr.h"
@ -56,7 +57,7 @@
#include "nsThreadUtils.h"
#include "logging.h"
#include "CSFLog.h"
// Max size given stereo is 480*2*2 = 1920 (10ms of 16-bits stereo audio at
// 48KHz)
@ -70,8 +71,11 @@ using namespace mozilla::dom;
using namespace mozilla::gfx;
using namespace mozilla::layers;
// Logging context
MOZ_MTLOG_MODULE("mediapipeline")
static const char* mpLogTag = "MediaPipeline";
#ifdef LOGTAG
#undef LOGTAG
#endif
#define LOGTAG mpLogTag
namespace mozilla {
extern mozilla::LogModule* AudioLogModule();
@ -148,8 +152,8 @@ public:
// giving us a margin to not cause some machines to drop every other frame.
const int32_t queueThrottlingLimit = 1;
if (mLength > queueThrottlingLimit) {
MOZ_MTLOG(ML_DEBUG, "VideoFrameConverter " << this << " queue is full." <<
" Throttling by throwing away a frame.");
CSFLogDebug(LOGTAG, "VideoFrameConverter %p queue is full. Throttling by throwing away a frame.",
this);
#ifdef DEBUG
++mThrottleCount;
mThrottleRecord = std::max(mThrottleCount, mThrottleRecord);
@ -159,15 +163,14 @@ public:
#ifdef DEBUG
if (mThrottleCount > 0) {
auto level = ML_DEBUG;
if (mThrottleCount > 5) {
// Log at a higher level when we have large drops.
level = ML_INFO;
CSFLogInfo(LOGTAG, "VideoFrameConverter %p stopped throttling after throwing away %d frames. Longest throttle so far was %d frames.",
this, mThrottleCount, mThrottleRecord);
} else {
CSFLogDebug(LOGTAG, "VideoFrameConverter %p stopped throttling after throwing away %d frames. Longest throttle so far was %d frames.",
this, mThrottleCount, mThrottleRecord);
}
MOZ_MTLOG(level, "VideoFrameConverter " << this << " stopped" <<
" throttling after throwing away " << mThrottleCount <<
" frames. Longest throttle so far was " <<
mThrottleRecord << " frames.");
mThrottleCount = 0;
}
#endif
@ -250,7 +253,7 @@ protected:
{
// check for parameter sanity
if (!aBuffer || aVideoFrameLength == 0 || aWidth == 0 || aHeight == 0) {
MOZ_MTLOG(ML_ERROR, __FUNCTION__ << " Invalid Parameters ");
CSFLogError(LOGTAG, "%s Invalid Parameters", __FUNCTION__);
MOZ_ASSERT(false);
return;
}
@ -308,7 +311,7 @@ protected:
// Fill Cb/Cr planes
memset(pixelData.get() + yPlaneLen.value(), 0x80, cbcrPlaneLen);
MOZ_MTLOG(ML_DEBUG, "Sending a black video frame");
CSFLogDebug(LOGTAG, "Sending a black video frame");
VideoFrameConverted(Move(pixelData), length.value(),
size.width, size.height,
mozilla::kVideoI420, 0);
@ -344,7 +347,7 @@ protected:
webrtc::VideoFrame i420_frame(video_frame_buffer,
0, 0, // not setting timestamps
webrtc::kVideoRotation_0);
MOZ_MTLOG(ML_DEBUG, "Sending an I420 video frame");
CSFLogDebug(LOGTAG, "Sending an I420 video frame");
VideoFrameConverted(i420_frame);
return;
}
@ -352,15 +355,16 @@ protected:
RefPtr<SourceSurface> surf = aImage->GetAsSourceSurface();
if (!surf) {
MOZ_MTLOG(ML_ERROR, "Getting surface from " << Stringify(format) << " image failed");
CSFLogError(LOGTAG, "Getting surface from %s image failed",
Stringify(format).c_str());
return;
}
RefPtr<DataSourceSurface> data = surf->GetDataSurface();
if (!data) {
MOZ_MTLOG(ML_ERROR, "Getting data surface from " << Stringify(format)
<< " image with " << Stringify(surf->GetType()) << "("
<< Stringify(surf->GetFormat()) << ") surface failed");
CSFLogError(LOGTAG, "Getting data surface from %s image with %s (%s) surface failed",
Stringify(format).c_str(), Stringify(surf->GetType()).c_str(),
Stringify(surf->GetFormat()).c_str());
return;
}
@ -383,9 +387,9 @@ protected:
DataSourceSurface::ScopedMap map(data, DataSourceSurface::READ);
if (!map.IsMapped()) {
MOZ_MTLOG(ML_ERROR, "Reading DataSourceSurface from " << Stringify(format)
<< " image with " << Stringify(surf->GetType()) << "("
<< Stringify(surf->GetFormat()) << ") surface failed");
CSFLogError(LOGTAG, "Reading DataSourceSurface from %s image with %s (%s) surface failed",
Stringify(format).c_str(), Stringify(surf->GetType()).c_str(),
Stringify(surf->GetFormat()).c_str());
return;
}
@ -411,16 +415,18 @@ protected:
size.width, size.height);
break;
default:
MOZ_MTLOG(ML_ERROR, "Unsupported RGB video format" << Stringify(surf->GetFormat()));
CSFLogError(LOGTAG, "Unsupported RGB video format %s",
Stringify(surf->GetFormat()).c_str());
MOZ_ASSERT(PR_FALSE);
return;
}
if (rv != 0) {
MOZ_MTLOG(ML_ERROR, Stringify(surf->GetFormat()) << " to I420 conversion failed");
CSFLogError(LOGTAG, "%s to I420 conversion failed",
Stringify(surf->GetFormat()).c_str());
return;
}
MOZ_MTLOG(ML_DEBUG, "Sending an I420 video frame converted from " <<
Stringify(surf->GetFormat()));
CSFLogDebug(LOGTAG, "Sending an I420 video frame converted from %s",
Stringify(surf->GetFormat()).c_str());
VideoFrameConverted(Move(yuv_scoped), buffer_size.value(), size.width, size.height, mozilla::kVideoI420, 0);
}
@ -594,7 +600,7 @@ MediaPipeline::MediaPipeline(const std::string& pc,
MediaPipeline::~MediaPipeline() {
ASSERT_ON_THREAD(main_thread_);
MOZ_MTLOG(ML_INFO, "Destroying MediaPipeline: " << description_);
CSFLogInfo(LOGTAG, "Destroying MediaPipeline: %s", description_.c_str());
}
nsresult MediaPipeline::Init() {
@ -770,7 +776,7 @@ void MediaPipeline::StateChange(TransportFlow *flow, TransportLayer::State state
MOZ_ASSERT(info);
if (state == TransportLayer::TS_OPEN) {
MOZ_MTLOG(ML_INFO, "Flow is ready");
CSFLogInfo(LOGTAG, "Flow is ready");
TransportReady_s(*info);
} else if (state == TransportLayer::TS_CLOSED ||
state == TransportLayer::TS_ERROR) {
@ -802,14 +808,13 @@ nsresult MediaPipeline::TransportReady_s(TransportInfo &info) {
// TODO(ekr@rtfm.com): implement some kind of notification on
// failure. bug 852665.
if (info.state_ != MP_CONNECTING) {
MOZ_MTLOG(ML_ERROR, "Transport ready for flow in wrong state:" <<
description_ << ": " << ToString(info.type_));
CSFLogError(LOGTAG, "Transport ready for flow in wrong state:%s :%s",
description_.c_str(), ToString(info.type_));
return NS_ERROR_FAILURE;
}
MOZ_MTLOG(ML_INFO, "Transport ready for pipeline " <<
static_cast<void *>(this) << " flow " << description_ << ": " <<
ToString(info.type_));
CSFLogInfo(LOGTAG, "Transport ready for pipeline %p flow %s: %s", this,
description_.c_str(), ToString(info.type_));
// TODO(bcampen@mozilla.com): Should we disconnect from the flow on failure?
nsresult res;
@ -822,7 +827,7 @@ nsresult MediaPipeline::TransportReady_s(TransportInfo &info) {
uint16_t cipher_suite;
res = dtls->GetSrtpCipher(&cipher_suite);
if (NS_FAILED(res)) {
MOZ_MTLOG(ML_ERROR, "Failed to negotiate DTLS-SRTP. This is an error");
CSFLogError(LOGTAG, "Failed to negotiate DTLS-SRTP. This is an error");
info.state_ = MP_CLOSED;
UpdateRtcpMuxState(info);
return res;
@ -833,7 +838,7 @@ nsresult MediaPipeline::TransportReady_s(TransportInfo &info) {
res = dtls->ExportKeyingMaterial(kDTLSExporterLabel, false, "",
srtp_block, sizeof(srtp_block));
if (NS_FAILED(res)) {
MOZ_MTLOG(ML_ERROR, "Failed to compute DTLS-SRTP keys. This is an error");
CSFLogError(LOGTAG, "Failed to compute DTLS-SRTP keys. This is an error");
info.state_ = MP_CLOSED;
UpdateRtcpMuxState(info);
MOZ_CRASH(); // TODO: Remove once we have enough field experience to
@ -875,16 +880,15 @@ nsresult MediaPipeline::TransportReady_s(TransportInfo &info) {
info.recv_srtp_ = SrtpFlow::Create(cipher_suite, true, read_key,
SRTP_TOTAL_KEY_LENGTH);
if (!info.send_srtp_ || !info.recv_srtp_) {
MOZ_MTLOG(ML_ERROR, "Couldn't create SRTP flow for "
<< ToString(info.type_));
CSFLogError(LOGTAG, "Couldn't create SRTP flow for %s",
ToString(info.type_));
info.state_ = MP_CLOSED;
UpdateRtcpMuxState(info);
return NS_ERROR_FAILURE;
}
MOZ_MTLOG(ML_INFO, "Listening for " << ToString(info.type_)
<< " packets received on " <<
static_cast<void *>(dtls->downward()));
CSFLogInfo(LOGTAG, "Listening for %s packets received on %p",
ToString(info.type_), dtls->downward());
switch (info.type_) {
case RTP:
@ -917,7 +921,7 @@ nsresult MediaPipeline::TransportFailed_s(TransportInfo &info) {
info.state_ = MP_CLOSED;
UpdateRtcpMuxState(info);
MOZ_MTLOG(ML_INFO, "Transport closed for flow " << ToString(info.type_));
CSFLogInfo(LOGTAG, "Transport closed for flow %s", ToString(info.type_));
NS_WARNING(
"MediaPipeline Transport failed. This is not properly cleaned up yet");
@ -959,7 +963,7 @@ nsresult MediaPipeline::SendPacket(TransportFlow *flow, const void *data,
if (res == TE_WOULDBLOCK)
return NS_OK;
MOZ_MTLOG(ML_ERROR, "Failed write on stream " << description_);
CSFLogError(LOGTAG, "Failed write on stream %s", description_.c_str());
return NS_BASE_STREAM_CLOSED;
}
@ -971,21 +975,18 @@ void MediaPipeline::increment_rtp_packets_sent(int32_t bytes) {
rtp_bytes_sent_ += bytes;
if (!(rtp_packets_sent_ % 100)) {
MOZ_MTLOG(ML_INFO, "RTP sent packet count for " << description_
<< " Pipeline " << static_cast<void *>(this)
<< " Flow : " << static_cast<void *>(rtp_.transport_)
<< ": " << rtp_packets_sent_
<< " (" << rtp_bytes_sent_ << " bytes)");
CSFLogInfo(LOGTAG, "RTP sent packet count for %s Pipeline %p Flow: %p: %u (%" PRId64 " bytes)",
description_.c_str(), this, static_cast<void *>(rtp_.transport_),
rtp_packets_sent_, rtp_bytes_sent_);
}
}
void MediaPipeline::increment_rtcp_packets_sent() {
++rtcp_packets_sent_;
if (!(rtcp_packets_sent_ % 100)) {
MOZ_MTLOG(ML_INFO, "RTCP sent packet count for " << description_
<< " Pipeline " << static_cast<void *>(this)
<< " Flow : " << static_cast<void *>(rtcp_.transport_)
<< ": " << rtcp_packets_sent_);
CSFLogInfo(LOGTAG, "RTCP sent packet count for %s Pipeline %p Flow: %p: %u",
description_.c_str(), this, static_cast<void *>(rtp_.transport_),
rtcp_packets_sent_);
}
}
@ -993,21 +994,18 @@ void MediaPipeline::increment_rtp_packets_received(int32_t bytes) {
++rtp_packets_received_;
rtp_bytes_received_ += bytes;
if (!(rtp_packets_received_ % 100)) {
MOZ_MTLOG(ML_INFO, "RTP received packet count for " << description_
<< " Pipeline " << static_cast<void *>(this)
<< " Flow : " << static_cast<void *>(rtp_.transport_)
<< ": " << rtp_packets_received_
<< " (" << rtp_bytes_received_ << " bytes)");
CSFLogInfo(LOGTAG, "RTP received packet count for %s Pipeline %p Flow: %p: %u (%" PRId64 " bytes)",
description_.c_str(), this, static_cast<void *>(rtp_.transport_),
rtp_packets_received_, rtp_bytes_received_);
}
}
void MediaPipeline::increment_rtcp_packets_received() {
++rtcp_packets_received_;
if (!(rtcp_packets_received_ % 100)) {
MOZ_MTLOG(ML_INFO, "RTCP received packet count for " << description_
<< " Pipeline " << static_cast<void *>(this)
<< " Flow : " << static_cast<void *>(rtcp_.transport_)
<< ": " << rtcp_packets_received_);
CSFLogInfo(LOGTAG, "RTCP received packet count for %s Pipeline %p Flow: %p: %u",
description_.c_str(), this, static_cast<void *>(rtp_.transport_),
rtcp_packets_received_);
}
}
@ -1015,22 +1013,22 @@ void MediaPipeline::RtpPacketReceived(TransportLayer *layer,
const unsigned char *data,
size_t len) {
if (!transport_->pipeline()) {
MOZ_MTLOG(ML_ERROR, "Discarding incoming packet; transport disconnected");
CSFLogError(LOGTAG, "Discarding incoming packet; transport disconnected");
return;
}
if (!conduit_) {
MOZ_MTLOG(ML_DEBUG, "Discarding incoming packet; media disconnected");
CSFLogDebug(LOGTAG, "Discarding incoming packet; media disconnected");
return;
}
if (rtp_.state_ != MP_OPEN) {
MOZ_MTLOG(ML_ERROR, "Discarding incoming packet; pipeline not open");
CSFLogError(LOGTAG, "Discarding incoming packet; pipeline not open");
return;
}
if (rtp_.transport_->state() != TransportLayer::TS_OPEN) {
MOZ_MTLOG(ML_ERROR, "Discarding incoming packet; transport not open");
CSFLogError(LOGTAG, "Discarding incoming packet; transport not open");
return;
}
@ -1115,11 +1113,11 @@ void MediaPipeline::RtpPacketReceived(TransportLayer *layer,
inner_data[2],
inner_data[3]);
MOZ_MTLOG(ML_NOTICE, "Error unprotecting RTP in " << description_
<< "len= " << len << "[" << tmp << "...]");
CSFLogError(LOGTAG, "Error unprotecting RTP in %s len= %zu [%s]",
description_.c_str(), len, tmp);
return;
}
MOZ_MTLOG(ML_DEBUG, description_ << " received RTP packet.");
CSFLogDebug(LOGTAG, "%s received RTP packet.", description_.c_str());
increment_rtp_packets_received(out_len);
RtpLogger::LogPacket(inner_data.get(), out_len, true, true, header.headerLength,
@ -1135,22 +1133,22 @@ void MediaPipeline::RtcpPacketReceived(TransportLayer *layer,
const unsigned char *data,
size_t len) {
if (!transport_->pipeline()) {
MOZ_MTLOG(ML_DEBUG, "Discarding incoming packet; transport disconnected");
CSFLogDebug(LOGTAG, "Discarding incoming packet; transport disconnected");
return;
}
if (!conduit_) {
MOZ_MTLOG(ML_DEBUG, "Discarding incoming packet; media disconnected");
CSFLogDebug(LOGTAG, "Discarding incoming packet; media disconnected");
return;
}
if (rtcp_.state_ != MP_OPEN) {
MOZ_MTLOG(ML_DEBUG, "Discarding incoming packet; pipeline not open");
CSFLogDebug(LOGTAG, "Discarding incoming packet; pipeline not open");
return;
}
if (rtcp_.transport_->state() != TransportLayer::TS_OPEN) {
MOZ_MTLOG(ML_ERROR, "Discarding incoming packet; transport not open");
CSFLogError(LOGTAG, "Discarding incoming packet; transport not open");
return;
}
@ -1168,7 +1166,7 @@ void MediaPipeline::RtcpPacketReceived(TransportLayer *layer,
// TODO bug 1279153: remove SR check for reduced size RTCP
if (filter_ && direction_ == RECEIVE) {
if (!filter_->FilterSenderReport(data, len)) {
MOZ_MTLOG(ML_NOTICE, "Dropping incoming RTCP packet; filtered out");
CSFLogWarn(LOGTAG, "Dropping incoming RTCP packet; filtered out");
return;
}
}
@ -1189,7 +1187,7 @@ void MediaPipeline::RtcpPacketReceived(TransportLayer *layer,
if (!NS_SUCCEEDED(res))
return;
MOZ_MTLOG(ML_DEBUG, description_ << " received RTCP packet.");
CSFLogDebug(LOGTAG, "%s received RTCP packet.", description_.c_str());
increment_rtcp_packets_received();
RtpLogger::LogPacket(inner_data.get(), out_len, true, false, 0, description_);
@ -1239,7 +1237,7 @@ void MediaPipeline::PacketReceived(TransportLayer *layer,
const unsigned char *data,
size_t len) {
if (!transport_->pipeline()) {
MOZ_MTLOG(ML_DEBUG, "Discarding incoming packet; transport disconnected");
CSFLogDebug(LOGTAG, "Discarding incoming packet; transport disconnected");
return;
}
@ -1486,9 +1484,8 @@ void MediaPipelineTransmit::AttachToTrack(const std::string& track_id) {
description_ += "]";
// TODO(ekr@rtfm.com): Check for errors
MOZ_MTLOG(ML_DEBUG, "Attaching pipeline to track "
<< static_cast<void *>(domtrack_) << " conduit type=" <<
(conduit_->type() == MediaSessionConduit::AUDIO ?"audio":"video"));
CSFLogDebug(LOGTAG, "Attaching pipeline to track %p conduit type=%s", this,
(conduit_->type() == MediaSessionConduit::AUDIO ?"audio":"video"));
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
// With full duplex we don't risk having audio come in late to the MSG
@ -1584,10 +1581,9 @@ nsresult MediaPipelineTransmit::ReplaceTrack(MediaStreamTrack& domtrack) {
nsString nsTrackId;
domtrack.GetId(nsTrackId);
std::string track_id(NS_ConvertUTF16toUTF8(nsTrackId).get());
MOZ_MTLOG(ML_DEBUG, "Reattaching pipeline " << description_ << " to track "
<< static_cast<void *>(&domtrack)
<< " track " << track_id << " conduit type=" <<
(conduit_->type() == MediaSessionConduit::AUDIO ?"audio":"video"));
CSFLogDebug(LOGTAG, "Reattaching pipeline %s to track %p track %s conduit type: %s",
description_.c_str(), &domtrack, track_id.c_str(),
(conduit_->type() == MediaSessionConduit::AUDIO ?"audio":"video"));
DetachMedia();
domtrack_ = &domtrack; // Detach clears it
@ -1620,13 +1616,13 @@ nsresult MediaPipeline::ConnectTransport_s(TransportInfo &info) {
if (info.transport_->state() == TransportLayer::TS_OPEN) {
nsresult res = TransportReady_s(info);
if (NS_FAILED(res)) {
MOZ_MTLOG(ML_ERROR, "Error calling TransportReady(); res="
<< static_cast<uint32_t>(res) << " in " << __FUNCTION__);
CSFLogError(LOGTAG, "Error calling TransportReady(); res=%u in %s",
static_cast<uint32_t>(res), __FUNCTION__);
return res;
}
} else if (info.transport_->state() == TransportLayer::TS_ERROR) {
MOZ_MTLOG(ML_ERROR, ToString(info.type_)
<< "transport is already in error state");
CSFLogError(LOGTAG, "%s transport is already in error state",
ToString(info.type_));
TransportFailed_s(info);
return NS_ERROR_FAILURE;
}
@ -1677,7 +1673,7 @@ nsresult MediaPipeline::PipelineTransport::SendRtpRtcpPacket_s(
TransportInfo& transport = is_rtp ? pipeline_->rtp_ : pipeline_->rtcp_;
if (!transport.send_srtp_) {
MOZ_MTLOG(ML_DEBUG, "Couldn't write RTP/RTCP packet; SRTP not set up yet");
CSFLogDebug(LOGTAG, "Couldn't write RTP/RTCP packet; SRTP not set up yet");
return NS_OK;
}
@ -1724,8 +1720,8 @@ nsresult MediaPipeline::PipelineTransport::SendRtpRtcpPacket_s(
// paranoia; don't have uninitialized bytes included in data->len()
data->SetLength(out_len);
MOZ_MTLOG(ML_DEBUG, pipeline_->description_ << " sending " <<
(is_rtp ? "RTP" : "RTCP") << " packet");
CSFLogDebug(LOGTAG, "%s sending %s packet", pipeline_->description_.c_str(),
(is_rtp ? "RTP" : "RTCP"));
if (is_rtp) {
pipeline_->packet_dumper_->Dump(
pipeline_->level(), dom::mozPacketDumpType::Srtp, true, data->data(), out_len);
@ -1774,9 +1770,8 @@ void MediaPipelineTransmit::PipelineListener::
NotifyRealtimeTrackData(MediaStreamGraph* graph,
StreamTime offset,
const MediaSegment& media) {
MOZ_MTLOG(ML_DEBUG, "MediaPipeline::NotifyRealtimeTrackData() listener=" <<
this << ", offset=" << offset <<
", duration=" << media.GetDuration());
CSFLogDebug(LOGTAG, "MediaPipeline::NotifyRealtimeTrackData() listener=%p, offset=%" PRId64 ", duration=%" PRId64,
this, offset, media.GetDuration());
if (media.GetType() == MediaSegment::VIDEO) {
// We have to call the upstream NotifyRealtimeTrackData and
@ -1792,7 +1787,7 @@ void MediaPipelineTransmit::PipelineListener::
NotifyQueuedChanges(MediaStreamGraph* graph,
StreamTime offset,
const MediaSegment& queued_media) {
MOZ_MTLOG(ML_DEBUG, "MediaPipeline::NotifyQueuedChanges()");
CSFLogDebug(LOGTAG, "MediaPipeline::NotifyQueuedChanges()");
if (queued_media.GetType() == MediaSegment::VIDEO) {
// We always get video from SetCurrentFrames().
@ -1816,15 +1811,15 @@ NotifyQueuedChanges(MediaStreamGraph* graph,
void MediaPipelineTransmit::PipelineListener::
NotifyDirectListenerInstalled(InstallationResult aResult) {
MOZ_MTLOG(ML_INFO, "MediaPipeline::NotifyDirectListenerInstalled() listener= " <<
this << ", result=" << static_cast<int32_t>(aResult));
CSFLogInfo(LOGTAG, "MediaPipeline::NotifyDirectListenerInstalled() listener=%p, result=%d",
this, static_cast<int32_t>(aResult));
direct_connect_ = InstallationResult::SUCCESS == aResult;
}
void MediaPipelineTransmit::PipelineListener::
NotifyDirectListenerUninstalled() {
MOZ_MTLOG(ML_INFO, "MediaPipeline::NotifyDirectListenerUninstalled() listener=" << this);
CSFLogInfo(LOGTAG, "MediaPipeline::NotifyDirectListenerUninstalled() listener=%p", this);
direct_connect_ = false;
}
@ -1832,7 +1827,7 @@ NotifyDirectListenerUninstalled() {
void MediaPipelineTransmit::PipelineListener::
NewData(const MediaSegment& media, TrackRate aRate /* = 0 */) {
if (!active_) {
MOZ_MTLOG(ML_DEBUG, "Discarding packets because transport not ready");
CSFLogDebug(LOGTAG, "Discarding packets because transport not ready");
return;
}
@ -2032,7 +2027,7 @@ public:
{
MOZ_ASSERT(source_);
if (!source_) {
MOZ_MTLOG(ML_ERROR, "NotifyPull() called from a non-SourceMediaStream");
CSFLogError(LOGTAG, "NotifyPull() called from a non-SourceMediaStream");
return;
}
@ -2053,10 +2048,9 @@ public:
if (err != kMediaConduitNoError) {
// Insert silence on conduit/GIPS failure (extremely unlikely)
MOZ_MTLOG(ML_ERROR, "Audio conduit failed (" << err
<< ") to return data @ " << played_ticks_
<< " (desired " << desired_time << " -> "
<< source_->StreamTimeToSeconds(desired_time) << ")");
CSFLogError(LOGTAG, "Audio conduit failed (%d) to return data @ %" PRId64 " (desired %" PRId64 " -> %f)",
err, played_ticks_, desired_time,
source_->StreamTimeToSeconds(desired_time));
// if this is not enough we'll loop and provide more
samples_length = WEBRTC_DEFAULT_SAMPLE_RATE/100;
PodArrayZero(scratch_buffer);
@ -2064,8 +2058,8 @@ public:
MOZ_ASSERT(samples_length * sizeof(uint16_t) < AUDIO_SAMPLE_BUFFER_MAX_BYTES);
MOZ_MTLOG(ML_DEBUG, "Audio conduit returned buffer of length "
<< samples_length);
CSFLogDebug(LOGTAG, "Audio conduit returned buffer of length %u",
samples_length);
RefPtr<SharedBuffer> samples = SharedBuffer::Create(samples_length * sizeof(uint16_t));
int16_t *samples_data = static_cast<int16_t *>(samples->Data());
@ -2108,7 +2102,7 @@ public:
}
}
} else {
MOZ_MTLOG(ML_ERROR, "AppendToTrack failed");
CSFLogError(LOGTAG, "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;
@ -2154,7 +2148,7 @@ void MediaPipelineReceiveAudio::DetachMedia()
nsresult MediaPipelineReceiveAudio::Init()
{
ASSERT_ON_THREAD(main_thread_);
MOZ_MTLOG(ML_DEBUG, __FUNCTION__);
CSFLogDebug(LOGTAG, "%s", __FUNCTION__);
description_ = pc_ + "| Receive audio[";
description_ += track_id_;
@ -2202,7 +2196,7 @@ public:
if (source_->AppendToTrack(track_id_, &segment)) {
played_ticks_ = desired_time;
} else {
MOZ_MTLOG(ML_ERROR, "AppendToTrack failed");
CSFLogError(LOGTAG, "AppendToTrack failed");
return;
}
}
@ -2336,7 +2330,7 @@ void MediaPipelineReceiveVideo::DetachMedia()
nsresult MediaPipelineReceiveVideo::Init() {
ASSERT_ON_THREAD(main_thread_);
MOZ_MTLOG(ML_DEBUG, __FUNCTION__);
CSFLogDebug(LOGTAG, "%s", __FUNCTION__);
description_ = pc_ + "| Receive video[";
description_ += track_id_;

View File

@ -10,10 +10,14 @@
#include "MediaPipelineFilter.h"
#include "webrtc/common_types.h"
#include "logging.h"
// Logging context
MOZ_MTLOG_MODULE("mediapipeline")
#include "CSFLog.h"
static const char* mpfLogTag = "MediaPipelineFilter";
#ifdef LOGTAG
#undef LOGTAG
#endif
#define LOGTAG mpfLogTag
namespace mozilla {
@ -41,8 +45,10 @@ bool MediaPipelineFilter::Filter(const webrtc::RTPHeader& header,
return true;
}
if (!header.extension.rtpStreamId.empty()) {
MOZ_MTLOG(ML_DEBUG, "MediaPipelineFilter ignoring seq# " << header.sequenceNumber <<
" ssrc: " << header.ssrc << " RID: " << header.extension.rtpStreamId.data());
CSFLogDebug(LOGTAG,
"MediaPipelineFilter ignoring seq# %u ssrc: %u RID: %s",
header.sequenceNumber, header.ssrc,
header.extension.rtpStreamId.data());
}
if (remote_ssrc_set_.count(header.ssrc)) {

View File

@ -5,7 +5,8 @@
// Original author: nohlmeier@mozilla.com
#include "RtpLogger.h"
#include "logging.h"
#include "CSFLog.h"
#include <ctime>
#include <iomanip>
@ -19,17 +20,22 @@
// Logging context
using namespace mozilla;
MOZ_MTLOG_MODULE("rtplogger")
static const char* rlLogTag = "RtpLogger";
#ifdef LOGTAG
#undef LOGTAG
#endif
#define LOGTAG rlLogTag
namespace mozilla {
bool RtpLogger::IsPacketLoggingOn() {
return MOZ_LOG_TEST(getLogModule(), ML_DEBUG);
return CSFLogTestLevel(CSF_LOG_DEBUG);
}
void RtpLogger::LogPacket(const unsigned char *data, int len, bool input,
bool isRtp, int headerLength, std::string desc) {
if (MOZ_LOG_TEST(getLogModule(), ML_DEBUG)) {
if (CSFLogTestLevel(CSF_LOG_DEBUG)) {
std::stringstream ss;
/* This creates text2pcap compatible format, e.g.:
* O 10:36:26.864934 000000 80 c8 00 06 6d ... RTCP_PACKET
@ -66,9 +72,8 @@ void RtpLogger::LogPacket(const unsigned char *data, int len, bool input,
ss << " " << std::setw(2) << (int)data[i];
}
}
MOZ_MTLOG(ML_DEBUG, "\n" << ss.str() <<
(isRtp ? " RTP_PACKET " : " RTCP_PACKET ") <<
desc);
CSFLogDebug(LOGTAG, "%s%s%s", ss.str().c_str(),
(isRtp ? " RTP_PACKET " : " RTCP_PACKET "), desc.c_str());
}
}

View File

@ -13,9 +13,13 @@
#include "mozilla/RefPtr.h"
// Logging context
static const char* sfLogTag = "SrtpFlow";
#ifdef LOGTAG
#undef LOGTAG
#endif
#define LOGTAG sfLogTag
using namespace mozilla;
MOZ_MTLOG_MODULE("mediapipeline")
namespace mozilla {
@ -38,12 +42,12 @@ RefPtr<SrtpFlow> SrtpFlow::Create(int cipher_suite,
RefPtr<SrtpFlow> flow = new SrtpFlow();
if (!key) {
MOZ_MTLOG(ML_ERROR, "Null SRTP key specified");
CSFLogError(LOGTAG, "Null SRTP key specified");
return nullptr;
}
if (key_len != SRTP_TOTAL_KEY_LENGTH) {
MOZ_MTLOG(ML_ERROR, "Invalid SRTP key length");
CSFLogError(LOGTAG, "Invalid SRTP key length");
return nullptr;
}
@ -54,19 +58,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(ML_DEBUG,
"Setting SRTP cipher suite SRTP_AES128_CM_HMAC_SHA1_80");
CSFLogDebug(LOGTAG,
"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(ML_DEBUG,
"Setting SRTP cipher suite SRTP_AES128_CM_HMAC_SHA1_32");
CSFLogDebug(LOGTAG,
"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(ML_ERROR, "Request to set unknown SRTP cipher suite");
CSFLogError(LOGTAG, "Request to set unknown SRTP cipher suite");
return nullptr;
}
// This key is copied into the srtp_t object, so we don't
@ -83,7 +87,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(ML_ERROR, "Error creating srtp session");
CSFLogError(LOGTAG, "Error creating srtp session");
return nullptr;
}
@ -95,30 +99,30 @@ nsresult SrtpFlow::CheckInputs(bool protect, void *in, int in_len,
int max_len, int *out_len) {
MOZ_ASSERT(in);
if (!in) {
MOZ_MTLOG(ML_ERROR, "NULL input value");
CSFLogError(LOGTAG, "NULL input value");
return NS_ERROR_NULL_POINTER;
}
if (in_len < 0) {
MOZ_MTLOG(ML_ERROR, "Input length is negative");
CSFLogError(LOGTAG, "Input length is negative");
return NS_ERROR_ILLEGAL_VALUE;
}
if (max_len < 0) {
MOZ_MTLOG(ML_ERROR, "Max output length is negative");
CSFLogError(LOGTAG, "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(ML_ERROR, "Output too short");
CSFLogError(LOGTAG, "Output too short");
return NS_ERROR_ILLEGAL_VALUE;
}
}
else {
if (in_len > max_len) {
MOZ_MTLOG(ML_ERROR, "Output too short");
CSFLogError(LOGTAG, "Output too short");
return NS_ERROR_ILLEGAL_VALUE;
}
}
@ -136,7 +140,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(ML_ERROR, "Error protecting SRTP packet");
CSFLogError(LOGTAG, "Error protecting SRTP packet");
return NS_ERROR_FAILURE;
}
@ -144,8 +148,8 @@ nsresult SrtpFlow::ProtectRtp(void *in, int in_len,
*out_len = len;
MOZ_MTLOG(ML_DEBUG, "Successfully protected an SRTP packet of len "
<< *out_len);
CSFLogDebug(LOGTAG, "Successfully protected an SRTP packet of len %d",
*out_len);
return NS_OK;
}
@ -160,15 +164,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(ML_ERROR, "Error unprotecting SRTP packet error=" << (int)r);
CSFLogError(LOGTAG, "Error unprotecting SRTP packet error=%d", (int)r);
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(len <= max_len);
*out_len = len;
MOZ_MTLOG(ML_DEBUG, "Successfully unprotected an SRTP packet of len "
<< *out_len);
CSFLogDebug(LOGTAG, "Successfully unprotected an SRTP packet of len %d",
*out_len);
return NS_OK;
}
@ -183,15 +187,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(ML_ERROR, "Error protecting SRTCP packet");
CSFLogError(LOGTAG, "Error protecting SRTCP packet");
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(len <= max_len);
*out_len = len;
MOZ_MTLOG(ML_DEBUG, "Successfully protected an SRTCP packet of len "
<< *out_len);
CSFLogDebug(LOGTAG, "Successfully protected an SRTCP packet of len %d",
*out_len);
return NS_OK;
}
@ -206,15 +210,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(ML_ERROR, "Error unprotecting SRTCP packet error=" << (int)r);
CSFLogError(LOGTAG, "Error unprotecting SRTCP packet error=%d", (int)r);
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(len <= max_len);
*out_len = len;
MOZ_MTLOG(ML_DEBUG, "Successfully unprotected an SRTCP packet of len "
<< *out_len);
CSFLogDebug(LOGTAG, "Successfully unprotected an SRTCP packet of len %d",
*out_len);
return NS_OK;
}
@ -229,14 +233,14 @@ nsresult SrtpFlow::Init() {
if (!initialized) {
err_status_t r = srtp_init();
if (r != err_status_ok) {
MOZ_MTLOG(ML_ERROR, "Could not initialize SRTP");
CSFLogError(LOGTAG, "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(ML_ERROR, "Could not install SRTP event handler");
CSFLogError(LOGTAG, "Could not install SRTP event handler");
MOZ_ASSERT(PR_FALSE);
return NS_ERROR_FAILURE;
}

View File

@ -10,14 +10,14 @@ LOCAL_INCLUDES += [
'/media/libyuv/libyuv/include',
'/media/mtransport',
'/media/webrtc',
'/media/webrtc/signaling/src/common/browser_logging',
'/media/webrtc/signaling/src/media-conduit',
'/media/webrtc/trunk',
'/netwerk/srtp/src/crypto/include',
'/netwerk/srtp/src/include',
]
# Duplicate definition of getLogModule
SOURCES += [
UNIFIED_SOURCES += [
'MediaPipeline.cpp',
'MediaPipelineFilter.cpp',
'RtpLogger.cpp',