1 #include <support/Autolock.h> 2 #include <media/MediaFormats.h> 3 4 #include <stdio.h> 5 #include <string.h> 6 #include <unistd.h> 7 8 #include "AddOn.h" 9 #include "Producer.h" 10 11 MediaAddOn::MediaAddOn(image_id imid) 12 : BMediaAddOn(imid) 13 { 14 /* Customize these parameters to match those of your node */ 15 fFlavorInfo.name = "FinePixProducer"; 16 fFlavorInfo.info = "FinePixProducer"; 17 fFlavorInfo.kinds = B_BUFFER_PRODUCER | B_CONTROLLABLE | B_PHYSICAL_INPUT; 18 fFlavorInfo.flavor_flags = 0; 19 fFlavorInfo.internal_id = 0; 20 fFlavorInfo.possible_count = 1; 21 fFlavorInfo.in_format_count = 0; 22 fFlavorInfo.in_format_flags = 0; 23 fFlavorInfo.in_formats = NULL; 24 fFlavorInfo.out_format_count = 1; 25 fFlavorInfo.out_format_flags = 0; 26 fMediaFormat.type = B_MEDIA_RAW_VIDEO; 27 fMediaFormat.u.raw_video = media_raw_video_format::wildcard; 28 fMediaFormat.u.raw_video.interlace = 1; 29 fMediaFormat.u.raw_video.display.format = B_RGB32; 30 fFlavorInfo.out_formats = &fMediaFormat; 31 32 fInitStatus = B_OK; 33 } 34 35 MediaAddOn::~MediaAddOn() 36 { 37 } 38 39 40 status_t 41 MediaAddOn::InitCheck(const char **out_failure_text) 42 { 43 if (fInitStatus < B_OK) { 44 *out_failure_text = "Unknown error"; 45 return fInitStatus; 46 } 47 48 return B_OK; 49 } 50 51 int32 52 MediaAddOn::CountFlavors() 53 { 54 if (fInitStatus < B_OK) 55 return fInitStatus; 56 57 /* This addon only supports a single flavor, as defined in the 58 * constructor */ 59 return 1; 60 } 61 62 /* 63 * The pointer to the flavor received only needs to be valid between 64 * successive calls to BMediaAddOn::GetFlavorAt(). 65 */ 66 status_t 67 MediaAddOn::GetFlavorAt(int32 n, const flavor_info **out_info) 68 { 69 if (fInitStatus < B_OK) 70 return fInitStatus; 71 72 if (n != 0) 73 return B_BAD_INDEX; 74 75 /* Return the flavor defined in the constructor */ 76 *out_info = &fFlavorInfo; 77 return B_OK; 78 } 79 80 BMediaNode * 81 MediaAddOn::InstantiateNodeFor( 82 const flavor_info *info, BMessage *config, status_t *out_error) 83 { 84 FinePixProducer *node; 85 86 if (fInitStatus < B_OK) 87 return NULL; 88 89 if (info->internal_id != fFlavorInfo.internal_id) 90 return NULL; 91 92 /* At most one instance of the node should be instantiated at any given 93 * time. The locking for this restriction may be found in the FinePixProducer 94 * class. */ 95 node = new FinePixProducer(this, fFlavorInfo.name, fFlavorInfo.internal_id); 96 if (node && (node->InitCheck() < B_OK)) { 97 delete node; 98 node = NULL; 99 } 100 101 return node; 102 } 103 104 BMediaAddOn * 105 make_media_addon(image_id imid) 106 { 107 return new MediaAddOn(imid); 108 } 109