translist.erase(hcw);
}
-void Remote::LoadKeysConfig(char *cfg)
+void Remote::LoadKeysConfig(VDR *vdr,const char *cfg)
{
- char *start = cfg;
- start = strchr(cfg,'H')+1;
- while ((start-1) != NULL)
- {
- ULONG ul1, ul2;
- ULONG uc;
- if (sscanf(start,"%lXI%lXK%lX",&ul1,&ul2,&uc) == 3)
- {
- translist[((ULLONG) ul1) | ((ULLONG)ul2) << 32]=(UCHAR)uc;
- }
- start = strchr(start, 'H')+1;
- }
+ ULONG number=0;
+ if (sscanf(cfg,"%ld",&number) != 1) return;
+ Log::getInstance()->log("Remote", Log::INFO, "Config General/Remote keys num keys %d",number);
+ char buffer[1024];
+ char keybuf[1024];
+ for (int i = 0; i < number; i++) {
+ sprintf(keybuf, "RemoteKey%d", i);
+ const char *keytrans = vdr->configLoad("General", keybuf);
+ if (keytrans) {
+ ULONG ul1, ul2;
+ ULONG uc;
+ if (sscanf(keytrans, "%lXI%lXK%lX", &ul1, &ul2, &uc) == 3) {
+ translist[((ULLONG) ul1) | ((ULLONG) ul2) << 32] = (UCHAR) uc;
+ }
+ }
+
+ }
}
-char *Remote::SaveKeysConfig()
+void Remote::SaveKeysConfig()
{
- int length=21*translist.size() +1;
- char *output=new char[length];
- char *current=output;
+ int number=0;
+ char buffer[1024];
+ char keybuf[1024];
RemoteTranslationList::const_iterator it;
for (it = translist.begin(); it != translist.end(); it++)
{
- current+=snprintf(current,21,"H%08lXI%08lXK%02X",
+ sprintf(buffer,"%08lXI%08lXK%02X",
(ULONG)it->first ,(ULONG) (it->first >> 32), it->second);
+ sprintf(keybuf,"RemoteKey%d",number);
+ VDR::getInstance()->configSave("General",keybuf,buffer);
+ number++;
}
- return output;
+ sprintf(buffer,"%d",number);
+ VDR::getInstance()->configSave("General","RemoteKeyNum",buffer);
}
{
// Set remote keys
char * config;
- config = vdr->configLoad("General", "Remote keys");
+ config = vdr->configLoad("General", "RemoteKeyNum");
if (config)
{
- Log::getInstance()->log("Remote", Log::INFO, "Config General/Remote keys load");
- LoadKeysConfig(config);
+ Log::getInstance()->log("Remote", Log::INFO, "Config General/Remote keys load");
+ LoadKeysConfig(vdr,config);
delete[] config;
}
else
bool Remote::saveOptionstoServer()
{
- char *keyscon=SaveKeysConfig();
- VDR::getInstance()->configSave("General","Remote keys",keyscon);
- delete [] keyscon;
+ SaveKeysConfig();
return true;
}
omx_running=true;
clock_mutex.Unlock();
updateMode();
- threadStart();
setClockExecutingandRunning();
}
input_bufs_omx_all.clear();
input_bufs_omx_free.clear();
- input_bufs_omx_present.clear();
- input_time_present.clear();
- //input_time_pts.clear();
- //input_is_last.clear();
input_bufs_omx_mutex.Unlock();
}
OMX_ERRORTYPE error;
omx_running=false;
Log::getInstance()->log("Video", Log::DEBUG, "enter deallocatecodecsomx");
- threadStop();
-
if (cur_input_buf_omx) {
cur_input_buf_omx->nFlags|=OMX_BUFFERFLAG_EOS;
lastrefvideotime=0;
lastreftimeOMX=0;
lastreftimePTS=0;
- //cur_pts=0;
-}
-/*
-long long VideoOMX::GetCurrentSystemTime()
-{
- struct timespec ts;
- clock_gettime(CLOCK_MONOTONIC, &ts);
- return ts.tv_sec*10000000LL+ts.tv_nsec/100LL;
-}
-
-void VideoOMX::WaitUntil(long long time)
-{
- struct timespec interval;
- interval.tv_sec=time/10000000LL;
- interval.tv_nsec=(time %10000000LL)*100LL;
- while (clock_nanosleep(CLOCK_MONOTONIC,TIMER_ABSTIME,&interval,NULL)==EINTR) {
- //Log::getInstance()->log("Video", Log::DEBUG, "Wait until multi");
-
- };
}
-bool VideoOMX::FrameSkip(long long pts)
-{
- //ok first calculate the absolute time
- bool skip=false;
- long long target_time=pts-playbacktimeoffset;
- // we have to wait untile the next frame
- long long offset=Demuxer::getInstance()->getFrameRate();
- if (offset==0) offset=25;
- offset=-2*10000000LL/offset;
- target_time+=offset;
- long long current_time=GetCurrentSystemTime();
- if (!skipping) {
- if ((target_time-current_time)<-400000LL) {
- skip=true; // we are too slow
- skipping=true;
- /* Log::getInstance()->log("Video", Log::DEBUG,
- "Skipping frames1 %lld %lld %d",target_time-current_time,pts,Demuxer::getInstance()->getFrameRate());
- Log::getInstance()->log("Video", Log::DEBUG, "skip detail pts: %lld target: %lld sys: %lld off: %lld diff %lld",pts,target_time,current_time,offset,
- target_time-current_time);*
- } else {
- skipping=false;
- }
- } else {
- if ((target_time - current_time) < 0000LL) { //skip a bit more
- skip = true; // we are too slow
- skipping = true;
-/* Log::getInstance()->log("Video", Log::DEBUG,"Skipping frames2 %lld %lld %d",target_time-current_time,pts,Demuxer::getInstance()->getFrameRate());
- Log::getInstance()->log("Video", Log::DEBUG, "skip detail pts: %lld target: %lld sys: %lld off: %lld diff %lld",pts,target_time,current_time,offset,
- target_time-current_time);*
- } else {
- skipping = false;
- }
-
- }
-
- return skip;
-}
-
-void VideoOMX::FrameWaitforDisplay(long long pts)
-{
- //ok first calculate the absolute time
- long long target_time=pts-playbacktimeoffset;
- // we have to wait untile the next frame
- long long offset=Demuxer::getInstance()->getFrameRate();
- long long current_time=GetCurrentSystemTime();
- if (offset==0) offset=25;
- offset=-3*10000000LL/offset;
- target_time+=offset;
- //Log::getInstance()->log("Video", Log::DEBUG, "Wait for display pts: %lld tg: %lld sys: %lld off: %lld diff %lld po: %lld",pts,target_time,current_time,offset,
- // target_time-current_time,playbacktimeoffset);
- if ((target_time-current_time)>1000000LL) target_time=current_time+1000000LL; // something is wrong do not wait too long
- //Log::getInstance()->log("Video", Log::DEBUG, "Wait for display pts: %lld tg: %lld sys: %lld off: %lld diff %lld po: %lld",pts,target_time,current_time,offset,
- // target_time-current_time,playbacktimeoffset);
-
- WaitUntil(target_time);
- //Log::getInstance()->log("Video", Log::DEBUG, "Wait for display out %lld",GetCurrentSystemTime());
-}
-
-void VideoOMX::AdjustAudioPTS(long long pts)
-{
- long long newplaybacktimeoffset=pts-GetCurrentSystemTime();
- if ((newplaybacktimeoffset-1000000LL)>playbacktimeoffset
- || (newplaybacktimeoffset+1000000LL)<playbacktimeoffset) {
- Log::getInstance()->log("Video", Log::DEBUG, "Adjust Playbackoffsettime o: %lld n: %lld",
- playbacktimeoffset,newplaybacktimeoffset);
- playbacktimeoffset=newplaybacktimeoffset;
-
- }
-}
-*/
-void VideoOMX::threadPostStopCleanup()
-{
- //Doing nothing
- //goo;
- Log::getInstance()->log("Video", Log::DEBUG,
- "end thread");
-}
-
-
-void VideoOMX::threadMethod()
-{
- Log::getInstance()->log("Video", Log::DEBUG,
- "start thread");
- while (true) {
-
- OMX_BUFFERHEADERTYPE* pict=NULL;
- long long time;
- //bool islast;
- if (!paused) {
- input_bufs_omx_mutex.Lock();
- if (input_bufs_omx_present.size()>0) {
- //cur_pts=input_time_pts.front();
- pict=input_bufs_omx_present.front();
- time=input_time_present.front();
- //islast=input_is_last.front();
- input_bufs_omx_present.pop_front();
- input_time_present.pop_front();
- //input_time_pts.pop_front();
- //input_is_last.pop_front();
- }
- input_bufs_omx_mutex.Unlock();
- }
-
- if ( pict) {
- //Log::getInstance()->log("Video", Log::DEBUG,
- // "Got pict");
- if (time!=0 && /*FrameSkip(time)*/false && !(pict->nFlags &OMX_BUFFERFLAG_STARTTIME)) {
-
- input_bufs_omx_mutex.Lock();
- input_bufs_omx_free.push_back(pict);
- input_bufs_omx_mutex.Unlock();
- //Log::getInstance()->log("Video", Log::DEBUG, "threadMethod Frameskip");
-
- } else {
- // Log::getInstance()->log("Video", Log::DEBUG,
- // "prot empty this buffer in");
- //if (islast) FrameWaitforDisplay(time);
- OMX_ERRORTYPE error = ProtOMXEmptyThisBuffer(omx_vid_dec, pict);
- if (error != OMX_ErrorNone) {
- Log::getInstance()->log("Video", Log::DEBUG,
- "OMX_EmptyThisBuffer failed %x", error);
- }
- //Log::getInstance()->log("Video", Log::DEBUG,
- // "time %lld",time);
- if (deint_first_frame && dodeint) DeinterlaceFix();
-
- }
- } else {
- MILLISLEEP(1);
- }
-
- threadCheckExit();
- }
- Log::getInstance()->log("Video", Log::DEBUG,
- "end thread");
-}
void VideoOMX::DeinterlaceFix()
{
}
-void VideoOMX::PutBufferToPres(OMX_BUFFERHEADERTYPE* buffer, long long time, /*long long pts,*/bool islast)
+void VideoOMX::PutBufferToPres(OMX_BUFFERHEADERTYPE* buffer)
{
- input_bufs_omx_mutex.Lock();
- input_bufs_omx_present.push_back(buffer);
- input_time_present.push_back(time);
- //input_time_pts.push_back(pts);
-// input_is_last.push_back(islast);
- input_bufs_omx_mutex.Unlock();
+
+ OMX_ERRORTYPE error = ProtOMXEmptyThisBuffer(omx_vid_dec, buffer);
+ if (error != OMX_ErrorNone) {
+ Log::getInstance()->log("Video", Log::DEBUG,
+ "OMX_EmptyThisBuffer failed %x", error);
+ }
+ if (deint_first_frame && dodeint) DeinterlaceFix();
}
if (!omx_running) return 0; // if we are not runnig do not do this
if (paused) return 0; //Block if we pause
+ //Log::getInstance()->log("Video", Log::DEBUG, "DeliverMediaPacketOMX time %lld",packet.presentation_time);
+ if (packet.synched && packet.presentation_time < 0) {
+ *samplepos = packet.length;
+ firstsynched = false;
+ Log::getInstance()->log("Video", Log::DEBUG,
+ "DeliverMediaPacketOMX Frameskip");
+ return packet.length;
+ }
+
/*if (packet.synched && FrameSkip(packet.presentation_time)) {
*samplepos=packet.length;
Log::getInstance()->log("Video", Log::DEBUG, "DeliverMediaPacketOMX Frameskip");
if (packet.disconti) {
firstsynched=false;
if (cur_input_buf_omx) {
- PutBufferToPres(cur_input_buf_omx, lastreftimeOMX,/*lastreftimePTS,*/ true);
+ PutBufferToPres(cur_input_buf_omx);
cur_input_buf_omx=NULL;
}
}
if ( packet.synched ) {
if (cur_input_buf_omx) {
cur_input_buf_omx->nFlags|=OMX_BUFFERFLAG_ENDOFFRAME;
- PutBufferToPres(cur_input_buf_omx, lastreftimeOMX,/*lastreftimePTS,*/true);
+ PutBufferToPres(cur_input_buf_omx);
cur_input_buf_omx=NULL;//write out old data
*samplepos+=cancopy;
// push old buffer out
- PutBufferToPres(cur_input_buf_omx, lastreftimeOMX,/*lastreftimePTS,*/false);
+ PutBufferToPres(cur_input_buf_omx);
cur_input_buf_omx=NULL;
// get5 new buffer
input_bufs_omx_mutex.Lock();
}
cur_input_buf_omx->nTimeStamp = intToOMXTicks(0);
- PutBufferToPres(cur_input_buf_omx, 0,/*0,*/false);
+ PutBufferToPres(cur_input_buf_omx);
cur_input_buf_omx = NULL;
if (!cur_input_buf_omx) {
}
cur_input_buf_omx->nTimeStamp = intToOMXTicks(0);
- PutBufferToPres(cur_input_buf_omx, 0,/*0,*/false);
+ PutBufferToPres(cur_input_buf_omx);
cur_input_buf_omx = NULL;
Log::getInstance()->log("Video", Log::DEBUG,
"EnterIframePlayback");
if (cur_input_buf_omx) {
- PutBufferToPres(cur_input_buf_omx, lastreftimeOMX,/* lastreftimePTS,*/true);
+ PutBufferToPres(cur_input_buf_omx);
cur_input_buf_omx = NULL;
}
- input_bufs_omx_mutex.Lock();
- while (input_bufs_omx_present.size()) {
- input_bufs_omx_free.push_back(input_bufs_omx_present.front());
- input_bufs_omx_present.pop_front();
- }
- input_time_present.clear();
- /*input_time_pts.clear();
- input_is_last.clear();*/
- input_bufs_omx_mutex.Unlock();
Log::getInstance()->log("Video", Log::DEBUG,
"EnterIframePlayback 2");
((AudioOMX*)Audio::getInstance())->DeAllocateCodecsOMX();