1 // LoggingConsumerAddOn.cpp 2 // e.moon 4jun99 3 4 #include "LoggingConsumer.h" 5 #include "LoggingConsumerAddOn.h" 6 #include <Entry.h> 7 #include <Debug.h> 8 #include <cstring> 9 #include <cstdlib> 10 11 // logfile path 12 const char* const g_pLogPath = "/tmp/node_log"; 13 14 15 // instantiation function 16 extern "C" _EXPORT BMediaAddOn* make_media_addon(image_id image) { 17 return new LoggingConsumerAddOn(image); 18 } 19 20 // -------------------------------------------------------- // 21 // ctor/dtor 22 // -------------------------------------------------------- // 23 24 LoggingConsumerAddOn::~LoggingConsumerAddOn() { 25 PRINT(("~LoggingConsumerAddOn()\n")); 26 } 27 LoggingConsumerAddOn::LoggingConsumerAddOn(image_id image) : 28 BMediaAddOn(image) {} 29 30 // -------------------------------------------------------- // 31 // BMediaAddOn impl 32 // -------------------------------------------------------- // 33 34 status_t LoggingConsumerAddOn::InitCheck( 35 const char** out_failure_text) { 36 return B_OK; 37 } 38 39 int32 LoggingConsumerAddOn::CountFlavors() { 40 return 1; 41 } 42 43 status_t LoggingConsumerAddOn::GetFlavorAt( 44 int32 n, 45 const flavor_info** out_info) { 46 if(n) 47 return B_ERROR; 48 49 flavor_info* pInfo = new flavor_info; 50 pInfo->internal_id = n; 51 pInfo->name = "LoggingConsumer"; 52 pInfo->info = 53 "An add-on version of the LoggingConsumer node.\n" 54 "See the Be Developer Newsletter III.18: 5 May, 1999\n" 55 "adapted by Eric Moon (4 June, 1999)"; 56 pInfo->kinds = B_BUFFER_CONSUMER | B_CONTROLLABLE; 57 pInfo->flavor_flags = 0; 58 pInfo->possible_count = 0; 59 60 pInfo->in_format_count = 1; 61 media_format* pFormat = new media_format; 62 pFormat->type = B_MEDIA_UNKNOWN_TYPE; 63 pInfo->in_formats = pFormat; 64 65 pInfo->out_format_count = 0; 66 pInfo->out_formats = 0; 67 68 69 *out_info = pInfo; 70 return B_OK; 71 } 72 73 BMediaNode* LoggingConsumerAddOn::InstantiateNodeFor( 74 const flavor_info* info, 75 BMessage* config, 76 status_t* out_error) { 77 78 // initialize log file 79 entry_ref ref; 80 get_ref_for_path(g_pLogPath, &ref); 81 LoggingConsumer* pNode = new LoggingConsumer(ref, this); 82 83 // trim down the log's verbosity a touch 84 pNode->SetEnabled(LOG_HANDLE_EVENT, false); 85 86 return pNode; 87 } 88 89 status_t LoggingConsumerAddOn::GetConfigurationFor( 90 BMediaNode* your_node, 91 BMessage* into_message) { 92 93 // no config yet 94 return B_OK; 95 } 96 97 // END -- LoggingConsumerAddOn.cpp 98