当前位置: 首页>>代码示例>>C++>>正文


C++ Packet::AppendData方法代码示例

本文整理汇总了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;
}
开发者ID:Brijen,项目名称:LAVFilters,代码行数:44,代码来源:StreamParser.cpp

示例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;
}
开发者ID:Brijen,项目名称:LAVFilters,代码行数:41,代码来源:StreamParser.cpp


注:本文中的Packet::AppendData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。