1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
/*
* Copyright (C) 2012-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "InputStreamPVRChannel.h"
#include "ServiceBroker.h"
#include "pvr/PVRManager.h"
#include "pvr/addons/PVRClient.h"
#include "pvr/channels/PVRChannelGroupsContainer.h"
#include "utils/log.h"
using namespace PVR;
CInputStreamPVRChannel::CInputStreamPVRChannel(IVideoPlayer* pPlayer, const CFileItem& fileitem)
: CInputStreamPVRBase(pPlayer, fileitem),
m_bDemuxActive(false)
{
}
CInputStreamPVRChannel::~CInputStreamPVRChannel()
{
Close();
}
CDVDInputStream::IDemux* CInputStreamPVRChannel::GetIDemux()
{
if (m_bDemuxActive)
return this;
return CInputStreamPVRBase::GetIDemux();
}
bool CInputStreamPVRChannel::OpenPVRStream()
{
std::shared_ptr<CPVRChannel> channel = m_item.GetPVRChannelInfoTag();
if (!channel)
channel = CServiceBroker::GetPVRManager().ChannelGroups()->GetByPath(m_item.GetPath());
if (!channel)
CLog::Log(LOGERROR,
"CInputStreamPVRChannel - {} - unable to obtain channel instance for channel {}",
__FUNCTION__, m_item.GetPath());
if (channel && m_client && (m_client->OpenLiveStream(channel) == PVR_ERROR_NO_ERROR))
{
m_bDemuxActive = m_client->GetClientCapabilities().HandlesDemuxing();
CLog::Log(LOGDEBUG, "CInputStreamPVRChannel - {} - opened channel stream {}", __FUNCTION__,
m_item.GetPath());
return true;
}
return false;
}
void CInputStreamPVRChannel::ClosePVRStream()
{
if (m_client && (m_client->CloseLiveStream() == PVR_ERROR_NO_ERROR))
{
m_bDemuxActive = false;
CLog::Log(LOGDEBUG, "CInputStreamPVRChannel - {} - closed channel stream {}", __FUNCTION__,
m_item.GetPath());
}
}
int CInputStreamPVRChannel::ReadPVRStream(uint8_t* buf, int buf_size)
{
int ret = -1;
if (m_client)
m_client->ReadLiveStream(buf, buf_size, ret);
return ret;
}
int64_t CInputStreamPVRChannel::SeekPVRStream(int64_t offset, int whence)
{
int64_t ret = -1;
if (m_client)
m_client->SeekLiveStream(offset, whence, ret);
return ret;
}
int64_t CInputStreamPVRChannel::GetPVRStreamLength()
{
int64_t ret = -1;
if (m_client)
m_client->GetLiveStreamLength(ret);
return ret;
}
CDVDInputStream::ENextStream CInputStreamPVRChannel::NextPVRStream()
{
if (m_eof)
return NEXTSTREAM_OPEN;
return NEXTSTREAM_RETRY;
}
bool CInputStreamPVRChannel::CanPausePVRStream()
{
bool ret = false;
if (m_client)
m_client->CanPauseStream(ret);
return ret;
}
bool CInputStreamPVRChannel::CanSeekPVRStream()
{
bool ret = false;
if (m_client)
m_client->CanSeekStream(ret);
return ret;
}
|