⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sapwatch.cpp

📁 流媒体传输协议的实现代码,非常有用.可以支持rtsp mms等流媒体传输协议
💻 CPP
字号:
/**********This library is free software; you can redistribute it and/or modify it underthe terms of the GNU Lesser General Public License as published by theFree Software Foundation; either version 2.1 of the License, or (at youroption) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)This library is distributed in the hope that it will be useful, but WITHOUTANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSFOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License formore details.You should have received a copy of the GNU Lesser General Public Licensealong with this library; if not, write to the Free Software Foundation, Inc.,59 Temple Place, Suite 330, Boston, MA  02111-1307  USA**********/// Copyright (c) 1996-2001, Live Networks, Inc.  All rights reserved// A program that receives and prints SDP/SAP announcements// (on the default SDP/SAP directory: 224.2.127.254/9875)#include "Groupsock.hh"#include "GroupsockHelper.hh"#include "BasicUsageEnvironment.hh"#include <stdio.h>static unsigned const maxPacketSize = 65536;static unsigned char packet[maxPacketSize+1];int main(int argc, char** argv) {  // Begin by setting up our usage environment:  TaskScheduler* scheduler = BasicTaskScheduler::createNew();  UsageEnvironment* env = BasicUsageEnvironment::createNew(*scheduler);  // Create a 'groupsock' for the input multicast group,port:  char* sessionAddressStr = "224.2.127.254";  struct in_addr sessionAddress;  sessionAddress.s_addr = our_inet_addr(sessionAddressStr);  const Port port(9875);  const unsigned char ttl = 0; // we're only reading from this mcast group    Groupsock inputGroupsock(*env, sessionAddress, port, ttl);    // Start reading and printing incoming packets  // (Because this is the only thing we do, we can just do this  // synchronously, in a loop, so we don't need to set up an asynchronous  // event handler like we do in most of the other test programs.)  unsigned packetSize;  struct sockaddr_in fromAddress;  while (inputGroupsock.handleRead(packet, maxPacketSize,				   packetSize, fromAddress)) {    printf("\n[packet from %s (%d bytes)]\n",	   our_inet_ntoa(fromAddress.sin_addr), packetSize);    // Ignore the first 8 bytes (SAP header).    if (packetSize < 8) {      *env << "Ignoring short packet from "	   << our_inet_ntoa(fromAddress.sin_addr) << "%s!\n";      continue;    }    packet[packetSize] = '\0'; // just in case    printf((char*)(packet+8));  }  return 0; // only to prevent compiler warning}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -