This file is indexed.

/usr/include/ptclib/delaychan.h is in libpt-dev 2.10.11~dfsg-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
/*
 * delaychan.h
 *
 * Class for implementing a serial queue channel in memory.
 *
 * Portable Windows Library
 *
 * Copyright (c) 2001 Equivalence Pty. Ltd.
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.0 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 * the License for the specific language governing rights and limitations
 * under the License.
 *
 * The Original Code is Portable Windows Library.
 *
 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
 *
 * Contributor(s): ______________________________________.
 *
 * $Revision: 24177 $
 * $Author: rjongbloed $
 * $Date: 2010-04-05 06:52:04 -0500 (Mon, 05 Apr 2010) $
 */

#ifndef PTLIB_DELAYCHAN_H
#define PTLIB_DELAYCHAN_H
#include <ptlib/contain.h>
#include <ptlib/object.h>
#include <ptlib/timeint.h>
#include <ptlib/ptime.h>
#include <ptlib/indchan.h>

#ifdef P_USE_PRAGMA
#pragma interface
#endif


/** Class for implementing an "adaptive" delay.
    This class will cause the the caller to, on average, delay
    the specified number of milliseconds between calls. This can
    be used to simulate hardware timing for a sofwtare only device

  */


class PAdaptiveDelay : public PObject
{ 
  PCLASSINFO(PAdaptiveDelay, PObject);
  
  public:

  /**@name Construction */
  //@{
    /**Create a new adaptive delay with the specified parameters.

       The maximum slip time can also be set later using SetMaximumSlip.
      */
    PAdaptiveDelay(
      unsigned maximumSlip = 0,   ///< Maximum slip time in milliseconds
      unsigned minimumDelay = 0   ///< Minimum delay (usually OS time slice)
    );
  //@}

  /**@name Operating Parameters */
  //@{
    /**Set the number of milliseconds that the delay may "catch up" by
       using zero delays. This is caused by the Delay() function not
       being called for a time by external factors.

       If @a maximumSlip is 0, this feature is disabled.
      */
    void SetMaximumSlip(PTimeInterval maximumSlip)
    { jitterLimit = maximumSlip; }

    /**Get the current slip time. */
    PTimeInterval GetMaximumSlip() const
    { return jitterLimit; }
  //@}

  /**@name Functionality */
  //@{
    /**Wait until the specified number of milliseconds have elapsed from
       the previous call (on average). The first time the function is called,
       no delay occurs. If the maximum slip time is set and the caller
       is "too late", the timer is restarted automatically and no delay
       occurs.

       If the calculated delay is less than the OS timer resolution
       specified on costruction, no delay occurs now ("better sooner
       than later" strategy).

       @return
       true if we are "too late" of @a time milliseconds (unrelated to
       the maximum slip time).
      */
    PBoolean Delay(int time);

    /**Invalidate the timer. The timing of this function call is not
       important, the timer will restart at the next call to Delay().
      */
    void Restart();
  //@}
 
  protected:
    PBoolean   firstTime;
    PTime  targetTime;

    PTimeInterval  jitterLimit;
    PTimeInterval  minimumDelay;
};


/** Class for implementing a "delay line" channel.
    This indirect channel can be placed in a channel I/O chain to limit the
    speed of I/O. This can be useful if blocking is not available and buffers
    could be overwritten if the I/O occurs at full speed.

    There are two modes of operation. In stream more, data can be read/written
    no faster than a fixed time for a fixed number of bytes. So, for example,
    you can say than 320 bytes must take 20 milliseconds, and thus if the
    application writes 640 byets it will delay 40 milliseconds before the next
    write.

    In frame mode, the rate limiting applies to individual read or write
    operations. So you can say that each read takes 30 milliseconds even if
    on 4 bytes is read, and the same time if 24 bytes are read.
  */
class PDelayChannel : public PIndirectChannel
{
    PCLASSINFO(PDelayChannel, PIndirectChannel);
  public:
  /**@name Construction */
  //@{
    enum Mode {
      DelayReadsOnly,
      DelayWritesOnly,
      DelayReadsAndWrites
    };

    /** Create a new delay channel with the specified delays. A value of zero
        for the numBytes parameter indicates that the delay is in frame mode.

        The maximum skip time is the number of milliseconds that the delay
        may "catch up" by using zero delays. This is caused by the Read() or
        Write() not being called for a time by external factors.
      */
    PDelayChannel(
      Mode mode,                  ///< Mode for delay channel
      unsigned frameDelay,        ///< Delay time in milliseconds
      PINDEX frameSize = 0,       ///< Bytes to apply to the delay time.
      unsigned maximumSlip = 250, ///< Maximum slip time in milliseconds
      unsigned minimumDelay = 10  ///< Minimim delay (usually OS time slice)
    );
    
    /** Create a new delay channel with the specified delays and channel. A value of zero
    for the numBytes parameter indicates that the delay is in frame mode.

    The maximum skip time is the number of milliseconds that the delay
    may "catch up" by using zero delays. This is caused by the Read() or
    Write() not being called for a time by external factors.
     */
    PDelayChannel(
        PChannel &channel,          ///< channel to use 
        Mode mode,                  ///< Mode for delay channel
        unsigned frameDelay,        ///< Delay time in milliseconds
        PINDEX frameSize = 0,       ///< Bytes to apply to the delay time.
        unsigned maximumSlip = 250, ///< Maximum slip time in milliseconds
        unsigned minimumDelay = 10  ///< Minimim delay (usually OS time slice)
                 );    
  //@}


  /**@name Overrides from class PChannel */
  //@{
    /**Low level read from the file channel. The read timeout is ignored for
       file I/O. The GetLastReadCount() function returns the actual number
       of bytes read.

       The GetErrorCode() function should be consulted after Read() returns
       false to determine what caused the failure.

       @return
       true indicates that at least one character was read from the channel.
       false means no bytes were read due to timeout or some other I/O error.
     */
    virtual PBoolean Read(
      void * buf,   ///< Pointer to a block of memory to receive the read bytes.
      PINDEX len    ///< Maximum number of bytes to read into the buffer.
    );

    /**Low level write to the file channel. The write timeout is ignored for
       file I/O. The GetLastWriteCount() function returns the actual number
       of bytes written.

       The GetErrorCode() function should be consulted after Write() returns
       false to determine what caused the failure.

       @return true if at least len bytes were written to the channel.
     */
    virtual PBoolean Write(
      const void * buf, ///< Pointer to a block of memory to write.
      PINDEX len        ///< Number of bytes to write.
    );
  //@}


  protected:
    virtual void Wait(PINDEX count, PTimeInterval & nextTick);

    Mode          mode;
    unsigned      frameDelay;
    PINDEX        frameSize;
    PTimeInterval maximumSlip;
    PTimeInterval minimumDelay;

    PTimeInterval nextReadTick;
    PTimeInterval nextWriteTick;
};


#endif // PTLIB_DELAYCHAN_H


// End Of File ///////////////////////////////////////////////////////////////