Inzwischen läuft das DLNA-Plugin auf einigen Testsystemen schon ganz rund und auch mehrere TV-Geräte sollen mit dem VDR zurechtkommen. Allerdings gibt es immer wieder Aussetzer oder generell kein stabiles TV-Bild. Im Log stehen die von mir erzeugten Fehler, dass zu wenige Daten da sind oder nicht auf den Strom synchronisiert werden konnte. Unten steht die Hauptfunktion des LiveReceivers, welches den Stream analysieren soll:
void cLiveReceiver::Action(void){
MESSAGE(VERBOSE_LIVE_TV, "Started buffering...");
while(this->Running()){
int bytesRead;
MESSAGE(VERBOSE_BUFFERS, "Buffer is filled with %d bytes", this->mLiveBuffer->Available());
uchar* bytes = this->mLiveBuffer->Get(bytesRead);
if(bytes){
int count = this->mFrameDetector->Analyze(bytes, bytesRead);
if(count){
MESSAGE(VERBOSE_BUFFERS, "%d bytes analyzed", count);
MESSAGE(VERBOSE_BUFFERS, "%2.2f FPS", this->mFrameDetector->FramesPerSecond());
if(!this->Running() && this->mFrameDetector->IndependentFrame())
break;
if(this->mFrameDetector->Synced()){
MESSAGE(VERBOSE_BUFFERS, "Frame detector synced to data stream");
if(this->mFrameDetector->IndependentFrame()){
this->mOutputBuffer->Put(this->mPatPmtGenerator.GetPat(), TS_SIZE);
int i = 0;
while(uchar* pmt = this->mPatPmtGenerator.GetPmt(i)){
this->mOutputBuffer->Put(pmt, TS_SIZE);
}
}
int bytesWrote = this->mOutputBuffer->Put(bytes, count);
if(bytesWrote != count){
this->mLiveBuffer->ReportOverflow(count - bytesWrote);
}
MESSAGE(VERBOSE_BUFFERS, "Wrote %d to output buffer", bytesWrote);
if(bytesWrote){
this->mLiveBuffer->Del(bytesWrote);
}
else {
cCondWait::SleepMs(100);
}
}
else {
ERROR("Cannot sync to stream");
}
}
}
}
MESSAGE(VERBOSE_LIVE_TV, "Receiver was detached from device");
}
int cLiveReceiver::read(char* buf, size_t buflen){
int bytesRead;
if(!this->IsAttached())
bytesRead = -1;
else {
int WaitTimeout = RECEIVER_WAIT_ON_NODATA_TIMEOUT;
// Wait until the buffer size is at least half the requested buffer length
while((unsigned)this->mOutputBuffer->Available() < (buflen / 2) ){
WARNING("Too few data, waiting...");
cCondWait::SleepMs(RECEIVER_WAIT_ON_NODATA);
if(!this->IsAttached()){
MESSAGE(VERBOSE_LIVE_TV, "Lost device...");
return 0;
}
WaitTimeout-=RECEIVER_WAIT_ON_NODATA;
if(WaitTimeout<=0){
double seconds = (RECEIVER_WAIT_ON_NODATA_TIMEOUT/1000);
ERROR("No data received for %4.2f seconds, aborting.", seconds);
this->Activate(false);
return 0;
}
}
uchar* buffer = this->mOutputBuffer->Get(bytesRead);
if(buffer){
if(buflen > (size_t)bytesRead){
memcpy(buf,(char*)buffer,bytesRead);
this->mOutputBuffer->Del(bytesRead);
}
else {
memcpy(buf,(char*)buffer,buflen);
this->mOutputBuffer->Del(buflen);
}
}
}
MESSAGE(VERBOSE_BUFFERS, "Read %d bytes from live feed", bytesRead);
return bytesRead;
}
Alles anzeigen
Und hier die komplette .cpp-Datei:
http://de.pastebin.ca/1743971
Ich hoffe nun auf eure Hilfe. Eventuell hat jemand eine Idee, wieso der Stream mit zu wenig Daten gefüttert wird, obwohl der VDR ständig neue nachwirft. Für mich fraglich ist die Aufgabe des FrameDetectors. Was muss gemacht werden, damit der Stream auch ohne 100%iger Signalqualität gestreamt werden kann?