示例#1
0
void CCAcc::invoke(const string& method, const AmArg& args, AmArg& ret)
{
    if(method == "getCredit"){
      assertArgCStr(args.get(0));
      ret.push(getCredit(args.get(0).asCStr()));
    } else if(method == "subtractCredit"){
      assertArgCStr(args.get(0));
      assertArgInt(args.get(1));
      ret.push(subtractCredit(args.get(0).asCStr(),
			      args.get(1).asInt()));	
    } else if(method == "addCredit"){
      assertArgCStr(args.get(0));
      assertArgInt(args.get(1));
      ret.push(addCredit(args.get(0).asCStr(),
			 args.get(1).asInt()));	
    } else if(method == "setCredit"){
      assertArgCStr(args.get(0));
      assertArgInt(args.get(1));
      ret.push(setCredit(args.get(0).asCStr(),
			 args.get(1).asInt()));	
    } else if(method == "_list"){
      ret.push("getCredit");
      ret.push("subtractCredit");
      ret.push("setCredit");
      ret.push("addCredit");
    }
    else
	throw AmDynInvoke::NotImplemented(method);
}
示例#2
0
/*
* RTP packet transmitted
*/
gfloat ScreamTx::addTransmitted(guint64 time_us,
    guint32 ssrc,
    gint size,
    guint16 seqNr) {
        if (!isInitialized) 
            initialize(time_us);

        int k = 0;
        int ix = -1;
        while (k < kMaxTxPackets) {
            if (txPackets[k].isUsed == FALSE) {
                ix = k;
                break;
            }
            k++;
        }
        if (ix == -1) {
            /*
            * If you end up here then it is necessary to increase
            * kMaxTxPackets
            */
            ix = 0;
            cerr << "Max number of txPackets allocated" << endl;
        }
        txPackets[ix].timestamp = (guint32) (time_us/1000);
        txPackets[ix].timeTx_us = time_us;
        txPackets[ix].ssrc = ssrc;
        txPackets[ix].size = size;
        txPackets[ix].seqNr = seqNr;
        txPackets[ix].isUsed = TRUE;

        Stream* stream = getStream(ssrc);
        stream->bytesTransmitted += size;
        lastTransmitT_us = time_us;
        /*
        * Add credit to unserved streams
        */
        addCredit(time_us, stream, size);
        /*
        * Reduce used credit for served stream
        */
        subtractCredit(time_us, stream, size);
        /*
        * compute paceInterval, we assume a min bw of 50kbps and a min tp of 1ms
        * for stable operation
        * this function implements the packet pacing
        */
        gfloat paceInterval = kMinPaceInterval;
        pacingBitrate = MAX(kMinimumBandwidth,cwnd * 8.0f / MAX(0.001f,getSRtt()));
        gfloat tp = (size * 8.0f) / pacingBitrate;
        if (owdFractionAvg > 0.1f && kEnablePacketPacing) {
            paceInterval = MAX(kMinPaceInterval,tp);
        }
        if (kBypassTxSheduling) {
            paceInterval = 0.0;
        }
        guint64 paceInterval_us = (guint64) (paceInterval*1000000);

        /*
        * Update MSS and cwndMin
        */
        mss = MAX(mss, size);
        cwndMin = 2 * mss;

        /*
        * Determine when next RTP packet can be transmitted
        */
        nextTransmitT_us = time_us + paceInterval_us;

        return paceInterval;
}