Resolved. This is NOT a bug with Live555 but simply a misunderstanding of how to use the Groupsocks. This is MY fault, NOT the Live555 code.
I should change the InitializeRoomClientAudioChannel method to use Groupsock2 pointers instead of passing the address from the stack-based ones. These addresses must be held onto internally, and obviously when the stack unwinds the addresses are blown away. So the values of Groupsock aren't copied by SimpleRTPSource::createNew, but the addresses are held onto. Which is perfectly fine. Sorry for the unnecessary post. On Mon, Jun 27, 2016 at 10:57 AM Ben Rush <b...@ben-rush.net> wrote: > This has happened to me a couple times while coding up things and I'd like > to see if it's something stupid I'm doing, or whether I've uncovered a bug > in Live555. > > I've got a class called "RoomClientStreamingServer" which does RTSP + RTP > audio. Here is the header file for it: > > class RoomClientStreamingServer : public IRoomClient > { > public: > RoomClientStreamingServer(); > ~RoomClientStreamingServer(); > void InitializeServer(); > bool InitializeRoomClientAudioChannel(int roomClientAudioListenPort); > bool InitializeRoomClientRTSPChannel(int rtspPort, std::string > streamName, bool doAudio); > void StartServer(); > virtual void StopServer() override; > private: > TaskScheduler* _taskScheduler; > BasicUsageEnvironment* _usageEnvironment; > > private://audio channel > SpeakerSink* _speakerSink; > RTPSource* _audioRTPSource; > RTCPInstance* _audioRTCPSource; > > private://RTSP channel > RTSPServer* _rtspServer; > ServerMediaSession* _sms; > H264LiveServerMediaSession *_videoSubSession; > WindowsAudioMediaSession* _audioSubSession; > char _volatile; > }; > > I use it like this: > > RoomClientStreamingServer* roomClient = new > RoomClientStreamingServer(); > roomClient->InitializeServer(); > > roomClient->InitializeRoomClientAudioChannel(roomClientAudioListenPort); > roomClient->InitializeRoomClientRTSPChannel(rtspPort, streamName, > doAudio); > > roomClient->StartServer(); > > The weirdness happens when calling StartServer. StartServer has a very > simple implementation: > > void RoomClientStreamingServer::StartServer() > { > _taskScheduler->doEventLoop(&_volatile); > } > > This bombs with the following error: > > "BasicTaskScheduler::SingleStep(): select() fails: No error > socket numbers used in the select() call: 812(r) 816(r)" > > It appears to be a problem with the InitializeRoomClientAudioChannel() > call because I can duplicate this error if I comment out the > InitializeRoomClientRTSPChannel(). > > Here is the InitializeRoomClientAudioChannel() implementation: > > _speakerSink = SpeakerSink::createNew(*_usageEnvironment, true, > nullptr, false); > > unsigned int rtpPortNum = roomClientAudioListenPort; // > StreamingOptions::RoomClientListenPort; > unsigned int rtcpPortNum = rtpPortNum + 1; > char* ipAddress = "0.0.0.0"; > //char* ipAddress = "239.255.42.42"; > > struct in_addr address; > address.S_un.S_addr = our_inet_addr(ipAddress); > const Port rtpPort(rtpPortNum); > const Port rtcpPort(rtcpPortNum); > > Groupsock2 rtpGroupSock(*_usageEnvironment, address, rtpPort, 1); > Groupsock2 rtcpGroupSock(*_usageEnvironment, address, rtcpPort, 1); > > _speakerSink->SetGroupSocks(&rtpGroupSock, &rtcpGroupSock); > > //RTPSource* rtpSource = WaveFormDataStreamer::createNew(*environment, > &rtpGroupSock); > int payloadFormatCode = 11; > const char* mimeType = "L16"; > int fSamplingFrequency = 44100; > int fNumChannels = 1; > _audioRTPSource = SimpleRTPSource::createNew( > *_usageEnvironment, (Groupsock*)&rtpGroupSock, payloadFormatCode, > fSamplingFrequency, "audio/L16", 0, False /*no 'M' bit*/); > > const unsigned maxCNAMElen = 100; > unsigned char CNAME[maxCNAMElen + 1]; > gethostname((char*)CNAME, maxCNAMElen); > CNAME[maxCNAMElen] = '\0'; // just in case > > _audioRTCPSource = > RTCPInstance::createNew(*_usageEnvironment, > (Groupsock*)&rtcpGroupSock, 5000, CNAME, NULL, _audioRTPSource); > _audioRTCPSource->setByeHandler(subsessionByeHandler, _speakerSink); > _speakerSink->startPlaying(*_audioRTPSource, afterAudioListening, > NULL); > //_taskScheduler->doEventLoop(&_volatile); > return true; > > If you'll notice I have _taskScheduler->doEventLoop(&_volatile); > commented out because, if I uncomment this line, then I no longer get the > crash. > > it's almost as if the _taskScheduler->doEventLoop() needs to be called on > the same stack as the rest of the setup code. Again, I've encountered > situations like this before when trying to separate the > _taskScheduler->doEventLoop() call in another method. > > One final bit of information: if I comment out > InitializeRoomClientAudioChannel > and just let the RTSP stuff go (the webcam), with the > _taskScheduler->doEventLoop() in its own method, then everything works > fine. > > I recognize this might be a bit tough to follow over email, so if you need > source that's fine. However, I also recognize people on this group are busy > and so fundamentally I'd like to at least understand what might be the > cause of the > > "BasicTaskScheduler::SingleStep(): select() fails: No error > socket numbers used in the select() call: 812(r) 816(r)" > > error if nothing else. > > If I uncover what I'm doing before I get a response here then I'll send > out another email to the group for posterity's sake. >
_______________________________________________ live-devel mailing list live-devel@lists.live555.com http://lists.live555.com/mailman/listinfo/live-devel