Index: tv_rec.cpp =================================================================== RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/tv_rec.cpp,v retrieving revision 1.131 diff -u -r1.131 tv_rec.cpp --- tv_rec.cpp 23 Jan 2004 06:01:16 -0000 1.131 +++ tv_rec.cpp 30 Jan 2004 01:24:50 -0000 @@ -18,21 +18,10 @@ #include "recordingprofile.h" #include "util.h" #include "programinfo.h" -#include "recorderbase.h" -#include "NuppelVideoRecorder.h" -#include "hdtvrecorder.h" #include "NuppelVideoPlayer.h" -#include "channel.h" #include "commercial_skip.h" -#ifdef USING_IVTV -#include "mpegrecorder.h" -#endif - -#ifdef USING_DVB -#include "dvbchannel.h" -#include "dvbrecorder.h" -#endif +#include void *SpawnEncode(void *param) { @@ -70,39 +59,62 @@ GetDevices(capturecardnum, videodev, vbidev, audiodev, audiosamplerate, inputname, startchannel, cardtype, dvb_options); - if (cardtype == "DVB") - { -#ifdef USING_DVB - channel = new DVBChannel(videodev.toInt(), this); - channel->Open(); - if (inputname.isEmpty()) - channel->SetChannelByString(startchannel); + QString plugin_path = QString(PREFIX) + QString("/lib/mythtv/record/lib") + + cardtype.lower() + QString(".so"); + plugin_handle = dlopen(plugin_path.ascii(), RTLD_LAZY); + if (plugin_handle != NULL) + { + getchannel_t* temp_gc = (getchannel_t*)dlsym(plugin_handle, "getchannel"); + char *err = dlerror(); + if (err != NULL) + { + cerr << "The recorder plugin for " << cardtype + << " is invalid, try reinstalling." << endl; + dlclose(plugin_handle); + plugin_handle = NULL; + return; // false; + } else - channel->SwitchToInput(inputname, startchannel); - channel->SetChannelOrdering(chanorder); - // don't close this channel, otherwise we cannot read data -#else - VERBOSE(VB_IMPORTANT, "ERROR: DVB Card configured, " - "but no DVB support compiled in!"); - VERBOSE(VB_IMPORTANT, "Remove the card from configuration, " - "or recompile MythTV."); - exit(-1); -#endif + plugin_getchannel = *temp_gc; + + getrecorder_t* temp_gr = (getrecorder_t*)dlsym(plugin_handle, "getrecorder"); + err = dlerror(); + if (err != NULL) + { + cerr << "The recorder plugin for " << cardtype + << " is invalid, try reinstalling." << endl; + dlclose(plugin_handle); + plugin_handle = NULL; + return; // false; + } + else + plugin_getrecorder = *temp_gr; } - else // "V4L" or "MPEG", ie, analog TV, or "HDTV" + else { - Channel *achannel = new Channel(this, videodev); - channel = achannel; // here for SetFormat()->RetrieveInputChannels() - channel->Open(); - achannel->SetFormat(gContext->GetSetting("TVFormat")); - achannel->SetDefaultFreqTable(gContext->GetSetting("FreqTable")); - if (inputname.isEmpty()) - channel->SetChannelByString(startchannel); - else - channel->SwitchToInput(inputname, startchannel); - channel->SetChannelOrdering(chanorder); - channel->Close(); + cerr << "Unable to open recorder plugin for " << cardtype << endl + << "the error was: " << dlerror() << endl; + return; // false; } + + channel = (*plugin_getchannel)(this, videodev); + if (channel == NULL) + { + cerr << "No Recorder plugins available." << endl; + return; // false; + } + + channel->Open(); + //if (false) return false; + + channel->SetFormat(gContext->GetSetting("TVFormat")); + channel->SetDefaultFreqTable(gContext->GetSetting("FreqTable")); + if (inputname.isEmpty()) + channel->SetChannelByString(startchannel); + else + channel->SwitchToInput(inputname, startchannel); + channel->SetChannelOrdering(chanorder); + channel->Close(); } void TVRec::Init(void) @@ -146,6 +158,8 @@ delete nvr; if (db_conn) DisconnectDB(); + + dlclose(plugin_handle); } TVState TVRec::GetState(void) @@ -525,57 +539,27 @@ void TVRec::SetupRecorder(RecordingProfile &profile) { - if (cardtype == "MPEG") + if (plugin_handle != NULL) { -#ifdef USING_IVTV - nvr = new MpegRecorder(); - nvr->SetRingBuffer(rbuffer); - - nvr->SetOptionsFromProfile(&profile, videodev, audiodev, vbidev, ispip); + nvr = (*plugin_getrecorder)(channel); - nvr->Initialize(); -#else - cerr << "Compiled without ivtv support\n"; -#endif - return; - } - else if (cardtype == "HDTV") - { - nvr = new HDTVRecorder(); nvr->SetRingBuffer(rbuffer); nvr->SetOptionsFromProfile(&profile, videodev, audiodev, vbidev, ispip); - nvr->Initialize(); - return; - } - else if (cardtype == "DVB") - { -#ifdef USING_DVB - nvr = new DVBRecorder(dynamic_cast(channel)); - nvr->SetRingBuffer(rbuffer); - - nvr->SetOptionsFromProfile(&profile, videodev, audiodev, vbidev, ispip); + if (cardtype == "DVB") + { + nvr->SetOption("swfilter", dvb_options.swfilter); + nvr->SetOption("recordts", dvb_options.recordts); + nvr->SetOption("wait_for_seqstart", dvb_options.wait_for_seqstart); + nvr->SetOption("dmx_buf_size", dvb_options.dmx_buf_size); + nvr->SetOption("pkt_buf_size", dvb_options.pkt_buf_size); + } - nvr->SetOption("swfilter", dvb_options.swfilter); - nvr->SetOption("recordts", dvb_options.recordts); - nvr->SetOption("wait_for_seqstart", dvb_options.wait_for_seqstart); - nvr->SetOption("dmx_buf_size", dvb_options.dmx_buf_size); - nvr->SetOption("pkt_buf_size", dvb_options.pkt_buf_size); nvr->Initialize(); -#endif - return; } - - // V4L/MJPEG from here on - - nvr = new NuppelVideoRecorder(channel); - - nvr->SetRingBuffer(rbuffer); - - nvr->SetOptionsFromProfile(&profile, videodev, audiodev, vbidev, ispip); - - nvr->Initialize(); + else + cerr << "Unable to open plugin for " << cardtype << endl; } void TVRec::TeardownRecorder(bool killFile)