1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/mtransport/transportlayerlog.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,55 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +// Original author: ekr@rtfm.com 1.11 + 1.12 +#include "logging.h" 1.13 +#include "transportflow.h" 1.14 +#include "transportlayerlog.h" 1.15 + 1.16 +namespace mozilla { 1.17 + 1.18 +MOZ_MTLOG_MODULE("mtransport") 1.19 + 1.20 +void TransportLayerLogging::WasInserted() { 1.21 + if (downward_) { 1.22 + downward_->SignalStateChange.connect( 1.23 + this, &TransportLayerLogging::StateChange); 1.24 + downward_->SignalPacketReceived.connect( 1.25 + this, &TransportLayerLogging::PacketReceived); 1.26 + TL_SET_STATE(downward_->state()); 1.27 + } 1.28 +} 1.29 + 1.30 +TransportResult 1.31 +TransportLayerLogging::SendPacket(const unsigned char *data, size_t len) { 1.32 + MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "SendPacket(" << len << ")"); 1.33 + 1.34 + if (downward_) { 1.35 + return downward_->SendPacket(data, len); 1.36 + } 1.37 + else { 1.38 + return static_cast<TransportResult>(len); 1.39 + } 1.40 +} 1.41 + 1.42 +void TransportLayerLogging::StateChange(TransportLayer *layer, State state) { 1.43 + MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Received StateChange to " << state); 1.44 + 1.45 + TL_SET_STATE(state); 1.46 +} 1.47 + 1.48 +void TransportLayerLogging::PacketReceived(TransportLayer* layer, 1.49 + const unsigned char *data, 1.50 + size_t len) { 1.51 + MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "PacketReceived(" << len << ")"); 1.52 + 1.53 + SignalPacketReceived(this, data, len); 1.54 +} 1.55 + 1.56 + 1.57 + 1.58 +} // close namespace