Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Stop libhdhomerun polluting our namespace.

libhdhomerun is nice enough to define min and max macros for us in one
of its global headers.  Unfortunately they already reside in the std
namespace so conflicts arise, resulting in compile errors.  We can limit
the polution to the hdhomerun dll interface by breaking it away from the
VFS implementation sources.
  • Loading branch information...
commit 26f4d3ea3cdc7e2c018c4223d87fe63e5c1ce48f 1 parent f84fd17
althekiller authored
View
71 xbmc/filesystem/DllHDHomeRun.h
@@ -0,0 +1,71 @@
+#pragma once
+/*
+ * Copyright (C) 2005-2008 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "DynamicDll.h"
+#include "lib/libhdhomerun/hdhomerun.h"
+
+class DllHdHomeRunInterface
+{
+public:
+ virtual ~DllHdHomeRunInterface() {}
+ virtual int discover_find_devices_custom(uint32_t target_ip, uint32_t device_type, uint32_t device_id, struct hdhomerun_discover_device_t result_list[], int max_count)=0;
+ virtual struct hdhomerun_device_t* device_create_from_str(const char *device_str, struct hdhomerun_debug_t *dbg)=0;
+ virtual void device_destroy(struct hdhomerun_device_t *hd)=0;
+ virtual int device_stream_start(struct hdhomerun_device_t *hd)=0;
+ virtual uint8_t* device_stream_recv(struct hdhomerun_device_t *hd, size_t max_size, size_t* pactual_size)=0;
+ virtual void device_stream_stop(struct hdhomerun_device_t *hd)=0;
+ virtual int device_set_tuner_channel(struct hdhomerun_device_t *hd, const char *channel)=0;
+ virtual int device_set_tuner_program(struct hdhomerun_device_t *hd, const char *program)=0;
+ virtual int device_set_tuner_from_str(struct hdhomerun_device_t *hd, const char *tuner_str)=0;
+ virtual void device_set_tuner(struct hdhomerun_device_t *hd, unsigned int tuner)=0;
+ virtual int device_get_tuner_status(struct hdhomerun_device_t *hd, char **pstatus_str, struct hdhomerun_tuner_status_t *status)=0;
+};
+
+class DllHdHomeRun : public DllDynamic, public DllHdHomeRunInterface
+{
+ DECLARE_DLL_WRAPPER(DllHdHomeRun, DLL_PATH_LIBHDHOMERUN)
+ DEFINE_METHOD5(int, discover_find_devices_custom, (uint32_t p1, uint32_t p2, uint32_t p3, struct hdhomerun_discover_device_t p4[], int p5))
+ DEFINE_METHOD2(struct hdhomerun_device_t*, device_create_from_str, (const char* p1, struct hdhomerun_debug_t *p2))
+ DEFINE_METHOD1(void, device_destroy, (struct hdhomerun_device_t* p1))
+ DEFINE_METHOD1(int, device_stream_start, (struct hdhomerun_device_t* p1))
+ DEFINE_METHOD3(uint8_t*, device_stream_recv, (struct hdhomerun_device_t* p1, size_t p2, size_t* p3))
+ DEFINE_METHOD1(void, device_stream_stop, (struct hdhomerun_device_t* p1))
+ DEFINE_METHOD2(int, device_set_tuner_channel, (struct hdhomerun_device_t *p1, const char *p2))
+ DEFINE_METHOD2(int, device_set_tuner_program, (struct hdhomerun_device_t *p1, const char *p2))
+ DEFINE_METHOD2(int, device_set_tuner_from_str, (struct hdhomerun_device_t *p1, const char *p2))
+ DEFINE_METHOD2(void, device_set_tuner, (struct hdhomerun_device_t *p1, unsigned int p2))
+ DEFINE_METHOD3(int, device_get_tuner_status, (struct hdhomerun_device_t *p1, char **p2, struct hdhomerun_tuner_status_t *p3));
+ BEGIN_METHOD_RESOLVE()
+ RESOLVE_METHOD_RENAME(hdhomerun_discover_find_devices_custom, discover_find_devices_custom)
+ RESOLVE_METHOD_RENAME(hdhomerun_device_create_from_str, device_create_from_str)
+ RESOLVE_METHOD_RENAME(hdhomerun_device_destroy, device_destroy)
+ RESOLVE_METHOD_RENAME(hdhomerun_device_stream_start, device_stream_start)
+ RESOLVE_METHOD_RENAME(hdhomerun_device_stream_recv, device_stream_recv)
+ RESOLVE_METHOD_RENAME(hdhomerun_device_stream_stop, device_stream_stop)
+ RESOLVE_METHOD_RENAME(hdhomerun_device_set_tuner_channel, device_set_tuner_channel)
+ RESOLVE_METHOD_RENAME(hdhomerun_device_set_tuner_program, device_set_tuner_program)
+ RESOLVE_METHOD_RENAME(hdhomerun_device_set_tuner_from_str, device_set_tuner_from_str)
+ RESOLVE_METHOD_RENAME(hdhomerun_device_set_tuner, device_set_tuner)
+ RESOLVE_METHOD_RENAME(hdhomerun_device_get_tuner_status, device_get_tuner_status)
+ END_METHOD_RESOLVE()
+};
+
View
43 xbmc/filesystem/HDHomeRun.cpp
@@ -22,6 +22,7 @@
#include "system.h"
#include "URL.h"
#include "FileItem.h"
+#include "DllHDHomeRun.h"
#include "HDHomeRun.h"
#include "utils/TimeUtils.h"
#include "utils/log.h"
@@ -67,17 +68,19 @@ class CUrlOptions
CDirectoryHomeRun::CDirectoryHomeRun()
{
- m_dll.Load();
+ m_pdll = new DllHdHomeRun;
+ m_pdll->Load();
}
CDirectoryHomeRun::~CDirectoryHomeRun()
{
- m_dll.Unload();
+ m_pdll->Unload();
+ delete m_pdll;
}
bool CDirectoryHomeRun::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
- if(!m_dll.IsLoaded())
+ if(!m_pdll->IsLoaded())
return false;
CURL url(strPath);
@@ -87,7 +90,7 @@ bool CDirectoryHomeRun::GetDirectory(const CStdString& strPath, CFileItemList &i
// no hostname, list all available devices
int target_ip = 0;
struct hdhomerun_discover_device_t result_list[64];
- int count = m_dll.discover_find_devices_custom(target_ip, HDHOMERUN_DEVICE_TYPE_TUNER, HDHOMERUN_DEVICE_ID_WILDCARD, result_list, 64);
+ int count = m_pdll->discover_find_devices_custom(target_ip, HDHOMERUN_DEVICE_TYPE_TUNER, HDHOMERUN_DEVICE_ID_WILDCARD, result_list, 64);
if (count < 0)
return false;
@@ -116,16 +119,16 @@ bool CDirectoryHomeRun::GetDirectory(const CStdString& strPath, CFileItemList &i
}
else
{
- hdhomerun_device_t* device = m_dll.device_create_from_str(url.GetHostName().c_str(), NULL);
+ hdhomerun_device_t* device = m_pdll->device_create_from_str(url.GetHostName().c_str(), NULL);
if(!device)
return false;
- m_dll.device_set_tuner_from_str(device, url.GetFileName().c_str());
+ m_pdll->device_set_tuner_from_str(device, url.GetFileName().c_str());
hdhomerun_tuner_status_t status;
- if(!m_dll.device_get_tuner_status(device, NULL, &status))
+ if(!m_pdll->device_get_tuner_status(device, NULL, &status))
{
- m_dll.device_destroy(device);
+ m_pdll->device_destroy(device);
return true;
}
@@ -141,7 +144,7 @@ bool CDirectoryHomeRun::GetDirectory(const CStdString& strPath, CFileItemList &i
item->SetLabelPreformated(true);
items.Add(item);
- m_dll.device_destroy(device);
+ m_pdll->device_destroy(device);
return true;
}
@@ -155,12 +158,14 @@ bool CDirectoryHomeRun::GetDirectory(const CStdString& strPath, CFileItemList &i
CFileHomeRun::CFileHomeRun()
{
m_device = NULL;
- m_dll.Load();
+ m_pdll = new DllHdHomeRun;
+ m_pdll->Load();
}
CFileHomeRun::~CFileHomeRun()
{
Close();
+ delete m_pdll;
}
bool CFileHomeRun::Exists(const CURL& url)
@@ -202,26 +207,26 @@ int64_t CFileHomeRun::GetLength()
bool CFileHomeRun::Open(const CURL &url)
{
- if(!m_dll.IsLoaded())
+ if(!m_pdll->IsLoaded())
return false;
- m_device = m_dll.device_create_from_str(url.GetHostName().c_str(), NULL);
+ m_device = m_pdll->device_create_from_str(url.GetHostName().c_str(), NULL);
if(!m_device)
return false;
- m_dll.device_set_tuner_from_str(m_device, url.GetFileName().c_str());
+ m_pdll->device_set_tuner_from_str(m_device, url.GetFileName().c_str());
CUrlOptions options(url.GetOptions().Mid(1));
CUrlOptions::iterator it;
if( (it = options.find("channel")) != options.end() )
- m_dll.device_set_tuner_channel(m_device, it->second.c_str());
+ m_pdll->device_set_tuner_channel(m_device, it->second.c_str());
if( (it = options.find("program")) != options.end() )
- m_dll.device_set_tuner_program(m_device, it->second.c_str());
+ m_pdll->device_set_tuner_program(m_device, it->second.c_str());
// start streaming from selected device and tuner
- if( m_dll.device_stream_start(m_device) <= 0 )
+ if( m_pdll->device_stream_start(m_device) <= 0 )
return false;
return true;
@@ -242,7 +247,7 @@ unsigned int CFileHomeRun::Read(void* lpBuf, int64_t uiBufSize)
while(1)
{
datasize = (size_t) uiBufSize;
- uint8_t* ptr = m_dll.device_stream_recv(m_device, datasize, &datasize);
+ uint8_t* ptr = m_pdll->device_stream_recv(m_device, datasize, &datasize);
if(ptr)
{
memcpy(lpBuf, ptr, datasize);
@@ -261,8 +266,8 @@ void CFileHomeRun::Close()
{
if(m_device)
{
- m_dll.device_stream_stop(m_device);
- m_dll.device_destroy(m_device);
+ m_pdll->device_stream_stop(m_device);
+ m_pdll->device_destroy(m_device);
m_device = NULL;
}
}
View
53 xbmc/filesystem/HDHomeRun.h
@@ -21,55 +21,10 @@
*/
#include "IDirectory.h"
-#include "DynamicDll.h"
-#include "lib/libhdhomerun/hdhomerun.h"
#include "IFile.h"
-class DllHdHomeRunInterface
-{
-public:
- virtual ~DllHdHomeRunInterface() {}
- virtual int discover_find_devices_custom(uint32_t target_ip, uint32_t device_type, uint32_t device_id, struct hdhomerun_discover_device_t result_list[], int max_count)=0;
- virtual struct hdhomerun_device_t* device_create_from_str(const char *device_str, struct hdhomerun_debug_t *dbg)=0;
- virtual void device_destroy(struct hdhomerun_device_t *hd)=0;
- virtual int device_stream_start(struct hdhomerun_device_t *hd)=0;
- virtual uint8_t* device_stream_recv(struct hdhomerun_device_t *hd, size_t max_size, size_t* pactual_size)=0;
- virtual void device_stream_stop(struct hdhomerun_device_t *hd)=0;
- virtual int device_set_tuner_channel(struct hdhomerun_device_t *hd, const char *channel)=0;
- virtual int device_set_tuner_program(struct hdhomerun_device_t *hd, const char *program)=0;
- virtual int device_set_tuner_from_str(struct hdhomerun_device_t *hd, const char *tuner_str)=0;
- virtual void device_set_tuner(struct hdhomerun_device_t *hd, unsigned int tuner)=0;
- virtual int device_get_tuner_status(struct hdhomerun_device_t *hd, char **pstatus_str, struct hdhomerun_tuner_status_t *status)=0;
-};
-
-class DllHdHomeRun : public DllDynamic, public DllHdHomeRunInterface
-{
- DECLARE_DLL_WRAPPER(DllHdHomeRun, DLL_PATH_LIBHDHOMERUN)
- DEFINE_METHOD5(int, discover_find_devices_custom, (uint32_t p1, uint32_t p2, uint32_t p3, struct hdhomerun_discover_device_t p4[], int p5))
- DEFINE_METHOD2(struct hdhomerun_device_t*, device_create_from_str, (const char* p1, struct hdhomerun_debug_t *p2))
- DEFINE_METHOD1(void, device_destroy, (struct hdhomerun_device_t* p1))
- DEFINE_METHOD1(int, device_stream_start, (struct hdhomerun_device_t* p1))
- DEFINE_METHOD3(uint8_t*, device_stream_recv, (struct hdhomerun_device_t* p1, size_t p2, size_t* p3))
- DEFINE_METHOD1(void, device_stream_stop, (struct hdhomerun_device_t* p1))
- DEFINE_METHOD2(int, device_set_tuner_channel, (struct hdhomerun_device_t *p1, const char *p2))
- DEFINE_METHOD2(int, device_set_tuner_program, (struct hdhomerun_device_t *p1, const char *p2))
- DEFINE_METHOD2(int, device_set_tuner_from_str, (struct hdhomerun_device_t *p1, const char *p2))
- DEFINE_METHOD2(void, device_set_tuner, (struct hdhomerun_device_t *p1, unsigned int p2))
- DEFINE_METHOD3(int, device_get_tuner_status, (struct hdhomerun_device_t *p1, char **p2, struct hdhomerun_tuner_status_t *p3));
- BEGIN_METHOD_RESOLVE()
- RESOLVE_METHOD_RENAME(hdhomerun_discover_find_devices_custom, discover_find_devices_custom)
- RESOLVE_METHOD_RENAME(hdhomerun_device_create_from_str, device_create_from_str)
- RESOLVE_METHOD_RENAME(hdhomerun_device_destroy, device_destroy)
- RESOLVE_METHOD_RENAME(hdhomerun_device_stream_start, device_stream_start)
- RESOLVE_METHOD_RENAME(hdhomerun_device_stream_recv, device_stream_recv)
- RESOLVE_METHOD_RENAME(hdhomerun_device_stream_stop, device_stream_stop)
- RESOLVE_METHOD_RENAME(hdhomerun_device_set_tuner_channel, device_set_tuner_channel)
- RESOLVE_METHOD_RENAME(hdhomerun_device_set_tuner_program, device_set_tuner_program)
- RESOLVE_METHOD_RENAME(hdhomerun_device_set_tuner_from_str, device_set_tuner_from_str)
- RESOLVE_METHOD_RENAME(hdhomerun_device_set_tuner, device_set_tuner)
- RESOLVE_METHOD_RENAME(hdhomerun_device_get_tuner_status, device_get_tuner_status)
- END_METHOD_RESOLVE()
-};
+struct hdhomerun_device;
+class DllHdHomeRun;
namespace XFILE
{
@@ -81,7 +36,7 @@ namespace XFILE
virtual bool IsAllowed(const CStdString &strFile) const { return true; };
virtual bool GetDirectory(const CStdString& strPath, CFileItemList &items);
private:
- DllHdHomeRun m_dll;
+ DllHdHomeRun* m_pdll;
};
}
@@ -105,6 +60,6 @@ namespace XFILE
virtual int GetChunkSize();
private:
struct hdhomerun_device_t* m_device;
- DllHdHomeRun m_dll;
+ DllHdHomeRun* m_pdll;
};
}
Please sign in to comment.
Something went wrong with that request. Please try again.