Live555笔记:创建SDP

来源:互联网 发布:马克飞象 知乎 编辑:程序博客网 时间:2024/05/20 07:19

H264LiveVideoServerMediaSubsession继承自OnDemandServerMediaSubsession,在OnDemandServerMediaSubsession调用析构函数的时候,会释手动放掉fSDPLines;

OnDemandServerMediaSubsession::~OnDemandServerMediaSubsession() {  delete[] fSDPLines;  // Clean out the destinations hash table:  while (1) {    Destinations* destinations      = (Destinations*)(fDestinationsHashTable->RemoveNext());    if (destinations == NULL) break;    delete destinations;  }  delete fDestinationsHashTable;}

 所以,在创建fSDPLines的时候,需要为它在堆上分配一块内存,再对其赋值,所以这里使用strDup();


char const* H264LiveVideoServerMediaSubsession::sdpLines(){//在OnDemandServerMediaSubsession::~OnDemandServerMediaSubsession()中会调用delete[] fSDPLines,所以这里需要使用strDup,而不能直接赋值/*return fSDPLines ="m=video 0 RTP/AVP 96\r\n""c=IN IP4 0.0.0.0\r\n""b=AS:96\r\n""a=rtpmap:96 H264/90000\r\n""a=fmtp:96 packetization-mode=1;profile-level-id=000000;sprop-parameter-sets=H264\r\n""a=control:track1\r\n";*/return fSDPLines = strDup("m=video 0 RTP/AVP 96\r\n""c=IN IP4 0.0.0.0\r\n""b=AS:96\r\n""a=rtpmap:96 H264/90000\r\n""a=fmtp:96 packetization-mode=1;profile-level-id=000000;sprop-parameter-sets=H264\r\n""a=control:track1\r\n");}


0 0
原创粉丝点击