Skip to content

Commit

Permalink
Allow providing file item properties from the addon
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuehlma committed Jul 9, 2017
1 parent aab5bb8 commit 9820f4e
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 12 deletions.
2 changes: 2 additions & 0 deletions xbmc/FileItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class CVariant;
class CFileItemList;
class CCueDocument;
typedef std::shared_ptr<CCueDocument> CCueDocumentPtr;
typedef std::map<std::string, std::string> CStringPropertyMap;
typedef std::shared_ptr<CStringPropertyMap> CStringPropertyMapPtr;

class IEvent;
typedef std::shared_ptr<const IEvent> EventPtr;
Expand Down
4 changes: 2 additions & 2 deletions xbmc/addons/PVRClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,15 +692,15 @@ bool CPVRClient::IsPlayable(const CConstPVREpgInfoTagPtr &tag)
return m_struct.toAddon.IsPlayable(pvrTag);
}

const std::string CPVRClient::GetEpgTagUrl(const CConstPVREpgInfoTagPtr &tag)
const std::string CPVRClient::GetEpgTagUrl(const CConstPVREpgInfoTagPtr &tag, const CStringPropertyMapPtr &properties)
{
if (!m_bReadyToUse)
return nullptr;

EPG_TAG pvrTag;
WriteEpgTag(tag, pvrTag);
char url[4096];
m_struct.toAddon.GetEpgTagUrl(pvrTag, url, sizeof(url));
m_struct.toAddon.GetEpgTagUrl(pvrTag, url, sizeof(url), properties);
return url;
}

Expand Down
3 changes: 2 additions & 1 deletion xbmc/addons/PVRClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,12 @@ namespace PVR
/*
* Get the URL to play a given EPG tag
* @param tag The EPG tag
* @param properties The properties to be provided to the file item
* @return The url to play for the EPG tag, empty string if it cannot be played
* @remarks Required, always return empty string if not supported by the addon
*
*/
const std::string GetEpgTagUrl(const CConstPVREpgInfoTagPtr &tag);
const std::string GetEpgTagUrl(const CConstPVREpgInfoTagPtr &tag, const CStringPropertyMapPtr &properties);

/*!
* @return True if this add-on has menu hooks, false otherwise.
Expand Down
3 changes: 2 additions & 1 deletion xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h
Original file line number Diff line number Diff line change
Expand Up @@ -582,11 +582,12 @@ extern "C"
* @param tag The EPG tag
* @param url The url to be returnd
* @param urlLen The length of the url buffer
* @param properties The properties to be provided to the file item
* @return The length of the url. -1 if the tag is not playable
* @remarks Required, always return -1 if not supported by the addon
*
*/
int GetEpgTagUrl(const EPG_TAG &tag, char *url, int urlLen);
int GetEpgTagUrl(const EPG_TAG &tag, char *url, int urlLen, const CStringPropertyMapPtr&);

/*!
* @brief Notify the pvr addon that XBMC (un)paused the currently playing stream
Expand Down
8 changes: 7 additions & 1 deletion xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <string.h>
#include <stdint.h>
#include <stdio.h>
#include <map>
#include <memory>

#include "xbmc_addon_types.h"
#include "xbmc_epg_types.h"
Expand Down Expand Up @@ -103,6 +105,10 @@ extern "C" {
xbmc_codec_id_t codec_id;
} xbmc_codec_t;

typedef std::map<std::string, std::string> CStringPropertyMap;
typedef std::shared_ptr<CStringPropertyMap> CStringPropertyMapPtr;


/*!
* @brief numeric PVR timer type definitions (PVR_TIMER.iTimerType values)
*/
Expand Down Expand Up @@ -664,7 +670,7 @@ extern "C" {
long long (__cdecl* LengthRecordedStream)(void);
PVR_ERROR (__cdecl* IsRecordable)(const EPG_TAG&, bool*);
bool (__cdecl* IsPlayable)(const EPG_TAG&);
int (__cdecl* GetEpgTagUrl)(const EPG_TAG&, char*, int);
int (__cdecl* GetEpgTagUrl)(const EPG_TAG&, char*, int, const CStringPropertyMapPtr&);
void (__cdecl* DemuxReset)(void);
void (__cdecl* DemuxAbort)(void);
void (__cdecl* DemuxFlush)(void);
Expand Down
6 changes: 5 additions & 1 deletion xbmc/pvr/PVRGUIActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1092,13 +1092,17 @@ namespace PVR
if (!epgTag)
return false;

std::string stream = epgTag->GetStreamUrl();
CStringPropertyMapPtr properties(new CStringPropertyMap());
std::string stream = epgTag->GetStreamUrl(properties);
if (stream.empty())
{
return false;
}

item->SetPath(stream);
for (auto const &entry : *properties.get()) {
item->SetProperty(entry.first, entry.second);
}

if (!bCheckResume || CheckResumeRecording(item))
CApplicationMessenger::GetInstance().PostMsg(TMSG_MEDIA_PLAY, 0, 0, static_cast<void*>(new CFileItem(*item)));
Expand Down
4 changes: 2 additions & 2 deletions xbmc/pvr/addons/PVRClients.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1243,13 +1243,13 @@ bool CPVRClients::IsPlayable(const CConstPVREpgInfoTagPtr &tag)
return NULL;
}

const std::string CPVRClients::GetEpgTagUrl(const CConstPVREpgInfoTagPtr &tag)
const std::string CPVRClients::GetEpgTagUrl(const CConstPVREpgInfoTagPtr &tag, const CStringPropertyMapPtr &properties)
{
PVR_CLIENT client;

if (GetClient(tag->ChannelTag()->ClientID(), client))
{
return client->GetEpgTagUrl(tag);
return client->GetEpgTagUrl(tag, properties);
}

return "";
Expand Down
2 changes: 1 addition & 1 deletion xbmc/pvr/addons/PVRClients.h
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ namespace PVR

bool IsPlayable(const CConstPVREpgInfoTagPtr &tag);

const std::string GetEpgTagUrl(const CConstPVREpgInfoTagPtr &tag);
const std::string GetEpgTagUrl(const CConstPVREpgInfoTagPtr &tag, const CStringPropertyMapPtr &properties);

bool IsRealTimeStream() const;

Expand Down
4 changes: 2 additions & 2 deletions xbmc/pvr/epg/EpgInfoTag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ bool CPVREpgInfoTag::IsPlayable(void) const
return CServiceBroker::GetPVRManager().Clients()->IsPlayable(shared_from_this());
}

const std::string CPVREpgInfoTag::GetStreamUrl(void) const
const std::string CPVREpgInfoTag::GetStreamUrl(CStringPropertyMapPtr &properties) const
{
return CServiceBroker::GetPVRManager().Clients()->GetEpgTagUrl(shared_from_this());
return CServiceBroker::GetPVRManager().Clients()->GetEpgTagUrl(shared_from_this(), properties);
}

bool CPVREpgInfoTag::IsRecordable(void) const
Expand Down
3 changes: 2 additions & 1 deletion xbmc/pvr/epg/EpgInfoTag.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ namespace PVR
bool IsPlayable(void) const;

/* @brief Get the stream url for this event
* @param properties The properties to be provided to the file item
* @return The stream url, empty string if playing is not possible
*/
const std::string GetStreamUrl(void) const;
const std::string GetStreamUrl(CStringPropertyMapPtr &properties) const;

/*!
* @return True when this event has already passed, false otherwise.
Expand Down

0 comments on commit 9820f4e

Please sign in to comment.