xbmc
VideoPlayerRadioRDS.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "DVDMessageQueue.h"
12 #include "IVideoPlayer.h"
13 #include "threads/Thread.h"
14 #include "utils/Stopwatch.h"
15 
16 #include <memory>
17 
18 class CDVDStreamInfo;
19 
20 namespace PVR
21 {
22 class CPVRChannel;
23 class CPVRRadioRDSInfoTag;
24 }
25 
27 
28 #define UECP_DATA_START 0xFE
29 #define UECP_DATA_STOP 0xFF
30 #define UECP_SIZE_MAX 263
32 #define RT_MEL 65
33 #define MAX_RTPC 50
34 
35 class CDVDRadioRDSData : public CThread, public IDVDStreamPlayer
36 {
37 public:
38  explicit CDVDRadioRDSData(CProcessInfo &processInfo);
39  ~CDVDRadioRDSData() override;
40 
41  bool CheckStream(const CDVDStreamInfo& hints);
42  bool OpenStream(CDVDStreamInfo hints) override;
43  void CloseStream(bool bWaitForBuffers) override;
44  void Flush();
45 
46  // waits until all available data has been rendered
47  void WaitForBuffers() { m_messageQueue.WaitUntilEmpty(); }
48  bool AcceptsData() const override { return !m_messageQueue.IsFull(); }
49  void SendMessage(std::shared_ptr<CDVDMsg> pMsg, int priority = 0) override
50  {
51  if (m_messageQueue.IsInited())
52  m_messageQueue.Put(pMsg, priority);
53  }
54  void FlushMessages() override { m_messageQueue.Flush(); }
55  bool IsInited() const override { return true; }
56  bool IsStalled() const override { return true; }
57 
58 protected:
59  void OnExit() override;
60  void Process() override;
61 
62 private:
63  void ResetRDSCache();
64  void ProcessUECP(const unsigned char *Data, unsigned int Length);
65 
66  inline unsigned int DecodePI(const uint8_t* msgElement);
67  inline unsigned int DecodePS(uint8_t *msgElement);
68  inline unsigned int DecodeDI(const uint8_t* msgElement);
69  inline unsigned int DecodeTA_TP(const uint8_t* msgElement);
70  inline unsigned int DecodeMS(const uint8_t* msgElement);
71  inline unsigned int DecodePTY(const uint8_t* msgElement);
72  inline unsigned int DecodePTYN(uint8_t *msgElement);
73  inline unsigned int DecodeRT(uint8_t *msgElement, unsigned int len);
74  inline unsigned int DecodeRTC(uint8_t *msgElement);
75  inline unsigned int DecodeODA(uint8_t *msgElement, unsigned int len);
76  inline unsigned int DecodeRTPlus(uint8_t *msgElement, unsigned int len);
77  inline unsigned int DecodeTMC(uint8_t *msgElement, unsigned int len);
78  inline unsigned int DecodeEPPTransmitterInfo(const uint8_t* msgElement);
79  inline unsigned int DecodeSlowLabelingCodes(const uint8_t* msgElement);
80  inline unsigned int DecodeDABDynLabelCmd(const uint8_t* msgElement, unsigned int len);
81  inline unsigned int DecodeDABDynLabelMsg(const uint8_t* msgElement, unsigned int len);
82  inline unsigned int DecodeAF(uint8_t *msgElement, unsigned int len);
83  inline unsigned int DecodeEonAF(uint8_t *msgElement, unsigned int len);
84  inline unsigned int DecodeTDC(uint8_t *msgElement, unsigned int len);
85 
86  void SendTMCSignal(unsigned int flags, uint8_t *data);
87  void SetRadioStyle(const std::string& genre);
88 
89  std::shared_ptr<PVR::CPVRRadioRDSInfoTag> m_currentInfoTag;
90  std::shared_ptr<PVR::CPVRChannel> m_currentChannel;
91  bool m_currentFileUpdate;
92  int m_speed;
93  CCriticalSection m_critSection;
94  CDVDMessageQueue m_messageQueue;
95 
96  uint8_t m_UECPData[UECP_SIZE_MAX+1];
97  unsigned int m_UECPDataIndex;
98  bool m_UECPDataStart;
99  bool m_UECPDatabStuff;
100  bool m_UECPDataDeadBreak;
101 
102  bool m_RDS_IsRBDS;
103  bool m_RDS_SlowLabelingCodesPresent;
104 
105  uint16_t m_PI_Current;
106  unsigned int m_PI_CountryCode;
107  unsigned int m_PI_ProgramType;
108  unsigned int m_PI_ProgramReferenceNumber;
109 
110  unsigned int m_EPP_TM_INFO_ExtendedCountryCode;
111 
112  bool m_DI_IsStereo;
113  bool m_DI_ArtificialHead;
114  bool m_DI_Compressed;
115  bool m_DI_DynamicPTY;
116 
117  bool m_TA_TP_TrafficAdvisory;
118  float m_TA_TP_TrafficVolume;
119 
120  bool m_MS_SpeechActive;
121 
122  int m_PTY;
123  char m_PTYN[9];
124  bool m_PTYN_Present;
125 
126  bool m_RT_NewItem;
127 
128  uint8_t m_RTPlus_WorkText[RT_MEL+1];
129  bool m_RTPlus_TToggle;
130  int m_RTPlus_iDiffs;
131  CStopWatch m_RTPlus_iTime;
132  bool m_RTPlus_GenrePresent;
133  char m_RTPlus_Temptext[RT_MEL];
134  bool m_RTPlus_Show;
135  char m_RTPlus_Title[RT_MEL];
136  char m_RTPlus_Artist[RT_MEL];
137  int m_RTPlus_iToggle;
138  unsigned int m_RTPlus_ItemToggle;
139  time_t m_RTPlus_Starttime;
140 
141  CDateTime m_RTC_DateTime;
142 
143  uint8_t m_TMC_LastData[5];
144 };
Definition: Stopwatch.h:14
Definition: DVDStreamInfo.h:23
Definition: IVideoPlayer.h:36
Definition: Thread.h:44
Definition: VideoPlayerRadioRDS.h:36
Definition: DVDMessageQueue.h:48
Definition: ContextMenuManager.h:24
Definition: ProcessInfo.h:26
DateTime class, which uses FileTime as it&#39;s base.
Definition: XBDateTime.h:63