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