diff options
author | phintuka <phintuka> | 2007-01-01 08:37:47 +0000 |
---|---|---|
committer | phintuka <phintuka> | 2007-01-01 08:37:47 +0000 |
commit | cfedfb7cc965cb206e5d28a51b4aa29f25c7dbd9 (patch) | |
tree | 6bf3b88f57a1eb5d010f8ed279b9db07dd4678b1 | |
parent | ad87cfe7603b648734caa7309881af0d7961dfcf (diff) | |
download | xineliboutput-cfedfb7cc965cb206e5d28a51b4aa29f25c7dbd9.tar.gz xineliboutput-cfedfb7cc965cb206e5d28a51b4aa29f25c7dbd9.tar.bz2 |
Poll before every PES frame when replaying MPEG2 ES still image
Added locking to file name freeing in playfile (it can be accessed from frontend server thread)
File name is now available during playfile execution (it is needed in http server if client wants to
stream file over http)
-rw-r--r-- | frontend.c | 47 |
1 files changed, 28 insertions, 19 deletions
@@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: frontend.c,v 1.25 2006-12-24 16:22:35 phintuka Exp $ + * $Id: frontend.c,v 1.26 2007-01-01 08:37:47 phintuka Exp $ * */ @@ -463,31 +463,35 @@ int cXinelibThread::Play_Mpeg1_PES(const uchar *data1, int len) bool cXinelibThread::Play_Mpeg2_ES(const uchar *data, int len, int streamID) { - static uchar hdr[] = {0x00,0x00,0x01,0xe0, 0x00,0x00,0x80,0,0}; /* mpeg2 */ + static uchar hdr_vid[] = {0x00,0x00,0x01,0xe0, 0x00,0x00,0x80,0x00,0x00}; /* mpeg2 */ + static uchar hdr_pts[] = {0x00,0x00,0x01,0xe0, 0x00,0x08,0x80,0x80, + 0x05,0x00,0x00,0x00, 0x00,0x00}; /* mpeg2 */ + static uchar seq_end[] = {0x00,0x00,0x01,0xe0, 0x00,0x07,0x80,0x00, + 0x00, + 0x00,0x00,0x01,0xB7}; /* mpeg2 */ int todo = len, done = 0, hdrlen = 9/*sizeof(hdr)*/; uchar *frame = new uchar[PES_CHUNK_SIZE+32]; + cPoller p; - static uchar hdr_pts[] = {0x00,0x00,0x01,0xe0, 0x00,0x08,0x80,0x80, - 0x05,0x00,0x00,0x00, 0x00,0x00}; /* mpeg2 */ hdr_pts[3] = (uchar)streamID; + Poll(p, 100); Play_PES(hdr_pts, sizeof(hdr_pts)); - hdr[3] = (uchar)streamID; + hdr_vid[3] = (uchar)streamID; while(todo) { int blocklen = todo; if(blocklen > ((PES_CHUNK_SIZE - hdrlen) & 0xfffc)) blocklen = (PES_CHUNK_SIZE - hdrlen) & 0xfffc; - hdr[4] = ((blocklen+3)&0xff00)>>8; - hdr[5] = ((blocklen+3)&0xff); + hdr_vid[4] = ((blocklen+3)&0xff00)>>8; + hdr_vid[5] = ((blocklen+3)&0xff); - memcpy(frame, hdr, hdrlen); + memcpy(frame, hdr_vid, hdrlen); memcpy(frame+hdrlen, data+done, blocklen); done += blocklen; todo -= blocklen; - cPoller p; Poll(p, 100); if(blocklen+hdrlen != Play_PES(frame,blocklen+hdrlen)) { @@ -498,11 +502,9 @@ bool cXinelibThread::Play_Mpeg2_ES(const uchar *data, int len, int streamID) // append sequence end code to video if((streamID & 0xF0) == 0xE0) { - static uchar seqend[] = {0x00,0x00,0x01,0xe0, 0x00,0x07,0x80,0x00, - 0x00, - 0x00,0x00,0x01,0xB7}; /* mpeg2 */ - seqend[3] = (uchar)streamID; - Play_PES(seqend, 13); + seq_end[3] = (uchar)streamID; + Poll(p, 100); + Play_PES(seq_end, sizeof(seq_end)); } delete[] frame; @@ -646,18 +648,25 @@ bool cXinelibThread::PlayFile(const char *FileName, int Position, snprintf(buf, sizeof(buf), "PLAYFILE %s %d %s %s\r\n", LoopPlay ? "Loop" : "", Position, vis, FileName ? FileName : ""); buf[sizeof(buf)-1] = 0; + + if(FileName) { + Lock(); + if(m_FileName) + free(m_FileName); + m_FileName = strdup(FileName); + m_bPlayingFile = true; + Unlock(); + } + int result = PlayFileCtrl(buf); if(!FileName || result != 0) { + Lock(); m_bPlayingFile = false; if(m_FileName) free(m_FileName); m_FileName = NULL; - } else { - if(m_FileName) - free(m_FileName); - m_FileName = strdup(FileName); - m_bPlayingFile = true; + Unlock(); } return (!GetStopSignal()) && (result==0); |