Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Digital TV: disable play button
Browse files Browse the repository at this point in the history
- Play button disabled to avoid the problems the internal splitter has when stopping/playing life streams
- Instead of using the button, a channel can be selected. The possibility of choosing the same current channel has been activated so in case there is an error and the player is stopped, the same channel can be re-selected.
- Do not show OSD "Stop" during a channel switch operation for digital TV
- IPTV: update the name of the channel in window title (as DVB )
- Enable the OSD message with the channel name
- Fixed problem when pressing stop not stopping
  • Loading branch information
xpc1000 committed Nov 3, 2017
1 parent 74704a3 commit 8077b30
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 48 deletions.
10 changes: 7 additions & 3 deletions src/mpc-hc/IPTVScanDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,14 @@ void CIPTVScanDlg::OnUpdateExpectedTime()

CT2CA pszConvertedAnsiString1(strIPAddress1);
char* sIPAddr1 = pszConvertedAnsiString1;
UINT32 uIP1 = inet_addr(sIPAddr1);
UINT32 uIP1;
inet_pton(AF_INET, sIPAddr1, &uIP1);
// UINT32 uIP1 = inet_addr(sIPAddr1);
CT2CA pszConvertedAnsiString2(strIPAddress2);
char* sIPAddr2 = pszConvertedAnsiString2;
UINT32 uIP2 = inet_addr(sIPAddr2);
UINT32 uIP2;
inet_pton(AF_INET, sIPAddr2, &uIP2);
// UINT32 uIP2 = inet_addr(sIPAddr2);
uIP1 = ntohl(uIP1);
uIP2 = ntohl(uIP2);
int iTime = (int)(uIP2 - uIP1) * 3 / 60;
Expand Down Expand Up @@ -373,7 +377,7 @@ void CIPTVScanDlg::OnClickedSave()
}
} catch (CException* e) {
// The tokenisation can fail if the input string was invalid
TRACE(_T("Failed to parse a IPTV channel from string \"%s\""), m_ChannelList.GetItemText(i, ISCC_CHANNEL));
TRACE(_T("Failed to parse a IPTV channel from string \"%s\""), m_ChannelList.GetItemText(i, ISCC_CHANNEL).GetString());
ASSERT(FALSE);
e->Delete();
}
Expand Down
110 changes: 66 additions & 44 deletions src/mpc-hc/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7019,8 +7019,14 @@ void CMainFrame::OnPlayPlay()
if (!(m_pDVBState->pChannel)) {
CDVBChannel* pChannel = s.FindChannelByPref(s.nDVBLastChannel);
// Only for DVB
if (!(pChannel && pChannel->IsIPTV())) {
SetChannel(s.nDVBLastChannel);
if (pChannel) {
if (pChannel->IsDVB()) {
SetChannel(s.nDVBLastChannel);
} else { // pChannel->IsIPTV()
m_pDVBState->bActive = true;
m_pDVBState->pChannel = pChannel;
m_pDVBState->sChannelName = pChannel->GetName();
}
}
}
m_pDVBState->bSetChannelActive = false;
Expand Down Expand Up @@ -7086,6 +7092,9 @@ void CMainFrame::OnPlayPlay()
}
if (GetPlaybackMode() != PM_DIGITAL_TV) {
m_OSD.DisplayMessage(OSD_TOPLEFT, strOSD, 3000);
} else if (m_pDVBState->pChannel && m_pDVBState->pChannel->IsIPTV()) {
MoveVideoWindow();
UpdateCurrentChannelInfo();
}
}

Expand Down Expand Up @@ -7195,7 +7204,11 @@ void CMainFrame::OnPlayStop()
m_pMC->Stop();
m_pDVDC->SetOption(DVD_ResetOnStop, FALSE);
} else if (GetPlaybackMode() == PM_DIGITAL_TV) {
m_pMC->Stop();
OAFilterState nState;
m_pMC->GetState(500, &nState);
if (nState == State_Running) {
m_pMC->Stop();
}
m_pDVBState->bActive = false;
OpenSetupWindowTitle();
m_wndStatusBar.SetStatusTimer(StrRes(IDS_CAPTURE_LIVE));
Expand Down Expand Up @@ -7235,16 +7248,19 @@ void CMainFrame::OnPlayStop()
}
}

