diff --git a/src/zapit/include/zapit/zapit.h b/src/zapit/include/zapit/zapit.h index e588884b6..df0fb9a7a 100644 --- a/src/zapit/include/zapit/zapit.h +++ b/src/zapit/include/zapit/zapit.h @@ -272,7 +272,7 @@ class CZapit : public OpenThreads::Thread int SetVolumePercent(int percent); void SetVolumePercent(int default_ac3, int default_pcm); #ifdef ENABLE_PIP - bool OpenPip(int pip = 0); + bool OpenPip(int pip = 0, int dnum = -1); bool StartPip(const t_channel_id channel_id, int pip = 0); bool StopPip(int pip = 0); #endif diff --git a/src/zapit/src/zapit.cpp b/src/zapit/src/zapit.cpp index 22f0117a0..86bee3fd3 100644 --- a/src/zapit/src/zapit.cpp +++ b/src/zapit/src/zapit.cpp @@ -651,18 +651,34 @@ bool CZapit::ZapIt(const t_channel_id channel_id, bool forupdate, bool startplay } #ifdef ENABLE_PIP -bool CZapit::OpenPip(int pip) +bool CZapit::OpenPip(int pip, int dnum) { if (!g_info.hw_caps->can_pip) return false; - pipVideoDecoder[pip] = new cVideo(0, NULL, NULL, pip+1); - pipVideoDecoder[pip]->ShowPig(0); - pipVideoDemux[pip] = new cDemux(pip+1); - pipVideoDemux[pip]->Open(DMX_VIDEO_CHANNEL); - pipAudioDecoder[pip] = new cAudio(0, NULL, NULL, pip+1); - pipAudioDemux[pip] = new cDemux(pip+1); - pipAudioDemux[pip]->Open(DMX_AUDIO_CHANNEL); + if (dnum == -1) + dnum = pip + 1; + + if (!pipVideoDecoder[pip]) + { + pipVideoDecoder[pip] = new cVideo(0, NULL, NULL, dnum); + pipVideoDecoder[pip]->ShowPig(0); + } + if (!pipVideoDemux[pip]) + { + pipVideoDemux[pip] = new cDemux(dnum); + pipVideoDemux[pip]->Open(DMX_VIDEO_CHANNEL); + } + if (!pipAudioDecoder[pip]) + { + pipAudioDecoder[pip] = new cAudio(0, NULL, NULL, dnum); + } + if (!pipAudioDemux[pip]) + { + pipAudioDemux[pip] = new cDemux(dnum); + pipAudioDemux[pip]->Open(DMX_AUDIO_CHANNEL); + } + return true; } bool CZapit::StopPip(int pip) @@ -708,7 +724,6 @@ bool CZapit::StopPip(int pip) delete pipAudioDecoder[pip]; pipAudioDecoder[pip] = NULL; } - return true; } @@ -721,14 +736,6 @@ bool CZapit::StartPip(const t_channel_id channel_id, int pip) StopPip(0); } - pipVideoDecoder[pip] = new cVideo(0, NULL, NULL, pip+1); - pipVideoDecoder[pip]->ShowPig(0); - pipVideoDemux[pip] = new cDemux(pip+1); - pipVideoDemux[pip]->Open(DMX_VIDEO_CHANNEL); - pipAudioDecoder[pip] = new cAudio(0, NULL, NULL, pip+1); - pipAudioDemux[pip] = new cDemux(pip+1); - pipAudioDemux[pip]->Open(DMX_AUDIO_CHANNEL); - CZapitChannel* newchannel; bool transponder_change; /* do lock if live is running, or in record mode - @@ -753,7 +760,9 @@ bool CZapit::StartPip(const t_channel_id channel_id, int pip) ERROR("Cannot get frontend\n"); return false; } + StopPip(pip); + if (!need_lock && !SAME_TRANSPONDER(newchannel->getChannelID(), live_channel_id)) live_channel_id = newchannel->getChannelID(); @@ -775,13 +784,7 @@ bool CZapit::StartPip(const t_channel_id channel_id, int pip) #endif INFO("[pip %d] vpid %X apid %X pcr %X", pip, newchannel->getVideoPid(), newchannel->getAudioPid(), newchannel->getPcrPid()); - if (!pipVideoDemux[pip]) { - pipVideoDemux[pip] = new cDemux(dnum); - pipVideoDemux[pip]->Open(DMX_VIDEO_CHANNEL); - if (!pipVideoDecoder[pip]) { - pipVideoDecoder[pip] = new cVideo(0, NULL, NULL, dnum); - } - } + OpenPip(pip, dnum); pipVideoDemux[pip]->SetSource(dnum, pip_fe[pip]->getNumber()); newchannel->setPipDemux(dnum); @@ -793,17 +796,9 @@ bool CZapit::StartPip(const t_channel_id channel_id, int pip) pipVideoDecoder[pip]->Start(0, newchannel->getPcrPid(), newchannel->getVideoPid()); pip_channel_id[pip] = newchannel->getChannelID(); - pipVideoDecoder[pip]->Pig(g_settings.pip_x,g_settings.pip_y,g_settings.pip_width,g_settings.pip_height,g_settings.screen_width,g_settings.screen_height); + pipVideoDecoder[pip]->Pig(g_settings.pip_x, g_settings.pip_y, g_settings.pip_width, g_settings.pip_height, g_settings.screen_width, g_settings.screen_height); pipVideoDecoder[pip]->ShowPig(1); - if (!pipAudioDemux[pip]) { - pipAudioDemux[pip] = new cDemux(dnum); - pipAudioDemux[pip]->Open(DMX_AUDIO_CHANNEL); - if (!pipAudioDecoder[pip]) { - pipAudioDecoder[pip] = new cAudio(0, NULL, NULL, dnum); - } - } - if (newchannel->getAudioChannel()) pipAudioDecoder[pip]->SetStreamType(newchannel->getAudioChannel()->audioChannelType); pipAudioDemux[pip]->pesFilter(newchannel->getAudioPid());