2 * Copyright (c) 2009, David McPaul
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
22 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
23 * OF THE POSSIBILITY OF SUCH DAMAGE.
42 IndexEntry::AddPayload(uint32 pdataSize
)
45 dataSize
+= pdataSize
;
48 StreamEntry::StreamEntry()
56 StreamEntry::~StreamEntry()
62 StreamEntry::setDuration(bigtime_t pduration
)
69 StreamEntry::GetIndex(uint32 frameNo
)
71 IndexEntry indexEntry
;
73 for (std::vector
<IndexEntry
>::iterator itr
= index
.begin(); itr
!= index
.end(); ++itr
) {
74 if (itr
->frameNo
== frameNo
) {
83 StreamEntry::HasIndex(uint32 frameNo
)
86 for (std::vector
<IndexEntry
>::iterator itr
= index
.begin(); itr
!= index
.end(); ++itr
) {
87 if (itr
->frameNo
== frameNo
) {
97 StreamEntry::GetIndex(bigtime_t pts
)
99 IndexEntry indexEntry
;
101 for (std::vector
<IndexEntry
>::iterator itr
= index
.begin(); itr
!= index
.end(); ++itr
) {
102 if (pts
<= itr
->pts
) {
111 StreamEntry::HasIndex(bigtime_t pts
)
113 if (!index
.empty()) {
114 for (std::vector
<IndexEntry
>::iterator itr
= index
.begin(); itr
!= index
.end(); ++itr
) {
115 if (pts
<= itr
->pts
) {
125 Combine payloads with the same id into a single IndexEntry
126 When isLast flag is set then no more payloads are available (ie add current entry to index)
130 StreamEntry::AddPayload(uint32 id
, bool keyFrame
, bigtime_t pts
, uint32 dataSize
, bool isLast
)
133 maxPTS
= indexEntry
.pts
;
134 if (frameCount
> 0) {
135 index
.push_back(indexEntry
);
136 // printf("Stream %d added Index %ld PTS %Ld payloads %d\n",streamIndex, indexEntry.frameNo, indexEntry.pts, indexEntry.noPayloads);
137 printf("Stream Index Loaded for Stream %d Max Frame %ld Max PTS %Ld size %ld\n",streamIndex
, frameCount
-1, maxPTS
, index
.size());
141 if (frameCount
!= 0) {
142 // add indexEntry to Index
143 index
.push_back(indexEntry
);
144 // printf("Stream %d added Index %ld PTS %Ld payloads %d\n",streamIndex, indexEntry.frameNo, indexEntry.pts, indexEntry.noPayloads);
149 indexEntry
.frameNo
= frameCount
++;
150 indexEntry
.keyFrame
= keyFrame
;
151 indexEntry
.pts
= pts
;
152 indexEntry
.dataSize
= dataSize
;
153 indexEntry
.noPayloads
= 1;
156 indexEntry
.AddPayload(dataSize
);