Browse Source

Live555 Trouble Stage 1

AGP
Evgeny Gagua 3 years ago
parent
commit
6e79953540
  1. 1
      Projects/la_mojo/Debug/server.conf
  2. 2
      Projects/la_mojo/build
  3. 3
      lib/App/common/deviceNode2D.cpp
  4. 2
      lib/App/common/deviceNode2D.h
  5. 7
      lib/App/common/kernelModuleEmbedVideo.cpp
  6. 5
      lib/components/base/basicThread.cpp
  7. 1
      lib/components/base/basicThread.h
  8. 4
      lib/data/media/video/videoAVLIBSource.cpp
  9. 92
      lib/data/media/video/videoLive555AVLibSource.cpp
  10. 20
      lib/data/media/video/videoLive555AVLibSource.h

1
Projects/la_mojo/Debug/server.conf

@ -8,6 +8,7 @@ GENERAL :
WEB_ACCESS_GROUP = "www-data";
DATA_MEMORY_NAME = "mem_db.db";
REPORT_FILE_NAME = "data/reports.db";
REPORTS_DIR_NAME = "data/reports";
};
KERNEL :
{

2
Projects/la_mojo/build

@ -1,7 +1,7 @@
#! /bin/sh
make clean -e "CFG=Debug"
#make clean -e "CFG=Debug"
make -e "CFG=Debug" -j6
#make clean -e "CFG=Debug86"

3
lib/App/common/deviceNode2D.cpp

@ -2486,6 +2486,9 @@ bool device2DSensor::packetHandler( protocolPackage *Package ){
#ifdef DEBUG
LOG("CMD_UNSUPPORTED!!");
#endif
if( getWM() == LRF_WM_SYNC_UP ){
setStage( LRF_WS_STAGE_1 );
}
break;
};
case CMD_FULL_RESET:{

2
lib/App/common/deviceNode2D.h

@ -23,7 +23,7 @@
#define LGS_DEFAULT_SLEEP_TIME 100
#define LGS_ALERT_SLEEP_TIME 10
#define LGS_DEFAULT_TO_COUNTER 10 //100ms
#define LGS_DEFAULT_WS_TIME 6 //60ms
#define LGS_DEFAULT_WS_TIME 10 //100ms
#define LGS_INITIAL_FLIPS 8
#define LGS_CMD_RETRY_COUNT 3

7
lib/App/common/kernelModuleEmbedVideo.cpp

@ -206,7 +206,8 @@ static const char * ht_no_signal = "HTTP/1.1 200 OK\r\n"
void signal_pipe_handler( int SIG ){
basicLogCollection::getInstance()->Log("SIG_PIPE", NULL, _LOG_ERROR, "Sig Pipe Received");
//basicLogCollection::getInstance()->Log("SIG_PIPE", NULL, _LOG_ERROR, "Sig Pipe Received");
// Web Client Disconnected!
};
void *kernelModuleEmbedVideo::webClientProc( void *ptr ){
@ -3425,12 +3426,14 @@ bool streamHandler::validate( void ){
if( m_nGlobalFrameCounter ) { //Frames Received from a source
if( m_nGlobalFrameCounter == m_nValidatorFrameCounter ) {
// Video Stalled!
return false;// Try use System to recuperate
LOG_ERROR("Video Stalled");
//return false;// Try use System to recuperate
} else m_nValidatorFrameCounter = m_nGlobalFrameCounter;
};
if( m_bThreadStatus < TH_ENDED ) return true;
#endif
};
LOG_ERROR("Video Ended");
};
return false;
};

5
lib/components/base/basicThread.cpp

@ -93,6 +93,11 @@ bool basicThread::uninit( void ){
return true;
};
void basicThread::abort(){
pthread_cancel( m_sThreadHandler );
pthread_join( m_sThreadHandler, NULL);
};
#undef LOG
#undef LOG_ERROR
#undef SLOG

1
lib/components/base/basicThread.h

@ -67,6 +67,7 @@ class basicThread {
thredStatus getStatus( void ){ return m_bThreadStatus; };
void setStatus( thredStatus A ){ m_bThreadStatus = A; };
void waitThreadEnd( bool forced = false );
void abort( void );
// Copy constructor
// TODO: Uncomment the copy constructor when you need it.
//basicThread(const basicThread& src);

4
lib/data/media/video/videoAVLIBSource.cpp

@ -867,8 +867,8 @@ void videoAVLIBSource::m_fThreadProc( void ){
SLEEP( 5 );
};
av_packet_unref( pPacket );
SLEEP( 10 );
} else SLEEP( 10 );
SLEEP( 5 );
} else SLEEP( 5 );
};
#ifdef DEBUG
LOG("Video Source Ended!");

