亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? netoutput.cpp

?? 很好的流媒體服務器程序,linux或window下做流媒體的可以參考很不錯哦
?? CPP
字號:
/******************************************************************************** netoutput.cpp: network output*-------------------------------------------------------------------------------* (c)1999-2001 VideoLAN* $Id: netoutput.cpp,v 1.11.4.5 2003/05/16 19:43:59 nitrox Exp $** Authors: Benoit Steiner <benny@via.ecp.fr>*          Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>** This program is free software; you can redistribute it and/or* modify it under the terms of the GNU General Public License* as published by the Free Software Foundation; either version 2* of the License, or (at your option) any later version.** This program is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the* GNU General Public License for more details.** You should have received a copy of the GNU General Public License* along with this program; if not, write to the Free Software* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.**-------------------------------------------------------------------------------********************************************************************************///------------------------------------------------------------------------------// Preamble//------------------------------------------------------------------------------#ifdef WIN32#include <winsock2.h>#include <ws2tcpip.h>#endif#include "../../core/defs.h"#include "../../core/core.h"#include "../../mpeg/mpeg.h"#include "../../mpeg/ts.h"#include "../../mpeg/rtp.h"#include "../../server/buffer.h"#include "../../server/output.h"#ifdef HAVE_NET_IF_H#include <net/if.h>#endif#include "netoutput.h"//******************************************************************************// C_NetOutput class//******************************************************************************////******************************************************************************//------------------------------------------------------------------------------// //------------------------------------------------------------------------------C_NetOutput::C_NetOutput(const C_String& strChannelName)                : C_Output(TS_IN_ETHER), m_cSocketBuff(TS_IN_ETHER+1){  C_Application* pApp = C_Application::GetApp();  ASSERT(pApp);  m_strSrcHost = pApp->GetSetting(strChannelName+".SrcHost", "");  m_strSrcPort = pApp->GetSetting(strChannelName+".SrcPort", "");  m_strDstHost = pApp->GetSetting(strChannelName+".DstHost", "");  m_strDstPort = pApp->GetSetting(strChannelName+".DstPort", "1234");  m_strType = pApp->GetSetting(strChannelName+".Type", "unicast").ToLower();  m_strInterface = pApp->GetSetting(strChannelName+".Interface", "");  C_String strTTL = pApp->GetSetting(strChannelName+".TTL", "0");  m_iTTL = strTTL.ToInt();  // Init the buffer  // The first slot is reserved for the Rtp Header  m_cSocketBuff.SetSlotSize(0, RTP_HEADER_LEN);  for(int iIndex = 1; iIndex < TS_IN_ETHER + 1; iIndex++)    m_cSocketBuff.SetSlotSize(iIndex, TS_PACKET_LEN);}//------------------------------------------------------------------------------// //------------------------------------------------------------------------------C_NetOutput::~C_NetOutput(){}//------------------------------------------------------------------------------// //------------------------------------------------------------------------------void C_NetOutput::OnInit(){  ASSERT(    (m_strType == "unicast")          || (m_strType == "multicast")          || (m_strType == "broadcast"));  int iOptVal=1;  if(m_strType == "broadcast")  {    // Allow the socket to send broadcast packets    iOptVal = 1;    m_cSocket.SetOption(SOL_SOCKET, SO_BROADCAST, (char *)&iOptVal, sizeof(iOptVal));  }  // Allow to use the ip/port couple more than once at a time to be  // able to send several streams to a same client using the same port  iOptVal = 1;  m_cSocket.SetOption(SOL_SOCKET, SO_REUSEADDR, (char *)&iOptVal, sizeof(iOptVal));  // Try to increase the size of the socket output buffer to 1/2MB (8Mb/s  // during 1/2s) to avoid packet loss  iOptVal = 524288;  for(;;)  {    try    {      m_cSocket.SetOption(SOL_SOCKET, SO_SNDBUF, (char *)&iOptVal, sizeof(iOptVal));      break;    }    catch(E_Exception e)    {      iOptVal = iOptVal / 2;      if(iOptVal <= 524288/16)        throw E_Output("Unable to allocate output buffer", e);    }  }#ifdef HAVE_IPV6  if ((m_cSocket.GetDomain() == AF_INET6)&&	  (m_strType == "multicast")&&	  (m_strInterface != ""))  {	/* now get the ifindex for this interface */	/* and set the appropriate option */    int mcif = if_nametoindex(m_strInterface.GetString());	if (mcif == 0) perror("if_nametoindex()\n");	else m_cSocket.SetOption(IPPROTO_IPV6, IPV6_MULTICAST_IF,                                 (char *)&mcif, sizeof(mcif));  }#endif#ifdef HAVE_SO_BINDTODEVICE  // If an interface is specified then bind to it  // (Very useful when several interfaces are connected to the same subnet)  if(m_strInterface != "")  {    struct ifreq sInterface;    strncpy(sInterface.ifr_ifrn.ifrn_name,            m_strInterface.GetString(), IFNAMSIZ);    m_cSocket.SetOption(SOL_SOCKET, SO_BINDTODEVICE, (char *)&sInterface,                        sizeof(sInterface));  }#endif  // Set the Time To Live value if != 0  if(m_iTTL)  {	if (m_cSocket.GetDomain() == AF_INET)	{      if((m_strType == "unicast") || (m_strType == "broadcast"))        m_cSocket.SetOption(IPPROTO_IP, IP_TTL, (char *)&m_iTTL, sizeof(m_iTTL));      else if(m_strType == "multicast")        m_cSocket.SetOption(IPPROTO_IP, IP_MULTICAST_TTL,                            (char *)&m_iTTL, sizeof(m_iTTL));    }#ifdef HAVE_IPV6	else if (m_cSocket.GetDomain() == AF_INET6)	{	    /* of course broadcast does not exist in IPv6 */    	if((m_strType == "unicast") || (m_strType == "broadcast"))      		m_cSocket.SetOption(IPPROTO_IPV6, IPV6_UNICAST_HOPS,                                    (char *)&m_iTTL, sizeof(m_iTTL));	    else if(m_strType == "multicast")      		m_cSocket.SetOption(IPPROTO_IPV6, IPV6_MULTICAST_HOPS,                                    (char *)&m_iTTL, sizeof(m_iTTL));	}#endif  }  // Bind it to the local address if specified  if(m_strSrcHost.Length() != 0)    m_cSocket.Bind(m_strSrcHost, m_strSrcPort);#ifndef BUGGY_VLC  // Connect it  m_cSocket.Connect(m_strDstHost, m_strDstPort);#endif}//------------------------------------------------------------------------------// //------------------------------------------------------------------------------void C_NetOutput::OnClose(){  try  {    m_cSocket.Close();  }  catch(E_Exception e)  {    throw E_Output("Output termination failed", e);  }}//------------------------------------------------------------------------------////------------------------------------------------------------------------------////------------------------------------------------------------------------------void C_NetOutput::WriteToPort(bool RtpEncapsulation, u32 RtpSendTime){  ASSERT(m_pTsProvider);  unsigned int iPacketNumber = m_cTsBuff.Size();  int HeaderOffset;  bool HasDiscontinuity = 0;    if(iPacketNumber > 0)  {    // To avoid problems with the socket buff    ASSERT(iPacketNumber <= TS_IN_ETHER);    if (RtpEncapsulation)    {      HeaderOffset = RTP_HEADER_LEN;      m_pRtpHeader->BuildHeader(m_iRtpCounter++);      // Check for discontinuity in one of the TS packets      for(unsigned int iIndex = 0; iIndex < iPacketNumber; iIndex++)        HasDiscontinuity |= m_cTsBuff[iIndex].IsDiscontinuity();      m_pRtpHeader->SetRtpDiscontinuity(HasDiscontinuity);      // Convert to the 90kHzClock : RtpSendTime()*90 000/1 000 000      // Doing a /10 *9 /10 fo conversion / integer issues.      m_pRtpHeader->SetRtpTimeStamp( ((RtpSendTime/10)*9)/10 );#ifdef BUGGY_VLC      memcpy(m_ByteBuff, *m_pRtpHeader, RTP_HEADER_LEN);#endif    }    else HeaderOffset = 0;#ifdef BUGGY_VLC    // TS concatenation    for(unsigned int iIndex = 0; iIndex < iPacketNumber; iIndex++)      memcpy(m_ByteBuff + HeaderOffset + TS_PACKET_LEN * iIndex, m_cTsBuff[iIndex],             TS_PACKET_LEN);    // Send the data that were stored in the buffer    int iRc = PrivateWriteTo(HeaderOffset + TS_PACKET_LEN * iPacketNumber);    if(iRc != HeaderOffset + TS_IN_ETHER * TS_PACKET_LEN)      m_iByteLost += HeaderOffset + TS_IN_ETHER * TS_PACKET_LEN - iRc;#else    // Fill in the socketbuff    if (RtpEncapsulation)    { // Rtp Header First      m_cSocketBuff.SetSlotBuff(0,(char*)(byte*)*m_pRtpHeader);    }    for(unsigned int iIndex = 1; iIndex < iPacketNumber+1; iIndex++)    {      m_cSocketBuff.SetSlotBuff(iIndex,(char*)(byte*)m_cTsBuff[iIndex-1]);    }    // Send the data that were stored in the buffer    try    {      int iRc;      if (RtpEncapsulation)      {        iRc = m_cSocket.Send(m_cSocketBuff, iPacketNumber + 1 , 0);      }      else      {        // No Rtp : skip first SockBuff -> iOffset=1        iRc = m_cSocket.Send(m_cSocketBuff, iPacketNumber, 1);      }      if(iRc != HeaderOffset + TS_IN_ETHER * TS_PACKET_LEN)        m_iByteLost += HeaderOffset + TS_IN_ETHER * TS_PACKET_LEN - iRc;    }    catch(E_Exception e)    {      throw E_Output("Connection lost", e);    }#endif    // Free the now unused packets    C_TsPacket* pPacket;    for(unsigned int i = 0; i < iPacketNumber; i++)    {      // Pop the packet from the buffer      pPacket = m_cTsBuff.Pop();      ASSERT(pPacket);      // And release it      m_pTsProvider->ReleasePacket(pPacket);    }  }}//******************************************************************************// C_Net4Output class//******************************************************************************////******************************************************************************//------------------------------------------------------------------------------// //------------------------------------------------------------------------------C_Net4Output::C_Net4Output(const C_String& strChannelName) :                                                C_NetOutput(strChannelName){}//------------------------------------------------------------------------------// //------------------------------------------------------------------------------C_Net4Output::~C_Net4Output(){}//------------------------------------------------------------------------------// //------------------------------------------------------------------------------void C_Net4Output::OnInit(){  try  {#ifdef BUGGY_VLC    /* Build the destination address */    m_cOutputInetAddr.Build(m_strDstHost, m_strDstPort);#endif    // Open the socket    m_cSocket.Open(AF_INET, SOCK_DGRAM);    C_NetOutput::OnInit();#ifndef _WIN32    if(m_strType == "multicast")    {      struct ip_mreq imr;      C_Inet4Addr cAddr;      imr.imr_interface.s_addr = INADDR_ANY;      cAddr.Build(m_strDstHost, m_strDstPort);      imr.imr_multiaddr.s_addr = cAddr.GetInetAddr()->sin_addr.s_addr;      m_cSocket.SetOption(IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&imr, sizeof(imr));    }#endif  }  catch(E_Exception e)  {    throw E_Output("Net4Output initialisation failed", e);  }}//------------------------------------------------------------------------------// //------------------------------------------------------------------------------void C_Net4Output::OnClose(){  try  {#ifndef _WIN32    if(m_strType == "multicast")    {      struct ip_mreq imr;      C_Inet4Addr cAddr;      imr.imr_interface.s_addr = INADDR_ANY;      cAddr.Build(m_strDstHost, m_strDstPort);      imr.imr_multiaddr.s_addr = cAddr.GetInetAddr()->sin_addr.s_addr;      m_cSocket.SetOption(IPPROTO_IP, IP_DROP_MEMBERSHIP, (char *)&imr, sizeof(imr));    }#endif    C_NetOutput::OnClose();  }  catch(E_Exception e)  {    throw E_Output("Net4Output termination failed", e);  }}#ifdef BUGGY_VLC//------------------------------------------------------------------------------////------------------------------------------------------------------------------int C_Net4Output::PrivateWriteTo(int iBuffLen){  return m_cSocket.WriteTo(m_cOutputInetAddr, (char *)m_ByteBuff, iBuffLen);}#endif//******************************************************************************// C_Net6Output class//******************************************************************************////******************************************************************************#ifdef HAVE_IPV6//------------------------------------------------------------------------------// //------------------------------------------------------------------------------C_Net6Output::C_Net6Output(const C_String& strChannelName) :                                                C_NetOutput(strChannelName){}//------------------------------------------------------------------------------// //------------------------------------------------------------------------------C_Net6Output::~C_Net6Output(){}//------------------------------------------------------------------------------// //------------------------------------------------------------------------------void C_Net6Output::OnInit(){  try  {#ifdef BUGGY_VLC    /* Build the destination address */    m_cOutputInetAddr.Build(m_strDstHost, m_strDstPort, SOCK_DGRAM);#endif    // Open the socket    m_cSocket.Open(AF_INET6, SOCK_DGRAM);    C_NetOutput::OnInit();    if(m_strType == "multicast")    {      struct ipv6_mreq imr;      C_Inet6Addr cAddr;      imr.ipv6mr_interface = 0;      cAddr.Build(m_strDstHost, m_strDstPort, SOCK_DGRAM);      imr.ipv6mr_multiaddr = cAddr.GetInetAddr()->sin6_addr;      m_cSocket.SetOption(IPPROTO_IPV6, IPV6_JOIN_GROUP, (char *)&imr, sizeof(imr));    }  }  catch(E_Exception e)  {    throw E_Output("Net6Output initialisation failed", e);  }}//------------------------------------------------------------------------------// //------------------------------------------------------------------------------void C_Net6Output::OnClose(){  try  {    if(m_strType == "multicast")    {      struct ipv6_mreq imr;      C_Inet6Addr cAddr;      imr.ipv6mr_interface = 0;      cAddr.Build(m_strDstHost, m_strDstPort, SOCK_DGRAM);      imr.ipv6mr_multiaddr = cAddr.GetInetAddr()->sin6_addr;      m_cSocket.SetOption(IPPROTO_IPV6, IPV6_LEAVE_GROUP,                          (char *)&imr, sizeof(imr));    }    C_NetOutput::OnClose();  }  catch(E_Exception e)  {    throw E_Output("Net6Output termination failed", e);  }}#ifdef BUGGY_VLC//------------------------------------------------------------------------------////------------------------------------------------------------------------------int C_Net6Output::PrivateWriteTo(int iBuffLen){  return m_cSocket.WriteTo(m_cOutputInetAddr, (const char *) m_ByteBuff, iBuffLen);}#endif#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色94色欧美sute亚洲线路一ni| 亚洲一二三区在线观看| 国产一区999| 久久久久国产一区二区三区四区| 韩国精品久久久| 欧美激情中文字幕| 99精品视频在线免费观看| 一级日本不卡的影视| 欧美日韩成人一区二区| 日本一区中文字幕| 久久一日本道色综合| 成人精品一区二区三区中文字幕| 亚洲欧美综合另类在线卡通| 色婷婷综合久久久久中文| 日韩在线一二三区| www激情久久| av亚洲精华国产精华精华| 亚洲精品免费在线| 日韩一区二区三区av| 高清视频一区二区| 一区二区三区欧美激情| 在线91免费看| 成人亚洲一区二区一| 亚洲午夜久久久久| 精品99999| 91黄色免费看| 极品少妇xxxx偷拍精品少妇| 亚洲女人小视频在线观看| 日韩欧美不卡一区| 99re免费视频精品全部| 毛片一区二区三区| 国产精品灌醉下药二区| 日韩欧美在线影院| 91亚洲精品久久久蜜桃网站| 久久国产尿小便嘘嘘| 亚洲精选视频免费看| wwwwww.欧美系列| 91豆麻精品91久久久久久| 国产美女视频91| 亚洲午夜一区二区| 国产欧美精品一区二区色综合朱莉| 91激情在线视频| 国产成人精品一区二区三区四区| 天天影视涩香欲综合网| 国产精品国产三级国产有无不卡 | 亚洲国产一二三| 精品国产精品网麻豆系列 | 国产麻豆日韩欧美久久| 五月婷婷另类国产| ●精品国产综合乱码久久久久| 在线综合视频播放| 在线免费不卡电影| 成人污视频在线观看| 久久99国产精品免费| 亚洲第一激情av| 日韩一区在线看| 中文欧美字幕免费| 26uuu欧美日本| 欧美一区二区三区免费大片| 在线观看国产91| 色综合中文字幕国产 | 在线看日韩精品电影| 成人免费看视频| 国产精品91xxx| 国内成人免费视频| 老司机免费视频一区二区| 亚洲va欧美va国产va天堂影院| 亚洲精品欧美在线| 亚洲精品高清在线| 最新热久久免费视频| 国产蜜臀av在线一区二区三区| 精品国产伦理网| 26uuu精品一区二区三区四区在线| 欧美日韩国产a| 7777精品久久久大香线蕉| 欧美日韩另类一区| 在线播放亚洲一区| 欧美高清精品3d| 日韩一区二区三区观看| 日韩三级伦理片妻子的秘密按摩| 日韩午夜在线影院| 精品剧情在线观看| 久久久久久9999| 一色屋精品亚洲香蕉网站| 亚洲女厕所小便bbb| 一区二区不卡在线播放| 日日夜夜免费精品视频| 青草av.久久免费一区| 麻豆久久久久久| 国产白丝精品91爽爽久久| 波多野结衣中文字幕一区 | 欧美视频完全免费看| 欧美日本视频在线| 日韩女优电影在线观看| 久久综合国产精品| 欧美激情综合网| 亚洲影院理伦片| 美腿丝袜亚洲综合| 国模无码大尺度一区二区三区| 国产一区二区导航在线播放| 懂色一区二区三区免费观看| 99久久精品免费看| 欧美日韩夫妻久久| 久久免费视频一区| 亚洲你懂的在线视频| 香蕉影视欧美成人| 国产成人免费在线视频| 在线精品国精品国产尤物884a| 91超碰这里只有精品国产| 国产无人区一区二区三区| 亚洲你懂的在线视频| 美女一区二区三区在线观看| 国产成人免费在线视频| 欧美性大战久久久| 日韩一区二区电影在线| 国产精品无圣光一区二区| 无码av中文一区二区三区桃花岛| 韩国女主播一区| 在线观看区一区二| 久久天堂av综合合色蜜桃网| 亚洲欧美日韩系列| 国模少妇一区二区三区| 在线免费观看一区| 久久久久高清精品| 丝袜美腿亚洲一区二区图片| 国产精品白丝jk白祙喷水网站| 精品视频1区2区3区| 欧美激情一区二区三区全黄| 男人操女人的视频在线观看欧美| 91在线云播放| 久久久美女艺术照精彩视频福利播放| 亚洲一区在线观看网站| 国产精品资源站在线| 欧美一区三区二区| 一区二区三区久久| 国产**成人网毛片九色| 欧美成人福利视频| 亚洲国产色一区| av高清不卡在线| 久久久精品中文字幕麻豆发布| 三级欧美在线一区| 在线观看亚洲a| 亚洲丝袜另类动漫二区| 国产在线精品一区二区三区不卡| 欧美精品日日鲁夜夜添| 中文字幕人成不卡一区| 国产盗摄精品一区二区三区在线| 日韩欧美一二区| 亚洲va国产天堂va久久en| caoporn国产一区二区| 久久亚洲综合av| 麻豆国产精品官网| 这里只有精品电影| 亚洲va欧美va人人爽| 精品视频在线免费看| 亚洲精品成人悠悠色影视| 91在线国内视频| 国产精品久久久久久久岛一牛影视| 国产精品一线二线三线精华| 精品福利av导航| 九色综合国产一区二区三区| 日韩免费性生活视频播放| 日本成人超碰在线观看| 欧美久久久一区| 丝袜亚洲另类丝袜在线| 91精品国产全国免费观看| 日本中文字幕一区二区有限公司| 欧美日韩高清一区二区三区| 一区二区三区久久久| 欧美亚洲一区二区在线观看| 亚洲线精品一区二区三区八戒| 色狠狠色噜噜噜综合网| 一个色在线综合| 欧美日韩亚洲综合一区二区三区| 亚洲一区二区综合| 欧美另类videos死尸| 日韩高清在线电影| 欧美xxxxxxxx| 岛国精品一区二区| 成人欧美一区二区三区1314| 91女人视频在线观看| 亚洲午夜激情网站| 日韩欧美激情一区| 国产露脸91国语对白| 欧美国产1区2区| 色老头久久综合| 日韩国产精品久久久久久亚洲| 欧美mv日韩mv国产网站| 国产一区二区免费视频| 亚洲欧美综合另类在线卡通| 欧美日韩精品一二三区| 美腿丝袜亚洲一区| 中文字幕成人在线观看| 色婷婷av一区二区三区之一色屋| 亚洲午夜一二三区视频| 日韩欧美一二区| 99久精品国产| 奇米一区二区三区av| 国产欧美日韩在线| 欧美在线不卡视频|