45
45
KaxCues::~KaxCues()
47
assert(myTempReferences.size() == 0); // otherwise that means you have added references and forgot to set the position
47
assert(myTempReferences.size() == 0); // otherwise that means you have added references and forgot to set the position
49
49
/* deprecated and wrong
50
50
bool KaxCues::AddBlockGroup(const KaxBlockGroup & BlockRef)
52
// Do not add the element if it's already present.
53
std::vector<const KaxBlockBlob *>::iterator ListIdx;
54
KaxBlockBlob *BlockReference = new KaxBlockBlob(BLOCK_BLOB_NO_SIMPLE);
55
BlockReference->SetBlockGroup(*const_cast<KaxBlockGroup*>(&BlockRef));
57
for (ListIdx = myTempReferences.begin(); ListIdx != myTempReferences.end(); ListIdx++)
58
if (&(KaxBlockGroup&)*ListIdx == &BlockRef)
60
delete BlockReference;
64
myTempReferences.push_back(BlockReference);
52
// Do not add the element if it's already present.
53
std::vector<const KaxBlockBlob *>::iterator ListIdx;
54
KaxBlockBlob *BlockReference = new KaxBlockBlob(BLOCK_BLOB_NO_SIMPLE);
55
BlockReference->SetBlockGroup(*const_cast<KaxBlockGroup*>(&BlockRef));
57
for (ListIdx = myTempReferences.begin(); ListIdx != myTempReferences.end(); ListIdx++)
58
if (&(KaxBlockGroup&)*ListIdx == &BlockRef) {
59
delete BlockReference;
63
myTempReferences.push_back(BlockReference);
68
67
bool KaxCues::AddBlockBlob(const KaxBlockBlob & BlockReference)
70
// Do not add the element if it's already present.
71
std::vector<const KaxBlockBlob *>::iterator ListIdx;
73
for (ListIdx = myTempReferences.begin(); ListIdx != myTempReferences.end(); ++ListIdx)
74
if (*ListIdx == &BlockReference)
77
myTempReferences.push_back(&BlockReference);
69
// Do not add the element if it's already present.
70
std::vector<const KaxBlockBlob *>::iterator ListIdx;
72
for (ListIdx = myTempReferences.begin(); ListIdx != myTempReferences.end(); ++ListIdx)
73
if (*ListIdx == &BlockReference)
76
myTempReferences.push_back(&BlockReference);
81
80
void KaxCues::PositionSet(const KaxBlockBlob & BlockReference)
83
// look for the element in the temporary references
84
std::vector<const KaxBlockBlob *>::iterator ListIdx;
82
// look for the element in the temporary references
83
std::vector<const KaxBlockBlob *>::iterator ListIdx;
86
for (ListIdx = myTempReferences.begin(); ListIdx != myTempReferences.end(); ++ListIdx) {
87
if (*ListIdx == &BlockReference) {
88
// found, now add the element to the entry list
89
KaxCuePoint & NewPoint = AddNewChild<KaxCuePoint>(*this);
90
NewPoint.PositionSet(BlockReference, GlobalTimecodeScale());
91
myTempReferences.erase(ListIdx);
85
for (ListIdx = myTempReferences.begin(); ListIdx != myTempReferences.end(); ++ListIdx) {
86
if (*ListIdx == &BlockReference) {
87
// found, now add the element to the entry list
88
KaxCuePoint & NewPoint = AddNewChild<KaxCuePoint>(*this);
89
NewPoint.PositionSet(BlockReference, GlobalTimecodeScale());
90
myTempReferences.erase(ListIdx);
97
96
void KaxCues::PositionSet(const KaxBlockGroup & BlockRef)
99
// look for the element in the temporary references
100
std::vector<const KaxBlockBlob *>::iterator ListIdx;
98
// look for the element in the temporary references
99
std::vector<const KaxBlockBlob *>::iterator ListIdx;
102
for (ListIdx = myTempReferences.begin(); ListIdx != myTempReferences.end(); ++ListIdx) {
103
const KaxInternalBlock &refTmp = **ListIdx;
104
if (refTmp.GlobalTimecode() == BlockRef.GlobalTimecode() &&
105
refTmp.TrackNum() == BlockRef.TrackNumber()) {
106
// found, now add the element to the entry list
107
KaxCuePoint & NewPoint = AddNewChild<KaxCuePoint>(*this);
108
NewPoint.PositionSet(**ListIdx, GlobalTimecodeScale());
109
myTempReferences.erase(ListIdx);
101
for (ListIdx = myTempReferences.begin(); ListIdx != myTempReferences.end(); ++ListIdx) {
102
const KaxInternalBlock &refTmp = **ListIdx;
103
if (refTmp.GlobalTimecode() == BlockRef.GlobalTimecode() &&
104
refTmp.TrackNum() == BlockRef.TrackNumber()) {
105
// found, now add the element to the entry list
106
KaxCuePoint & NewPoint = AddNewChild<KaxCuePoint>(*this);
107
NewPoint.PositionSet(**ListIdx, GlobalTimecodeScale());
108
myTempReferences.erase(ListIdx);
116
\warning Assume that the list has been sorted (Sort())
115
\warning Assume that the list has been sorted (Sort())
118
117
const KaxCuePoint * KaxCues::GetTimecodePoint(uint64 aTimecode) const
120
uint64 TimecodeToLocate = aTimecode / GlobalTimecodeScale();
121
const KaxCuePoint * aPointPrev = NULL;
122
uint64 aPrevTime = 0;
123
uint64 aNextTime = EBML_PRETTYLONGINT(0xFFFFFFFFFFFF);
125
EBML_MASTER_CONST_ITERATOR Itr;
126
for (Itr = begin(); Itr != end(); ++Itr)
128
if (EbmlId(*(*Itr)) == EBML_ID(KaxCuePoint)) {
129
const KaxCuePoint *tmp = static_cast<const KaxCuePoint *>(*Itr);
131
const KaxCueTime *aTime = static_cast<const KaxCueTime *>(tmp->FindFirstElt(EBML_INFO(KaxCueTime)));
134
uint64 _Time = uint64(*aTime);
135
if (_Time > aPrevTime && _Time < TimecodeToLocate) {
139
if (_Time < aNextTime && _Time > TimecodeToLocate) {
119
uint64 TimecodeToLocate = aTimecode / GlobalTimecodeScale();
120
const KaxCuePoint * aPointPrev = NULL;
121
uint64 aPrevTime = 0;
122
uint64 aNextTime = EBML_PRETTYLONGINT(0xFFFFFFFFFFFF);
124
EBML_MASTER_CONST_ITERATOR Itr;
125
for (Itr = begin(); Itr != end(); ++Itr) {
126
if (EbmlId(*(*Itr)) == EBML_ID(KaxCuePoint)) {
127
const KaxCuePoint *tmp = static_cast<const KaxCuePoint *>(*Itr);
129
const KaxCueTime *aTime = static_cast<const KaxCueTime *>(tmp->FindFirstElt(EBML_INFO(KaxCueTime)));
131
uint64 _Time = uint64(*aTime);
132
if (_Time > aPrevTime && _Time < TimecodeToLocate) {
136
if (_Time < aNextTime && _Time > TimecodeToLocate) {
149
146
uint64 KaxCues::GetTimecodePosition(uint64 aTimecode) const
151
const KaxCuePoint * aPoint = GetTimecodePoint(aTimecode);
155
const KaxCueTrackPositions * aTrack = aPoint->GetSeekPosition();
159
return aTrack->ClusterPosition();
148
const KaxCuePoint * aPoint = GetTimecodePoint(aTimecode);
152
const KaxCueTrackPositions * aTrack = aPoint->GetSeekPosition();
156
return aTrack->ClusterPosition();
162
159
END_LIBMATROSKA_NAMESPACE