92
lib/data/media/video/videoLive555AVLibSource.cpp

@ -35,7 +35,7 @@ CustomRTSPClient::CustomRTSPClient(
int verbosityLevel,
char const* applicationName,
portNumBits tunnelOverHTTPPortNum)
: RTSPClient(env,rtspURL, verbosityLevel, applicationName, tunnelOverHTTPPortNum, -1) ,
: RTSPClient( env, rtspURL, verbosityLevel, applicationName, tunnelOverHTTPPortNum, -1 ),
session(session){
};
@ -355,6 +355,7 @@ DummySink::DummySink( videoLIVE555Source* session, UsageEnvironment& env, MediaS
m_pSwsContext = sws_getContext( m_pCodecContext->width, m_pCodecContext->height, m_pCodecContext->pix_fmt, m_nOutWidth, m_nOutHeight, AV_PIX_FMT_BGR24, SWS_BICUBIC, NULL, NULL, NULL);
m_pRGB = new cv::Mat( m_nOutHeight, m_nOutWidth, CV_8UC3, cv::Scalar( 255, 0, 255 ) );
} else {
LOG("No Decode Frames Mode!");
m_pFrame = m_pRGBFrame = NULL;
m_pSwsContext = NULL;
m_pRGB = NULL;
@ -368,7 +369,7 @@ DummySink::DummySink( videoLIVE555Source* session, UsageEnvironment& env, MediaS
};
DummySink::~DummySink() {
LOG("Sink Destructor!");
if( m_pOutFormatCtx != NULL ) {
av_write_trailer( m_pOutFormatCtx );
avio_close( m_pOutFormatCtx->pb );
@ -421,6 +422,7 @@ void DummySink::afterGettingFrame(void* clientData, unsigned frameSize, unsigned
void DummySink::afterGettingFrame(unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds ) {
// We've just received a frame of data. (Optionally) print out information about it:
//if (strcmp(fSubsession.codecName(),"H264") == 0) {
LOG("FRM");
if( m_eCodecProbe != AV_CODEC_ID_NONE ) {
int got_picture;
@ -443,6 +445,7 @@ void DummySink::afterGettingFrame(unsigned frameSize, unsigned numTruncatedBytes
m_iFrameIndex ++;
};
};
av_packet_unref( &m_sAvPkt );
if ( m_pSession->getWM() & MS_MODE_STREAM_PROXY ) {
if ( m_pSession->getWM() & MS_MODE_OVERLAYED_LOOPS ) {
@ -648,13 +651,20 @@ videoLIVE555Source::~videoLIVE555Source(){
};
void videoLIVE555Source::m_fThreadProc( void ){
LOG("Start Thread");
_eventLoopWatchVariable = 0;
m_bThreadStatus = TH_WORKING;
//while ( m_bThreadStatus == TH_WORKING ) {
m_pScheduler->doEventLoop( &_eventLoopWatchVariable );
//streamTimerHandler( m_pRtspClient );
//SLEEP(3);
//};
LOG( "Rtsp event finished" );
m_pUsageEnvironment->reclaim();
m_pUsageEnvironment = NULL;
delete m_pScheduler;
m_pScheduler = NULL;
//m_pUsageEnvironment->reclaim();
//m_pUsageEnvironment = NULL;
//delete m_pScheduler;
//m_pScheduler = NULL;
LOG("End Thread");
};
@ -670,7 +680,7 @@ void videoLIVE555Source::continueAfterDESCRIBE( RTSPClient* rtspClient, int resu
UsageEnvironment& env = rtspClient->envir(); // alias
StreamClientState& scs = MM->getStreamClientState(); // alias
if (resultCode != 0) {
if( resultCode != 0 ){
MLOG( "Failed to get a SDP description: ");
MLOG( resultString );
delete[] resultString;
@ -682,9 +692,9 @@ void videoLIVE555Source::continueAfterDESCRIBE( RTSPClient* rtspClient, int resu
MLOG( sdpDescription );
// Create a media session object from this SDP description:
scs.session = MediaSession::createNew(env, sdpDescription);
scs.session = MediaSession::createNew( env, sdpDescription );
delete[] sdpDescription; // because we don't need it anymore
if (scs.session == NULL) {
if( scs.session == NULL ){
MLOG( "Failed to create a MediaSession object from the SDP description:" );
MLOG( env.getResultMsg() );
break;
@ -698,7 +708,7 @@ void videoLIVE555Source::continueAfterDESCRIBE( RTSPClient* rtspClient, int resu
// Then, create and set up our data source objects for the session. We do this by iterating over the session's 'subsessions',
// calling "MediaSubsession::initiate()", and then sending a RTSP "SETUP" command, on each one.
// (Each 'subsession' will have its own data source.)
scs.iter = new MediaSubsessionIterator(*scs.session);
scs.iter = new MediaSubsessionIterator( *scs.session );
ME->setupNextSubsession( rtspClient );
return;
} while (0);
@ -771,8 +781,8 @@ void videoLIVE555Source::continueAfterSETUP( RTSPClient* rtspClient, int resultC
};
MLOG( "Created a data sink for the subsession" );
MLOG( streamClientState.subsession->mediumName() );
MLOG( streamClientState.subsession->codecName() );
//MLOG( streamClientState.subsession->mediumName() );
//MLOG( streamClientState.subsession->codecName() );
streamClientState.subsession->miscPtr = rtspClient; // a hack to let subsession handler functions get the "RTSPClient" from the subsession
@ -792,10 +802,11 @@ void videoLIVE555Source::continueAfterSETUP( RTSPClient* rtspClient, int resultC
streamClientState.subsession->rtcpInstance()->setByeHandler( subsessionByeHandler, streamClientState.subsession );
}
} while (0);
} while (0);
delete[] resultString;
// Set up the next subsession, if any:
ME->setupNextSubsession(rtspClient);
ME->setupNextSubsession( rtspClient );
MLOG("Done ContAfterSetup");
};
void videoLIVE555Source::continueAfterPLAY( RTSPClient* rtspClient, int resultCode, char* resultString){
@ -899,7 +910,6 @@ void videoLIVE555Source::streamTimerHandler( void* clientData ){
StreamClientState& scs = rtspClient->getStreamClientState(); // alias
videoLIVE555Source * ME = (videoLIVE555Source *) rtspClient->getSession();
scs.streamTimerTask = NULL;
// Shut down the stream:
ME->shutdownStream(rtspClient);
};
@ -967,6 +977,40 @@ void videoLIVE555Source::shutdownStream(RTSPClient* rtspClient, int exitCode ){
#ifdef DEBUG
MLOG("Shutdown EVT");
#endif
StreamClientState & streamClientState = MM->getStreamClientState(); // alias
//if( resultCode != 0 ){
// MLOG( "Failed to set up the subsession:");
// MLOG( streamClientState.subsession->mediumName() );
// MLOG( streamClientState.subsession->codecName() );
// MLOG( resultString );
// break;
//};
UsageEnvironment & env = rtspClient->envir();
MLOG( "sendTearDown" );
rtspClient->sendTeardownCommand( *streamClientState.session, NULL );
MLOG( "Close Client" );
Medium::close( rtspClient );
MLOG( "SetLOOP" );
_eventLoopWatchVariable = 1;
//MLOG( "Close Session" );
//Medium::close( streamClientState.session );
//MLOG( "Abort Thread" );
//waitThreadEnd( true );
// close RTSP client
//MLOG( "recalm Env" );
//env.reclaim();
//MLOG( "Delete Client" );
//delete MM;
//MLOG( "Delete Sink" );
//delete( (DummySink*) streamClientState.subsession->sink );
//*/
MLOG( "Delete Scheduler" );
m_pUsageEnvironment->reclaim();
m_pUsageEnvironment = NULL;
delete m_pScheduler;
m_pScheduler = NULL;
MLOG( "All Done!" );
m_eMediaStatus = MS_CLOSED;
};
@ -1011,17 +1055,21 @@ bool videoLIVE555Source::_close( void ){
LOG("CLOSE!");
return _stop();
};
bool videoLIVE555Source::_stop( void ){
LOG("STOP!");
shutdownStream( m_pRtspClient );
LOG("SHUTDOWN!");
_eventLoopWatchVariable = 1;
basicThread::waitThreadEnd( true );
LOG("TH ENDED!");
shutdownStream( m_pRtspClient );
return true;
};
bool videoLIVE555Source::isFinished( void ){ return false;};
MediaStateStatus videoLIVE555Source::getStatus( void ){ return MS_UNDEFINED; };
bool videoLIVE555Source::isFinished( void ){
return (m_eMediaStatus == MS_CLOSED);
};
MediaStateStatus videoLIVE555Source::getStatus( void ){
return m_eMediaStatus;
};
bool videoLIVE555Source::setSize( int Width, int Height ){ return false; };
bool videoLIVE555Source::setProportionalByWidth( int Width ){ return false; };
bool videoLIVE555Source::setProportionalByHeight( int Height ){ return false; };

20
lib/data/media/video/videoLive555AVLibSource.h

@ -48,21 +48,19 @@ class CustomRTSPClient: public RTSPClient {
StreamClientState& getStreamClientState() { return this->streamClientState; }
videoLIVE555Source * getSession() { return this->session; }
protected:
virtual ~CustomRTSPClient();
private:
CustomRTSPClient( videoLIVE555Source *session,
UsageEnvironment& env,
char const* rtspURL,
int verbosityLevel,
char const* applicationName,
portNumBits tunnelOverHTTPPortNum );
virtual ~CustomRTSPClient();
};
class DummySink: public MediaSink {
public:
static DummySink* createNew( videoLIVE555Source *session,
UsageEnvironment& env,
MediaSubsession& subsession, // identifies the kind of data that's being received
static DummySink* createNew( videoLIVE555Source *session, UsageEnvironment& env, MediaSubsession& subsession, // identifies the kind of data that's being received
char const* streamId = NULL, int w = -1, int h = -1, int ww = -1, int hh = -1 ); // identifies the stream itself (optional)
virtual ~DummySink();
private:
@ -79,12 +77,8 @@ class DummySink: public MediaSink {
// called only by "createNew()"
static void afterGettingFrame(void* clientData, unsigned frameSize,
unsigned numTruncatedBytes,
struct timeval presentationTime,
unsigned durationInMicroseconds);
void afterGettingFrame(unsigned frameSize, unsigned numTruncatedBytes,
struct timeval presentationTime, unsigned durationInMicroseconds);
static void afterGettingFrame( void* clientData, unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds );
void afterGettingFrame( unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds );
//void saveFrameToFile()
private:
// redefined virtual functions:
@ -94,7 +88,6 @@ class DummySink: public MediaSink {
void setSprop( u_int8_t const* prop, unsigned size );
private:
videoLIVE555Source * m_pSession;
private:
uint8_t * m_pReceiveBuffer;
uint8_t * m_pReceiveBufferAV;
MediaSubsession & m_sSubSession;
@ -102,7 +95,6 @@ class DummySink: public MediaSink {
H264or5VideoFileSink * qtOut;
FILE * m_pOutFile[2];
uint8_t m_nCurrentOutFile;
private:
AVCodec * m_pCodec;
AVCodecContext * m_pCodecContext;
@ -144,7 +136,7 @@ class videoLIVE555Source : public basicMediaSource, public basicThread {
UsageEnvironment * m_pUsageEnvironment;
MediaSession * m_pMediaSession;
char _eventLoopWatchVariable;
volatile char _eventLoopWatchVariable;
CustomRTSPClient * m_pRtspClient;
DummySink * m_pSink;

Loading…
Cancel
Save