Mercurial > projects > hoofbaby
view src/impl/hoofbaby/codec/libav/avbuffer.d @ 0:3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
author | fraserofthenight |
---|---|
date | Mon, 06 Jul 2009 08:06:28 -0700 |
parents | |
children |
line wrap: on
line source
/** * Hoofbaby -- http://www.dsource.org/projects/hoofbaby * Copyright (C) 2009 Robert Fraser * * This program is free software; you can redistribute it andor * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ module hoofbaby.codec.libav.avbuffer; import hoofbaby.codec.libav.avformat; import hoofbaby.util.buffer; import tango.stdc.stdlib; import tango.stdc.string; import tango.stdc.stdio; ByteIOContext* getBioContext(RingBuffer* buf, int maxPacketSize) { ByteIOContext* bio = av_alloc_put_byte(cast(char*) malloc(1 << 16), 1 << 16, 1, buf, null, &hoofbaby_avbuffer_write, null); if(bio) bio.is_streamed = true; return bio; } extern(C) int hoofbaby_avbuffer_write(void* _buf, char* data, int size) { RingBuffer* buf = cast(RingBuffer*) _buf; assert(buf); void* p = buf.beginWrite(size); assert(p); memcpy(p, data, size); buf.endWrite(size); return 0; }