Audio/video stream recording forums

Attention Visitor:
You may have to register or log in before you can post:
  • Click the register link to sign up.
  • Registered members please fill in the form below and click the "Log in" button.
To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Audio/video stream recording forums > Streaming media recording forum > rtmpdump
Register FAQ Members List Calendar Mark Forums Read

Reply Post New Thread
 
Thread Tools Display Modes
  #51  
Old 04-18-2013, 08:50 AM
KSV KSV is offline
Senior Member
 
Join Date: Apr 2011
Posts: 853
KSV is on a distinguished road
Cool

Re: Customized rtmpdump binaries with patch file


for the time being try with openssl and fresh copy of repo without any modifications.
Reply With Quote
  #52  
Old 04-18-2013, 01:28 PM
mkucharski mkucharski is offline
Junior Member
 
Join Date: Apr 2013
Posts: 1
mkucharski is on a distinguished road
Default

Re: Customized rtmpdump binaries with patch file


KSV, would you consider forking rtmpdump on github (or any other source code hosting service) and integrate your patches there? Or have you considered to push your changes upstream?
Reply With Quote
  #53  
Old 04-18-2013, 01:58 PM
RedPenguin RedPenguin is offline
Member
 
Join Date: Feb 2012
Posts: 85
RedPenguin is on a distinguished road
Default

Re: Customized rtmpdump binaries with patch file


Quote:
Originally Posted by KSV View Post
for the time being try with openssl and fresh copy of repo without any modifications.
Doing this produces a rtmpdump that works also.
Reply With Quote
  #54  
Old 04-18-2013, 02:09 PM
KSV KSV is offline
Senior Member
 
Join Date: Apr 2011
Posts: 853
KSV is on a distinguished road
Cool

Re: Customized rtmpdump binaries with patch file


can you add my latest patch file to the openssl mix and try. also try with fresh repo + polarssl only.
Reply With Quote
  #55  
Old 04-18-2013, 03:26 PM
RedPenguin RedPenguin is offline
Member
 
Join Date: Feb 2012
Posts: 85
RedPenguin is on a distinguished road
Default

Re: Customized rtmpdump binaries with patch file


Adding your patch to openssl blend breaks and so does with polarssl no other changes.

EDIT: As a test I upgraded to PolarSSL 1.2.7 from 1.0.0 and with fresh code that actually does download but again the minute your patch is added, broken again .

Last edited by RedPenguin : 04-18-2013 at 04:58 PM.
Reply With Quote
  #56  
Old 04-19-2013, 12:12 PM
KSV KSV is offline
Senior Member
 
Join Date: Apr 2011
Posts: 853
KSV is on a distinguished road
Cool

Re: Customized rtmpdump binaries with patch file


Quote:
Originally Posted by RedPenguin View Post
Adding your patch to openssl blend breaks and so does with polarssl no other changes.

EDIT: As a test I upgraded to PolarSSL 1.2.7 from 1.0.0 and with fresh code that actually does download but again the minute your patch is added, broken again .
hmmm so then something in patch is causing this particular problem. in absence of test case you have to debug it yourself. i can only suggest how to do that if you are interested.

1. first create two fresh repos and apply patch to only one of them.

2. copy rtmp.c, rtmp.h and rtmp_sys.h from patched repo to non-patched one.

3. compile it and check if problem reoccurs. if yes then we can leave out changes in other files as possible culprit.

4. now the hard part, if the problem is with changes of rtmp.c then you have to remove the code added by patch, block by block and figure out the offending code.
Reply With Quote
  #57  
Old 04-19-2013, 07:38 PM
RedPenguin RedPenguin is offline
Member
 
Join Date: Feb 2012
Posts: 85
RedPenguin is on a distinguished road
Default

Re: Customized rtmpdump binaries with patch file


Well so far it appears it's definitely those files but to even get rtmpdump to compile I had to copy over the patched rtmpdump.c but it still fails on rtmpgw but that's not needed right now.

I also tried with only rtmp_sys.h only so that looks like it's not the problem.

Will update once I get further.
Reply With Quote
  #58  
Old 04-19-2013, 11:13 PM
RedPenguin RedPenguin is offline
Member
 