if (!m_fEndOfStream && GetLoadState() == MLS::LOADED) {
CString strOSD(StrRes(ID_PLAY_STOP));
int i = strOSD.Find(_T("\n"));
if (i > 0) {
strOSD.Delete(i, strOSD.GetLength() - i);
// Show OSD only if not in the middle of a channel switch operation for digital TV
if (!(GetPlaybackMode() == PM_DIGITAL_TV && m_pDVBState && m_pDVBState->bSetChannelActive)) {
if (!m_fEndOfStream && GetLoadState() == MLS::LOADED) {
CString strOSD(StrRes(ID_PLAY_STOP));
int i = strOSD.Find(_T("\n"));
if (i > 0) {
strOSD.Delete(i, strOSD.GetLength() - i);
}
m_OSD.DisplayMessage(OSD_TOPLEFT, strOSD, 3000);
m_Lcd.SetStatusMessage(ResStr(IDS_CONTROLS_STOPPED), 3000);
} else {
m_fEndOfStream = false;
}
m_OSD.DisplayMessage(OSD_TOPLEFT, strOSD, 3000);
m_Lcd.SetStatusMessage(ResStr(IDS_CONTROLS_STOPPED), 3000);
} else {
m_fEndOfStream = false;
}
SetPlayState(PS_STOP);
}
Expand All @@ -7270,8 +7286,12 @@ void CMainFrame::OnUpdatePlayPauseStop(CCmdUI* pCmdUI)
fEnable = false;
} else if (m_fLiveWM && pCmdUI->m_nID == ID_PLAY_PAUSE) {
fEnable = false;
} else if (GetPlaybackMode() == PM_DIGITAL_TV && pCmdUI->m_nID == ID_PLAY_PAUSE) {
fEnable = false; // Disable pause for digital capture mode to avoid accidental playback stop. We don't support time shifting yet.
} else if (GetPlaybackMode() == PM_DIGITAL_TV &&
(pCmdUI->m_nID == ID_PLAY_PAUSE || pCmdUI->m_nID == ID_PLAY_PLAY)) {
// Disable pause for digital TV to avoid accidental playback stop. We don't support time shifting yet.
// Also disable play to avoid problem with life streams when using the internal splitter
// Instead of play, we should select a channel
fEnable = false;
}
} else if (GetPlaybackMode() == PM_DVD) {
fEnable = m_iDVDDomain != DVD_DOMAIN_VideoManagerMenu
Expand Down Expand Up @@ -8695,8 +8715,6 @@ void CMainFrame::OnNavigateJumpTo(UINT nID)
return;
}

const CAppSettings& s = AfxGetAppSettings();

