#define STRCASECMP _stricmp
#define STRCASESTR StrStrI
/* #define STRTOULL _strtoui64 */
+ #define STRTOUL strtoul
#define CLOSESOCKET closesocket
#else
data[5] = (length & 0xFF);
return 1;
}
-#ifndef NEW_DEMUXER
+
int Demuxer::PESPacket::submit()
-#else
-int Demuxer::PESPacket::submit(ULLONG cur_pos)
-#endif
{
if (submitted >= size) return 0;
if (!closed) parseDetails();
{
if (dx->video_current == -1) dx->video_current = packetType;
if (dx->video_current == packetType && !dx->vid_seeking)
-#ifndef NEW_DEMUXER
sent = dx->videostream.put(data+submitted, size-submitted);
-#else
- sent = dx->videostream.put(data+submitted, size-submitted,cur_pos);
-#endif
else
sent = size-submitted;
}
{
if (dx->audio_current == -1) dx->audio_current = packetType;
if (dx->audio_current == packetType && !dx->aud_seeking)
-#ifndef NEW_DEMUXER
sent = dx->audiostream.put(data+submitted, size-submitted);
-#else
- sent = dx->audiostream.put(data+submitted, size-submitted,cur_pos);
-#endif
else
sent = size-submitted;
}
PESPacket();
void init(UCHAR type);
int write(UCHAR* buf, int len);
-#ifndef NEW_DEMUXER
int submit();
-#else
- int submit(ULLONG cur_pos);
-#endif
protected:
UCHAR data[0x10000];
UINT length, size;
virtual int scan(UCHAR* buf, int len) = 0;
virtual int findVideoPTS(UCHAR* buf, int len, ULLONG* dest) = 0;
-#ifndef NEW_DEMUXER
virtual int put(UCHAR* buf, int len) = 0;
-#else
- virtual int put(UCHAR* buf, int len,ULLONG cur_pos) = 0;
-#endif
virtual void setFrameNum(ULONG frame) {}
virtual ULONG getFrameNumFromPTS(ULLONG pts) {return 0;}
Log::getInstance()->log("Demuxer", Log::DEBUG, "setFrameNum %d", frame);
}
-#ifndef NEW_DEMUXER
int DemuxerVDR::put(UCHAR* buf, int len)
-#else
-int DemuxerVDR::put(UCHAR* buf, int len, ULLONG cur_pos)
-#endif
{
int ret = 0; // return number of bytes consumed
-
-#ifdef NEW_DEMUXER
- ULLONG current_position = cur_pos;
-#endif
-
if (submitting)
{
-#ifndef NEW_DEMUXER
if (packet.submit() == 0) // Still full!
-#else
- if (packet.submit(current_position) == 0) // Still full!
-#endif
return ret;
else
submitting = false;
packet.write(buf, state);
buf += state; len -= state; ret += state;
state = 0;
-#ifndef NEW_DEMUXER
- if (packet.submit() == 0) // Stream is full
-#else
- if (packet.submit(current_position) == 0) // Stream is full
-#endif
+ if (packet.submit() == 0) // Stream is full
{
submitting = true;
return ret;
break;
}
-#ifdef NEW_DEMUXER
- current_position++;
-#endif
-
if (state == -6) // Packet header complete
{
if (len >= packetLength) // The entire packet is available.
{
packet.write(buf, packetLength);
buf += packetLength; len -= packetLength; ret += packetLength;
-#ifdef NEW_DEMUXER
- current_position+=(ULLONG)packetLength;
-#endif
state = 0;
-#ifndef NEW_DEMUXER
if (packet.submit() == 0) // Stream is full
-#else
- if (packet.submit(current_position) == 0) // Stream is full
-#endif
{
submitting = true;
return ret;
ULLONG difference = (1LL<<33);
ULONG ref_frame = 0;
int total = 0, actual = 0;
- pthread_mutex_lock(&pts_map_mutex);
+ pts_map_mutex.Lock();
PTSMap::iterator iter = pts_map.begin();
while (iter != pts_map.end())
{
iter = pts_map.begin(); iter++;
pts_map.erase(iter, pts_map.end());
}
- pthread_mutex_unlock(&pts_map_mutex);
+ pts_map_mutex.Unlock();
if (total > 1 && actual == 1)
Log::getInstance()->log("Demuxer", Log::DEBUG, "DELETED REFERENCES");
if (actual > 1)
if (seq_header && pts != PTS_INVALID)
{
PTSMapEntry me;
- pthread_mutex_lock(&(dx->pts_map_mutex));
+ dx->pts_map_mutex.Lock();
if (dx->pts_map.empty())
{
me.pts = pts;
me.frame = frame_num;
- pthread_mutex_unlock(&(dx->pts_map_mutex));
+ dx->pts_map_mutex.Unlock();
Log::getInstance()->log("Demuxer", Log::DEBUG, "+* PTS INIT *+ %llu %u", me.pts, me.frame);
- pthread_mutex_lock(&(dx->pts_map_mutex));
+ dx->pts_map_mutex.Lock();
dx->pts_map.push_front(me);
}
me = dx->pts_map.front();
- pthread_mutex_unlock(&(dx->pts_map_mutex));
+ dx->pts_map_mutex.Unlock();
UINT fps = Video::getInstance()->getFPS();
ULLONG pts_expected = me.pts + 90000*(frame_num - me.frame) / fps;
Log::getInstance()->log("Demuxer", Log::DEBUG, "+* PTS JUMP *+ %llu %u", pts, frame_num);
me.pts = pts;
me.frame = frame_num;
- pthread_mutex_lock(&(dx->pts_map_mutex));
+ dx->pts_map_mutex.Lock();
dx->pts_map.push_front(me);
- pthread_mutex_unlock(&(dx->pts_map_mutex));
+ dx->pts_map_mutex.Unlock();
}
}
}
#ifndef DEMUXERVDR_H
#define DEMUXERVDR_H
-#include "pthread.h"
+#include "mutex.h"
#include <deque>
#include "demuxer.h"
#include "defines.h"
void flush();
int scan(UCHAR* buf, int len);
int findVideoPTS(UCHAR* buf, int len, ULLONG* dest);
-#ifndef NEW_DEMUXER
int put(UCHAR* buf, int len);
-#else
- int put(UCHAR* buf, int len,ULLONG cur_pos);
-#endif
void setFrameNum(ULONG frame);
ULONG getFrameNumFromPTS(ULLONG pts);
typedef struct { ULLONG pts; ULONG frame; } PTSMapEntry;
typedef std::deque<PTSMapEntry> PTSMap;
PTSMap pts_map;
- pthread_mutex_t pts_map_mutex;
+ Mutex pts_map_mutex;
};
#endif
-OBJECTS1 = command.o log.o tcp.o dsock.o thread.o timers.o i18n.o \\r
- message.o messagequeue.o \\r
- vdr.o recman.o recording.o channel.o rectimer.o event.o directory.o \\r
- player.o vfeed.o afeed.o \\r
- demuxer.o demuxervdr.o stream.o draintarget.o \\r
- viewman.o box.o region.o colour.o view.o \\r
- vinfo.o vwallpaper.o vvolume.o vrecordinglist.o vlivebanner.o vmute.o \\r
- vtimerlist.o vtimeredit.o voptionsmenu.o vrecordingmenu.o vquestion.o \\r
- vchannellist.o vwelcome.o vvideolive.o vvideorec.o vepgsettimer.o \\r
- vchannelselect.o vserverselect.o vconnect.o voptions.o vepg.o vrecmove.o \\r
- widget.o wselectlist.o wjpeg.o wsymbol.o wbutton.o woptionbox.o wtextbox.o \\r
- fonts/helvB24.o fonts/helvB18.o \\r
+OBJECTS1 = command.o log.o tcp.o dsock.o thread.o timers.o i18n.o mutex.o \\r
+ message.o messagequeue.o \\r
+ vdr.o recman.o recording.o channel.o rectimer.o event.o directory.o\\r
+ player.o vfeed.o afeed.o \\r
+ demuxer.o demuxervdr.o stream.o draintarget.o \\r
+ viewman.o box.o region.o colour.o view.o \\r
+ vinfo.o vquestion.o vwallpaper.o vrecordinglist.o vlivebanner.o \\r
+ vmute.o vvolume.o voptions.o \\r
+ vtimerlist.o vtimeredit.o voptionsmenu.o vrecordingmenu.o \\r
+ vchannellist.o vwelcome.o vvideolive.o vvideorec.o vepgsettimer.o \\r
+ vchannelselect.o vserverselect.o vconnect.o vepg.o vrecmove.o \\r
+ widget.o wselectlist.o wjpeg.o wsymbol.o wbutton.o \\r
+ woptionbox.o wtextbox.o \\r
+ fonts/helvB24.o fonts/helvB18.o \\r
remote.o led.o mtd.o video.o audio.o osd.o surface.o\r
UINT writeLength;
UINT thisWrite;
UINT preBufferTotal = 0;
-#ifdef NEW_DEMUXER
- ULLONG currentposition;
-#endif
VDR* vdr = VDR::getInstance();
}
threadBuffer = vdr->getBlock(feedPosition, askFor, &thisRead);
-#ifdef NEW_DEMUXER
- currentposition=feedPosition;
-#endif
+
if (!vdr->isConnected())
{
doConnectionLost();
while(writeLength < thisRead)
{
-#ifndef NEW_DEMUXER
thisWrite = demuxer->put(threadBuffer + writeLength, thisRead - writeLength);
-#else
- thisWrite = demuxer->put(threadBuffer + writeLength, thisRead - writeLength,
- currentposition+(ULLONG)writeLength);
-#endif
writeLength += thisWrite;
// logger->log("Player", Log::DEBUG, "Put %i to demuxer", thisWrite);
return ret;
}
#else
-int Stream::put(UCHAR* inbuf, int len,ULLONG curpos)
+int Stream::put(UCHAR* inbuf, int len)
{
int ret = 0;
int tail = bufferTail;
MediaPacket newPacket;
newPacket.length=len;
newPacket.pos_buffer=0;
- newPacket.recording_byte_pos=curpos;
newPacket.synched=false;
newPacket.disconti=false;
newPacket.pts=0;
int init(DrainTarget* tdt, int bufsize);
void shutdown();
void flush();
-#ifndef NEW_DEMUXER
int put(UCHAR* inbuf, int len);
-#else
- int put(UCHAR* inbuf, int len,ULLONG curpos);
-#endif
-
int drain();
private:
startoffset=0;\r
lastrefaudiotime=0;\r
lastrefvideotime=0;\r
- lastreftimeBYTE=0;\r
lastreftimeRT=0;\r
+ lastreftimePTS=0;\r
firstsynched=false;\r
cur_audio_media_sample=NULL;\r
cur_video_media_sample=NULL;\r
startoffset=sourcefilter->getStartOffset();\r
ncr_time-=startoffset;\r
ncr_time-=lastreftimeRT;\r
- ULLONG result=frameNumberToTimecode(\r
- VDR::getInstance()->frameNumberFromPosition(lastreftimeBYTE));\r
+ /* ULLONG result=frameNumberToTimecode(\r
+ VDR::getInstance()->frameNumberFromPosition(lastreftimeBYTE));*/\r
+ ULLONG result=lastreftimePTS;\r
result+=(ULLONG)(ncr_time/10000LL*90LL);\r
return result;\r
\r
else ms->SetPreroll(FALSE);\r
/*Timecode handling*/\r
lastreftimeRT=reftime1;\r
- lastreftimeBYTE=packet.recording_byte_pos;\r
+ lastreftimePTS=packet.pts;\r
\r
}else {\r
ms->SetSyncPoint(FALSE);\r
startoffset=0;\r
lastrefaudiotime=0;\r
lastrefvideotime=0;\r
- lastreftimeBYTE=0;\r
lastreftimeRT=0;\r
+ lastreftimePTS=0;\r
\r
\r
}\r
bool videoon;\r
UCHAR pseudotvsize;\r
REFERENCE_TIME lastreftimeRT;\r
- ULLONG lastreftimeBYTE;\r
+ ULLONG lastreftimePTS;\r
unsigned int videoposx;\r
unsigned int videoposy;\r
#ifdef DS_DEBUG\r