StepMotionBlurFilter::StepMotionBlurFilter(BMediaAddOn* pAddOn) : // * init base classes BMediaNode(s_nodeName), // (virtual base) BBufferConsumer(B_MEDIA_RAW_VIDEO), BBufferProducer(B_MEDIA_RAW_VIDEO), BControllable(), BMediaEventLooper(), // * init connection state m_outputEnabled(true), m_downstreamLatency(0), m_processingLatency(0), // * init add-on stuff m_pAddOn(pAddOn) { // the rest of the initialization happens in NodeRegistered(). BParameterWeb *web = new BParameterWeb(); BParameterGroup *main = web->MakeGroup(Name()); BContinuousParameter *pimpact = main->MakeContinuousParameter(P_IMPACT, B_MEDIA_RAW_VIDEO, "Blur latency (%)", "MotionBalance", "", 0.0, 100.0, 1.0); BContinuousParameter *pstep = main->MakeContinuousParameter(P_STEP, B_MEDIA_RAW_VIDEO, "Step period (frames)", "MotionBalance", "", 1, 30, 1.0); impact=50; step_period = 5; tmp_buffer=NULL; count=0; fLastImpactChange = system_time(); /* After this call, the BControllable owns the BParameterWeb object and * will delete it for you */ SetParameterWeb(web); fRoster = BMediaRoster::Roster(); fRoster->RegisterNode(this); }
// build the LoggingConsumer's BParameterWeb static BParameterWeb* build_parameter_web() { BParameterWeb* web = new BParameterWeb; BParameterGroup* mainGroup = web->MakeGroup("LoggingConsumer Parameters"); BParameterGroup* group = mainGroup->MakeGroup("Latency control"); BParameter* nullParam = group->MakeNullParameter(INPUT_NULL_PARAM, B_MEDIA_NO_TYPE, "Latency", B_GENERIC); BParameter* latencyParam = group->MakeContinuousParameter(LATENCY_PARAM, B_MEDIA_NO_TYPE, "", B_GAIN, "ms", 5, 100, 5); nullParam->AddOutput(latencyParam); latencyParam->AddInput(nullParam); group = mainGroup->MakeGroup("CPU percentage"); nullParam = group->MakeNullParameter(CPU_NULL_PARAM, B_MEDIA_NO_TYPE, "CPU spin percentage", B_GENERIC); BContinuousParameter* cpuParam = group->MakeContinuousParameter(CPU_SPIN_PARAM, B_MEDIA_NO_TYPE, "", B_GAIN, "percent", 5, 80, 5); nullParam->AddOutput(cpuParam); cpuParam->AddInput(nullParam); group = mainGroup->MakeGroup("Priority"); nullParam = group->MakeNullParameter(PRIO_NULL_PARAM, B_MEDIA_NO_TYPE, "Thread priority", B_GENERIC); BDiscreteParameter* prioParam = group->MakeDiscreteParameter(PRIORITY_PARAM, B_MEDIA_NO_TYPE, "", B_GENERIC); prioParam->AddItem(5, "B_LOW_PRIORITY"); prioParam->AddItem(10, "B_NORMAL_PRIORITY"); prioParam->AddItem(15, "B_DISPLAY_PRIORITY"); prioParam->AddItem(20, "B_URGENT_DISPLAY_PRIORITY"); prioParam->AddItem(100, "B_REAL_TIME_DISPLAY_PRIORITY"); prioParam->AddItem(110, "B_URGENT_PRIORITY"); prioParam->AddItem(120, "B_REAL_TIME_PRIORITY"); return web; }
// utility - build the ToneProducer's parameter web static BParameterWeb* make_parameter_web() { FPRINTF(stderr, "make_parameter_web() called\n"); BParameterWeb* web = new BParameterWeb; BParameterGroup* mainGroup = web->MakeGroup("Tone Generator Parameters"); BParameterGroup* group = mainGroup->MakeGroup("Frequency"); BParameter* nullParam = group->MakeNullParameter(FREQUENCY_NULL_PARAM, B_MEDIA_NO_TYPE, "Frequency", B_GENERIC); BContinuousParameter* param = group->MakeContinuousParameter(FREQUENCY_PARAM, B_MEDIA_NO_TYPE, "", B_GAIN, "Hz", 0, 2500, 0.1); nullParam->AddOutput(param); param->AddInput(nullParam); group = mainGroup->MakeGroup("Amplitude"); nullParam = group->MakeNullParameter(GAIN_NULL_PARAM, B_MEDIA_NO_TYPE, "Amplitude", B_GENERIC); param = group->MakeContinuousParameter(GAIN_PARAM, B_MEDIA_NO_TYPE, "", B_GAIN, "", 0, 1, 0.01); nullParam->AddOutput(param); param->AddInput(nullParam); group = mainGroup->MakeGroup("Waveform"); nullParam = group->MakeNullParameter(WAVEFORM_NULL_PARAM, B_MEDIA_NO_TYPE, "Waveform", B_GENERIC); BDiscreteParameter* waveParam = group->MakeDiscreteParameter(WAVEFORM_PARAM, B_MEDIA_NO_TYPE, "", B_GENERIC); waveParam->AddItem(SINE_WAVE, "Sine wave"); waveParam->AddItem(TRIANGLE_WAVE, "Triangle"); waveParam->AddItem(SAWTOOTH_WAVE, "Sawtooth"); nullParam->AddOutput(waveParam); waveParam->AddInput(nullParam); return web; }
FlipTransition::FlipTransition(BMediaAddOn* pAddOn) : // * init base classes BMediaNode(s_nodeName), // (virtual base) BBufferConsumer(B_MEDIA_RAW_VIDEO), BBufferProducer(B_MEDIA_RAW_VIDEO), BControllable(), BMediaEventLooper(), // * init connection state m_outputEnabled(true), m_downstreamLatency(0), m_processingLatency(0), // * init add-on stuff m_pAddOn(pAddOn) { // the rest of the initialization happens in NodeRegistered(). BParameterWeb *web = new BParameterWeb(); BParameterGroup *main = web->MakeGroup(Name()); BContinuousParameter *pstate = main->MakeContinuousParameter(P_STATE,B_MEDIA_RAW_VIDEO,"State (%)","","",0.0,100.0,1.0); BContinuousParameter *pdx = main->MakeContinuousParameter(P_X,B_MEDIA_RAW_VIDEO,"X offset (%)","","",0.0,100.0,1.0); BContinuousParameter *pdy = main->MakeContinuousParameter(P_Y,B_MEDIA_RAW_VIDEO,"Y offset (%)","","",0.0,100.0,1.0); BContinuousParameter *pr = main->MakeContinuousParameter(P_RED,B_MEDIA_RAW_VIDEO,"Background Redness","","",0.0,255.0,1.0); BContinuousParameter *pg = main->MakeContinuousParameter(P_GREEN,B_MEDIA_RAW_VIDEO,"Background Greeness","","",0.0,255.0,1.0); BContinuousParameter *pb = main->MakeContinuousParameter(P_BLUE,B_MEDIA_RAW_VIDEO,"Background Blueness","","",0.0,255.0,1.0); BDiscreteParameter *pmode = main->MakeDiscreteParameter(P_MODE,B_MEDIA_RAW_VIDEO,"Mode",""); pmode->AddItem(0,"Horizontal"); pmode->AddItem(1,"Vertical"); pmode->AddItem(2,"Both"); TState = 0; Mode = 0; Red=Green=Blue=0; Dx=Dy=50; fLastStateChange = system_time(); firstInputBufferHere = false; secondInputBufferHere = false; buffers = NULL; transitionBuffer = NULL; /* After this call, the BControllable owns the BParameterWeb object and * will delete it for you */ SetParameterWeb(web); fRoster = BMediaRoster::Roster(); fRoster->RegisterNode(this); }
BParameterWeb *VideoRecorderNode::GetParameterWeb(void) { int32 cookie = 0; bool first=true; media_file_format *mff=new media_file_format; // if (web) delete web; web = new BParameterWeb(); BParameterGroup *videoFormat=web->MakeGroup("VideoFormat"); BParameterGroup *formatGroup = videoFormat->MakeGroup("Fileformat"); format = formatGroup->MakeDiscreteParameter(VIDEO_FORMAT, B_MEDIA_RAW_VIDEO, "VideoFileFormat", "FileFormat"); BParameterGroup *codecGroup = videoFormat->MakeGroup("Codec"); codec = codecGroup->MakeDiscreteParameter(VIDEO_CODEC, B_MEDIA_RAW_VIDEO, "Codec", "Codec"); BParameterGroup *qualityGroup = videoFormat->MakeGroup("Quality"); quality = qualityGroup->MakeContinuousParameter(VIDEO_QUALITY, B_MEDIA_RAW_VIDEO, "Video Quality", B_QUALITY,"",0,1.0,0.005); while (get_next_file_format(&cookie, mff) == B_OK) { if (mff->capabilities & media_file_format::B_KNOWS_ENCODED_VIDEO) { // format->AddItem(formatList->CountItems(), mff->pretty_name); format->AddItem((uint32)mff->family, mff->pretty_name); formatList->AddItem(&(mff->family)); if (first) { videoFileFormat=*mff; BuildCodecMenu(videoFileFormat.family); first=false; } } } videoQuality=1.0; return web; }
OffsetFilter::OffsetFilter(BMediaAddOn* pAddOn) : // * init base classes BMediaNode(s_nodeName), // (virtual base) BBufferConsumer(B_MEDIA_RAW_VIDEO), BBufferProducer(B_MEDIA_RAW_VIDEO), BControllable(), BMediaEventLooper(), // * init connection state m_outputEnabled(true), m_downstreamLatency(0), m_processingLatency(0), // * init add-on stuff m_pAddOn(pAddOn) { // the rest of the initialization happens in NodeRegistered(). BParameterWeb *web = new BParameterWeb(); BParameterGroup *main = web->MakeGroup(Name()); BContinuousParameter *pDELTA_X = main->MakeContinuousParameter(P_DELTA_X, B_MEDIA_RAW_VIDEO, "X Offset", "OffSetBalance", "", 0, 1000.0, 1.0); BContinuousParameter *pDELTA_Y = main->MakeContinuousParameter(P_DELTA_Y, B_MEDIA_RAW_VIDEO, "Y Offset", "OffSetBalance", "", 0, 1000.0, 1.0); DELTA_X=0; DELTA_Y=0; fLastOffSetChange = system_time(); /* After this call, the BControllable owns the BParameterWeb object and * will delete it for you */ SetParameterWeb(web); fRoster = BMediaRoster::Roster(); fRoster->RegisterNode(this); }
void EqualizerNode::InitParameterWeb(void) { fWeb = new BParameterWeb(); BParameterGroup* fParamGroup = fWeb->MakeGroup("EqualizerNode Parameters"); BParameterGroup* fFControlGroup = fParamGroup->MakeGroup("FilterControl"); fFControlGroup->MakeDiscreteParameter(P_MUTE,B_MEDIA_NO_TYPE,"Mute", B_ENABLE); fFControlGroup->MakeDiscreteParameter(P_BYPASS,B_MEDIA_NO_TYPE,"ByPass", B_ENABLE); BNullParameter* label; BParameterGroup* group; BContinuousParameter* value; group = fParamGroup->MakeGroup("Pre Amp"); label = group->MakeNullParameter(P_PREAMP_LABEL, B_MEDIA_NO_TYPE, "Pre Amp", B_GENERIC); value = group->MakeContinuousParameter(P_PREAMP, B_MEDIA_NO_TYPE, "", B_GAIN, "dB", -8.0, 8.0, 0.1); label->AddOutput(value); value->AddInput(label); for (int i = 0; i < fEqualizer.BandCount(); i++) { char freq[32]; sprintf(freq,"%gHz",fEqualizer.BandFrequency(i)); group = fParamGroup->MakeGroup(freq); label = group->MakeNullParameter(P_BAND_LABELS + i, B_MEDIA_NO_TYPE, freq, B_GENERIC); value = group->MakeContinuousParameter(P_BANDS + i, B_MEDIA_NO_TYPE, "", B_GAIN, "dB", -16.0, 16.0, 0.1); label->AddOutput(value); value->AddInput(label); } SetParameterWeb(fWeb); }
// protected: BParameterWeb * AbstractFileInterfaceNode::MakeParameterWeb(void) { CALLED(); BParameterWeb * web = new BParameterWeb(); BParameterGroup * mainGroup = web->MakeGroup("AbstractFileInterfaceNode Parameters"); // these three are related: // DEFAULT_CHUNK_SIZE_PARAM = // DEFAULT_BIT_RATE_PARAM / 1024 * DEFAULT_BUFFER_PERIOD_PARAM * 1000 BParameterGroup * chunkSizeGroup = mainGroup->MakeGroup("Chunk Size Group"); BContinuousParameter * chunkSizeParameter = chunkSizeGroup->MakeContinuousParameter( DEFAULT_CHUNK_SIZE_PARAM, B_MEDIA_MULTISTREAM, "Chunk Size", B_GAIN, "bytes", 1024, 32*1024, 512); chunkSizeParameter->SetResponse(BContinuousParameter::B_LINEAR,1,0); chunkSizeParameter->SetValue(&fDefaultChunkSizeParam,sizeof(fDefaultChunkSizeParam),0); BParameterGroup * bitRateGroup = mainGroup->MakeGroup("Bit Rate Group"); BContinuousParameter * bitRateParameter = bitRateGroup->MakeContinuousParameter( DEFAULT_BIT_RATE_PARAM, B_MEDIA_MULTISTREAM, "Bit Rate", B_GAIN, "kbits/sec", 1, 320000, 1); bitRateParameter->SetResponse(BContinuousParameter::B_LINEAR,.001,0); bitRateParameter->SetValue(&fDefaultBitRateParam,sizeof(fDefaultBitRateParam),0); BParameterGroup * bufferPeriodGroup = mainGroup->MakeGroup("Buffer Period Group"); BContinuousParameter * bufferPeriodParameter = bufferPeriodGroup->MakeContinuousParameter( DEFAULT_BUFFER_PERIOD_PARAM, B_MEDIA_MULTISTREAM, "Buffer Period", B_GAIN, "ms", 1, 10000, 1); bufferPeriodParameter->SetResponse(BContinuousParameter::B_LINEAR,1,0); bufferPeriodParameter->SetValue(&fDefaultBufferPeriodParam,sizeof(fDefaultBufferPeriodParam),0); return web; }
void UVCCamDevice::_AddProcessingParameter(BParameterGroup* group, int32 index, const usbvc_processing_unit_descriptor* descriptor) { BParameterGroup* subgroup; BContinuousParameter* p; uint16 wValue = 0; // Control Selector float minValue = 0.0; float maxValue = 100.0; if (descriptor->controlSize >= 1) { if (descriptor->controls[0] & 1) { // debug_printf("\tBRIGHTNESS\n"); fBrightness = _AddParameter(group, &subgroup, index, PU_BRIGHTNESS_CONTROL, "Brightness"); } if (descriptor->controls[0] & 2) { // debug_printf("\tCONSTRAST\n"); fContrast = _AddParameter(group, &subgroup, index + 1, PU_CONTRAST_CONTROL, "Contrast"); } if (descriptor->controls[0] & 4) { // debug_printf("\tHUE\n"); fHue = _AddParameter(group, &subgroup, index + 2, PU_HUE_CONTROL, "Hue"); if (descriptor->controlSize >= 2) { if (descriptor->controls[1] & 8) { fHueAuto = _AddAutoParameter(subgroup, index + 3, PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL); } } } if (descriptor->controls[0] & 8) { // debug_printf("\tSATURATION\n"); fSaturation = _AddParameter(group, &subgroup, index + 4, PU_SATURATION_CONTROL, "Saturation"); } if (descriptor->controls[0] & 16) { // debug_printf("\tSHARPNESS\n"); fSharpness = _AddParameter(group, &subgroup, index + 5, PU_SHARPNESS_CONTROL, "Sharpness"); } if (descriptor->controls[0] & 32) { // debug_printf("\tGamma\n"); fGamma = _AddParameter(group, &subgroup, index + 6, PU_GAMMA_CONTROL, "Gamma"); } if (descriptor->controls[0] & 64) { // debug_printf("\tWHITE BALANCE TEMPERATURE\n"); fWBTemp = _AddParameter(group, &subgroup, index + 7, PU_WHITE_BALANCE_TEMPERATURE_CONTROL, "WB Temperature"); if (descriptor->controlSize >= 2) { if (descriptor->controls[1] & 16) { fWBTempAuto = _AddAutoParameter(subgroup, index + 8, PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL); } } } if (descriptor->controls[0] & 128) { // debug_printf("\tWhite Balance Component\n"); fWBComponent = _AddParameter(group, &subgroup, index + 9, PU_WHITE_BALANCE_COMPONENT_CONTROL, "WB Component"); if (descriptor->controlSize >= 2) { if (descriptor->controls[1] & 32) { fWBTempAuto = _AddAutoParameter(subgroup, index + 10, PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL); } } } } if (descriptor->controlSize >= 2) { if (descriptor->controls[1] & 1) { // debug_printf("\tBACKLIGHT COMPENSATION\n"); int16 data; wValue = PU_BACKLIGHT_COMPENSATION_CONTROL << 8; fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, GET_MAX, wValue, fControlRequestIndex, sizeof(data), &data); maxValue = (float)data; fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, GET_MIN, wValue, fControlRequestIndex, sizeof(data), &data); minValue = (float)data; fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, GET_CUR, wValue, fControlRequestIndex, sizeof(data), &data); fBacklightCompensation = (float)data; subgroup = group->MakeGroup("Backlight Compensation"); if (maxValue - minValue == 1) { // Binary Switch fBinaryBacklightCompensation = true; subgroup->MakeDiscreteParameter(index + 11, B_MEDIA_RAW_VIDEO, "Backlight Compensation", B_ENABLE); } else { // Range of values fBinaryBacklightCompensation = false; p = subgroup->MakeContinuousParameter(index + 11, B_MEDIA_RAW_VIDEO, "Backlight Compensation", B_GAIN, "", minValue, maxValue, 1.0 / (maxValue - minValue)); } } if (descriptor->controls[1] & 2) { // debug_printf("\tGAIN\n"); fGain = _AddParameter(group, &subgroup, index + 12, PU_GAIN_CONTROL, "Gain"); } if (descriptor->controls[1] & 4) { // debug_printf("\tPOWER LINE FREQUENCY\n"); wValue = PU_POWER_LINE_FREQUENCY_CONTROL << 8; int8 data; if (fDevice->ControlTransfer(USB_REQTYPE_CLASS | USB_REQTYPE_INTERFACE_IN, GET_CUR, wValue, fControlRequestIndex, sizeof(data), &data) == sizeof(data)) { fPowerlineFrequency = data; } subgroup = group->MakeGroup("Power Line Frequency"); p = subgroup->MakeContinuousParameter(index + 13, B_MEDIA_RAW_VIDEO, "Frequency", B_GAIN, "", 0, 60.0, 1.0 / 60.0); } // TODO Determine whether controls apply to these /* if (descriptor->controls[1] & 64) debug_printf("\tDigital Multiplier\n"); if (descriptor->controls[1] & 128) debug_printf("\tDigital Multiplier Limit\n"); */ } // TODO Determine whether controls apply to these /* if (descriptor->controlSize >= 3) { if (descriptor->controls[2] & 1) debug_printf("\tAnalog Video Standard\n"); if (descriptor->controls[2] & 2) debug_printf("\tAnalog Video Lock Status\n"); } */ }
// create and register a parameter web void FlangerNode::initParameterWeb() { BParameterWeb* pWeb = new BParameterWeb(); BParameterGroup* pTopGroup = pWeb->MakeGroup("FlangerNode Parameters"); BNullParameter* label; BContinuousParameter* value; BParameterGroup* g; // mix ratio g = pTopGroup->MakeGroup("Mix ratio"); label = g->MakeNullParameter( P_MIX_RATIO_LABEL, B_MEDIA_NO_TYPE, "Mix ratio", B_GENERIC); value = g->MakeContinuousParameter( P_MIX_RATIO, B_MEDIA_NO_TYPE, "", B_GAIN, "", 0.0, 1.0, 0.05); label->AddOutput(value); value->AddInput(label); // sweep rate g = pTopGroup->MakeGroup("Sweep rate"); label = g->MakeNullParameter( P_SWEEP_RATE_LABEL, B_MEDIA_NO_TYPE, "Sweep rate", B_GENERIC); value = g->MakeContinuousParameter( P_SWEEP_RATE, B_MEDIA_NO_TYPE, "", B_GAIN, "Hz", 0.01, 10.0, 0.01); label->AddOutput(value); value->AddInput(label); // sweep range: minimum delay g = pTopGroup->MakeGroup("Delay"); label = g->MakeNullParameter( P_DELAY_LABEL, B_MEDIA_NO_TYPE, "Delay", B_GENERIC); value = g->MakeContinuousParameter( P_DELAY, B_MEDIA_NO_TYPE, "", B_GAIN, "ms", 0.1, s_fMaxDelay/2.0, 0.1); label->AddOutput(value); value->AddInput(label); // sweep range: maximum g = pTopGroup->MakeGroup("Depth"); label = g->MakeNullParameter( P_DEPTH_LABEL, B_MEDIA_NO_TYPE, "Depth", B_GENERIC); value = g->MakeContinuousParameter( P_DEPTH, B_MEDIA_NO_TYPE, "", B_GAIN, "ms", 1.0, s_fMaxDelay/4.0, 0.1); label->AddOutput(value); value->AddInput(label); // feedback g = pTopGroup->MakeGroup("Feedback"); label = g->MakeNullParameter( P_FEEDBACK_LABEL, B_MEDIA_NO_TYPE, "Feedback", B_GENERIC); value = g->MakeContinuousParameter( P_FEEDBACK, B_MEDIA_NO_TYPE, "", B_GAIN, "", 0.0, 1.0, 0.01); label->AddOutput(value); value->AddInput(label); // * Install parameter web SetParameterWeb(pWeb); }