1 /******************************************************************************* 2 / 3 / File: Controllable.h 4 / 5 / Description: A BControllable is a BMediaNode with "tweakable" parameters/settings. 6 / 7 / Copyright 1997-98, Be Incorporated, All Rights Reserved 8 / 9 *******************************************************************************/ 10 11 #if !defined(_CONTROLLABLE_H) 12 #define _CONTROLLABLE_H 13 14 #include <MediaDefs.h> 15 #include <MediaNode.h> 16 17 class BParameterWeb; 18 19 20 class BControllable : 21 public virtual BMediaNode 22 { 23 protected: 24 /* Need this to force vtable */ 25 virtual ~BControllable(); 26 27 public: 28 29 /* BControllable might seem somewhat spartan. */ 30 31 /* That is because control change requests and notifications */ 32 /* typically come in/go out in B_MEDIA_PARAMETERS type buffers */ 33 /* (and a BControllable thus also needs to be a BBufferConsumer */ 34 /* and/or a BBufferProducer) */ 35 /* The format of these buffers is: */ 36 /* media_node(node), int32(count) */ 37 /* repeat(count) { int64(when), int32(control_id), int32(value_size), <value> } */ 38 39 BParameterWeb * Web(); 40 bool LockParameterWeb(); 41 void UnlockParameterWeb(); 42 43 protected: 44 45 BControllable(); /* call SetParameterWeb() from your constructor */ 46 status_t SetParameterWeb( 47 BParameterWeb * web); 48 49 virtual status_t HandleMessage( 50 int32 message, 51 const void * data, 52 size_t size); 53 54 /* Call when the actual control changes, NOT when the value changes. */ 55 /* A typical case would be a CD with a Selector for Track when a new CD is inserted */ 56 status_t BroadcastChangedParameter( 57 int32 id); 58 59 /* Call this function when a value change takes effect, and */ 60 /* you want people who are interested to stay in sync with you. */ 61 /* Don't call this too densely, though, or you will flood the system */ 62 /* with messages. */ 63 status_t BroadcastNewParameterValue( 64 bigtime_t when, // performance time 65 int32 id, // parameter ID 66 void * newValue, 67 size_t valueSize); 68 69 /* These are alternate methods of accomplishing the same thing as */ 70 /* connecting to control information source/destinations would. */ 71 virtual status_t GetParameterValue( 72 int32 id, 73 bigtime_t * last_change, 74 void * value, 75 size_t * ioSize) = 0; 76 virtual void SetParameterValue( 77 int32 id, 78 bigtime_t when, 79 const void * value, 80 size_t size) = 0; 81 82 /* The default implementation of StartControlPanel launches the add-on */ 83 /* as an application (if the Node lives in an add-on). Thus, you can write your */ 84 /* control panel as a "main()" in your add-on, and it'll automagically work! */ 85 /* Your add-on needs to have multi-launch app flags for this to work right. */ 86 /* The first argv argument to main() will be a string of the format "node=%d" */ 87 /* with the node ID in question as "%d". */ 88 virtual status_t StartControlPanel( 89 BMessenger * out_messenger); 90 91 /* Call this from your BufferReceived() for control information buffers */ 92 /* if you implement BBufferConsumer for that format (recommended!) */ 93 status_t ApplyParameterData( 94 const void * value, 95 size_t size); 96 /* If you want to generate control information for a set of controls, you */ 97 /* can use this utility function. */ 98 status_t MakeParameterData( 99 const int32 * controls, 100 int32 count, 101 void * buf, 102 size_t * ioSize); 103 104 private: 105 106 friend class BMediaNode; 107 108 BControllable( /* private unimplemented */ 109 const BControllable & clone); 110 BControllable & operator=( 111 const BControllable & clone); 112 113 /* Mmmh, stuffing! */ 114 virtual status_t _Reserved_Controllable_0(void *); 115 virtual status_t _Reserved_Controllable_1(void *); 116 virtual status_t _Reserved_Controllable_2(void *); 117 virtual status_t _Reserved_Controllable_3(void *); 118 virtual status_t _Reserved_Controllable_4(void *); 119 virtual status_t _Reserved_Controllable_5(void *); 120 virtual status_t _Reserved_Controllable_6(void *); 121 virtual status_t _Reserved_Controllable_7(void *); 122 virtual status_t _Reserved_Controllable_8(void *); 123 virtual status_t _Reserved_Controllable_9(void *); 124 virtual status_t _Reserved_Controllable_10(void *); 125 virtual status_t _Reserved_Controllable_11(void *); 126 virtual status_t _Reserved_Controllable_12(void *); 127 virtual status_t _Reserved_Controllable_13(void *); 128 virtual status_t _Reserved_Controllable_14(void *); 129 virtual status_t _Reserved_Controllable_15(void *); 130 131 BParameterWeb * fWeb; 132 sem_id fSem; 133 int32 fBen; 134 uint32 _reserved_controllable_[14]; 135 }; 136 137 138 #endif /* _CONTROLLABLE_H */ 139 140