Send/Receive FIR Packet

439 views
Skip to first unread message

Luke Mauldin

unread,
Oct 29, 2013, 2:22:17 PM10/29/13
to discuss...@googlegroups.com
All,

I am attempting to send an FIR packet to a Chrome browser using the native C++ WebRTC libraries and I am using the code as rtcp_sender.cc.  I know that the packet is going from the C++ application to the browser because I have stepped through it in debug mode, however it seems like the browser is ignoring the packet.  I am running chrome with the following settings: ./chrome --enable-logging --vmodule=*libjingle/source/talk/*=3  
However, I am not able to determine why Chrome is ignoring the FIR packet.  Can anyone please help me out?

Luke

Adam Fineberg

unread,
Oct 29, 2013, 2:33:33 PM10/29/13
to discuss...@googlegroups.com
You might want to make sure the correct SSRC is being sent.
Additionally, check in the log (you'll need a debug build with webrtc
trace enabled) for the message:

SIG [RTCP] Incoming PLI from SSRC:0x%x

This message should be printed for received FIRs as well as PLIs if the
SSRC in rtcpPacket.FIRItem.SSRC matches a known stream SSRC.

Regards,
Adam
> --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "discuss-webrtc" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to discuss-webrt...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Luke Mauldin

unread,
Oct 29, 2013, 5:09:48 PM10/29/13
to discuss...@googlegroups.com
Adam, I have a built my own version of debug chromium. How do I turn on webrtc trace?
Also, it looks like there are two SSRC fields in the data packet. Which one should be set?

Luke
--- You received this message because you are subscribed to a topic in the Google Groups "discuss-webrtc" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/discuss-webrtc/4YcHasYC3xg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to discuss-webrt...@googlegroups.com.

Adam Fineberg

unread,
Oct 29, 2013, 5:32:28 PM10/29/13
to discuss...@googlegroups.com
You need to set enable_trace = 1 in the gyp file.  The SSRC should be the FIRItem.SSRC.
-- 
Regards,
Adam

Luke Mauldin

unread,
Oct 29, 2013, 6:46:31 PM10/29/13
to discuss...@googlegroups.com
Adam,

Which gyp file should I update?  I did the following search in the chromium source tree and didn't find any matching files:
grep -r --include="*.gyp" -i "enable_trace"


On Tuesday, October 29, 2013 4:32:28 PM UTC-5, Adam Fineberg wrote:
You need to set enable_trace = 1 in the gyp file.  The SSRC should be the FIRItem.SSRC.

On 10/29/13 2:09 PM, Luke Mauldin wrote:
Adam, I have a built my own version of debug chromium. How do I turn on webrtc trace?
Also, it looks like there are two SSRC fields in the data packet. Which one should be set?

Luke

On Tuesday, October 29, 2013, Adam Fineberg wrote:
You might want to make sure the correct SSRC is being sent. Additionally, check in the log (you'll need a debug build with webrtc trace enabled) for the message:

SIG [RTCP] Incoming PLI from SSRC:0x%x

This message should be printed for received FIRs as well as PLIs if the SSRC in rtcpPacket.FIRItem.SSRC matches a known stream SSRC.

Regards,
Adam

On 10/29/13 11:22 AM, Luke Mauldin wrote:
All,

I am attempting to send an FIR packet to a Chrome browser using the native C++ WebRTC libraries and I am using the code as rtcp_sender.cc.  I know that the packet is going from the C++ application to the browser because I have stepped through it in debug mode, however it seems like the browser is ignoring the packet.  I am running chrome with the following settings: ./chrome --enable-logging --vmodule=*libjingle/source/talk/*=3
However, I am not able to determine why Chrome is ignoring the FIR packet.  Can anyone please help me out?

Luke
--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrtc+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--

--- You received this message because you are subscribed to a topic in the Google Groups "discuss-webrtc" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/discuss-webrtc/4YcHasYC3xg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to discuss-webrtc+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
--
 
---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

-- 
Regards,
Adam

Adam Fineberg

unread,
Oct 29, 2013, 6:49:44 PM10/29/13
to discuss...@googlegroups.com
third_party/webrtc/build/common.gypi, look for enable_tracing

Luke Mauldin

unread,
Oct 30, 2013, 9:51:49 AM10/30/13
to discuss...@googlegroups.com
I modified the common.gypi file mentioned above and did a full rebuild of Chromium.  Now when I launch Chromium I get some additional logging, but I do not see any messages like you described above saying "Incoming PLI" or "Incoming FIR" packet.  I am attempting to send both FLI and FIR packets using the methods below.  It is like Chromium is either not receiving the packets or not accepting them?  Is there any additional logging I can enable or where should I set breakpoints for debugging?

std::shared_ptr<talk_base::Buffer> BuildPLIPacket(uint32 localSsrc, uint32 remoteSsrc)
{
  const int bufferSize = 20;
  const int bufferCapacity = bufferSize + 14;
  uint8_t rtcpbuffer[bufferSize];
  std::fill(std::begin(rtcpbuffer), std::end(rtcpbuffer), 0);
  int pos = 0;

   
    // add picture loss indicator
    uint8_t FMT = 1;
    rtcpbuffer[pos++]=(uint8_t)0x80 + FMT;
    rtcpbuffer[pos++]=(uint8_t)206;

    //Used fixed length of 2
    rtcpbuffer[pos++]=(uint8_t)0;
    rtcpbuffer[pos++]=(uint8_t)(2);

    // Add our own SSRC
    AssignUWord32ToBuffer(rtcpbuffer+pos, localSsrc);
    pos += 4;

    // Add the remote SSRC
    AssignUWord32ToBuffer(rtcpbuffer+pos, remoteSsrc);
    pos += 4;
  
  //Build and send buffer packet
  std::cout << "Built PLI packet for localSsrc: " << localSsrc
            << " -- remoteSsrc: " << remoteSsrc << " -- pos: " << pos
            << std::endl;
  return std::make_shared<talk_base::Buffer>(rtcpbuffer, bufferSize,
                                             bufferCapacity);
}

static int firSequenceNumber = 0;
std::shared_ptr<talk_base::Buffer> BuildFIRPacket(uint32 localSsrc,
                                                  uint32 remoteSsrc) {
  //Build FIR packet
  const int bufferSize = 20;
  const int bufferCapacity = bufferSize + 14;
  uint8_t rtcpbuffer[bufferSize];
  std::fill(std::begin(rtcpbuffer), std::end(rtcpbuffer), 0);
  int pos = 0;

  // add full intra request indicator
  uint8_t FMT = 4;
  rtcpbuffer[pos++] = (uint8_t) 0x80 + FMT;
  rtcpbuffer[pos++] = (uint8_t) 206;

  //Length of 4
  rtcpbuffer[pos++] = (uint8_t) 0;
  rtcpbuffer[pos++] = (uint8_t)(4);

  // Add our own SSRC
  AssignUWord32ToBuffer(rtcpbuffer + pos, localSsrc);
  pos += 4;

  // RFC 5104     4.3.1.2.  Semantics
  // SSRC of media source
  rtcpbuffer[pos++] = (uint8_t) 0;
  rtcpbuffer[pos++] = (uint8_t) 0;
  rtcpbuffer[pos++] = (uint8_t) 0;
  rtcpbuffer[pos++] = (uint8_t) 0;

  // Additional Feedback Control Information (FCI)
  AssignUWord32ToBuffer(rtcpbuffer + pos, remoteSsrc);
  pos += 4;

  rtcpbuffer[pos++] = (uint8_t)(firSequenceNumber);
  rtcpbuffer[pos++] = (uint8_t) 0;
  rtcpbuffer[pos++] = (uint8_t) 0;
  rtcpbuffer[pos++] = (uint8_t) 0;
  firSequenceNumber++;

  //Build and send buffer packet
  std::cout << "Built FIR packet for localSsrc: " << localSsrc
            << " -- remoteSsrc: " << remoteSsrc << " -- pos: " << pos
            << std::endl;
  return std::make_shared<talk_base::Buffer>(rtcpbuffer, bufferSize,
                                             bufferCapacity);
}


//Sending code - I have also tried it with BuildPLIPacket
firPacket = BuildFIRPacket(presenterVideoChannel->GetSendSsrc(),
                                 presenterVideoChannel->GetRecvSsrc());
      presenterVideoChannel->SendRtcp(firPacket.get());

Adam Fineberg

unread,
Oct 30, 2013, 10:36:16 AM10/30/13
to discuss...@googlegroups.com
Set your breakpoint in webrtc/modules/rtp_rtcp_source/rtcp_receiver.cc HandleFIR and/or HandlePLI and you should see if the packets are being received and why they are dropped (if they are).

Sergio Garcia Murillo

unread,
Oct 30, 2013, 11:07:53 AM10/30/13
to discuss...@googlegroups.com
It would be great if anyone of you could share the binary built of chromium with webrtc traces enabled (especially for windows). It would be really helpful for quite a lot of us.. ;)

Best regards
Sergio

Lorenzo Miniero

unread,
Oct 30, 2013, 11:44:42 AM10/30/13
to discuss...@googlegroups.com
+1!

Lorenzo

Kaiduan Xie

unread,
Oct 30, 2013, 12:10:48 PM10/30/13
to discuss...@googlegroups.com
You can build Chromium with webrtc trace,

On Mac run Chrome as below,

Chrome --enable-logging > log 2>&1

/Kaiduan


The following lists the changes, the changes are marked in pink.

1) Libjingle,

third_party/libjingle/overrides/talk/base/logging.cc

$ svn diff .
Index: overrides/talk/base/logging.cc
===================================================================
--- overrides/talk/base/logging.cc (revision 221536)
+++ overrides/talk/base/logging.cc (working copy)
@@ -151,7 +151,7 @@
 DiagnosticLogMessage::~DiagnosticLogMessage() {
   print_stream_ << extra_;
   const std::string& str = print_stream_.str();
-  if (log_to_chrome_)
+  //if (log_to_chrome_)
     LOG_LAZY_STREAM_DIRECT(file_name_, line_, severity_) << str;
   if (g_logging_delegate_function && severity_ <= LS_INFO) {
     print_stream_with_timestamp_ << str;
@@ -290,6 +290,7 @@

kxie@ci0000003749415 ~/chromium/src/third_party/libjingle/source/talk/media/webrtc $ svn diff .
Index: webrtcvoiceengine.cc
===================================================================
--- webrtcvoiceengine.cc (revision 4650)
+++ webrtcvoiceengine.cc (working copy)
@@ -1070,8 +1070,9 @@
 }
 
 void WebRtcVoiceEngine::SetTraceFilter(int filter) {
-  log_filter_ = filter;
-  tracing_->SetTraceFilter(filter);
+  //log_filter_ = filter;
+  log_filter_ = webrtc::kTraceAll;
+  tracing_->SetTraceFilter(log_filter_);
 }
 
 // We suppport three different logging settings for VoiceEngine:
@@ -1159,9 +1160,10 @@
     LOG_V(sev) << msg;
   } else {
     std::string msg(trace + 71, length - 72);
-    if (!ShouldIgnoreTrace(msg)) {
-      LOG_V(sev) << "webrtc: " << msg;
-    }
+    //if (!ShouldIgnoreTrace(msg)) {
+    LOG(LS_INFO) << "webrtc: " << msg;
+    //  LOG_V(sev) << "webrtc: " << msg;
+    //}
   }
 }
 
Index: webrtcvideoengine.cc
===================================================================
--- webrtcvideoengine.cc (revision 4650)
+++ webrtcvideoengine.cc (working copy)
@@ -1324,10 +1324,11 @@
     LOG_V(sev) << msg;
   } else {
     std::string msg(trace + 71, length - 72);
-    if (!ShouldIgnoreTrace(msg) &&
-        (!voice_engine_ || !voice_engine_->ShouldIgnoreTrace(msg))) {
-      LOG_V(sev) << "webrtc: " << msg;
-    }
+    //if (!ShouldIgnoreTrace(msg) &&
+    //    (!voice_engine_ || !voice_engine_->ShouldIgnoreTrace(msg))) {
+    //  LOG_V(sev) << "webrtc: " << msg;
+    LOG(LS_INFO) << "webrtc: " << msg;
+    //}
   }
 }

2) webrtc

kxie@ci0000003749415 ~/chromium/src/third_party/webrtc/system_wrappers $ svn diff .

Index: source/trace_impl.cc
===================================================================
--- source/trace_impl.cc (revision 4650)
+++ source/trace_impl.cc (working copy)
@@ -29,13 +29,16 @@
 #pragma warning(disable:4355)
 #endif  // _WIN32
 
+#define WEBRTC_DIRECT_TRACE
+
 namespace webrtc {
 
 const int Trace::kBoilerplateLength = 71;
 const int Trace::kTimestampPosition = 13;
 const int Trace::kTimestampLength = 12;
 
-static uint32_t level_filter = kTraceDefault;
+static uint32_t level_filter = kTraceAll;
+//static uint32_t level_filter = kTraceDefault;
 
 // Construct On First Use idiom. Avoids "static initialization order fiasco".
 TraceImpl* TraceImpl::StaticInstance(CountOperation count_operation,
@@ -43,11 +46,13 @@
   // Sanities to avoid taking lock unless absolutely necessary (for
   // performance reasons). count_operation == kAddRefNoCreate implies that a
   // message will be written to file.
+#if 0 // !xkd!
   if ((level != kTraceAll) && (count_operation == kAddRefNoCreate)) {
     if (!(level & level_filter)) {
       return NULL;
     }
   }
+#endif
   TraceImpl* impl =
     GetStaticInstance<TraceImpl>(count_operation);
   return impl;

Bo Xu

unread,
Jan 10, 2017, 3:30:52 PM1/10/17
to discuss-webrtc

could you tell me where(which cc file) I can run the following part of your code to send out FIR packet?
...
//Sending code - I have also tried it with BuildPLIPacket
firPacket = BuildFIRPacket(presenterVideoChannel->GetSendSsrc(),presenterVideoChannel->GetRecvSsrc());
presenterVideoChannel->SendRtcp(firPacket.get());
...

Thanks!
Bo Xu

Luke Mauldin

unread,
Jan 10, 2017, 4:08:55 PM1/10/17
to discuss-webrtc
Sorry, I don't have access to that code anymore.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--

--- You received this message because you are subscribed to a topic in the Google Groups "discuss-webrtc" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/discuss-webrtc/4YcHasYC3xg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to discuss-webrt...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
--
 
---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

-- 
Regards,
Adam
--
 
---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

-- 
Regards,
Adam

--

---
You received this message because you are subscribed to a topic in the Google Groups "discuss-webrtc" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/discuss-webrtc/4YcHasYC3xg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/27b99888-fa94-4b0e-9da1-e3b0048f85ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages