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