教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 实用模板 >

基于内存缓冲区的流媒体数据缓存(6)

来源:网络收集 时间:2026-02-02
导读: follow=helpone->next; total=helpone->arra.size()+helpone->offset; if(follow==NULL) break; } }//将缓冲区中可以连接的存储体,进行连接 return; }//写在当前存储体末尾 if(totaltwo==helpone->offset) { vecto

follow=helpone->next;

total=helpone->arra.size()+helpone->offset; if(follow==NULL) break; }

}//将缓冲区中可以连接的存储体,进行连接 return;

}//写在当前存储体末尾

if(totaltwo==helpone->offset) {

vector temp;

for(unsigned int i=0;iarra.size();i++) temp.push_back(helpone->arra[i]); helpone->arra.clear(); for(int i=0;i

helpone->arra.push_back(databag[i]); for(unsigned int i=0;iarra.push_back(temp[i]); temp.clear();

helpone->offset=indataoffset; return;

}//写在当前存储体开始

if(totaltwooffset) {

b* t; t=new b;

for(int i=0;i

t->arra.push_back(databag[i]); t->offset=indataoffset; t->judge=0;

if(helpone!=buffer) {

helptwo->next=t; t->next=helpone; } else {

t->next=helpone; buffer=t; }

return;

}//如果到来的数据是在第一个存储体前,或者到来的数据在两个存储体之间。那么申请一个新的存储体,并调整好指针

if(indataoffset>totalone&&helpone->next==NULL) {

b* t; t=new b;

for(iniaot i=0;i

t->arra.push_back(databag[i]); t->next=NULL;

t->offset=indataoffset; t->judge=0;

helpone->next=t; return;

}//如果当前数据包不能写入当前缓冲区的连续数据区,则申请新的存储体,将数据包写入新的存储体

helptwo=helpone;//记住当前指针的上一个指针 helpone=helpone->next;//更新当前指针 }

} //数据接收函数

int program::remaindata(int decision,char* &poutdata){ poutdata=NULL; b* help; help=buffer;

while(help!=NULL){

if((endnumber==help->offset)&&(help->arra.size()!=0)) {

if((decision==1&&help->arra.size()>1024)||(decision==0)) {

help->judge=1;

if(originalone.size()<1)

originalone.push_back(help->offset);//获取疑似第一个输出到目的文件中的数据包的首元素偏移量

}//在两种情况下该存储体被确定为输出源,一为文件没有读取完毕,存储体的数据量大于1K,二为文件读取完毕 poutdata=help->arra.data(); return (help->arra.size()); }

help=help->next;

}//该存储体中的数据与目标文件,为连续数据

help=buffer;

while(help!=NULL) {

if(help->arra.size()!=0&&decision==0)

{//选择不连续的时间,为读取完文件后 help->judge=1;

poutdata=help->arra.data(); return (help->arra.size()); }

help=help->next;

}//如果找不到连续的数据,那么寻找偏移量最小的存储体,选中这个存储体 return 0;//如果缓冲区中没有数据,那么返回0值 }//计算缓冲区数据剩余量函数

void program::cleardata(int useddata){ b* help;

help=buffer;vector temp; while(help!=NULL) {

if(help->judge==1)

{//寻找作为源的存储体

help->judge=0;//消除该源的标记

for(unsigned int i=useddata;iarra.size();i++) temp.push_back(help->arra[i]); help->arra.clear();

for(unsigned int i=0;i

help->arra.push_back(temp[i]);//更新存储体中的数据 temp.clear();

…… 此处隐藏:126字,全部文档内容请下载后查看。喜欢就下载吧 ……
基于内存缓冲区的流媒体数据缓存(6).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/521285.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)