bool GMVideoInputManager_ptlib::open (unsigned width, unsigned height, unsigned fps) { PVideoDevice::VideoFormat pvideo_format; PTRACE(4, "GMVideoInputManager_ptlib\tOpening Device " << current_state.device); PTRACE(4, "GMVideoInputManager_ptlib\tOpening Device with " << width << "x" << height << "/" << fps); current_state.width = width; current_state.height = height; current_state.fps = fps; expectedFrameSize = (width * height * 3) >> 1; pvideo_format = (PVideoDevice::VideoFormat)current_state.format; input_device = PVideoInputDevice::CreateOpenedDevice (current_state.device.source, #ifdef WIN32 utf2codepage (current_state.device.name), // reencode back to codepage #else current_state.device.name, #endif FALSE); Ekiga::VideoInputErrorCodes error_code = Ekiga::VI_ERROR_NONE; if (!input_device) error_code = Ekiga::VI_ERROR_DEVICE; else if (!input_device->SetVideoFormat (pvideo_format)) error_code = Ekiga::VI_ERROR_FORMAT; else if (!input_device->SetChannel (current_state.channel)) error_code = Ekiga::VI_ERROR_CHANNEL; else if (!input_device->SetColourFormatConverter ("YUV420P")) error_code = Ekiga::VI_ERROR_COLOUR; else if (!input_device->SetFrameRate (current_state.fps)) error_code = Ekiga::VI_ERROR_FPS; else if (!input_device->SetFrameSizeConverter (current_state.width, current_state.height, PVideoFrameInfo::eScale)) error_code = Ekiga::VI_ERROR_SCALE; else input_device->Start (); if (error_code != Ekiga::VI_ERROR_NONE) { PTRACE(1, "GMVideoInputManager_ptlib\tEncountered error " << error_code << " while opening device "); Ekiga::Runtime::run_in_main (boost::bind (&GMVideoInputManager_ptlib::device_error_in_main, this, current_state.device, error_code)); return false; } int whiteness, brightness, colour, contrast, hue; input_device->GetParameters (&whiteness, &brightness, &colour, &contrast, &hue); current_state.opened = true; Ekiga::VideoInputSettings settings; settings.whiteness = whiteness >> 8; settings.brightness = brightness >> 8; settings.colour = colour >> 8; settings.contrast = contrast >> 8; settings.modifyable = true; Ekiga::Runtime::run_in_main (boost::bind (&GMVideoInputManager_ptlib::device_opened_in_main, this, current_state.device, settings)); return true; }
bool GMAudioInputManager_ptlib::open (unsigned channels, unsigned samplerate, unsigned bits_per_sample) { PTRACE(4, "GMAudioInputManager_ptlib\tOpening Device " << current_state.device); PTRACE(4, "GMAudioInputManager_ptlib\tOpening Device with " << channels << "-" << samplerate << "/" << bits_per_sample); current_state.channels = channels; current_state.samplerate = samplerate; current_state.bits_per_sample = bits_per_sample; input_device = PSoundChannel::CreateOpenedChannel (current_state.device.source, #ifdef WIN32 utf2codepage (current_state.device.name), // reencode back to codepage #else current_state.device.name, #endif PSoundChannel::Recorder, channels, samplerate, bits_per_sample); Ekiga::AudioInputErrorCodes error_code = Ekiga::AI_ERROR_NONE; if (!input_device) error_code = Ekiga::AI_ERROR_DEVICE; if (error_code != Ekiga::AI_ERROR_NONE) { PTRACE(1, "GMAudioInputManager_ptlib\tEncountered error " << error_code << " while opening device "); Ekiga::Runtime::run_in_main (boost::bind (&GMAudioInputManager_ptlib::device_error_in_main, this, current_state.device, error_code)); return false; } unsigned volume; input_device->GetVolume (volume); current_state.opened = true; Ekiga::AudioInputSettings settings; settings.volume = volume; settings.modifyable = true; Ekiga::Runtime::run_in_main (boost::bind (&GMAudioInputManager_ptlib::device_opened_in_main, this, current_state.device, settings)); return true; }