📄 sitypes.cpp
字号:
/* * $Id: sitypes.cpp,v 1.8 2005/03/27 18:18:56 taylor Exp $ * vim: set expandtab tabstop=4 shiftwidth=4: * * Original Project * MythTV http://www.mythtv.org * * Author(s): * John Pullan (john@pullan.org) * Taylor Jacob (rtjacob@earthlink.net) * * Description: * Collection of classes to provide dvb a transport editor * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Or, point your browser to http://www.gnu.org/copyleft/gpl.html * */#include <stdint.h>#include "sitypes.h"// Set EIT_DEBUG_SID to a valid serviceid to enable EIT debugging// #define EIT_DEBUG_SID 1602void pidHandler::reset(){ pid = 0; mask = 0; filter = 0; pulling = false;}void privateTypes::reset(){ ChannelNumbers = 0; Descriptors.clear(); TVServiceTypes.clear(); EITFixUp = 0; SDTMapping = false; CurrentTransportID = 0; ForceGuidePresent = false; CustomGuideRanges = false; CurrentTransportTableMin = 0; CurrentTransportTableMax = 0; OtherTransportTableMin = 0; OtherTransportTableMax = 0; GuidePID = 0; GuideTransportID = 0; CustomGuidePID = false; GuideOnSingleTransport = false; ParseSubtitleServiceIDs.clear();}void pullStatus::Reset(){ pulling = false; requested = false; requestedEmit = false; emitted = false;}void TableSourcePIDObject::Reset(){ TransportPID = 0; ServicesPID = 0; ServicesTable = 0; ServicesMask = 0; ChannelETT = 0;}void SectionTracker::Reset(){ MaxSections = -1; Version = -1; memset(&Filled, 0, sizeof(Filled));}void SectionTracker::MarkUnused(int Section){ if (Section > (MaxSections+1)) return; else Filled[Section]=2;}int SectionTracker::Complete(){ if (MaxSections == -1) return 0; for (int x = 0; x <= MaxSections; x++) { if (Filled[x] == 0) return 0; } return 1;}QString SectionTracker::loadStatus(){ QString retval = ""; if (MaxSections == -1) return QString("[---] "); retval += QString("["); for (int x=0;x<MaxSections+1;x++) { if (Filled[x] == 1) retval += QString("P"); else if (Filled[x] == 2) retval += QString("u"); else retval += QString("m"); } retval += QString("] "); return retval;}int SectionTracker::AddSection(tablehead *head){ if (MaxSections == -1) { MaxSections = head->section_last; Version = head->version; Filled[head->section_number]=1; return 0; } else if (Version != head->version) { Reset(); MaxSections = head->section_last; Version = head->version; Filled[head->section_number]=1; return -1; } else { if (Filled[head->section_number] == 1) return 1; else { Filled[head->section_number] = 1; return 0; } }}void SDTObject::Reset(){ ServiceID = 0; TransportID = 0; EITPresent = 0; NetworkID = 0; RunningStatus = 0; CAStatus = 0; ServiceName = ""; ProviderName = ""; ChanNum = -1; Version = 33; ServiceType = 0; ATSCSourceID = 0; MplexID = 0;}void CAPMTObject::Reset(){ CASystemID = 0; PID = 0; Data_Length = 0; memset(Data, 0, sizeof(Data));}Descriptor::Descriptor(){ Data = NULL; Length = 0;}Descriptor::Descriptor(const uint8_t *Data, const uint8_t Length){ this->Length = Length; this->Data = new uint8_t[Length]; memcpy(this->Data, Data, Length);}Descriptor::Descriptor(const Descriptor &orig){ Length = orig.Length; Data = new uint8_t[Length]; memcpy(Data, orig.Data, Length);}Descriptor::~Descriptor(){ if (Data) delete[] Data;}void ElementaryPIDObject::Reset(){ Type = ES_TYPE_UNKNOWN; Orig_Type = 0; PID = 0; Description = ""; Language = ""; CA.clear(); Descriptors.clear(); Record = false;}void Event::Reset(){ ServiceID = 0; TransportID = 0; NetworkID = 0; ATSC = false; clearEventValues();}void Event::clearEventValues(){ SourcePID = 0; LanguageCode = ""; Event_Name = ""; Description = ""; EventID = 0; ETM_Location = 0; Event_Subtitle = ""; ContentDescription = ""; Year = ""; SubTitled = false; Stereo = false; HDTV = false; ATSC = false; //PreviouslyShown = false; OriginalAirDate = QDate(); Credits.clear();}void TransportObject::Reset(){ Type = ""; NetworkID = 0; TransportID = 0; Frequency = 0; Modulation = "auto"; Constellation = "auto"; SymbolRate = 0; FEC_Inner = "auto"; OrbitalLocation = ""; Polarity = ""; FEC_Outer = "auto"; Bandwidth = "a"; Hiearchy = "a"; CodeRateHP = "auto"; CodeRateLP = "auto"; GuardInterval = "auto"; TransmissionMode = "a"; Inversion = "a";}void NetworkObject::Reset(){ NetworkName = ""; NetworkID = 0; LinkageTransportID = 0; LinkageNetworkID = 0; LinkageServiceID = 0; LinkageType = 0; LinkagePresent = 0;}void PMTObject::Reset(){ ServiceID = 0; PCRPID = 0; CA.clear(); Components.clear(); PMTPID = 0; hasCA = false; hasAudio = false; hasVideo = false;}// --- BEGIN: changes by PJ ---bool DSMCCHandler::RequirePIDs(){ if (!patloaded) return false; QMap_pullStatus::Iterator i; for (i = status.begin() ; i != status.end() ; ++i) { if ((i.data().pulling == false) && (i.data().requested)) return true; } return false;}bool DSMCCHandler::GetPIDs(uint16_t& pid, uint8_t& filter, uint8_t& mask){ QMap_pullStatus::Iterator i; for (i = status.begin() ; i != status.end() ; ++i) { if ((i.data().pulling == false) && (i.data().requested == true)) { i.data().pulling = true; pid = i.key(); filter = 0x00; mask = 0x00; return true; } } return false;}void DSMCCHandler::Request(uint16_t key){ status[key].requested = true;}void DSMCCHandler::RequestEmit(uint16_t key){ status[key].requested = true; status[key].requestedEmit = true;}bool DSMCCHandler::EmitRequired(){ return false;}bool DSMCCHandler::GetEmitID(uint16_t& key0, uint16_t& key1){ (void) key0; (void) key1; return false;}bool DSMCCHandler::AddSection(tablehead_t* head, uint16_t key0, uint16_t key1){ (void) key0; (void) key1; (void) head; return true;}// --- END: changes by PJ ---void PATHandler::Reset(){ status.Reset(); Tracker.Reset(); pids.clear();}bool PATHandler::RequirePIDs(){ if ((status.pulling == false) && (status.requested == true)) return true; return false;}bool PATHandler::GetPIDs(uint16_t& pid, uint8_t& filter, uint8_t& mask){ if (status.pulling == true) return false; pid = 0x00; filter = 0x00; mask = 0xFF; status.pulling = true; return true;}void PATHandler::Request(uint16_t key){ (void) key; status.requested = true;}bool PATHandler::Complete(){ if (Tracker.Complete() && (!status.emitted)) { if (status.requestedEmit == false) status.emitted = true; return true; } return false;}bool PATHandler::AddSection(tablehead_t *head, uint16_t key0, uint16_t key1){ (void) key0; (void) key1; return Tracker.AddSection(head);}bool PMTHandler::RequirePIDs(){ if (!patloaded) return false; QMap_pullStatus::Iterator i; for (i = status.begin() ; i != status.end() ; ++i) { if ((i.data().pulling == false) && (i.data().requested)) return true; } return false;}bool PMTHandler::GetPIDs(uint16_t& pid, uint8_t& filter, uint8_t& mask){ QMap_pullStatus::Iterator i; for (i = status.begin() ; i != status.end() ; ++i) { if ((i.data().pulling == false) && (i.data().requested == true)) { i.data().pulling = true; pid = pmt[i.key()].PMTPID; filter = 0x02; mask = 0xFF; return true; } } return false;}void PMTHandler::RequestEmit(uint16_t key){ status[key].requested = true; status[key].requestedEmit = true;}bool PMTHandler::EmitRequired(){ QMap_pullStatus::Iterator i; for (i = status.begin() ; i != status.end() ; ++i) { if (i.data().requestedEmit && (i.data().emitted == false) && Tracker[i.key()].Complete()) return true; } return false;}bool PMTHandler::GetEmitID(uint16_t& key0, uint16_t& key1){ QMap_pullStatus::Iterator i; for (i = status.begin() ; i != status.end() ; ++i) { if ((i.data().requestedEmit) && (i.data().emitted == false) && Tracker[i.key()].Complete()) { i.data().emitted = true; key0 = i.key(); key1 = 0; return true; } } return false;}bool PMTHandler::AddSection(tablehead_t* head, uint16_t key0, uint16_t key1){ (void) key0; (void) key1; return Tracker[key0].AddSection(head);}void PMTHandler::AddKey(uint16_t key0, uint16_t key1){ (void) key1; Tracker[key0].Reset(); if (!(status.contains(key0))) status[key0].Reset();;}void PMTHandler::DependencyMet(tabletypes t){ if (t == PAT) patloaded = true;}void PMTHandler::DependencyChanged(tabletypes t){ (void) t; //TODO: Handle this situation}bool MGTHandler::RequirePIDs(){ if ((status.pulling == false) && (status.requested == true)) return true; return false;}/* It's best to open the PID wide open so you get the other ATSC tables */bool MGTHandler::GetPIDs(uint16_t& pid, uint8_t& filter, uint8_t& mask){ if (status.pulling == true) return false; pid = 0x1FFB; filter = 0xFF; mask = 0x00; status.pulling = true; return true;}void MGTHandler::Request(uint16_t key){ (void) key; status.requested = true;}bool MGTHandler::Complete(){ if (Tracker.Complete() && (!status.emitted)) { if (status.requestedEmit == false) status.emitted = true; return true; } return false;}bool MGTHandler::AddSection(tablehead_t *head, uint16_t key0, uint16_t key1){ (void) key0; (void) key1; int retval = Tracker.AddSection(head); if (retval == -1) return false; return retval;}bool STTHandler::RequirePIDs(){ if ((status.pulling == false) && (status.requested == true)) return true; return false;}bool STTHandler::GetPIDs(uint16_t& pid, uint8_t& filter, uint8_t& mask){ if (status.pulling == true) return false; pid = 0x1FFB; filter = 0xFF;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -