1 /* 2 * Copyright 2011, Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * SHINTA 7 */ 8 #include "ImageTrackVideoSupplier.h" 9 10 #include <string.h> 11 12 13 ImageTrackVideoSupplier::ImageTrackVideoSupplier(BBitmap* bitmap, 14 int32 trackIndex, status_t& initStatus) 15 : 16 VideoTrackSupplier(), 17 fPerformanceTime(0), 18 fDuration(0), 19 fCurrentFrame(0), 20 fBitmap(bitmap), 21 fTrackIndex(trackIndex) 22 { 23 fFormat.type = B_MEDIA_ENCODED_VIDEO; 24 fFormat.u.encoded_video.output.field_rate = 0.0; 25 fFormat.u.encoded_video.output.interlace = 1; 26 fFormat.u.encoded_video.output.first_active = 0; 27 fFormat.u.encoded_video.output.orientation = B_VIDEO_TOP_LEFT_RIGHT; 28 fFormat.u.encoded_video.output.display.format = B_RGB32; 29 fFormat.u.encoded_video.output.pixel_width_aspect 30 = fFormat.u.raw_video.display.line_width 31 = static_cast<int32>(fBitmap->Bounds().right) + 1; 32 fFormat.u.encoded_video.output.pixel_height_aspect 33 = fFormat.u.raw_video.display.line_count 34 = static_cast<int32>(fBitmap->Bounds().bottom) + 1; 35 fFormat.u.encoded_video.output.display.bytes_per_row 36 = fFormat.u.raw_video.display.line_width * sizeof(int32); 37 fFormat.u.encoded_video.output.display.pixel_offset = 0; 38 fFormat.u.encoded_video.output.display.line_offset = 0; 39 fFormat.u.encoded_video.output.display.flags = 0; 40 fFormat.u.encoded_video.output.last_active 41 = fFormat.u.raw_video.display.line_count - 1; 42 fFormat.u.encoded_video.avg_bit_rate = 0.0; 43 fFormat.u.encoded_video.max_bit_rate = 0.0; 44 fFormat.u.encoded_video.encoding = media_encoded_video_format::B_ANY; 45 fFormat.u.encoded_video.frame_size 46 = fFormat.u.encoded_video.output.display.bytes_per_row * 47 fFormat.u.raw_video.display.line_count; 48 fFormat.u.encoded_video.forward_history = 0; 49 fFormat.u.encoded_video.backward_history = 0; 50 51 initStatus = B_OK; 52 } 53 54 55 ImageTrackVideoSupplier::~ImageTrackVideoSupplier() 56 { 57 } 58 59 60 const media_format& 61 ImageTrackVideoSupplier::Format() const 62 { 63 return fFormat; 64 } 65 66 67 status_t 68 ImageTrackVideoSupplier::GetEncodedFormat(media_format* format) const 69 { 70 *format = fFormat; 71 return B_OK; 72 } 73 74 75 status_t 76 ImageTrackVideoSupplier::GetCodecInfo(media_codec_info* info) const 77 { 78 strlcpy(info->pretty_name, "Artwork (static image)", 79 sizeof(info->pretty_name)); 80 strlcpy(info->short_name, "Artwork", sizeof(info->short_name)); 81 info->id = info->sub_id = 0; 82 83 return B_OK; 84 } 85 86 87 status_t 88 ImageTrackVideoSupplier::ReadFrame(void* buffer, bigtime_t* performanceTime, 89 const media_raw_video_format& format, bool& wasCached) 90 { 91 uint32 size = format.display.bytes_per_row * format.display.line_count; 92 memcpy(buffer, fBitmap->Bits(), size); 93 return B_OK; 94 } 95 96 97 status_t 98 ImageTrackVideoSupplier::FindKeyFrameForFrame(int64* frame) 99 { 100 return B_OK; 101 } 102 103 104 status_t 105 ImageTrackVideoSupplier::SeekToTime(bigtime_t* performanceTime) 106 { 107 return B_OK; 108 } 109 110 111 status_t 112 ImageTrackVideoSupplier::SeekToFrame(int64* frame) 113 { 114 return B_OK; 115 } 116 117 118