diff options
author | Martin Schirrmacher <vdr.skinflatplus@schirrmacher.eu> | 2014-08-04 16:08:18 +0200 |
---|---|---|
committer | Martin Schirrmacher <vdr.skinflatplus@schirrmacher.eu> | 2014-08-04 16:08:18 +0200 |
commit | ea7abbd4c040a5b5041a329db0e5a2beb1b8a7fb (patch) | |
tree | ed3d2f96841a1f7be70aa25458c86a7a7a10aaa7 | |
parent | 295552e49b7a5b61b6f3e5064524fe626e757380 (diff) | |
download | skin-flatplus-ea7abbd4c040a5b5041a329db0e5a2beb1b8a7fb.tar.gz skin-flatplus-ea7abbd4c040a5b5041a329db0e5a2beb1b8a7fb.tar.bz2 |
fixes in show bitrate
-rw-r--r-- | config.c | 2 | ||||
-rw-r--r-- | displaychannel.c | 21 | ||||
-rw-r--r-- | femonreceiver.c | 272 | ||||
-rw-r--r-- | femonreceiver.h | 88 |
4 files changed, 195 insertions, 188 deletions
@@ -25,7 +25,7 @@ cFlatConfig::cFlatConfig(void) { ChannelResolutionAspectShow = true; ChannelSimpleAspectFormat = true; ChannelBitrateShow = false; - ChannelBitrateShowCalcInterval = 50; + ChannelBitrateShowCalcInterval = 20; RecordingResolutionAspectShow = true; RecordingFormatShow = true; diff --git a/displaychannel.c b/displaychannel.c index 3583e903..c1a7593b 100644 --- a/displaychannel.c +++ b/displaychannel.c @@ -502,7 +502,7 @@ void cFlatDisplayChannel::SignalQualityDraw(void) { cFont *SignalFont = cFont::CreateFont(Setup.FontOsd, Config.decorProgressSignalSize); int top = fontHeight*2 + fontSmlHeight*2 + marginItem; - top += max(fontSmlHeight, Config.decorProgressSignalSize) / 2 - fontSmlHeight / 2; + top += max(fontSmlHeight, Config.decorProgressSignalSize) - (Config.decorProgressSignalSize*2) - marginItem; int left = marginItem * 2; int progressTop = fontHeight*2 + fontSmlHeight*2 + marginItem; progressTop += max(fontSmlHeight, Config.decorProgressSignalSize) / 2 - Config.decorProgressSignalSize / 2; @@ -530,13 +530,15 @@ void cFlatDisplayChannel::SignalQualityDraw(void) { cRect(progressLeft, progressTop, progressWidth, Config.decorProgressSignalSize), SignalQuality, 100, Config.decorProgressSignalFg, Config.decorProgressSignalBarFg, Config.decorProgressSignalBg, Config.decorProgressSignalType, false, Config.SignalQualityUseColors); + delete SignalFont; } void cFlatDisplayChannel::BitrateDraw(void) { int top = fontHeight*2 + fontSmlHeight*2 + marginItem; - top += max(fontSmlHeight, Config.decorProgressSignalSize) / 2 - fontSmlHeight / 2; + top += max(fontSmlHeight, Config.decorProgressSignalSize) - (Config.decorProgressSignalSize*2) - marginItem; int left = marginItem * 2; cFont *SignalFont = cFont::CreateFont(Setup.FontOsd, Config.decorProgressSignalSize); + cFont *BitrateFont = cFont::CreateFont(Setup.FontOsd, (Config.decorProgressSignalSize*2)); if( Config.SignalQualityShow ) { int signalWidth = channelWidth / 2; @@ -546,15 +548,16 @@ void cFlatDisplayChannel::BitrateDraw(void) { left = progressLeft + progressWidth + marginItem * 4; } - cString videoBit = cString::sprintf("%.2f", bitrateVideo / 1000000.0 ); - cString audioBit = cString::sprintf("%.2f", bitrateAudio / 1000.0); + cString bitrateText; + if( bitrateAudio > 0.0 || bitrateDolby == 0.0 ) + bitrateText = cString::sprintf("Video: %.2f Mbit/s | Audio: %.2f kbit/s", bitrateVideo / 1000000.0, bitrateAudio / 1000.0 ); + else + bitrateText = cString::sprintf("Video: %.2f Mbit/s | Dolby: %.2f kbit/s", bitrateVideo / 1000000.0, bitrateDolby / 1000.0 ); - cString video = cString::sprintf("Video: %s Mbit/s", *videoBit ); - cString audio = cString::sprintf("Audio: %s kbit/s", *audioBit ); + chanInfoBottomPixmap->DrawText(cPoint(left, top), bitrateText, Theme.Color(clrChannelSignalFont), Theme.Color(clrChannelBg), BitrateFont); - chanInfoBottomPixmap->DrawText(cPoint(left, top), video, Theme.Color(clrChannelSignalFont), Theme.Color(clrChannelBg), SignalFont); - top += Config.decorProgressSignalSize + marginItem; - chanInfoBottomPixmap->DrawText(cPoint(left, top), audio, Theme.Color(clrChannelSignalFont), Theme.Color(clrChannelBg), SignalFont); + delete SignalFont; + delete BitrateFont; } void cFlatDisplayChannel::ChannelSwitch(const cDevice * device, int channelNumber, bool liveView) diff --git a/femonreceiver.c b/femonreceiver.c index 9c7df27e..19b12406 100644 --- a/femonreceiver.c +++ b/femonreceiver.c @@ -9,177 +9,181 @@ #include "femonreceiver.h" cFemonReceiver::cFemonReceiver(const cChannel *Channel, int ATrack, int DTrack) -: cReceiver(Channel), - cThread("femon receiver"), - m_Mutex(), - m_Sleep(), - m_Active(false), - m_VideoBuffer(KILOBYTE(512), TS_SIZE, false, "Femon video"), - m_VideoType(Channel ? Channel->Vtype(): 0), - m_VideoPid(Channel ? Channel->Vpid() : 0), // Y - m_VideoPacketCount(0), // Y - m_AudioBuffer(KILOBYTE(256), TS_SIZE, false, "Femon audio"), // Y - m_AudioPid(Channel ? Channel->Apid(ATrack) : 0), // Y - m_AudioPacketCount(0), // Y - m_AC3Buffer(KILOBYTE(256), TS_SIZE, false, "Femon AC3"), - m_AC3Pid(Channel ? Channel->Dpid(DTrack) : 0), // Y - m_AC3PacketCount(0) // Y + : cReceiver(Channel), + cThread("femon receiver"), + m_Mutex(), + m_Sleep(), + m_Active(false), + m_VideoBuffer(KILOBYTE(512), TS_SIZE, false, "Femon video"), + m_VideoType(Channel ? Channel->Vtype(): 0), + m_VideoPid(Channel ? Channel->Vpid() : 0), + m_VideoPacketCount(0), + m_AudioBuffer(KILOBYTE(256), TS_SIZE, false, "Femon audio"), + m_AudioPid(Channel ? Channel->Apid(ATrack) : 0), + m_AudioPacketCount(0), + m_AC3Buffer(KILOBYTE(256), TS_SIZE, false, "Femon AC3"), + m_AC3Pid(Channel ? Channel->Dpid(DTrack) : 0), + m_AC3PacketCount(0) { - SetPids(NULL); - AddPid(m_VideoPid); // Y - AddPid(m_AudioPid); // Y - AddPid(m_AC3Pid); // Y + SetPids(NULL); + AddPid(m_VideoPid); + AddPid(m_AudioPid); + AddPid(m_AC3Pid); - m_VideoBuffer.SetTimeouts(0, 100); // Y - m_AudioBuffer.SetTimeouts(0, 100); // Y - m_AC3Buffer.SetTimeouts(0, 100); // Y + m_VideoBuffer.SetTimeouts(0, 100); + m_AudioBuffer.SetTimeouts(0, 100); + m_AC3Buffer.SetTimeouts(0, 100); + + m_VideoBitrate = 0.0; + m_AudioBitrate = 0.0; + m_AC3Bitrate = 0.0; } cFemonReceiver::~cFemonReceiver(void) { - Deactivate(); + Deactivate(); } void cFemonReceiver::Deactivate(void) { - Detach(); - if (m_Active) { - m_Active = false; - m_Sleep.Signal(); - if (Running()) - Cancel(3); + Detach(); + if (m_Active) { + m_Active = false; + m_Sleep.Signal(); + if (Running()) + Cancel(3); } } void cFemonReceiver::Activate(bool On) { - if (On) - Start(); - else - Deactivate(); + if (On) + Start(); + else + Deactivate(); } void cFemonReceiver::Receive(uchar *Data, int Length) { - // TS packet length: TS_SIZE - if (Running() && (*Data == TS_SYNC_BYTE) && (Length == TS_SIZE)) { - int len, pid = TsPid(Data); - if (pid == m_VideoPid) { - ++m_VideoPacketCount; - len = m_VideoBuffer.Put(Data, Length); - if (len != Length) { - m_VideoBuffer.ReportOverflow(Length - len); - m_VideoBuffer.Clear(); - } + // TS packet length: TS_SIZE + if (Running() && (*Data == TS_SYNC_BYTE) && (Length == TS_SIZE)) { + int len, pid = TsPid(Data); + if (pid == m_VideoPid) { + ++m_VideoPacketCount; + len = m_VideoBuffer.Put(Data, Length); + if (len != Length) { + m_VideoBuffer.ReportOverflow(Length - len); + m_VideoBuffer.Clear(); + } } - else if (pid == m_AudioPid) { - ++m_AudioPacketCount; - len = m_AudioBuffer.Put(Data, Length); - if (len != Length) { - m_AudioBuffer.ReportOverflow(Length - len); - m_AudioBuffer.Clear(); - } + else if (pid == m_AudioPid) { + ++m_AudioPacketCount; + len = m_AudioBuffer.Put(Data, Length); + if (len != Length) { + m_AudioBuffer.ReportOverflow(Length - len); + m_AudioBuffer.Clear(); + } } - else if (pid == m_AC3Pid) { - ++m_AC3PacketCount; - len = m_AC3Buffer.Put(Data, Length); - if (len != Length) { - m_AC3Buffer.ReportOverflow(Length - len); - m_AC3Buffer.Clear(); - } + else if (pid == m_AC3Pid) { + ++m_AC3PacketCount; + len = m_AC3Buffer.Put(Data, Length); + if (len != Length) { + m_AC3Buffer.ReportOverflow(Length - len); + m_AC3Buffer.Clear(); + } } - } + } } void cFemonReceiver::Action(void) { - cTimeMs calcPeriod(0); - m_Active = true; + cTimeMs calcPeriod(0); + m_Active = true; - while (Running() && m_Active) { - uint8_t *Data; - double timeout; - int Length; - bool processed = false; + while (Running() && m_Active) { + uint8_t *Data; + double timeout; + int Length; + bool processed = false; - // process available video data - while ((Data = m_VideoBuffer.Get(Length))) { - if (!m_Active || (Length < TS_SIZE)) - break; - Length = TS_SIZE; - if (*Data != TS_SYNC_BYTE) { - for (int i = 1; i < Length; ++i) { - if (Data[i] == TS_SYNC_BYTE) { - Length = i; + // process available video data + while ((Data = m_VideoBuffer.Get(Length))) { + if (!m_Active || (Length < TS_SIZE)) break; + Length = TS_SIZE; + if (*Data != TS_SYNC_BYTE) { + for (int i = 1; i < Length; ++i) { + if (Data[i] == TS_SYNC_BYTE) { + Length = i; + break; + } } - } - m_VideoBuffer.Del(Length); - continue; - } - processed = true; - if (TsPayloadStart(Data)) { - m_VideoAssembler.Reset(); - } - m_VideoAssembler.PutTs(Data, Length); - m_VideoBuffer.Del(Length); - } + m_VideoBuffer.Del(Length); + continue; + } + processed = true; + if (TsPayloadStart(Data)) { + m_VideoAssembler.Reset(); + } + m_VideoAssembler.PutTs(Data, Length); + m_VideoBuffer.Del(Length); + } - // process available audio data - while ((Data = m_AudioBuffer.Get(Length))) { - if (!m_Active || (Length < TS_SIZE)) - break; - Length = TS_SIZE; - if (*Data != TS_SYNC_BYTE) { - for (int i = 1; i < Length; ++i) { - if (Data[i] == TS_SYNC_BYTE) { - Length = i; + // process available audio data + while ((Data = m_AudioBuffer.Get(Length))) { + if (!m_Active || (Length < TS_SIZE)) break; + Length = TS_SIZE; + if (*Data != TS_SYNC_BYTE) { + for (int i = 1; i < Length; ++i) { + if (Data[i] == TS_SYNC_BYTE) { + Length = i; + break; + } } - } - m_AudioBuffer.Del(Length); - continue; - } - processed = true; - m_AudioAssembler.PutTs(Data, Length); - m_AudioBuffer.Del(Length); - } + m_AudioBuffer.Del(Length); + continue; + } + processed = true; + m_AudioAssembler.PutTs(Data, Length); + m_AudioBuffer.Del(Length); + } - // process available dolby data - while ((Data = m_AC3Buffer.Get(Length))) { - if (!m_Active || (Length < TS_SIZE)) - break; - Length = TS_SIZE; - if (*Data != TS_SYNC_BYTE) { - for (int i = 1; i < Length; ++i) { - if (Data[i] == TS_SYNC_BYTE) { - Length = i; + // process available dolby data + while ((Data = m_AC3Buffer.Get(Length))) { + if (!m_Active || (Length < TS_SIZE)) break; + Length = TS_SIZE; + if (*Data != TS_SYNC_BYTE) { + for (int i = 1; i < Length; ++i) { + if (Data[i] == TS_SYNC_BYTE) { + Length = i; + break; + } } - } - m_AC3Buffer.Del(Length); - continue; - } - processed = true; - m_AC3Assembler.PutTs(Data, Length); - m_AC3Buffer.Del(Length); - } + m_AC3Buffer.Del(Length); + continue; + } + processed = true; + m_AC3Assembler.PutTs(Data, Length); + m_AC3Buffer.Del(Length); + } - // calculate bitrates - timeout = double(calcPeriod.Elapsed()); - if (m_Active && (timeout >= (100.0 * Config.ChannelBitrateShowCalcInterval ))) { - // TS packet 188 bytes - 4 byte header; MPEG standard defines 1Mbit = 1000000bit - // PES headers should be compensated! - m_VideoBitrate = (1000.0 * 8.0 * 184.0 * m_VideoPacketCount) / timeout; - m_VideoPacketCount = 0; - m_AudioBitrate = (1000.0 * 8.0 * 184.0 * m_AudioPacketCount) / timeout; - m_AudioPacketCount = 0; - m_AC3Bitrate = (1000.0 * 8.0 * 184.0 * m_AC3PacketCount) / timeout; - m_AC3PacketCount = 0; - calcPeriod.Set(0); - } + // calculate bitrates + timeout = double(calcPeriod.Elapsed()); + if (m_Active && (timeout >= (100.0 * Config.ChannelBitrateShowCalcInterval ))) { + // TS packet 188 bytes - 4 byte header; MPEG standard defines 1Mbit = 1000000bit + // PES headers should be compensated! + m_VideoBitrate = (1000.0 * 8.0 * 184.0 * m_VideoPacketCount) / timeout; + m_VideoPacketCount = 0; + m_AudioBitrate = (1000.0 * 8.0 * 184.0 * m_AudioPacketCount) / timeout; + m_AudioPacketCount = 0; + m_AC3Bitrate = (1000.0 * 8.0 * 184.0 * m_AC3PacketCount) / timeout; + m_AC3PacketCount = 0; + calcPeriod.Set(0); + } - if (!processed) - m_Sleep.Wait(10); // to avoid busy loop and reduce cpu load + if (!processed) + m_Sleep.Wait(10); // to avoid busy loop and reduce cpu load } } diff --git a/femonreceiver.h b/femonreceiver.h index 75ea6f0b..4d768ef9 100644 --- a/femonreceiver.h +++ b/femonreceiver.h @@ -13,50 +13,50 @@ #include "baserender.h" class cFemonReceiver : public cFlatBaseRender, public cReceiver, public cThread { -private: - cMutex m_Mutex; - cCondWait m_Sleep; - bool m_Active; - - - cRingBufferLinear m_VideoBuffer; // Y - cTsToPes m_VideoAssembler; - int m_VideoType; - int m_VideoPid; // Y - int m_VideoPacketCount; // Y - double m_VideoBitrate; - - cRingBufferLinear m_AudioBuffer; // Y - cTsToPes m_AudioAssembler; - int m_AudioPid; // Y - int m_AudioPacketCount; // Y - double m_AudioBitrate; - bool m_AudioValid; - - cRingBufferLinear m_AC3Buffer; // Y - cTsToPes m_AC3Assembler; - int m_AC3Pid; // Y - int m_AC3PacketCount; // Y - double m_AC3Bitrate; // Y - bool m_AC3Valid; - -protected: - virtual void Activate(bool On); - virtual void Receive(uchar *Data, int Length); - virtual void Action(void); - -public: - cFemonReceiver(const cChannel* Channel, int ATrack, int DTrack); - virtual ~cFemonReceiver(); - void Deactivate(void); - - double VideoBitrate(void) { cMutexLock MutexLock(&m_Mutex); - return m_VideoBitrate; }; // bit/s - double AudioBitrate(void) { cMutexLock MutexLock(&m_Mutex); - return m_AudioBitrate; }; // bit/s - double AC3Bitrate(void) { cMutexLock MutexLock(&m_Mutex); - return m_AC3Bitrate; }; // bit/s - }; + private: + cMutex m_Mutex; + cCondWait m_Sleep; + bool m_Active; + + + cRingBufferLinear m_VideoBuffer; + cTsToPes m_VideoAssembler; + int m_VideoType; + int m_VideoPid; + int m_VideoPacketCount; + double m_VideoBitrate; + + cRingBufferLinear m_AudioBuffer; + cTsToPes m_AudioAssembler; + int m_AudioPid; + int m_AudioPacketCount; + double m_AudioBitrate; + bool m_AudioValid; + + cRingBufferLinear m_AC3Buffer; + cTsToPes m_AC3Assembler; + int m_AC3Pid; + int m_AC3PacketCount; + double m_AC3Bitrate; + bool m_AC3Valid; + + protected: + virtual void Activate(bool On); + virtual void Receive(uchar *Data, int Length); + virtual void Action(void); + + public: + cFemonReceiver(const cChannel* Channel, int ATrack, int DTrack); + virtual ~cFemonReceiver(); + void Deactivate(void); + + double VideoBitrate(void) { cMutexLock MutexLock(&m_Mutex); + return m_VideoBitrate; }; // bit/s + double AudioBitrate(void) { cMutexLock MutexLock(&m_Mutex); + return m_AudioBitrate; }; // bit/s + double AC3Bitrate(void) { cMutexLock MutexLock(&m_Mutex); + return m_AC3Bitrate; }; // bit/s +}; #endif //__FEMONRECEIVER_H |