if (GetPlaybackMode() == PM_FILE) {
int id = nID - ID_NAVIGATE_JUMPTO_SUBITEM_START;

Expand Down Expand Up @@ -8739,11 +8757,9 @@ void CMainFrame::OnNavigateJumpTo(UINT nID)
} else if (GetPlaybackMode() == PM_DIGITAL_TV) {
int nChannel = nID - ID_NAVIGATE_JUMPTO_SUBITEM_START;

if (s.nDVBLastChannel != nChannel) {
if (SUCCEEDED(SetChannel(nChannel))) {
if (m_controls.ControlChecked(CMainFrameControls::Panel::NAVIGATION)) {
m_wndNavigationBar.m_navdlg.UpdatePos(nChannel);
}
if (SUCCEEDED(SetChannel(nChannel))) {
if (m_controls.ControlChecked(CMainFrameControls::Panel::NAVIGATION)) {
m_wndNavigationBar.m_navdlg.UpdatePos(nChannel);
}
}
}
Expand Down Expand Up @@ -15255,15 +15271,13 @@ HRESULT CMainFrame::SetChannel(int nChannel)
}
} else if (pChannel->IsIPTV() && s.bEnabledIPTV) {
// IPTV
// Only switch channel if new channel != current channel
if (pChannel != s.FindChannelByPref(s.nDVBLastChannel)) {
// Rebuild graph
m_nLockedZoomVideoWindow = 0;
s.nDVBLastChannel = nChannel;
m_wndNavigationBar.m_navdlg.SetChannelInfoAvailable(FALSE);
m_pDVBState->pChannel = pChannel;
hr = ReCreateGraph();
}
// Always rebuild graph
m_nLockedZoomVideoWindow = 0;
s.nDVBLastChannel = nChannel;
m_wndNavigationBar.m_navdlg.SetChannelInfoAvailable(FALSE);
m_pDVBState->pChannel = pChannel;
m_pDVBState->sChannelName = pChannel->GetName();
hr = ReCreateGraph();
} else {
// The channel is IPTV and IPTV is not enabled
hr = E_INVALIDARG;
Expand Down Expand Up @@ -15325,6 +15339,9 @@ void CMainFrame::UpdateCurrentChannelInfo(bool bShowOSD /*= true*/, bool bShowIn
return infoData;
});
}
else if (m_pDVBState && pChannel->IsIPTV()) {
PostMessage(WM_DVB_EIT_DATA_READY);
}
}


Expand Down Expand Up @@ -15417,6 +15434,13 @@ LRESULT CMainFrame::OnCurrentChannelInfoUpdated(WPARAM wParam, LPARAM lParam)
m_OSD.DisplayMessage(OSD_TOPLEFT, sChannelInfo, 3500);
}

// Update window title and skype status
OpenSetupWindowTitle();
SendNowPlayingToSkype();
} else if (m_pDVBState->pChannel->IsIPTV() && m_pDVBState->sChannelName) {
RecalcLayout();
m_OSD.DisplayMessage(OSD_TOPLEFT, m_pDVBState->sChannelName, 3500);

// Update window title and skype status
OpenSetupWindowTitle();
SendNowPlayingToSkype();
Expand Down Expand Up @@ -17042,23 +17066,21 @@ CString CMainFrame::GetCaptureTitle()
CString title;

title.LoadString(IDS_CAPTURE_LIVE);
CString devName = GetFriendlyName(m_VidDispName);
if (!devName.IsEmpty()) {
if (GetPlaybackMode() == PM_ANALOG_CAPTURE) {
CString devName = GetFriendlyName(m_VidDispName);
if (!devName.IsEmpty()) {
title.AppendFormat(_T(" | %s"), devName.GetString());
}
return title;
}

CString CMainFrame::GetDigitalTVTitle()
{
CString title;

title.LoadString(IDS_CAPTURE_LIVE);
CString& eventName = m_pDVBState->NowNext.eventName;
if (m_pDVBState->bActive) {
}
} else {
CString& eventName = m_pDVBState->NowNext.eventName;
if (m_pDVBState->bActive) {
title.AppendFormat(_T(" | %s"), m_pDVBState->sChannelName.GetString());
if (!eventName.IsEmpty()) {
if (!eventName.IsEmpty()) {
title.AppendFormat(_T(" - %s"), eventName.GetString());
}
}
else if (m_pDVBState->sChannelName) {
title.AppendFormat(_T(" | %s"), m_pDVBState->sChannelName.GetString());
} else {
title += _T(" | DTV");
}
Expand Down
1 change: 0 additions & 1 deletion src/mpc-hc/MainFrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,6 @@ class CMainFrame : public CFrameWnd, public CDropClient

CString GetFileName();
CString GetCaptureTitle();
CString GetDigitalTVTitle();

// shaders
void SetShaders(bool bSetPreResize = true, bool bSetPostResize = true);
Expand Down

0 comments on commit 8077b30

Please sign in to comment.