MythTV  master
tablestatus.cpp
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 // Copyright (c) 2003-2012
3 
4 #include "tablestatus.h"
5 
6 static inline uint8_t BIT_SEL(uint8_t x) { return 1 << x; }
7 
8 const std::array<const uint8_t,8> TableStatus::kInitBits = {0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00};
9 
10 void TableStatus::InitSections(sections_t &sect, uint32_t last_section)
11 {
12  sect.clear();
13 
14  uint endz = last_section >> 3;
15  if (endz)
16  sect.resize(endz, 0x00);
17  sect.resize(32, 0xff);
18  sect[endz] = kInitBits[last_section & 0x7];
19 }
20 
21 void TableStatus::SetVersion(int32_t version, uint32_t last_section)
22 {
23  if (m_version == version)
24  return;
25 
27  InitSections(m_sections, last_section);
28 }
29 
30 void TableStatus::SetSectionSeen(int32_t version, uint32_t section,
31  uint32_t last_section, uint32_t segment_last_section)
32 {
33  SetVersion(version, last_section);
34  m_sections[section>>3] |= BIT_SEL(section & 0x7);
35  if ((segment_last_section != 0xffff) && (last_section != segment_last_section))
36  m_sections[segment_last_section >> 3]
37  |= kInitBits[segment_last_section & 0x7];
38 
39 }
40 
41 bool TableStatus::IsSectionSeen(int32_t version, uint32_t section) const
42 {
43  if (m_version != version)
44  return false;
45 
46  return (bool) (m_sections[section>>3] & BIT_SEL(section & 0x7));
47 }
48 
50 {
51  for (uint32_t i = 0; i < 32; i++)
52  if (m_sections[i] != 0xff)
53  return false;
54  return true;
55 }
56 
57 
58 void TableStatusMap::SetVersion(uint32_t key, int32_t version, uint32_t last_section)
59 {
60  TableStatus &status = (*this)[key];
61  //NOTE: relies on status.m_version being invalid(-2) if a new entry was just added to the map
62  status.SetVersion(version, last_section);
63 }
64 
65 void TableStatusMap::SetSectionSeen(uint32_t key, int32_t version, uint32_t section,
66  uint32_t last_section, uint32_t segment_last_section)
67 {
68  TableStatus &status = (*this)[key];
69  //NOTE: relies on status.m_version being invalid(-2) if a new entry was just added to the map
70  status.SetSectionSeen(version, section, last_section, segment_last_section);
71 }
72 
73 bool TableStatusMap::IsSectionSeen(uint32_t key, int32_t version, uint32_t section) const
74 {
75  const_iterator it = this->find(key);
76  if (it == this->end() || it->m_version != version)
77  return false;
78  return (bool) (it->m_sections[section>>3] & BIT_SEL(section & 0x7));
79 }
80 
81 bool TableStatusMap::HasAllSections(uint32_t key) const
82 {
83  const_iterator it = this->find(key);
84  if (it == this->end())
85  return false;
86 
87  return it->HasAllSections();
88 }
89 
TableStatus::InitSections
static void InitSections(sections_t &sect, uint32_t last_section)
Definition: tablestatus.cpp:10
TableStatus::HasAllSections
bool HasAllSections() const
Definition: tablestatus.cpp:49
TableStatusMap::SetSectionSeen
void SetSectionSeen(uint32_t key, int32_t version, uint32_t section, uint32_t last_section, uint32_t segment_last_section=0xffff)
Definition: tablestatus.cpp:65
TableStatusMap::HasAllSections
bool HasAllSections(uint32_t key) const
Definition: tablestatus.cpp:81
TableStatusMap::SetVersion
void SetVersion(uint32_t key, int32_t version, uint32_t last_section)
Definition: tablestatus.cpp:58
TableStatus::sections_t
std::vector< uint8_t > sections_t
Definition: tablestatus.h:17
TableStatus::IsSectionSeen
bool IsSectionSeen(int32_t version, uint32_t section) const
Definition: tablestatus.cpp:41
TableStatus::m_version
int32_t m_version
Definition: tablestatus.h:27
tablestatus.h
TableStatus
Definition: tablestatus.h:14
TableStatus::kInitBits
static const std::array< const uint8_t, 8 > kInitBits
Definition: tablestatus.h:31
TableStatus::SetVersion
void SetVersion(int32_t version, uint32_t last_section)
Definition: tablestatus.cpp:21
TableStatus::m_sections
sections_t m_sections
Definition: tablestatus.h:28
TableStatusMap::IsSectionSeen
bool IsSectionSeen(uint32_t key, int32_t version, uint32_t section) const
Definition: tablestatus.cpp:73
nv_python_libs.bbciplayer.bbciplayer_api.version
string version
Definition: bbciplayer_api.py:77
BIT_SEL
static uint8_t BIT_SEL(uint8_t x)
Definition: tablestatus.cpp:6
TableStatus::SetSectionSeen
void SetSectionSeen(int32_t version, uint32_t section, uint32_t last_section, uint32_t segment_last_section=0xffff)
Definition: tablestatus.cpp:30
find
static pid_list_t::iterator find(const PIDInfoMap &map, pid_list_t &list, pid_list_t::iterator begin, pid_list_t::iterator end, bool find_open)
Definition: dvbstreamhandler.cpp:363
uint
unsigned int uint
Definition: freesurround.h:24