本文整理汇总了C++中Packet::AppendData方法的典型用法代码示例。如果您正苦于以下问题:C++ Packet::AppendData方法的具体用法?C++ Packet::AppendData怎么用?C++ Packet::AppendData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet::AppendData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseRawSSA
HRESULT CStreamParser::ParseRawSSA(Packet *pPacket)
{
int i, layer = 0, max_duration = 0;
size_t size, line_size, data_size = pPacket->GetDataSize();
const char *start, *end, *data = (char *)pPacket->GetData();
char buffer[2048];
while(data_size) {
int duration = ass_get_duration(data);
max_duration = FFMAX(duration, max_duration);
end = (char *)memchr(data, '\n', data_size);
size = line_size = end ? end-data+1 : data_size;
size -= end ? (end[-1]=='\r')+1 : 0;
start = data;
for (i=0; i<3; i++, start++)
if (!(start = (char *)memchr(start, ',', size-(start-data))))
break;
size -= start - data;
// ASS packages with layer
sscanf_s(data, "Dialogue: %d,", &layer);
i = _snprintf_s(buffer, sizeof(buffer), "%I64d,%d,", 0, layer);
size = FFMIN(i+size, sizeof(buffer));
memcpy(buffer+i, start, size-i);
Packet *p = new Packet();
p->pmt = pPacket->pmt;
pPacket->pmt = nullptr;
p->bDiscontinuity = pPacket->bDiscontinuity;
p->bSyncPoint = pPacket->bSyncPoint;
p->StreamId = pPacket->StreamId;
p->rtStart = pPacket->rtStart;
p->rtStop = p->rtStart + (duration * 10000);
p->AppendData(buffer, size);
Queue(p);
data += line_size;
data_size -= line_size;
}
SAFE_DELETE(pPacket);
return S_FALSE;
}
示例2: ParseSRT
HRESULT CStreamParser::ParseSRT(Packet *pPacket)
{
int ts_start, ts_end, x1 = -1, y1 = -1, x2 = -1, y2 = -1;
const char *ptr = (const char *)pPacket->GetData();
const char *end = ptr + pPacket->GetDataSize();
if (pPacket->GetDataSize() == 0)
return S_FALSE;
while(ptr && end > ptr && *ptr) {
// Read the embeded timestamp and find the start of the subtitle
ptr = read_srt_ts(ptr, &ts_start, &ts_end, &x1, &y1, &x2, &y2);
if (ptr) {
const char *linestart = ptr;
while (end > ptr) {
if (*ptr != ' ' && *ptr != '\n' && *ptr != '\r') {
ptr += strcspn(ptr, "\n") + 1;
} else {
if (*ptr++ == '\n')
break;
}
}
int size = ptr - linestart;
Packet *p = new Packet();
p->pmt = pPacket->pmt;
pPacket->pmt = nullptr;
p->bDiscontinuity = pPacket->bDiscontinuity;
p->bSyncPoint = pPacket->bSyncPoint;
p->StreamId = pPacket->StreamId;
p->rtStart = pPacket->rtStart;
p->rtStop = pPacket->rtStop;
p->AppendData(linestart, size);
Queue(p);
}
}
SAFE_DELETE(pPacket);
return S_FALSE;
}