1ca16f5cbSbeveloper #include <stdio.h> 2*bce1ab5eSbeveloper #include <string.h> 3ca16f5cbSbeveloper #include <DataIO.h> 4ca16f5cbSbeveloper #include "RawDecoderPlugin.h" 5ca16f5cbSbeveloper 6ca16f5cbSbeveloper #define TRACE_THIS 1 7ca16f5cbSbeveloper #if TRACE_THIS 8ca16f5cbSbeveloper #define TRACE printf 9ca16f5cbSbeveloper #else 10ca16f5cbSbeveloper #define TRACE ((void)0) 11ca16f5cbSbeveloper #endif 12ca16f5cbSbeveloper 13ca16f5cbSbeveloper 14ca16f5cbSbeveloper status_t 15*bce1ab5eSbeveloper RawDecoder::Setup(media_format *ioEncodedFormat, media_format *ioDecodedFormat, 16*bce1ab5eSbeveloper const void *infoBuffer, int32 infoSize) 17ca16f5cbSbeveloper { 18*bce1ab5eSbeveloper if (ioEncodedFormat->type != B_MEDIA_RAW_AUDIO && ioEncodedFormat->type != B_MEDIA_RAW_VIDEO) 19ca16f5cbSbeveloper return B_ERROR; 20ca16f5cbSbeveloper 21*bce1ab5eSbeveloper if (ioEncodedFormat->type == B_MEDIA_RAW_VIDEO) 22*bce1ab5eSbeveloper fFrameSize = ioEncodedFormat->u.raw_video.display.line_count * ioEncodedFormat->u.raw_video.display.bytes_per_row; 23*bce1ab5eSbeveloper else 24*bce1ab5eSbeveloper fFrameSize = (ioEncodedFormat->u.raw_audio.format & 0xf) * ioEncodedFormat->u.raw_audio.channel_count; 25*bce1ab5eSbeveloper 26*bce1ab5eSbeveloper *ioDecodedFormat = *ioEncodedFormat; 27*bce1ab5eSbeveloper 28ca16f5cbSbeveloper return B_OK; 29ca16f5cbSbeveloper } 30ca16f5cbSbeveloper 31ca16f5cbSbeveloper 32ca16f5cbSbeveloper status_t 33ca16f5cbSbeveloper RawDecoder::Seek(media_seek_type seekTo, 34*bce1ab5eSbeveloper int64 seekFrame, int64 *frame, 35*bce1ab5eSbeveloper bigtime_t seekTime, bigtime_t *time) 36ca16f5cbSbeveloper { 37ca16f5cbSbeveloper return B_OK; 38ca16f5cbSbeveloper } 39ca16f5cbSbeveloper 40ca16f5cbSbeveloper 41ca16f5cbSbeveloper status_t 42ca16f5cbSbeveloper RawDecoder::Decode(void *buffer, int64 *frameCount, 43ca16f5cbSbeveloper media_header *mediaHeader, media_decode_info *info) 44ca16f5cbSbeveloper { 45*bce1ab5eSbeveloper void *chunkBuffer; 46*bce1ab5eSbeveloper int32 chunkSize; 47*bce1ab5eSbeveloper if (B_OK != GetNextChunk(&chunkBuffer, &chunkSize, mediaHeader)) 48*bce1ab5eSbeveloper return B_ERROR; 49*bce1ab5eSbeveloper 50*bce1ab5eSbeveloper memcpy(buffer, chunkBuffer, chunkSize); 51*bce1ab5eSbeveloper *frameCount = chunkSize / fFrameSize; 52*bce1ab5eSbeveloper 53ca16f5cbSbeveloper return B_OK; 54ca16f5cbSbeveloper } 55ca16f5cbSbeveloper 56ca16f5cbSbeveloper 57ca16f5cbSbeveloper Decoder * 58ca16f5cbSbeveloper RawDecoderPlugin::NewDecoder() 59ca16f5cbSbeveloper { 60ca16f5cbSbeveloper return new RawDecoder; 61ca16f5cbSbeveloper } 62ca16f5cbSbeveloper 63*bce1ab5eSbeveloper status_t 64*bce1ab5eSbeveloper RawDecoderPlugin::RegisterPlugin() 65*bce1ab5eSbeveloper { 66*bce1ab5eSbeveloper media_format fmt; 67*bce1ab5eSbeveloper memset(&fmt, 0, sizeof(fmt)); 68*bce1ab5eSbeveloper fmt.type = B_MEDIA_RAW_AUDIO; 69*bce1ab5eSbeveloper PublishDecoder("raw audio", "RAW audio decoder", fmt); 70*bce1ab5eSbeveloper fmt.type = B_MEDIA_RAW_VIDEO; 71*bce1ab5eSbeveloper PublishDecoder("raw video", "RAW video decoder", fmt); 72*bce1ab5eSbeveloper return B_OK; 73*bce1ab5eSbeveloper } 74ca16f5cbSbeveloper 75ca16f5cbSbeveloper MediaPlugin *instantiate_plugin() 76ca16f5cbSbeveloper { 77ca16f5cbSbeveloper return new RawDecoderPlugin; 78ca16f5cbSbeveloper } 79