Join Date: Feb 2012
Posts: 85
RedPenguin is on a distinguished road
Default

Re: Customized rtmpdump binaries with patch file


I have found almost the exact problem, it is definitely changes to the rtmp.c that break it.

The code you place in at the very bottom is doing it:

I can't seem to pinpoint the exact part of the code but once I removed all of this said code plus some small pieces above referencing it, it immediately worked.

Code:
+static int
+ConnectSocket(RTMP *r)
+{
+  int on = 1;
+  struct sockaddr_in service;
+  if (!r->Link.hostname.av_len)
+    return FALSE;
+
+  memset(&service, 0, sizeof (struct sockaddr_in));
+  service.sin_family = AF_INET;
+
+  if (r->Link.socksport)
+    {
+      /* Connect via SOCKS */
+      if (!add_addr_info(&service, &r->Link.sockshost, r->Link.socksport))
+        return FALSE;
+    }
+  else
+    {
+      /* Connect directly */
+      if (!add_addr_info(&service, &r->Link.hostname, r->Link.port))
+        return FALSE;
+    }
+
+  r->m_sb.sb_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+  if (r->m_sb.sb_socket != -1)
+    {
+      if (connect(r->m_sb.sb_socket, (struct sockaddr *) &service, sizeof (struct sockaddr)) < 0)
+        {
+          int err = GetSockError();
+          RTMP_Log(RTMP_LOGERROR, "%s, failed to connect socket. %d (%s)",
+                   __FUNCTION__, err, strerror(err));
+          RTMP_Close(r);
+          return FALSE;
+        }
+
+      if (r->Link.socksport)
+        {
+          RTMP_Log(RTMP_LOGDEBUG, "%s ... SOCKS negotiation", __FUNCTION__);
+          if (!SocksNegotiate(r))
+            {
+              RTMP_Log(RTMP_LOGERROR, "%s, SOCKS negotiation failed.", __FUNCTION__);
+              RTMP_Close(r);
+              return FALSE;
+            }
+        }
+    }
+  else
+    {
+      RTMP_Log(RTMP_LOGERROR, "%s, failed to create socket. Error: %d",
+               __FUNCTION__, GetSockError());
+      return FALSE;
+    }
+
+  /* set timeout */
+  SET_RCVTIMEO(tv, r->Link.timeout);
+  if (setsockopt(r->m_sb.sb_socket, SOL_SOCKET, SO_RCVTIMEO, (char *) &tv, sizeof (tv)))
+    {
+      RTMP_Log(RTMP_LOGERROR, "%s, Setting socket timeout to %d failed!",
+               __FUNCTION__, r->Link.timeout);
+    }
+
+  setsockopt(r->m_sb.sb_socket, IPPROTO_TCP, TCP_NODELAY, (char *) &on, sizeof (on));
+  if (r->Link.protocol & RTMP_FEATURE_HTTP)
+    setsockopt(r->m_sb.sb_socket, SOL_SOCKET, SO_KEEPALIVE, (char *) &on, sizeof (on));
+
+  return TRUE;
+}
+
+static int
+SendCommand(RTMP *r, char *method, int queue)
+{
+  char pbuf[256], *pend = pbuf + sizeof (pbuf), *enc;
+  AVal av_command, methodName;
+
+  enc = pbuf;
+  methodName.av_val = method;
+  methodName.av_len = strlen(method);
+  enc = AMF_EncodeString(enc, pend, &methodName);
+  enc = AMF_EncodeNumber(enc, pend, ++r->m_numInvokes);
+  *enc++ = AMF_NULL;
+  av_command.av_val = pbuf;
+  av_command.av_len = enc - pbuf;
+
+  return SendInvoke(r, &av_command, queue);
+}
+
+static int
+SendGetStreamLength(RTMP *r)
+{
+  char pbuf[256], *pend = pbuf + sizeof (pbuf), *enc;
+  AVal av_Command;
+
+  enc = pbuf;
+  enc = AMF_EncodeString(enc, pend, &av_getStreamLength);
+  enc = AMF_EncodeNumber(enc, pend, ++r->m_numInvokes);
+  *enc++ = AMF_NULL;
+  enc = AMF_EncodeString(enc, pend, &r->Link.playpath);
+  av_Command.av_val = pbuf;
+  av_Command.av_len = enc - pbuf;
+
+  return SendInvoke(r, &av_Command, TRUE);
+}
+
+static int
+SendInvoke(RTMP *r, AVal *command, int queue)
+{
+  RTMPPacket packet;
+  char pbuf[512], *enc;
+
+  packet.m_nChannel = 0x03; /* control channel (invoke) */
+  packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+  packet.m_nTimeStamp = 0;
+  packet.m_nInfoField2 = 0;
+  packet.m_hasAbsTimestamp = 0;
+  packet.m_body = pbuf + RTMP_MAX_HEADER_SIZE;
+
+  enc = packet.m_body;
+  if (command->av_len)
+    {
+      memcpy(enc, command->av_val, command->av_len);
+      enc += command->av_len;
+    }
+  else
+    return FALSE;
+  packet.m_nBodySize = enc - packet.m_body;
+
+  return RTMP_SendPacket(r, &packet, queue);
+}
+
+static int
+strsplit(char *src, int srclen, char delim, char ***params)
+{
+  char *sptr, *srcbeg, *srcend, *dstr;
+  int count = 1, i = 0, len = 0;
+
+  if (src == NULL)
+    return 0;
+  if (!srclen)
+    srclen = strlen(src);
+  srcbeg = src;
+  srcend = srcbeg + srclen;
+  sptr = srcbeg;
+
+  /* count the delimiters */
+  while (sptr < srcend)
+    {
+      if (*sptr++ == delim)
+        count++;
+    }
+  sptr = srcbeg;
+  *params = calloc(count, sizeof (size_t));
+  char **param = *params;
+
+  for (i = 0; i < (count - 1); i++)
+    {
+      dstr = strchr(sptr, delim);
+      len = dstr - sptr;
+      param[i] = calloc(len + 1, sizeof (char));
+      strncpy(param[i], sptr, len);
+      sptr += len + 1;
+    }
+
+  /* copy the last string */
+  if (sptr <= srcend)
+    {
+      len = srclen - (sptr - srcbeg);
+      param[i] = calloc(len + 1, sizeof (char));
+      strncpy(param[i], sptr, len);
+    }
+  return count;
+}
Reply With Quote
  #59  
