diff options
| author | louis <louis.braun@gmx.de> | 2014-10-28 16:39:42 +0100 |
|---|---|---|
| committer | louis <louis.braun@gmx.de> | 2014-10-28 16:39:42 +0100 |
| commit | abd8fd8db042ae860bb5346ce886ee961a847ae6 (patch) | |
| tree | ba5f6bfdcf8a899ebf43d32ba4ed3755e39d08c1 /views | |
| parent | c53dbf7cd63785a4e23b9d85faf6ac8493a7a9c3 (diff) | |
| download | vdr-plugin-skindesigner-abd8fd8db042ae860bb5346ce886ee961a847ae6.tar.gz vdr-plugin-skindesigner-abd8fd8db042ae860bb5346ce886ee961a847ae6.tar.bz2 | |
added tokens for current video and audio bitrate in displaychannel
Diffstat (limited to 'views')
| -rw-r--r-- | views/displaychannelview.c | 29 | ||||
| -rw-r--r-- | views/displaychannelview.h | 2 | ||||
| -rw-r--r-- | views/viewhelpers.c | 74 | ||||
| -rw-r--r-- | views/viewhelpers.h | 17 |
4 files changed, 117 insertions, 5 deletions
diff --git a/views/displaychannelview.c b/views/displaychannelview.c index e8b5177..486218a 100644 --- a/views/displaychannelview.c +++ b/views/displaychannelview.c @@ -5,7 +5,6 @@ #include "../libcore/timers.h" #include "../libcore/helpers.h" - cDisplayChannelView::cDisplayChannelView(cTemplateView *tmplView) : cView(tmplView) { lastDate = ""; lastScreenWidth = 0; @@ -18,6 +17,7 @@ cDisplayChannelView::cDisplayChannelView(cTemplateView *tmplView) : cView(tmplVi lastTracDesc = ""; lastTrackLang = ""; InitDevices(); + InitFemonReceiver(); DeleteOsdOnExit(); SetFadeTime(tmplView->GetNumericParameter(ptFadeTime)); } @@ -424,6 +424,33 @@ void cDisplayChannelView::ClearDevices(void) { ClearViewElement(veDevices); } +void cDisplayChannelView::DrawBitrates(void) { + if (!ViewElementImplemented(veBitRate)) { + return; + } + double bitrateVideo; + double bitrateAudio; + double bitrateDolby; + + bool changed = GetBitrates(bitrateVideo, bitrateAudio, bitrateDolby); + if (!changed) { + return; + } + map < string, string > stringTokens; + map < string, int > intTokens; + stringTokens.insert(pair<string,string>("bitratevideo", *cString::sprintf("%.2f", bitrateVideo))); + intTokens.insert(pair<string,int>("bitrateaudio", bitrateAudio)); + intTokens.insert(pair<string,int>("bitratedolby", bitrateDolby)); + intTokens.insert(pair<string,int>("isdolby", (bitrateDolby > 0) ? true : false)); + + ClearBitrates(); + DrawViewElement(veBitRate, &stringTokens, &intTokens); +} + +void cDisplayChannelView::ClearBitrates(void) { + ClearViewElement(veBitRate); +} + void cDisplayChannelView::DrawChannelGroups(const cChannel *Channel, cString ChannelName) { if (!ViewElementImplemented(veChannelGroup)) { return; diff --git a/views/displaychannelview.h b/views/displaychannelview.h index 4cb0be4..f1167d8 100644 --- a/views/displaychannelview.h +++ b/views/displaychannelview.h @@ -47,6 +47,8 @@ public: void ClearSignalBackground(void); void DrawDevices(bool initial); void ClearDevices(void); + void DrawBitrates(void); + void ClearBitrates(void); void DrawChannelGroups(const cChannel *Channel, cString ChannelName); void ClearChannelGroups(void); void DisplayMessage(eMessageType Type, const char *Text); diff --git a/views/viewhelpers.c b/views/viewhelpers.c index d08d6f2..f4d86c7 100644 --- a/views/viewhelpers.c +++ b/views/viewhelpers.c @@ -4,6 +4,8 @@ cViewHelpers::cViewHelpers(void) { devicesInit = false; + femonReceiver = NULL; + bitrateVideoLast = bitrateAudioLast = bitrateDolbyLast = 0.0; } cViewHelpers::~cViewHelpers() { @@ -12,6 +14,10 @@ cViewHelpers::~cViewHelpers() { delete[] lastSignalQuality; delete[] recDevices; } + if (femonReceiver) { + femonReceiver->Deactivate(); + delete femonReceiver; + } } void cViewHelpers::InitDevices(void) { @@ -131,4 +137,70 @@ bool cViewHelpers::SetDevices(bool initial, map<string,int> *intTokens, vector<m intTokens->insert(pair<string, int>("numdevices", actualNumDevices)); return true; -}
\ No newline at end of file +} + +void cViewHelpers::InitFemonReceiver(void) { + const cChannel *channel = Channels.GetByNumber(cDevice::CurrentChannel()); + eTrackType track = cDevice::PrimaryDevice()->GetCurrentAudioTrack(); + if (channel) { + femonReceiver = new cFemonReceiver(channel, + IS_AUDIO_TRACK(track) ? int(track - ttAudioFirst) : 0, + IS_DOLBY_TRACK(track) ? int(track - ttDolbyFirst) : 0); + cDevice::ActualDevice()->AttachReceiver(femonReceiver); + } +} + +void cViewHelpers::ChannelSwitch(const cDevice * device, int channelNumber, bool liveView) { + if (!femonReceiver) + return; + bitrateVideoLast = bitrateAudioLast = bitrateDolbyLast = 0.0; + eTrackType track = cDevice::PrimaryDevice()->GetCurrentAudioTrack(); + const cChannel *channel = Channels.GetByNumber(cDevice::CurrentChannel()); + + if (!liveView || !channelNumber || !channel || channel->Number() != channelNumber) + return; + + if (femonReceiver) { + femonReceiver->Deactivate(); + delete femonReceiver; + femonReceiver = NULL; + } + if (channel) { + femonReceiver = new cFemonReceiver(channel, + IS_AUDIO_TRACK(track) ? int(track - ttAudioFirst) : 0, + IS_DOLBY_TRACK(track) ? int(track - ttDolbyFirst) : 0); + cDevice::ActualDevice()->AttachReceiver(femonReceiver); + } +} + +void cViewHelpers::SetAudioTrack(int Index, const char * const *Tracks) { + if (!femonReceiver) + return; + bitrateVideoLast = bitrateAudioLast = bitrateDolbyLast = 0.0; + eTrackType track = cDevice::PrimaryDevice()->GetCurrentAudioTrack(); + if (femonReceiver) { + femonReceiver->Deactivate(); + delete femonReceiver; + femonReceiver = NULL; + } + const cChannel *channel = Channels.GetByNumber(cDevice::CurrentChannel()); + if (channel) { + femonReceiver = new cFemonReceiver(channel, + IS_AUDIO_TRACK(track) ? int(track - ttAudioFirst) : 0, + IS_DOLBY_TRACK(track) ? int(track - ttDolbyFirst) : 0); + cDevice::ActualDevice()->AttachReceiver(femonReceiver); + } +} + +bool cViewHelpers::GetBitrates(double &bitrateVideo, double &bitrateAudio, double &bitrateDolby) { + bitrateVideo = (int)(femonReceiver->VideoBitrate() / 1024 / 1024 * 100 + 0.5) / 100.0; + bitrateAudio = (int)(femonReceiver->AudioBitrate() / 1024 * 100 + 0.5) / 100.0; + bitrateDolby = (int)(femonReceiver->AC3Bitrate() / 1024 * 100 + 0.5) / 100.0; + if (bitrateVideo != bitrateVideoLast || bitrateAudio != bitrateAudioLast || bitrateDolby != bitrateDolbyLast) { + bitrateVideoLast = bitrateVideo; + bitrateAudioLast = bitrateAudio; + bitrateDolbyLast = bitrateDolby; + return true; + } + return false; +} diff --git a/views/viewhelpers.h b/views/viewhelpers.h index d88651c..676a2d1 100644 --- a/views/viewhelpers.h +++ b/views/viewhelpers.h @@ -1,18 +1,29 @@ #ifndef __VIEWHELPERS_H #define __VIEWHELPERS_H -class cViewHelpers { +#include <vdr/status.h> +#include "../libcore/femonreceiver.h" + +class cViewHelpers : public cStatus { private: bool devicesInit; int* lastSignalStrength; int* lastSignalQuality; bool* recDevices; + cFemonReceiver *femonReceiver; + double bitrateVideoLast; + double bitrateAudioLast; + double bitrateDolbyLast; protected: + virtual void ChannelSwitch(const cDevice *device, int channelNumber, bool liveView); + virtual void SetAudioTrack(int Index, const char * const *Tracks); + void InitDevices(void); + bool SetDevices(bool initial, map<string,int> *intTokens, vector<map<string,string> > *devices); + void InitFemonReceiver(void); + bool GetBitrates(double &bitrateVideo, double &bitrateAudio, double &bitrateDolby); public: cViewHelpers(void); virtual ~cViewHelpers(void); - void InitDevices(void); - bool SetDevices(bool initial, map<string,int> *intTokens, vector<map<string,string> > *devices); }; #endif //__VIEWHELPERS_H
\ No newline at end of file |
