#ifndef _GPAC_MEDIA_CONTROLLER_H_
#define _GPAC_MEDIA_CONTROLLER_H_
#include "PltMediaServer.h"
#include "PltMediaController.h"
#include "PltMediaBrowser.h"
#include "NptMap.h"
#include "NptStack.h"
#include <gpac/thread.h>
typedef struct {
NPT_SharedVariable shared_var;
NPT_Result res;
PLT_BrowseInfo info;
} GPAC_BrowseData;
class GPAC_MediaRendererItem
{
public:
GPAC_MediaRendererItem(PLT_DeviceDataReference device, NPT_String uuid) : m_device(device), m_UUID(uuid) { }
PLT_DeviceDataReference m_device;
NPT_String m_UUID;
};
class GPAC_MediaServerItem
{
public:
GPAC_MediaServerItem(PLT_DeviceDataReference device, NPT_String uuid) : m_device(device), m_UUID(uuid) , m_BrowseResults(NULL) { }
PLT_DeviceDataReference m_device;
NPT_String m_UUID;
PLT_MediaObjectListReference m_BrowseResults;
NPT_Stack<NPT_String> m_ParentDirectories;
};
typedef NPT_Reference<GPAC_BrowseData> GPAC_BrowseDataReference;
class GF_UPnP;
class GPAC_MediaController : public PLT_CtrlPointListener,
public PLT_MediaControllerDelegate,
public PLT_MediaBrowserDelegate
{
public:
GPAC_MediaController(PLT_CtrlPointReference& ctrlPoint, GF_UPnP *upnp);
~GPAC_MediaController();
virtual NPT_Result OnDeviceAdded(PLT_DeviceDataReference& device)
{
return NPT_SUCCESS;
}
virtual NPT_Result OnDeviceRemoved(PLT_DeviceDataReference& device)
{
return NPT_SUCCESS;
}
virtual NPT_Result OnActionResponse(NPT_Result res,
PLT_ActionReference& action,
void* userdata);
virtual NPT_Result OnEventNotify(PLT_Service* service, NPT_List<PLT_StateVariable*>* vars);
virtual bool OnMRAdded(PLT_DeviceDataReference& device);
virtual void OnMRRemoved(PLT_DeviceDataReference& device);
virtual void OnMRStateVariablesChanged(PLT_Service* , NPT_List<PLT_StateVariable*>* );
virtual bool OnMSAdded(PLT_DeviceDataReference& device);
virtual void OnMSRemoved(PLT_DeviceDataReference& device);
virtual void OnMSStateVariablesChanged(PLT_Service *service, NPT_List<PLT_StateVariable*>* vars);
virtual void OnBrowseResult(NPT_Result res,
PLT_DeviceDataReference& device,
PLT_BrowseInfo* info,
void* userdata);
NPT_Result Browse(GPAC_MediaServerItem *server, const char *id, const char *filter);
GF_List *m_MediaRenderers;
GF_List *m_MediaServers;
PLT_MediaController* m_MediaController;
PLT_MediaBrowser *m_MediaBrowser;
protected:
NPT_Result Browse(GPAC_BrowseDataReference& browse_data,
PLT_DeviceDataReference& device,
const char* object_id,
NPT_Int32 index,
NPT_Int32 count,
bool browse_metadata = false,
const char* filter = "*",
const char* sort = "");
private:
NPT_Result WaitForResponse(NPT_SharedVariable& shared_var);
GF_UPnP *m_pUPnP;
GF_Mutex *m_ControlPointLock;
};
#endif