Old 04-20-2013, 02:04 AM
KSV KSV is offline
Senior Member
 
Join Date: Apr 2011
Posts: 853
KSV is on a distinguished road
Cool

Re: Customized rtmpdump binaries with patch file


Quote:
Originally Posted by RedPenguin View Post
I can't seem to pinpoint the exact part of the code but once I removed all of this said code plus some small pieces above referencing it, it immediately worked.
Those functions can't be the real culprit. they aren't even being used as per your log file. keep all the patch except following change. revert
Code:
  else if (AVMATCH(&method, &av__onbwcheck) || AVMATCH(&method, &av_onBWCheck))
to original
Code:
  else if (AVMATCH(&method, &av__onbwcheck))
Reply With Quote
  #60  
Old 04-20-2013, 02:07 AM
RedPenguin RedPenguin is offline
Member
 
Join Date: Feb 2012
Posts: 85
RedPenguin is on a distinguished road
Default

Re: Customized rtmpdump binaries with patch file


Quote:
Originally Posted by KSV View Post
Those functions can't be the real culprit. they aren't even being used as per your log file. keep all the patch except following change. revert
Code:
  else if (AVMATCH(&method, &av__onbwcheck) || AVMATCH(&method, &av_onBWCheck))
to original
Code:
  else if (AVMATCH(&method, &av__onbwcheck))
Yea that's what I figured, because I swear I made those changes, compiled and it worked, but when I tried to reproduce it, it failed.

EDIT: Damn KSV are you good! I made this single change only and it worked immediately! Also just to double verify, I deleted the dir and reused git, made same change, and works again.

Though as far as you know, this should not break anything else in the patch?
Reply With Quote
Reply Post New Thread
Tags: , , , , , ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -6. The time now is 06:34 AM.


Powered by All-streaming-media.com; 2006-2011
vB forum hacked with Zoints add-ons