[Live-devel] Proxying SIP live RTP to RTSP problem (segfault)

rus at sfinx.in rus at sfinx.in
Sun Sep 24 08:50:44 PDT 2017


Greetings,

I need to to dynamically create the RTSP endpoints from the live SIP calls
(video stream only). So first I've tested the playSIP with Asterisk (small
patch to liveMedia/SIPClient.cpp needed) and successfully got the raw
out.264 file recorded with the video from the call.
 Next I've modified the playCommon.cpp so its dynamically creates the
RTSP server and sinks the data from already present video subsession.
 Compiling, running, connecting to the call are ok, but after connecting
with openRTSP to the RTSP endpoint I'm getting the segfault after message:

"FramedSource[0x2493050]::getNextFrame(): attempting to read more than once at the same time!"

#0  0x0000000000473828 in ?? ()
#1  0x00000000004738b9 in ?? ()
#2  0x00000000001e8694 in ?? ()
#3  0x000000000044bcae in FramedSource::getNextFrame (this=0x12d2050, to=0x14c7cd1 "", maxSize=2000000,     afterGettingFunc=0x45117e <H264or5VideoStreamDiscreteFramer::doGetNextFrame()+62>,     afterGettingClientData=0x12dd6f0,     onCloseFunc=0x44bd28 <FramedSource::afterGetting(FramedSource*)+96>, onCloseClientData=0x12dd6f0)    at FramedSource.cpp:78
#4  0x0000000000451177 in H264or5VideoStreamDiscreteFramer::doGetNextFrame (this=0x12dd6f0)    at H264or5VideoStreamDiscreteFramer.cpp:40
#5  0x000000000044bcae in FramedSource::getNextFrame (this=0x12dd6f0, to=0x14c7cd1 "", maxSize=2000000,     afterGettingFunc=0x45fb12 <H264or5Fragmenter::doStopGettingFrames()+18>,     afterGettingClientData=0x14c7bc0,     onCloseFunc=0x44bd28 <FramedSource::afterGetting(FramedSource*)+96>, onCloseClientData=0x14c7bc0)    at FramedSource.cpp:78
#6  0x000000000045f64a in H264or5Fragmenter::doGetNextFrame (this=0x14c7bc0)    at H264or5VideoRTPSink.cpp:181
#7  0x000000000044bcae in FramedSource::getNextFrame (this=0x14c7bc0, to=0x12ded6c "", maxSize=2000532,     afterGettingFunc=0x41484e <MultiFramedRTPSink::packFrame()+442>, afterGettingClientData=0x12ddb40,     onCloseFunc=0x415238 <MultiFramedRTPSink::sendNext(void*)+18>, onCloseClientData=0x12ddb40)    at FramedSource.cpp:78
#8  0x000000000041482d in MultiFramedRTPSink::packFrame (this=0x12ddb40) at MultiFramedRTPSink.cpp:224
#9  0x000000000041467a in MultiFramedRTPSink::buildAndSendPacket (this=0x12ddb40,     isFirstPacket=1 '\001') at MultiFramedRTPSink.cpp:198
#10 0x00000000004144b9 in MultiFramedRTPSink::continuePlaying (this=0x12ddb40)    at MultiFramedRTPSink.cpp:156
#11 0x000000000045f36a in H264or5VideoRTPSink::continuePlaying (this=0x12ddb40)    at H264or5VideoRTPSink.cpp:124
#12 0x000000000040c04e in MediaSink::startPlaying (this=0x12ddb40, source=...,
...

What can be the problem ? I'm new to the live555 so the list help will be very appreciated.

The simple mods to the playCommon are below:

...
 void continueAfterSETUP(RTSPClient* client, int resultCode, char* resultString) {
+  if (!strcmp(clientProtocolName, "SIP") && !strcmp(subsession->mediumName(), "video") && !strcmp(subsession->codecName(), "H264"))
+    createRTSPServer(subsession);
...

The simple RTSP server endpoint creation :

class H264LiveServerMediaSession : public OnDemandServerMediaSubsession {
   MediaSubsession *ss;
 public:
   H264LiveServerMediaSession(MediaSubsession *s) : OnDemandServerMediaSubsession(*env, true) {
     ss = s;
   }
   FramedSource* createNewStreamSource(unsigned clientSessionId, unsigned &estBitRate) {
     estBitRate = ss->bandwidth();
     if (!estBitRate)
       estBitRate = 90;
     return H264VideoStreamDiscreteFramer::createNew(ss->parentSession().envir(), ss->readSource());
   }
   RTPSink* createNewRTPSink(Groupsock* rtpGroupsock, unsigned char rtpPayloadTypeIfDynamic,     FramedSource* inputSource) {
       return H264VideoRTPSink::createNew(envir(), rtpGroupsock, rtpPayloadTypeIfDynamic, ss->fmtp_spropparametersets());
   }
};

void createRTSPServer(MediaSubsession *ss)
{
 RTSPServer *rtspServer = RTSPServer::createNew(*env, 8554, NULL);
 if (!rtspServer) {
    *env << "Failed to create RTSP server: " << env->getResultMsg() << "\n";
    exit(1);
 }
 char const* info = "stream0";
 ServerMediaSession* sms = ServerMediaSession::createNew(*env, info, info, info);
 H264LiveServerMediaSession *sip = new H264LiveServerMediaSession(subsession);
 sms->addSubsession(sip);
 rtspServer->addServerMediaSession(sms);
 // announceStream(rtspServer, sms, streamName);
}
.....

.... small liveMedia/SIPClient.cpp patch for latest Asterisk ....

@@ -503,6 +508,8 @@ unsigned SIPClient::getResponseCode() {
              // Asterisk #####
              sscanf(lineStart, "Proxy-Authenticate: Digest
realm=\"%[^\"]\", nonce=\"%[^\"]\"",
                     realm, nonce) == 2 ||
+             sscanf(lineStart, "WWW-Authenticate: Digest  realm=\"%[^\"]\",nonce=\"%[^\"]\"",
+                    realm, nonce) == 2 ||
              // Cisco ATA #####
              sscanf(lineStart, "Proxy-Authenticate: Digest algorithm=MD5,domain=\"%*[^\"]\",nonce=\"%[^\"]\", realm=\"%[^\"]\"",
                     nonce, realm) == 2) {
@@ -868,7 +875,7 @@ SIPClient::createAuthenticatorString(Authenticator const* authenticator,
       && authenticator->password() != NULL) {
     // We've been provided a filled-in authenticator, so use it:
     char const* const authFmt
-      = "Proxy-Authorization: Digest username=\"%s\", realm=\"%s\", nonce=\"%s\", response=\"%s\", uri=\"%s\"\r\n";
+      = "Authorization: Digest username=\"%s\", realm=\"%s\", nonce=\"%s\", response=\"%s\", uri=\"%s\"\r\n";
...

---
Rus


More information about the live-devel mailing list