1 /******************************************************************************* 2 / 3 / File: ParameterWeb.h 4 / 5 / Description: A BParameterWeb is a description of media controls within a BControllable 6 / Media Kit Node. 7 / BParameter, BParameterGroup, BContinuousParameter, BDiscreteParameter and 8 / BNullParameter are "data classes" used to describe the relation within a 9 / BParameterWeb. These are NOT direct visible classes like BControls; just data 10 / containers which applications can use to decide what kind of views to create. 11 / 12 / Copyright 1997-98, Be Incorporated, All Rights Reserved 13 / 14 *******************************************************************************/ 15 16 #if !defined(_CONTROL_WEB_H) 17 #define _CONTROL_WEB_H 18 19 #include <MediaDefs.h> 20 #include <Flattenable.h> 21 #include <MediaNode.h> 22 23 #if !defined(_PR3_COMPATIBLE_) 24 enum { 25 B_MEDIA_PARAMETER_TYPE = 'BMCT', 26 B_MEDIA_PARAMETER_WEB_TYPE = 'BMCW', 27 B_MEDIA_PARAMETER_GROUP_TYPE= 'BMCG' 28 }; 29 #endif 30 31 32 // It is highly unfortunate that a linker bug forces these symbols out 33 // from the BParameter class. Hope they don't collide with anything else. 34 35 /* These are control KINDs */ 36 /* kind used when you don't know or care */ 37 extern _IMPEXP_MEDIA const char * const B_GENERIC; 38 /* kinds used for sliders */ 39 extern _IMPEXP_MEDIA const char * const B_MASTER_GAIN; /* Main Volume */ 40 extern _IMPEXP_MEDIA const char * const B_GAIN; 41 extern _IMPEXP_MEDIA const char * const B_BALANCE; 42 extern _IMPEXP_MEDIA const char * const B_FREQUENCY; /* like a radio tuner */ 43 extern _IMPEXP_MEDIA const char * const B_LEVEL; /* like for effects */ 44 extern _IMPEXP_MEDIA const char * const B_SHUTTLE_SPEED; /* Play, SloMo, Scan 1.0 == regular */ 45 extern _IMPEXP_MEDIA const char * const B_CROSSFADE; /* 0 == first input, +100 == second input */ 46 extern _IMPEXP_MEDIA const char * const B_EQUALIZATION; /* depth (dB) */ 47 48 /* kinds used for compressors */ 49 extern _IMPEXP_MEDIA const char * const B_COMPRESSION; /* 0% == no compression, 99% == 100:1 compression */ 50 extern _IMPEXP_MEDIA const char * const B_QUALITY; /* 0% == full compression, 100% == no compression */ 51 extern _IMPEXP_MEDIA const char * const B_BITRATE; /* in bits/second */ 52 extern _IMPEXP_MEDIA const char * const B_GOP_SIZE; /* Group Of Pictures. a k a "Keyframe every N frames" */ 53 /* kinds used for selectors */ 54 extern _IMPEXP_MEDIA const char * const B_MUTE; /* 0 == thru, 1 == mute */ 55 extern _IMPEXP_MEDIA const char * const B_ENABLE; /* 0 == disable, 1 == enable */ 56 extern _IMPEXP_MEDIA const char * const B_INPUT_MUX; /* "value" 1-N == input selected */ 57 extern _IMPEXP_MEDIA const char * const B_OUTPUT_MUX; /* "value" 1-N == output selected */ 58 extern _IMPEXP_MEDIA const char * const B_TUNER_CHANNEL; /* like cable TV */ 59 extern _IMPEXP_MEDIA const char * const B_TRACK; /* like a CD player; "value" should be 1-N */ 60 extern _IMPEXP_MEDIA const char * const B_RECSTATE; /* like mutitrack tape deck, 0 == silent, 1 == play, 2 == record */ 61 extern _IMPEXP_MEDIA const char * const B_SHUTTLE_MODE; /* -1 == backwards, 0 == stop, 1 == play, 2 == pause/cue */ 62 extern _IMPEXP_MEDIA const char * const B_RESOLUTION; 63 extern _IMPEXP_MEDIA const char * const B_COLOR_SPACE; /* "value" should be color_space */ 64 extern _IMPEXP_MEDIA const char * const B_FRAME_RATE; 65 extern _IMPEXP_MEDIA const char * const B_VIDEO_FORMAT; /* 1 == NTSC-M, 2 == NTSC-J, 3 == PAL-BDGHI, 4 == PAL-M, 5 == PAL-N, 6 == SECAM, 7 == MPEG-1, 8 == MPEG-2 */ 66 /* kinds used for junctions */ 67 // the prefix of "WEB" is to avoid collission with an enum in Defs.h 68 extern _IMPEXP_MEDIA const char * const B_WEB_PHYSICAL_INPUT; /* a jack on the back of the card */ 69 extern _IMPEXP_MEDIA const char * const B_WEB_PHYSICAL_OUTPUT; 70 extern _IMPEXP_MEDIA const char * const B_WEB_ADC_CONVERTER; /* from analog to digital signals */ 71 extern _IMPEXP_MEDIA const char * const B_WEB_DAC_CONVERTER; /* from digital to analog signals */ 72 extern _IMPEXP_MEDIA const char * const B_WEB_LOGICAL_INPUT; /* an "input" that may not be physical */ 73 extern _IMPEXP_MEDIA const char * const B_WEB_LOGICAL_OUTPUT; 74 extern _IMPEXP_MEDIA const char * const B_WEB_LOGICAL_BUS; /* a logical connection point that is neither input nor output; auxilliary bus */ 75 extern _IMPEXP_MEDIA const char * const B_WEB_BUFFER_INPUT; /* an input that corresponds to a media_input */ 76 extern _IMPEXP_MEDIA const char * const B_WEB_BUFFER_OUTPUT; 77 78 // a simple transport control is a discrete parameter with five values (states): 79 // rewinding, stopped, playing, paused, and fast-forwarding 80 extern _IMPEXP_MEDIA const char * const B_SIMPLE_TRANSPORT; 81 82 class BList; 83 class BParameterGroup; 84 class BParameter; 85 class BNullParameter; 86 class BContinuousParameter; 87 class BDiscreteParameter; 88 89 90 /* Set these flags on parameters and groups to control how a Theme will */ 91 /* render the Web. Hidden means, generally, "don't show". Advanced means, */ 92 /* generally, that you can show it or not depending on your whim. */ 93 enum media_parameter_flags { 94 B_HIDDEN_PARAMETER = 0x1, 95 B_ADVANCED_PARAMETER = 0x2 96 }; 97 98 99 class BParameterWeb : 100 public BFlattenable 101 { 102 public: 103 BParameterWeb(); 104 ~BParameterWeb(); 105 106 media_node Node(); 107 108 BParameterGroup * MakeGroup( 109 const char * name); 110 111 int32 CountGroups(); 112 BParameterGroup * GroupAt( 113 int32 index); 114 int32 CountParameters(); 115 BParameter * ParameterAt( 116 int32 index); 117 118 virtual bool IsFixedSize() const; 119 virtual type_code TypeCode() const; 120 virtual ssize_t FlattenedSize() const; 121 virtual status_t Flatten(void *buffer, ssize_t size) const; 122 virtual bool AllowsTypeCode(type_code code) const; 123 virtual status_t Unflatten(type_code c, const void *buf, ssize_t size); 124 125 private: 126 127 friend class BParameterGroup; 128 friend class BControllable; 129 130 BParameterWeb( 131 const BParameterWeb & clone); 132 BParameterWeb & operator=( 133 const BParameterWeb & clone); 134 135 /* Mmmh, stuffing! */ 136 virtual status_t _Reserved_ControlWeb_0(void *); 137 virtual status_t _Reserved_ControlWeb_1(void *); 138 virtual status_t _Reserved_ControlWeb_2(void *); 139 virtual status_t _Reserved_ControlWeb_3(void *); 140 virtual status_t _Reserved_ControlWeb_4(void *); 141 virtual status_t _Reserved_ControlWeb_5(void *); 142 virtual status_t _Reserved_ControlWeb_6(void *); 143 virtual status_t _Reserved_ControlWeb_7(void *); 144 145 BList * mGroups; 146 media_node mNode; 147 uint32 _reserved_control_web_[8]; 148 149 BList * mOldRefs; 150 BList * mNewRefs; 151 152 void AddRefFix( 153 void * oldItem, 154 void * newItem); 155 }; 156 157 158 class BParameterGroup : 159 public BFlattenable 160 { 161 private: 162 163 BParameterGroup( 164 BParameterWeb * web, 165 const char * name); 166 virtual ~BParameterGroup(); 167 168 public: 169 170 BParameterWeb * Web() const; 171 const char * Name() const; 172 173 void SetFlags(uint32 flags); 174 uint32 Flags() const; 175 176 BNullParameter * MakeNullParameter( 177 int32 id, 178 media_type m_type, 179 const char * name, 180 const char * kind); 181 BContinuousParameter * MakeContinuousParameter( 182 int32 id, 183 media_type m_type, 184 const char * name, 185 const char * kind, 186 const char * unit, 187 float minimum, 188 float maximum, 189 float stepping); 190 BDiscreteParameter * MakeDiscreteParameter( 191 int32 id, 192 media_type m_type, 193 const char * name, 194 const char * kind); 195 BParameterGroup * MakeGroup( 196 const char * name); 197 198 int32 CountParameters(); 199 BParameter * ParameterAt( 200 int32 index); 201 int32 CountGroups(); 202 BParameterGroup * GroupAt( 203 int32 index); 204 205 virtual bool IsFixedSize() const; 206 virtual type_code TypeCode() const; 207 virtual ssize_t FlattenedSize() const; 208 virtual status_t Flatten(void *buffer, ssize_t size) const; 209 virtual bool AllowsTypeCode(type_code code) const; 210 virtual status_t Unflatten(type_code c, const void *buf, ssize_t size); 211 212 private: 213 214 BParameterGroup(); /* private unimplemented */ 215 BParameterGroup( 216 const BParameterGroup & clone); 217 BParameterGroup & operator=( 218 const BParameterGroup & clone); 219 220 /* Mmmh, stuffing! */ 221 virtual status_t _Reserved_ControlGroup_0(void *); 222 virtual status_t _Reserved_ControlGroup_1(void *); 223 virtual status_t _Reserved_ControlGroup_2(void *); 224 virtual status_t _Reserved_ControlGroup_3(void *); 225 virtual status_t _Reserved_ControlGroup_4(void *); 226 virtual status_t _Reserved_ControlGroup_5(void *); 227 virtual status_t _Reserved_ControlGroup_6(void *); 228 virtual status_t _Reserved_ControlGroup_7(void *); 229 230 friend class BParameterWeb; 231 232 BParameterWeb * mWeb; 233 BList * mControls; 234 BList * mGroups; 235 char * mName; 236 uint32 mFlags; 237 uint32 _reserved_control_group_[7]; 238 239 BParameter * MakeControl( 240 int32 type); 241 }; 242 243 244 /* After you create a BParameter, hook it up by calling AddInput() and/or AddOutput() */ 245 /* (which will call the reciprocal in the target) and optionally call SetChannelCount() and SetMediaType() */ 246 class BParameter : 247 public BFlattenable 248 { 249 public: 250 251 /* This is a parameter TYPE */ 252 enum media_parameter_type 253 { 254 B_NULL_PARAMETER, 255 B_DISCRETE_PARAMETER, 256 B_CONTINUOUS_PARAMETER 257 }; 258 259 media_parameter_type Type() const; 260 BParameterWeb * Web() const; 261 BParameterGroup * Group() const; 262 const char * Name() const; 263 const char * Kind() const; 264 const char * Unit() const; 265 int32 ID() const; 266 267 void SetFlags(uint32 flags); 268 uint32 Flags() const; 269 270 virtual type_code ValueType() = 0; 271 /* These functions are typically used by client apps; they will result in */ 272 /* your BControllable getting called to read/write values. */ 273 status_t GetValue( 274 void * buffer, 275 size_t * ioSize, 276 bigtime_t * when); 277 status_t SetValue( 278 const void * buffer, 279 size_t size, 280 bigtime_t when); 281 int32 CountChannels(); /* Number of ValueType() values; default is 1 */ 282 void SetChannelCount( /* One value could still control e g a stereo pair */ 283 int32 channel_count); 284 285 media_type MediaType(); /* Optional (default is B_MEDIA_NO_TYPE) */ 286 void SetMediaType(media_type m_type); 287 288 int32 CountInputs(); 289 BParameter * InputAt( 290 int32 index); 291 void AddInput( 292 BParameter * input); 293 int32 CountOutputs(); 294 BParameter * OutputAt( 295 int32 index); 296 void AddOutput( 297 BParameter * output); 298 299 virtual bool IsFixedSize() const; 300 virtual type_code TypeCode() const; 301 virtual ssize_t FlattenedSize() const; 302 virtual status_t Flatten(void *buffer, ssize_t size) const; 303 virtual bool AllowsTypeCode(type_code code) const; 304 virtual status_t Unflatten(type_code c, const void *buf, ssize_t size); 305 306 private: 307 friend class BNullParameter; 308 friend class BContinuousParameter; 309 friend class BDiscreteParameter; 310 friend class BParameterGroup; 311 friend class BParameterWeb; 312 313 bool SwapOnUnflatten() { return mSwapDetected; } 314 315 /* Mmmh, stuffing! */ 316 virtual status_t _Reserved_Control_0(void *); 317 virtual status_t _Reserved_Control_1(void *); 318 virtual status_t _Reserved_Control_2(void *); 319 virtual status_t _Reserved_Control_3(void *); 320 virtual status_t _Reserved_Control_4(void *); 321 virtual status_t _Reserved_Control_5(void *); 322 virtual status_t _Reserved_Control_6(void *); 323 virtual status_t _Reserved_Control_7(void *); 324 325 326 BParameter( 327 int32 id, 328 media_type m_type, 329 media_parameter_type type, 330 BParameterWeb * web, 331 const char * name, 332 const char * kind, 333 const char * unit); 334 ~BParameter(); 335 336 int32 mID; 337 media_parameter_type mType; 338 BParameterWeb * mWeb; 339 BParameterGroup * mGroup; 340 char * mName; 341 char * mKind; 342 char * mUnit; 343 BList * mInputs; 344 BList * mOutputs; 345 bool mSwapDetected; 346 media_type mMediaType; 347 int32 mChannels; 348 uint32 mFlags; 349 uint32 _reserved_control_[7]; 350 351 virtual void FixRefs( 352 BList & old, 353 BList & updated); 354 }; 355 356 357 class BContinuousParameter : 358 public BParameter 359 { 360 public: 361 362 virtual type_code ValueType(); 363 364 float MinValue(); 365 float MaxValue(); 366 float ValueStep(); 367 368 /* The "response" specifies what value to display to the user. */ 369 /* Thus, if response is B_POLYNOMIAL with factor 2, an actual */ 370 /* control value of 10 would be displayed to the user as 100, and */ 371 /* if response was B_EXPONENTIAL and factor was 2, an actual */ 372 /* value of 3 would display 8 (two to the third). The ValueStep() */ 373 /* is given in actual control values, before the transformation for */ 374 /* display is done. Thus, with min 0, max 4 and value step 1, and an */ 375 /* exponential response with factor 10, you will get the displayed */ 376 /* values 1, 10, 100, 1000 and 10000 equally spaced across a slider */ 377 /* (or whatever UI the app puts to the parameter). */ 378 /* The "offset" is added to the value after transformation, before display. */ 379 /* If "resp" is negative, the resulting value/display relation is turned upside down. */ 380 enum response { 381 B_UNKNOWN = 0, 382 B_LINEAR = 1, /* factor is direct multiplier >= 0 */ 383 B_POLYNOMIAL, /* factor should be power; typically "2" for squared or "-1" for inverse */ 384 B_EXPONENTIAL, /* factor should be base, typically 2 or 10 */ 385 B_LOGARITHMIC /* factor should be base, typically 2 or 10 */ 386 }; 387 void SetResponse( 388 int resp, 389 float factor, 390 float offset); 391 void GetResponse( 392 int * resp, 393 float * factor, 394 float * offset); 395 396 virtual ssize_t FlattenedSize() const; 397 virtual status_t Flatten(void *buffer, ssize_t size) const; 398 virtual status_t Unflatten(type_code c, const void *buf, ssize_t size); 399 400 private: 401 402 /* Mmmh, stuffing! */ 403 virtual status_t _Reserved_ContinuousParameter_0(void *); 404 virtual status_t _Reserved_ContinuousParameter_1(void *); 405 virtual status_t _Reserved_ContinuousParameter_2(void *); 406 virtual status_t _Reserved_ContinuousParameter_3(void *); 407 virtual status_t _Reserved_ContinuousParameter_4(void *); 408 virtual status_t _Reserved_ContinuousParameter_5(void *); 409 virtual status_t _Reserved_ContinuousParameter_6(void *); 410 virtual status_t _Reserved_ContinuousParameter_7(void *); 411 friend class BParameterGroup; 412 413 BContinuousParameter( 414 int32 id, 415 media_type m_type, 416 BParameterWeb * web, 417 const char * name, 418 const char * kind, 419 const char * unit, 420 float minimum, 421 float maximum, 422 float stepping); 423 ~BContinuousParameter(); 424 425 float mMinimum; 426 float mMaximum; 427 float mStepping; 428 response mResponse; 429 float mFactor; 430 float mOffset; 431 uint32 _reserved_control_slider_[8]; 432 433 }; 434 435 436 class BDiscreteParameter : 437 public BParameter 438 { 439 public: 440 441 virtual type_code ValueType(); 442 443 int32 CountItems(); 444 const char * ItemNameAt( 445 int32 index); 446 int32 ItemValueAt( 447 int32 index); 448 status_t AddItem( 449 int32 value, 450 const char * name); 451 status_t MakeItemsFromInputs(); 452 status_t MakeItemsFromOutputs(); 453 void MakeEmpty(); 454 455 virtual ssize_t FlattenedSize() const; 456 virtual status_t Flatten(void *buffer, ssize_t size) const; 457 virtual status_t Unflatten(type_code c, const void *buf, ssize_t size); 458 459 private: 460 /* Mmmh, stuffing! */ 461 virtual status_t _Reserved_DiscreteParameter_0(void *); 462 virtual status_t _Reserved_DiscreteParameter_1(void *); 463 virtual status_t _Reserved_DiscreteParameter_2(void *); 464 virtual status_t _Reserved_DiscreteParameter_3(void *); 465 virtual status_t _Reserved_DiscreteParameter_4(void *); 466 virtual status_t _Reserved_DiscreteParameter_5(void *); 467 virtual status_t _Reserved_DiscreteParameter_6(void *); 468 virtual status_t _Reserved_DiscreteParameter_7(void *); 469 470 friend class BParameterGroup; 471 472 BList * mSelections; 473 BList * mValues; 474 uint32 _reserved_control_selector_[8]; 475 476 BDiscreteParameter( 477 int32 id, 478 media_type m_type, 479 BParameterWeb * web, 480 const char * name, 481 const char * kind); 482 ~BDiscreteParameter(); 483 }; 484 485 486 class BNullParameter : 487 public BParameter 488 { 489 public: 490 491 virtual type_code ValueType(); 492 493 virtual ssize_t FlattenedSize() const; 494 virtual status_t Flatten(void *buffer, ssize_t size) const; 495 virtual status_t Unflatten(type_code c, const void *buf, ssize_t size); 496 497 private: 498 /* Mmmh, stuffing! */ 499 virtual status_t _Reserved_NullParameter_0(void *); 500 virtual status_t _Reserved_NullParameter_1(void *); 501 virtual status_t _Reserved_NullParameter_2(void *); 502 virtual status_t _Reserved_NullParameter_3(void *); 503 virtual status_t _Reserved_NullParameter_4(void *); 504 virtual status_t _Reserved_NullParameter_5(void *); 505 virtual status_t _Reserved_NullParameter_6(void *); 506 virtual status_t _Reserved_NullParameter_7(void *); 507 508 friend class BParameterGroup; 509 510 uint32 _reserved_control_junction_[8]; 511 512 BNullParameter( 513 int32 id, 514 media_type m_type, 515 BParameterWeb * web, 516 const char * name, 517 const char * kind); 518 ~BNullParameter(); 519 520 }; 521 522 523 #endif /* _CONTROL_WEB_H */ 524