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 class BTextParameter; 89 90 91 /* Set these flags on parameters and groups to control how a Theme will */ 92 /* render the Web. Hidden means, generally, "don't show". Advanced means, */ 93 /* generally, that you can show it or not depending on your whim. */ 94 enum media_parameter_flags { 95 B_HIDDEN_PARAMETER = 0x1, 96 B_ADVANCED_PARAMETER = 0x2 97 }; 98 99 100 class BParameterWeb : 101 public BFlattenable 102 { 103 public: 104 BParameterWeb(); 105 ~BParameterWeb(); 106 107 media_node Node(); 108 109 BParameterGroup * MakeGroup( 110 const char * name); 111 112 int32 CountGroups(); 113 BParameterGroup * GroupAt( 114 int32 index); 115 int32 CountParameters(); 116 BParameter * ParameterAt( 117 int32 index); 118 119 virtual bool IsFixedSize() const; 120 virtual type_code TypeCode() const; 121 virtual ssize_t FlattenedSize() const; 122 virtual status_t Flatten(void *buffer, ssize_t size) const; 123 virtual bool AllowsTypeCode(type_code code) const; 124 virtual status_t Unflatten(type_code c, const void *buf, ssize_t size); 125 126 private: 127 128 friend class BParameterGroup; 129 friend class BControllable; 130 131 BParameterWeb( 132 const BParameterWeb & clone); 133 BParameterWeb & operator=( 134 const BParameterWeb & clone); 135 136 /* Mmmh, stuffing! */ 137 virtual status_t _Reserved_ControlWeb_0(void *); 138 virtual status_t _Reserved_ControlWeb_1(void *); 139 virtual status_t _Reserved_ControlWeb_2(void *); 140 virtual status_t _Reserved_ControlWeb_3(void *); 141 virtual status_t _Reserved_ControlWeb_4(void *); 142 virtual status_t _Reserved_ControlWeb_5(void *); 143 virtual status_t _Reserved_ControlWeb_6(void *); 144 virtual status_t _Reserved_ControlWeb_7(void *); 145 146 BList * mGroups; 147 media_node mNode; 148 uint32 _reserved_control_web_[8]; 149 150 BList * mOldRefs; 151 BList * mNewRefs; 152 153 void AddRefFix( 154 void * oldItem, 155 void * newItem); 156 }; 157 158 159 class BParameterGroup : 160 public BFlattenable 161 { 162 private: 163 164 BParameterGroup( 165 BParameterWeb * web, 166 const char * name); 167 virtual ~BParameterGroup(); 168 169 public: 170 171 BParameterWeb * Web() const; 172 const char * Name() const; 173 174 void SetFlags(uint32 flags); 175 uint32 Flags() const; 176 177 BNullParameter * MakeNullParameter( 178 int32 id, 179 media_type m_type, 180 const char * name, 181 const char * kind); 182 BContinuousParameter * MakeContinuousParameter( 183 int32 id, 184 media_type m_type, 185 const char * name, 186 const char * kind, 187 const char * unit, 188 float minimum, 189 float maximum, 190 float stepping); 191 BDiscreteParameter * MakeDiscreteParameter( 192 int32 id, 193 media_type m_type, 194 const char * name, 195 const char * kind); 196 BTextParameter * MakeTextParameter( 197 int32 id, 198 media_type m_type, 199 const char * name, 200 const char * kind, 201 size_t max_bytes); 202 BParameterGroup * MakeGroup( 203 const char * name); 204 205 int32 CountParameters(); 206 BParameter * ParameterAt( 207 int32 index); 208 int32 CountGroups(); 209 BParameterGroup * GroupAt( 210 int32 index); 211 212 virtual bool IsFixedSize() const; 213 virtual type_code TypeCode() const; 214 virtual ssize_t FlattenedSize() const; 215 virtual status_t Flatten(void *buffer, ssize_t size) const; 216 virtual bool AllowsTypeCode(type_code code) const; 217 virtual status_t Unflatten(type_code c, const void *buf, ssize_t size); 218 219 private: 220 221 BParameterGroup(); /* private unimplemented */ 222 BParameterGroup( 223 const BParameterGroup & clone); 224 BParameterGroup & operator=( 225 const BParameterGroup & clone); 226 227 /* Mmmh, stuffing! */ 228 virtual status_t _Reserved_ControlGroup_0(void *); 229 virtual status_t _Reserved_ControlGroup_1(void *); 230 virtual status_t _Reserved_ControlGroup_2(void *); 231 virtual status_t _Reserved_ControlGroup_3(void *); 232 virtual status_t _Reserved_ControlGroup_4(void *); 233 virtual status_t _Reserved_ControlGroup_5(void *); 234 virtual status_t _Reserved_ControlGroup_6(void *); 235 virtual status_t _Reserved_ControlGroup_7(void *); 236 237 friend class BParameterWeb; 238 239 BParameterWeb * mWeb; 240 BList * mControls; 241 BList * mGroups; 242 char * mName; 243 uint32 mFlags; 244 uint32 _reserved_control_group_[7]; 245 246 BParameter * MakeControl( 247 int32 type); 248 }; 249 250 251 /* After you create a BParameter, hook it up by calling AddInput() and/or AddOutput() */ 252 /* (which will call the reciprocal in the target) and optionally call SetChannelCount() and SetMediaType() */ 253 class BParameter : 254 public BFlattenable 255 { 256 public: 257 258 /* This is a parameter TYPE */ 259 enum media_parameter_type 260 { 261 B_NULL_PARAMETER, 262 B_DISCRETE_PARAMETER, 263 B_CONTINUOUS_PARAMETER, 264 B_TEXT_PARAMETER 265 }; 266 267 media_parameter_type Type() const; 268 BParameterWeb * Web() const; 269 BParameterGroup * Group() const; 270 const char * Name() const; 271 const char * Kind() const; 272 const char * Unit() const; 273 int32 ID() const; 274 275 void SetFlags(uint32 flags); 276 uint32 Flags() const; 277 278 virtual type_code ValueType() = 0; 279 /* These functions are typically used by client apps; they will result in */ 280 /* your BControllable getting called to read/write values. */ 281 status_t GetValue( 282 void * buffer, 283 size_t * ioSize, 284 bigtime_t * when); 285 status_t SetValue( 286 const void * buffer, 287 size_t size, 288 bigtime_t when); 289 int32 CountChannels(); /* Number of ValueType() values; default is 1 */ 290 void SetChannelCount( /* One value could still control e g a stereo pair */ 291 int32 channel_count); 292 293 media_type MediaType(); /* Optional (default is B_MEDIA_NO_TYPE) */ 294 void SetMediaType(media_type m_type); 295 296 int32 CountInputs(); 297 BParameter * InputAt( 298 int32 index); 299 void AddInput( 300 BParameter * input); 301 int32 CountOutputs(); 302 BParameter * OutputAt( 303 int32 index); 304 void AddOutput( 305 BParameter * output); 306 307 virtual bool IsFixedSize() const; 308 virtual type_code TypeCode() const; 309 virtual ssize_t FlattenedSize() const; 310 virtual status_t Flatten(void *buffer, ssize_t size) const; 311 virtual bool AllowsTypeCode(type_code code) const; 312 virtual status_t Unflatten(type_code c, const void *buf, ssize_t size); 313 314 private: 315 friend class BNullParameter; 316 friend class BContinuousParameter; 317 friend class BDiscreteParameter; 318 friend class BTextParameter; 319 friend class BParameterGroup; 320 friend class BParameterWeb; 321 322 bool SwapOnUnflatten() { return mSwapDetected; } 323 324 /* Mmmh, stuffing! */ 325 virtual status_t _Reserved_Control_0(void *); 326 virtual status_t _Reserved_Control_1(void *); 327 virtual status_t _Reserved_Control_2(void *); 328 virtual status_t _Reserved_Control_3(void *); 329 virtual status_t _Reserved_Control_4(void *); 330 virtual status_t _Reserved_Control_5(void *); 331 virtual status_t _Reserved_Control_6(void *); 332 virtual status_t _Reserved_Control_7(void *); 333 334 335 BParameter( 336 int32 id, 337 media_type m_type, 338 media_parameter_type type, 339 BParameterWeb * web, 340 const char * name, 341 const char * kind, 342 const char * unit); 343 ~BParameter(); 344 345 int32 mID; 346 media_parameter_type mType; 347 BParameterWeb * mWeb; 348 BParameterGroup * mGroup; 349 char * mName; 350 char * mKind; 351 char * mUnit; 352 BList * mInputs; 353 BList * mOutputs; 354 bool mSwapDetected; 355 media_type mMediaType; 356 int32 mChannels; 357 uint32 mFlags; 358 uint32 _reserved_control_[7]; 359 360 virtual void FixRefs( 361 BList & old, 362 BList & updated); 363 }; 364 365 366 class BContinuousParameter : 367 public BParameter 368 { 369 public: 370 371 virtual type_code ValueType(); 372 373 float MinValue(); 374 float MaxValue(); 375 float ValueStep(); 376 377 /* The "response" specifies what value to display to the user. */ 378 /* Thus, if response is B_POLYNOMIAL with factor 2, an actual */ 379 /* control value of 10 would be displayed to the user as 100, and */ 380 /* if response was B_EXPONENTIAL and factor was 2, an actual */ 381 /* value of 3 would display 8 (two to the third). The ValueStep() */ 382 /* is given in actual control values, before the transformation for */ 383 /* display is done. Thus, with min 0, max 4 and value step 1, and an */ 384 /* exponential response with factor 10, you will get the displayed */ 385 /* values 1, 10, 100, 1000 and 10000 equally spaced across a slider */ 386 /* (or whatever UI the app puts to the parameter). */ 387 /* The "offset" is added to the value after transformation, before display. */ 388 /* If "resp" is negative, the resulting value/display relation is turned upside down. */ 389 enum response { 390 B_UNKNOWN = 0, 391 B_LINEAR = 1, /* factor is direct multiplier >= 0 */ 392 B_POLYNOMIAL, /* factor should be power; typically "2" for squared or "-1" for inverse */ 393 B_EXPONENTIAL, /* factor should be base, typically 2 or 10 */ 394 B_LOGARITHMIC /* factor should be base, typically 2 or 10 */ 395 }; 396 void SetResponse( 397 int resp, 398 float factor, 399 float offset); 400 void GetResponse( 401 int * resp, 402 float * factor, 403 float * offset); 404 405 virtual ssize_t FlattenedSize() const; 406 virtual status_t Flatten(void *buffer, ssize_t size) const; 407 virtual status_t Unflatten(type_code c, const void *buf, ssize_t size); 408 409 private: 410 411 /* Mmmh, stuffing! */ 412 virtual status_t _Reserved_ContinuousParameter_0(void *); 413 virtual status_t _Reserved_ContinuousParameter_1(void *); 414 virtual status_t _Reserved_ContinuousParameter_2(void *); 415 virtual status_t _Reserved_ContinuousParameter_3(void *); 416 virtual status_t _Reserved_ContinuousParameter_4(void *); 417 virtual status_t _Reserved_ContinuousParameter_5(void *); 418 virtual status_t _Reserved_ContinuousParameter_6(void *); 419 virtual status_t _Reserved_ContinuousParameter_7(void *); 420 friend class BParameterGroup; 421 422 BContinuousParameter( 423 int32 id, 424 media_type m_type, 425 BParameterWeb * web, 426 const char * name, 427 const char * kind, 428 const char * unit, 429 float minimum, 430 float maximum, 431 float stepping); 432 ~BContinuousParameter(); 433 434 float mMinimum; 435 float mMaximum; 436 float mStepping; 437 response mResponse; 438 float mFactor; 439 float mOffset; 440 uint32 _reserved_control_slider_[8]; 441 442 }; 443 444 445 class BDiscreteParameter : 446 public BParameter 447 { 448 public: 449 450 virtual type_code ValueType(); 451 452 int32 CountItems(); 453 const char * ItemNameAt( 454 int32 index); 455 int32 ItemValueAt( 456 int32 index); 457 status_t AddItem( 458 int32 value, 459 const char * name); 460 status_t MakeItemsFromInputs(); 461 status_t MakeItemsFromOutputs(); 462 void MakeEmpty(); 463 464 virtual ssize_t FlattenedSize() const; 465 virtual status_t Flatten(void *buffer, ssize_t size) const; 466 virtual status_t Unflatten(type_code c, const void *buf, ssize_t size); 467 468 private: 469 /* Mmmh, stuffing! */ 470 virtual status_t _Reserved_DiscreteParameter_0(void *); 471 virtual status_t _Reserved_DiscreteParameter_1(void *); 472 virtual status_t _Reserved_DiscreteParameter_2(void *); 473 virtual status_t _Reserved_DiscreteParameter_3(void *); 474 virtual status_t _Reserved_DiscreteParameter_4(void *); 475 virtual status_t _Reserved_DiscreteParameter_5(void *); 476 virtual status_t _Reserved_DiscreteParameter_6(void *); 477 virtual status_t _Reserved_DiscreteParameter_7(void *); 478 479 friend class BParameterGroup; 480 481 BList * mSelections; 482 BList * mValues; 483 uint32 _reserved_control_selector_[8]; 484 485 BDiscreteParameter( 486 int32 id, 487 media_type m_type, 488 BParameterWeb * web, 489 const char * name, 490 const char * kind); 491 ~BDiscreteParameter(); 492 }; 493 494 495 class BNullParameter : 496 public BParameter 497 { 498 public: 499 500 virtual type_code ValueType(); 501 502 virtual ssize_t FlattenedSize() const; 503 virtual status_t Flatten(void *buffer, ssize_t size) const; 504 virtual status_t Unflatten(type_code c, const void *buf, ssize_t size); 505 506 private: 507 /* Mmmh, stuffing! */ 508 virtual status_t _Reserved_NullParameter_0(void *); 509 virtual status_t _Reserved_NullParameter_1(void *); 510 virtual status_t _Reserved_NullParameter_2(void *); 511 virtual status_t _Reserved_NullParameter_3(void *); 512 virtual status_t _Reserved_NullParameter_4(void *); 513 virtual status_t _Reserved_NullParameter_5(void *); 514 virtual status_t _Reserved_NullParameter_6(void *); 515 virtual status_t _Reserved_NullParameter_7(void *); 516 517 friend class BParameterGroup; 518 519 uint32 _reserved_control_junction_[8]; 520 521 BNullParameter( 522 int32 id, 523 media_type m_type, 524 BParameterWeb * web, 525 const char * name, 526 const char * kind); 527 ~BNullParameter(); 528 529 }; 530 531 532 class BTextParameter : 533 public BParameter 534 { 535 public: 536 537 size_t MaxBytes() const; 538 virtual type_code ValueType(); 539 540 virtual ssize_t FlattenedSize() const; 541 virtual status_t Flatten(void *buffer, ssize_t size) const; 542 virtual status_t Unflatten(type_code c, const void *buf, ssize_t size); 543 544 private: 545 /* Mmmh, stuffing! */ 546 virtual status_t _Reserved_TextParameter_0(void *); 547 virtual status_t _Reserved_TextParameter_1(void *); 548 virtual status_t _Reserved_TextParameter_2(void *); 549 virtual status_t _Reserved_TextParameter_3(void *); 550 virtual status_t _Reserved_TextParameter_4(void *); 551 virtual status_t _Reserved_TextParameter_5(void *); 552 virtual status_t _Reserved_TextParameter_6(void *); 553 virtual status_t _Reserved_TextParameter_7(void *); 554 555 friend class BParameterGroup; 556 557 uint32 mMaxBytes; 558 uint32 _reserved_control_junction_[8]; 559 560 BTextParameter( 561 int32 id, 562 media_type m_type, 563 BParameterWeb * web, 564 const char * name, 565 const char * kind, 566 size_t max_bytes); 567 ~BTextParameter(); 568 569 }; 570 571 #endif /* _CONTROL_WEB_H */ 572