3rdparty/licenseReport: Add seperate LGPL checks
[haiku.git] / src / add-ons / media / media-add-ons / writer / MediaWriterAddOn.cpp
blob9003384c5b2de5dcc0a7605f447c0c535aad8e7a
1 // MediaWriterAddOn.cpp
2 //
3 // Andrew Bachmann, 2002
4 //
5 // A MediaWriterAddOn is an add-on
6 // that can make MediaWriter nodes
7 //
8 // MediaWriter nodes write a multistream into a file
11 #include <MediaDefs.h>
12 #include <MediaAddOn.h>
13 #include <Errors.h>
14 #include <Node.h>
15 #include <Mime.h>
16 #include <StorageDefs.h>
18 #include "MediaWriter.h"
19 #include "MediaWriterAddOn.h"
21 #include <limits.h>
22 #include <stdio.h>
23 #include <string.h>
25 // instantiation function
26 extern "C" _EXPORT BMediaAddOn * make_media_addon(image_id image) {
27 return new MediaWriterAddOn(image);
30 // -------------------------------------------------------- //
31 // ctor/dtor
32 // -------------------------------------------------------- //
34 MediaWriterAddOn::~MediaWriterAddOn()
38 MediaWriterAddOn::MediaWriterAddOn(image_id image) :
39 AbstractFileInterfaceAddOn(image)
41 fprintf(stderr,"MediaWriterAddOn::MediaWriterAddOn\n");
44 // -------------------------------------------------------- //
45 // BMediaAddOn impl
46 // -------------------------------------------------------- //
48 status_t MediaWriterAddOn::GetFlavorAt(
49 int32 n,
50 const flavor_info ** out_info)
52 fprintf(stderr,"MediaWriterAddOn::GetFlavorAt\n");
53 if (n != 0) {
54 fprintf(stderr,"<- B_BAD_INDEX\n");
55 return B_BAD_INDEX;
57 flavor_info * infos = new flavor_info[1];
58 MediaWriter::GetFlavor(&infos[0],n);
59 (*out_info) = infos;
60 return B_OK;
63 BMediaNode * MediaWriterAddOn::InstantiateNodeFor(
64 const flavor_info * info,
65 BMessage * config,
66 status_t * out_error)
68 fprintf(stderr,"MediaWriterAddOn::InstantiateNodeFor\n");
69 size_t defaultChunkSize = size_t(8192); // XXX: read from add-on's attributes
70 float defaultBitRate = 800000;
71 MediaWriter * node
72 = new MediaWriter(defaultChunkSize,
73 defaultBitRate,
74 info,config,this);
75 if (node == 0) {
76 *out_error = B_NO_MEMORY;
77 fprintf(stderr,"<- B_NO_MEMORY\n");
78 } else {
79 *out_error = node->InitCheck();
81 return node;
84 status_t MediaWriterAddOn::GetConfigurationFor(
85 BMediaNode * your_node,
86 BMessage * into_message)
88 fprintf(stderr,"MediaWriterAddOn::GetConfigurationFor\n");
89 MediaWriter * node
90 = dynamic_cast<MediaWriter*>(your_node);
91 if (node == 0) {
92 fprintf(stderr,"<- B_BAD_TYPE\n");
93 return B_BAD_TYPE;
95 return node->GetConfigurationFor(into_message);
98 // -------------------------------------------------------- //
99 // BMediaAddOn impl for B_FILE_INTERFACE nodes
100 // -------------------------------------------------------- //
102 status_t MediaWriterAddOn::GetFileFormatList(
103 int32 flavor_id,
104 media_file_format * out_writable_formats,
105 int32 in_write_items,
106 int32 * out_write_items,
107 media_file_format * out_readable_formats,
108 int32 in_read_items,
109 int32 * out_read_items,
110 void * _reserved)
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");
116 return B_BAD_INDEX;
118 // don't go off the end
119 if (in_write_items > 0) {
120 MediaWriter::GetFileFormat(&out_writable_formats[0]);
122 return B_OK;
125 status_t MediaWriterAddOn::SniffTypeKind(
126 const BMimeType & type,
127 uint64 in_kinds,
128 float * out_quality,
129 int32 * out_internal_id,
130 void * _reserved)
132 fprintf(stderr,"MediaWriterAddOn::SniffTypeKind\n");
133 return AbstractFileInterfaceAddOn::SniffTypeKind(type,in_kinds,
134 B_BUFFER_CONSUMER,
135 out_quality,out_internal_id,
136 _reserved);
139 // -------------------------------------------------------- //
140 // main
141 // -------------------------------------------------------- //
143 int main(int argc, char *argv[])
145 fprintf(stderr,"main called for MediaWriterAddOn\n");
148 // -------------------------------------------------------- //
149 // stuffing
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; };