1 /* 2 * Copyright 1991-1999, Be Incorporated. 3 * Copyright (c) 1999-2000, Eric Moon. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions, and the following disclaimer. 12 * 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions, and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * 3. The name of the author may not be used to endorse or promote products 18 * derived from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR 21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 28 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 33 // LoggingConsumerAddOn.cpp 34 // e.moon 4jun99 35 36 #include "LoggingConsumer.h" 37 #include "LoggingConsumerAddOn.h" 38 #include <Entry.h> 39 #include <Debug.h> 40 #include <cstring> 41 #include <cstdlib> 42 43 // logfile path 44 const char* const g_pLogPath = "/tmp/node_log"; 45 46 47 // instantiation function 48 extern "C" _EXPORT BMediaAddOn* make_media_addon(image_id image) { 49 return new LoggingConsumerAddOn(image); 50 } 51 52 // -------------------------------------------------------- // 53 // ctor/dtor 54 // -------------------------------------------------------- // 55 56 LoggingConsumerAddOn::~LoggingConsumerAddOn() { 57 PRINT(("~LoggingConsumerAddOn()\n")); 58 } 59 LoggingConsumerAddOn::LoggingConsumerAddOn(image_id image) : 60 BMediaAddOn(image) {} 61 62 // -------------------------------------------------------- // 63 // BMediaAddOn impl 64 // -------------------------------------------------------- // 65 66 status_t LoggingConsumerAddOn::InitCheck( 67 const char** out_failure_text) { 68 return B_OK; 69 } 70 71 int32 LoggingConsumerAddOn::CountFlavors() { 72 return 1; 73 } 74 75 status_t LoggingConsumerAddOn::GetFlavorAt( 76 int32 n, 77 const flavor_info** out_info) { 78 if(n) 79 return B_ERROR; 80 81 flavor_info* pInfo = new flavor_info; 82 pInfo->internal_id = n; 83 pInfo->name = "LoggingConsumer"; 84 pInfo->info = 85 "An add-on version of the LoggingConsumer node.\n" 86 "See the Be Developer Newsletter III.18: 5 May, 1999\n" 87 "adapted by Eric Moon (4 June, 1999)"; 88 pInfo->kinds = B_BUFFER_CONSUMER | B_CONTROLLABLE; 89 pInfo->flavor_flags = 0; 90 pInfo->possible_count = 0; 91 92 pInfo->in_format_count = 1; 93 media_format* pFormat = new media_format; 94 pFormat->type = B_MEDIA_UNKNOWN_TYPE; 95 pInfo->in_formats = pFormat; 96 97 pInfo->out_format_count = 0; 98 pInfo->out_formats = 0; 99 100 101 *out_info = pInfo; 102 return B_OK; 103 } 104 105 BMediaNode* LoggingConsumerAddOn::InstantiateNodeFor( 106 const flavor_info* info, 107 BMessage* config, 108 status_t* out_error) { 109 110 // initialize log file 111 entry_ref ref; 112 get_ref_for_path(g_pLogPath, &ref); 113 LoggingConsumer* pNode = new LoggingConsumer(ref, this); 114 115 // trim down the log's verbosity a touch 116 pNode->SetEnabled(LOG_HANDLE_EVENT, false); 117 118 return pNode; 119 } 120 121 status_t LoggingConsumerAddOn::GetConfigurationFor( 122 BMediaNode* your_node, 123 BMessage* into_message) { 124 125 // no config yet 126 return B_OK; 127 } 128 129 // END -- LoggingConsumerAddOn.cpp 130