1 // MediaWriterAddOn.cpp
3 // Andrew Bachmann, 2002
5 // A MediaWriterAddOn is an add-on
6 // that can make MediaWriter nodes
8 // MediaWriter nodes write a multistream into a file
11 #include <MediaDefs.h>
12 #include <MediaAddOn.h>
16 #include <StorageDefs.h>
18 #include "MediaWriter.h"
19 #include "MediaWriterAddOn.h"
25 // instantiation function
26 extern "C" _EXPORT BMediaAddOn
* make_media_addon(image_id image
) {
27 return new MediaWriterAddOn(image
);
30 // -------------------------------------------------------- //
32 // -------------------------------------------------------- //
34 MediaWriterAddOn::~MediaWriterAddOn()
38 MediaWriterAddOn::MediaWriterAddOn(image_id image
) :
39 AbstractFileInterfaceAddOn(image
)
41 fprintf(stderr
,"MediaWriterAddOn::MediaWriterAddOn\n");
44 // -------------------------------------------------------- //
46 // -------------------------------------------------------- //
48 status_t
MediaWriterAddOn::GetFlavorAt(
50 const flavor_info
** out_info
)
52 fprintf(stderr
,"MediaWriterAddOn::GetFlavorAt\n");
54 fprintf(stderr
,"<- B_BAD_INDEX\n");
57 flavor_info
* infos
= new flavor_info
[1];
58 MediaWriter::GetFlavor(&infos
[0],n
);
63 BMediaNode
* MediaWriterAddOn::InstantiateNodeFor(
64 const flavor_info
* info
,
68 fprintf(stderr
,"MediaWriterAddOn::InstantiateNodeFor\n");
69 size_t defaultChunkSize
= size_t(8192); // XXX: read from add-on's attributes
70 float defaultBitRate
= 800000;
72 = new MediaWriter(defaultChunkSize
,
76 *out_error
= B_NO_MEMORY
;
77 fprintf(stderr
,"<- B_NO_MEMORY\n");
79 *out_error
= node
->InitCheck();
84 status_t
MediaWriterAddOn::GetConfigurationFor(
85 BMediaNode
* your_node
,
86 BMessage
* into_message
)
88 fprintf(stderr
,"MediaWriterAddOn::GetConfigurationFor\n");
90 = dynamic_cast<MediaWriter
*>(your_node
);
92 fprintf(stderr
,"<- B_BAD_TYPE\n");
95 return node
->GetConfigurationFor(into_message
);
98 // -------------------------------------------------------- //
99 // BMediaAddOn impl for B_FILE_INTERFACE nodes
100 // -------------------------------------------------------- //
102 status_t
MediaWriterAddOn::GetFileFormatList(
104 media_file_format
* out_writable_formats
,
105 int32 in_write_items
,
106 int32
* out_write_items
,
107 media_file_format
* out_readable_formats
,
109 int32
* out_read_items
,
112 fprintf(stderr
,"MediaWriterAddOn::GetFileFormatList\n");
113 if (flavor_id
!= 0) {
114 // this is a sanity check for now
115 fprintf(stderr
,"<- B_BAD_INDEX\n");
118 // don't go off the end
119 if (in_write_items
> 0) {
120 MediaWriter::GetFileFormat(&out_writable_formats
[0]);
125 status_t
MediaWriterAddOn::SniffTypeKind(
126 const BMimeType
& type
,
129 int32
* out_internal_id
,
132 fprintf(stderr
,"MediaWriterAddOn::SniffTypeKind\n");
133 return AbstractFileInterfaceAddOn::SniffTypeKind(type
,in_kinds
,
135 out_quality
,out_internal_id
,
139 // -------------------------------------------------------- //
141 // -------------------------------------------------------- //
143 int main(int argc
, char *argv
[])
145 fprintf(stderr
,"main called for MediaWriterAddOn\n");
148 // -------------------------------------------------------- //
150 // -------------------------------------------------------- //
152 status_t
MediaWriterAddOn::_Reserved_MediaWriterAddOn_0(void *) { return B_ERROR
; };
153 status_t
MediaWriterAddOn::_Reserved_MediaWriterAddOn_1(void *) { return B_ERROR
; };
154 status_t
MediaWriterAddOn::_Reserved_MediaWriterAddOn_2(void *) { return B_ERROR
; };
155 status_t
MediaWriterAddOn::_Reserved_MediaWriterAddOn_3(void *) { return B_ERROR
; };
156 status_t
MediaWriterAddOn::_Reserved_MediaWriterAddOn_4(void *) { return B_ERROR
; };
157 status_t
MediaWriterAddOn::_Reserved_MediaWriterAddOn_5(void *) { return B_ERROR
; };
158 status_t
MediaWriterAddOn::_Reserved_MediaWriterAddOn_6(void *) { return B_ERROR
; };
159 status_t
MediaWriterAddOn::_Reserved_MediaWriterAddOn_7(void *) { return B_ERROR
; };
160 status_t
MediaWriterAddOn::_Reserved_MediaWriterAddOn_8(void *) { return B_ERROR
; };
161 status_t
MediaWriterAddOn::_Reserved_MediaWriterAddOn_9(void *) { return B_ERROR
; };
162 status_t
MediaWriterAddOn::_Reserved_MediaWriterAddOn_10(void *) { return B_ERROR
; };
163 status_t
MediaWriterAddOn::_Reserved_MediaWriterAddOn_11(void *) { return B_ERROR
; };
164 status_t
MediaWriterAddOn::_Reserved_MediaWriterAddOn_12(void *) { return B_ERROR
; };
165 status_t
MediaWriterAddOn::_Reserved_MediaWriterAddOn_13(void *) { return B_ERROR
; };
166 status_t
MediaWriterAddOn::_Reserved_MediaWriterAddOn_14(void *) { return B_ERROR
; };
167 status_t
MediaWriterAddOn::_Reserved_MediaWriterAddOn_15(void *) { return B_ERROR
; };