Kamaelia

Nuts & Bolts | Components | Tools | Cookbook | Systems
wiki:( guest720857, Dev Console, Index, Recent, Edit )


Home, News
Dev Console

How, Why
Project Blog
Summer of Code

Documentation
Download
SVN (web)
Sourceforge page

Project Admin
License

Contact Us

  Page Tags

No tags are defined for this page yet - how would you classify/think of this page? Add your notes below!

Kamaelia docs : Kamaelia.Util.RateChunker

Breaks data into chunks matching a required chunk rate

Send data, such as binary strings to this component and it will break it down to roughly constant sized chunks, to match a required 'rate' of chunk emission.

This is not about 'real time' chunking of a live data source, but is instead about precisely chunking data that you know has been generated, or will be consumed, at a particular rate.

You specify the 'rate' of the incoming data and the rate you want chunks sent out at. RateChunker will determine what size the chunks need to be, applying dynamic rounding to precisely match the rate without drift over time.

Example Usage

Chunking a stream of 48KHz 16bit stereo audio into 25 chunks per second of audio data (one chunk for each frame of a corresponding piece of 25fps video):

bps = bytesPerSample = 2*2

Pipeline( AudioSource(),
          RateChunker(datarate=48000*bps, quantasize=bps, chunkrate=25),
          ...
        )

The quanta size ensures that the chunks RateChunker sends out always contain a whole number of samples (4 bytes per sample).

Behaviour

At initialisation, specify:

  • the rate of the incoming data (eg. bytes/second)
  • the required rate of outgoing chunks of data
  • the minimum quanta size (see below)

Send slicable data items, such as strings containing binary data to the "inbox" inbox. The same data is sent out of the "outbox" outbox, rechunked to meet the required chunk rate.

The outgoing chunk sizes are dynamically varied to match the required chunk rate as accurately as possible. The quantasize parameter dictates the minimum unit by which the chunksize will be varied.

For example, for 16bit stereo audio data, there are 4 bytes per sample, so a quantasize of 4 should be specified, to make sure samples remain whole.

If a producerFinished or shutdownMicroprocess message is received on the "control" inbox. It is immediately sent on out of the "signal" outbox and the component then immediately terminates.


Kamaelia.Util.RateChunker.RateChunker

class RateChunker(Axon.Component.component)

RateChunker(datarate,quantasize,chunkrate) -> new Chunk component.

Alters the chunksize of incoming data to match a desired chunkrate.

Keyword arguments:

  • datarate -- rate of the incoming data
  • quantasize -- minimum granularity with which the data can be split
  • chunkrate -- desired chunk rate

Inboxes

  • control : Shutdown signalling
  • inbox : Data items

Outboxes

  • outbox : Rechunked data items
  • signal : Shutdown signalling

Methods defined here

Warning!

You should be using the inbox/outbox interface, not these methods (except construction). This documentation is designed as a roadmap as to their functionalilty for maintainers and new component developers.

__init__(self, datarate, quantasize, chunkrate)

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

main(self)

Main loop

Feedback

Got a problem with the documentation? Something unclear that could be clearer? Want to help improve it? Constructive criticism is very welcome - especially if you can suggest a better rewording!

Please leave you feedback here in reply to the documentation thread in the Kamaelia blog.

-- Automatic documentation generator, 20 Jul 2008 at 03:02:36 UTC/GMT


Your tags for this page: If you had set UserPreferences (name & email) and validated them (simple single click in your email), you would be able to define personal tags

Versions: current , 1


(C) 2005 Kamaelia Contributors, including the British Broadcasting Corporation, All Rights Reserved,
This is an ongoing community based development site. As a result the contents of this page is the opinions of the contributors of the pages involved not the organisations involved. Specificially, this page may contain personal views which are not the views of the BBC.