LCOV - code coverage report
Current view: top level - media/webrtc/signaling/src/mediapipeline - RtpLogger.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 25 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* This Source Code Form is subject to the terms of the Mozilla Public
       2             :  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
       3             :  * You can obtain one at http://mozilla.org/MPL/2.0/. */
       4             : 
       5             : // Original author: nohlmeier@mozilla.com
       6             : 
       7             : #include "RtpLogger.h"
       8             : #include "logging.h"
       9             : 
      10             : #include <sstream>
      11             : #ifdef _WIN32
      12             : #include <time.h>
      13             : #include <sys/timeb.h>
      14             : #else
      15             : #include <sys/time.h>
      16             : #endif
      17             : 
      18             : // Logging context
      19             : using namespace mozilla;
      20           0 : MOZ_MTLOG_MODULE("rtplogger")
      21             : 
      22             : namespace mozilla {
      23             : 
      24           0 : bool RtpLogger::IsPacketLoggingOn() {
      25           0 :   return MOZ_LOG_TEST(getLogModule(), ML_DEBUG);
      26             : }
      27             : 
      28           0 : void RtpLogger::LogPacket(const unsigned char *data, int len, bool input,
      29             :                           bool isRtp, int headerLength, std::string desc) {
      30           0 :   if (MOZ_LOG_TEST(getLogModule(), ML_DEBUG)) {
      31           0 :     std::stringstream ss;
      32             :     /* This creates text2pcap compatible format, e.g.:
      33             :      *   O 10:36:26.864934  000000 80 c8 00 06 6d ... RTCP_PACKET
      34             :      */
      35           0 :     ss << (input ? "I " : "O ");
      36           0 :     std::time_t t = std::time(nullptr);
      37           0 :     std::tm tm = *std::localtime(&t);
      38             :     char buf[9];
      39           0 :     if (0 < strftime(buf, sizeof(buf), "%H:%M:%S", &tm)) {
      40           0 :       ss << buf;
      41             :     }
      42           0 :     ss << std::setfill('0');
      43             : #ifdef _WIN32
      44             :     struct timeb tb;
      45             :     ftime(&tb);
      46             :     ss << "." << (tb.millitm) << " ";
      47             : #else
      48             :     struct timeval tv;
      49           0 :     gettimeofday(&tv, NULL);
      50           0 :     ss << "." << (tv.tv_usec) << " ";
      51             : #endif
      52           0 :     ss << " 000000";
      53           0 :     ss << std::hex << std::setfill('0');
      54           0 :     int offset_ = headerLength;
      55           0 :     if (isRtp && (offset_ + 5 < len)) {
      56             :       // Allow the first 5 bytes of the payload in clear
      57           0 :       offset_ += 5;
      58             :     }
      59           0 :     for (int i=0; i < len; ++i) {
      60           0 :       if (isRtp && i > offset_) {
      61           0 :         ss << " 00";
      62             :       }
      63             :       else {
      64           0 :         ss << " " << std::setw(2) << (int)data[i];
      65             :       }
      66             :     }
      67           0 :     MOZ_MTLOG(ML_DEBUG, "\n" << ss.str() <<
      68             :               (isRtp ? " RTP_PACKET " : " RTCP_PACKET ") <<
      69             :               desc);
      70             :   }
      71           0 : }
      72             : 
      73             : }  // end of namespace
      74             : 

Generated by: LCOV version 1.13