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

📄 maxrecording.cxx

📁 RTP协议
💻 CXX
字号:
/* ==================================================================== * The Vovida Software License, Version 1.0  *  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved. *  * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: *  * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. *  * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in *    the documentation and/or other materials provided with the *    distribution. *  * 3. The names "VOCAL", "Vovida Open Communication Application Library", *    and "Vovida Open Communication Application Library (VOCAL)" must *    not be used to endorse or promote products derived from this *    software without prior written permission. For written *    permission, please contact vocal@vovida.org. * * 4. Products derived from this software may not be called "VOCAL", nor *    may "VOCAL" appear in their name, without prior written *    permission of Vovida Networks, Inc. *  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. *  * ==================================================================== *  * This software consists of voluntary contributions made by Vovida * Networks, Inc. and many individuals on behalf of Vovida Networks, * Inc.  For more information on Vovida Networks, Inc., please see * <http://www.vovida.org/>. * */static const char* const maxRecording_cxx_Version =    "$Id: maxRecording.cxx,v 1.6 2001/05/13 08:33:20 icahoon Exp $";#include <stdlib.h>#include <unistd.h>#include <fstream>#include <stdio.h>#include "rtpTypes.h"#include "RtpSession.hxx"#include "TimeTracker.hxx"#include "support.hxx"int main (int argc, char *argv[]){    // allocate and initialize default configuration values    // note, you may need to create two executable, each with the    // others address info    char rmtHost[256] = "vvs-tennis";    int max_sessions = 100;    int rmtPort = 7000;    int lclPort = 5000;    int apSize = 160;    int npSize = 160;    int numPkts = 10000;    TimeTracker T(cerr);    if (argc == 1)    {        cout << "Usage: ./maxRtpSessions host sessions rmt_start_port lcl_start_port num_packets" << endl;        return 0;    }     else if (argc == 6)    {        strcpy( rmtHost, argv[1] );        max_sessions = atoi( argv[2] );        rmtPort = atoi( argv[3] );        lclPort = atoi( argv[4] );        numPkts = atoi( argv[5] );    }    else    {        printf("Enter remote hostname: ");        scanf ("%s", rmtHost);        printf("Enter number of the max rtp sessions: ");        scanf ("%d", &max_sessions);        printf("Enter remote port number: ");        scanf ("%d", &rmtPort);        printf("Enter local port number: ");        scanf ("%d", &lclPort);        printf("Enter number of packets sending or receiving: ");        scanf ("%d", &numPkts);    }    pid_t pid;    int seqnum1 = 0;    int seqnum2 = 0;    for (int j=0; j < max_sessions; j++)    {        if ((pid = fork()) < 0)        {            cerr << "Fork failed." << endl;            return -1;        }        else if (pid == 0)        {            cout << "Get pid is: " << getpid() <<endl;            cout << "Creating rtp session " << j << endl;            RtpSession* stack = new RtpSession ( rmtHost,                                      rmtPort + 2*j, lclPort + 2*j,                                     rmtPort + 2*j + 1, lclPort + 2*j + 1,                                      rtpPayloadPCMU, rtpPayloadPCMU, 5);            RtpPacket* inPacket = NULL;                    stack->setApiFormat (rtpPayloadPCMU, apSize);            stack->setNetworkFormat (rtpPayloadPCMU, npSize);                   string filename = itos((unsigned int) j);            filename.append(".data");            ofstream file(filename.c_str(), ios::out);            if (!file)            {                cerr << "Could not open file: " << filename << endl;                return 3;            }            int i = 0;            while (i < (numPkts )) // assumming allowing 5 packets lost            {//                cerr << "?" << endl;                // receive a packet                inPacket = stack->receive ();                if (inPacket)                {                    seqnum2 = inPacket->getSequence();                    if (i == 0)                     {                        T.startTime();                        seqnum1 = inPacket->getSequence();                    }                    i++;//                    cerr << "get packets: " << i << endl;                    file.write(inPacket->getPayloadLoc(), inPacket->getPayloadUsage());                    delete inPacket;                    inPacket = NULL;                }                else                {                }                        // send and receive RTCP packet                if (stack->checkIntervalRTCP())                {                    stack->transmitRTCP();                }                if (stack->receiveRTCP() == 1)                {                   break;                }                             usleep(1*1000);            }                    stack->transmitRTCPBYE();                    if (inPacket)            {                delete inPacket;                inPacket = NULL;            }                    delete stack;            stack = NULL;            T.endTime();            cout << "get packets: " << i << endl;            cerr << " start seq num = " << seqnum1 << endl;            cout << "   end seq num = " << seqnum2 << endl;            cout << "End rtp session " << j << endl << endl;            return 3;//            break;        }    }    return 0;}

⌨️ 快捷键说明

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