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 #define BIT_SEL(x) (1 << (x))
7 
8 const uint8_t TableStatus::init_bits[8] = {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] = init_bits[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  |= init_bits[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 
bool IsSectionSeen(uint32_t key, int32_t version, uint32_t section) const
Definition: tablestatus.cpp:73
vector< uint8_t > sections_t
Definition: tablestatus.h:17
bool HasAllSections() const
Definition: tablestatus.cpp:49
void SetSectionSeen(int32_t version, uint32_t section, uint32_t last_section, uint32_t segment_last_section=0xffff)
Definition: tablestatus.cpp:30
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)
#define BIT_SEL(x)
Definition: tablestatus.cpp:6
unsigned int uint
Definition: compat.h:140
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
bool IsSectionSeen(int32_t version, uint32_t section) const
Definition: tablestatus.cpp:41
bool HasAllSections(uint32_t key) const
Definition: tablestatus.cpp:81
int32_t m_version
Definition: tablestatus.h:27
static const uint8_t init_bits[8]
Definition: tablestatus.h:31
sections_t m_sections
Definition: tablestatus.h:28
void SetVersion(uint32_t key, int32_t version, uint32_t last_section)
Definition: tablestatus.cpp:58
void SetVersion(int32_t version, uint32_t last_section)
Definition: tablestatus.cpp:21
static void InitSections(sections_t &sect, uint32_t last_section)
Definition: tablestatus.cpp:10